Datasets:
Add files using upload-large-folder tool
Browse files- md/dev/-P7G-8dmSh4/-P7G-8dmSh4.md +452 -0
- md/dev/0Q6BzWbvg0P/0Q6BzWbvg0P.md +482 -0
- md/dev/1QQnYd02etI/1QQnYd02etI.md +280 -0
- md/dev/2PSrjVtj6gU/2PSrjVtj6gU.md +404 -0
- md/dev/2hMEdc35xZ6/2hMEdc35xZ6.md +452 -0
- md/dev/3jooF27-0Wy/3jooF27-0Wy.md +618 -0
- md/dev/3mRwyG5one/3mRwyG5one.md +387 -0
- md/dev/45L_dgP48Vd/45L_dgP48Vd.md +410 -0
- md/dev/4oXTQ6m_ws8/4oXTQ6m_ws8.md +363 -0
- md/dev/6at6rB3IZm/6at6rB3IZm.md +302 -0
- md/dev/9-umxtNPx5E/9-umxtNPx5E.md +488 -0
- md/dev/A6X9y8n4sT/A6X9y8n4sT.md +308 -0
- md/dev/ATiz_CDA66/ATiz_CDA66.md +315 -0
- md/dev/B72HXs80q4/B72HXs80q4.md +354 -0
- md/dev/Bl8CQrx2Up4/Bl8CQrx2Up4.md +393 -0
- md/dev/Bq2-WN5csW/Bq2-WN5csW.md +423 -0
- md/dev/FjqBs4XKe87/FjqBs4XKe87.md +359 -0
- md/dev/H4DqfPSibmx/H4DqfPSibmx.md +444 -0
- md/dev/HtoA0oT30jC/HtoA0oT30jC.md +525 -0
- md/dev/IDwN6xjHnK8/IDwN6xjHnK8.md +545 -0
- md/dev/JTmO2V9Xpz/JTmO2V9Xpz.md +340 -0
- md/dev/K0E_F0gFDgA/K0E_F0gFDgA.md +0 -0
- md/dev/Ms6QZafNv01/Ms6QZafNv01.md +493 -0
- md/dev/NPJznfA7ZC/NPJznfA7ZC.md +284 -0
- md/dev/OpC-9aBBVJe/OpC-9aBBVJe.md +390 -0
- md/dev/Q42f0dfjECO/Q42f0dfjECO.md +446 -0
- md/dev/Qg2vi4ZbHM9/Qg2vi4ZbHM9.md +472 -0
- md/dev/RRGVCN8kjim/RRGVCN8kjim.md +349 -0
- md/dev/TQ75Md-FqQp/TQ75Md-FqQp.md +0 -0
- md/dev/URNZQmbxpwh/URNZQmbxpwh.md +0 -0
- md/dev/UYS38ssi1M/UYS38ssi1M.md +442 -0
- md/dev/VnurXbqxr0B/VnurXbqxr0B.md +0 -0
- md/dev/XSEBx0iSjFQ/XSEBx0iSjFQ.md +374 -0
- md/dev/XVjTT1nw5z/XVjTT1nw5z.md +0 -0
- md/dev/XcDVT8HarS/XcDVT8HarS.md +0 -0
- md/dev/XzTtHjgPDsT/XzTtHjgPDsT.md +479 -0
- md/dev/ZTK3SefE8_Z/ZTK3SefE8_Z.md +443 -0
- md/dev/akddwRG6EGi/akddwRG6EGi.md +416 -0
- md/dev/eLxADkHrBcR/eLxADkHrBcR.md +245 -0
- md/dev/g3faCfrwm7/g3faCfrwm7.md +167 -0
- md/dev/lq62uWRJjiY/lq62uWRJjiY.md +416 -0
- md/dev/oMI9PjOb9Jl/oMI9PjOb9Jl.md +360 -0
- md/dev/r9b6T088_75/r9b6T088_75.md +347 -0
- md/dev/sc7bBHAmcN/sc7bBHAmcN.md +329 -0
- md/dev/tZXaHWfsXB/tZXaHWfsXB.md +376 -0
- md/dev/tZmqS73_07/tZmqS73_07.md +574 -0
- md/dev/tjFaqsSK2I3/tjFaqsSK2I3.md +233 -0
- md/dev/vhKaBdOOobB/vhKaBdOOobB.md +292 -0
- md/dev/wiBEFdAvl8L/wiBEFdAvl8L.md +309 -0
- md/dev/x5mtJD2ovc/x5mtJD2ovc.md +430 -0
md/dev/-P7G-8dmSh4/-P7G-8dmSh4.md
ADDED
|
@@ -0,0 +1,452 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# FORMAL MATHEMATICS STATEMENTCURRICULUM LEARNING
|
| 2 |
+
|
| 3 |
+
Stanislas Polu OpenAI
|
| 4 |
+
|
| 5 |
+
Jesse Michael Han† Multi Technologies
|
| 6 |
+
|
| 7 |
+
Kunhao Zheng École Polytechnique
|
| 8 |
+
|
| 9 |
+
Mantas Baksys University of Cambridge
|
| 10 |
+
|
| 11 |
+
Igor Babuschkin† DeepMind
|
| 12 |
+
|
| 13 |
+
Ilya Sutskever OpenAI
|
| 14 |
+
|
| 15 |
+
# ABSTRACT
|
| 16 |
+
|
| 17 |
+
We explore the use of expert iteration in the context of language modeling applied to formal mathematics. We show that at same compute budget, expert iteration, by which we mean proof search interleaved with learning, dramatically outperforms proof search only. We also observe that when applied to a collection of formal statements of sufficiently varied difficulty, expert iteration is capable of finding and solving a curriculum of increasingly difficult problems, without the need for associated ground-truth proofs. Finally, by applying this expert iteration to a manually curated set of problem statements, we surpass previous state-of-the-art on the miniF $2 F$ benchmark, automatically solving multiple challenging problems drawn from high school olympiads.
|
| 18 |
+
|
| 19 |
+
# 1 INTRODUCTION
|
| 20 |
+
|
| 21 |
+
Deep learning has enjoyed spectacular success in many domains, including language (Brown et al., 2020; Devlin et al., 2019; Wu et al., 2016), vision (Radford et al., 2021; Tan & Le, 2019), and image generation (Ramesh et al., 2021; Karras et al., 2019). One domain where deep learning has not yet enjoyed a comparable success is in tasks that require extensive planning and symbolic reasoning, with the exception of two-player games (Silver et al., 2016; 2017; Berner et al., 2019; Vinyals et al., 2019). In such games, deep learning systems exhibit a considerable degree of reasoning, especially when trained with self-play combined with a search procedure such as Monte Carlo Tree Search (MCTS) (Browne et al., 2012). But the resulting reasoning abilities achieved are limited due to the relatively narrow scope of games.
|
| 22 |
+
|
| 23 |
+
As such, theorem proving in interactive proof assistants, or formal mathematics, appears as an interesting game-like domain to tackle due to its increased scope. The typical tasks consist of generating a machine-checkable proof given a formal statements. Like games, formal mathematics has an automated way of determining whether a trajectory (i.e. a proof) is successful (i.e. formally correct). But the vast scope of formal mathematics means that any strong reasoning result obtained in it will be more meaningful than comparable results in games (e.g. finding proofs to mathematical conjectures), and could even be applicable to important practical problems (e.g. software verification).
|
| 24 |
+
|
| 25 |
+
However, tackling formal mathematics involves two main challenges that we must address in order to continue making progress:
|
| 26 |
+
|
| 27 |
+
Infinite action space Not only does formal mathematics have an extremely large search space (like Go (Silver et al., 2016) for example), it also has an infinite action space. At each step of proof search, the model must choose not from a well-behaved finite set of actions, but a complex and infinite set of tactics, potentially involving exogenous mathematical terms that have to be generated (e.g., generating a mathematical statement to be used as a witness, an object used steps such as “there exists an x ...”, or a cut, the introduction and the chaining of a lemma in the middle of a proof).
|
| 28 |
+
|
| 29 |
+
No direct self-play setup In formal mathematics, a prover is not playing against an opponent but against a set of statements to prove. When faced with a statement that is just too hard, there is no obvious reframing of the formal mathematics setup that will let the prover generate intermediary easier statements to tackle first. This asymmetry prevents naive application of the symmetric self-play algorithms commonly used in 2-player games.
|
| 30 |
+
|
| 31 |
+
These two differences make a naive application of reinforcement learning to formal mathematics leave a large room for improvement (Whalen, 2016; Winands et al., 2008). Past work proposed to address the infinite action space problem by sampling from a language model (Polu & Sutskever, 2020), while training such language model requires a large dataset of statements with proof. This paper focuses on this second problem and our basis for addressing it is the observation that the key role of self-play is to provide an unsupervised curriculum. We propose instead to supply auxiliary sets of problem statements (without requiring proofs) of varying difficulty. We empirically show that, when the difficulty of these auxiliary problems is varied enough, a simple expert iteration procedure is able to solve a curriculum of increasingly difficult problems, eventually generalizing to our target distribution. We show that this works with both automatically-generated and manually-curated auxiliary distributions of problems and leverage this to achieve state-of-the-art on the miniF2F benchmark. Our results suggest that continuous self-improvement in formal mathematics can potentially be reduced to the problem of generating such sets of formal statements, which we have done in part manually in this work, but could eventually be scaled in the future with more automation (such as more domain-specific statements generator or even informal to formal machine translation).
|
| 32 |
+
|
| 33 |
+
miniF2F benchmark In this work, we target the miniF $2 F$ (Zheng et al., 2022) benchmark, which consists of 244 validation and 244 test formalized statements of mathematical problems from various competitions. We believe it to be a better measure of mathematical reasoning compared to a formal library-derived split. Also, the extreme scarcity in formal libraries of this type of problems makes it an ideal test-bed for the expert iteration methodology studied in this paper.
|
| 34 |
+
|
| 35 |
+
# 2 RELATED WORK
|
| 36 |
+
|
| 37 |
+
Our work strongly relies on, and can be seen as a natural continuation of the work presented in the original GPT-f paper (Polu & Sutskever, 2020) which studies the use of language models to generate tactics, the PACT paper (Han et al., 2022) which applies GPT-f to Lean and studies the benefits from co-training on self-supervised objectives, and the miniF2F benchmark (Zheng et al., 2022). We present additional related work in Appendix A.
|
| 38 |
+
|
| 39 |
+
# 3 FORMAL ENVIRONMENT
|
| 40 |
+
|
| 41 |
+
We choose Lean (de Moura et al., 2015; lea) as our formal environment. Unlike Metamath (Megill & Wheeler, 2019) , which has been studied in the original GPT-f paper (Polu & Sutskever, 2020), Lean benefits from high-level tactics which were shown to be beneficial in the context of the miniF2F benchmark. Also, Lean has recently received a lot of attention from the mathematical community, thanks to projects such as the Perfectoid Spaces (Buzzard et al., 2019) and the Liquid Tensor experiment (Scholze, 2020), and benefits from a vibrant community of hundreds of contributors to its main mathematical library called mathlib. We refer to the PACT paper’s Background section (Han et al., 2022) for a detailed introduction to Lean in the context of neural theorem proving. We refer to Appendix D for an illustration of miniF2F input and Lean environment.
|
| 42 |
+
|
| 43 |
+
lean-gym In the PACT paper (Han et al., 2022), proof search is performed by the Lean runtime using the LEANSTEP environment, with a generic backend interface to models. While easy to use–one just needs to plug in their model–this approach makes it difficult to alter and iterate on the search procedure because it is programmed in Lean (which is not designed or intended for cluster-wide parallelised I/O intensive tasks), and the coupling of the search procedure with the Lean runtime introduces challenges when scaling to a large number of parallel workers.
|
| 44 |
+
|
| 45 |
+
To solve these issues we implemented lean-gym1 – a simple REPL interface over the standard input/output implemented in Lean directly. We present lean-gym’s API and discuss some of its advantages and limitations in Appendix B.
|
| 46 |
+
|
| 47 |
+
Proof extraction We rely on the proof extraction methodology presented in the PACT paper (Han et al., 2022) to extract human tactic proof steps from mathlib (the tactic dataset) as well as the various other proof artifacts $( \mathsf { m i x } 1$ and $\mathfrak { m i x 2 }$ datasets). We also extract mathlib-{train, valid, test}, the set of statements from mathlib along the split proposed in Han et al. (2022) (the validation and test splits of tactic, mix1, mix2 being aligned with mathlib-{valid, test} as the splits are determined by declaration name hashes (across all data sources including proof-term mining) as opposed to individual proof steps or data-points.
|
| 48 |
+
|
| 49 |
+
# 4 EXPERT ITERATION
|
| 50 |
+
|
| 51 |
+
Expert iteration was introduced in Silver et al. (2017) and broadly consists in iteratively training models on their previously sampled trajectories, to achieve continuous improvement. In this section we present our expert iteration methodology, including the models and pre-training strategies. We use decoder-only Transformers similar to GPT-3 (Brown et al., 2020). Throughout this paper we focus on a model with 36 layers and 774 million trainable parameters (referred to as the 700m model in the GPT-f paper (Polu & Sutskever, 2020)).
|
| 52 |
+
|
| 53 |
+
# 4.1 PRE-TRAINING
|
| 54 |
+
|
| 55 |
+
We pre-train our models successively on GPT-3’s post-processed version of CommonCrawl (for 300B tokens) and an updated version of WebMath (Polu & Sutskever, 2020) (for 72B tokens) whose mix is presented in Appendix C.
|
| 56 |
+
|
| 57 |
+
# 4.2 TRAINING OBJECTIVES
|
| 58 |
+
|
| 59 |
+
Proofstep objective The proofstep objective, introduced in Polu & Sutskever (2020), consists in generating a PROOFSTEP (a Lean tactic) given a GOAL (a Lean tactic state). We also condition this objective on the current DECLARATION (a Lean theorem name), which remains the same throughout a proof search: DECL <DECLARATION> GOAL <GOAL> PROOFSTEP <PROOFSTEP>.
|
| 60 |
+
|
| 61 |
+
The rationale for conditioning on the declaration name is to hint our models on the position of the current declaration in the mathlib library. It can be considered as a weak proxy signal for the large amount of information not shown to the model (the full environment consisting of the available imports and currently open declarations such as module names, notations, declared instances, ...). The declaration name lets models at least in principle memorize and then retrieve some of that information, knowing that lean-gym errors if a theorem or definition that is not available in the environment associated with the current declaration is used by tactics generated by our models. Also note that conversely to Polu & Sutskever (2020) and like Han et al. (2022) ${ < } G O A L >$ is not necessarily a single goal but a Lean tactic state, which possibly comprises multiple goals.
|
| 62 |
+
|
| 63 |
+
Proofsize objective We depart from Polu & Sutskever (2020) and use a proofsize objective to guide our proof searches, which consists in generating one token that represents a proof size estimate bucket for the current goal (Lean tactic state): DECL <DECLARATION> GOAL ${ < } G O A L >$ PROOFSIZE <PROOFSIZE_BUCKET_TOKEN>
|
| 64 |
+
|
| 65 |
+
For a given goal $g$ , either the goal was proved as part of the proof search and we denote its proof size (the number of tactic applications (compounded Lean tactics counting as one)) as $p s ( g )$ , or the goal was not proved in which case we assign the goal to a bucket that virtually represents "infinite" proof sizes.
|
| 66 |
+
|
| 67 |
+
We use 11 buckets $B = 0 . . . 1 0$ and compute the proofsize bucket $b ( g )$ for a goal $g$ by assigning infinite proof sizes to bucket 0, all proof sizes over 20 to bucket 1 and linearly projecting proof sizes lower than 20 on the remaining buckets $2 , . . . , 1 0$ (10 being the bucket for the shortest proof sizes). In practice, when training and sampling from the model, we map $B$ to the tokens $\therefore \mathrm { A \Omega } . . . \mathrm { K \Omega }$ .
|
| 68 |
+
|
| 69 |
+
To value goals as we run proof searches, we sample the proofsize bucket token and record the probability $p _ { b } ( g )$ for each viable bucket and use them to get a weighted average with the following formula: $\begin{array} { r } { \dot { v } ( \dot { g } ) = \frac { 1 } { \# B } \sum _ { b \in B } p _ { b } ( g ) \cdot b } \end{array}$ . As an example, if the model assigns $p _ { 0 } = 1$ (hence $p _ { b \neq 0 } = 0$ ) then $v ( g ) = 0$ . Conversely if the model assigns $p _ { 1 0 } = 1$ (10 being the bucket for the shortest proof sizes) then $v ( g ) = 1$ .
|
| 70 |
+
|
| 71 |
+
Table 1: Performance of $\theta _ { 0 }$ and $\theta _ { 1 }$ on mathlib-valid and miniF $_ { 2 F }$ -valid compared to PACT Lean GPT-f as reported in Han et al. (2022); Zheng et al. (2022). All models have the same architecture. $\theta _ { 0 }$ is sampled using cumulative logprob priority best-first search. $\theta _ { 1 }$ is sampled using best-first search based on the proofsize objective. We report our setup $d = 5 1 2$ expansions and $e = 8$ tactic samples per expansions) as well as the setups used in Han et al. (2022); Zheng et al. (2022) (denoted as $\theta _ { 0 } ^ { * }$ ) to control for compute. We also report the performance of $\theta _ { 1 }$ on mathlib-valid when trained using the outcome objective (denoted as $\theta _ { 1 } ^ { \prime }$ ) from Polu & Sutskever (2020) as an ablation of our proposed proofsize objective.
|
| 72 |
+
|
| 73 |
+
<table><tr><td>Model</td><td>d</td><td>e</td><td>pass@1</td><td>pass@8</td></tr><tr><td>mathlib-valid</td><td></td><td></td><td></td><td></td></tr><tr><td>PACT</td><td>512</td><td>16</td><td>48.4%</td><td></td></tr><tr><td>0</td><td>512</td><td>16</td><td>48.5%</td><td>57.6%</td></tr><tr><td>0</td><td>512</td><td>8</td><td>46.7%</td><td>57.5%</td></tr><tr><td>01</td><td>512</td><td>8</td><td>56.3%</td><td>66.3%</td></tr><tr><td>0</td><td>512</td><td>8</td><td>55.6%</td><td>65.9%</td></tr></table>
|
| 74 |
+
|
| 75 |
+
<table><tr><td>Model</td><td>d</td><td>e</td><td>pass@1</td><td>pass@8</td></tr><tr><td colspan="3">miniF2F-valid</td><td></td><td></td></tr><tr><td>miniF2F</td><td>128</td><td>16</td><td>23.9%</td><td>29.3%</td></tr><tr><td></td><td>128</td><td>16</td><td>27.6%</td><td>31.8%</td></tr><tr><td>0</td><td>512</td><td>8</td><td>28.4%</td><td>33.6%</td></tr><tr><td>01</td><td>512</td><td>8</td><td>28.5%</td><td>35.5%</td></tr><tr><td>0</td><td>512</td><td>8</td><td>28.3%</td><td>34.7%</td></tr></table>
|
| 76 |
+
|
| 77 |
+
The rationale for using this proofsize objective instead of the outcome objective described in Polu & Sutskever (2020) is that (i) it achieves better performance compared to the outcome objective (see Table 1), and (ii) it prioritizes goals that potentially lead to shorter proofs during proof search, creating an intrinsic incentive for the system to converge towards shorter proofs. Similarly to Polu & Sutskever (2020) we favor this token-based approach to the introduction of a separate value head to keep the overall architecture simple. This way the proofsize objective can be implemented by simply augmenting the training dataset and without any architectural change.
|
| 78 |
+
|
| 79 |
+
# 4.3 BOOTSTRAPPING
|
| 80 |
+
|
| 81 |
+
Bootstrapping consists in the steps required to train an initial model on both the proofstep objective and the proofsize objective.
|
| 82 |
+
|
| 83 |
+
Given a pre-trained model on WebMath, we fine-tune it on the tactic dataset extracted from mathlib as well as the proof artifacts dataset mix1 as described in Han et al. (2022). This initial model, which we denote $\theta _ { 0 }$ is solely trained on the proofstep objective. We use the validation splits of the tactic and m1 datasets to early-stop training. Note that this is our only use of mathlib-valid to influence the training process throughout this paper.
|
| 84 |
+
|
| 85 |
+
To generate data for the proofsize objective, we use $\theta _ { 0 }$ to sample proofs for statements from mathlibtrain. For each statement from mathlib-train (25k) we attempt $a = 1$ proof searches using the cumulative logprob priority search described in Polu & Sutskever (2020) (which does not require a trained value function) using $d = 5 1 2$ expansions and $e = 8$ samples per expansion. We denote the set of successful proof searches created in this process as $S _ { 0 }$ .
|
| 86 |
+
|
| 87 |
+
Using $S _ { 0 }$ we generate dataset $D _ { 0 }$ by concatenating: (i) the initial tactic dataset (proofstep objective), (ii) a deduplicated set of proofsteps extracted from the proofs in $S _ { 0 }$ (proofstep objective) and (iii) a deduplicated set of proofsize tuples (goals and proofsize) extracted from the full proof searches in $S _ { 0 }$ (proofsize objective).
|
| 88 |
+
|
| 89 |
+
Note that the full proof searches in $S _ { 0 }$ include goals that are visited but eventually remain unproved, which provides useful negative examples for the trained value function (even if these negatives may include provable goals that simply were not prioritized by the search). Also note that $S _ { 0 }$ doesn’t include failed proof searches.
|
| 90 |
+
|
| 91 |
+
We fine-tune $\theta _ { 0 }$ on $D _ { 0 }$ for exactly one epoch (no use of validation data for early-stopping) to obtain our initial model $\theta _ { 1 }$ trained on both the proofstep objective and the proofsize objective. $\theta _ { 0 }$ is used in our expert iteration setup as base model to fine-tune from at each iteration, and $\theta _ { 1 }$ is our first iterated model or mathlib bootstrapped model trained on both objectives.
|
| 92 |
+
|
| 93 |
+
We report in Table 1 the pass rates of $\theta _ { 0 }$ and $\theta _ { 1 }$ on mathlib-valid and miniF2F-valid and compare with previously reported pass rates for equivalent amounts of compute. As reported in Polu & Sutskever (2020), training a value function to guide search greatly improves the pass rates of $\theta _ { 1 }$ on mathlib-valid.
|
| 94 |
+
|
| 95 |
+
Interestingly, the gap between $\theta _ { 0 }$ and $\theta _ { 1 }$ on miniF ${ } ^ { 7 2 F }$ -valid is not as significant, demonstrating that training a value function on proofs sampled from mathlib-train has limited transfer to miniF2F-valid. The main differences with Zheng et al. (2022), potentially explaining the gap on miniF2F-valid $( 2 7 . 6 \%$ vs $2 3 . 9 \%$ ), consists in the new pre-training described in Section 4.1 as well as the use of a more recent mathlib checkpoint for the mix1, mix2 and tactic datasets.
|
| 96 |
+
|
| 97 |
+
# 4.4 ITERATED SAMPLING AND TRAINING
|
| 98 |
+
|
| 99 |
+
Our expert iteration process takes as input: (i) a set of formal statements $S t$ , (ii) a function $a : S t \mathbb { N }$ indicating the number of proof search attempts to run per statement at each iteration, (iii) a base model $\theta _ { 0 }$ to fine-tune from at each iteration, and (iv) a mathlib bootstrapped model $\theta _ { 1 }$ trained on both objectives. A high-level illustration of the iterated sampling and training is available in Appendix E.
|
| 100 |
+
|
| 101 |
+
Each iteration $k$ consists in sampling proof searches for statements in $S t$ using $\theta _ { k }$ , filtering successful proof searches $S _ { k }$ to extract a new dataset $D _ { k }$ , and fine-tuning $\theta _ { 0 }$ on it to obtain $\theta _ { k + 1 }$ , on which we can iterate. To sample proof searches from $S t$ we use the best-first search described in Polu $\&$ Sutskever (2020) with the value function described in Section 4.2. We attempt $a$ proof searches for each statement $s ( s \in S t )$ with $d = 5 1 2$ expansions and $e = 8$ samples per expansion. We denote the set of successful proof searches for iteration $k$ as $S _ { k }$ .
|
| 102 |
+
|
| 103 |
+
Using $S _ { k }$ we generate datasets $D _ { k }$ by concatenating: (i) the initial tactic dataset (proofstep objective), (ii) a deduplicated set of proofsteps extracted from the proofs in $\textstyle \bigcup _ { 1 \leq i \leq k } { \bar { S } } _ { k }$ (proofstep objective), and (iii) a deduplicated set of proofsize tuples (goals and proofsize) extracted from the full proof searches in $\textstyle \bigcup _ { 1 \leq i \leq k } S _ { k }$ (proofsize objective).
|
| 104 |
+
|
| 105 |
+
We use a global deduplication across iterations for both proofsteps and proofsize tuples which we found to be important to maintain the stability of the expert iteration procedure. This global deduplication is somewhat equivalent for each statement to growing a unique proof tree by aggregating all the proof searches that have been run for it across iterations. This virtual proof tree accumulates a growing number of positive proof paths and visited goals that remain unproven. We use these goals as negative examples for the proofsize objective, labeling them with an infinite proofsize. Positive goals are deduplicated keeping the minimum proof sizes across proof searches.
|
| 106 |
+
|
| 107 |
+
Finally $\theta _ { k }$ is obtained by fine-tuning $\theta _ { 0 }$ for exactly one epoch on $D _ { k }$ . Note that the initial tactic dataset is included in each $D _ { k }$ , despite $\theta _ { 0 }$ being already trained on it (along with mix1). We found this repetition to be beneficial overall (as it adds the mathlib extracted proofsteps to our deduplicated per statements virtual proof trees) despite it leading to a slight overfit on the tactic dataset in terms of validation loss.
|
| 108 |
+
|
| 109 |
+
# 4.5 EXPERT ITERATION ON mathlib-train
|
| 110 |
+
|
| 111 |
+
In this section we propose to set $S t$ to the statements in mathlib-train, run our expert iteration process with it and report performance on both mathlib-valid and miniF2F-valid. Performance is reported in terms of pass rate (percentage of successful proof searches) as a function of the number of attempts per statement, noted pass $@ k$ where $k$ is the number of attempts per statement at test time. To reduce noise in these metrics we run more than $k$ attempts at test time (generally 32 to compute pass@1 and $p a s s @ 8 )$ ), averaging across attempts as needed to obtain a smoother pass $@ k$ value.
|
| 112 |
+
|
| 113 |
+
Given the large number of statements in mathlib-train (25k) we uniformly set $a = 1$ and use $\theta _ { 0 }$ and $\theta _ { 1 }$ as described in Section 4.3 and report pass $@ l$ and pass $@ 8$ across 8 iterations in Figure 1. The pass $@ l$ on mathlib-valid goes from $5 6 . 3 \%$ for $\theta _ { 1 }$ to $6 2 . 6 \%$ for $\theta _ { 9 }$ . The performance steadily improves and follows a clear logarithmic scaling law on mathlib-valid. It is also notable that, initially, transfer to out-of-distribution miniF2F-valid appears limited but eventually kicks in as we reach better performance on mathlib-valid. This demonstrates that the expert iteration process does not just overfit to mathlib but also leads to improved performance on out-of-distribution statements.
|
| 114 |
+
|
| 115 |
+
We define the cumulative pass rate at iteration $k$ as the pass rate consisting of all proof searches up to iteration $k$ . Since we set $a = 1 6$ for evaluation on mathlib-valid and miniF $2 F$ -valid at each iteration, the cumulative pass rate at iteration $k$ can be seen as a noisy ensembled pass@16k (multiple models $( \theta _ { k } )$ , no averaging). In Figure 2, we report this cumulative pass rate for two iteration loops, our normal one and a sampling-only loop where we skip re-training the model between iterations and solely sample from $\theta _ { 1 }$ . This directly compares test-time compute scaling (scaling proof search attempts) to expert iteration scaling (interleaved training on new data sampled from mathlib-train) and provides a very clear visualization of the gains of expert iteration. For a fair comparison, we also report an adjusted compute line which approximates the test-time performance we would get at each iteration if we were to focus all the additional compute used by expert iteration (sampling proofs from mathlib-train as well as re-training models at each iteration) towards solely running proof searches against mathlib-valid.
|
| 116 |
+
|
| 117 |
+

|
| 118 |
+
Figure 1: pass@1 (plain) and pass $@ 8$ (dotted) for mathlib-valid and miniF $2 F$ -valid when running 8 expert iterations with $S t$ set to be the statements in mathlib-train. The $\mathbf { X }$ -axis is logscaled. It corresponds to the indices of the $\theta _ { k }$ models and serves as a good proxy to compute (the amount of test-time and train-time compute per iteration being fixed). The y-axis is scaled linearly and simply shifted between the two graphs (spans an equal range).
|
| 119 |
+
|
| 120 |
+

|
| 121 |
+
Figure 2: Cumulative pass rate for our expert iteration loop as well as a sample only loop where we skip re-training the model between iterations. The adjusted compute line is computed by fitting the sample only curve and shifting it to approximate a setup where we would focus all the additional compute used by expert iteration (sampling training data from mathlib-train as well as re-training models at each iteration) towards running proof searches against mathlibvalid.
|
| 122 |
+
|
| 123 |
+
As shown by Figure 2, the scaling exponent of expert iteration is substantially higher than the scaling exponent associated with solely scaling test-time compute (running more proof searches), demonstrating the clear benefit of expert iteration. We’ll denote the fully iterated model from this section as θmathlib9 .
|
| 124 |
+
|
| 125 |
+
Even in the presence of ground-truth proofs for each of the statements in mathlib-train (tactic dataset), expert iteration generates data that further improves the performance of the model. The number of statements proved in mathlib-train goes from 17390 $( 6 7 . 8 \% )$ at iteration 1 to 19476 $( 7 6 . 0 \% )$ at iteration 9, while the average proof length of these statements goes from 4.8 to 4.0. We hypothesize that this continuously improving performance through expert iteration stems from two effects: (i) the model finding new original proofs for the same statements and (ii) the model closing marginally harder statements at each iteration – which in turn provides more useful training data for the next iteration. By iteration 9, the model is trained on more than $9 0 \%$ generated data. We present in Appendix I a few examples of original proofs found by our models on mathlib-train compared with their ground-truth versions.
|
| 126 |
+
|
| 127 |
+
To verify our hypothesis that expert iteration is capable of closing a curriculum of increasingly difficult problems out of a set of problem statements, and that this capability is independent of having access to ground-truth proofs, we propose in the next section to study expert iteration applied to a synthetically generated set of problems for which we have fine-grained control on the difficulty of each statement.
|
| 128 |
+
|
| 129 |
+
# 5 STATEMENT CURRICULUM LEARNING
|
| 130 |
+
|
| 131 |
+
In this section we focus on running expert iteration on synthetic statements generated by an inequality generator. The use of synthetic statements enables us to control the difficulty of each statement to present evidence that expert iteration can hill-climb the intrinsic difficulty gradient of the resulting set
|
| 132 |
+
|
| 133 |
+
of statements. In particular, we show that, at fixed compute budget, expert iteration eventually closes proofs of hard statements that remain completely out of reach of simply sampling proof searches without interleaved training.
|
| 134 |
+
|
| 135 |
+
# 5.1 SYNTHETIC INEQUALITY GENERATOR
|
| 136 |
+
|
| 137 |
+
We designed a synthetic inequality statement generator for Lean in the spirit of the INT (Wu et al., 2021) generator. The generator consists in generating inequalities from well known inequality theorems (AM-GM, Trivial inequality, Cauchy-Schwarz, Bernoulli, Young, Hölder) and composing them. It is driven by two difficulty parameters: $N _ { D }$ which controls depth of composition of inequalities and $N _ { S }$ which controls the complexity of the input expressions to the composed inequalities. We provide details on its implementation in Appendix F.
|
| 138 |
+
|
| 139 |
+
Using this generator we generate a curriculum of 5600 inequality statements (for which we don’t have proofs), 100 for each values of $0 \le N _ { S } \le 7$ and $0 \le N _ { D } \le 6$ . We denote this set of statements as synth-ineq. To bootstrap our models capabilities on this specific task, we also generate 100 statements of low difficulty ( $N _ { D } = 1$ and $N _ { S } = 5$ ) and formalize a proof for each of these statements. We refer to this dataset as synth-ineq-train. In the rest of this paper we adjunct this training dataset to the tactic dataset used to train our models.
|
| 140 |
+
|
| 141 |
+
# 5.2 EXPERT ITERATION ON SYNTHETIC INEQUALITY STATEMENTS
|
| 142 |
+
|
| 143 |
+
In this section we propose to set $S t$ to the union of the statements in mathlib-train and synth-ineq. Again, we uniformly set $a = 1$ and use $\theta _ { 0 }$ and $\theta _ { 1 }$ as described in Section 4.3, except that they are now also trained on synth-ineq-train.
|
| 144 |
+
|
| 145 |
+
Similarly to the previous section, we report in Figure 3 the cumulative pass rate for two loops, our standard expert iteration loop, and a proof search only loop where we do not interleave training between iterations. The pass rates are reported split by values of $N _ { D }$ (pooling together $0 \le N _ { S } \le 7$ ) which we found to be the main driver for difficulty.
|
| 146 |
+
|
| 147 |
+

|
| 148 |
+
Figure 3: Cumulative pass rate for our expert iteration loop as well as a sample only loop where we skip re-training the model between iterations. Pass rates are reported for each value of $N _ { D }$ (pooling together $0 \le N _ { S } \le 7$ ).
|
| 149 |
+
|
| 150 |
+
Despite the challenging nature of these synthetic inequalities, Figure 3 demonstrates that expert iteration is capable of learning the intrinsic curriculum induced by synth-ineq. In particular, expert iteration is capable of closing 6 problems of difficulty $N _ { D } = 6$ without having been provided with any seed ground-truth proof for this difficulty level. Note that difficulty $N _ { D } = 6$ remains completely out of reach of simply scaling the number of attempts per statements (the sample only loop remaining stuck at 0 for $N _ { D } = 6$ ).
|
| 151 |
+
|
| 152 |
+
This confirms on our synthetic statements dataset synth-ineq that not only expert iteration is capable of learning the curricula occurring in a set of statements, but this process also enables the emergence of new capabilities without the need for ground-truth proofs (ability to close, highly challenging, deeply composed inequalities).
|
| 153 |
+
|
| 154 |
+
# 6 TARGETING miniF2F
|
| 155 |
+
|
| 156 |
+
Motivated by the results from Section 5, we curated and manually formalized a set of math exercises denoted as miniF $2 F$ -curriculum to target miniF2F. miniF $2 F$ -curriculum contains 327 statements from various sources, with their provenance and analysis detailed in Appendix G.
|
| 157 |
+
|
| 158 |
+
miniF $2 F$ statements being quite out of distribution compared to mathlib statements (which typically are generic theorems and lemmas), we hypothesized that if the difficulty of miniF2F-curriculum was made varied enough, expert iteration could potentially leverage it to effectively shift our models’ distribution closer to miniF $2 F$ ’s, and in turn, improve their eventual performance on it.
|
| 159 |
+
|
| 160 |
+
# 6.1 TRANSFER TO miniF2F
|
| 161 |
+
|
| 162 |
+
In this section we propose to set $S t$ to the union of the statements in mathlib-train, synth-ineq and miniF2F-curriculum. We uniformly set $a = 1$ on mathlib-train and synth-ineq and $a = 8$ on miniF $2 F$ -curriculum and use $\theta _ { 0 }$ and $\theta _ { 1 }$ as described in Section 5.
|
| 163 |
+
|
| 164 |
+
Similarly to previous sections, we report in Figure 4 (left) the cumulative pass rate on miniF $2 F$ -valid of our full curriculum expert iteration loop and compare them with the mathlib-train only expert iteration from Section 4.5. Since more compute is deployed in our full-curriculum loop (more statements), we also report a mathlib-train only loop taking $a = 2$ . At the end of the expert iteration, 100 out of the 327 statements from miniF $2 F .$ -curriculum end up being closed, suggesting a lack of density in our manually formalized set of statement.
|
| 165 |
+
|
| 166 |
+
We also report in Figure 4 (right) the pass $@ l$ and pass $@ 8$ for our full curriculum expert iteration loop. The steady improvement on miniF2F-valid shows that the expert iteration procedure we propose does not overfit on the statements that compose the curriculum it uses. Despite the potential inefficiency of our curriculum, the improved performance associated with its use demonstrates, as hypothesized, an effective transfer between miniF ${ } ^ { 7 2 F }$ -curriculum, synth-ineq and miniF2F-valid through expert iteration. We will denote the fully iterated model from this section as $\theta _ { 9 } ^ { f u l l }$ .
|
| 167 |
+
|
| 168 |
+

|
| 169 |
+
Figure 4: Left: cumulative pass rate on miniF $2 F$ -valid for our expert iteration loop using our full curriculum (mathlib-train, synth-ineq and miniF $2 F$ -curriculum) compared to the expert iteration loop from Section 4.5. The total number of attempts per iteration in our full loop is $2 5 k + 5 . 6 k + 8 * 3 2 7 \approx$ $3 3 . 2 k$ , which means the total compute deployed is higher than in the mathlib-train only loop $( 2 5 k )$ . We therefore also report in dotted a mathlib-train only loop, taking $a = 2$ , whose total number of attempts per iteration is $\approx 5 0 k$ . Right: pass $@ l$ (plain) and pass $@ 8$ (dotted) for our expert iteration loop using our full curriculum (mathlib-train, synth-ineq and miniF $2 F$ -curriculum) compared to the expert iteration loop from Section 4.5.
|
| 170 |
+
|
| 171 |
+
# 6.2 RESULTS
|
| 172 |
+
|
| 173 |
+
We report in Table 2 the pass rates on mathlib-{valid, test} and miniF2F-{valid, test} for the models trained in previous sections, namely $\theta _ { 1 }$ , θmathlib9 , and $\theta _ { 9 } ^ { f u l l }$ . We achieve a $4 7 . 3 \%$ pass rate (using $a = 6 4$ attempts) on miniF $2 F .$ -valid and a $3 6 . 6 \%$ pass rate on miniF2F-test, substantially improving from the previous state-of-the-art (Zheng et al., 2022).
|
| 174 |
+
|
| 175 |
+
These results include the resolution of 26 AMC12 problems, 6 AIME problems and 2 IMO-adapted problems. Out of these statements, 4 AMC12 problems (amc12b_2020_p5, amc12a_2009_p9, amc12a_2003_p24, amc12b_2003_p17), 2 AIME problems (aime_1984_p1, aime_1990_p4), and 2 IMO-adapted problems $( \mathrm { i } \mathsf { m o } _ { - } 1 9 6 1 \mathsf { \Pi } _ { - } \mathsf { p } 1 ^ { 2 }$ , imo_1964_p2) are uniquely solved by expert iterated models, the two IMO-adapted and the two AIME problems being uniquely solved by $\theta _ { 9 } ^ { \bar { f } u l l }$ .
|
| 176 |
+
|
| 177 |
+
Table 2: Performance of $\theta _ { 1 }$ (value-function based search), $\theta _ { 9 } ^ { m a t h l i b }$ (expert iterated on mathlib-train) and $\theta _ { 9 } ^ { f u l l }$ (expert iterated on our full curriculum) on mathlib-{valid, test} and miniF2F-{valid, test}. All proof searches are run with $d = 5 1 2$ and $e = 8$ .
|
| 178 |
+
|
| 179 |
+
<table><tr><td>Model</td><td>pass@1</td><td>pass@8</td><td>pass@64</td><td>pass@1</td><td>pass@8</td><td>pass@64</td></tr><tr><td>mathlib-valid</td><td></td><td></td><td></td><td>mathlib-test</td><td></td><td></td></tr><tr><td>PACT (Han et al.,2022)</td><td>48.4%</td><td></td><td></td><td>=</td><td></td><td></td></tr><tr><td>01</td><td>56.3%</td><td>66.3%</td><td>72.0%</td><td>56.5%</td><td>66.9%</td><td>73.7%</td></tr><tr><td></td><td>62.6%</td><td>70.7%</td><td>75.8%</td><td>63.0%</td><td>71.5%</td><td>77.1%</td></tr><tr><td>G</td><td>61.7%</td><td>69.8%</td><td>75.3%</td><td>62.9%</td><td>71.6%</td><td>76.3%</td></tr><tr><td>miniF2F-valid</td><td></td><td></td><td></td><td>miniF2F-test</td><td></td><td></td></tr><tr><td>PACT (Zheng et al., 2022)</td><td>23.9%</td><td>29.3%</td><td></td><td>24.6%</td><td>29.2%</td><td></td></tr><tr><td>01</td><td>28.5%</td><td>35.5%</td><td>41.2%</td><td>25.9%</td><td>31.1%</td><td>33.6%</td></tr><tr><td>ggahibh</td><td>31.3%</td><td>38.3%</td><td>44.1%</td><td>27.2%</td><td>33.0%</td><td>35.2%</td></tr><tr><td></td><td>33.6%</td><td>41.2%</td><td>47.3%</td><td>29.6%</td><td>34.5%</td><td>36.6%</td></tr></table>
|
| 180 |
+
|
| 181 |
+
We provide a selection of the proofs found by our models for these statements as well as a qualitative analysis of them in Appendix J. Also, we achieve a new state-of-the-art: higher than $7 5 \%$ pass rate (using $a = 6 4$ attempts) on mathlib-{valid, test}, suggesting that our models could potentially be effectively leveraged as proof assistants in the formalization efforts associated with mathlib.
|
| 182 |
+
|
| 183 |
+
# 7 DISCUSSION AND LIMITATION
|
| 184 |
+
|
| 185 |
+
Throughout this paper, we used a single model size ( $7 7 4 \mathrm { m }$ trainable parameters). We refer readers to Appendix H for more discussion on model size, compute budget and training time. Despite our models’ capability, as discussed in Appendix J.1, to generate cuts and witnesses, we believe that their current main limitation lies in their inability (under our proposed search procedure) to chain more than 2 or 3 non-trivial steps of mathematical reasoning, preventing them from consistently solving challenging olympiad problems. We’ve been repeatedly impressed by the complexity of some of the proofsteps generated by our models. But, proofs requiring many of such reasoning steps remain beyond our current compute horizon. Even if we solved a selection of challenging olympiad problems, our models are still far from being competitive with the brightest students in these competitions.
|
| 186 |
+
|
| 187 |
+
While our models have demonstrated some capabilities to generate cuts, the cuts they generate are often shallow (they involve only a few proofsteps and don’t necessarily deeply change the structure of the proof–we refer the reader to the Cut-Elimination theorem and Carbone & Semmes (1996) for a discussion of the influence of cuts on proof size). We believe that studying language models’ ability to generate cuts, and designing search procedures that leverage that capability (related ideas can be found in Czechowski et al. (2021)), are interesting avenues of research to alleviate this limitation.
|
| 188 |
+
|
| 189 |
+
# 8 CONCLUSION
|
| 190 |
+
|
| 191 |
+
In this paper we presented an expert iteration procedure for GPT-f (Polu & Sutskever, 2020), demonstrating that it is capable of solving a curriculum of increasingly difficult problems out of a set of formal statements of sufficiently varied difficulty. Our results suggest that the lack of self-play in the formal mathematics setup can be effectively compensated for by automatically/manually curated sets of formal statements, which are much cheaper to formalize than full proofs. Finally, we hope that the statement curriculum learning methodology we presented in this work will help accelerate progress in automated reasoning, especially if scaled with automated generation and curation of formal statements in the future.
|
| 192 |
+
|
| 193 |
+
# REFERENCES
|
| 194 |
+
|
| 195 |
+
Lean theorem prover. https://leanprover.github.io/about/.
|
| 196 |
+
|
| 197 |
+
Kshitij Bansal, Sarah M Loos, Markus N Rabe, and Christian Szegedy. Learning to reason in large theories without imitation. arXiv preprint arXiv:1905.10501, 2019a.
|
| 198 |
+
|
| 199 |
+
Kshitij Bansal, Sarah M. Loos, Markus N. Rabe, Christian Szegedy, and Stewart Wilcox. Holist: An environment for machine learning of higher order logic theorem proving. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, ICML 2019, volume 97 of Proceedings of Machine Learning Research, pp. 454–463. PMLR, 2019b. URL http://proceedings.mlr.press/v97/bansal19a.html.
|
| 200 |
+
|
| 201 |
+
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.
|
| 202 |
+
|
| 203 |
+
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. Curran Associates, Inc., 2020. URL https://proceedings.neurips. cc/paper/2020/file/1457c0d6bfcb4967418bfb8ac142f64a-Paper.pdf.
|
| 204 |
+
|
| 205 |
+
Cameron B Browne, Edward Powley, Daniel Whitehouse, Simon M Lucas, Peter I Cowling, Philipp Rohlfshagen, Stephen Tavener, Diego Perez, Spyridon Samothrakis, and Simon Colton. A survey of monte carlo tree search methods. IEEE Transactions on Computational Intelligence and AI in games, 4(1):1–43, 2012.
|
| 206 |
+
|
| 207 |
+
Kevin Buzzard, Johan Commelin, and Patrick Massot. Lean perfectoid spaces. https:// leanprover-community.github.io/lean-perfectoid-spaces/, 2019.
|
| 208 |
+
|
| 209 |
+
Alessandra Carbone and S. Semmes. Making proofs without modus ponens: An introduction to the combinatorics and complexity of cut elimination. Bulletin of the American Mathematical Society, 34:131–159, 1996.
|
| 210 |
+
|
| 211 |
+
Konrad Czechowski, Tomasz Odrzygó´zd´z, Marek Zbysinski, MichałZawalski, Krzysztof Ole- ´ jnik, Yuhuai Wu, Ł ukasz Kucinski, and Piotr Mił o ´ s. Subgoal search for complex rea- ´ soning tasks. In M. Ranzato, A. Beygelzimer, Y. Dauphin, P.S. Liang, and J. Wortman Vaughan (eds.), Advances in Neural Information Processing Systems, volume 34, pp. 624–638. Curran Associates, Inc., 2021. URL https://proceedings.neurips.cc/paper/2021/file/ 05d8cccb5f47e5072f0a05b5f514941a-Paper.pdf.
|
| 212 |
+
|
| 213 |
+
Leonardo de Moura, Soonho Kong, Jeremy Avigad, Floris Van Doorn, and Jakob von Raumer. The lean theorem prover (system description). In International Conference on Automated Deduction, pp. 378–388. Springer, 2015.
|
| 214 |
+
|
| 215 |
+
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.), Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, NAACL-HLT 2019, volume 1, pp. 4171–4186. Association for Computational Linguistics, 2019. doi: 10.18653/v1/ n19-1423. URL https://doi.org/10.18653/v1/n19-1423.
|
| 216 |
+
|
| 217 |
+
Vlad Firoiu, Eser Aygun, Ankit Anand, Zafarali Ahmed, Xavier Glorot, Laurent Orseau, Lei Zhang, Doina Precup, and Shibl Mourad. Training a first-order theorem prover from synthetic data. arXiv preprint arXiv:2103.03798, 2021.
|
| 218 |
+
|
| 219 |
+
Jesse Michael Han, Jason Rute, Yuhuai Wu, Edward Ayers, and Stanislas Polu. Proof artifact cotraining for theorem proving with language models. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id=rpxJc9j04U.
|
| 220 |
+
|
| 221 |
+
Dan Hendrycks, Collin Burns, Saurav Kadavath, Akul Arora, Steven Basart, Eric Tang, Dawn Song, and Jacob Steinhardt. Measuring mathematical problem solving with the MATH dataset. In Joaquin Vanschoren and Sai-Kit Yeung (eds.), Proceedings of the Neural Information Processing Systems Track on Datasets and Benchmarks 1, NeurIPS Datasets and Benchmarks 2021, 2021. URL https://datasets-benchmarks-proceedings.neurips.cc/paper/2021/hash/ be83ab3ecd0db773eb2dc1b0a17836a1-Abstract-round2.html.
|
| 222 |
+
|
| 223 |
+
Daniel Huang, Prafulla Dhariwal, Dawn Song, and Ilya Sutskever. Gamepad: A learning environment for theorem proving. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id=r1xwKoR9Y7.
|
| 224 |
+
|
| 225 |
+
Geoffrey Irving, Christian Szegedy, Alexander A Alemi, Niklas Een, Francois Chollet, and Josef Urban. Deepmath - deep sequence models for premise selection. In D. Lee, M. Sugiyama, U. Luxburg, I. Guyon, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 29, pp. 2235–2243. Curran Associates, Inc., 2016. URL https://proceedings.neurips. cc/paper/2016/file/f197002b9a0853eca5e046d9ca4663d5-Paper.pdf.
|
| 226 |
+
|
| 227 |
+
Albert Q Jiang, Wenda Li, Szymon Tworkowski, Konrad Czechowski, Tomasz Odrzygó´zd´z, Piotr Miłos, Yuhuai Wu, and Mateja Jamnik. Thor: Wielding hammers to integrate language models ´ and automated theorem provers. arXiv preprint arXiv:2205.10893, 2022.
|
| 228 |
+
|
| 229 |
+
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.
|
| 230 |
+
|
| 231 |
+
Tero Karras, Samuli Laine, and Timo Aila. A style-based generator architecture for generative adversarial networks. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2019, pp. 4401–4410. Computer Vision Foundation / IEEE, 2019. doi: 10.1109/CVPR.2019.00453. URL http://openaccess.thecvf.com/content_CVPR_2019/html/Karras_A_Style-Based_ Generator_Architecture_for_Generative_Adversarial_Networks_CVPR_2019_paper. html.
|
| 232 |
+
|
| 233 |
+
Guillaume Lample, Marie-Anne Lachaux, Thibaut Lavril, Xavier Martinet, Amaury Hayat, Gabriel Ebner, Aurélien Rodriguez, and Timothée Lacroix. Hypertree proof search for neural theorem proving. CoRR, abs/2205.11491, 2022. doi: 10.48550/arXiv.2205.11491. URL https://doi. org/10.48550/arXiv.2205.11491.
|
| 234 |
+
|
| 235 |
+
Sandor Lehoczky and Richard Rusczyk. The Art of Problem Solving, Volume 1: the Basics, a. ISBN:978-0-9773045-6-1.
|
| 236 |
+
|
| 237 |
+
Sandor Lehoczky and Richard Rusczyk. The Art of Problem Solving, Volume 2: and Beyond, b. ISBN:978-0-9773045-8-5.
|
| 238 |
+
|
| 239 |
+
Wenda Li, Lei Yu, Yuhuai Wu, and Lawrence C. Paulson. Isarstep: a benchmark for high-level mathematical reasoning. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id=Pzj6fzU6wkj.
|
| 240 |
+
|
| 241 |
+
Sarah M. Loos, Geoffrey Irving, Christian Szegedy, and Cezary Kaliszyk. Deep network guided proof search. In Thomas Eiter and David Sands (eds.), 21st International Conference on Logic for Programming, Artificial Intelligence and Reasoning, LPAR-21, volume 46 of EPiC Series in Computing, pp. 85–105, 2017. doi: 10.29007/8mwc. URL https://doi.org/10.29007/8mwc.
|
| 242 |
+
|
| 243 |
+
Norman D. Megill and David A. Wheeler. Metamath: A Computer Language for Pure Mathematics, 2019. URL http://us.metamath.org/downloads/metamath.pdf.
|
| 244 |
+
|
| 245 |
+
Lawrence C. Paulson. Three years of experience with sledgehammer, a practical link between automatic and interactive theorem provers. In Renate A. Schmidt, Stephan Schulz, and Boris Konev (eds.), Proceedings of the 2nd Workshop on Practical Aspects of Automated Reasoning, PAAR-2010, Edinburgh, Scotland, UK, July 14, 2010, volume 9 of EPiC Series in Computing, pp. 1–10. EasyChair, 2010. doi: 10.29007/tnfd. URL https://doi.org/10.29007/tnfd.
|
| 246 |
+
|
| 247 |
+
Stanislas Polu and Ilya Sutskever. Generative language modeling for automated theorem proving. arXiv preprint arXiv:2009.03393, 2020.
|
| 248 |
+
|
| 249 |
+
Markus Norman Rabe, Dennis Lee, Kshitij Bansal, and Christian Szegedy. Mathematical reasoning via self-supervised skip-tree training. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id=YmqAnY0CMEy.
|
| 250 |
+
|
| 251 |
+
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 Marina Meila and Tong Zhang (eds.), Proceedings of the 38th International Conference on Machine Learning, ICML 2021, volume 139 of Proceedings of Machine Learning Research, pp. 8748–8763. PMLR, 2021. URL http://proceedings.mlr.press/v139/radford21a.html.
|
| 252 |
+
|
| 253 |
+
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.), Proceedings of the 38th International Conference on Machine Learning, ICML 2021, volume 139 of Proceedings of Machine Learning Research, pp. 8821–8831. PMLR, 2021. URL http://proceedings.mlr.press/v139/ramesh21a.html.
|
| 254 |
+
|
| 255 |
+
Peter Scholze. Liquid tensor experiment. https://xenaproject.wordpress.com/2020/12/05/ liquid-tensor-experiment/, 2020.
|
| 256 |
+
|
| 257 |
+
Daniel Selsam, Matthew Lamm, Benedikt Bünz, Percy Liang, Leonardo de Moura, and David L. Dill. Learning a SAT solver from single-bit supervision. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id=HJMC_iA5tm.
|
| 258 |
+
|
| 259 |
+
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.
|
| 260 |
+
|
| 261 |
+
David Silver, Thomas Hubert, Julian Schrittwieser, Ioannis Antonoglou, Matthew Lai, Arthur Guez, Marc Lanctot, Laurent Sifre, Dharshan Kumaran, Thore Graepel, et al. Mastering chess and shogi by self-play with a general reinforcement learning algorithm. arXiv preprint arXiv:1712.01815, 2017.
|
| 262 |
+
|
| 263 |
+
Mingxing Tan and Quoc V. Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, ICML 2019, volume 97 of Proceedings of Machine Learning Research, pp. 6105–6114. PMLR, 2019. URL http://proceedings.mlr.press/v97/ tan19a.html.
|
| 264 |
+
|
| 265 |
+
Josef Urban and Jan Jakubuv. First neural conjecturing datasets and experiments. In Christoph Benzmüller and Bruce R. Miller (eds.), Intelligent Computer Mathematics - 13th International Conference, CICM 2020, volume 12236 of Lecture Notes in Computer Science, pp. 315–323. Springer, 2020. doi: 10.1007/978-3-030-53518-6\_24. URL https://doi.org/10.1007/ 978-3-030-53518-6_24.
|
| 266 |
+
|
| 267 |
+
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.
|
| 268 |
+
|
| 269 |
+
Mingzhe Wang, Yihe Tang, Jian Wang, and Jia Deng. Premise selection for theorem proving by deep graph embedding. In I. Guyon, U. Von Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 30, pp. 2786– 2796. Curran Associates, Inc., 2017. URL https://proceedings.neurips.cc/paper/2017/ file/18d10dc6e666eab6de9215ae5b3d54df-Paper.pdf.
|
| 270 |
+
|
| 271 |
+
Daniel Whalen. Holophrasm: a neural automated theorem prover for higher-order logic. CoRR, abs/1608.02644, 2016. URL http://arxiv.org/abs/1608.02644.
|
| 272 |
+
|
| 273 |
+
Mark H. Winands, Yngvi Björnsson, and Jahn-Takeshi Saito. Monte-carlo tree search solver. In Proceedings of the 6th International Conference on Computers and Games, pp. 25–36. SpringerVerlag, 2008. doi: 10.1007/978-3-540-87608-3_3.
|
| 274 |
+
|
| 275 |
+
Yonghui Wu, Mike Schuster, Zhifeng Chen, Quoc V Le, Mohammad Norouzi, Wolfgang Macherey, Maxim Krikun, Yuan Cao, Qin Gao, Klaus Macherey, et al. Google’s neural machine translation system: Bridging the gap between human and machine translation. arXiv preprint arXiv:1609.08144, 2016.
|
| 276 |
+
|
| 277 |
+
Yuhuai Wu, Albert Jiang, Jimmy Ba, and Roger Baker Grosse. INT: an inequality benchmark for evaluating generalization in theorem proving. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id=O6LPudowNQm.
|
| 278 |
+
|
| 279 |
+
Yuhuai Wu, Albert Qiaochu Jiang, Wenda Li, Markus Norman Rabe, Charles E Staats, Mateja Jamnik, and Christian Szegedy. Autoformalization with large language models. In Alice H. Oh, Alekh Agarwal, Danielle Belgrave, and Kyunghyun Cho (eds.), Advances in Neural Information Processing Systems, 2022. URL https://openreview.net/forum?id=IUikebJ1Bf0.
|
| 280 |
+
|
| 281 |
+
Kaiyu Yang and Jia Deng. Learning to prove theorems via interacting with proof assistants. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, ICML 2019, volume 97 of Proceedings of Machine Learning Research, pp. 6984–6994. PMLR, 2019. URL http://proceedings.mlr.press/v97/yang19a. html.
|
| 282 |
+
|
| 283 |
+
Kunhao Zheng, Jesse Michael Han, and Stanislas Polu. minif2f: a cross-system benchmark for formal olympiad-level mathematics. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id=9ZPegFuFTFv.
|
| 284 |
+
|
| 285 |
+
# A RELATED WORK
|
| 286 |
+
|
| 287 |
+
Deep learning applied to premise selection and proof guidance Early applications of deep learning to formal mathematics focused primarily on premise selection and proof guidance. DeepMath (Irving et al., 2016) explored the use of CNNs and RNNs to predict whether a premise is useful to demonstrate a given conjecture. Their results were later improved with FormulaNet (Wang et al., 2017) by the use of graph neural networks, reminiscent of NeuroSAT (Selsam et al., 2019). Proof guidance consists in selecting the next clause to process inside an automated theorem prover. Loos et al. (2017) investigated the use of models similar to DeepMath’s for proof guidance and demonstrated a significant uplift on the Mizar library. More recently Firoiu et al. (2021) demonstrated the potential of deep learning techniques to be competitive with E prover’s heuristics when applied to resolution calculus while training on fully synthetic data.
|
| 288 |
+
|
| 289 |
+
Deep learning applied to automated theorem-proving HOList (Bansal et al., 2019b) proposes a formal environment based on HOL Light. They achieve their best performance (Bansal et al., 2019a) with a GNN model designed for premise selection and the use of exploration. The same team studied the use of a skip-tree objective with Transformers on formal statements (Rabe et al., 2021), demonstrating, along with GPT-f (Polu & Sutskever, 2020), the potential of leveraging Transformers for formal reasoning. GamePad (Huang et al., 2019) and CoqGymn/ASTactic (Yang & Deng, 2019) introduce environments based on the Coq theorem prover. ASTactic generates tactics as programs by sequentially expanding a partial abstract syntax tree. Urban & Jakubuv (2020) studied the capability of GPT-2 to produce useful conjectures for the Mizar library and IsarStep (Li et al., 2021) explored the synthesis of intermediate propositions in declarative proofs for Isabelle/HOL using Transformers.
|
| 290 |
+
|
| 291 |
+
Targeting miniF2F Lample et al. (2022) designed HyperTree Proof Search (HTPS), an online training procedure targeting Lean, Metamath and hand-crafted environment named Equations. Lample et al. (2022) report $41 \%$ pass-rate on miniF $2 F$ -test and $4 2 . 5 \%$ pass-rate on miniF $2 F .$ -curriculum in Lean (de Moura et al., 2015; lea) setup. Thor (Jiang et al., 2022) combined language model and Sledgehammer (Paulson, 2010) and achieved $2 9 . 9 \%$ pass-rate on miniF $2 F$ -test in Isabelle setup, which is later improved to $3 5 . 2 \%$ by $\mathbf { W } \mathbf { u }$ et al. (2022) leveraging autoformalization and expert iteration.
|
| 292 |
+
|
| 293 |
+
# B LEAN-GYM
|
| 294 |
+
|
| 295 |
+
lean-gym presents the following API:
|
| 296 |
+
|
| 297 |
+
• init-search: declaration tactic_state. Takes a declaration name (a theorem name from the loaded library) and initializes a search while setting the run-time environment at that particular declaration. It returns the initial tactic state along with a fresh search_id and tactic_state_id.
|
| 298 |
+
• run_tac: (tactic_state, tactic) tactic_state. Takes a search_id and a tactic_state_id to identify a tactic state, as well as a tactic string to apply to it. It returns a new tactic state and its associated tactic_state_id.
|
| 299 |
+
|
| 300 |
+
Below is an example in-terminal trace demonstrating the use of lean-gym’s REPL interface:
|
| 301 |
+
|
| 302 |
+
$\$ 1$ lean --run src/repl.lean
|
| 303 |
+
["init_search", ["int.prime.dvd_mul", ""]]
|
| 304 |
+
{ "error":null, "search_id":"0", "tactic_state":"⊢ ∀ {m n : Z} {p : N}, nat.prime p → ↑p | m \* n → p | m.nat_abs ∨ p | n.nat_abs", "tactic_state_id":"0"
|
| 305 |
+
}
|
| 306 |
+
["run_tac",["1","1","apply (nat.prime.dvd_mul hp).mp"]]
|
| 307 |
+
{
|
| 308 |
+
|
| 309 |
+
"error":null, "search_id":"1", "tactic_state":"m n : Z, p : N, hp : nat.prime p, h : ↑p | m \* n ⊢ p | m.nat_abs $\star$ n.nat_abs", "tactic_state_id":"2" }
|
| 310 |
+
|
| 311 |
+
Using lean-gym is virtually equivalent to opening a Lean editor at a specific theorem, deleting its proof and interacting with Lean to reconstruct it.
|
| 312 |
+
|
| 313 |
+
Providing a REPL interface over the standard input/output makes it very easy to integrate lean-gym from any programming language. Writing a wrapper in Python, as an example, only takes a few dozen lines of code. Since lean-gym is a Lean program, managing the loaded libraries is done directly using Lean’s own infrastructure (using leanpkg.toml), making it quite straightforward to have access to both mathlib and miniF2F statements from the same lean-gym instance.
|
| 314 |
+
|
| 315 |
+
Note that lean-gym is stateful, meaning that distributing proof searches on multiple lean-gym instances requires to track which instance is associated with which proof search. In practice, we were able to scale the use of lean-gym to thousands of cores running thousands of proof searches in parallel. Finally, lean-gym’s REPL interface is blocking, preventing inner-proof search parallelization, though this limitation can probably be removed in the future.
|
| 316 |
+
|
| 317 |
+
# C WEBMATH
|
| 318 |
+
|
| 319 |
+
Our updated WebMath pre-training dataset consists in the mix presented in table 3.
|
| 320 |
+
|
| 321 |
+
Table 3: Mix and source of data involved in the updated WebMath pre-training.
|
| 322 |
+
|
| 323 |
+
<table><tr><td>Dataset</td><td>Size</td><td>Mix</td></tr><tr><td>Github Python</td><td>179 GB</td><td>25%</td></tr><tr><td>arXiv Math</td><td>10 GB</td><td>25%</td></tr><tr><td>Math StackExchange</td><td>2GB</td><td>25%</td></tr><tr><td>PACT mix2</td><td>28GB</td><td>17%</td></tr><tr><td>Math Overflow</td><td>200 M</td><td>5%</td></tr><tr><td>ProofWiki</td><td>30M</td><td>2%</td></tr><tr><td>PlanetMath</td><td>25M</td><td>1%</td></tr></table>
|
| 324 |
+
|
| 325 |
+
As demonstrated in table 3, we empirically up-weighted (compared to their token size) parts of WebMath with high-quality mathematical content while making sure they don’t overfit (despite running ${ > } 1$ epochs for some of them). We also included PACT $\mathfrak { m i x } 2$ directly in the WebMath pre-training to avoid having to sequence more than two pre-training phases to prepare Lean models.
|
| 326 |
+
|
| 327 |
+
# D EXAMPLE OF MINIF2F INPUT, LEAN ENVIRONMENT AND MODEL OUTPUT
|
| 328 |
+
|
| 329 |
+
We illustrate an example of the interaction between Lean environment and our model. In the figure shown below, the model has 1 output for each current goal (corresponding to 1 expand budget). The model could have expand budget bigger than 1, in which case the search procedure becomes a tree.
|
| 330 |
+
|
| 331 |
+

|
| 332 |
+
Figure 5: Input from miniF $2 F$ consists of a mathematical statement written in formal language (here the Lean version) without proof. Lean environment parses the statement and exposes to users the goal to be proved. The model outputs a line of code (tactics and corresponding arguments). Lean environment receives the model output and transforms the previous goal to another goal to be proved. This process is repeated till all remaining goals are closed. In this case, the original statement is proved: the final proof is collected by following the trajectory of model’s output.
|
| 333 |
+
|
| 334 |
+
# E ILLUSTRATION OF EXPERT ITERATION
|
| 335 |
+
|
| 336 |
+

|
| 337 |
+
Figure 6: Illustration of expert iteration. The notation in this figure corresponds to Section 4.4 in main text.
|
| 338 |
+
|
| 339 |
+
# F SYNTHETIC INEQUALITIES
|
| 340 |
+
|
| 341 |
+
F.1 DESIGN
|
| 342 |
+
|
| 343 |
+
The generator consists of three phases:
|
| 344 |
+
|
| 345 |
+
Seed expressions generation The first phase consists in generating seed expressions for which we track the sign. We start by initializing an expression set $E$ composed of tuples of expressions and sign constraints, by generating $n _ { v }$ variable names (letters) assumed strictly positive as well as $n _ { n }$ integers (for which we know the sign). For $N _ { S }$ rounds, we compose elements of $E$ using unary $( l o g ( \cdot ) , \bar { l o g } ( 1 / \cdot ) , s q r t ( \cdot ) )$ or binary operations $( + , - , \times , / , \wedge , m a x , m i n )$ for which we can deduce the sign based on the sign condition of the input expression(s) and re-inject the resulting expression and sign constraint in $E$ . This produces a set $E$ of signed seed expressions of size $n _ { v } + n _ { n } + N _ { S }$ .
|
| 346 |
+
|
| 347 |
+
Inequality composition The second phase consists in generating inequalities from well known inequality theorems (AM-GM, Trivial inequality, Cauchy-Schwarz, Bernoulli, Young, Hölder) taking as input to these theorems expressions from $E$ based on the sign constraints required for each theorem. We finally compose these inequalities $N _ { D }$ times using compositions theorems detailed in F.2. The resulting inequality is a composed inequality of depth $N _ { D }$ based on $n _ { v } + n _ { n } + N _ { S }$ seed expressions.
|
| 348 |
+
|
| 349 |
+
Simplification We finally post-process these inequalities so that they are parsable by Lean and run them through Lean’s simp tactic for a final simplification.
|
| 350 |
+
|
| 351 |
+
$N _ { D }$ and $N _ { S }$ together control for the difficulty of the resulting inequality. $N _ { D }$ controls depth of composition, while $N _ { S }$ controls for obfuscation as it increases the complexity of the input expressions to the composed inequalities. When sampling inequalities, we $n _ { n } ~ = ~ 4$ and randomly sample $2 \leq n _ { v } \leq 8$ at each generation. We report below examples of generated inequalities for various values of $N _ { D }$ and $N _ { S }$ .
|
| 352 |
+
|
| 353 |
+
# F.2 LIST OF INEQUALITY COMPOSITION THEOREMS
|
| 354 |
+
|
| 355 |
+
Below is the list of theorem names from mathlib that we use to compose inequalities together. One third of the time, we only transform the current composed inequality with one of the following theorems:
|
| 356 |
+
|
| 357 |
+
• neg_le_neg
|
| 358 |
+
• inv_le_inv
|
| 359 |
+
• mul_self_le_mul_self
|
| 360 |
+
• div_le_one_of_le
|
| 361 |
+
|
| 362 |
+
We otherwise compose the current composed inequality with a newly generated inequality using the following theorems:
|
| 363 |
+
|
| 364 |
+
• mul_le_mul
|
| 365 |
+
• add_le_add
|
| 366 |
+
• div_le_div
|
| 367 |
+
• mul_le_mul_of_nonneg
|
| 368 |
+
• le_mul_of_ratio
|
| 369 |
+
|
| 370 |
+
F.3 EXAMPLES
|
| 371 |
+
|
| 372 |
+
$$
|
| 373 |
+
\begin{array} { c } { { N _ { D } = 0 \ N _ { S } = 0 } } \\ { { { } } } \\ { { N _ { D } = 0 \ N _ { S } = 4 } } \end{array}
|
| 374 |
+
$$
|
| 375 |
+
|
| 376 |
+
<table><tr><td>Compositions</td><td>AmGm a b (67:R)((1:R)/(10:R))((1:R)/(10:R)) ((8:R)/(10:R))</td></tr><tr><td>Statement</td><td>theorem synthetic_ineq_nb_seed_var_0_depth_0_p_1 (ab:R) (h0:0<a) (h1:0<b): (67:R)^((8:R)/(10:R))*b^(10:R)-1 * a^(10:R)-1≤ (8:R)/(10:R)* (67:R) + (10:R)-1 * a+b* (10:R)-1 := sorry</td></tr></table>
|
| 377 |
+
|
| 378 |
+
<table><tr><td>Compositions</td><td>Sqnonneg a ((a)+((-68:R)))</td></tr><tr><td>Statement</td><td>theorem synthetic_ineq_nb_seed_var_4_depth_0_p_4 (ab:R) (h0 :0<a) (h1:0<b): (2:R)*(a*(a+-(68:R)))≤ (a +-(68:R))^2 +a^2 := sorry</td></tr></table>
|
| 379 |
+
|
| 380 |
+
$$
|
| 381 |
+
N _ { D } = 4 N _ { S } = 4
|
| 382 |
+
$$
|
| 383 |
+
|
| 384 |
+
<table><tr><td>Compositions</td><td>AddLeAdd Bernoulli 99 c AddLeAdd SelfDivConst((a)/(f))6 LeMulOfRatio SelfDivConst c 70 DivLeDiv Cauchy((a)/(f))dc(log(((59:R)+ f))) Young((a)/(f))a((3:R)/(2:R))((3:R)/(1:R)) theorem synthetic_ineq_nb_seed_var_4_depth_4_p_13</td></tr><tr><td>Statement</td><td>(abcdef:R) (h0 :0<a) (h1 :0<b) (h2 :0<c) (h3:0<d) (h4 :0<e) (h5:0<f): (1:R)+(99:R)*c+(a/f/(6:R)+a*(a/f)/ ((d^2+a^2/f^2)* (real.log((59:R)+f)^2+c^2)))≤ ((a/f)^((3:R)/(2:R))/((3:R)/(2:R))+ a^3/(3:R))/ (real.log((59:R)+f)*d+a/ f*c)^2 * (c/(c/(70:R)))+a/f+(c+(1:R))^99 := sorry</td></tr></table>
|
| 385 |
+
|
| 386 |
+
# G MINIF2F-CURRICULUM
|
| 387 |
+
|
| 388 |
+
The 327 statements of miniF2F-curriculum3 are manually formalized from:
|
| 389 |
+
|
| 390 |
+
• AOPS Books (Lehoczky & Rusczyk, a;b): 302 examples and exercises. The books are classic problem solving textbooks for students in grades 7-12 preparing for contests such as AMCs and AIMEs. We skipped problems that were too challenging to formalize due to missing infrastructure in mathlib or non-suitable format for formalization (see section Formalization effort and challenges in Zheng et al. (2022)).
|
| 391 |
+
|
| 392 |
+
• MATH (Hendrycks et al., 2021) dataset: 25 problems. All problems were drawn from the train split of the dataset, focusing on difficulty 5 problems (miniF2F only contains problems from the test split).
|
| 393 |
+
|
| 394 |
+
We verified (based on problem provenance and manual inspection of statements) that miniF2Fcurriculum had an empty intersection with miniF2F-{test, valid}. We refer to Zheng et al. (2022) for more details on the formalization procedure and the typical time needed for it as these problems were formalized in similar conditions.
|
| 395 |
+
|
| 396 |
+
# H MODEL SIZE
|
| 397 |
+
|
| 398 |
+
Other than the single model size we use in the experiment reported in the main text $7 7 4 \mathrm { m }$ trainable parameters), we briefly experimented with different model sizes (not reported in this paper) and found that model size scaling is not as straightforward as in the case of unsupervised learning (Kaplan et al., 2020). We found that bigger models are better, in the sense that they consistently exhibit higher $p a s s @ { I }$ . But, they are also much more expensive to sample from. And despite their pass@1 being higher, it is often the case that for a fixed amount of compute, sampling more attempts from a smaller model leads to a better final performance.
|
| 399 |
+
|
| 400 |
+
For the compute budget we had available, we estimated the model size we used to be a compelling trade-off. We leave as future work a more thorough study of these dynamics to better understand the different compute frontiers involved. Indicatively, with our $7 7 4 \mathrm { m }$ parameters model, running a full expert iteration to train $\theta _ { 9 } ^ { f u l l }$ required about $2 0 0 0 \mathrm { { A } 1 0 0 }$ days of compute. Running one full proof search $( a = 1 ~ d = 5 1 2 ~ e = 8 )$ when properly parallelised, requires on average about 0.1 A100 hour of compute.
|
| 401 |
+
|
| 402 |
+
# I EXAMPLE PROOFS FROM mathlib-train
|
| 403 |
+
|
| 404 |
+
We present in this section original proofs found by our models from mathlib-train, compared with their ground-truth version.
|
| 405 |
+
|
| 406 |
+
comap_eq_of_inverse
|
| 407 |
+
|
| 408 |
+
<table><tr><td rowspan=1 colspan=1>Statement</td><td rowspan=1 colspan=1>lemma comap_eq_of_inverse {f:filter α} {g:filter β}{Φ:α→β} (φ:β→α)(eq:γ○Φ=id)(hΦ : tendsto f g)(hψ :tendsto 𝜑 g f):comap Φ g = f :=</td></tr><tr><td rowspan=1 colspan=1>Ground-truth</td><td rowspan=1 colspan=1>beginrefine((comap_mono $map_le_iff_le_comap.1 h).trans_).antisymm(map_le_iff_le_comap.1 hΦ),rw [comap_comap,eq,comap_id],exact le_rflend</td></tr><tr><td rowspan=1 colspan=1>Model proof</td><td rowspan=1 colspan=1>beginrefine le_antisymm _ (filter.map_le_iff_le_comap.1 h),refine 入s hs,-,rw mem_comap,use [ -1' s,h hs],rw[← preimage_comp,eq,preimage_id]end</td></tr></table>
|
| 409 |
+
|
| 410 |
+
sum_range_sub_sum_range
|
| 411 |
+
|
| 412 |
+
<table><tr><td rowspan=1 colspan=1>Statement</td><td rowspan=1 colspan=1>lemma sum_range_sub_sum_range {α :Type*}[add_comm_group α]{f:N→α}{nm:N}(hnm:n≤m):∑k in range m,fk-∑kin range n,fk =∑k in (range m).filter (λk,n≤k),f k :=</td></tr><tr><td rowspan=1 colspan=1>Ground-truth</td><td rowspan=1 colspan=1>beginrw[← sum_sdiff(@filter_subset _(λ k,n ≤k)_(range m)),sub_eq_iff_eq_add,← eq_sub_iff_add_eq,add_sub_cancel'],refine finset.sum_congr(finset.ext $入 a,< h,by simp at *;finish,入 h,have ham :a<m :=lt_of_lt_of_le (mem_range.1 h)hnm,by simp * at *>)(λ__,rfl)end</td></tr><tr><td rowspan=1 colspan=1>Model proof</td><td rowspan=1 colspan=1>beginrw[← sum_Ico_eq_sub_ hnm],congr,apply finset.ext,simp [Ico.mem,*],tautoend</td></tr></table>
|
| 413 |
+
|
| 414 |
+
prod_inv_distrib
|
| 415 |
+
|
| 416 |
+
<table><tr><td rowspan=1 colspan=1>Statement</td><td rowspan=1 colspan=1>lemma prod_inv_distrib :(II× in s,(f x)-1)=①I×in s,f x)-1 :=</td></tr><tr><td rowspan=1 colspan=1>Ground-truth</td><td rowspan=1 colspan=1>beginclassical,by_casesh:×∈s,fx=0,{simpa [prod_eq_zero_iff.mpr h,prod_eq_zero_iff]using h },{ push_neg at h,have h' := prod_ne_zero_iff.mpr h,have hf :∀x ∈ s,(f x)-1 * fx=1 :=λx hx,inv_mul_cancel (h × hx),apply mul_right_cancel'h',simp[h,h',← finset.prod_mul_distrib,prod_congr rfl hf]}end</td></tr><tr><td rowspan=1 colspan=1>Model proof</td><td rowspan=1 colspan=1>beginclassical;induction s usingfinset.induction_on with a s has ih,{simp,},simp only[has,prod_insert has,mul_inv_rev'],finishend</td></tr></table>
|
| 417 |
+
|
| 418 |
+
# J EXAMPLE PROOFS FROM miniF2F-{test, valid, curriculum}
|
| 419 |
+
|
| 420 |
+
We present in this section proofs found by our models from miniF2F-{test, valid, curriculum}, demonstrating some of the capabilities emerging from our training procedure.
|
| 421 |
+
|
| 422 |
+
# J.1 QUALITATIVE ANALYSIS OF PROOFS
|
| 423 |
+
|
| 424 |
+
We provide qualitative insights in the nature of the proofs found by our models, which we believe are useful to build a better intuition of their capabilities beyond pass rate numbers. Throughout this section, we refer to statements and solutions found by our models that are presented in Appendix J along with comments describing the specificity of each proof.
|
| 425 |
+
|
| 426 |
+
First, we observe that a large number of olympiad problems that are designed to be computationally challenging for humans are rendered trivial for our models through the use of Lean tactics. As an example, mathd_numbertheory_447 which is not necessarily considered straightforward for humans, can be closed in Lean by a simple refl (proof found by our models).
|
| 427 |
+
|
| 428 |
+
In recent years, Lean’s mathlib community has developed high-powered tactics such as linarith/nlinarith (solves (non)linear inequalities), norm_num (normalizes numerical expressions), simp (simplifies goals and hypotheses) and ring (normalizes expressions in a ring). These tactics can be used with arguments to guide their underlying search procedure. As mentioned in Zheng et al. (2022), we confirm here that our models acquire advanced capabilities to leverage these high-level tactics by providing exogenous arguments which are not present in the current tactic state. The generation of these exogenous arguments through language modeling seems to require a non-trivial amount of mathematical intuition. imo_1964_p2, imo_1961_p1 and aime_1990_p15 are good examples of such uses.
|
| 429 |
+
|
| 430 |
+
We have also observed a number of proofs that require multiple non-trivial reasoning steps through the use of lower-level tactics such as use, have, or by_cases that generally involve producing a witness or chaining implications, requiring the generation of context specific exogenous terms. These interesting reasoning steps are structurally different from simple normalization, simplification and rewriting of hypotheses or goals because they heavily rely on our models ability to generate meaningful cuts or witnesses. This capability is, in our opinion, the most exciting stepping stone towards solving more challenging mathematical problems. See, aopsbook_v2_c8_ex1, amc12b_2020_p6 and mathd_train_algebra_217 for examples of such proofs.
|
| 431 |
+
|
| 432 |
+
More generally, we also observe that proofs generated by our models have a distinctive style compared to proofs formalized by humans. This stems in part from the model’s capability to leverage high-level tactics in a way that is challenging for humans as discussed in this section (e.g. one-liners such as nlinarith [sq_nonneg $( \textsf { x } \texttt { - y } )$ , sq_nonneg $( \mathsf { y } \mathrm { ~ ~ { ~ - ~ } ~ } \mathsf { z } ) ]$ where humans would generally decompose the problem in a less machine-like way). Additionally, as a result of our search procedure and despite the bias towards shorter proofs introduced by our value function, extraneous proofsteps (such as reversion/introduction of hypotheses, or no-op rewrites) are often interleaved with useful ones, which rarely happens in human formalizations.
|
| 433 |
+
|
| 434 |
+
imo_1961_p1 imo_1964_p2 aime_1990_p15 mathd_train_algebra_217 amc12b_2020_p6 mathd_algebra_140 aime_1984_p1 aopsbook_v2_c8_ex1 mathd_numbertheory_447
|
| 435 |
+
|
| 436 |
+
<table><tr><td rowspan=1 colspan=1>Natural language</td><td rowspan=1 colspan=1>Solve the system of equations:x+y+z=αx²+y²+2²=b²xy= x²where α and b are constants.Give the conditions that α and b must satisfy sothat x,y,z (the solutions of the system) are distinct positive numbers.Note: theformalized statement in miniF2F is a weaker problem as it focuses on the secondpart of the question, providing the actual conditions,and asking for a proof that therequirement entails them.</td></tr><tr><td rowspan=1 colspan=1>Model proof</td><td rowspan=1 colspan=1>theorem imo_1961_p1(xyzab:R)(ho:0<x>0<y>0<z)(h1:×≠y)(h2 :y≠z)(h3:z≠x)(h4 :x+y+z= a)(h5 :x^2 +y^2 + z^2 = b^2)(h6 :x *y= z^2) :0<a∧ b^2<a^2 > a^2<3*b^2 :=beginrevert_all,intros,rw mul_comm,split,{nlinarith [sq_nonneg (x - y),sq_nonneg(y- z)],},split,{nlinarith [sq_nonneg(z - 1)],},revert h3 h4,field_simp [mul_comm a b],rw [mul_comm,← h5],contrapose!,rw mul_comm at h6,rw mul_comm,intro h,nlinarith [sq_nonneg (x - y),sq_nonneg (y - z)]end</td></tr><tr><td rowspan=1 colspan=1>Comments</td><td rowspan=1 colspan=1>The model is able to close this problem by spliting into cases,contraposing for thelast case and using nlinarith.It must be noted that the arguments for the first twonlinarith uses are not necessary,however the [sq_nonneg (x - y),sq_nonneg(y- z)] argument provided on the last line is crucial to close the goal and arecompletely exogenous (present in no form in the tactic state before).</td></tr></table>
|
| 437 |
+
|
| 438 |
+
<table><tr><td rowspan=1 colspan=1>Natural language</td><td rowspan=1 colspan=1>Suppose a,b,c are the sides of a triangle.Prove thata²(b+c-a)+b²(c+a-b)+c²(a+b-c)≤3abc</td></tr><tr><td rowspan=1 colspan=1>Model proof</td><td rowspan=1 colspan=1>theorem imo_1964_p2(abc:R)(ho:0<a>0<b>0<c)(h1:c<a+b)(h2:b<a+c)(h3:a<b+c):a^2*(b+c-a)+b^2*(c+a-b)+c^2*(a+b-c)≤3*a*b*c:=beginnlinarith [sq_nonneg (b - a),sq_nonneg (c - b),sq_nonneg (a - c),sq_nonneg (c - a)]end</td></tr><tr><td rowspan=1 colspan=1>Comments</td><td rowspan=1 colspan=1>The model is able to close an IMO problem in one-line.It correctly providesexogenous arguments to nlinarith,which are necessary to close the goal. Notethat either one of the last two arguments in the sequence [sq_nonneg (b - a),sq_nonneg(c -b),sq_nonneg(a - c),sq_nonneg (c- a)]can be omitted.</td></tr></table>
|
| 439 |
+
|
| 440 |
+
<table><tr><td>Natural language</td><td>Find ax+ by if the real numbers a,b,x,and y satisfy the equations ax+by =3, ax²+by²=7, ax²+by³=16, ax²4 +by4 = 42. Note: the formalized statement in miniF2F provides the answer and asks for a proof of it. theorem aime_1990_p15</td></tr><tr><td>Model proof</td><td>(abxy:R) (ho:a*x+b*y=3) (h1 :a* x^2+b*y^2= 7) (h2 :a* x^3 +b*y^3= 16) (h3 :a* x^4 +b*y^4= 42) : a * x^5+b*y^5=20 := begin revert_all, intros ab ×y hg hi h2 h4, ring_nf at hi h2, rw ← sub_eq_zero at h1, nlinarith [sq_nonneg (× - y),sq_nonneg (a + b - 2), sq_nonneg (x + y - (2:R)),sq_nonneg (a -b - 2)]</td></tr><tr><td>Comments</td><td>end The model is able to close a challenging AIME problem by providing crucial ex- ogenous arguments sq_nonneg (x - y) and sq_nonneg (x + y - (2 :R)) to nlinarith,which are required to close the goal (while the other two can be removed).</td></tr></table>
|
| 441 |
+
|
| 442 |
+
<table><tr><td>Natural language</td><td>Let f(x)= Ax+B and g(x)=Bx +A,where A≠B. If f(g(x)) - g(f(x))= B-A,what is A+B? Note: the formalized statement in our curriculum provides the answer and asks for a proof of it. theorem mathd_train_algebra_217</td></tr><tr><td>Model proof</td><td>(ab:R) (fg:R→R) (ho:∀x,fx=a*x+b) (h1:∀×,fx=b*x+a) (h2 :a≠b) (h3 :∀x,f (gx)-g(f x)=b-a): a+b=0 := begin revert_all, intros a b, intros f g, contrapose!, rintro <ho,<hi,h2>>, use (0 :R), simp only[sub_eq_iff_eq_add,ho,mul_zero]at *, simp only[*,zero_add],</td></tr><tr><td>Comments</td><td>norm_num at ho end The model is able to close the goal by contraposing,supplying a witness by the use of use (O :R)and finally leveraging the simp and norm_num. This example demonstrates the model's ability to chain multiple non-trivial steps of reasoning including the generation of witnesses.</td></tr></table>
|
| 443 |
+
|
| 444 |
+
<table><tr><td rowspan="2">Natural language (A) a multiple of 4 (D) a perfect square</td><td colspan="2">For all integers n ≥ 9, the value of (n+2)!-(n+1)!</td></tr><tr><td colspan="2">n! is always which of the following? (B) a multiple of 10 (C)a prime number</td></tr><tr><td>Model proof</td><td>theorem amc12b_2020_p6 (n :N) (ho:9≤n): x :N,(x:R)^2 = (nat.factorial (n + 2) - nat.factorial (n + 1))/ nat.factorial n := begin revert_all, intros n hn, use n + 1,</td><td>field_simp [nat.factorial_ne_zero,pow_succ'],</td></tr><tr><td>Comments</td><td>ring_exp end The model exhibits here its ability to implicitly interpret factorial expressions by guessing the correct answer with the use of use n + 1 and straightforwardly proving</td><td></td></tr></table>
|
| 445 |
+
|
| 446 |
+
<table><tr><td>Natural language</td><td>The expression 24x² - 19x - 35 can be written as (Ax - 5)(2Bx + C),where A, B,and C are positive numbers.Find AB- 3C.Note: the formalized statement in miniF2F provides the answer and asks for a proof of it.</td></tr><tr><td>Model proof</td><td>theorem mathd_algebra_140 (abc:R) (ho:0<a>0<b>0<c) (h1:∀×,24* ×^2-19*×-35= (((a*x)-5)*((2*(b*x))+c))): a*b-3*c=-9:= begin revert_all, rintro abc h1, rw mul_comm, rw ←sub_eq_zero, field_simp, rw sub_eq_add_neg, rw←eq_neg_iff_add_eq_zero, rw [mul_comm,← sub_eq_add_neg,sub_eq_add_neg, ← sub_eq_add_neg], rw ←sub_eq_zero, simp only [mul_add,neg_mul_eq_neg_mul_symm,mul_comm, add_left_comm], norm_num, simp only [pow_two], intro ho, rw← sub_eq_zero, linarith [hi.2,hi.1,ho 3,ho 1,ho 2]</td></tr><tr><td>Comments</td><td>end The model mostly "struggles" to make progress up to the last line. There, it presents us with the idea to specialize the statement given in h1 (which became ho in the process of the proof) at three consecutive natural numbers 1,2,3 which closes the goal with nlinarith. This proof is interesting as it demonstrates the model's ability to evaluate symbolic expressions implicitly.</td></tr></table>
|
| 447 |
+
|
| 448 |
+
<table><tr><td>Natural language</td><td>Find the value of a2 +a4 +a6 +ag +...+ ag if a1,a2,a3... is an arithmetic progression with common difference 1,and a1 +a2 + a3 +...+ag8 = 137.Note: the formalized statement in miniF2F provides the answer and asks for a proof of it.</td></tr><tr><td>Model proof</td><td>theorem aime_1984_p1 (u:N→Q) (ho :∀n,u(n+1)=un+1) (hi :∑k in finset.range 98,u k.succ = 137): ∑ k in finset.range 49,u (2 * k.succ)= 93 := begin revert_all, simp [finset.sum_range_succ], ring, simp[pow_succ,mul_comm,add_left_comm,add_assoc], simp [two_mul], rintro p, revert p, simp [add_comm], intros p hp, simp [hp],ring_nf, intros, nlinarith</td></tr><tr><td>Comments</td><td>end The model finds a rather short proof of the statement compared to typ- ical human formalizations (see https://gist.github.com/MantasBaksys/ 3efd5c0d42f440d16c09076db42822f2).</td></tr></table>
|
| 449 |
+
|
| 450 |
+
<table><tr><td>Natural language</td><td>Consider the sequence = 1 3 ,,,. Prove that this sequence tends to 1 as n→ </td></tr><tr><td>Model proof</td><td>theorem aopsbook_v2_c8_ex1 (u:N→R) (ho:∀n,un=n/(n+1)): filter.tendsto u filter.at_top (N 1) := begin revert_all, simp [← nnreal.coe_one], norm_cast, intros, revert ho, assume h, simp [tendsto_const_nhds,← nnreal.coe_one,h], revert u, assume f, norm_num, rw tendsto_iff_norm_tendsto_zero, assume H, convert tendsto_norm_zero.comp tendsto_one_div_add_at_top_nhds_0_nat, funext n, have ho :(((n:R)+1):R)≠0, { norm_cast,exact n.succ_ne_zero,}, rwH, field_simp [ho,norm_neg], ring, rw [← sub_eq_zero], simp [← sub_eq_zero], simp[sub_eq_add_neg],</td></tr><tr><td>Comments</td><td>end An interesting example of a generated have statement,denoted by ho,which is introduced as a cut in order to simplify the expression containing divisions by using field_simp[ho,norm_neg] ata later step.</td></tr></table>
|
| 451 |
+
|
| 452 |
+
<table><tr><td rowspan=1 colspan=1>Natural language</td><td rowspan=1 colspan=1>What is the sum of the units digits of all the multiples of 3 between O and 5O? Note:the formalized statement in miniF2F provides the answer and asks for a proof of it.</td></tr><tr><td rowspan=1 colspan=1>Model proof</td><td rowspan=1 colspan=1>theorem mathd_numbertheory_447 :∑ k in finset.filter (入 ×,3|x)(finset.erase (finset.range 50) 0),(k % 10) = 78 :=beginreflend</td></tr><tr><td rowspan=1 colspan=1>Comments</td><td rowspan=1 colspan=1>Because the predicate 入 ×,3|× is registered as decidable over N,we can state theproblem by using finset.filter,which is computable.Hence,refl is able toclose the goal.</td></tr></table>
|
md/dev/0Q6BzWbvg0P/0Q6BzWbvg0P.md
ADDED
|
@@ -0,0 +1,482 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# LESS IS MORE: DIMENSION REDUCTION FINDS ON-MANIFOLD ADVERSARIAL EXAMPLES IN HARDLABEL ATTACKS
|
| 2 |
+
|
| 3 |
+
Anonymous authors Paper under double-blind review
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
Designing deep networks robust to adversarial examples remains an open problem. Likewise, recent zeroth-order hard-label attacks on image classification models have shown comparable performance to their first-order, gradient-level alternatives. It was recently shown in the gradient-level setting that regular adversarial examples leave the data manifold, while their on-manifold counterparts are in fact generalization errors. In this paper, we argue that query efficiency in the zeroth-order setting is connected to an adversary’s traversal through the data manifold. To explain this behavior, we propose an information-theoretic argument based on a noisy manifold distance oracle, which leaks manifold information through the adversary’s gradient estimate. Through numerical experiments of manifold-gradient mutual information, we show this behavior acts as a function of the effective problem dimensionality. On high-dimensional real-world datasets and multiple zeroth-order attacks using dimension reduction, we observe the same behavior to produce samples closer to the data manifold. This can result in up to $4 \mathbf { x }$ decrease in the manifold distance measure, regardless of the model robustness. Our results suggest that taking the manifold-gradient mutual information into account can thus inform better robust model design in the future, and avoid leakage of the sensitive data manifold information.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Adversarial examples against deep learning models were originally investigated as blind spots in classification (Szegedy et al., 2013; Goodfellow et al., 2014). Formal methods for discovering these blind spots emerged, which we denote as gradient-level attacks, and became the first techniques to reach widespread attention within the deep learning community (Papernot et al., 2016; MoosaviDezfooli et al., 2015; Carlini & Wagner, 2016; 2017; Chen et al., 2018). In order to compute the necessary gradient information, such techniques required access to the model parameters and a sizeable query budget. These shortcomings were addressed by the creation of score-level attacks, which only require the confidence values output by the deep learning models (Fredrikson et al., 2015; Tramer et al., 2016; Chen et al., 2017; Ilyas et al., 2018). However, these attacks still rely on \` models to divulge information that would be impractical to receive in real-world systems. By contrast, hard-label attacks make no assumptions about receiving side information, and only the predicted class is observable, thus providing the weakest, yet most realistic adversarial threat model. These methods, which originated from a random-walk on the decision boundary (Brendel et al., 2017), have been carefully refined to offer convergence guarantees (Cheng et al., 2019), query efficiency (Chen et al., 2019; Cheng et al., 2020), and capability in the physical world Feng et al. (2020).
|
| 12 |
+
|
| 13 |
+
Despite the steady improvements of hard-label attacks, open questions persist about their behavior, and adversarial machine learning (AML) attacks at large. Adversarial examples were originally assumed to lie in rare pockets of the input space (Goodfellow et al., 2014), but this conventional wisdom was later challenged by the boundary tilting assumption (Tanay & Griffin, 2016; Gilmer et al., 2018), which adopts a “data-geometric” view of the input space living on a lower-dimensional manifold. This is supported by Stutz et al. (2019), who suggest that regular adversarial examples leave the data manifold, while on-manifold adversarial examples are generalization errors. From a data-geometric perspective, an adversarial example’s distance to the manifold primarily describes the amount of semantic features preserved during the attack process. This makes it advantageous to produce on-manifold adversarial examples, since the adversary can exploit the inherent generalization error of the model while producing samples that are semantically similar for humans. However, the true data manifold is either difficult or impossible to describe, and relying solely on approximations of the manifold can lead to the creation of crude adversarial examples (Stutz et al., 2019).
|
| 14 |
+
|
| 15 |
+
In this paper, we adopt the boundary-tilting assumption and demonstrate an unexpected benefit of query-efficient zeroth-order attacks, i.e., attacks enabled by the use of dimensionality reduction techniques. These attacks are more likely to discover on-manifold examples, which we theoretically demonstrate is the result of manifold-gradient mutual information. Our results suggest that this quantity can increase as a function of the data dimensionality. This information leakage leads to adversarial examples that are on-manifold generalization errors. With this knowledge, we empirically demonstrate how to improve hard-label attacks in a generic yet principled way, and potentially re-think their interaction with model robustness and public-facing systems in the near future.
|
| 16 |
+
|
| 17 |
+
For clarity, we provide a block diagram of our claims and experiments in the Appendix (Section A.3). Our specific contributions are as follows:
|
| 18 |
+
|
| 19 |
+
• Introduction of manifold distance oracle. To create on-manifold examples, the adversary must (implicitly) leverage manifold information during the attack phase. We thus propose an informationtheoretic formulation of the noisy manifold distance (NMD) oracle, which can explain how zerothorder attacks craft on-manifold examples. We theoretically demonstrate on a Gaussian data model that manifold-gradient mutual information can increase as a function of data dimensionality. We empirically show this is true even on large-scale image datasets such as CIFAR-10 and ImageNet. This finding relates to known behavior in the gradient-level setting, where semantic manifold priors (e.g., shapes and textures) can be leaked from robust models (Engstrom et al., 2019).
|
| 20 |
+
|
| 21 |
+
• Reveal new insights of manifold feedback during query-efficient zeroth-order search. In practice, the data manifold is difficult to characterize. We propose the use of three proxies for manifold distance, which all show consistent results in terms of an adversary’s ability to search near the manifold. This methodology allows us to empirically demonstrate the connection between dimension reduction, model robustness, and manifold feedback from the model, beyond the known convergence rates tied to dimensionality (Nesterov & Spokoiny, 2017). Our findings inform how to search closer to the manifold (Table 1), reduce gradient deviation (Table 2), and improve query efficiency (Figure 2) in a simple and generic way for hard-label attacks.
|
| 22 |
+
|
| 23 |
+
• Attack-agnostic method for super-pixel grouping. We show that spatial dimension reduction of a decision-based gradient estimate acts as an attack- and knowledge-agnostic method for searching over super-pixels of an image. More importantly, this helps an attacker exploit a model’s reaction to salient input changes, leading to samples closer to the manifold compared to the attack on full dimension. As a result, we demonstrate up to $200 \%$ and $340 \%$ success rate improvement for state-of-the-art hard-label attacks HSJA (Chen et al., 2019) and Sign-OPT attack (Cheng et al., 2020), respectively.
|
| 24 |
+
|
| 25 |
+
# 2 RELATED WORK
|
| 26 |
+
|
| 27 |
+
Since the original discovery of adversarial samples against deep models (Szegedy et al., 2013; Goodfellow et al., 2014), the prevailing question was why such examples existed. The original assumption was that adversarial examples lived in low-probability pockets of the input space, and were never encountered during parameter optimization (Szegedy et al., 2013). This effect was believed to be amplified by the linearity of weight activations in the presence of small perturbations (Goodfellow et al., 2014). These assumptions were later challenged by the boundary tilting assumption, which in summary 1) asserts that the train and test sets of a model only occupy a sub-manifold of the true data, while the decision boundary lies close to samples on and beyond the sub-manifold (Tanay & Griffin, 2016), and 2) supports the “data geometric“ view, where high-dimensional geometry of the true data manifold enables a low-probability error set to exist (Gilmer et al., 2018). Likewise the boundary tilting assumption describes adversarial samples as leaving the manifold, which has inspired defenses based on projecting such samples back to the data manifold (Jalal et al., 2019; Samangouei et al., 2018). However, these approaches were later defeated by adaptive attacks (Carlini et al., 2019; Carlini & Wagner, 2017; Tramer et al., 2020).
|
| 28 |
+
|
| 29 |
+
We investigate the scenario where an adversary uses zeroth-order information (i.e., top-1 label feedback) to estimate the desired gradient direction (Cheng et al., 2020; Chen et al., 2019). Contemporary attacks in this setting are variants of random gradient-free method (RGF) (Nesterov & Spokoiny, 2017), and rely on formulations which convert the top-1 (hard) label, which is a step function, into a continuous real-valued function $\cdot$ , which takes search direction $\cdot$ and outputs the distance to the nearest adversarial example (Cheng et al., 2018). The gradient estimate is conceived as a function of the gradient $\cdot$ and can be estimated with either two samples of information (SignOPT) (Cheng et al., 2020), or a single point (HopSkipJumpAttack) (Chen et al., 2019). Details of specific formulations for each attack are provided in Section A.2 of the Appendix.
|
| 30 |
+
|
| 31 |
+
Query efficiency is a persistent desire in the study of hard-label attacks. One clue for achieving efficiency comes from the theory of gradient estimation error and convergence, which shows that the estimation cost is polynomial in $d$ , the dimension of the optimized variable, thus motivating the use of standard dimension-reduction techniques (Tu et al., 2019). However, to date it is not completely understood how this relates to traversal through the data manifold. We leverage previous results of the gradient-level setting (Stutz et al., 2019; Engstrom et al., 2019) to formulate an explanation of manifold leakage during hard-label adversarial attacks.
|
| 32 |
+
|
| 33 |
+
# 3 NOISY MANIFOLD DISTANCE ORACLE
|
| 34 |
+
|
| 35 |
+
Santurkar et al. (2019) demonstrate that the gradients of robust models have higher visual semantic alignment with the data compared to gradients of standard models. We build on this finding by first assuming that the benign observable data generates from a true lower-dimension distribution. Under the boundary-tilting assumption, this lower-dimension distribution forms a manifold onto which new observations, either benign or adversarial, can be encoded (Tanay & Griffin, 2016). Likewise, we assume that deep learning models will learn a lower-dimension representation of the observable data, e.g., feature layers of convolutional neural networks learn to encode training observations onto a low dimension approximate manifold (Zhang et al., 2018). When an adversary creates adversarial samples, they are leveraging a pathway that shadows the model gradient, not the true manifold. Thus there is the possibility that adversarial samples are considered “off-manifold”, e.g., cannot be expected to generate naturally from the true manifold. However, it is critical for adversarial samples to be as close to the manifold as possible, since on-manifold adversarial examples can exploit the fundamental generalization error of the model (Stutz et al., 2019). More formally, we define the notion of manifold distance as follows.
|
| 36 |
+
|
| 37 |
+
Definition 3.1 (Manifold Distance). Consider the benign sample $\mathbf { x } _ { \mathrm { 0 } }$ and adversarial counterpart $\mathbf { x }$ . Assuming a perfect encoding back to the true manifold $\phi$ , the manifold distance is defined as $\mathrm { d } ( \phi ( \mathbf { x } _ { 0 } ) , \phi ( \mathbf { x } ) )$ , where d is a distance function with the domain of the true manifold.
|
| 38 |
+
|
| 39 |
+
Unfortunately, unless the true manifold for a dataset is known, it is impossible to define $\phi$ . Instead, a proxy $\mathrm { d } ^ { \prime }$ can be used such that $\mathrm { d } ^ { \prime } ( \mathbf { x } , \mathbf { x } ^ { \prime } ) \sim \mathrm { d } ( \phi ( \mathbf { x } ) , \phi ( \mathbf { x } ^ { \prime } ) )$ . In practice, one can implement $\mathrm { d } ^ { \prime }$ with any perceptual distance score, such as Learned Perceptual Image Patch Similarity (Zhang et al., 2018). If relying on a distance measure $\mathrm { d }$ , such as the $L _ { p }$ -norm, an approximate encoder $\phi ^ { \prime } ( \cdot ) \^ { - } \phi ( \cdot )$ can be learned using reconstruction-based training of autoencoders (Stutz et al., 2019), or leveraging feature layers of convolutional neural networks (Zhang et al., 2018). We are interested in the class of hard-label adversaries that implicitly minimize some proxy of the manifold distance. Given the result of Santurkar et al. (2019), the robust model’s gradient could be treated as a manifold distance oracle, because it leaks the direction towards its approximate manifold. As a result, the model acts as an oracle responding to queries about manifold distance, or in other words, an implicit proxy for manifold distance, $\mathrm { d } ^ { \prime }$ . In the hard-label setting, the data manifold, true gradient, and model parameters are not accessible. Thus we are interested in a decision-based version of the manifold distance oracle, defined as follows.
|
| 40 |
+
|
| 41 |
+
Definition 3.2 (Noisy Manifold Distance Oracle). Consider a manifold distance oracle instantiating $\mathrm { d } ^ { \prime }$ , benign sample $\mathbf { x } _ { \mathrm { 0 } }$ , and pair of adversarial samples $( \mathbf { x } ^ { \prime } , \mathbf { x } ^ { \prime \prime } )$ such that $\mathrm { d } ^ { \prime } ( \mathbf { x } _ { 0 } , \mathbf { x } ^ { \prime } ) < \mathrm { d } ^ { \prime } ( \mathbf { x } _ { 0 } , \mathbf { x } ^ { \prime \prime } ) $ , e.g., $\mathbf { x } ^ { \prime }$ is considered on-manifold while $\mathbf { x } ^ { \prime \prime }$ is not. In the hard-label setting, the noisy manifold distance (NMD) oracle instantiates $\mathrm { d } ^ { \prime \prime }$ such that $\mathrm { d } ^ { \prime \prime } ( \mathbf { x } _ { 0 } , \mathbf { x } ^ { \prime } ) = 0$ and $\mathrm { d } ^ { \prime \prime } ( \mathbf { x } _ { 0 } , \mathbf { x } ^ { \bar { \prime } \prime } ) = 1$ .
|
| 42 |
+
|
| 43 |
+
During a hard-label attack, the adversary searches in a direction that minimizes perceptual distance to the original sample. Concurrently, the adversary can be said to implicitly minimize the expected output of the NMD oracle, which is a binary indicator that a sample is on-manifold or not. Without knowledge of the true (or approximate) manifold, this requires careful selection of the search direction from the current sample. Since the search direction of contemporary hard-label attacks is synthesized over expectation of a ball around the adversarial sample, we are interested in search directions such as $\mathbf { x } _ { 0 } - \mathbf { x } ^ { \prime }$ which minimize the expected distance to the manifold.
|
| 44 |
+
|
| 45 |
+
To formalize the entailed information in the NMD oracle, we turn to a standard result in data processing, which states the following:
|
| 46 |
+
|
| 47 |
+
Definition 3.3 (Data Processing Inequality (DPI) (Beaudry & Renner, 2012)). If three random variables form the Markov chain $X Y Z$ , then their mutual information (MI) has the relation $I ( X ; Y ) \geqslant I ( X ; Z )$ .
|
| 48 |
+
|
| 49 |
+
We assume the data manifold $\mathcal { M }$ , the input gradient $\mathcal { G }$ , and the hard-label gradient estimate $\ddot { \mathcal { G } }$ will form the Markov chain $\mathcal { M } \to \mathcal { G } \to \ddot { \mathcal { G } }$ . This assumption is reasonable due to the observations by Santurkar et al. (2019); modifying the sampled data manifold (e.g., by adding adversarial samples through saddle-point optimization) causally induces a smoother loss surface, which imposes its own gradient distribution. Likewise, the true gradient and gradient estimate of hard-label attack are causally linked due to the estimate’s bounded variance (Cheng et al., 2020).
|
| 50 |
+
|
| 51 |
+
If $I ( { \mathcal { M } } , { \mathcal { G } } )$ is larger for adversarially robust models, by Definition 3.3 the upper bound on $I ( { \mathcal { M } } , { \ddot { \mathcal { G } } } )$ is larger, which means more manifold information could be leaked in the noisy gradient. This information could be used to search in the direction where $\mathrm { d } ^ { \prime \prime }$ is minimized in expectation, leading towards on-manifold examples. However, DPI only offers an upper bound, thus the distance decrease is not guaranteed, only suggested. In the information theoretic sense, does this mean the gradients of models robust in an $\epsilon$ -ball around each sample can reveal more information about the distance to training data than standard models? An immediate follow-up concern is whether other factors can influence the model to reveal this information, such as the problem dimensionality. As a first step we posit the following hypothesis:
|
| 52 |
+
|
| 53 |
+
Hypothesis 1. Consider the manifold distribution $\mathcal { M }$ which can generate data to train a natural model with gradient distribution $\mathcal { G }$ , and train robust model with smoothed gradient distribution $\mathcal { G } ^ { \prime }$ . We posit that their manifold-gradient mutual information $I$ has the relation $\bar { I } ( \mathcal { M } , \mathcal { G } ^ { \prime } ) \geq I ( \mathcal { M } , \mathcal { G } )$ .
|
| 54 |
+
|
| 55 |
+
In order to empirically verify Hypothesis 1, we must parameterize the notion of model robustness while solving for $I ( { \mathcal { M } } , { \mathcal { G } } )$ , given an arbitrary gradient distribution $\mathcal { G }$ and manifold distribution $\mathcal { M }$ Schmidt et al. (2018) have shown that robust training requires additional data as a function of the data dimensionality. We leverage the data model and results from Schmidt et al. (2018) to derive an analytical solution for $I ( \mathcal { M } , \bar { \mathcal { G } } )$ , since we can parameterize model robustness as a function of data size and dimensionality. Consequently, the remainder of our theoretical analysis assumes a Gaussian mixture data model.
|
| 56 |
+
|
| 57 |
+
Definition 3.4 (Data model and optimal weights (Schmidt et al., 2018)). Let $\pmb { \mu } \in \mathbb { R } ^ { d }$ be the per-class centers (means) and let $\sigma > 0$ be the variance parameter. Then the $( \mu , \sigma I )$ -Gaussian model is defined by the following distribution over $( \mathbf { x } , y ) \in \bar { \mathbb { R } ^ { d } } \times \{ \pm 1 \}$ : First, draw a label $y \in \{ \pm 1 \}$ uniformly at random. Then sample the data point $\mathbf { x } \in \mathbb { R } ^ { d }$ from $\mathcal { N } ( \boldsymbol { y } \cdot \boldsymbol { \mu } , \sigma \boldsymbol { I } )$ .
|
| 58 |
+
|
| 59 |
+
Definition 3.5 (Optimal classification weight (Schmidt et al., 2018)). Fix $\sigma \leq c _ { 1 } d ^ { \frac { 1 } { 4 } }$ for the universal constant $c _ { 1 }$ , and samples $( \mathbf { x } _ { 1 } , y _ { 1 } ) , \cdot \cdot \cdot , ( \mathbf { x } _ { n } , y _ { n } )$ drawn $i . i . d$ from the $( \mu , \sigma I )$ -Gaussian model with $| | { \boldsymbol { \mu } } | | = { \sqrt { d } }$ (i.e., $\mu _ { k } = 1$ for all dimensions $k \in \{ 0 , \ldots , d \} )$ . Schmidt et al. (2018) prove that the weight setting $\begin{array} { r } { \widehat { \mathbf { w } } = \frac { 1 } { n } \sum _ { i = 1 } ^ { n } y _ { i } \mathbf { x } _ { i } } \end{array}$ yields an $l _ { \infty } ^ { \epsilon }$ -robust classification error of at most $1 \%$ for the linear classifier $f _ { \widehat { \mathbf { w } } } : \mathbb { R } ^ { d } \{ \pm 1 \}$ instantiated as $f _ { \widehat { \mathbf { w } } } ( x ) = \mathrm { s i g n } ( \widehat { \mathbf { w } } ^ { T } \mathbf { x } )$ if
|
| 60 |
+
|
| 61 |
+
$$
|
| 62 |
+
n \geq \left\{ \begin{array} { l l } { { 1 , } } & { { \mathrm { f o r } ~ \epsilon \leq \frac 1 4 d ^ { - \frac 1 4 } } } \\ { { c _ { 2 } \epsilon ^ { 2 } \sqrt { d } , } } & { { \mathrm { f o r } ~ \frac 1 4 d ^ { - \frac 1 4 } \leq \epsilon \leq \frac 1 4 } } \end{array} , \right.
|
| 63 |
+
$$
|
| 64 |
+
|
| 65 |
+
for a universal constant $c _ { 2 }$
|
| 66 |
+
|
| 67 |
+
Note that the instantiation of $\widehat { \bf w }$ must change with choice of $\epsilon$ and $d$ . We can leverage the weight settings as a function of $n$ and $d$ to give a definition of manifold-gradient mutual information.
|
| 68 |
+
|
| 69 |
+

|
| 70 |
+
Figure 1: a) Average per-dimension mutual information $\cdot$ over dimension $d$ for values of $c _ { 2 }$ and $\epsilon$ in Equation 13, log-scale $\cdot$ -axis with $\cdot$ , average over ten seeds. The approximate mutual information is higher for robust and standard models at lower $d$ regardless of $\cdot$ and choice of $\cdot$ .
|
| 71 |
+
|
| 72 |
+
# 3.1 MANIFOLD-GRADIENT MUTUAL INFORMATION
|
| 73 |
+
|
| 74 |
+
Notice the classifier $\operatorname { s g n } ( { \mathord { \cdot } } )$ in Definition 3.5 is discontinuous at ${ \bf x } _ { k } = 0$ for any dimension $k$ . Instead we consider the sub-gradient of the classifier at $\mathbf { x } _ { k } < 0$ and $\mathbf { x } _ { k } > 0$ . In either case (non-robust or robust), the input sub-gradient for $f _ { \widehat { w } } ( \mathbf { x } _ { k } ^ { \prime } )$ is defined dimension-wise for our isotropic Gaussian as $\nabla _ { \mathbf x _ { k } ^ { \prime } } f _ { \widehat { \mathbf w _ { k } } } = \mathrm { s i g n } \mathbf w _ { k }$ b. Since the weight of each dimension is Gaussian distributed with $\widehat { \mathbf { w } _ { k } } \sim$ $\mathcal { N } ( \mu _ { k } , \sigma ^ { 2 } )$ , we can define the distribution of gradients as $\mathcal { G } \sim$ Rademacher $\left( \mathbb { P } _ { \widehat { \mathbf { w } _ { k } } \sim \mathcal { N } } \left[ \widehat { \mathbf { w } _ { k } } \geq 0 \right] \right) ,$ ). c cUsing this fact, we define manifold-gradient mutual information in three parts: 1) defining the manifold-gradient point-wise joint probabilities between $\mathbf { g } _ { k }$ and $\mathbf { x } _ { k }$ at each dimension $k$ for the sub-gradient cases where $\mathbf { x } _ { k } > 0$ and $\mathbf { x } _ { k } < 0 , 2$ ) defining the manifold-gradient marginal probability under the gradient, and 3) the marginal probability under the manifold. The complete derivation of the joint and marginal probabilities can be found in Section A.1 of the Appendix. The three parts are used in the standard definition of mutual information (Cover & Thomas, 2006).
|
| 75 |
+
|
| 76 |
+
Notation. Fix $\sigma = c _ { 1 } d ^ { \frac { 1 } { 4 } }$ for both cases. We denote the sub-manifold sampled from the positive $( y = 1 )$ ) and negative $( y = - 1$ ) classes as $\mathcal { M } ^ { + }$ and $\mathcal { M } ^ { - }$ , respectively. For brevity we label $\mathbf { x } _ { k } > 0$ as $\mathbf { x } ^ { + }$ and $\mathbf { x } _ { k } < 0$ as $\mathbf { x } ^ { - }$ .
|
| 77 |
+
|
| 78 |
+
Definition 3.6 (Manifold-Gradient Mutual Information). We define the manifold-gradient mutual information, based on the standard definition of mutual information from information theory (Cover & Thomas, 2006), as
|
| 79 |
+
|
| 80 |
+
$$
|
| 81 |
+
I ( \mathcal M , \mathcal G ) _ { \epsilon , k } = 2 \int _ { \mathcal M ^ { + } } p ( 1 , \mathbf x ^ { + } ) \log ( \frac { p ( 1 , \mathbf x ^ { + } ) } { p _ { \mathcal G } ( 1 ) p _ { \mathcal M } ( \mathbf x ^ { + } ) } ) d \mathbf x ^ { + } + 2 \int _ { \mathcal M ^ { + } } p ( - 1 , x ^ { + } ) \log ( \frac { p ( - 1 , x ^ { + } ) } { p _ { \mathcal G } ( - 1 ) p _ { \mathcal M } ( x ^ { + } ) } ) d x ^ { + } .
|
| 82 |
+
$$
|
| 83 |
+
|
| 84 |
+
with the total unnormalized mutual information defined as the summation over dimensions (due to dimension co-independence) $\begin{array} { r } { I ( \mathcal { M } , \mathcal { G } ) _ { \epsilon } = \sum _ { k = 1 } ^ { d } I ( \mathcal { M } , \mathcal { G } ) _ { \epsilon , k } } \end{array}$ .
|
| 85 |
+
|
| 86 |
+
# 3.2 MUTUAL INFORMATION AS A FUNCTION OF DIMENSIONALITY
|
| 87 |
+
|
| 88 |
+
To provide numerical support for Hypothesis 1, we run experiments using the Riemann approximation of Equation 13, provided in the Appendix as Equation 15. We estimate the average per-dimension mutual information, $\begin{array} { r } { I ( \mathcal { M } , \mathcal { G } ) _ { \epsilon , \overline { { k } } } = \frac { I ( \mathcal { M } , \mathcal { G } ) _ { \epsilon } } { d } } \end{array}$ I(M,G)d , for the case where x ∈ Rd while varying the dimensionality term $\cdot$ against values of $c _ { 2 } \in \{ 1 , 1 0 0 \}$ and $-$ . The values of $c _ { 2 }$ represent two multiplicative factors for number of samples in robust models (Equation 1). In our experiments, we target an error within $1 0 ^ { - 1 }$ (e.g., $-$ . Thus we multiply each branch of Equation 1 by a large constant $( 1 0 ^ { 4 } )$ . We run the approximation over ten different random seeds and show the average with standard error shaded.
|
| 89 |
+
|
| 90 |
+
The estimation result is shown in Figure 1 with log-scale $\mathbf { X }$ -axis. Regardless of $c _ { 2 }$ and $\epsilon$ , lower values of the dimensionality evidence a higher mutual information. We minimize variance of the estimate when $\cdot$ (right plot shaded area), which follows intuition due to the higher sample count in the estimate.
|
| 91 |
+
|
| 92 |
+
Observation 1. Given reduced data dimensionality, a robust model could increase $I ( \mathcal { M } , \mathcal { G } ) _ { \epsilon , \overline { { k } } }$ and lead to leaking better search direction through the gradient (e.g., act as manifold distance oracle). This supports Hypothesis 1.
|
| 93 |
+
|
| 94 |
+
This can theoretically explain the high visual alignment observed empirically by Engstrom et al. (2019) and Santurkar et al. (2019) on robust models. From the security perspective, the NMD oracle acts as a side channel leaking sensitive information as a factor of the model robustness and data dimensionality.
|
| 95 |
+
|
| 96 |
+
# 4 ZEROTH-ORDER SEARCH THROUGH THE MANIFOLD DISTANCE ORACLE
|
| 97 |
+
|
| 98 |
+
According to Observation 1, the true gradient and manifold of a robust model have higher mutual information, and this is exacerbated by reducing the data dimensionality. Under our Markov chain assumption, this means an attack algorithm can act as a noisy manifold distance oracle, and this oracle could be upper bounded by the true gradient-manifold mutual information. Although the data dimensionality and robustness are controlled by the model designer, an attacker can search in arbitrarily lower dimensionality through dimension-reduction techniques, such as autoencoder-based attacks (Tu et al., 2019). In fact, in the image domain the intrinsic dimensionality of data can be lower than the true dimension (Amsaleg et al., 2017). In order to connect the notion of manifold-gradient mutual information with on-manifold adversarial samples of real datasets, we posit the following.
|
| 99 |
+
|
| 100 |
+
Hypothesis 2. Consider Observation 1 and Definition 3.3 (DPI), then due to the higher upper bound on $I ( { \mathcal { M } } , { \ddot { \mathcal { G } } } )$ and leaking better search directions, a hard-label adversary can minimize $d ^ { \prime \prime }$ in expectation on robust models when the gradient estimate dimensionality is reduced.
|
| 101 |
+
|
| 102 |
+
In the most common problem setting, the adversary is interested in attacking a $K$ -way multiclass classification model $f : \mathbb { R } ^ { d } \mathbf { \bar { \{ 1 , \dots , K \} } }$ . Given an original example $\mathbf { x } _ { \mathrm { 0 } }$ , the goal is to generate adversarial example $\mathbf { x }$ such that $\mathbf { x }$ is close to $\mathbf { x } _ { \mathrm { 0 } }$ and $f ( \mathbf { \bar { x } } ) \neq f ( \mathbf { x } _ { 0 } )$ , where closeness is often approximated by the $L _ { p }$ -norm of ${ \bf x } - { \bf x } _ { 0 }$ . In the gradient-level setting, we require the gradient $\nabla f ( \cdot )$ . However, in the hard-label setting we are forced to estimate $\frac { \partial f ( \mathbf { x } ) } { \partial \mathbf { x } }$ without access to $\nabla f ( \cdot )$ , only decision evaluations of $f$ . Rather than optimizing the step function $\boldsymbol { \mathscr { f } }$ , hard-label attacks minimize the continuous function $g ( \pmb \theta )$ , which is an estimate of the distance to the nearest decision boundary in the direction $\pmb \theta$ . We evaluate the effect of dimension reduction on Sign-OPT attack (Cheng et al., 2020) and HopSkipJumpAttack (HSJA) (Chen et al., 2019), as both are considered state-of-the-art in the literature, and rely on minimization of $g ( \cdot )$ . We provide a brief overview of their formulation in Section A.2 of the Appendix, and leave details to the respective authors’ work. Alternative hard-label attacks, such as RayS by Chen & Gu (2020), do not rely on the explicit zeroth-order gradient estimate from the model. This style of attack behaves differently since it can adapt to the problem dimension independent of the true gradient, which we demonstrate in Section A.5.6 of the Appendix.
|
| 103 |
+
|
| 104 |
+
# 4.1 DIMENSION-REDUCED ZEROTH-ORDER SEARCH
|
| 105 |
+
|
| 106 |
+
To test Hypothesis 2, we modify existing hard-label attacks to produce dimension-reduced variants. This scheme enables dynamic scaling of the effective dimensionality regardless of specific attack formulation. In practice we implement the reduction through an encoding map $\mathcal { E } : \mathbb { R } ^ { d } \mathbb { R } ^ { d ^ { \prime } }$ for reduced dimension $d ^ { \prime }$ and decoding map $\mathcal { D } : \mathbb { R } ^ { d ^ { \prime } } \mathbb { R } ^ { d }$ . In general the adversarial sample is created by $\begin{array} { r } { \mathbf { x } = \mathbf { x } _ { 0 } + g \left( { \cal D } ( \pmb { \theta } ^ { \prime } ) \right) \frac { \pmb { \mathcal { D } } ( \pmb { \theta } ^ { \prime } ) } { | | \pmb { \mathcal { D } } ( \pmb { \theta } ^ { \prime } ) | | } } \end{array}$ , where $\pmb { \theta } ^ { \prime } \in \mathbb { R } ^ { d ^ { \prime } }$ and is optimized depending on the respective attack (e.g., Sign-OPT and HSJA), and as before, $g$ is a measure of distance to the decision boundary in direction ${ \mathcal { D } } ( \theta ^ { \prime } )$ . The mapping functions can be initialized with either an autoencoder (AE), or a pair of channel-wise bilinear transform functions (henceforth referred to as BiLN) which simply scales the spatial dimension of the input up or down. This represents two distinct methods to search over super-pixels of the image, which either rely on an approximate description of the manifold (AE), or instead exploit the known spatial co-dependence of images (BiLN). The implementation and training details of the AE variant can be found in Section A.4.2 of the Appendix. To study the effect of dimension-reduction without semantic information, we implement a random variant of BiLN (Rand) which samples a subset of coordinates uniform-randomly from the source image as the dimension-reduced version, then replaces the pixels at these coordinates with those from the gradient estimate. This is meant to show the effect of discarding some semantic information (e.g., spatial correlation) in the update.
|
| 107 |
+
|
| 108 |
+
# 4.2 ESTIMATING MANIFOLD DISTANCE
|
| 109 |
+
|
| 110 |
+
We leverage three proxies of manifold distance in order to test Hypothesis 2. The Learned Perceptual Image Patch Similarity (LPIPS) acts as a proxy for manifold distance, $\mathrm { d } ^ { \prime }$ , and computes a distance that correlated well with human perception in human studies (Zhang et al., 2018; Laidlaw et al., 2021). We use the same LPIPS code and checkpoint provided by the authors. Frechet Inception ´ Distance (FID) (Heusel et al., 2018) is similar to LPIPS, and leverages the internal representations of deep networks as an approximate encoding onto the manifold. Although FID lacks human studies, Heusel et al. (2018) show it is viable for scoring the visual quality of synthetically generated images, which offers us a comparison against LPIPS. In addition to LPIPS and FID, we create an approximate encoding $\phi ^ { \prime }$ by taking the encoder of trained autoencoders for each dataset, which can be used to compute $L _ { \infty }$ distance between encoded samples. In other words, this lets us compute $| | \phi ^ { \prime } ( \mathbf { x } _ { 0 } ) - \phi ^ { \prime } ( \bar { \mathbf { x } } ) | | _ { \infty }$ for benign sample $\mathbf { x } _ { \mathrm { 0 } }$ and adversarial sample x. The results on FID and our trained autoencoder were consistent with LPIPS, so they are described in Section A.5.9 of the Appendix.
|
| 111 |
+
|
| 112 |
+
Finally, if hard-label gradient estimates on real-world data resulted in a sample close to the approximate manifold, we could say the gradient estimates leveraged noisy mutual information, which may be upper bounded by the clean mutual information (Hypothesis 1). This would manifest in a lower gradient deviation, or in other words, the distance between the true gradient and gradient estimate at the first attack step. We can further infer that the adversarial training effectively smooths the sampled data manifold (which generates from true manifold) by augmenting perturbed data samples during training. The smoothing yields a well-defined boundary that aligns with salient input changes (Santurkar et al., 2019), and should further lower variance of the gradient estimate compared to natural models, which improves the baseline performance of an attack. We test this by calculating per-pixel gradient deviation $\frac { | | \mathbf { g } - \hat { \mathbf { g } } | | _ { 2 } } { H \times W }$ for true gradient $\mathbf { g }$ (in the direction of the adversarial label), first gradient estimate $\hat { \bf g }$ , estimate height $H$ , and estimate width $W$ . When taking the true input gradient in the direction of the adversarial label, we use the victim model’s original criterion to calculate the gradient, which was cross-entropy for all models in our evaluation.
|
| 113 |
+
|
| 114 |
+
# 5 RESULTS & DISCUSSION
|
| 115 |
+
|
| 116 |
+
We test Hypothesis 2 by comparing two SotA hard-label attacks with their compatible dimensionreduced variants, against both natural and robust models. First we show empirical evidence of the relationship between manifold distance and dimension-reduced attacks in Section 5.1. Next in Section 5.2, we investigate the result of Section 5.1 from the perspective of reducing error in the gradient estimate. Finally in Section 5.3, we show how these observations inform better attack design.
|
| 117 |
+
|
| 118 |
+
Setup. We perform experiments using CIFAR-10 (Krizhevsky, 2009) and ImageNet (Krizhevsky et al., 2012) for RGB image data. The natural CIFAR-10 network is the same implementation opensourced by Cheng et al. (2020). The architecture for ImageNet is the Resnet50 network taken from the PyTorch Torchvision library, and the accompanying pre-trained weights act as the natural model.1 In addition, we leverage the representative adversarial training technique proposed by Madry et al. (2017) (and their = 8255 $\epsilon = \overline { { \frac { 8 } { 2 5 5 } } } = 0 . \dot { 0 3 } 1$ checkpoints for $L _ { \infty }$ setting) as the robust models for CIFAR-10 and ImageNet. The BiLN variants downscale to $1 6 \times 1 6$ for CIFAR-10, and $3 2 \times 3 2$ for ImageNet. We use $L _ { \infty }$ -norm versions of attacks for all experiments, and the same $\epsilon$ values for natural models as the robust CIFAR-10 and robust ImageNet (hereafter referred to as Madry CIFAR-10 and Madry ImageNet). All attacks run for $2 5 \mathrm { k }$ queries without early stopping on correctly classified samples. For brevity, we only show results for the untargeted case. Additional implementation details, such as hyperparameters and hardware used, can be found in the Appendices (Section A.4). Code for experiments is provided in the supplementary materials.
|
| 119 |
+
|
| 120 |
+
Table 1: Average LPIPS scores for each attack’s set of 200 adversarial samples on CIFAR-10 and ImageNet (lower is better). Arrows denote higher or lower score compared to baseline variant, and starred items indicate highest success rate.
|
| 121 |
+
|
| 122 |
+
<table><tr><td>Attack Variant</td><td>Natural CIFAR-10</td><td>Madry CIFAR-10</td><td>Natural ImageNet</td><td>Madry ImageNet</td></tr><tr><td>HSJA</td><td>0.132 ± 0.098*</td><td>1.335 ± 0.611</td><td>0.257 ± 0.378</td><td>1.249 ± 0.652</td></tr><tr><td>HSJA+BiLN</td><td>0.252 ±0.165个</td><td>1.147 ± 0.535↓*</td><td>0.170 ± 0.143↓*</td><td>1.205± 0.711↓*</td></tr><tr><td>HSJA+Rand</td><td>1.433 ± 0.747个</td><td>2.384± 0.503个</td><td>1.276 ± 0.649个</td><td>1.183 ± 0.596↓</td></tr><tr><td>Sign-OPT</td><td>0.105 ± 0.081</td><td>0.768 ±0.408</td><td>0.768± 0.872</td><td>1.229 ± 0.771</td></tr><tr><td>Sign-OPT+BiLN</td><td>0.225 ± 0.146个</td><td>0.849 ± 0.397个</td><td>0.176 ± 0.204↓</td><td>0.708 ±0.461↓</td></tr><tr><td>Sign-OPT+Rand</td><td>0.440 ± 0.464个</td><td>1.021 ± 0.593个</td><td>0.356 ± 0.385↓</td><td>0.367 ± 0.361↓</td></tr><tr><td>Sign-OPT+AE</td><td>0.331 ± 0.389↑</td><td>0.660 ± 0.302↓</td><td>1.034 ± 0.571个</td><td>1.658 ± 0.638个</td></tr></table>
|
| 123 |
+
|
| 124 |
+
<table><tr><td>Med. Benign Local ID</td><td>0.469</td><td>0.224</td><td>1.039</td><td>2.013</td></tr><tr><td>Attack Variant</td><td>Natural CIFAR-10</td><td>Madry CIFAR-10</td><td>Natural ImageNet</td><td>Madry ImageNet</td></tr><tr><td>HSJA</td><td>6.65 ± 0.61*</td><td>5.46 ±0.06</td><td>77.35 ± 0.04</td><td>77.32 ± 0.00</td></tr><tr><td>HSJA+BiLN</td><td>5.37 ± 0.69↓</td><td>3.86 ±0.10↓*</td><td>55.12 ± 1.37↓*</td><td>56.14±0.12↓</td></tr><tr><td>HSJA+Rand</td><td>11.33 ± 7.41个</td><td>2.01 ±1.65↓</td><td>72.19 ± 59.98↓</td><td>3.22 ±2.73</td></tr><tr><td>Sign-OPT</td><td>3.72 ± 0.99</td><td>0.71 ±0.38</td><td>1.70 ± 1.01</td><td>0.55 ± 0.18</td></tr><tr><td>Sign-OPT+BiLN</td><td>3.71 ± 1.02↓</td><td>0.78 ± 0.35个</td><td>1.83 ± 0.97个</td><td>1.74 ± 0.56个</td></tr><tr><td>Sign-OPT+Rand</td><td>8.21 ± 6.67个</td><td>2.32 ± 2.07个</td><td>37.54± 46.20个</td><td>6.72 ± 1.54个</td></tr><tr><td>Sign-OPT+AE</td><td>4.66 ± 0.86↑</td><td>2.48 ± 0.32↑</td><td>36.83 ± 0.15个</td><td>36.87 ± 0.31↑</td></tr></table>
|
| 125 |
+
|
| 126 |
+
Table 2: Average per-pixel gradient deviation on natural and robust CIFAR-10 (unit of $1 0 ^ { - 2 }$ ) and ImageNet (unit of $\mathrm { { \bar { 1 0 } ^ { - 4 } } }$ ) over 200 samples. Top row lists the median Local Intrinsic Dimensionality (LID) of benign samples from the dataset. Arrows denote higher or lower deviation compared to baseline variant, and starred items indicate highest success rate.
|
| 127 |
+
|
| 128 |
+
# 5.1 MANIFOLD DISTANCE
|
| 129 |
+
|
| 130 |
+
LPIPS results are shown in Table 1, with colored arrows denoting either lower distance than baseline variant (green arrow), or a higher distance (red arrow). Generally, the dimension-reduced variants lower the proxy of manifold distance on ImageNet more often than on CIFAR-10 (green arrows). The random sampling variant $\times$ -Rand) discards the semantic priors of the estimate, and in fact it achieved the lowest SR AUC scores, despite having lower scores. Our results using LPIPS are consistent with $L _ { \infty }$ distance of the manifold approximation (Section A.5.9), and Frechet Inception Distance ´ (Section A.5.8), which all demonstrate a tendency to be lower with dimension-reduced attacks.
|
| 131 |
+
|
| 132 |
+
Observation 2. Dimension-reduced hard-label attacks can have lower LPIPS score, $L _ { \infty }$ approximated distance, and Frechet Inception Distance (and thus lower manifold distance) on robust models ´ if they preserve semantic priors in the update, which supports Hypothesis 2.
|
| 133 |
+
|
| 134 |
+
# 5.2 GRADIENT DEVIATION
|
| 135 |
+
|
| 136 |
+
The results for gradient deviation are shown in Table 2. Notably, an attack can have high gradient deviation despite low LPIPS score (AE case, bottom row). Likewise, low deviation does not imply successful attack, as we show later with the Rand variant (rows three and six). We investigated why Madry ImageNet did not always have lower gradient deviation, which we posit is due to having a higher true dimensionality. For the benign samples of each dataset we estimated the Local Intrinsic Dimensionality (LID), which was proposed to estimate true data dimensionality in a region around samples (Amsaleg et al., 2017). In the top row of Table 2 we find the median LID is similar between natural and robust CIFAR-10, but much higher on robust ImageNet than natural. Since our results of Section 3 suggested that higher problem dimension reduced mutual information, we suspect the Madry ImageNet model reduces the leakage through the NMD oracle through higher true data dimensionality. We leave a deeper analysis of this direction for future work. Results on additional robust CIFAR-10 models are provided in Section A.5.2 of the Appendix, which exhibited a similar trend of lower gradient deviation. Sign-OPT has a universally lower gradient deviation than HSJA, which aligns with findings of Liu et al. (2020).
|
| 137 |
+
|
| 138 |
+

|
| 139 |
+
Figure 2: Success rates across attacks over 200 samples on CIFAR-10 (a) and ImageNet (b).
|
| 140 |
+
|
| 141 |
+
Observation 3. The gradient deviation is universally lower on the robust CIFAR-10 model for BiLN attacks (rows two and five). For ImageNet, deviation on robust models is either lower or similar (rows one, two, four, and seven).
|
| 142 |
+
|
| 143 |
+
# 5.3 INFORMING PRACTICE
|
| 144 |
+
|
| 145 |
+
We have shown that dimension reduction has unexpected consequences in terms of manifold distance, and on CIFAR-10 and some ImageNet cases, leads to a lower gradient deviation on the robust model. We finalize our contribution by providing a comprehensive evaluation of the attack success rates in Figure 2 against number of queries. The plots are quantified by taking their max-normalized Trapezoid rule area-under-curve (AUC).2 For comparison, the highest AUC scores are starred in the previous tables. Our dimension-reduced HSJA $+$ BiLN variant (yellow line) surpasses the previous SotA hard-label attack for ImageNet, HSJA, on both natural and robust models. This variant also exhibited the lowest LPIPS score across attack variants. However, lowest LPIPS score does not imply highest SR, evidenced with HSJA $^ +$ Rand on natural ImageNet (brown line, $\mathrm { A U C } = 0 . 0 7 7 $ and SignOPT variants on either dataset (e.g., yellow line in Madry ImageNet, $\mathbf { A U C } = 0 . 2 1 5 ,$ . Low gradient deviation does not imply higher attack success, evidenced by Sign-OPT $+$ BiLN in Table 2 for Madry CIFAR-10 $( \mathrm { A U C } = 0 . 1 5 6 )$ or HSJA $^ { + }$ Rand and Sign-OPT $^ { + }$ Rand $( \mathrm { A U C } = 0 . 0 8 8$ and $\mathrm { { A U C } = 0 . 0 9 2 }$ , respectively). The Rand variants, combined with our findings so far, allow us to say the following.
|
| 146 |
+
|
| 147 |
+
Observation 4. Successful attacks exhibit preservation of leaked semantic priors. Measures of manifold distance such as LPIPS tend to be lower on dimension-reduced attacks, independent of variance in the gradient estimate.
|
| 148 |
+
|
| 149 |
+
We posit that minimizing gradient deviation through correction of estimator bias alone could be misleading, since the semantic information provided by a better NMD oracle (due to dimension reduction) can potentially improve the gradient deviation. Although our theoretical analysis focuses on robust models, we suspect future hard-label attacks may treat $\epsilon$ as a useful prior, which carries with it implications about when to deploy robust models in society. On the contrary, natural models will respond to any input changes, even if they are semantically meaningless (Santurkar et al., 2019), so depending on the adversary’s goal (e.g., evasion or information leakage), they could be less useful in the hard-label setting.
|
| 150 |
+
|
| 151 |
+
# 6 CONCLUSION
|
| 152 |
+
|
| 153 |
+
Despite the recent progress in zeroth-order attack methods, open questions remain about their precise behavior. We develop an information-theoretic analysis that sheds light on their ability to produce on-manifold adversarial examples. Through experiments on real-world datasets, we show an over two-fold increase in attack success rates by leveraging new findings about manifold distance and gradient deviation. With knowledge of the manifold-gradient relationship, it is possible to further refine hard-label attacks, and inform a better evaluation of model robustness. Given the availability of larger datasets in the future, our method may turn the strength of deep learning, which is efficiently extracting patterns in large-scale data, into a weakness.
|
| 154 |
+
|
| 155 |
+
# REFERENCES
|
| 156 |
+
|
| 157 |
+
L. Amsaleg, J. Bailey, D. Barbe, S. Erfani, M. E. Houle, V. Nguyen, and M. Radovanovic. The ´ vulnerability of learning to adversarial perturbation increases with intrinsic dimensionality. In 2017 IEEE Workshop on Information Forensics and Security (WIFS), pp. 1–6, December 2017. doi: 10.1109/WIFS.2017.8267651.
|
| 158 |
+
Normand J. Beaudry and Renato Renner. An intuitive proof of the data processing inequality. arXiv:1107.0740 [quant-ph], September 2012. URL http://arxiv.org/abs/1107.0740. arXiv: 1107.0740.
|
| 159 |
+
Wieland Brendel, Jonas Rauber, and Matthias Bethge. Decision-Based Adversarial Attacks: Reliable Attacks Against Black-Box Machine Learning Models. arXiv:1712.04248 [cs, stat], December 2017. URL http://arxiv.org/abs/1712.04248. arXiv: 1712.04248.
|
| 160 |
+
Nicholas Carlini and David Wagner. Towards Evaluating the Robustness of Neural Networks. In Security and Privacy (SP), pp. 582–597, 2016. ISBN 978-1-5090-5533-3. doi: 10.1109/SP.2017.49. arXiv: 1608.04644 ISSN: 10816011.
|
| 161 |
+
Nicholas Carlini and David Wagner. Adversarial Examples Are Not Easily Detected: Bypassing Ten Detection Methods. In Proceedings of the 10th ACM Workshop on Artificial Intelligence and Security - AISec ’17, pp. 3–14, Dallas, Texas, USA, 2017. ACM Press. ISBN 978-1-4503-5202- 4. doi: 10.1145/3128572.3140444. URL http://dl.acm.org/citation.cfm?doid= 3128572.3140444.
|
| 162 |
+
Nicholas Carlini, Anish Athalye, Nicolas Papernot, Wieland Brendel, Jonas Rauber, Dimitris Tsipras, Ian Goodfellow, Aleksander Madry, and Alexey Kurakin. On Evaluating Adversarial Robustness. arXiv:1902.06705 [cs, stat], February 2019. URL http://arxiv.org/abs/1902.06705. arXiv: 1902.06705.
|
| 163 |
+
Jianbo Chen, Michael I. Jordan, and Martin J. Wainwright. HopSkipJumpAttack: A Query-Efficient Decision-Based Attack. arXiv:1904.02144 [cs, math, stat], April 2019. URL http://arxiv. org/abs/1904.02144. arXiv: 1904.02144.
|
| 164 |
+
Jinghui Chen and Quanquan Gu. RayS: A Ray Searching Method for Hard-label Adversarial Attack. arXiv:2006.12792 [cs, stat], June 2020. URL http://arxiv.org/abs/2006.12792. arXiv: 2006.12792.
|
| 165 |
+
Pin-Yu Chen, Huan Zhang, Yash Sharma, Jinfeng Yi, and Cho-Jui Hsieh. ZOO: Zeroth order optimization based black-box attacks to deep neural networks without training substitute models. In ACM Workshop on Artificial Intelligence and Security, pp. 15–26, 2017.
|
| 166 |
+
Pin-Yu Chen, Yash Sharma, Huan Zhang, Jinfeng Yi, and Cho-Jui Hsieh. Ead: elastic-net attacks to deep neural networks via adversarial examples. In Thirty-second AAAI conference on artificial intelligence, 2018.
|
| 167 |
+
Minhao Cheng, Thong Le, Pin-Yu Chen, Jinfeng Yi, Huan Zhang, and Cho-Jui Hsieh. Query-Efficient Hard-label Black-box Attack:An Optimization-based Approach. arXiv:1807.04457 [cs, stat], July 2018. URL http://arxiv.org/abs/1807.04457. arXiv: 1807.04457.
|
| 168 |
+
|
| 169 |
+
Minhao Cheng, Thong Le, Pin-Yu Chen, Jinfeng Yi, Huan Zhang, and Cho-Jui Hsieh. Queryefficient hard-label black-box attack: An optimization-based approach. International Conference on Learning Representations, 2019.
|
| 170 |
+
|
| 171 |
+
Minhao Cheng, Simranjit Singh, Patrick Chen, Pin-Yu Chen, Sijia Liu, and Cho-Jui Hsieh. SIGNOPT: A QUERY-EFFICIENT HARD-LABEL ADVERSARIAL ATTACK. The International Conference on Learning Representations (ICLR), pp. 16, 2020. URL https://openreview. net/forum?id ${ . } = { }$ SklTQCNtvS.
|
| 172 |
+
|
| 173 |
+
Jeremy M. Cohen, Elan Rosenfeld, and J. Zico Kolter. Certified Adversarial Robustness via Randomized Smoothing. arXiv:1902.02918 [cs, stat], February 2019. URL http://arxiv.org/ abs/1902.02918. arXiv: 1902.02918.
|
| 174 |
+
|
| 175 |
+
Thomas M Cover and Joy A Thomas. Elements of Information Theory. Wiley-Interscience. John Wiley & Sons, 2nd edition, 2006.
|
| 176 |
+
|
| 177 |
+
Logan Engstrom, Andrew Ilyas, Shibani Santurkar, Dimitris Tsipras, Brandon Tran, and Aleksander Madry. Learning Perceptually-Aligned Representations via Adversarial Robustness. arXiv:1906.00945 [cs, stat], June 2019. URL http://arxiv.org/abs/1906.00945. arXiv: 1906.00945.
|
| 178 |
+
|
| 179 |
+
Ryan Feng, Jiefeng Chen, Nelson Manohar, Earlence Fernandes, Somesh Jha, and Atul Prakash. Query-Efficient Physical Hard-Label Attacks on Deep Learning Visual Classification. arXiv:2002.07088 [cs], February 2020. URL http://arxiv.org/abs/2002.07088. arXiv: 2002.07088.
|
| 180 |
+
|
| 181 |
+
Matt Fredrikson, Somesh Jha, and Thomas Ristenpart. Model Inversion Attacks that Exploit Confidence Information and Basic Countermeasures. Proceedings of the 22nd ACM SIGSAC Conference on Computer and Communications Security - CCS ’15, pp. 1322–1333, 2015. ISSN 15437221. doi: 10.1145/2810103.2813677. URL http://dl.acm.org/citation.cfm? doid ${ . } =$ 2810103.2813677. ISBN: 9781450338325.
|
| 182 |
+
|
| 183 |
+
Justin Gilmer, Luke Metz, Fartash Faghri, Samuel S. Schoenholz, Maithra Raghu, Martin Wattenberg, and Ian Goodfellow. The Relationship Between High-Dimensional Geometry and Adversarial Examples. arXiv:1801.02774 [cs], September 2018. URL http://arxiv.org/abs/1801. 02774. arXiv: 1801.02774.
|
| 184 |
+
|
| 185 |
+
Ian J. Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and Harnessing Adversarial Examples. 2014. ISSN 0012-7183. URL http://arxiv.org/abs/1412.6572. arXiv: 1412.6572 ISBN: 1412.6572.
|
| 186 |
+
|
| 187 |
+
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. arXiv:1706.08500 [cs, stat], January 2018. URL http://arxiv.org/abs/1706.08500. arXiv: 1706.08500.
|
| 188 |
+
|
| 189 |
+
Andrew Ilyas, Logan Engstrom, Anish Athalye, and Jessy Lin. Black-box Adversarial Attacks with Limited Queries and Information. arXiv:1804.08598 [cs, stat], July 2018. URL http: //arxiv.org/abs/1804.08598. arXiv: 1804.08598.
|
| 190 |
+
|
| 191 |
+
Ajil Jalal, Andrew Ilyas, Constantinos Daskalakis, and Alexandros G. Dimakis. The Robust Manifold Defense: Adversarial Training using Generative Models. arXiv:1712.09196 [cs, stat], July 2019. URL http://arxiv.org/abs/1712.09196. arXiv: 1712.09196.
|
| 192 |
+
|
| 193 |
+
Kim Jungeum and Xiao Wang. Sensible Adversarial Learning. 2020. URL https:// openreview.net/pdf?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ rJlf_RVKwr.
|
| 194 |
+
|
| 195 |
+
Alex Krizhevsky. Learning Multiple Layers of Features from Tiny Images. pp. 60, 2009.
|
| 196 |
+
|
| 197 |
+
Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. ImageNet Classification with Deep Convolutional Neural Networks. In F. Pereira, C. J. C. Burges, L. Bottou, and K. Q. Weinberger (eds.), Advances in Neural Information Processing Systems 25, pp. 1097–1105. Curran Associates, Inc., 2012. URL http://papers.nips.cc/paper/ 4824-imagenet-classification-with-deep-convolutional-neural-networks. pdf.
|
| 198 |
+
|
| 199 |
+
Cassidy Laidlaw, Sahil Singla, and Soheil Feizi. Perceptual Adversarial Robustness: Defense Against Unseen Threat Models. arXiv:2006.12655 [cs, stat], July 2021. URL http://arxiv.org/ abs/2006.12655. arXiv: 2006.12655.
|
| 200 |
+
|
| 201 |
+
Sijia Liu, Pin-Yu Chen, Bhavya Kailkhura, Gaoyuan Zhang, Alfred Hero, and Pramod K. Varshney. A Primer on Zeroth-Order Optimization in Signal Processing and Machine Learning. arXiv:2006.06224 [cs, eess, stat], June 2020. URL http://arxiv.org/abs/2006.06224. arXiv: 2006.06224.
|
| 202 |
+
|
| 203 |
+
Aleksander Madry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras, and Adrian Vladu. Towards Deep Learning Models Resistant to Adversarial Attacks. arXiv:1706.06083 [cs, stat], June 2017. URL http://arxiv.org/abs/1706.06083. arXiv: 1706.06083.
|
| 204 |
+
|
| 205 |
+
Seyed-Mohsen Moosavi-Dezfooli, Alhussein Fawzi, and Pascal Frossard. DeepFool: a simple and accurate method to fool deep neural networks. 2015. ISSN 10636919. doi: 10.1109/ CVPR.2016.282. URL http://arxiv.org/abs/1511.04599. arXiv: 1511.04599 ISBN: 9781467388511.
|
| 206 |
+
|
| 207 |
+
Yurii Nesterov and Vladimir Spokoiny. Random Gradient-Free Minimization of Convex Functions. Foundations of Computational Mathematics, 17(2):527–566, April 2017. ISSN 1615-3375, 1615- 3383. doi: 10.1007/s10208-015-9296-2. URL http://link.springer.com/10.1007/ s10208-015-9296-2.
|
| 208 |
+
|
| 209 |
+
Nicolas Papernot, Patrick Mcdaniel, Somesh Jha, Matt Fredrikson, Z. Berkay Celik, and Ananthram Swami. The limitations of deep learning in adversarial settings. Proceedings - 2016 IEEE European Symposium on Security and Privacy, EURO S and P 2016, pp. 372–387, 2016. doi: 10.1109/ EuroSP.2016.36. URL http://arxiv.org/abs/1511.07528. arXiv: 1511.07528 ISBN: 9781509017515.
|
| 210 |
+
|
| 211 |
+
Pouya Samangouei, Maya Kabkab, and Rama Chellappa. Defense-gan: Protecting classifiers against adversarial attacks using generative models. In International Conference on Learning Representations, 2018.
|
| 212 |
+
|
| 213 |
+
Shibani Santurkar, Dimitris Tsipras, Brandon Tran, Andrew Ilyas, Logan Engstrom, and Aleksander Madry. Image Synthesis with a Single (Robust) Classifier. arXiv:1906.09453 [cs, stat], June 2019. URL http://arxiv.org/abs/1906.09453. arXiv: 1906.09453.
|
| 214 |
+
|
| 215 |
+
Ludwig Schmidt, Shibani Santurkar, Dimitris Tsipras, Kunal Talwar, and Aleksander Madry. Adversarially Robust Generalization Requires More Data. arXiv:1804.11285 [cs, stat], May 2018. URL http://arxiv.org/abs/1804.11285. arXiv: 1804.11285.
|
| 216 |
+
|
| 217 |
+
David Stutz, Matthias Hein, and Bernt Schiele. Disentangling Adversarial Robustness and Generalization. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 12. IEEE Computer Society, 2019.
|
| 218 |
+
|
| 219 |
+
Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, Ian Goodfellow, and Rob Fergus. Intriguing properties of neural networks. pp. 1–10, 2013. ISSN 15499618. doi: 10.1021/ct2009208. URL http://arxiv.org/abs/1312.6199. arXiv: 1312.6199 ISBN: 1549-9618.
|
| 220 |
+
|
| 221 |
+
Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2818–2826, 2016.
|
| 222 |
+
|
| 223 |
+
Thomas Tanay and Lewis Griffin. A Boundary Tilting Persepective on the Phenomenon of Adversarial Examples. arXiv:1608.07690 [cs, stat], August 2016. URL http://arxiv.org/abs/1608. 07690. arXiv: 1608.07690.
|
| 224 |
+
|
| 225 |
+
Florian Tramer, Nicholas Carlini, Wieland Brendel, and Aleksander Madry. On Adaptive Attacks to Adversarial Example Defenses. arXiv:2002.08347 [cs, stat], February 2020. URL http: //arxiv.org/abs/2002.08347. arXiv: 2002.08347.
|
| 226 |
+
|
| 227 |
+
Florian Tramer, Fan Zhang, Floriantra Er Epfl, Ari Juels, Michael K Reiter, and Thomas \` Ristenpart. Stealing Machine Learning Models via Prediction APIs. 2016. URL https: //www.usenix.org/conference/usenixsecurity16/technical-sessions/ presentation/tramer. ISBN: 978-1-931971-32-4.
|
| 228 |
+
|
| 229 |
+
Chun-Chen Tu, Paishun Ting, Pin-Yu Chen, Sijia Liu, Huan Zhang, Jinfeng Yi, Cho-Jui Hsieh, and Shin-Ming Cheng. AutoZOOM: Autoencoder-Based Zeroth Order Optimization Method for Attacking Black-Box Neural Networks. Proceedings of the AAAI Conference on Artificial Intelligence, 33:742–749, July 2019. ISSN 2374-3468, 2159-5399. doi: 10.1609/aaai.v33i01. 3301742. URL https://aaai.org/ojs/index.php/AAAI/article/view/3852.
|
| 230 |
+
|
| 231 |
+
Haichao Zhang and Jianyu Wang. Defense Against Adversarial Attacks Using Feature Scatteringbased Adversarial Training. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d\textquotesingle Alche-Buc, E. Fox, and R. Garnett (eds.), ´ Advances in Neural Information Processing Systems 32, pp. 1831–1841. Curran Associates, Inc., 2019.
|
| 232 |
+
|
| 233 |
+
Haichao Zhang and Wei Xu. Adversarial Interpolation Training: A simple approach for improving model robustness. 2020. URL https://openreview.net/pdf?id $\underline { { \underline { { \mathbf { \Pi } } } } }$ Syejj0NYvr.
|
| 234 |
+
|
| 235 |
+
Hongyang Zhang, Yaodong Yu, Jiantao Jiao, Eric P Xing, Laurent El Ghaoui, and Michael I Jordan. Theoretically Principled Trade-off between Robustness and Accuracy. PMLR, pp. 11, 2019.
|
| 236 |
+
|
| 237 |
+
Richard Zhang, Phillip Isola, Alexei A. Efros, Eli Shechtman, and Oliver Wang. The Unreasonable Effectiveness of Deep Features as a Perceptual Metric. In 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 586–595, Salt Lake City, UT, June 2018. IEEE. ISBN 978-1- 5386-6420-9. doi: 10.1109/CVPR.2018.00068. URL https://ieeexplore.ieee.org/ document/8578166/.
|
| 238 |
+
|
| 239 |
+
Xiao Zhang, Jinghui Chen, Quanquan Gu, and David Evans. Understanding the Intrinsic Robustness of Image Distributions using Conditional Generative Models. arXiv:2003.00378 [cs, stat], February 2020. URL http://arxiv.org/abs/2003.00378. arXiv: 2003.00378.
|
| 240 |
+
|
| 241 |
+
# A APPENDIX
|
| 242 |
+
|
| 243 |
+
# A.1 DERIVATION OF MANIFOLD-GRADIENT MUTUAL INFORMATION (MI)
|
| 244 |
+
|
| 245 |
+
We define the manifold-gradient point-wise joint probability in a case-wise manner, for the respective values under $\mathbf { g } \in \{ - 1 , \bar { 1 } \} ^ { d }$ and $\bar { \mathbf { x } } \in \mathbb { R } ^ { d }$ . We are concerned with the sub-gradient cases where $\mathbf { x } > 0$ (denoted $\mathbf { x } ^ { + }$ ) and $\mathbf { x } < 0$ (denoted $\mathbf { x } ^ { - }$ ) which correspond to fixed values of $\mathbf { g }$ based on class means $y \cdot \pmb { \mu }$ with $y \in \{ - 1 , 1 \}$ . This gives for each dimension $k$ ,
|
| 246 |
+
|
| 247 |
+
$$
|
| 248 |
+
\begin{array} { l } { { \displaystyle p ( { \bf g } _ { k } = 1 , { \bf x } _ { k } ^ { + } ) = \frac { 1 } { 2 \sigma \sqrt { 2 \pi } } \mathrm { e x p } \left( - \frac { 1 } { 2 } \left( \frac { { \bf x } _ { k } ^ { + } - \mu _ { k } } { \sigma } \right) ^ { 2 } \right) } } \\ { { \displaystyle p ( { \bf g } _ { k } = 1 , { \bf x } _ { k } ^ { - } ) = \frac { 1 } { 2 \sigma \sqrt { 2 \pi } } \mathrm { e x p } \left( - \frac { 1 } { 2 } \left( \frac { { \bf x } _ { k } ^ { + } + \mu _ { k } } { \sigma } \right) ^ { 2 } \right) } } \end{array}
|
| 249 |
+
$$
|
| 250 |
+
|
| 251 |
+
$$
|
| 252 |
+
\begin{array} { l } { { \displaystyle p ( { \bf g } _ { k } = - 1 , { \bf x } _ { k } ^ { + } ) = \frac { 1 } { 2 \sigma \sqrt { 2 \pi } } \mathrm { e x p } \left( - \frac { 1 } { 2 } \left( \frac { { \bf x } _ { k } ^ { + } + \mu _ { k } } { \sigma } \right) ^ { 2 } \right) } } \\ { { \displaystyle p ( { \bf g } _ { k } = - 1 , { \bf x } _ { k } ^ { - } ) = \frac { 1 } { 2 \sigma \sqrt { 2 \pi } } \mathrm { e x p } \left( - \frac { 1 } { 2 } \left( \frac { { \bf x } _ { k } ^ { + } - \mu _ { k } } { \sigma } \right) ^ { 2 } \right) . } } \end{array}
|
| 253 |
+
$$
|
| 254 |
+
|
| 255 |
+
Since the Schmidt et al. Gaussian mixture is created symmetrically (the probability mass is evenly split between the two classes i.e., the mixture comprises one Gaussian offset by $\pmb { \mu _ { k } }$ and mirrored at $\mathbf { x } _ { k } = 0 .$ ) we can simplify to
|
| 256 |
+
|
| 257 |
+
$$
|
| 258 |
+
p ( \mathbf { g } _ { k } = 1 , \mathbf { x } _ { k } ^ { + } ) = \frac { 1 } { 2 \sigma \sqrt { 2 \pi } } \mathrm { e x p } \left( - \frac { 1 } { 2 } \left( \frac { \mathbf { x } _ { k } ^ { + } - \pmb { \mu } _ { k } } { \sigma } \right) ^ { 2 } \right) ,
|
| 259 |
+
$$
|
| 260 |
+
|
| 261 |
+
$$
|
| 262 |
+
p ( \mathbf { g } _ { k } = - 1 , \mathbf { x } _ { k } ^ { + } ) = \frac { 1 } { 2 \sigma \sqrt { 2 \pi } } \mathrm { e x p } \left( - \frac { 1 } { 2 } \left( \frac { \mathbf { x } _ { k } ^ { + } + \pmb { \mu } _ { k } } { \sigma } \right) ^ { 2 } \right) ,
|
| 263 |
+
$$
|
| 264 |
+
|
| 265 |
+
where $\mathbf { x } \sim { \mathcal { N } } ( y \cdot \mu , \sigma I )$ . In words, Equation 6 is the symmetrical tail of the Gaussian mixture marginal while Equation 5 is the remainder of the mixture.
|
| 266 |
+
|
| 267 |
+
Similarly, a point-wise gradient is given as the Rademacher outcome $\mathbf { g } _ { k } \in \{ \pm 1 \}$ . The choice of $\epsilon$ directly influences the marginal probability over the manifold. The marginal probability over the manifold can be given as the Riemann approximations
|
| 268 |
+
|
| 269 |
+
$$
|
| 270 |
+
p _ { \mathcal { G } } ( \mathbf { g } _ { k } = 1 ) _ { \epsilon } = \frac { 1 } { 2 \sigma \sqrt { 2 \pi } } \sum _ { i = 1 } ^ { n } \exp \left( - \frac { 1 } { 2 } \left( \frac { \mathbf { x } _ { i , k } ^ { * } - \pmb { \mu } _ { k } } { \sigma } \right) ^ { 2 } \right) \Delta _ { i }
|
| 271 |
+
$$
|
| 272 |
+
|
| 273 |
+
and
|
| 274 |
+
|
| 275 |
+
$$
|
| 276 |
+
p _ { \mathcal { G } } ( \mathbf { g } _ { k } = - 1 ) _ { \epsilon } = \frac { 1 } { 2 \sigma \sqrt { 2 \pi } } \sum _ { i = 1 } ^ { n } \exp \left( - \frac { 1 } { 2 } \left( \frac { \mathbf { x } _ { i , k } ^ { * } + \mu _ { k } } { \sigma } \right) ^ { 2 } \right) \Delta _ { i } ,
|
| 277 |
+
$$
|
| 278 |
+
|
| 279 |
+
with $\Delta _ { i } = \mathbf { x } _ { i , k } ^ { + } - \mathbf { x } _ { i - 1 , k } ^ { + }$ for arbitrary $\mathbf { x } _ { i , k } ^ { * } \in [ \mathbf { x } _ { i - 1 , k } ^ { + } , \mathbf { x } _ { i , k } ^ { + } ]$ , and $n$ is controlled by the hyper-parameter $\epsilon$ .
|
| 280 |
+
|
| 281 |
+
The marginal for the manifold under the gradient is given similarly as
|
| 282 |
+
|
| 283 |
+
$$
|
| 284 |
+
{ \begin{array} { r l } & { p _ { \mathcal { M } } ( \mathbf { x } _ { k } ) = p ( \mathbf { g } _ { k } = 1 , \mathbf { x } _ { k } ^ { + } ) + p ( \mathbf { g } _ { k } = - 1 , \mathbf { x } _ { k } ^ { + } ) } \\ & { \qquad = { \frac { 1 } { \sigma { \sqrt { 2 \pi } } } } \exp \left( - { \frac { 1 } { 2 } } \left( { \frac { \mathbf { x } _ { k } ^ { + } - { \boldsymbol { \mu } } _ { k } } { \sigma } } \right) ^ { 2 } \right) + { \frac { 1 } { \sigma { \sqrt { 2 \pi } } } } \exp \left( - { \frac { 1 } { 2 } } \left( { \frac { \mathbf { x } _ { k } ^ { + } + { \boldsymbol { \mu } } _ { k } } { \sigma } } \right) ^ { 2 } \right) , } \end{array} }
|
| 285 |
+
$$
|
| 286 |
+
|
| 287 |
+
where $\mathbf { x } _ { k } ^ { + } > 0$ for all dimensions $k$ . Denote the sub-manifold sampled from the positive $( y = 1 )$ ) and negative $y = - 1 ,$ ) classes as $\mathcal { M } ^ { + }$ and $\mathcal { M } ^ { - }$ , respectively. Our definition for manifold-gradient mutual information is based on the standard definition of mutual information from information theory (Cover & Thomas, 2006),
|
| 288 |
+
|
| 289 |
+
$$
|
| 290 |
+
I ( \mathcal { M } , \mathcal { G } ) _ { \epsilon , k } = \int _ { \mathcal { M } } \int _ { \mathcal { G } } p ( \mathbf { g } _ { k } , \mathbf { x } _ { k } ) \log \bigr ( \frac { p ( \mathbf { g } _ { k } , \mathbf { x } _ { k } ) } { p _ { \mathcal { G } } ( \mathbf { g } _ { k } ) p _ { \mathcal { M } } ( \mathbf { x } _ { k } ) } \bigr ) d \mathbf { g } _ { k } d \mathbf { x } _ { k } ,
|
| 291 |
+
$$
|
| 292 |
+
|
| 293 |
+
where $\epsilon$ is treated as a hyper-parameter controlling the value of $n$ in $p _ { \mathcal { G } } ( \mathbf { g } _ { k } )$ . By substitution into Equation 10 we have
|
| 294 |
+
|
| 295 |
+
$$
|
| 296 |
+
\begin{array} { l } { { \displaystyle I ( { \mathcal { M } } , { \mathcal { G } } ) _ { \epsilon , k } = \int _ { { \mathcal { M } } } p ( 1 , { \mathbf { x } } _ { k } ) \log ( \frac { p ( 1 , { \mathbf { x } } _ { k } ) } { p _ { \mathcal { G } } ( 1 ) p _ { \mathcal { M } } ( { \mathbf { x } } _ { k } ) } ) d { \mathbf { x } } _ { k } } } \\ { { \displaystyle ~ + \int _ { { \mathcal { M } } } p ( - 1 , { \mathbf { x } } _ { k } ) \log ( \frac { p ( - 1 , { \mathbf { x } } _ { k } ) } { p _ { \mathcal { G } } ( - 1 ) p _ { \mathcal { M } } ( { \mathbf { x } } _ { k } ) } ) d { \mathbf { x } } _ { k } } . } \end{array}
|
| 297 |
+
$$
|
| 298 |
+
|
| 299 |
+
This is split further similar to true positive, true negative, false positive, and false negative, as
|
| 300 |
+
|
| 301 |
+
$$
|
| 302 |
+
\begin{array} { l } { { \displaystyle I ( { \mathcal M } , { \mathcal G } ) _ { \epsilon , k } = \int _ { { \mathcal M } + } p ( 1 , { \mathbf x } _ { k } ^ { + } ) \log ( \frac { p ( 1 , { \mathbf x } _ { k } ^ { + } ) } { p _ { \mathcal G } ( 1 ) p _ { { \mathcal M } } ( { \mathbf x } _ { k } ^ { + } ) } ) d { \mathbf x } _ { k } ^ { + } } } \\ { ~ + \int _ { { \mathcal M } ^ { - } } p ( 1 , { \mathbf x } _ { k } ^ { - } ) \log ( \frac { p ( 1 , { \mathbf x } _ { k } ^ { - } ) } { p _ { \mathcal G } ( 1 ) p _ { { \mathcal M } } ( { \mathbf x } _ { k } ^ { - } ) } ) d { \mathbf x } _ { k } ^ { - } } \\ { { + \int _ { { \mathcal M } ^ { + } } p ( - 1 , { \mathbf x } _ { k } ^ { + } ) \log ( \frac { p ( - 1 , { \mathbf x } _ { k } ^ { + } ) } { p _ { \mathcal G } ( - 1 ) p _ { { \mathcal M } } ( { \mathbf x } _ { k } ^ { + } ) } ) d { \mathbf x } _ { k } ^ { + } } } \\ { { + \int _ { { \mathcal M } ^ { - } } p ( - 1 , { \mathbf x } _ { k } ^ { - } ) \log ( \frac { p ( - 1 , { \mathbf x } _ { k } ^ { - } ) } { p _ { \mathcal G } ( - 1 ) p _ { { \mathcal M } } ( { \mathbf x } _ { k } ^ { - } ) } ) d { \mathbf x } _ { k } ^ { - } , } } \end{array}
|
| 303 |
+
$$
|
| 304 |
+
|
| 305 |
+
and simplified due to symmetry at 0 as
|
| 306 |
+
|
| 307 |
+
$$
|
| 308 |
+
\begin{array} { l } { { \displaystyle I ( { \mathcal { M } } , { \mathcal { G } } ) _ { \epsilon , k } = 2 \int _ { { \mathcal { M } } ^ { + } } p ( 1 , { \mathbf { x } } _ { k } ^ { + } ) \log ( \frac { p ( 1 , { \mathbf { x } } _ { k } ^ { + } ) } { p _ { \mathcal { G } } ( 1 ) p _ { \mathcal { M } } ( { \mathbf { x } } _ { k } ^ { + } ) } ) d { \mathbf { x } } _ { k } ^ { + } } } \\ { { \displaystyle ~ + \ 2 \int _ { { \mathcal { M } } ^ { + } } p ( - 1 , { \mathbf { x } } _ { k } ^ { + } ) \log ( \frac { p ( - 1 , { \mathbf { x } } _ { k } ^ { + } ) } { p _ { \mathcal { G } } ( - 1 ) p _ { \mathcal { M } } ( { \mathbf { x } } _ { k } ^ { + } ) } ) d { \mathbf { x } } _ { k } ^ { + } } . } \end{array}
|
| 309 |
+
$$
|
| 310 |
+
|
| 311 |
+
The total un-normalized mutual information is given by the summation over dimensions $\scriptstyle \sum _ { k = 1 } ^ { d } I ( { \mathcal { M } } , { \mathcal { G } } ) _ { \epsilon , k }$ . Notably the cases for each possible scenario under detection theory are repre- is bounded by the results of Schmidt et al. (2018). By substitution from each $I ( \mathcal { M } , \mathcal { G } ) _ { \epsilon } =$ marginal and joint probability in Equations 8, 3, and 4 respectively, we have the closed form solution for mutual information.
|
| 312 |
+
|
| 313 |
+
This leads to the Riemann approximation of Equation 13,
|
| 314 |
+
|
| 315 |
+
$$
|
| 316 |
+
\begin{array} { r l } { \displaystyle I ( \mathcal { M } , \mathcal { G } ) _ { \epsilon , k } = 2 \sum _ { i = 1 } ^ { n } p ( 1 , \mathbf { x } _ { i , k } ^ { * } ) \log ( \frac { p ( 1 , \mathbf { x } _ { i , k } ^ { * } ) } { p _ { \mathcal { G } } ( 1 ) p _ { \mathcal { M } } ( \mathbf { x } _ { i , k } ^ { * } ) } ) \Delta _ { i } } & { } \\ { \displaystyle + 2 \sum _ { i = 1 } ^ { n } p ( - 1 , \mathbf { x } _ { i , k } ^ { * } ) \log ( \frac { p ( - 1 , \mathbf { x } _ { i , k } ^ { * } ) } { p _ { \mathcal { G } } ( - 1 ) p _ { \mathcal { M } } ( \mathbf { x } _ { i , k } ^ { * } ) } ) \Delta _ { i } . } & { } \end{array}
|
| 317 |
+
$$
|
| 318 |
+
|
| 319 |
+
with $\Delta _ { i } = \mathbf { x } _ { i , k } ^ { + } - \mathbf { x } _ { i - 1 , k } ^ { + }$ for arbitrary positive $\mathbf { x } _ { i , k } ^ { * } \in [ \mathbf { x } _ { i - 1 , k } ^ { + } , \mathbf { x } _ { i , k } ^ { + } ]$ . Since $\mathbf { x } ^ { + }$ is a standard multivariate Gaussian (Cover & Thomas, 2006), the final mutual information is the summation over each dimension,
|
| 320 |
+
|
| 321 |
+
$$
|
| 322 |
+
\begin{array} { r l } { I ( \mathcal { M } , \mathcal { G } ) _ { \epsilon } = 2 \displaystyle \sum _ { k = 1 } ^ { d } \sum _ { i = 1 } ^ { n } p ( 1 , \mathbf { x } _ { i , k } ^ { * } ) \log ( \frac { p ( 1 , \mathbf { x } _ { i , k } ^ { * } ) } { p _ { \mathcal { G } } ( 1 ) p _ { \mathcal { M } } ( \mathbf { x } _ { i , k } ^ { * } ) } ) \Delta _ { i } } & { { } } \\ { \quad \quad \quad \quad + 2 \displaystyle \sum _ { k = 1 } ^ { d } \sum _ { i = 1 } ^ { n } p ( - 1 , \mathbf { x } _ { i , k } ^ { * } ) \log ( \frac { p ( - 1 , \mathbf { x } _ { i , k } ^ { * } ) } { p _ { \mathcal { G } } ( - 1 ) p _ { \mathcal { M } } ( \mathbf { x } _ { i , k } ^ { * } ) } ) \Delta _ { i } . } & { { } } \end{array}
|
| 323 |
+
$$
|
| 324 |
+
|
| 325 |
+
# A.2 HARD-LABEL ATTACK FORMULATION
|
| 326 |
+
|
| 327 |
+
Contemporary hard-label attacks are variants of random gradient-free method (RGF) (Nesterov & Spokoiny, 2017), a gradient estimator which yields the estimate $\hat { \bf g }$ over $q$ random directions $\{ { \mathbf { u } } _ { i } \} _ { i = 1 } ^ { q }$
|
| 328 |
+
|
| 329 |
+
OPT-Attack For benign example $\mathbf { x } _ { \mathrm { 0 } }$ , true label $y _ { 0 }$ , and hard-label black-box function $f : \mathbb { R } ^ { d } $ $\{ 1 , \ldots , K \}$ , Cheng et al. (2019) define the objective function $g : \mathbb { R } ^ { d } \mathbb { R }$ as a function of search direction $\pmb \theta$ , where the optimal solution is $g ( \theta ^ { * } )$ , the minimum distance from $\mathbf { x } _ { \mathrm { 0 } }$ to the nearest adversarial example along the direction $\pmb { \theta } ^ { * }$ . For the untargeted attack, $g ( \pmb \theta )$ is the distance to any decision boundary along direction $\pmb \theta$ , and allows for estimating the gradient as
|
| 330 |
+
|
| 331 |
+
$$
|
| 332 |
+
\hat { \mathbf { g } } = \frac { 1 } { q } \sum _ { i = 0 } ^ { q } \frac { g ( \pm \beta \mathbf { u } _ { i } ) - g ( \pmb { \theta } ) } { \beta } \cdot \mathbf { u } _ { i } ,
|
| 333 |
+
$$
|
| 334 |
+
|
| 335 |
+
where $\beta$ is a small smoothing parameter. Notably, $g ( \pmb \theta )$ is continuous even if $f$ is a non-continuous step function.
|
| 336 |
+
|
| 337 |
+
Sign-OPT Cheng et al. (2020) later improved the query efficiency by only considering the sign of the gradient estimate,
|
| 338 |
+
|
| 339 |
+
$$
|
| 340 |
+
\hat { \nabla } g ( \pmb \theta ) \approx \hat { \mathbf g } : = \sum _ { i = 1 } ^ { q } \mathrm { s i g n } \left( g ( \pmb \theta + \beta \mathbf { u } _ { i } ) - g ( \pmb \theta ) \right) \mathbf { u } _ { i } .
|
| 341 |
+
$$
|
| 342 |
+
|
| 343 |
+
We focus on the Sign-OPT variant, since the findings are more relevant to the current state-of-the-art.
|
| 344 |
+
|
| 345 |
+
HopSkipJumpAttack Similar to Sign-OPT, HopSkipJumpAttack (HSJA) (Chen et al., 2019) uses a zeroth-order sign oracle to improve Boundary Attack (Brendel et al., 2017). HSJA lacks the convergence analysis of Sign-OPT and relies on one-point gradient estimate. Regardless, HSJA is competitive and can excel in the $L _ { \infty }$ setting.
|
| 346 |
+
|
| 347 |
+
Dimension-reduced Sign-OPT & HSJA. In general, for attacks relying on the Cheng et al. (2019) formulation, the update in Equation 16 becomes
|
| 348 |
+
|
| 349 |
+
$$
|
| 350 |
+
\hat { \bf g } = \frac { 1 } { q } \sum _ { i = 0 } ^ { q } \frac { g ( \pmb { \theta } ^ { \prime } + \beta \mathbf { u } _ { i } ^ { \prime } ) - g ( \pmb { \theta } ^ { \prime } ) } { \beta } \cdot \mathbf { u } _ { i } ^ { \prime }
|
| 351 |
+
$$
|
| 352 |
+
|
| 353 |
+
for the reduced-dimension Gaussian vectors $\{ \mathbf { u } _ { i } ^ { \prime } \in \mathbb { R } ^ { d ^ { \prime } } \} _ { i = 0 } ^ { q }$ for integer $d ^ { \prime } < d$ and direction $\pmb { \theta } ^ { \prime } \in \mathbb { R } ^ { d ^ { \prime } }$ . The reduced-dimension direction $\pmb { \theta } ^ { \prime }$ is initialized randomly with $\pmb { \theta } ^ { \prime } \sim \mathcal { N } ( 0 , 1 )$ for the untargeted case, or for the targeted case as $\pmb { \theta } ^ { \prime } = \mathcal { E } ( \mathbf { x } _ { t } )$ , where $\mathbf { x } _ { t }$ is a test sample correctly classified as target class $t$ by the victim model. This scheme also applies to HSJA, since HSJA performs a single-point sign estimate. As in the normal variants, $\hat { \bf g }$ is used to update $\pmb { \theta } ^ { \prime }$ .
|
| 354 |
+
|
| 355 |
+
# A.3 MAIN PAPER BLOCK DIAGRAM
|
| 356 |
+
|
| 357 |
+
A block diagram of assumptions, claims, and observations is shown in Figure 3.
|
| 358 |
+
|
| 359 |
+

|
| 360 |
+
Figure 3: Block diagram summarizing the assumptions, claims, and observations of the main paper.
|
| 361 |
+
|
| 362 |
+
# A.4 IMPLEMENTATION DETAILS
|
| 363 |
+
|
| 364 |
+
# A.4.1 HARDWARE AND ATTACK HYPERPARAMETERS
|
| 365 |
+
|
| 366 |
+
All experiments in the main paper were performed on an internal high-performance compute cluster equipped with NVIDIA Tesla V100 Tensor Core GPUs and high-speed non-volatile flash storage. In total 16 GPUs, 1TB main system memory, and 40 Intel Xeon CPU cores were used to run experiments completely.
|
| 367 |
+
|
| 368 |
+
Depending on dataset dimension, HSJA requires tuning of parameter $\gamma$ for best performance. On CIFAR-10 we used $\gamma = 1 0 . 0$ . For ImageNet, it was necessary to set $\gamma \geq 1 0 0 0 . 0$ to re-create the published results of the regular variant (Chen et al., 2019). Due to similar performance we use $\gamma = 1 0 0 0 . 0$ for regular and dimension-reduced variants. We note that the dimension-reduced variants like HSJA+BiLN were less sensitive to $\gamma$ , performing similarly regardless of the setting.
|
| 369 |
+
|
| 370 |
+
# A.4.2 ADVERSARY AUTOENCODER
|
| 371 |
+
|
| 372 |
+
We are primarily interested in the effect of reduced search resolution on attack behavior. Thus in this work, given a candidate direction $\pmb { \theta } ^ { \prime }$ and magnitude (or radius) $r$ , the adversarial sample in the AE case is the blending $( 1 - r ) \mathbf { x } _ { 0 } + r \mathcal { D } \left( \mathcal { E } ( \mathbf { x } _ { 0 } ) \mathbf { \bar { \rho } } + \pmb { \theta } ^ { \prime } \right)$ . 3
|
| 373 |
+
|
| 374 |
+
For AE attack variants, we implement the same architecture described by Tu et al. (2019). Specifically it leverages a fully convolutional network for the encoder and decoder. Every AE is trained using the held out test set, as we assume disjoint data between adversary and victim.
|
| 375 |
+
|
| 376 |
+
The adversary’s AE is tuned to minimize reconstruction error of input images, so the output quality of the AE will depend on the adversary’s ability to collect data. We assume the adversary only has access to the test set, which tends to be considerably less informative than the training set. This crude manifold approximation can manifest as an additional layer of distortion on top of adversarial noise. With BiLN, no additional training is required, so it synthesizes search directions independent of the adversary’s manifold description (i.e., possible extracted knowledge about test samples).
|
| 377 |
+
|
| 378 |
+
ImageNet samples are downsized to $1 2 8 \mathrm { x } 1 2 8$ before passing to the AE, and the output of the AE is scaled back to $2 2 4 \mathbf { x } 2 2 4$ , as described by Tu et al. (2019).
|
| 379 |
+
|
| 380 |
+
# A.4.3 DATA SAMPLING
|
| 381 |
+
|
| 382 |
+
Original samples are chosen from the test set using the technique from Chen et al. (2019): on CIFAR-10, five random samples are taken from each of ten uniform-randomly chosen classes (i.e., 50 total samples). On the ImageNet dataset, ten random classes are uniform-randomly chosen and ten random samples taken from each (100 total samples).
|
| 383 |
+
|
| 384 |
+
# A.5 SUPPLEMENTAL RESULTS
|
| 385 |
+
|
| 386 |
+
# A.5.1 QUERY VS. DISTORTION PLOTS
|
| 387 |
+
|
| 388 |
+
We show the model queries against attack distortion measurement in Figure 4 to accompany the results in the main paper. The distortion is much higher and stays higher with Rand variants, due to discarding important semantic information. The plots evidence that BiLN variants (yellow lines) offer a simple yet effective way to improve the query efficiency of the hard-label attacks.
|
| 389 |
+
|
| 390 |
+
# A.5.2 GRADIENT DEVIATION ON ROBUST CIFAR-10
|
| 391 |
+
|
| 392 |
+
In Table 3 we show supplementary gradient deviation results for CIFAR-10 using different defense mechanisms or robust models. In general they exhibit the same trend as our main paper results, which is that dimension-reduced attacks manage to reduce gradient deviation across each robust model.
|
| 393 |
+
|
| 394 |
+

|
| 395 |
+
Figure 4: Query vs. distortion plots for a) CIFAR-10 and b) ImageNet, corresponding to the success rate plots in the main text. Dashed lines denote the value of $\epsilon$ .
|
| 396 |
+
|
| 397 |
+
Table 3: Per-pixel gradient deviation measured across additional robust CIFAR-10 models
|
| 398 |
+
|
| 399 |
+
<table><tr><td>Attack Variant</td><td>TRADES (Zhang et al., 2019)</td><td>Interpolation (Zhang & Xu,2020)</td><td>Feat. Scattering (Zhang &Wang,2019)</td><td>SENSE (Jungeum & Wang,2020)</td></tr><tr><td>HSJA</td><td>0.0542±0.0001</td><td>0.0542±0.0001</td><td>0.0541±0.0000</td><td>0.0556±0.0045</td></tr><tr><td>HSJA+BiLN</td><td>0.0395±0.0001</td><td>0.0393±0.0001</td><td>0.0401±0.0004</td><td>0.0389±0.0056</td></tr><tr><td>HSJA+Rand</td><td>0.008±0.004</td><td>0.002±0.005</td><td>0.216±0.000</td><td>0.222±0.017</td></tr><tr><td>Sign-OPT</td><td>0.0042±0.0005</td><td>0.0039±0.0007</td><td>0.0019±0.0004</td><td>0.0083±0.0104</td></tr><tr><td>Sign-OPT+BiLN</td><td>0.0026±0.0007</td><td>0.0023±0.0009</td><td>0.0020±0.0004</td><td>0.0075±0.0110</td></tr><tr><td>Sign-OPT+Rand</td><td>0.007±0.002</td><td>0.004±0.005</td><td>0.006±0.002</td><td>0.025±0.048</td></tr><tr><td>Sign-OPT+AE</td><td>0.0257±0.0002</td><td>0.0282±0.0002</td><td>0.0259±0.0000</td><td>0.0278±0.0069</td></tr></table>
|
| 400 |
+
|
| 401 |
+
# A.5.3 SUCCESS RATE NORMALIZED AUC SCORES
|
| 402 |
+
|
| 403 |
+
Tables 5 and 4 show the max-normalized Trapezoid rule area-under-curve (AUC) measurements for the success rate plots of the main text. Highest scores are bolded. Notably, the HSJA $+$ BiLN variant earns the highest score in almost all cases.
|
| 404 |
+
|
| 405 |
+
# A.5.4 SUCCESS RATE SCORES
|
| 406 |
+
|
| 407 |
+
We provide the success rates over all samples at specific query intervals in Tables 6 and 7.
|
| 408 |
+
|
| 409 |
+
# A.5.5 ATTACKING A SMOOTHED MODEL
|
| 410 |
+
|
| 411 |
+
Gaussian smoothing is a technique of performing adversarial training with sampled affected by Gaussian noise. At test time, inference is achieved via a Monte Carlo search over many Gaussianperturbed versions of the sample under test. The SotA at time of writing, randomized smoothing proposed by Cohen et al. (2019), is a good candidate for hard-label attacks since the true gradient of the smoothed model is undefined. We use the checkpoint corresponding to smoothing parameter $\sigma = 0 . 5$ and $\epsilon \simeq 1 . 0$ . These results are shown in Figure 5. In general, the BiLN variant exceeds all other variants in the natural ImageNet case, with small improvement on the smoothed model. Although it can find samples closer to the smoothed $\epsilon$ , only a fraction are within the bound.
|
| 412 |
+
|
| 413 |
+
Table 4: Success Rate (SR) Normalized AUC scores for CIFAR-10 SR plots of the main text. Higher is better.
|
| 414 |
+
|
| 415 |
+
<table><tr><td>Attack Variant</td><td>Natural CIFAR-10</td><td>Madry CIFAR-10</td></tr><tr><td>HSJA</td><td>1.000</td><td>0.650</td></tr><tr><td>HSJA+BiLN</td><td>0.968</td><td>1.000</td></tr><tr><td>HSJA+Rand</td><td>0.033</td><td>0.088</td></tr><tr><td>Sign-OPT</td><td>0.763</td><td>0.171</td></tr><tr><td>Sign-OPT+BiLN</td><td>0.310</td><td>0.156</td></tr><tr><td>Sign-OPT+Rand</td><td>0.144</td><td>0.092</td></tr><tr><td>Sign-OPT+AE</td><td>0.312</td><td>0.300</td></tr></table>
|
| 416 |
+
|
| 417 |
+
<table><tr><td>Attack Variant</td><td>Natural ImageNet</td><td>Madry ImageNet</td></tr><tr><td>HSJA</td><td>0.867</td><td>0.470</td></tr><tr><td>HSJA+BiLN</td><td>1.000</td><td>1.000</td></tr><tr><td>HSJA+Rand</td><td>0.077</td><td>0.211</td></tr><tr><td>Sign-OPT</td><td>0.364</td><td>0.153</td></tr><tr><td>Sign-OPT+BiLN</td><td>0.376</td><td>0.215</td></tr><tr><td>Sign-OPT+Rand</td><td>0.070</td><td>0.033</td></tr><tr><td>Sign-OPT+AE</td><td>0.018</td><td>0.105</td></tr></table>
|
| 418 |
+
|
| 419 |
+

|
| 420 |
+
Table 5: Success Rate (SR) Normalized AUC scores for ImageNet SR plots of the main text. Higher is better.
|
| 421 |
+
Figure 5: Results of attacking Smoothed ImageNet Cohen et al. (2019) in the $L _ { 2 }$ setting for a) query vs. distortion and b) query vs. success rate, Dashed lines denote the value of $\epsilon$ .
|
| 422 |
+
|
| 423 |
+
# A.5.6 ATTACKING WITHOUT GRADIENT ESTIMATE
|
| 424 |
+
|
| 425 |
+
We perform additional experiments with an attack that does not perform an explicit gradient estimate. Chen & Gu (2020) propose an alternative hard-label attack method which is to search for the minimum decision boundary radius $r$ from a sample $\mathbf { x } _ { \mathrm { 0 } }$ , along a ray direction $\pmb { \theta }$ . Instead of searching over $\mathbb { R } ^ { d }$ to minimize $g ( \pmb \theta )$ , Chen et al. propose to perform ray search over directions $\pmb { \theta } \in \{ - 1 , 1 \} ^ { d }$ , resulting in $2 ^ { d }$ maximum possible directions. This reduction of the search resolution enables SotA query efficiency in the $L _ { \infty }$ setting with proof of convergence. The search resolution is further reduced by the hierarchical variant of RayS, which performs on-the-fly upscaling of image super-pixels.
|
| 426 |
+
|
| 427 |
+
Table 6: CIFAR-10 succcess rate values at query intervals 4k, 11k, and 25k, for setting $\cdot$
|
| 428 |
+
|
| 429 |
+
<table><tr><td>Attack Variant</td><td>Natural @4k</td><td>Madry @4k</td><td>Natural @11k</td><td>Madry @11k</td><td>Natural @25k</td><td>Madry @25k</td></tr><tr><td>HSJA</td><td>0.905</td><td>0.100</td><td>0.995</td><td>0.145</td><td>1.000</td><td>0.180</td></tr><tr><td>HSJA+BiLN</td><td>0.850</td><td>0.165</td><td>0.970</td><td>0.225</td><td>0.985</td><td>0.255</td></tr><tr><td>HSJA+Rand</td><td>0.040</td><td>0.020</td><td>0.020</td><td>0.020</td><td>0.040</td><td>0.000</td></tr><tr><td>Sign-OPT</td><td>0.515</td><td>0.030</td><td>0.795</td><td>0.040</td><td>0.890</td><td>0.040</td></tr><tr><td>Sign-OPT+BiLN</td><td>0.235</td><td>0.035</td><td>0.310</td><td>0.035</td><td>0.355</td><td>0.035</td></tr><tr><td>Sign-OPT+Rand</td><td>0.060</td><td>0.020</td><td>0.200</td><td>0.020</td><td>0.180</td><td>0.020</td></tr><tr><td>Sign-OPT+AE</td><td>0.210</td><td>0.055</td><td>0.325</td><td>0.065</td><td>0.345</td><td>0.070</td></tr></table>
|
| 430 |
+
|
| 431 |
+
Table 7: ImageNet succcess rate values at query intervals 4k, 11k, and 25k, for setting $\cdot$
|
| 432 |
+
|
| 433 |
+
<table><tr><td>Attack Variant</td><td>Natural @4k</td><td>Madry @4k</td><td>Natural @11k</td><td>Madry @11k</td><td>Natural @25k</td><td>Madry @ 25k</td></tr><tr><td>HSJA</td><td>0.550</td><td>0.105</td><td>0.850</td><td>0.130</td><td>0.965</td><td>0.165</td></tr><tr><td>HSJA+BiLN</td><td>0.835</td><td>0.240</td><td>0.965</td><td>0.290</td><td>1.000</td><td>0.335</td></tr><tr><td>HSJA+Rand</td><td>0.070</td><td>0.060</td><td>0.070</td><td>0.060</td><td>0.070</td><td>0.060</td></tr><tr><td>Sign-OPT</td><td>0.210</td><td>0.045</td><td>0.335</td><td>0.045</td><td>0.485</td><td>0.045</td></tr><tr><td>Sign-OPT+BiLN</td><td>0.240</td><td>0.055</td><td>0.345</td><td>0.065</td><td>0.445</td><td>0.065</td></tr><tr><td>Sign-OPT+Rand</td><td>0.050</td><td>0.010</td><td>0.070</td><td>0.010</td><td>0.070</td><td>0.010</td></tr><tr><td>Sign-OPT+AE</td><td>0.015</td><td>0.030</td><td>0.015</td><td>0.030</td><td>0.020</td><td>0.040</td></tr></table>
|
| 434 |
+
|
| 435 |
+

|
| 436 |
+
Figure 6: Results for RayS on the CIFAR-10 dataset, corresponding to distortion against query usage (dotted red line denotes the value of $\epsilon$ , shaded areas mark standard deviation).
|
| 437 |
+
|
| 438 |
+
The intuition behind RayS attack is to perform a discrete search in at most $2 ^ { d }$ directions. Chen et al. also perform a hierarchical search over progressively larger super-pixels of the image. This has the effect of already upscaling on-the-fly (Chen & Gu, 2020). RayS has the unique behavior of performing a discrete search for the decision boundary, rather than an explicit gradient estimate. To achieve an appropriate reduced-dimension version of RayS, we modify the calculation of $s$ in Algorithm 3 of Chen & Gu (2020), which either speeds up upscaling by a factor $a$ (i.e., $s = s + a )$ ), or extends the search through a specific block index by a factor $b$ (increase block level at $k = 2 ^ { s } b$ instead of $k = 2 ^ { s }$ ).
|
| 439 |
+
|
| 440 |
+
The result of attacking CIFAR-10 with RayS is shown in Figure 6. The BiLN variants of RayS each have minimal effect on overall query efficiency (Insets 6.i and 6.ii). This is a result of RayS not relying on explicit gradient estimation. When comparing the FID-64 score, the dimension-reduced variants of RayS do not have a large variation between them (Inset 6.i), a side-effect of the adaptive super-pixel search, which can automatically scale the super-pixel size as the search progresses.
|
| 441 |
+
|
| 442 |
+
Table 8: Measurement of Local Intrinsic Dimensionality (LID) averaged over 200 samples.
|
| 443 |
+
|
| 444 |
+
<table><tr><td></td><td>Natural CIFAR-10</td><td>Madry CIFAR-10</td><td>Natural ImageNet</td><td>Madry ImageNet</td></tr><tr><td>Benign</td><td>0.787 ± 0.830</td><td>0.564± 1.724</td><td>1.206 ± 0.803</td><td>2.623 ± 2.383</td></tr><tr><td>HSJA</td><td>8.014 ± 5.829</td><td>62.709 ± 112.416</td><td>4.798 ± 2.578</td><td>3.342 ± 2.263</td></tr><tr><td>HSJA+BiLN</td><td>7.497 ± 5.811</td><td>50.467 ± 100.057</td><td>4.787 ± 2.550</td><td>4.290 ± 4.524</td></tr><tr><td>HSJA+Rand</td><td>6.156 ± 6.053</td><td>15.745 ± 24.195</td><td>5.191 ± 1.948</td><td>3.132 ± 2.489</td></tr><tr><td>Sign-OPT</td><td>7.240 ± 5.006</td><td>51.491 ± 100.080</td><td>4.747 ± 1.988</td><td>3.707 ± 3.660</td></tr><tr><td>Sign-OPT+BiLN</td><td>6.308 ± 4.079</td><td>47.355 ± 119.958</td><td>4.547 ± 2.118</td><td>4.808 ± 4.873</td></tr><tr><td>Sign-OPT+Rand</td><td>5.576 ± 4.178</td><td>12.792 ± 13.546</td><td>5.364 ± 1.757</td><td>4.867 ± 3.369</td></tr><tr><td>Sign-OPT+AE</td><td>6.700 ± 4.735</td><td>51.380 ± 103.355</td><td>4.891 ± 2.299</td><td>3.791 ± 3.598</td></tr></table>
|
| 445 |
+
|
| 446 |
+
# A.5.7 LOCAL INTRINSIC DIMENSIONALITY
|
| 447 |
+
|
| 448 |
+
In Table 8 we show the average Local Intrinsic Dimensionality Amsaleg et al. (2017) for each dataset and attack combination.
|
| 449 |
+
|
| 450 |
+
# A.5.8 FRECHET ´ INCEPTION DISTANCE
|
| 451 |
+
|
| 452 |
+
Unfortunately, the data manifold of real-world datasets is difficult to describe. This is an open problem in the study of Generative Adversarial Networks (GANs), since designers require that generator images are on-manifold (i.e., in-distribution Zhang et al. (2020)) to preserve semantic relationships between images. This has motivated the recently proposed Frechet Inception Distance (FID) that acts ´ as a surrogate measure of the manifold distance over a set of RGB image samples (Heusel et al., 2018). As an additional proxy for manifold distance, we run experiments that assume adversarial samples are synthetically generated images from the data manifold, which can later be compared to their unmodified counterparts on the true manifold using FID. As a result, this estimation process is only available from the defender’s perspective. Since FID uses an Inception-V3 coding layer (Szegedy et al., 2016) to encode images, the estimation correlates with distortion of semantic high-level features. Thus sampling closer to the data manifold will result in a lower FID score. The attacks in our experiments do not target the Inception-V3 network, so the FID metric will not rely on any internal aspects of the victim models.
|
| 453 |
+
|
| 454 |
+
FID score is calculated using the 64-dimensional max pooling layer of the Inception-V3 deep network for coding (denoted as FID-64 in this supplementary material), taken from an open-source implementation.4 The choice of the 64-dimensional feature layer allows to calculate full-rank FID without the full 2,048 sample count of original FID, which is prohibitive based on the scale of our analysis. Since the coding layer differs slightly from the original FID-2048 implementation, the magnitudes will differ from those published by Heusel et al. (2018).
|
| 455 |
+
|
| 456 |
+
The comparison of FID scores is shown in Table 9 for natural and robust models. The scores for ImageNet on dimension-reduced attack variants (italicized) are universally lower (as low as 0.014, bold), while on CIFAR-10 the regular variants did not exhibit the behavior. We posit that the higher dimensionality of ImageNet $( 2 2 4 \times 2 2 4 )$ enables dimension reduction to be more effective than the lower dimension CIFAR-10 $( 3 2 \times 3 2 )$ . In general, attacks have a higher FID score on robust models than natural models. This can be explained by the fact that robust models are more secure in a region around the original sample, as a result the adversarial sample discovery is further away from the true manifold. The random variant (Rand) in rows three and six evidences that the preservation of semantic priors is important during the update, otherwise samples have high manifold distance. The regular variants of HSJA and Sign-OPT are capable of high FID scores on robust models. However, dimension-reduced variants have a universal behavior to reduce the score in the robust setting, similar to the natural setting for ImageNet. AE variants exhibit higher FID score than BiLN, since BiLN can rescale invariant of the adversary’s manifold knowledge (e.g., only having knowledge of test set).
|
| 457 |
+
|
| 458 |
+
Table 9: Frechet Inception Distance (FID) scores for each attack’s set of 200 adversarial samples on ´ CIFAR-10 and ImageNet (lower is better). ∗ denotes highest success rate (SR) AUC. Arrows denote higher or lower score compared to baseline variant.
|
| 459 |
+
|
| 460 |
+
<table><tr><td>Attack Variant</td><td>Natural CIFAR-10</td><td>Madry CIFAR-10</td><td>Natural ImageNet</td><td>Madry ImageNet</td></tr><tr><td>HSJA</td><td>0.005</td><td>1.622</td><td>1.026</td><td>29.756</td></tr><tr><td>HSJA+BiLN</td><td>0.006个</td><td>0.373↓</td><td>0.012↓</td><td>4.646↓</td></tr><tr><td>HSJA+Rand</td><td>2.198个</td><td>8.256个</td><td>3.404↑</td><td>2.354↓</td></tr><tr><td>Sign-OPT</td><td>0.001</td><td>0.305</td><td>20.969</td><td>38.505</td></tr><tr><td>Sign-OPT+BiLN</td><td>0.002个</td><td>0.045↓</td><td>0.009↓</td><td>0.062↓</td></tr><tr><td>Sign-OPT+Rand</td><td>0.141个</td><td>0.210↓</td><td>0.234↓</td><td>0.156↓</td></tr><tr><td>Sign-OPT+AE</td><td>0.333个</td><td>0.008↓</td><td>1.514↓</td><td>7.869↓</td></tr></table>
|
| 461 |
+
|
| 462 |
+
<table><tr><td>Attack Variant</td><td>Natural CIFAR-10</td><td>Madry CIFAR-10</td><td>Natural ImageNet</td><td>Madry ImageNet</td></tr><tr><td>HSJA</td><td>0.016 ± 0.012*</td><td>0.162 ± 0.099</td><td>0.030 ±0.046</td><td>0.170 ± 0.119</td></tr><tr><td>HSJA+BiLN</td><td>0.033 ± 0.024个</td><td>0.156 ± 0.096↓*</td><td>0.019 ± 0.017↓*</td><td>0.169 ± 0.122↓*</td></tr><tr><td>HSJA+Rand</td><td>0.334 ± 0.176个</td><td>0.457 ± 0.101↑</td><td>0.309 ± 0.136个</td><td>0.308 ± 0.141个</td></tr><tr><td>Sign-OPT</td><td>0.015 ± 0.013</td><td>0.137 ± 0.088</td><td>0.096 ±0.118</td><td>0.152 ± 0.112</td></tr><tr><td>Sign-OPT+BiLN</td><td>0.048 ± 0.039↑</td><td>0.191 ± 0.103个</td><td>0.040 ± 0.044↓</td><td>0.171 ± 0.105个</td></tr><tr><td>Sign-OPT+Rand</td><td>0.084±0.092个</td><td>0.214± 0.100↑</td><td>0.082±0.077↓</td><td>0.087± 0.059↓</td></tr><tr><td>Sign-OPT+AE</td><td>0.058 ±0.123个</td><td>0.094 ± 0.068↓</td><td>0.235 ± 0.200个</td><td>0.586 ± 0.299↑</td></tr></table>
|
| 463 |
+
|
| 464 |
+
Table 10: $L _ { \infty }$ distance between adversarial and benign samples projected to approximated manifold (using autoencoder trained on training data) for each attack’s set of 200 adversarial samples on CIFAR-10 and ImageNet (lower is better). Arrows denote higher or lower distance compared to baseline variant, and starred items indicate highest success rate.
|
| 465 |
+
|
| 466 |
+
# A.5.9 $L _ { \infty }$ -NORM OVER APPROXIMATE MANIFOLD
|
| 467 |
+
|
| 468 |
+
We re-use the setup described in Section A.4.2, but train the autoencoders using the training data (defender’s perspective) instead of test data (attacker’s perspective). The results are shown in Table 10. The HSJA $+$ BiLN attack variants were successful in lowering distance for both natural and robust ImageNet. Generally, Sign-OPT variants were most successful for lowering distance from baseline variant for both CIFAR-10 and ImageNet. The primary factor is the dataset dimensionality, with dimension reduction having a bigger impact on ImageNet than CIFAR-10 (green arrows in ImageNet are more widespread). Likewise, robust models always exhibit a higher distance than natural. This can be explained by the fact that adversarially trained models are more robust in a region around the benign sample, thus the successful adversarial sample will be farther away.
|
| 469 |
+
|
| 470 |
+
# A.5.10 VISUAL RESULTS - CIFAR-10
|
| 471 |
+
|
| 472 |
+
We provide visual qualitative results for each attack on CIFAR-10 in Figure 7.
|
| 473 |
+
|
| 474 |
+
# A.5.11 VISUAL RESULTS - IMAGENET
|
| 475 |
+
|
| 476 |
+
We provide visual qualitative results for each attack on ImageNet in Figure 8.
|
| 477 |
+
|
| 478 |
+

|
| 479 |
+
Figure 7: Visual selection of attack trajectories on CIFAR-10.
|
| 480 |
+
|
| 481 |
+

|
| 482 |
+
Figure 8: Visual selection of attack trajectories on ImageNet.
|
md/dev/1QQnYd02etI/1QQnYd02etI.md
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# UNIFIED VISION AND LANGUAGE PROMPT LEARNING
|
| 2 |
+
|
| 3 |
+
Anonymous authors Paper under double-blind review
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
Prompt tuning, a parameter- and data-efficient transfer learning paradigm that tunes only a small number of parameters in a pre-trained model’s input space, has become a trend in the vision community since the emergence of large visionlanguage models like CLIP. We present a systematic study on two representative prompt tuning methods, namely text prompt tuning and visual prompt tuning. A major finding is that none of the unimodal prompt tuning methods performs consistently well: text prompt tuning fails on data with high intra-class visual variances while visual prompt tuning cannot handle low inter-class variances. To combine the best from both worlds, we propose a conceptually simple approach called Unified Prompt Tuning (UPT), which learns a tiny neural network to jointly optimize prompts across different modalities. Extensive experiments on over 11 vision datasets show that UPT achieves a better trade-off than the unimodal counterparts on few-shot learning benchmarks, as well as on domain generalization benchmarks. Code and models will be released to facilitate future research.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Vision-language (VL) models pre-trained on millions of image-text pairs (e.g., CLIP (Radford et al., 2021) and ALIGN (Jia et al., 2021)) have shown excellent transferability on a variety of downstream tasks, such as few-shot learning (Zhou et al., 2022a;b; Ju et al., 2021) and open-vocabulary perception (Gu et al., 2022; Zhou et al., 2022c; Zang et al., 2022; Ghiasi et al., 2021). When adapting large VL models to downstream tasks, it is often impractical to fine-tune the entire model directly due to their huge parameter size. To make adaptation more efficiently, many studies (Gao et al., 2021; Li & Liang, 2021; Lester et al., 2021; Zhou et al., 2022a; Lu et al., 2022; Ju et al., 2021; Yao et al., 2021; Jia et al., 2022; Bahng et al., 2022) have explored prompt tuning where the idea is to fine-tune a small number of parameters in a pre-trained model’s input space, called prompt, while keeping the majority of pre-trained parameters frozen.
|
| 12 |
+
|
| 13 |
+
A typical VL model consists of two sub-networks—an image encoder and a text encoder—to extract features from visual and textual modalities respectively. Correspondingly, existing prompt tuning approaches can be grouped into two types: text prompt tuning and visual prompt tuning. For text prompt tuning methods, e.g., CoOp (Zhou et al., 2022a), extra text prompt tokens treated as learnable parameters are applied on the text encoder (Fig. 1(a)) to mitigate the issue that hand-crafted text prompt templates (e.g., “a photo of a [CLASS].”) are often sub-optimal. On the contrary, visual prompt tuning approaches focus on modulating the image encoder (Fig. 1(b)). A representative method is VPT (Jia et al., 2022), which injects learnable parameters into multiple layers of a Vision Transformer. Notably, these prompt-based methods treat the two modalities in isolation.
|
| 14 |
+
|
| 15 |
+
Despite significant improvements achieved recently, we observe that current prompt tuning approaches (Zhou et al., 2022a; Jia et al., 2022) fail to perform consistently due to inherent variances in visual and text features in downstream tasks. That is to say, using the unimodal prompt may obtain good results on one dataset but not on others.
|
| 16 |
+
|
| 17 |
+
To analyze the phenomenon, we measure the discrepancy in data distribution focusing on the intraclass variance of visual features and inter-class variance of text embedding, and study the correlation between data statistics and performance improvement. As shown in Fig. 1(d), when the intra-class variance of image features is large (bottom right), CoOp struggles to learn suitable text prompts for improving the text classifier. As for visual prompt tuning, VPT faces difficulties when the interclass variance of text features is small, as shown in bottom left of Fig. 1(e). That is, if the text classifiers are based on text features of low separability, tuning visual prompts would lend little help to improve the final performance. Moreover, intra-class visual variance and inter-class text variance are typically orthogonal. As a consequence, the performance of unimodal prompt tuning methods varies widely across different datasets: CoOp beats VPT by $8 . 1 \%$ on Flowers102 (Nilsback & Zisserman, 2008) while VPT outperforms CoOp by $8 . 4 \%$ on EuroSAT (Helber et al., 2019).
|
| 18 |
+
|
| 19 |
+

|
| 20 |
+
Figure 1: Top: Architectures of (a) text prompt tuning (Zhou et al., 2022a), (b) visual prompt tuning (Jia et al., 2022) and (c) our multimodal unified prompt tuning ( $\textcircled { 3 }$ : learnable; $\frac { 2 0 0 } { 9 0 0 }$ : frozen parameters). Bottom: the performance improvements $( \% )$ of text prompt tuning (d) and visual prompt tuning (e) compared with the zero-shot CLIP baseline. We show that the variance of visual and text features ( $\scriptstyle { \dot { x } }$ -axis) will affect the improvements $y$ -axis). We project the text/visual features of the dataset (pointed by the dashed arrow) into a unit sphere to show the variance of different distributions. Please refer to the appendix for the implementation details about how we compute the feature variance.
|
| 21 |
+
|
| 22 |
+
We argue that the key would be to simultaneously adapt both text and visual prompts to overcome the vast differences across different data distributions. A straightforward solution is to introduce both text and visual prompts to the model and jointly optimize the two modality-specific prompts. However, we find that such a na¨ıve joint training leads to poor performance due to the intrinsic discrepancy between text and image modalities. In particular, the performance is occasionally worse than tuning modality-specific prompts as shown in our experiments.
|
| 23 |
+
|
| 24 |
+
Solving the aforementioned issues requires modality-agnostic optimization to bridge the isolated prompts. To this end, we present a unified prompt tuning method for both text and visual modalities, dubbed Unified Prompt Tuning (UPT). See Fig. 1(c). Specifically, we start with a shared prompt and propose a lightweight self-attention network to generate the prompts for CLIP’s text and visual encoders respectively. We empirically show that such a conceptually simple design can preserve the benefit of individual modalities.
|
| 25 |
+
|
| 26 |
+
Our contributions are summarized as follows. 1) We provide a comprehensive study on existing text and visual prompt tuning methods, and identify the shortcoming of unimodal learning. 2) We present a unified prompt learning method for VL models, which is simple and easy to implement. 3) We conduct extensive experiments to show that unified prompt tuning outperforms previous unimodal prompt tuning methods under the few-shot learning and domain generalization settings.
|
| 27 |
+
|
| 28 |
+
# 2 METHODOLOGY
|
| 29 |
+
|
| 30 |
+
We first introduce vision-language models focusing on CLIP (Radford et al., 2021), in company with text/visual prompt tuning approaches for visual recognition in Sec. 2.1. We then analyze the
|
| 31 |
+
|
| 32 |
+
limitations of previous single-modal prompt tuning approaches in Sec. 2.2. Finally, we present technical details of our proposed unified prompt learning in Sec. 2.3.
|
| 33 |
+
|
| 34 |
+
# 2.1 PRELIMINARIES
|
| 35 |
+
|
| 36 |
+
CLIP. CLIP (Radford et al., 2021) consists of two sub-networks: an image encoder $\phi$ and a text encoder $\psi$ . These two encoders, respectively, map the text and image inputs into a joint hidden space $\mathbb { R } ^ { d }$ , where the semantics of vision and language modalities are well-aligned. Here, $d$ refers to the final hidden dimension of the text or image encoder (e.g., $d = 2 5 6$ in the ResNet (He et al., 2016) backbone and $d = 5 1 2$ in the ViT backbone). Given an input image $_ { \textbf { \em x } }$ and a set of categories $\mathbf { Y } = \{ y _ { 1 } , y _ { 2 } , . . . , y _ { k } \}$ (e.g., $k = 1 0 0 0$ for ImageNet (Deng et al., 2009)), the image encoder extracts the corresponding image feature $z = f _ { \phi } ( \pmb { x } ) \in \mathbb { R } ^ { d }$ . While the class names in $\mathbf { Y }$ are first filled into a hand-crafted text prompt template a photo of a [CLASS] to obtain the text descriptions A, further processed by the text encoder for the text representations: $\mathbf { W } = f _ { \psi } ( \mathbf { A } ) \in \mathbb { R } ^ { d \times k }$ . The final prediction is computed as follows:
|
| 37 |
+
|
| 38 |
+
$$
|
| 39 |
+
p ( y = i \mid \pmb { x } ) = \frac { \exp \left( \cos \left( \pmb { w } _ { i } , \pmb { z } \right) / \tau \right) } { \sum _ { j = 1 } ^ { k } \exp \left( \cos \left( \pmb { w } _ { j } , \pmb { z } \right) / \tau \right) } ,
|
| 40 |
+
$$
|
| 41 |
+
|
| 42 |
+
where $\cos ( \cdot , \cdot )$ denotes the cosine similarity and $\tau$ is a fixed temperature value (e.g., $\tau = 1 0 0$ ). Conceptually, such a decision process for the input image $_ { \textbf { \em x } }$ in Eq. (1) is formulated in a way that the text encoder $\psi$ takes a role of generating dynamic classifiers W from open-set categories $\mathbf { Y }$ , with the image encoder $\phi$ producing encoded visual features $_ { z }$ . In practice, it is generally infeasible to fine-tune the millions of parameters (i.e., $\phi$ and $\psi$ ) in a VL model for transfer learning in every downstream task.
|
| 43 |
+
|
| 44 |
+
Text Prompt Tuning. For efficient and effective model adaptation, text prompt tuning approaches consider generating more adaptive classifiers without fine-tuning the text encoder $\psi$ . For example, Context Optimization $\left( \mathbf { C o O p } \right)$ (Zhou et al., 2022a) introduce a set of learnable parameters $\textbf { T } \in$ $\mathbb { R } ^ { d \times m }$ to replace the hand-crafted text prompt template (a photo of a [CLASS]). The wordembedding of class names in $\mathbf { Y }$ will concatenate with these text prompts in the following form:
|
| 45 |
+
|
| 46 |
+
$$
|
| 47 |
+
\mathrm { \hat { T } } = [ t _ { 1 } , t _ { 2 } , \dots , t _ { m } , \mathrm { C L A S S } ] .
|
| 48 |
+
$$
|
| 49 |
+
|
| 50 |
+
Here, the symbol $m$ denotes the prompt length. The resulting dynamic text representations are extracted by the text encoder: $\mathbf { W } = f _ { \psi } ( \hat { \mathbf { T } } ) \in \mathbb { R } ^ { d \times k }$ . In each downstream task, the learnable prompts $\mathbf { T }$ will be optimized with each task-specific objective function, e.g., a cross-entropy classification loss $\mathcal { L } _ { \mathrm { C E } } ( p , y )$ in few-shot learning. Note that both the image and text encoders $\cdot \phi$ and $\psi$ ) are frozen during downstream training. As a result, updating the text prompt $\mathbf { T }$ will correspondingly adjust the decision boundaries with generated classifiers $\mathbf { W }$ for downstream tasks.
|
| 51 |
+
|
| 52 |
+
Visual Prompt Tuning. Conversely, visual prompt tuning methods focus on extracting more transferable visual features while keeping the visual encoder $\phi$ unchanged. Following the success of text prompt tuning approaches, recent Visual Prompt Tuning (VPT) (Jia et al., 2022) introduces a similar prompt tuning recipe for the visual encoder $\phi$ . Suppose the image encoder $\phi$ contains $L$ Vision Transformer layers, the output of $i$ -th layer, $l _ { i }$ , where $i = 1 , 2 , \dots , L$ , is given by:
|
| 53 |
+
|
| 54 |
+
$$
|
| 55 |
+
[ { \pmb { c } } ^ { i + 1 } , z _ { 1 } ^ { i + 1 } , \dots , z _ { s } ^ { i + 1 } ] = l _ { i } \left( \left[ { \pmb { c } } ^ { i } , z _ { 1 } ^ { i } , \dots , z _ { s } ^ { i } \right] \right) ,
|
| 56 |
+
$$
|
| 57 |
+
|
| 58 |
+
where $c \in \mathbb { R } ^ { d }$ denotes the classification token ([CLS]), and $Z = [ z _ { 1 } , z _ { 2 } , \ldots , z _ { s } ] \in \mathbb { R } ^ { d \times s }$ denotes the input image patch tokens with length $s$ . For the $i$ -th encoder layer, a set of learnable visual prompts $\mathbf { V } ^ { i } \in \mathbb { R } ^ { \tilde { d } \times n }$ are inserted and computed as follows:
|
| 59 |
+
|
| 60 |
+
$$
|
| 61 |
+
[ { \pmb { c } } ^ { i + 1 } , \ldots , { \pmb { Z } } ^ { i + 1 } ] = l _ { i } \left( \left[ { \pmb { c } } ^ { i } , { \pmb { V } } ^ { i } , { \pmb { Z } } ^ { i } \right] \right) ,
|
| 62 |
+
$$
|
| 63 |
+
|
| 64 |
+
where $n$ stands for the length of visual prompts. Two VPT variants are proposed: VPT-shallow and VPT-deep. For VPT-shallow, the visual prompts are only inserted into the first Transformer layer $( i = 1 )$ ). Whereas for VPT-deep, visual prompts are introduced at every layer. The learnable visual prompts are data-independent, which once learned, can modulate the visual features $_ z$ of input images for better downstream transfer learning.
|
| 65 |
+
|
| 66 |
+

|
| 67 |
+
Figure 2: Visualization of input features $_ { z }$ (projected points) and text classifier W (projected lines) on EuroSAT and Flowers102.
|
| 68 |
+
|
| 69 |
+
# 2.2 ANALYSIS
|
| 70 |
+
|
| 71 |
+
We conduct a series of probing studies to analyze the characteristics of text/visual prompt tuning. First, when adapting the CLIP model with two representative text and visual prompt tuning approaches $\mathrm { C o O p }$ (Zhou et al., 2022a) and VPT (Jia et al., 2022)), we measure the variance of both visual features $_ z$ and text embeddings W (i.e., classifiers) for all 11 downstream vision datasets (see Appendix for detailed implementations). For text prompt tuning, as shown in Fig. 1(d), we observe that CoOp performs well on datasets with low intra-class variance between visual features, such as Flowers102, but fails on Food101 dataset with high intra-class feature variance. As for visual prompt tuning, VPT succeeds in improving performance on SUN397 dataset with large inter-class text embeddings, while being less effective on Food101 and Flowers102 with relatively smaller inter-class text embedding variance. The performance improvements of text/visual prompt tuning are highly correlated with the variance of visual features $_ z$ or text embeddings W in downstream datasets.
|
| 72 |
+
|
| 73 |
+
In order to understand this phenomenon, we select two downstream vision datasets (Flowers102 (Nilsback & Zisserman, 2008), EuroSAT (Helber et al., 2019)) for further analysis. During downstream training, we project both visual features $_ z$ and text embeddings W (i.e., classifiers) into joint sphere space ${ \bar { \mathbb { R } } } ^ { 3 }$ for better visualization. As we illustrated in Fig. 2, we can observe that: 1) For the EuroSAT dataset with high intra-class visual feature variance, text prompts in $\mathrm { C o O p }$ fails to adapt the text classifiers W. Clearly, the text classifiers in Fig. $2 ( \mathbf { b } )$ are almost unchanged compared with zero-shot CLIP baseline (Fig. 2(a)). 2) For the Flowers102 dataset with low inter-class text embedding variance, visual prompts in VPT are not effective in modulating the visual features $_ { z }$ (Fig. ${ \bf \Pi } ( \mathbf { g } )$ ), thus cannot obtain considerable performance gain.
|
| 74 |
+
|
| 75 |
+
In conclusion, the single-modal prompt tuning approaches $\mathrm { C o O p }$ and VPT), face the dilemma that consistent improvements over Zero-shot CLIP are hard to achieve due to inherent variances of visual features and text embedding in downstream tasks. Our observation motivates us to present a unified prompt tuning method that tunes the $_ z$ and W at the same time.
|
| 76 |
+
|
| 77 |
+
# 2.3 UNIFIED PROMPT TUNING
|
| 78 |
+
|
| 79 |
+
Driven by our analysis, we devise a simple yet effective multi-modal Unified Prompt Tuning (UPT) approach for adapting VL models. Specifically, instead of introducing two sets of isolated modalityspecific prompts (i.e., T in Eq. (2) and $\mathbf { V }$ in Eq. (4)) for the text and visual encoders, we consider learning a set of unified modality-agnostic prompts for tuning VL models. As shown in Fig. 3, we define a set of learnable prompts $\breve { U } \in \mathbb { R } ^ { \tilde { d } \times n }$ with length $n$ . Rather than na¨ıvely appending the unified prompts into the text and visual encoders, we employ a lightweight Transformer layer $\theta$ to
|
| 80 |
+
|
| 81 |
+

|
| 82 |
+
Figure 3: The architecture of (a) our unified prompt $U$ that is applied to $\mathbf { ( b ) }$ CLIP text encoder and (c) CLIP image encoder.
|
| 83 |
+
|
| 84 |
+
transform unified prompts $U$ as follows:
|
| 85 |
+
|
| 86 |
+
$$
|
| 87 |
+
\begin{array} { r l } & { U ^ { \prime } = \mathrm { S A } \left( U \right) + \mathrm { L N } \left( U \right) , } \\ & { \hat { U } = \mathrm { F F N } \left( \mathrm { L N } \left( U ^ { \prime } \right) \right) + \mathrm { L N } \left( U ^ { \prime } \right) , } \end{array}
|
| 88 |
+
$$
|
| 89 |
+
|
| 90 |
+
where the self-attention operator SA, feed-forward network FFN and layer normalization LN are applied to obtain the transformed prompts $\hat { U }$ . The self-attention module in the lightweight Transformer layer allows beneficial interaction between two modalities, so as to maximize the complementary effects. Our unified prompts can be introduced into multiple layers of VL models. In particular, for each $i$ -th layer of text and image encoders, we consider learning a set of layer-wise prompts $U ^ { i }$ , and split transformed $\hat { \pmb { U } } ^ { i }$ into two parts $\hat { U } ^ { i } = \{ \hat { U } _ { t } ^ { i } , \hat { U } _ { v } ^ { i } \}$ , sending into the text and visual encoders respectively. During downstream training, we froze both the text and visual encoder $\dot { \psi }$ and $\phi$ ) and only optimize the unified prompts $U$ and the lightweight Transformer layer $\theta$ . In this way, both the dynamic classifiers W and visual features $_ z$ in Eq. (1) are effectively tuned for reliable prediction in the downstream task. As shown in Fig. 2 (d) and (h), our unified prompts can simultaneously obtain well-aligned text classifiers and separable visual features compared with single-modal counterparts.
|
| 91 |
+
|
| 92 |
+
# 3 EXPERIMENTS
|
| 93 |
+
|
| 94 |
+
In this section, we conduct experiments under two problem settings, i.e., (i) few-shot image classification (Sec. 3.1) and (ii) domain generalization (Sec. 3.2). We also present ablation studies in Sec. 3.3 on several design choices and extra experimental results about generalizability in Appendix.
|
| 95 |
+
|
| 96 |
+
Baselines. We compare our approach against the following methods: (1) Zero-shot CLIP. This baseline uses hand-crafted text prompt templates and does not involve any prompt-learning strategies. (2) Single-modal Prompt Tuning methods, including CoOp (Zhou et al., 2022a) and ProDA (Lu et al., 2022) for the text modality, and VPT (Jia et al., 2022) for the visual modality. In the domain generalization setting, we further compare with CoCoOp (Zhou et al., 2022b), which improves CoOp’s generalization performance with an input-conditional design. For VPT, we report the results of both the shallow and deep variants, as described in Sec. 2.1.
|
| 97 |
+
|
| 98 |
+
# 3.1 FEW-SHOT LEARNING
|
| 99 |
+
|
| 100 |
+
In this section, we measure a model’s generalization ability by conducting prompt tuning using different strategies, with just a limited amount of labeled examples per-class in the specific downstream task. Detailed implementation is presented in Appendix.
|
| 101 |
+
|
| 102 |
+
Datasets. We follow (Zhou et al., 2022b) to use 11 datasets (ImageNet (Deng et al., 2009), Caltech101 (Fei-Fei et al., 2004), OxfordPets (Parkhi et al., 2012), StanfordCars (Krause et al., 2013), Flowers102 (Nilsback & Zisserman, 2008), Food101 (Bossard et al., 2014), FGVC-Aircraft (Maji et al., 2013), SUN397 (Xiao et al., 2010), UCF101 (Soomro et al., 2012), DTD (Cimpoi et al., 2014), EuroSAT (Helber et al., 2019)) as our benchmarks. Following (Zhou et al., 2022a), we use the fewshot evaluation protocol selecting 1/2/4/8/16 shots for training and the whole test set for evaluation. We report averaged results over three runs with different random seeds to reduce the variance. The detailed results are shown in Fig. 4.
|
| 103 |
+
|
| 104 |
+
Limitation of Single-modal Baselines. Figure 4 shows that the performance improvements of existing text prompt tuning method CoOp and visual prompt tuning method VPT are not consistent across different datasets. In particular, CoOp obtains better performance than VPT on some datasets, such as StanfordCars and SUN397. However, for other datasets with high intra-class visual variances, VPT is much more effective than CoOp. For instance, on the EuroSAT dataset, VPT-deep beats $\mathrm { C o O p }$ by over $12 \%$ . The discrepancy of previous single-modal baselines is also consistent with our motivation in Fig. 1(d) and Fig. 1(e). According to VPT (Jia et al., 2022), VPT-deep is more effective than VPT-shallow, and our experimental results also verify this point. We later show that VPT-shallow obtains much stronger performance than the VPT-deep in the domain generalization setting (Sec. 3.2).
|
| 105 |
+
|
| 106 |
+

|
| 107 |
+
Figure 4: Main results over 11 datasets under the few-shot learning setting. We report the average accuracy $( \% )$ of 1/2/4/8/16 shots over three runs. Overall, the proposed UPT (blue line) achieves apparent improvements compared with the Zero-shot CLIP and single-modal prompt tuning baselines $\mathrm { C o O p }$ , ProDA and VPT).
|
| 108 |
+
|
| 109 |
+
UPT vs. Single-modal Baselines. Our UPT achieves clear advantages over the single-modal prompt-tuning counterparts CoOp, ProDA and VPT, as suggested by the averaged performance (topleft of Fig. 4). In general, the average performance gap between UPT and baselines increases with the shot number available for prompt tuning. Specifically, UPT obtains $0 . 4 8 / 1 . 3 6 / 1 . 2 9 / 2 . 4 6 / 3 . 1 9 ( \% )$ accuracy improvements compared with the text prompt tuning method CoOp on 1/2/4/8/16 shots settings. Even compared with the strong text prompt tuning baseline ProDA, UPT still boosts the accuracy of $0 . 1 1 / 1 . { \overset { \cdot } { 0 } } 1 / 0 . 6 7 / 1 . 5 / 1 . 6 1 ( \% )$ . Similarly, UPT achieves $0 . 8 9 / 2 . 7 0 / 2 . 0 3 / 2 . 4 0 / 2 . 0 1 ( \% )$ accuracy gains over the visual prompt tuning approach VPT-deep. Notably, UPT significantly boosts the performance over CoOp and VPT-deep on challenging large datasets, such as ImageNet with 1,000 classes and SUN397 with 397 categories. UPT also surpasses CoOp and VPT-deep on finegrained datasets such as StanfordCars and FGVC Aircraft. We also observe that UPT shows less improvement on the two datasets (OxfordPets and Food101), possibly caused by the noisy training data (Zhou et al., 2022a; Bossard et al., 2014). Overall, the experimental results in Fig. 4 demonstrate the effectiveness of our proposed UPT.
|
| 110 |
+
|
| 111 |
+
Table 1: Main results under the domain generalization setting. We report the average accuracy $( \% )$ of 16 shots over three runs. The best and second best methods are highlighted in red and orange , respectively.
|
| 112 |
+
|
| 113 |
+
<table><tr><td rowspan="2">#</td><td rowspan="2">Method</td><td>Source</td><td colspan="4">Target</td><td rowspan="2">Overall Average</td><td rowspan="2">00D Average</td></tr><tr><td>ImageNet</td><td>-V2</td><td>-S</td><td>-A</td><td>-R</td></tr><tr><td></td><td>CoOp</td><td>71.51</td><td>64.20</td><td>47.99</td><td>49.71</td><td>75.21</td><td>61.72</td><td>59.28</td></tr><tr><td></td><td>CoCoOp</td><td>71.02</td><td>64.07</td><td>48.75</td><td>50.63</td><td>76.18</td><td>62.13</td><td> 59.91</td></tr><tr><td></td><td>VPT-shallow</td><td>68.98</td><td>62.10</td><td>47.68</td><td>47.19</td><td>76.10</td><td>60.38</td><td>58.27</td></tr><tr><td>1234</td><td>VPT-deep</td><td>70.57</td><td>63.67</td><td>47.66</td><td>43.85</td><td>74.42</td><td>60.04</td><td>57.40</td></tr><tr><td>5</td><td>Joint Training</td><td>71.42</td><td>64.36</td><td>48.20</td><td>49.71</td><td>76.23</td><td>61.97</td><td>59.61</td></tr><tr><td>6</td><td>Shared</td><td>71.46</td><td>64.43</td><td>48.13</td><td>50.03</td><td>75.76</td><td>61.96</td><td>59.55</td></tr><tr><td>7</td><td>MLP</td><td>71.00</td><td>64.11</td><td>48.65</td><td>48.76</td><td>76.14</td><td>61.78</td><td>59.48</td></tr><tr><td>8</td><td>UPT</td><td>72.63</td><td>64.35</td><td>48.66</td><td>50.66</td><td>76.24</td><td>62.51</td><td> 59.98</td></tr></table>
|
| 114 |
+
|
| 115 |
+

|
| 116 |
+
Figure 5: Ablation studies on different design choices. (a): jointly train the existing text and visual prompt tuning approaches; (b): shared prompts for all modalities; (c): using two MLP layers to generate the prompts.
|
| 117 |
+
|
| 118 |
+
# 3.2 DOMAIN GENERALIZATION
|
| 119 |
+
|
| 120 |
+
Pre-trained VL models like CLIP have shown strong generalization ability. However, the prompt tuned on a specific downstream dataset may hinder the generalization ability on categories outside the training set. In this section, we evaluate the generalization ability of different prompt tuning methods on out-of-distribution (OOD) data.
|
| 121 |
+
|
| 122 |
+
Datasets. We follow (Zhou et al., 2022a) to use five datasets (ImageNet (Deng et al., 2009), ImageNet V2 (Recht et al., 2019), ImageNet-Sketch (Wang et al., 2019), ImageNet-A (Hendrycks et al., 2021b) and ImageNet-R (Hendrycks et al., 2021a)) for evaluation. Following the protocol, we train a model on ImageNet and evaluate it on four other variants of ImageNet with their domains shifted.
|
| 123 |
+
|
| 124 |
+
Results. Table 1 summarizes the results. We report the average accuracy on both the source and target datasets (penultimate column), and the OOD average accuracy on target datasets (last column). The results show that VPT-shallow (row #2) achieves higher OOD accuracy than VPT-deep (row #3), and text prompt tuning methods outperform visual prompt tuning approaches. Furthermore, the proposed UPT (row #8) is generally a better option than single-modal baselines (rows #1-#4) and obtains comparable performance with CoCoOp. Our UPT achieves the best results three times on five datasets, showing that UPT is a reliable prompt tuning method among its competitors in the domain generalization setting.
|
| 125 |
+
|
| 126 |
+
# 3.3 ABLATION STUDIES
|
| 127 |
+
|
| 128 |
+
Comparison with the Joint Training Baseline. As shown in Fig. 5(a), a straightforward approach for multi-modal prompts is tune the text prompt (using CoOp) and visual prompt (using VPT) jointly.
|
| 129 |
+
|
| 130 |
+
Table 2: Ablation studies on different multi-modal prompt design choices in Fig. 5 over 11 datasets. We report the accuracy results under the 16 shots setting. The best and second best methods are highlighted in red and orange , respectively.
|
| 131 |
+
|
| 132 |
+
<table><tr><td>#</td><td>Prrega</td><td>eee</td><td>Grreeaer</td><td>s1edpitrit</td><td>ssrrprteets</td><td>Tiroeni0</td><td></td><td>FTaaeieelr [orpoon</td><td></td><td>163308</td><td></td><td>JtoSSS</td><td>UUIIII</td><td>2neace</td></tr><tr><td>1</td><td>CoOp</td><td>71.36</td><td>95.93</td><td>92.74</td><td>77.45</td><td>95.90</td><td>86.36</td><td>38.04</td><td>73.59</td><td>68.38</td><td>78.77</td><td></td><td>82.04</td><td>78.24</td></tr><tr><td>2</td><td>VPT-shallow</td><td>68.98</td><td>94.66</td><td>92.61</td><td>69.09</td><td></td><td>81.40</td><td>86.91</td><td>30.93</td><td>68.08</td><td>52.28</td><td>84.87</td><td>75.19</td><td>73.18</td></tr><tr><td>3</td><td>VPT-deep</td><td>70.57</td><td>95.83</td><td>92.91</td><td>76.13</td><td></td><td>94.96</td><td>86.18</td><td>40.96</td><td>71.63</td><td>69.79</td><td>91.53</td><td>82.76</td><td>79.39</td></tr><tr><td>4</td><td>Joint Training</td><td>71.42</td><td>95.84</td><td></td><td>93.34 79.02</td><td></td><td>95.25</td><td>86.55</td><td>40.56</td><td>74.17</td><td>67.83</td><td>78.94</td><td>82.81</td><td>78.70</td></tr><tr><td>5</td><td>Shared</td><td>71.46</td><td>95.50</td><td>92.99</td><td>78.66</td><td></td><td>95.55</td><td>86.67</td><td>39.18</td><td>73.64</td><td>67.69</td><td>73.36</td><td>82.06</td><td>77.88</td></tr><tr><td>6</td><td>MLP</td><td>71.00</td><td>95.59</td><td>93.74</td><td>75.88</td><td>93.38</td><td></td><td>87.20</td><td>37.17</td><td>72.74</td><td>67.31</td><td>90.66</td><td>81.43</td><td>78.73</td></tr><tr><td>7</td><td>UPT (Ours)</td><td>72.63 95.94</td><td></td><td>92.95</td><td></td><td>84.33 97.11</td><td></td><td>85.00</td><td>46.80</td><td>75.92 70.65</td><td></td><td>90.51</td><td>84.03 81.44</td><td></td></tr></table>
|
| 133 |
+
|
| 134 |
+

|
| 135 |
+
Figure 6: Visualization of attention response map between visual prompts and image patch tokens. The images are test images from ImageNet. We visualize the self-attention module from the last block of ViT of the CLIP image encoder.
|
| 136 |
+
|
| 137 |
+
We investigate the effectiveness of such joint training scheme, and report its results in Table 2 row #4 and Table 1 row #5. On the few-shot learning setting, we see that such a joint training solution performs better than $\mathrm { C o O p }$ and VPT-shallow, which shows that multi-modal optimization is helpful to a certain extent. But the joint training approach obtains slightly worse accuracy than the VPT-deep $7 8 . 7 0 \%$ vs. $7 9 . 3 9 \%$ ) since VPT-deep involves a large number of parameters. On the domain generalization setting, we find the joint training method performs much better than VPT-deep. Also, the joint training method shows inferior performance to our UPT, demonstrating that our self-attention base mechanism is more effective.
|
| 138 |
+
|
| 139 |
+
Shared Prompts for Text and Visual Modalities. We also investigate the results of directly sharing prompts for different modalities. As shown in Fig. 5(b), the shared prompts will be optimized for both text and visual modalities. This scheme differs from the proposed UPT, where the shared prompts are transformed with self attention. Experimental results are presented in Table 2 row #5 and Table 1 row #6, and we observe that such a prompt sharing strategy achieves worst performance among all the ablation design choices.
|
| 140 |
+
|
| 141 |
+
MLP Baseline. For our proposed UPT, we use a Transformer layer with the self-attention operator to partially share the hyper-parameters for different modalities. Here, we study a simpler design that generates the unified prompts with two MLP layers. Results are presented on Table 2 row #6 and Table 1 row #7. The MLP baseline is still competitive, yielding best performance on two datasets. Nonetheless, the average results is still poorer than the proposed self-attention based approach.
|
| 142 |
+
|
| 143 |
+
# 3.4 QUALITATIVE RESULTS
|
| 144 |
+
|
| 145 |
+
While it is hard to visualize what have been learned during text prompt tuning, it is possible to visualize the visual prompts learned by VPT and UPT following the self-supervised learning method, DINO (Caron et al., 2021). In particular, for each layer of the Vision Transformer (ViT), we can compute the self-attention response map of visual prompts and image patch tokens. Figure 6 compares such response maps by VPT and the proposed UPT. We find that UPT shows stronger selfattention responses compared with VPT. This could be the possible reason why UPT achieves better performance on the few-shot learning and the OOD generalization settings.
|
| 146 |
+
|
| 147 |
+
# 4 RELATED WORK
|
| 148 |
+
|
| 149 |
+
Vision-Language Models. Recent vision-language pre-trained models (Radford et al., 2021; Jia et al., 2021) use the contrastive loss to align an image encoder (e.g., ViT (Dosovitskiy et al., 2021)) and a text encoder (e.g., BERT (Kenton & Toutanova, 2019)) in a common feature space. These vision-language models are trained on web-scale image-text pairs and are transferable across various downstream tasks such as point cloud classification (Zhang et al., 2022a), video classification (Qian et al., 2022), object detection (Gu et al., 2022; Du et al., 2022; Zhou et al., 2022c; Zang et al., 2022) and semantic segmentation (Ghiasi et al., 2021). In this work, we aim to explore how to adapt the CLIP model to the downstream few-shot recognition task.
|
| 150 |
+
|
| 151 |
+
Text Prompt Tuning. The concept of prompt tuning was first proposed in the NLP area (Liu et al., 2021; Gao et al., 2021; Li & Liang, 2021; Lester et al., 2021). In particular, a text prompt refers to a task-specific template for language models. For example, in sentiment analysis, the template might be “I [MASK] the movie.” where the mask placeholder will be filled with either “love” or “hate.” Common practices in text prompt tuning include (i) searching for a specific word in the dictionary, known as hard prompt learning (Gao et al., 2021), or (ii) turning masked tokens into learnable vectors, known as soft prompt learning (Li & Liang, 2021; Lester et al., 2021). Text prompt tuning has also been applied in computer vision after the emergence of large vision-language models (e.g., CLIP (Radford et al., 2021)), which are too big to fine-tune. A representative work is CoOp (Zhou et al., 2022a), which turned the input context tokens in CLIP’s text branch into learnable vectors for adapting CLIP to downstream image recognition. Other follow-ups of $\mathrm { C o O p }$ include CoCoOp (Zhou et al., 2022b), DualCoOp (Sun et al., 2022), ProGrad (Xing et al., 2022), and ProDA (Lu et al., 2022).
|
| 152 |
+
|
| 153 |
+
Visual Prompt Tuning. The idea of visual prompt tuning is to adapt large pre-trained Vision Transformers (Dosovitskiy et al., 2021) by adding learnable parameters in the visual input space, which is analogous to text prompt tuning in NLP. VPT (Jia et al., 2022) and Visual Prompting (Bahng et al., 2022) both add trainable tokens to the input of Transformer models. A recent work, NOAH (Zhang et al., 2022b), uses neural architecture search algorithms to identify the optimal configuration of prompt modules. In comparison to the unimodal prompt learning methods discussed above, our paper provides a timely study on how to achieve a better trade-off using multimodal prompt learning.
|
| 154 |
+
|
| 155 |
+
# 5 CONCLUSION
|
| 156 |
+
|
| 157 |
+
With the rapid scaling of vision models along the size dimension, efficient downstream adaptation methods have become essential for facilitating large-scale deployment of vision models in the wild. Our paper provides a timely and comprehensive study on how to adapt large vision-language models like CLIP from the prompt learning perspective. In particular, our study unveils that the previous unimodal prompt tuning methods do not work consistently well across different computer vision datasets. In contrast, the proposed UPT method, despite having a simple design, achieves a better trade-off compared with the unimodal counterparts. The results suggest that one should exploit correspondences between different modalities for prompt learning.
|
| 158 |
+
|
| 159 |
+
On the other hand, the results achieved by UPT are by no means perfect: in the ablation studies we observe that some alternative designs, such as using MLP instead of Transformer, might sometimes give better performance. In summary, we believe multimodal prompt learning is a promising framework, and we expect more improvements to be achieved with more advanced (and efficient) designs.
|
| 160 |
+
|
| 161 |
+
# REFERENCES
|
| 162 |
+
|
| 163 |
+
Hyojin Bahng, Ali Jahanian, Swami Sankaranarayanan, and Phillip Isola. Visual prompting: Modifying pixel space to adapt pre-trained models. arXiv preprint arXiv:2203.17274, 2022.
|
| 164 |
+
|
| 165 |
+
Lukas Bossard, Matthieu Guillaumin, and Luc Van Gool. Food-101–mining discriminative components with random forests. In ECCV, pp. 446–461. Springer, 2014.
|
| 166 |
+
|
| 167 |
+
Mathilde Caron, Hugo Touvron, Ishan Misra, Herve J ´ egou, Julien Mairal, Piotr Bojanowski, and ´ Armand Joulin. Emerging properties in self-supervised vision transformers. In ICCV, pp. 9650– 9660, 2021.
|
| 168 |
+
|
| 169 |
+
Mircea Cimpoi, Subhransu Maji, Iasonas Kokkinos, Sammy Mohamed, and Andrea Vedaldi. Describing textures in the wild. In CVPR, pp. 3606–3613, 2014.
|
| 170 |
+
|
| 171 |
+
Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In CVPR, pp. 248–255. IEEE, 2009.
|
| 172 |
+
|
| 173 |
+
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. ICLR, 2021.
|
| 174 |
+
|
| 175 |
+
Yu Du, Fangyun Wei, Zihe Zhang, Miaojing Shi, Yue Gao, and Guoqi Li. Learning to prompt for open-vocabulary object detection with vision-language model. In CVPR, pp. 14084–14093, 2022.
|
| 176 |
+
|
| 177 |
+
Li Fei-Fei, Rob Fergus, and Pietro Perona. Learning generative visual models from few training examples: An incremental bayesian approach tested on 101 object categories. In CVPR workshop, pp. 178–178. IEEE, 2004.
|
| 178 |
+
|
| 179 |
+
Tianyu Gao, Adam Fisch, and Danqi Chen. Making pre-trained language models better few-shot learners. In ACL, 2021.
|
| 180 |
+
|
| 181 |
+
Golnaz Ghiasi, Xiuye Gu, Yin Cui, and Tsung-Yi Lin. Open-vocabulary image segmentation. arXiv preprint arXiv:2112.12143, 2021.
|
| 182 |
+
|
| 183 |
+
Xiuye Gu, Tsung-Yi Lin, Weicheng Kuo, and Yin Cui. Open-vocabulary object detection via vision and language knowledge distillation. In ICLR, 2022.
|
| 184 |
+
|
| 185 |
+
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, pp. 770–778, 2016.
|
| 186 |
+
|
| 187 |
+
Patrick Helber, Benjamin Bischke, Andreas Dengel, and Damian Borth. Eurosat: A novel dataset and deep learning benchmark for land use and land cover classification. IEEE J. Sel. Top. Appl. Earth Obs. Remote Sens., 12(7):2217–2226, 2019.
|
| 188 |
+
|
| 189 |
+
Dan Hendrycks, Steven Basart, Norman Mu, Saurav Kadavath, Frank Wang, Evan Dorundo, Rahul Desai, Tyler Zhu, Samyak Parajuli, Mike Guo, et al. The many faces of robustness: A critical analysis of out-of-distribution generalization. In ICCV, pp. 8340–8349, 2021a.
|
| 190 |
+
|
| 191 |
+
Dan Hendrycks, Kevin Zhao, Steven Basart, Jacob Steinhardt, and Dawn Song. Natural adversarial examples. In CVPR, pp. 15262–15271, 2021b.
|
| 192 |
+
|
| 193 |
+
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, pp. 4904–4916. PMLR, 2021.
|
| 194 |
+
|
| 195 |
+
Menglin Jia, Luming Tang, Bor-Chun Chen, Claire Cardie, Serge Belongie, Bharath Hariharan, and Ser-Nam Lim. Visual prompt tuning. arXiv preprint arXiv:2203.12119, 2022.
|
| 196 |
+
|
| 197 |
+
Chen Ju, Tengda Han, Kunhao Zheng, Ya Zhang, and Weidi Xie. Prompting visual-language models for efficient video understanding. arXiv reprint arXiv:2112.04478, 2021.
|
| 198 |
+
|
| 199 |
+
Jacob Devlin Ming-Wei Chang Kenton and Lee Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In NAACL, pp. 4171–4186, 2019.
|
| 200 |
+
|
| 201 |
+
Jonathan Krause, Michael Stark, Jia Deng, and Li Fei-Fei. 3d object representations for fine-grained categorization. In ICCV workshops, pp. 554–561, 2013.
|
| 202 |
+
Brian Lester, Rami Al-Rfou, and Noah Constant. The power of scale for parameter-efficient prompt tuning. In EMNLP, 2021.
|
| 203 |
+
Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. ACL, 2021.
|
| 204 |
+
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.
|
| 205 |
+
Yuning Lu, Jianzhuang Liu, Yonggang Zhang, Yajing Liu, and Xinmei Tian. Prompt distribution learning. In CVPR, 2022.
|
| 206 |
+
Subhransu Maji, Esa Rahtu, Juho Kannala, Matthew Blaschko, and Andrea Vedaldi. Fine-grained visual classification of aircraft. arXiv preprint arXiv:1306.5151, 2013.
|
| 207 |
+
Maria-Elena Nilsback and Andrew Zisserman. Automated flower classification over a large number of classes. In ICVGIP, pp. 722–729. IEEE, 2008.
|
| 208 |
+
Omkar M Parkhi, Andrea Vedaldi, Andrew Zisserman, and CV Jawahar. Cats and dogs. In CVPR, pp. 3498–3505. IEEE, 2012.
|
| 209 |
+
Rui Qian, Yeqing Li, Zheng Xu, Ming-Hsuan Yang, Serge Belongie, and Yin Cui. Multimodal open-vocabulary video classification via pre-trained vision and language models. arXiv preprint arXiv:2207.07646, 2022.
|
| 210 |
+
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, pp. 8748–8763. PMLR, 2021.
|
| 211 |
+
Benjamin Recht, Rebecca Roelofs, Ludwig Schmidt, and Vaishaal Shankar. Do imagenet classifiers generalize to imagenet? In ICML, pp. 5389–5400. PMLR, 2019.
|
| 212 |
+
Khurram Soomro, Amir Roshan Zamir, and Mubarak Shah. Ucf101: A dataset of 101 human actions classes from videos in the wild. arXiv preprint arXiv:1212.0402, 2012.
|
| 213 |
+
Ximeng Sun, Ping Hu, and Kate Saenko. Dualcoop: Fast adaptation to multi-label recognition with limited annotations. arXiv preprint arXiv:2206.09541, 2022.
|
| 214 |
+
Haohan Wang, Songwei Ge, Zachary Lipton, and Eric P Xing. Learning robust global representations by penalizing local predictive power. In NeurIPS, pp. 10506–10518, 2019.
|
| 215 |
+
Yongqin Xian, Bernt Schiele, and Zeynep Akata. Zero-shot learning-the good, the bad and the ugly. In CVPR, pp. 4582–4591, 2017.
|
| 216 |
+
Jianxiong Xiao, James Hays, Krista A Ehinger, Aude Oliva, and Antonio Torralba. Sun database: Large-scale scene recognition from abbey to zoo. In CVPR, pp. 3485–3492. IEEE, 2010.
|
| 217 |
+
Yinghui Xing, Qirui Wu, De Cheng, Shizhou Zhang, Guoqiang Liang, and Yanning Zhang. Class-aware visual prompt tuning for vision-language pre-trained model. arXiv preprint arXiv:2208.08340, 2022.
|
| 218 |
+
Yuan Yao, Ao Zhang, Zhengyan Zhang, Zhiyuan Liu, Tat-Seng Chua, and Maosong Sun. Cpt: Colorful prompt tuning for pre-trained vision-language models. arXiv preprint arXiv:2109.11797, 2021.
|
| 219 |
+
Yuhang Zang, Wei Li, Kaiyang Zhou, Chen Huang, and Chen Change Loy. Open-vocabulary detr with conditional matching. In ECCV, 2022.
|
| 220 |
+
Renrui Zhang, Ziyu Guo, Wei Zhang, Kunchang Li, Xupeng Miao, Bin Cui, Yu Qiao, Peng Gao, and Hongsheng Li. Pointclip: Point cloud understanding by clip. In CVPR, pp. 8552–8562, 2022a.
|
| 221 |
+
Yuanhan Zhang, Kaiyang Zhou, and Ziwei Liu. Neural prompt search. arXiv preprint arXiv:2206.04673, 2022b.
|
| 222 |
+
Kaiyang Zhou, Jingkang Yang, Chen Change Loy, and Ziwei Liu. Learning to prompt for visionlanguage models. International Journal of Computer Vision (IJCV), 2022a.
|
| 223 |
+
Kaiyang Zhou, Jingkang Yang, Chen Change Loy, and Ziwei Liu. Conditional prompt learning for vision-language models. In CVPR, 2022b.
|
| 224 |
+
Xingyi Zhou, Rohit Girdhar, Armand Joulin, Philipp Krahenb ¨ uhl, and Ishan Misra. Detecting ¨ twenty-thousand classes using image-level supervision. In ECCV, 2022c.
|
| 225 |
+
|
| 226 |
+
# Appendix
|
| 227 |
+
|
| 228 |
+
In the supplementary materials, we discuss the implementation details and more experimental results. Section A explains how we compute the intra-/inter- class variance for Fig.(1) of the main paper. Section B reports the implementation details of our paper. Section C presents more experimental results under the base-to-new generalization and cross-dataset transfer settings.
|
| 229 |
+
|
| 230 |
+
# A INTRA-/INTER- CLASS VARIANCE
|
| 231 |
+
|
| 232 |
+
In this section, we provide the implementation details about how we compute the intra-class visual variance and inter-class text variance for different datasets (Fig.1 (d)(e) in the main paper.
|
| 233 |
+
|
| 234 |
+
Intra-class Visual Variance. Given one dataset with $k$ classes in total, for each image $_ { \textbf { \em x } }$ that belongs to class $c$ , we first use the CLIP image encoder $\phi$ to extract the corresponding image feature $f _ { \phi } ( \bar { \pmb x ) }$ . Then we get the intra-class variance of class $c$ as:
|
| 235 |
+
|
| 236 |
+
$$
|
| 237 |
+
\mathsf { v a r } _ { c } = \frac { 1 } { \vert \vert X _ { c } \vert \vert } \sum _ { x \in X _ { c } } \left( f _ { \phi } ( \pmb { x } ) - \bar { f } _ { \phi } ( \pmb { x } ) \right) ^ { 2 } ,
|
| 238 |
+
$$
|
| 239 |
+
|
| 240 |
+
where $X _ { c }$ denotes to the set of images that have the ground-truth class label $c$ , and $\bar { f } _ { \phi } ( \pmb { x } )$ refers to the mean values of class $c$ . Then we can compute the intra-class variance $\operatorname { V a r } _ { \mathrm { v } }$ for all the $k$ classes as
|
| 241 |
+
|
| 242 |
+
$$
|
| 243 |
+
\mathrm { V a r } _ { \mathrm { v } } = { \frac { 1 } { k } } \sum _ { c = 1 } ^ { k } \mathrm { v a r } _ { c } .
|
| 244 |
+
$$
|
| 245 |
+
|
| 246 |
+
Inter-class Text Variance. For each dataset, we first compute the CLIP text features $\pmb { w }$ of classs $c$ , and the mean value $\bar { \pmb w }$ of all the $k$ classes. Then we get the inter-class text variance $\mathrm { V a r } _ { \mathrm { t } }$ as:
|
| 247 |
+
|
| 248 |
+
$$
|
| 249 |
+
\mathrm { V a r _ { t } } = { \frac { 1 } { k } } \sum _ { c = 1 } ^ { k } ( w _ { c } - { \bar { w } } ) ^ { 2 } .
|
| 250 |
+
$$
|
| 251 |
+
|
| 252 |
+
# B IMPLEMENTATION DETAILS
|
| 253 |
+
|
| 254 |
+
Our implementation is based on the source code of $\mathrm { C o O p }$ (Zhou et al., 2022a). We use ViT-B/16 as the CLIP backbone (Radford et al., 2021). Following (Zhou et al., 2022b), we set the context length of $\mathrm { C o O p }$ as $m = 4$ (same for VPT). For Zero-shot CLIP and VPT, we use the default prompt template, “a photo of a [CLS].” We use SGD as the optimizer, with an initial learning rate of 0.002, which is decayed by the cosine annealing rule. The batch size is set to 32 for all datasets.
|
| 255 |
+
|
| 256 |
+
# C MORE EXPERIMENTAL RESULTS
|
| 257 |
+
|
| 258 |
+
Recent work CoCoOp (Zhou et al., 2022b) points out that the text prompts learned by $\mathrm { C o O p }$ (Zhou et al., 2022a) are not generalizable to novel classes and out-of-distribution data. CoCoOp defines two new settings - base-to-new generalization and cross-dataset transfer - to measure the generalizability ability of prompt learning approaches. In this section, we provide the experimental results of our UPT in these two settings.
|
| 259 |
+
|
| 260 |
+
Datasets. We use the same 11 datasets we used in the few-shot learning setting (section 3.1 in the main paper). Following CoCoOp (Zhou et al., 2022b), we use the 16-shot protocol and report the averaged results over three runs, and set the training schedule as ten epochs. We report the accuracy on base and new classes, and the harmonic mean for base-to-novel trade-off.
|
| 261 |
+
|
| 262 |
+
# C.1 BASE-TO-NEW GENERALIZATION
|
| 263 |
+
|
| 264 |
+
In the base-to-new generalization setting, we split the classes into two disjoint groups - base classes and new classes. All the prompt learning approaches are required to train on the base classes, while evaluation is conducted on the base and new classes separately. The experimental results are shown in Table 3.
|
| 265 |
+
|
| 266 |
+
Table 3: Comparison results in the base-to-new generalization setting. H: Harmonic mean (Xian et al., 2017). The best and second best methods are highlighted in red and orange , respectively. The method ‘VPT-s’ refers to VPT-shallow.
|
| 267 |
+
|
| 268 |
+
<table><tr><td colspan="4">(a) Average over 11 datasets.</td><td colspan="4">(b) ImageNet.</td><td colspan="4">(c) Caltech101.</td></tr><tr><td></td><td>Base</td><td>New</td><td>H</td><td></td><td>Base</td><td>New</td><td>H</td><td></td><td>Base</td><td>New</td><td>H</td></tr><tr><td>CLIP</td><td>69.34</td><td>74.22</td><td>71.70</td><td>CLIP</td><td></td><td>72.43 68.14</td><td>70.22</td><td>CLIP</td><td></td><td>96.8494.00</td><td>95.40</td></tr><tr><td>CoOp</td><td>82.69</td><td>63.22</td><td>71.66</td><td>CoOp</td><td>76.47</td><td>67.88</td><td>71.92</td><td>CoOp</td><td>98.00</td><td>89.81</td><td>93.73</td></tr><tr><td>CoCoOp</td><td>80.47</td><td>71.69</td><td>75.83</td><td>CoCoOp</td><td>75.98</td><td>70.43</td><td>73.10</td><td>CoCoOp</td><td>97.96</td><td>93.81</td><td>95.84</td></tr><tr><td>VPT-s</td><td>73.32</td><td>73.21</td><td>73.16</td><td>VPT-s</td><td>74.47</td><td>69.13</td><td>71.70</td><td>VPT-s</td><td>97.47</td><td>93.80</td><td>95.60</td></tr><tr><td> VPT-deep</td><td>75.81</td><td>72.40</td><td>73.97</td><td>VPT-deep</td><td>75.80</td><td>68.76</td><td>72.11</td><td> VPT-deep</td><td>97.50</td><td>94.10</td><td>95.77</td></tr><tr><td>UPT</td><td>76.88</td><td></td><td>75.5776.15</td><td>UPT</td><td>75.83</td><td>70.8073.23</td><td></td><td>UPT</td><td>97.70</td><td></td><td>95.6396.14</td></tr><tr><td colspan="4">(d) OxfordPets.</td><td colspan="4">(e) StanfordCars.</td><td colspan="4">(f) Flowers102.</td></tr><tr><td></td><td>Base</td><td>New</td><td>H</td><td></td><td>Base</td><td>New</td><td>H</td><td></td><td>Base</td><td>New</td><td>H</td></tr><tr><td>CLIP</td><td>91.17</td><td>97.26</td><td>94.12</td><td>CLIP</td><td>63.37</td><td>74.89</td><td>68.65</td><td>CLIP</td><td>72.08</td><td>77.80</td><td>74.83</td></tr><tr><td>CoOp CoCoOp</td><td>93.67</td><td>95.29</td><td>94.47</td><td>CoOp</td><td>78.12</td><td>60.40</td><td>68.13</td><td>CoOp</td><td>97.60</td><td>59.67</td><td>74.06</td></tr><tr><td>VPT-s</td><td>95.20</td><td>97.69</td><td>96.43</td><td>CoCoOp</td><td>70.49</td><td>73.59</td><td>72.01</td><td>CoCoOp</td><td>94.87</td><td>71.75</td><td>81.71</td></tr><tr><td></td><td>93.90</td><td>96.87</td><td>95.36</td><td>VPT-s</td><td>66.00</td><td>74.23</td><td>69.88</td><td>VPT-s</td><td>75.83</td><td>75.73</td><td>75.78</td></tr><tr><td>VPT-deep</td><td>94.33 95.50</td><td></td><td>94.91</td><td>VPT-deep</td><td>69.23</td><td>74.03</td><td>71.55</td><td>VPT-deep</td><td>83.63</td><td>70.50</td><td>76.50</td></tr><tr><td>UPT</td><td colspan="3">96.07 97.6096.32</td><td>UPT</td><td>68.5075.37</td><td></td><td>71.77</td><td>UPT</td><td>85.00</td><td></td><td>77.3380.99</td></tr><tr><td></td><td colspan="3">(g) Food101.</td><td></td><td>(h) FGVCAircraft.</td><td></td><td></td><td></td><td>(i) SUN397.</td><td></td><td></td></tr><tr><td></td><td colspan="3">Base New</td><td>H</td><td>Base</td><td>New</td><td>H</td><td></td><td>Base</td><td>New</td><td>H</td></tr><tr><td>CLIP CoOp</td><td>90.10</td><td>91.22</td><td>90.66</td><td>CLIP</td><td>27.19</td><td>36.29</td><td>31.09</td><td>CLIP</td><td>69.36</td><td>75.35</td><td>72.23</td></tr><tr><td>CoCoOp</td><td>88.33</td><td>82.26</td><td>85.19</td><td>CoOp</td><td>40.44</td><td>22.30</td><td>28.75</td><td>CoOp</td><td>80.60</td><td>65.89</td><td>72.51</td></tr><tr><td>VPT-s</td><td>90.70</td><td>91.29</td><td>90.99</td><td>CoCoOp</td><td>33.41</td><td>23.71</td><td>27.74</td><td>CoCoOp</td><td>79.74</td><td>76.86</td><td>78.27</td></tr><tr><td></td><td>90.17</td><td>90.97</td><td>90.56</td><td>VPT-s</td><td>30.83</td><td>35.17</td><td>32.86</td><td>VPT-s</td><td>75.40</td><td>77.27</td><td>76.32</td></tr><tr><td>VPT-deep</td><td>90.20 91.17</td><td></td><td>90.68</td><td>VPT-deep</td><td>33.40</td><td>35.17</td><td>34.26</td><td>VPT-deep</td><td>78.23 76.63</td><td></td><td>77.43</td></tr><tr><td>UPT</td><td colspan="3">90.72 92.0091.35</td><td>UPT</td><td>32.76</td><td>36.10</td><td>34.53</td><td>UPT</td><td>78.90</td><td></td><td>78.5678.73</td></tr><tr><td></td><td colspan="3">() DTD.</td><td></td><td>(k) EuroSAT.</td><td></td><td></td><td></td><td>(l) UCF101.</td><td></td><td></td></tr><tr><td></td><td>Base</td><td>New</td><td>H</td><td></td><td>Base</td><td>New</td><td>H</td><td></td><td>Base</td><td>New</td><td>H</td></tr><tr><td>CLIP CoOp</td><td>53.24</td><td>59.90</td><td>56.37</td><td>CLIP</td><td>56.48</td><td>64.05</td><td>60.03</td><td>CLIP</td><td>70.53</td><td>77.50</td><td>73.85</td></tr><tr><td>CoCoOp</td><td>79.44</td><td>41.18</td><td>54.24</td><td>CoOp</td><td>92.19</td><td>54.74</td><td>68.69</td><td>CoOp</td><td>84.69</td><td>56.05</td><td>67.46</td></tr><tr><td>VPT-s</td><td>77.01</td><td>56.00</td><td>64.85</td><td>CoCoOp</td><td>87.49</td><td>60.04</td><td>71.21</td><td>CoCoOp</td><td>82.33</td><td>73.45</td><td>77.64</td></tr><tr><td>VPT-deep</td><td>55.27</td><td>57.16</td><td>56.20</td><td>VPT-s</td><td>71.67</td><td>58.87</td><td>64.64</td><td>VPT-s</td><td>75.60</td><td>76.10</td><td>75.85</td></tr><tr><td></td><td>64.87</td><td>55.40</td><td>59.76</td><td>VPT-deep</td><td>66.70</td><td>60.67</td><td>63.54</td><td> VPT-deep</td><td>80.07</td><td>74.50</td><td>77.18</td></tr><tr><td>UPT</td><td colspan="3">69.53 62.1365.63</td><td>UPT</td><td>73.57</td><td></td><td>70.4371.96</td><td>UPT</td><td>78.10</td><td></td><td>76.3377.21</td></tr></table>
|
| 269 |
+
|
| 270 |
+
Single-modal Baselines. We observe that previous single-modal baselines perform dramatically different on the base and new splits. In particular, the text prompt tuning method CoOp achieves the highest performance on base classes and poor performance on new classes. On the contrary, visual prompt tuning approaches VPT-shallow and VPT-deep obtain high accuracy on base classes, but low accuracy on new classes. Such results show the intrinsic discrepancy between single-modal text and visual prompt tuning methods. CoOp optimizes specifically for base classes but at the expense of generalization ability on new classes. The advanced text prompt tuning approach CoCoOp with the input-conditional design achieves the best base and new trade-off among the single-modal baselines.
|
| 271 |
+
|
| 272 |
+
Strong Generalizability of UPT. As shown in Table 3, UPT is more generalizable than baseline methods when taking into account both the base and new classes. As for base classes, UPT is better than VPT but worse than $\mathrm { C o O p }$ . This is reasonable because UPT are jointly optimized on the text and visual modalities, and the visual modality branch is not specifically for base classes. For new classes, UPT has significantly improved performance. For instance, UPT obtains $+ 1 2 . 3 5 / + 2 . 3 6 / + 3 . 1 7$ gains for CoOp/VPT-shallow/VPT-deep. UPT even achieves $+ 1 . 3 5$ gains on new classes compared with the CLIP baseline without prompt learning. In summary, the experimental results under the base-to-new generalization setting show strong generalizability of UPT.
|
| 273 |
+
|
| 274 |
+
Table 4: Comparison results in the cross-dataset transfer setting. Prompts applied to the 10 target datasets are learned from source ImageNet dataset. The best and second best methods are highlighted in red and orange , respectively.
|
| 275 |
+
|
| 276 |
+
<table><tr><td></td><td>Source</td><td colspan="10">Target</td></tr><tr><td></td><td>1enege</td><td>CErleeaer</td><td>DPPpprtet</td><td>srsrrretttes</td><td>TiroinG</td><td>JorPoon</td><td>FrTeiettt</td><td>160308</td><td>CII</td><td>JItoII</td><td>UUUIII</td><td>aneace</td></tr><tr><td>CoOp CoCoOp</td><td>71.51</td><td>93.70</td><td>89.14</td><td>64.51</td><td>68.71</td><td>85.30</td><td>18.47</td><td>64.15</td><td>41.92</td><td>46.39</td><td>66.55</td><td>63.88</td></tr><tr><td></td><td>71.02</td><td>94.43</td><td>90.14</td><td>65.32</td><td>71.88</td><td>86.06</td><td>22.94</td><td>67.36</td><td>45.73</td><td>45.37</td><td>68.21</td><td>65.74</td></tr><tr><td>VPT-shallow</td><td>68.98</td><td>93.07</td><td>89.63</td><td>63.63</td><td>70.50</td><td>85.03</td><td>24.01</td><td>66.30</td><td>45.13</td><td>45.56</td><td>66.80</td><td>65.33</td></tr><tr><td>VPT-deep</td><td>70.57</td><td>90.33</td><td>88.50</td><td>57.87</td><td>63.83</td><td>76.90</td><td>21.93</td><td>63.10</td><td>42.13</td><td>40.63</td><td>64.53</td><td>61.85</td></tr><tr><td>UPT</td><td>70.86</td><td>93.31</td><td></td><td></td><td></td><td>90.57 65.3372.33 86.17</td><td>24.57</td><td>67.66</td><td>45.67</td><td>44.94</td><td></td><td>68.23 65.85</td></tr></table>
|
| 277 |
+
|
| 278 |
+
# C.2 CROSS-DATASET TRANSFER
|
| 279 |
+
|
| 280 |
+
In the cross-dataset transfer setting, prompts learned from ImageNet are applied to ten other target datasets to evaluate the generalizability. The detailed results are presented in Table 4. We find VPT-shallow achieves higher accuracy than VPT-deep, and the text prompt tuning method CoCoOp outperforms visual prompt tuning approaches. On the source dataset, UPT obtains better performance than VPT but worse than CoOp. On target datasets, UPT obtains the best performance on six out of ten. The results on the cross-dataset transfer setting also verify that our proposed UPT is more generalizable than single-modal baselines.
|
md/dev/2PSrjVtj6gU/2PSrjVtj6gU.md
ADDED
|
@@ -0,0 +1,404 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# GRAPH ATTENTION MULTI-LAYER PERCEPTRON
|
| 2 |
+
|
| 3 |
+
Anonymous authors Paper under double-blind review
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
Recently, graph neural networks (GNNs) have achieved a stride of success in many graph-based applications. However, most GNNs suffer from a critical issue: representation learned is constructed based on a fixed $k$ -hop neighborhood and insensitive to individual needs for each node, which greatly hampers the performance of GNNs. To satisfy the unique needs of each node, we propose a new architecture – Graph Attention Multi-Layer Perceptron (GAMLP). This architecture combines multi-scale knowledge and learns to capture the underlying correlations between different scales of knowledge with two novel attention mechanisms: Recursive attention and Jumping Knowledge (JK) attention. Instead of using node feature only, the knowledge within node labels is also exploited to reinforce the performance of GAMLP. Extensive experiments on 12 real-world datasets demonstrate that GAMLP achieves state-of-the-art performance while enjoying high scalability and efficiency.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Graph Neural Networks (GNNs) generalize convolutional neural networks to graph-structured data and have achieved great success in a wide range of tasks, including node classification, link prediction, and recommendation. (Kipf & Welling, 2016; Hamilton et al., 2017; Bo et al., 2020; Cui et al., 2020; Fan et al., 2019). Through stacking $K$ graph convolution layers, GNNs learn node representations by utilizing information from the $K$ -hop neighborhood and thus enhance the performance by getting more unlabeled nodes involved in the training process. In such a GNN model, the nodes within the $K$ -hop neighborhood of a specific node are called this node’s Receptive Field (RF). As the size of RF grows exponentially to the number of GNN layers, the rapidly expanding RF incurs high computation and memory costs in a single machine. Besides, even in a distributed environment, GNN has to pull a great number of neighboring node features to compute the representation of each node, leading to high communication cost (Zheng et al., 2020).
|
| 12 |
+
|
| 13 |
+
Many recent advancements towards scalable GNNs are based on model simplification. For example, Simplified GCN (SGC) (Wu et al., 2019) decouples the feature propagation and the non-linear transformation process, and the former is executed during pre-processing. Unlike the sampling-based methods (Hamilton et al., 2017), which still need feature propagation during each training epoch, this time-consuming process in SGC is only executed once, and only the nodes of the training set are involved in the training process. As a result, SGC is computation and memory-efficient in a single machine and scalable in distributed settings since it does not require each machine to fetch neighboring node features during the model training process. Despite the high efficiency and scalability, SGC simply preserves a fixed RF for all the nodes by assigning them the same feature propagation depth. Such a fixed propagation mechanism in SGC disables its ability to exploit knowledge within neighborhoods of different sizes.
|
| 14 |
+
|
| 15 |
+
Lines of other simplified models have been proposed to learn better node representations exploiting multi-scale knowledge. SIGN (Frasca et al., 2020) proposes to concatenate all the propagated features without information loss, while $\mathrm { S ^ { 2 } G C }$ (Zhu & Koniusz, 2021) averages all these propagated features to generate the combined feature. Although multi-scale knowledge is considered, the importance and correlations between multiple scales are ignored. Being the first attempt to explore the correlations between different scales of knowledge, GBP (Chen et al., 2020b) adopts a heuristic constant decay factor for the weighted average for propagated features at different propagation steps. Motivated by Personalized PageRank, the large-scale features has a higher risk of over-smoothing, and they will contribute less to the combination in GBP.
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
Figure 1: (Left) Test accuracy of SGC on 20 randomly sampled nodes of Citeseer. The X-axis is the node id, and Y-axis is the propagation steps (layers). The color from white to blue represents the ratio of being predicted correctly in 50 different runs. (Right) The local graph structures for two nodes in different regions; the node in the dense region has larger RF within two iterations of propagation.
|
| 19 |
+
|
| 20 |
+
Unfortunately, the coarse-grained, layer-wise combination prevents these methods from unleashing their full potential. As shown in Figure 1(a), different nodes require different propagation steps to achieve optimal predictive accuracy. Besides, assigning the same weight distribution to propagated features along with propagation depth to all the nodes may be unsuitable due to the inconsistent RF expansion speed shown in Figure 1(b). However, nodes in most existing GNNs are restricted to a fixed-hop neighborhood and insensitive to the actual demands of different nodes. This imperfection either makes that long-range dependencies cannot be fully leveraged due to limited hops/layers or loses local information by introducing many irrelevant nodes into the receptive fields for many nodes when increasing the number of propagation depth (Chen et al., 2020a; Li et al., 2018; Xu et al., 2018).
|
| 21 |
+
|
| 22 |
+
The above observations motivate us to explicitly learn the importance and correlation of multiscale knowledge in a node-adaptive manner. To this end, we develop a new architecture – Graph Attention Multi-Layer Perceptron (GAMLP) – that could automatically exploit the knowledge over different neighborhoods at the granularity of nodes. GAMLP achieves this by introducing two novel attention mechanisms: Recursive attention and Jumping Knowledge (JK) attention. These two attention mechanisms can capture the complex correlations between propagated features at different propagation depths in a node-adaptive manner. Consequently, our architecture has the same benefits as the existing simplified and scalable GNN models while providing much better performance derived from its ability to utilizes a node-adaptive receptive field. Moreover, the proposed attention mechanisms can be applied to both node features and labels over neighborhoods with different sizes. By combining these two categories of information together, GAMLP could achieve the best of both worlds in terms of accuracy.
|
| 23 |
+
|
| 24 |
+
Our contributions are as follows: (1) New perspective. To the best of our knowledge, we are the first to explore both node-adaptive feature and label propagation schemes for scalable GNNs. (2) Novel method. We propose GAMLP, a scalable, efficient, and deep graph model. (3) State-of-the-art performance. Experimental results demonstrate that GAMLP achieves state-of-theart performance on 12 benchmark datasets while maintains high scalability and efficiency. In particular, GAMLP outperforms the competitive baseline GraphSAINT (Zeng et al., 2020) in terms of accuracy by a margin of $0 . 4 2 \%$ , $3 . 0 2 \%$ and $0 . 4 4 \%$ on PPI, Flickr, and Reddit datasets under the inductive setting, while achieving up to $4 5 \times$ training speedups in the large ogbn-products dataset. Remarkably, under the transductive setting in large OGB datasets, the accuracy of GAMLP exceeds the current state-of-the-art method by $1 . 0 { \bar { 3 } } \%$ and $\mathbf { \bar { 1 . 3 2 \% } }$ on the ogbn-products and ogbn-papers100M datasets, respectively.
|
| 25 |
+
|
| 26 |
+
# 2 PRELIMINARIES
|
| 27 |
+
|
| 28 |
+
# 2.1 PROBLEM FORMULATION
|
| 29 |
+
|
| 30 |
+
We consider an undirected graph $\mathcal { G } = ( \nu , \mathcal { E } )$ with $| \nu | = n$ nodes, $| { \mathcal { E } } | = m$ edges, and $c$ different node classes. We denote by $\mathbf { A }$ the adjacency matrix of $\mathcal { G }$ , weighted or not. Nodes can possibly have features vector of size $f$ , stacked up in an $n \times f$ matrix $\mathbf { X }$ $\mathbf { \bar { \Phi } } _ { \cdot } \mathbf { \bar { D } } = \operatorname { d i a g } \left( d _ { 1 } , d _ { 2 } , \cdot \cdot \cdot , \mathbf { \bar { \Phi } } _ { \cdot } d _ { N } \right) \in \mathbf { \bar { \Phi } } _ { \mathbb { R } ^ { n \times n } }$ denotes the degree matrix of $\mathbf { A }$ , where $\begin{array} { r } { d _ { i } = \sum _ { v _ { j } \in \mathcal { V } } \mathbf { A } _ { i j } } \end{array}$ is the degree of node $v _ { i }$ . Suppose $\mathcal { V } _ { l }$ is the labeled set, and our goal is to predict the labels for nodes in the unlabeled set $\nu _ { u }$ with the supervision of $\nu _ { l }$ .
|
| 31 |
+
|
| 32 |
+
# 2.2 SCALABLE GNNS
|
| 33 |
+
|
| 34 |
+
Sampling. A commonly used method to tackle the scalability issue (i.e., the recursive neighborhood expansion) in GNN is sampling. As a node-wise sampling method, GraphSAGE (Hamilton et al., 2017) randomly samples a fixed-size set of neighbors for computation in each mini-batch. VRGCN (Chen et al., 2018a) analyzes the variance reduction, and it reduces the size of samples with additional memory cost. For the layer-wise sampling, Fast-GCN (Chen et al., 2018b) samples a fixed number of nodes at each layer, and ASGCN (Huang et al., 2018) proposes the adaptive layer-wise sampling with better variance control. In the graph level, Cluster-GCN (Chiang et al., 2019) firstly clusters the nodes and then samples the nodes in the clusters, and GraphSAINT (Zeng et al., 2020) directly samples a subgraph for mini-batch training. Orthogonal to model simplification, sampling has already been widely used in many GNNs and GNN systems (Zheng et al., 2020; Zhu et al., 2019; Fey & Lenssen, 2019). However, these sampling-based GNNs are imperfect because they still face high communication costs, and the sampling quality highly influences the model performance.
|
| 35 |
+
|
| 36 |
+
Graph-wise Propagation. Recently studies have observed that non-linear feature transformation contributes little to the performance of the GNNs as compared to feature propagation. Thus, a new direction recently emerging for scalable GNN is based on the simplified GCN (SGC) (Wu et al., 2019), which successively removes nonlinearities and collapsing weight matrices between consecutive layers. This reduces GNNs into a linear model operating on $K$ -layers propagated features:
|
| 37 |
+
|
| 38 |
+
$$
|
| 39 |
+
\mathbf { X } ^ { ( K ) } = \hat { \mathbf { A } } ^ { K } \mathbf { X } ^ { ( 0 ) } , \qquad \mathbf { Y } = \mathrm { s o f t m a x } ( \Theta \mathbf { X } ^ { ( K ) } ) ,
|
| 40 |
+
$$
|
| 41 |
+
|
| 42 |
+
where $\mathbf { X } ^ { ( 0 ) } = \mathbf { X }$ , $\mathbf { X } ^ { ( K ) }$ is the $K$ -layers propagated feature, and $\hat { \mathbf { A } } = \widetilde { \mathbf { D } } ^ { r - 1 } \widetilde { \mathbf { A } } \widetilde { \mathbf { D } } ^ { - r }$ . By setting $r =$ 0.5, 1 and 0, $\hat { \bf A }$ represents the symmetric normalization adjacency matrix $\widetilde { \mathbf { D } } ^ { - 1 / 2 } \widetilde { \mathbf { A } } \widetilde { \mathbf { D } } ^ { - \mathrm { i } / 2 }$ (Klicpera et al., 2019), the transition probability matrix $\widetilde { \mathbf { A } } \widetilde { \mathbf { D } } ^ { - 1 }$ (Zeng et al., 2020), or the reverse transition probability matrix $\widetilde { \bf D } ^ { - 1 } \widetilde { \bf A }$ ( $\mathrm { X u }$ et al., 2018), respectively. As the propagated features $\mathbf { X } ^ { ( K ) }$ can be precomputed, SGC is more scalable and efficient for the large graph. However, such graph-wise propagation restricts the same propagation steps and a fixed RF for each node. Therefore, some nodes’ features may be over-smoothed or under-smoothed due to the inconsistent RF expansion speed, leading to non-optimal performance.
|
| 43 |
+
|
| 44 |
+
Layer-wise Propagation. Following SGC, some recent methods adopt layer-wise propagation to combine the features with different propagation layers. SIGN (Frasca et al., 2020) proposes to concatenate the propagated features at different propagation depth after simple linear transformation: $[ \mathbf { X } ^ { ( 0 ) } \mathbf { W } _ { 0 } , \mathbf { X } ^ { ( 1 ) } \mathbf { W } _ { 1 } , . . . , \mathbf { X } ^ { ( K ) } \mathbf { W } _ { K } ]$ . $\mathrm { { S ^ { 2 } G C } }$ (Zhu & Koniusz, 2021) proposes the simple spectral graph convolution to average the propagated features in different iterations as $\mathbf { X } ^ { ( K ) } = \sum _ { l = 0 } ^ { K } \hat { \mathbf { A } } ^ { l } \mathbf { X } ^ { ( 0 ) }$ . In addition, GBP (Chen et al., 2020b) further improves the combination process by weighted averaging $\mathbf { X } ^ { ( K ) } = \sum _ { l = 0 } ^ { K } w _ { l } \hat { \mathbf { A } } ^ { l } \mathbf { X } ^ { ( 0 ) }$ with the layer weight $w _ { l } = \beta { \left( 1 - \beta \right) } ^ { l }$ . Similar to these works, we also use a linear model for higher training scalability. The difference lies in that we consider the propagation process from a node-wise perspective and each node in GAMLP has a personalized combination of different steps of the propagated features.
|
| 45 |
+
|
| 46 |
+
# 2.3 LABEL UTILIZATION ON GNNS.
|
| 47 |
+
|
| 48 |
+
Labels of training nodes are conventionally only used as supervision signals in loss functions in most graph learning methods. However, there also exist some graph learning methods that directly exploit the labels of training nodes. Among them, the label propagation algorithm (Zhu & Ghahramani, 2002) is the most well-known one. It simply regards the partially observed label matrix $\mathbf { Y } \in \mathbb { R } ^ { N \times C }$ as input features for nodes in the graph and propagates the input features through the graph structure, where $C$ is the number of candidate classes. UniMP (Shi et al., 2020) proposes to map the partially observed label matrix $\mathbf { Y }$ to the dimension of the node feature matrix $\mathbf { X }$ and add these two matrices together as the new input feature. To fight against the label leakage problem, UniMP further randomly masks the training nodes during every training epoch.
|
| 49 |
+
|
| 50 |
+
Instead of using only the hard training labels, Correct & Smooth (Huang et al., 2020) first trains a simple model such as an MLP and gets this model’s predicted soft labels for unlabeled nodes. Then, it propagates the learning errors on the labeled nodes to connected nodes and smooths the output in a
|
| 51 |
+
|
| 52 |
+

|
| 53 |
+
Figure 2: Overview of the proposed GAMLP, including (1) feature and label propagation, (2) combine the propagated features and labels with RF attention, and (3) MLP training. Note that both the feature and label propagation can be pre-processed.
|
| 54 |
+
|
| 55 |
+
Personalized PageRank manner like APPNP (Klicpera et al., 2019). Besides, SLE (Sun & Wu, 2021) decouples the label utilization procedure in UniMP, and executes the propagation in advance. Unlike UniMP, “label reuse” (Wang et al., 2021) concatenates the partially observed label matrix $\mathbf { Y }$ with the node feature matrix $\mathbf { X }$ to form the new input matrix. Concretely, it fills the missing elements in the partially observed label matrix $\mathbf { Y }$ with the soft label predicted by the model, and this newly generated $\mathbf { Y } ^ { \prime }$ is again concatenated with $\mathbf { X }$ and then fed into the model to generate new predictions.
|
| 56 |
+
|
| 57 |
+
# 3 GRAPH ATTENTION MULTI-LAYER PERCEPTRON
|
| 58 |
+
|
| 59 |
+
# 3.1 ARCHITECTURE OVERVIEW
|
| 60 |
+
|
| 61 |
+
As shown in Fig. 2, GAMLP decomposes the end-to-end GNN training into three parts: feature and label propagation, feature and label combination with RF attention, and the MLP training. As the feature and label propagation is pre-processed only once, and MLP training is efficient and salable, we can easily scale GAMLP to large graphs. Besides, with the RF attention, each node in GAMLP can adaptively get the suitable combination weights for propagated features and labels under different receptive fields, thus boosting model performance.
|
| 62 |
+
|
| 63 |
+
# 3.2 NODE-WISE FEATURE AND LABEL PROPAGATION
|
| 64 |
+
|
| 65 |
+
Node-wise Feature Propagation. We separate the essential operation of GNNs — feature propagation by removing the neural network $\Theta$ and nonlinear activation $\delta$ for feature transformation. Specifically, we construct a parameter-free $K$ -step feature propagation as:
|
| 66 |
+
|
| 67 |
+
$$
|
| 68 |
+
\mathbf { X } ^ { ( k ) } \hat { \mathbf { A } } \mathbf { X } ^ { ( k - 1 ) } , \forall k = 1 , \ldots , K ,
|
| 69 |
+
$$
|
| 70 |
+
|
| 71 |
+
where $\mathbf { X } ^ { ( k ) }$ contains the features of a fixed RF: the node itself and its $k$ -hop neighborhoods.
|
| 72 |
+
|
| 73 |
+
After $K$ -step feature propagation shown in E.q. 2, we correspondingly get a list of propagated features under different propagation steps: $[ \mathbf { X } ^ { ( 0 ) } , \mathbf { X } ^ { ( 1 ) } , \mathbf { X } ^ { ( k ) } , . . . , \mathbf { X } ^ { ( K ) } ]$ . For a node-wise propagation, we propose to average these propagated features in a weighted manner:
|
| 74 |
+
|
| 75 |
+
$$
|
| 76 |
+
\mathbf { H } _ { \mathbf { X } } = \sum _ { k = 0 } ^ { K } \mathbf { W } _ { k } \mathbf { X } ^ { ( k ) } ,
|
| 77 |
+
$$
|
| 78 |
+
|
| 79 |
+
where $\mathbf { W } _ { k } = D i a g ( \eta _ { k } ) \in \mathbb { R } ^ { n \times n }$ is the diagonal matrix derived from vector $\eta _ { k }$ , and $\eta _ { k } \in \mathbb { R } ^ { n }$ is a vector derived from vector $\eta _ { k } [ i ] = w _ { i } ( k ) , 1 \le i \le n$ , and $w _ { i } ( k )$ measures the importance of the $k$ -step propagated feature for node $v _ { i }$ .
|
| 80 |
+
|
| 81 |
+
Node-wise Label Propagation. We use a scalable and node-adaptive way to take advantage of the node labels of the training set. Concretely, the label embedding matrix $\mathbf { Y } \in \mathbb { R } ^ { n \times c } ( \mathbf { Y } ^ { ( \bar { 0 } ) } )$ is propagated with the normalized adjacency matrix $\hat { \bf A }$ :
|
| 82 |
+
|
| 83 |
+
$$
|
| 84 |
+
\mathbf { Y } ^ { ( l ) } \hat { \mathbf { A } } \mathbf { Y } ^ { ( l - 1 ) } , \forall l = 1 , \dots , L ,
|
| 85 |
+
$$
|
| 86 |
+
|
| 87 |
+
After $L$ -step label propagation, we get a list of propagated labels under different propagation steps: $[ \mathbf { Y } ^ { ( 0 ) } , \mathbf { Y } ^ { ( 1 ) } , \mathbf { Y } ^ { ( 2 ) } , . . . , \mathbf { Y } ^ { ( L ) } ]$ . Generally, the propagated label $\mathbf { Y } ^ { ( l ) }$ is closer to the original label matrix $\mathbf { Y } ^ { ( 0 ) }$ with smaller propagation step $l$ , and thus face a higher risk of data leakage problem if it is directly used as the model input. We propose last residual connection to solve this problem.
|
| 88 |
+
|
| 89 |
+
Definition 3.1 (Last Residual Connection). Given the propagation step $l$ , and a list of propagated labels: $[ \mathbf { Y } ^ { ( 0 ) } , \dot { \mathbf { Y } } ^ { ( 1 ) } , \mathbf { Y } ^ { ( 2 ) } , . . . , \mathbf { Y } ^ { ( L ) } ]$ , we smooth each label $\dot { \mathbf { Y } } ^ { ( \tilde { l } ) }$ with the smoothed label ${ \bf Y } ^ { ( L ) }$ :
|
| 90 |
+
|
| 91 |
+
$$
|
| 92 |
+
\hat { \mathbf { Y } } ^ { ( l ) } \gets ( 1 - \alpha _ { l } ) \mathbf { Y } ^ { ( l ) } + \alpha _ { l } \mathbf { Y } ^ { ( L ) } , l = 1 , \dots , L ,
|
| 93 |
+
$$
|
| 94 |
+
|
| 95 |
+
where $\begin{array} { r } { \alpha _ { l } = \cos \left( \frac { \pi l } { 2 L } \right) } \end{array}$ controls the proportion of $\mathbf { Y } ^ { ( L ) }$ in the $l$ -step propagated label.
|
| 96 |
+
|
| 97 |
+
Similar to the node-wise feature propagation introduced in Sec. 3.2, we propose to average these propagated labels in a weighted manner:
|
| 98 |
+
|
| 99 |
+
$$
|
| 100 |
+
\mathbf { H } _ { \mathbf { Y } } = \sum _ { l = 0 } ^ { L } \hat { \mathbf { W } } _ { l } \hat { \mathbf { Y } } ^ { ( l ) } .
|
| 101 |
+
$$
|
| 102 |
+
|
| 103 |
+
# 3.3 NODE-ADAPTIVE ATTENTION MECHANISMS
|
| 104 |
+
|
| 105 |
+
To satisfy different RF requirements for each node, we introduce two RF attention mechanisms to get $w _ { i } ( k )$ . Note that these attention mechanisms can be used in both the feature and label propagation, and we introduce them from a feature perspective here. To apply them for node-wise label propagation, we only need to replace the feature $\mathbf { X } _ { i }$ in Eq. 7 and Eq. 8 with the label $\mathbf { Y } _ { i }$ .
|
| 106 |
+
|
| 107 |
+
Definition 3.2 (Recursive Attention). At each propagation step $l$ , suppose $s \in \mathbb { R } ^ { d }$ is a learnable parameter vector, we recursively measure the feature information gain compared with the previous combined feature as:
|
| 108 |
+
|
| 109 |
+
$$
|
| 110 |
+
\widetilde { \mathbf { X } } _ { i } ^ { ( l ) } = \mathbf { X } _ { i } ^ { ( l ) } \parallel \sum _ { k = 0 } ^ { l - 1 } w _ { i } ( k ) \mathbf { X } _ { i } ^ { ( k ) } , \quad \widetilde { w } _ { i } ( l ) = \delta ( \widetilde { \mathbf { X } } _ { i } ^ { ( l ) } \cdot s ) , \quad w _ { i } ( l ) = e ^ { \widetilde { w } _ { i } ( l ) } / \sum _ { k = 0 } ^ { K } e ^ { \widetilde { w } _ { i } ( k ) } .
|
| 111 |
+
$$
|
| 112 |
+
|
| 113 |
+
As Xe (l−1)i ∈ combines the graph information under different propagation steps and RF, large proportion of the information in $\widetilde { \mathbf { X } } _ { i } ^ { ( l ) }$ may have already existed in $\begin{array} { r } { \sum _ { k = 0 } ^ { l - 1 } w _ { i } ( k ) \mathbf { X } _ { i } ^ { ( k ) } } \end{array}$ , leading to small information gain. A larger $w _ { i } ( l )$ indicates the feature $\mathbf { X } _ { i } ^ { ( l ) }$ is more important to the current state of node $v _ { i }$ since combining $\widetilde { \mathbf X } _ { i } ^ { ( l ) }$ will introduce higher information gain.
|
| 114 |
+
|
| 115 |
+
Jumping Knowledge Network (JK-Net) (Xu et al., 2018) adopts layer aggregation to combine the node embeddings of different GCN layers, and thus it can leverage the propagated nodes’ information with different RF. Motivated by JK-Net, we propose to guide the feature combination process with the model prediction trained on all the propagated features. Concretely, GAMLP with JK attention includes two branches: the concatenated JK branch and the attention-based combination branch.
|
| 116 |
+
|
| 117 |
+
Definition 3.3 (JK Attention). Given the MLP prediction of the JK branch as $\mathbf { E } _ { i } = M L P ( \mathbf { X } _ { i } ^ { ( 1 ) } \mid \mid$ $\mathbf { X } _ { i } ^ { ( 2 ) } \parallel . . . \parallel \mathbf { X } _ { i } ^ { ( K ) } ) \in \mathbb { R } ^ { K f }$ , the combination weight is defined as:
|
| 118 |
+
|
| 119 |
+
$$
|
| 120 |
+
\widetilde { \mathbf { X } } _ { i } ^ { ( l ) } = \mathbf { X } _ { i } ^ { ( l ) } \parallel \mathbf { E } _ { i } , \quad \widetilde { w } _ { i } ( l ) = \delta ( \widetilde { \mathbf { X } } _ { i } ^ { ( l ) } \cdot s ) , \quad w _ { i } ( l ) = e ^ { \widetilde { w } _ { i } ( l ) } / \sum _ { k = 0 } ^ { K } e ^ { \widetilde { w } _ { i } ( k ) } .
|
| 121 |
+
$$
|
| 122 |
+
|
| 123 |
+
The JK branch aims to create a multi-scale feature representation for each node, which helps the attention mechanism learn the weight $w _ { i } ( k )$ . The learned weights are then fed into the attentionbased combination branch to generate each node’s refined attention feature representation. As the training process continues, the attention-based combination branch will gradually emphasize those neighborhood regions that are more helpful to the target nodes. The JK attention can model a wider neighborhood while enhancing correlations, bringing a better feature representation for each node.
|
| 124 |
+
|
| 125 |
+
# 3.4 MODEL TRAINING
|
| 126 |
+
|
| 127 |
+
Both the combined feature $\mathbf { H } _ { \mathbf { X } }$ and combined label $\mathbf { H } _ { \mathbf { Y } }$ are transformed with MLP, and then be added to get the final output embedding:
|
| 128 |
+
|
| 129 |
+
$$
|
| 130 |
+
\widetilde { \mathbf { H } } = \mathbf { M } \mathbf { L } \mathbf { P } ( \mathbf { H } _ { \mathbf { X } } ) + \beta \mathbf { M } \mathbf { L } \mathbf { P } ( \mathbf { H } _ { \mathbf { Y } } ) ,
|
| 131 |
+
$$
|
| 132 |
+
|
| 133 |
+
where $\beta$ is a hyper-parameter that measures the importance of the combined label. For example, some graphs have good features but low-quality labels (e.g., label noise or low label rate), and we should decrease $\beta$ so that more attention is paid to the graph features.
|
| 134 |
+
|
| 135 |
+
We adopt the Cross-Entropy (CE) measurement between the predicted softmax outputs and the one-hot ground-truth label distributions as the objective function:
|
| 136 |
+
|
| 137 |
+
$$
|
| 138 |
+
\mathcal { L } _ { C E } = - \sum _ { i \in \mathcal { V } _ { l } } \sum _ { j } \mathbf { Y } _ { i j } \log ( \mathrm { s o f t m a x } ( \widetilde { \mathbf { H } } ) _ { i j } ) ,
|
| 139 |
+
$$
|
| 140 |
+
|
| 141 |
+
where $\mathbf { Y } _ { i }$ is the one-hot label indicator vector.
|
| 142 |
+
|
| 143 |
+
# 3.5 PROPERTIES OF GAMLP
|
| 144 |
+
|
| 145 |
+
High Efficiency and Scalability. Compared with the previous GNNs (e.g., GCN and GraphSAGE), our proposed GAMLP only need to do the feature and label propagation only once. Suppose $P$ and $Q$ are the number of layers in MLP trained with feature and labels, and $k$ is the sampled nodes, the time complexity of GAMLP is $\mathcal { O } ( P n f ^ { 2 } + Q n c ^ { 2 } )$ , which is smaller than the complexity of GraphSAGE (i.e., $\mathcal { O } ( k ^ { \bar { K } _ { n } } f ^ { 2 } ) )$ . Besides, it also cost less memory than the sampling-based GNNs, and thus can scale to a larger graph in a single machine. Notably, like other simplified GNNs (i.e., SGC and SIGN), GAMLP can pre-compute the propagated features and labels only once. It doesn’t need to pull the intermediate representation of other nodes during the MLP training. Therefore, it can also be well adapted to the distributed environment. Further details can be found in Appendix A.3.
|
| 146 |
+
|
| 147 |
+
Deep propagation. With our recursive and JK attention, GAMLP can support large propagation depth without the over-smoothing issue since each node can get the node personalized combination weights for different propagated features and labels according to its demand. Such characteristic is essential for sparse graph, i.e., sparse labels, edges, and features. For example, a graph with a low label rate or edge rate can increase the propagation depth to spread the label supervision over the full graph. Each node can utilize the high-order graph structure information with deep propagation and then boost the node classification performance. Further details is in Appendix B.2.
|
| 148 |
+
|
| 149 |
+
# 3.6 RELATION WITH CURRENT METHODS
|
| 150 |
+
|
| 151 |
+
GAMLP vs. GBP. Both GAMLP and GBP propose to combine the propagated features under different propagation steps. However, GBP adopts a layer-wise propagation scheme and ignores the inconsistent receptive field expansion speed for different nodes. As the optimal propagation steps and smoothing levels of different nodes are different, some nodes may face the over-smoothing issue, even propagating the same step. GAMLP considers the feature and label propagation in a more fine-grained node perspective.
|
| 152 |
+
|
| 153 |
+
GAMLP vs. GAT. Each node in a GAT layer learns to weighted combine the embedding (or feature) of its neighborhoods with an attention mechanism, and the attention weights are measured by the local information in a fixed RF – the node itself and its direct neighbors. Different from the attention mechanism in GAT, GAMLP considers more global information under different RF.
|
| 154 |
+
|
| 155 |
+
GAMLP vs. JK-Net. Motivated by JK-Net, GAMLP with JK attention concatenate the propagated features under different propagation steps. However, the model prediction based on the concatenated feature is just used as a reference vector for the attention-based combination branch in GAMLP rather than the final results. Compared with JK-Net, GAMLP with JK attention is more effective in alleviating the over-smoothing and scalability issue that deep architecture introduces.
|
| 156 |
+
|
| 157 |
+
GAMLP vs. SAGN. SAGN also proposes to do node-specific propagation in GNN. Concretely, SAGN learns the node-specific attention weights with the original node feature. Unlike SAGN, GAMLP adopts two attention mechanisms to learn the interactions between the propagated features over different sizes of receptive fields. Besides, node-wise label propagation is also employed in GAMLP for better utilization of node labels.
|
| 158 |
+
|
| 159 |
+
# 4 EXPERIMENTS
|
| 160 |
+
|
| 161 |
+
In this section, we verify the effectiveness of GAMLP on 12 real-world graph datasets under both the transductive and inductive settings. We aim to answer the following four questions. Q1: Can GAMLP outperform the state-of-the-art GNN methods? Q2: If so, where does the performance gain of GAMLP come from? Q3: How about the efficiency of GAMLP compared with current GNN methods? Q4: How does GAMLP perform when applied to highly sparse graphs (i.e., given few edges and low label rate)? More experimental results about the heterogeneous graph, propagation depth and interpretability can be found in Appendix B.
|
| 162 |
+
|
| 163 |
+
Table 1: Performance comparison on seven transductive datasets.
|
| 164 |
+
|
| 165 |
+
<table><tr><td>Methods</td><td>Cora</td><td>Citeseer</td><td>PubMed</td><td>Amazon Computer</td><td>Amazon Photo</td><td>Coauthor CS</td><td>Coauthor Physics</td></tr><tr><td>GCN</td><td>81.8±0.5</td><td>70.8±0.5</td><td>79.3±0.7</td><td>82.4±0.4</td><td>91.2±0.6</td><td>90.7±0.2</td><td>92.7±1.1</td></tr><tr><td>GAT</td><td>83.0±0.7</td><td>72.5±0.7</td><td>79.0±0.3</td><td>80.1±0.6</td><td>90.8±1.0</td><td>87.4±0.2</td><td>90.2±1.4</td></tr><tr><td>JK-Net</td><td>81.8±0.5</td><td>70.7±0.7</td><td>78.8±0.7</td><td>82.0±0.6</td><td>91.9±0.7</td><td>89.5±0.6</td><td>92.5±0.4</td></tr><tr><td>ResGCN</td><td>82.2±0.6</td><td>70.8±0.7</td><td>78.3±0.6</td><td>81.1±0.7</td><td>91.3±0.9</td><td>87.9±0.6</td><td>92.2±1.5</td></tr><tr><td>APPNP</td><td>83.3±0.5</td><td>71.8±0.5</td><td>80.1±0.2</td><td>81.7±0.3</td><td>91.4±0.3</td><td>92.1±0.4</td><td>92.8±0.9</td></tr><tr><td>AP-GCN</td><td>83.4±0.3</td><td>71.3±0.5</td><td>79.7±0.3</td><td>83.7±0.6</td><td>92.1±0.3</td><td>91.6±0.7</td><td>93.1±0.9</td></tr><tr><td>SGC</td><td>81.0±0.2</td><td>71.3±0.5</td><td>78.9±0.5</td><td>82.2±0.9</td><td>91.6±0.7</td><td>90.3±0.5</td><td>91.7±1.1</td></tr><tr><td>SIGN</td><td>82.1±0.3</td><td>72.4±0.8</td><td>79.5±0.5</td><td>83.1±0.8</td><td>91.7±0.7</td><td>91.9±0.3</td><td>92.8±0.8</td></tr><tr><td>S²GC</td><td>82.7±0.3</td><td>73.0±0.2</td><td>79.9±0.3</td><td>83.1±0.7</td><td>91.6±0.6</td><td>91.6±0.6</td><td>93.1±0.8</td></tr><tr><td>GBP</td><td>83.9±0.7</td><td>72.9±0.5</td><td>80.6±0.4</td><td>83.5±0.8</td><td>92.1±0.8</td><td>92.3±0.4</td><td>93.3±0.7</td></tr><tr><td>UNIMP</td><td>82.6±0.4</td><td>72.5±0.9</td><td>80.1±0.5</td><td>83.9±0.8</td><td>92.0±1.1</td><td>92.4±0.3</td><td>93.5±0.8</td></tr><tr><td>GAMLP(JK)</td><td>84.3±0.8</td><td>74.6±0.4</td><td>80.7±0.4</td><td>84.5±0.7</td><td>92.8±0.7</td><td>92.6±0.5</td><td>93.6±1.0</td></tr><tr><td>GAMLP(R)</td><td>83.9±0.6</td><td>73.9±0.6</td><td>80.8±0.5</td><td>84.2±0.5</td><td>92.6±0.8</td><td>92.8±0.7</td><td>93.2±1.0</td></tr></table>
|
| 166 |
+
|
| 167 |
+
# 4.1 EXPERIMENTAL SETUP
|
| 168 |
+
|
| 169 |
+
Datasets. We evaluate the predictive accuracy of GAMLP under both transductive and inductive settings. For transductive settings, we conduct experiments on nine transductive datasets: three citation network datasets (Cora, Citeseer, PubMed) (Sen et al., 2008), two user-item datasets (Amazon Computer, Amazon Photo), two co-author datasets (Coauthor CS, Coauthor Physics) (Shchur et al., 2018), and two OGB datasets (ogbn-products, ogbn-papers100M) (Hu et al., 2021). For inductive settings, we perform the comparison experiments on three inductive datasets: PPI, Flickr, and Reddit (Zeng et al., 2019). The statistics about these datasets can be found in Table 10 in Appendix C.1.
|
| 170 |
+
|
| 171 |
+
Baselines. Under the transductive setting, we compare GAMLP with the following representative baseline methods: GCN (Kipf & Welling, 2016), GAT (Velickovi ˇ c et al., 2017), JK-Net (Xu et al., ´ 2018), ResGCN (Li et al., 2019), APPNP (Klicpera et al., 2018), AP-GCN (Spinelli et al., 2020), SGC (Wu et al., 2019), SIGN (Frasca et al., 2020), $\mathrm { { S ^ { 2 } G C } }$ (Zhu & Koniusz, 2021), and GBP (Chen et al., 2020b). For the comparison in the OGB datasets, we choose the top-performing methods from the OGB leaderboard along with their accuracy results. Under the inductive setting, we choose following representative methods: SGC (Wu et al., 2019), GraphSAGE (Hamilton et al., 2017), Cluster-GCN (Chiang et al., 2019), and GraphSAINT (Zeng et al., 2019).
|
| 172 |
+
|
| 173 |
+
In addition, two variants of GAMLP are tested in the evaluation: GAMLP(JK) and GAMLP(R). “JK” and “R” stand for adopting “JK attention” and “Recursive attention” for the node-adaptive attention mechanism, respectively.
|
| 174 |
+
|
| 175 |
+
Table 2: Performance comparison on the ogbnproducts dataset.
|
| 176 |
+
|
| 177 |
+
<table><tr><td>Methods</td><td>Val Accuracy</td><td>Test Accuracy</td></tr><tr><td>GCN</td><td>92.00±0.03</td><td>75.64±0.21</td></tr><tr><td>SGC</td><td>92.13±0.02</td><td>75.87±0.14</td></tr><tr><td>GraphSAGE</td><td>92.24±0.07</td><td>78.50±0.14</td></tr><tr><td>GraphSAINT</td><td>92.52±0.13</td><td>80.27±0.26</td></tr><tr><td>GBP</td><td>92.82±0.10</td><td>80.48±0.05</td></tr><tr><td>SIGN</td><td>92.99±0.04</td><td>80.52±0.16</td></tr><tr><td>DeeperGCN</td><td>92.38±0.09</td><td>80.98±0.20</td></tr><tr><td>UniMP</td><td>93.08±0.17</td><td>82.56±0.31</td></tr><tr><td>SAGN</td><td>93.09±0.04</td><td>81.20±0.07</td></tr><tr><td>SAGN+0-SLE</td><td>93.27±0.04</td><td>83.29±0.18</td></tr><tr><td>GAMLP(JK)</td><td>93.19±0.03</td><td>83.54±0.25</td></tr><tr><td>GAMLP(R)</td><td>93.11±0.05</td><td>83.59±0.09</td></tr></table>
|
| 178 |
+
|
| 179 |
+
Table 3: Performance comparison on the ogbnpapers100M dataset.
|
| 180 |
+
|
| 181 |
+
<table><tr><td>Methods</td><td>Val Accuracy</td><td>Test Accuracy</td></tr><tr><td>SGC</td><td>66.48±0.20</td><td>63.29±0.19</td></tr><tr><td>SIGN</td><td>69.32±0.06</td><td>65.68±0.06</td></tr><tr><td>SIGN-XL</td><td>69.84±0.06</td><td>66.06±0.19</td></tr><tr><td>SAGN</td><td>70.34±0.99</td><td>66.75±0.84</td></tr><tr><td>SAGN+0-SLE</td><td>71.06±0.08</td><td>67.55±0.15</td></tr><tr><td>GAMLP(JK)</td><td>71.92±0.04</td><td>68.07±0.10</td></tr><tr><td>GAMLP(R)</td><td>71.21±0.03</td><td>67.46±0.02</td></tr></table>
|
| 182 |
+
|
| 183 |
+
Table 4: Performance comparison on three inductive datasets.
|
| 184 |
+
|
| 185 |
+
<table><tr><td>Methods</td><td>PPI</td><td>Flickr</td><td>Reddit</td></tr><tr><td>SGC</td><td>65.7±0.01</td><td>50.2±0.12</td><td>94.9±0.00</td></tr><tr><td>GraphSAGE</td><td>61.2±0.05</td><td>50.1±0.13</td><td>95.4±0.01</td></tr><tr><td>Cluster-GCN</td><td>99.2±0.04</td><td>48.1±0.05</td><td>95.7±0.00</td></tr><tr><td>GraphSAINT</td><td>99.4±0.03</td><td>51.1±0.10</td><td>96.6±0.01</td></tr><tr><td>GAMLP(JK)</td><td>99.82±0.01</td><td>54.12±0.01</td><td>97.04±0.01</td></tr><tr><td>GAMLP(R)</td><td>99.66±0.01</td><td>53.12±0.00</td><td>96.62±0.01</td></tr></table>
|
| 186 |
+
|
| 187 |
+
# 4.2 END-TO-END COMPARISON
|
| 188 |
+
|
| 189 |
+
Transductive Performance. To answer Q1, we report the transductive performance of GAMLP in Tables 1, 2, and 3. We observe that both variants of GAMLP outperform all the baseline methods on almost all the datasets. For example, on the small Citeseer dataset, GAMLP(JK) outperforms the state-of-the-art method $\mathrm { { S ^ { 2 } G C } }$ by a large margin of $1 . 6 \%$ ; on the medium-sized dataset Amazon Computers, the predictive accuracy of GAMLP (JK) exceeds the one of the state-of-the-art method GBP by $1 . 0 \%$ ; on the two large OGB datasets, GAMLP takes the lead by $1 . 0 3 \%$ and $1 . 3 2 \%$ on ogbn-products and ogbn-papers100M, respectively. Furthermore, the experimental results illustrate that the contest between the two variants of GAMLP is not a one-horse race, which suggests that these two different attention mechanisms both have their irreplaceable sense in some ways.
|
| 190 |
+
|
| 191 |
+
Inductive Performance. We also evaluate GAMLP under the inductive setting. The experiment results in Table 4 show that GAMLP consistently outperforms all the baseline methods. The leading advantage of GAMLP(JK) over SOTA inductive method – GraphSAINT is more than $3 . 0 \%$ on the widely-used dataset – Filckr. The impressive performance of GAMLP under the inductive setting illustrates that GAMLP is alpowerful in predicting the properties of unseen nodes.
|
| 192 |
+
|
| 193 |
+
Table 5: Ablation study on label utilization.
|
| 194 |
+
|
| 195 |
+
<table><tr><td>Methods</td><td>Val Accuracy</td><td>Test Accuracy</td></tr><tr><td>GAMLP(R)</td><td>93.11±0.05</td><td>83.59±0.05</td></tr><tr><td>-no_label</td><td>92.29±0.06</td><td>81.43±0.18</td></tr><tr><td>-plain_label</td><td>92.53±0.21</td><td>81.12±0.45</td></tr><tr><td>-uniform</td><td>92.72±0.15</td><td>81.28±0.93</td></tr></table>
|
| 196 |
+
|
| 197 |
+
Table 6: Ablation study on reference vector.
|
| 198 |
+
|
| 199 |
+
<table><tr><td>Methods</td><td>Val Accuracy</td><td>Test Accuracy</td></tr><tr><td>GAMLP(JK)</td><td>82.5±0.5</td><td>80.7±0.4</td></tr><tr><td>-origin_feature</td><td>82.2±0.4</td><td>80.5±0.4</td></tr><tr><td>-normal_noise</td><td>81.8±0.4</td><td>79.8±0.5</td></tr><tr><td>-no_reference</td><td>81.5±0.5</td><td>79.9±0.3</td></tr></table>
|
| 200 |
+
|
| 201 |
+
# 4.3 ABLATION STUDY
|
| 202 |
+
|
| 203 |
+
To answer Q2, we focus on two modules in GAMLP: (1) label utilization; (2) attention mechanism in the node-wise propagation. For the second one, we evaluate the effects of different choices for reference vectors in the JK attention.
|
| 204 |
+
|
| 205 |
+
Label Utilization. In this part, we evaluate whether adding last residual connection and making use of training labels really help or not. The predictive accuracy of GAMLP(R) is evaluated on the ogbn-products dataset along with its three variants: “-no_label”, “-plain_label”, and “-uniform”, which stands for not using labels, removing last residual connections, and replacing last residual connections with uniform distributions, respectively. The experimental results in Table 5 show that utilizing labels brings huge performance gain to GAMLP: from $8 1 . 4 3 \%$ to $8 3 . 5 9 \%$ . The performance drop from removing the last residual connections (“-plain_label” in Table 5) is significant since directly adopting the raw training labels leads to the overfitting issue. The fact that “-uniform” performs worse than “-no_label” illustrates that intuitively fusing the original label distribution with the uniform distribution would harm the predictive accuracy. It further demonstrates the effectiveness of our proposed last residual connections.
|
| 206 |
+
|
| 207 |
+
Reference Vector in Attention Mechanism. In this part, we study the role of the reference vector (originally set as the concatenated features from different propagation steps) in our proposed JK attention. We evaluate the three variants of GAMLP(JK): “-origin_feature”, “-normal_noise”, and “-no_reference”, which changes the reference vector to the original node feature, noise from the normal distribution, and nothing, respectively. The predictive accuracy of each variant on the PubMed dataset is reported in Table 6. The experimental results show that our original choice of the reference vector is the best among itself and its three variants. The superiority of the concatenated features from different propagation steps comes from the fact that it allows the model to capture the interactions between the propagated features over the receptive fields with different sizes.
|
| 208 |
+
|
| 209 |
+
Table 7: Efficiency comparison on the ogbn-products dataset.
|
| 210 |
+
|
| 211 |
+
<table><tr><td>Methods</td><td>SGC</td><td>SIGN</td><td>GAMLP(JK)</td><td>GAMLP(R)</td><td>GraphSAINT</td><td>Cluster-GCN</td></tr><tr><td>Training time</td><td>1.0</td><td>4.0</td><td>8.0</td><td>9.3</td><td>364</td><td>503</td></tr><tr><td>Test accuracy</td><td>75.87</td><td>80.52</td><td>83.54</td><td>83.59</td><td>79.08</td><td>78.97</td></tr></table>
|
| 212 |
+
|
| 213 |
+

|
| 214 |
+
Figure 3: Test accuracy on PubMed dataset under different levels of label and edge sparsity.
|
| 215 |
+
|
| 216 |
+
# 4.4 EFFICIENCY COMPARISON
|
| 217 |
+
|
| 218 |
+
To answer Q3, we evaluate the efficiency of each method on the ogbn-products dataset. We compare the efficiency of GAMLP with sampling-based GraphSAINT and Cluster-GCN, graph-wisepropagation-based SGC, and layer-wise-propagation-based SIGN. Table 7 illustrates the relative training time of each compared method along with its predictive accuracy. The training time of SGC is set to 1 as reference. We observe that (1) sampling-based methods (e.g., GraphSAINT) consume much more time than graph/layer-wise-propagation based methods (e.g., SGC, SIGN) due to the high computation cost introduced by the sampling process; (2) the two variants of GAMLP achieve the best predictive accuracy while requiring comparable training time with SGC.
|
| 219 |
+
|
| 220 |
+
# 4.5 EXPERIMENTS ON SPARSE GRAPHS
|
| 221 |
+
|
| 222 |
+
To answer Q4, we conduct experiments to evaluate the predictive accuracy of GAMLP when faced with edge and label sparsity problems, where the number of edges and training labels are highly scarce. We randomly remove a fixed percentage of edges from the original graph to simulate the edge sparsity problem. The removed edges are exactly the same for all the compared methods. Besides, we enumerate the number of training nodes per class from 1 to 20 to evaluate the performance of GAMLP given different levels of label sparsity. The experimental results in Figure 3 show that GAMLP consistently outperforms all the baselines when faced with different levels of edge and label sparsity. This experiment further demonstrates the effectiveness of our proposed node-wise propagation scheme. The node-wise propagation enables GAMLP to better capture long-range dependencies, which is crucial when applying GNN methods to highly sparse graphs.
|
| 223 |
+
|
| 224 |
+
# 5 CONCLUSION
|
| 225 |
+
|
| 226 |
+
We presented Graph Attention Multilayer Perceptron (GAMLP), a scalable, efficient, and deep graph model based on receptive field attention. GAMLP introduced two new attention mechanisms: recursive attention and JK attention, which enables to learn the representations over RF with different sizes in a node-adaptive manner. Extensive experiments on 12 graph datasets verified the effectiveness of the proposed method. GAMLP moves forward the performance boundary of scalable GNNs, especially on large-scale graphs. This initial attempt also motivates several interesting future directions: (1) exploring other attention mechanisms and (2) studying the mechanisms on heterogeneous graphs.
|
| 227 |
+
|
| 228 |
+
# 6 REPRODUCIBILITY STATEMENT
|
| 229 |
+
|
| 230 |
+
The source code of GAMLP can be found in Anonymous Github (https://anonymous.4open. science/r/ICLR-GAMLP). To ensure reproducibility, we have provided the overview of datasets and baselines in Section 4.1 and Table 10 in Appendix C.1. The detailed hyperparameter settings for our GAMLP can be found in Appendix C.2. Our experimental environment is presented in Appendix C.1, and please refer to “README.md” in the Github repository for more details.
|
| 231 |
+
|
| 232 |
+
# REFERENCES
|
| 233 |
+
|
| 234 |
+
Deyu Bo, Xiao Wang, Chuan Shi, Meiqi Zhu, Emiao Lu, and Peng Cui. Structural deep clustering network. In Proceedings of The Web Conference 2020, pp. 1400–1410, 2020.
|
| 235 |
+
|
| 236 |
+
Deli Chen, Yankai Lin, Wei Li, Peng Li, Jie Zhou, and Xu Sun. Measuring and relieving the oversmoothing problem for graph neural networks from the topological view. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pp. 3438–3445, 2020a.
|
| 237 |
+
|
| 238 |
+
Jianfei Chen, Jun Zhu, and Le Song. Stochastic training of graph convolutional networks with variance reduction. In Proceedings of the 35th International Conference on Machine Learning, ICML 2018, Stockholmsmässan, Stockholm, Sweden, July 10-15, 2018, pp. 941–949, 2018a.
|
| 239 |
+
|
| 240 |
+
Jie Chen, Tengfei Ma, and Cao Xiao. Fastgcn: Fast learning with graph convolutional networks via importance sampling. In 6th International Conference on Learning Representations, ICLR 2018, Vancouver, BC, Canada, April 30 - May 3, 2018, Conference Track Proceedings, 2018b.
|
| 241 |
+
|
| 242 |
+
Ming Chen, Zhewei Wei, Bolin Ding, Yaliang Li, Ye Yuan, Xiaoyong Du, and Ji-Rong Wen. Scalable graph neural networks via bidirectional propagation. arXiv preprint arXiv:2010.15421, 2020b.
|
| 243 |
+
|
| 244 |
+
Wei-Lin Chiang, Xuanqing Liu, Si Si, Yang Li, Samy Bengio, and Cho-Jui Hsieh. Cluster-gcn: An efficient algorithm for training deep and large graph convolutional networks. In SIGKDD, pp. 257–266, 2019.
|
| 245 |
+
|
| 246 |
+
Ganqu Cui, Jie Zhou, Cheng Yang, and Zhiyuan Liu. Adaptive graph encoder for attributed graph embedding. In SIGKDD, pp. 976–985, 2020.
|
| 247 |
+
|
| 248 |
+
Wenqi Fan, Yao Ma, Qing Li, Yuan He, Eric Zhao, Jiliang Tang, and Dawei Yin. Graph neural networks for social recommendation. In The World Wide Web Conference, pp. 417–426, 2019.
|
| 249 |
+
|
| 250 |
+
Matthias Fey and Jan E. Lenssen. Fast graph representation learning with PyTorch Geometric. In ICLR 2019 Workshop on Representation Learning on Graphs and Manifolds, 2019. URL https://arxiv.org/abs/1903.02428.
|
| 251 |
+
|
| 252 |
+
Fabrizio Frasca, Emanuele Rossi, Davide Eynard, Ben Chamberlain, Michael Bronstein, and Federico Monti. Sign: Scalable inception graph neural networks. arXiv preprint arXiv:2004.11198, 2020.
|
| 253 |
+
|
| 254 |
+
William L Hamilton, Rex Ying, and Jure Leskovec. Inductive representation learning on large graphs. In NeurIPS, pp. 1025–1035, 2017.
|
| 255 |
+
|
| 256 |
+
Weihua Hu, Matthias Fey, Hongyu Ren, Maho Nakata, Yuxiao Dong, and Jure Leskovec. Ogb-lsc: A large-scale challenge for machine learning on graphs. arXiv preprint arXiv:2103.09430, 2021.
|
| 257 |
+
|
| 258 |
+
Ziniu Hu, Yuxiao Dong, Kuansan Wang, and Yizhou Sun. Heterogeneous graph transformer. In Proceedings of The Web Conference 2020, pp. 2704–2710, 2020.
|
| 259 |
+
|
| 260 |
+
Qian Huang, Horace He, Abhay Singh, Ser-Nam Lim, and Austin R Benson. Combining label propagation and simple models out-performs graph neural networks. arXiv preprint arXiv:2010.13993, 2020.
|
| 261 |
+
|
| 262 |
+
Wen-bing Huang, Tong Zhang, Yu Rong, and Junzhou Huang. Adaptive sampling towards fast graph representation learning. In Advances in Neural Information Processing Systems 31: Annual Conference on Neural Information Processing Systems 2018, NeurIPS 2018, December 3-8, 2018, Montréal, Canada, pp. 4563–4572, 2018.
|
| 263 |
+
|
| 264 |
+
Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. arXiv preprint arXiv:1609.02907, 2016.
|
| 265 |
+
|
| 266 |
+
Johannes Klicpera, Aleksandar Bojchevski, and Stephan Günnemann. Predict then propagate: Graph neural networks meet personalized pagerank. arXiv preprint arXiv:1810.05997, 2018.
|
| 267 |
+
|
| 268 |
+
Johannes Klicpera, Aleksandar Bojchevski, and Stephan Günnemann. Predict then propagate: Graph neural networks meet personalized pagerank. In 7th International Conference on Learning Representations, ICLR 2019, New Orleans, LA, USA, May 6-9, 2019, 2019.
|
| 269 |
+
|
| 270 |
+
Guohao Li, Matthias Muller, Ali Thabet, and Bernard Ghanem. Deepgcns: Can gcns go as deep as cnns? In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 9267–9276, 2019.
|
| 271 |
+
|
| 272 |
+
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, volume 32, 2018.
|
| 273 |
+
|
| 274 |
+
Michael Schlichtkrull, Thomas N Kipf, Peter Bloem, Rianne Van Den Berg, Ivan Titov, and Max Welling. Modeling relational data with graph convolutional networks. In European semantic web conference, pp. 593–607. Springer, 2018.
|
| 275 |
+
|
| 276 |
+
Prithviraj Sen, Galileo Namata, Mustafa Bilgic, Lise Getoor, Brian Gallagher, and Tina Eliassi-Rad. Collective classification in network data. AI Mag., 29(3):93–106, 2008.
|
| 277 |
+
|
| 278 |
+
Oleksandr Shchur, Maximilian Mumme, Aleksandar Bojchevski, and Stephan Günnemann. Pitfalls of graph neural network evaluation. arXiv preprint arXiv:1811.05868, 2018.
|
| 279 |
+
|
| 280 |
+
Yunsheng Shi, Zhengjie Huang, Wenjin Wang, Hui Zhong, Shikun Feng, and Yu Sun. Masked label prediction: Unified message passing model for semi-supervised classification. arXiv preprint arXiv:2009.03509, 2020.
|
| 281 |
+
|
| 282 |
+
Indro Spinelli, Simone Scardapane, and Aurelio Uncini. Adaptive propagation graph convolutional network. IEEE Transactions on Neural Networks and Learning Systems, 2020.
|
| 283 |
+
|
| 284 |
+
Chuxiong Sun and Guoshi Wu. Scalable and adaptive graph neural networks with self-label-enhanced training. arXiv preprint arXiv:2104.09376, 2021.
|
| 285 |
+
|
| 286 |
+
Théo Trouillon, Christopher R Dance, Johannes Welbl, Sebastian Riedel, Éric Gaussier, and Guillaume Bouchard. Knowledge graph completion via complex tensor factorization. arXiv preprint arXiv:1702.06879, 2017.
|
| 287 |
+
|
| 288 |
+
Petar Velickovi ˇ c, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Lio, and Yoshua ´ Bengio. Graph attention networks. arXiv preprint arXiv:1710.10903, 2017.
|
| 289 |
+
|
| 290 |
+
Yangkun Wang, Jiarui Jin, Weinan Zhang, Yong Yu, Zheng Zhang, and David Wipf. Bag of tricks for node classification with graph neural networks. arXiv preprint arXiv:2103.13355, 2021.
|
| 291 |
+
|
| 292 |
+
Felix Wu, Tianyi Zhang, Amauri Holanda de Souza Jr, Christopher Fifty, Tao Yu, and Kilian Q Weinberger. Simplifying graph convolutional networks. arXiv preprint arXiv:1902.07153, 2019.
|
| 293 |
+
|
| 294 |
+
Xinliang Wu, Mengying Jiang, and Guizhong Liu. R-gsn: The relation-based graph similar network for heterogeneous graph. arXiv preprint arXiv:2103.07877, 2021.
|
| 295 |
+
|
| 296 |
+
Keyulu Xu, Chengtao Li, Yonglong Tian, Tomohiro Sonobe, Ken-ichi Kawarabayashi, and Stefanie Jegelka. Representation learning on graphs with jumping knowledge networks. In ICML, pp. 5453–5462. PMLR, 2018.
|
| 297 |
+
|
| 298 |
+
Le Yu, Leilei Sun, Bowen Du, Chuanren Liu, Weifeng Lv, and Hui Xiong. Hybrid micro/macro level convolution for heterogeneous graph learning. arXiv preprint arXiv:2012.14722, 2020a.
|
| 299 |
+
|
| 300 |
+
Le Yu, Leilei Sun, Bowen Du, Chuanren Liu, Weifeng Lv, and Hui Xiong. Heterogeneous graph representation learning with relation awareness. arXiv preprint arXiv:2105.11122, 2021.
|
| 301 |
+
|
| 302 |
+
Lingfan Yu, Jiajun Shen, Jinyang Li, and Adam Lerer. Scalable graph neural networks for heterogeneous graphs. arXiv preprint arXiv:2011.09679, 2020b.
|
| 303 |
+
|
| 304 |
+
Hanqing Zeng, Hongkuan Zhou, Ajitesh Srivastava, Rajgopal Kannan, and Viktor Prasanna. Graphsaint: Graph sampling based inductive learning method. In ICLR, 2019.
|
| 305 |
+
|
| 306 |
+
Hanqing Zeng, Hongkuan Zhou, Ajitesh Srivastava, Rajgopal Kannan, and Viktor K. Prasanna. Graphsaint: Graph sampling based inductive learning method. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020, 2020.
|
| 307 |
+
|
| 308 |
+
Da Zheng, Chao Ma, Minjie Wang, Jinjing Zhou, Qidong Su, Xiang Song, Quan Gan, Zheng Zhang, and George Karypis. Distdgl: Distributed graph neural network training for billion-scale graphs. In 10th IEEE/ACM Workshop on Irregular Applications: Architectures and Algorithms, IA3 2020, Atlanta, GA, USA, November 11, 2020, pp. 36–44. IEEE, 2020.
|
| 309 |
+
|
| 310 |
+
Hao Zhu and Piotr Koniusz. Simple spectral graph convolution. In International Conference on Learning Representations, 2021.
|
| 311 |
+
|
| 312 |
+
Rong Zhu, Kun Zhao, Hongxia Yang, Wei Lin, Chang Zhou, Baole Ai, Yong Li, and Jingren Zhou. Aligraph: A comprehensive graph neural network platform. Proc. VLDB Endow., 12(12): 2094–2105, August 2019. ISSN 2150-8097. doi: 10.14778/3352063.3352127. URL https: //doi.org/10.14778/3352063.3352127.
|
| 313 |
+
|
| 314 |
+
Xiaojin Zhu and Zoubin Ghahramani. Learning from labeled and unlabeled data with label propagation. 2002.
|
| 315 |
+
|
| 316 |
+

|
| 317 |
+
Figure 4: The architecture of GAMLP with JK Attention.
|
| 318 |
+
|
| 319 |
+
# A MORE DETAILS ABOUT GAMLP
|
| 320 |
+
|
| 321 |
+
A.1 AN EXAMPLE OF JK ATTENTION
|
| 322 |
+
|
| 323 |
+
Fig. 4 provides a more zoomed-in look of JK attention, one of the two node-adaptive attention mechanisms we proposed. The propagated features are concatenated and then fed into an MLP to map the concatenated feature to the hidden dimension of the model. The mapped feature is then set as the reference vector of the following attention mechanism, where a linear layer is adopted to calculate the combination weight for propagated features at different propagation steps. The propagated features are then multiplied with the corresponding combination weight, and the summed results are fed into another MLP to generate final predictions.
|
| 324 |
+
|
| 325 |
+
# A.2 COMPARISON BETWEEN THE LABEL USAGE IN UNIMP AND GAMLP
|
| 326 |
+
|
| 327 |
+
(1) The label usage in UniMP is coupled with the training process, making it hard to scale to large graphs. While GAMLP decouples the label usage from the training process, the label propagation process can be executed as preprocessing.
|
| 328 |
+
|
| 329 |
+
(2) The label propagation steps in UniMP are restricted to the same number of model layers. And if the number of model layers becomes large, UniMP will encounter the efficiency and scalability issues even on relatively small graphs. While the label propagation steps in GAMLP can be quite large since the label propagation is performed as preprocessing.
|
| 330 |
+
|
| 331 |
+
(3) Both UniMP and GAMLP propose approaches to fight against the label leakage issue. However, the random masking in UniMP has to be executed in each training epoch, while the last residual connection (composed of simple matrix addition) in GAMLP just needs to be executed once during preprocessing. Thus, UniMP consumes more resources than GAMLP to fight the label leakage issue.
|
| 332 |
+
|
| 333 |
+
# A.3 COMPLEXITY ANALYSIS
|
| 334 |
+
|
| 335 |
+
Table 8 provides a detailed asymptotic complexity comparison between GAMLP and representative scalable GNN methods. During preprocessing, the time cost of clustering in Cluster-GCN is $\mathcal { O } ( m )$ and the time complexity of most linear models is $\mathcal { O } ( K m f )$ . Besides, GAMLP has an extra time cost $\mathcal { O } ( L m c )$ for the propagation of training labels. GBP takes advantage of Monte-Carlo method and conducts this process approximately with a bound of $\begin{array} { r } { \mathcal { O } ( K n f + K \frac { \sqrt { m \log n } } { \varepsilon } ) } \end{array}$ , where $\varepsilon$ is a error threshold. Compared with sampling-based GNNs, graph/layer/node-wise-propagation-based models usually have smaller training and inference time complexity. Memory complexity is a crucial factor in large-scale graph learning as it fundamentally determines whether it is possible to adopt the method. Compared with SIGN, both GBP and GAMLP do not need to store smoothed features at different propagation steps, and the memory complexity can be reduced from $\mathcal { O } ( b L f )$ to $\mathcal { O } ( b f )$ .
|
| 336 |
+
|
| 337 |
+
Table 8: Algorithm analysis for existing scalable GNNs. $n , m , c ,$ , and $f$ are the number of nodes, edges, classes, and feature dimensions, respectively. $b$ is the batch size, and $k$ refers to the number of sampled nodes. $K$ and $L$ corresponds to the number of times we aggregate features and labels respectively. Besides, $P$ and $Q$ are the number of layers in MLP classifiers trained with features and labels respectively.
|
| 338 |
+
|
| 339 |
+
<table><tr><td>Type</td><td>Method</td><td>Pre-processing</td><td>Training</td><td>Memory</td></tr><tr><td rowspan="3">Sampling</td><td>GraphSAGE</td><td>=</td><td>O(kKnf²)</td><td>O(bkK f+Kf²)</td></tr><tr><td>FastGCN</td><td></td><td>O(kKnf2)</td><td>O(bkKf+Kf²)</td></tr><tr><td>Cluster-GCN</td><td>0(m)</td><td>O(Pmf+Pnf²)</td><td>O(bKf+Kf²)</td></tr><tr><td>Graph-wise propagation</td><td>SGC</td><td>O(Kmf)</td><td>O(nf²)</td><td>O(bf+f²)</td></tr><tr><td rowspan="3">Layer-wise propagation</td><td>SIGN</td><td>O(Kmf)</td><td>O(Pnf2)</td><td>O(bLf+Pf²)</td></tr><tr><td>S²GC</td><td>O(Kmf)</td><td>O(nf2)</td><td>O(bf+f²)</td></tr><tr><td>GBP</td><td>O(Knf+KVmlgn)</td><td>O(Pnf²)</td><td>O(bf+Pf²)</td></tr><tr><td>Node-wise propagation</td><td>GAMLP</td><td>O(Kmf+Lmc)</td><td>O(Pnf² +Qnc²)</td><td>O(bf+Pf²+Qc²)</td></tr></table>
|
| 340 |
+
|
| 341 |
+
Table 9: Test accuracy on ogbn-mag dataset.
|
| 342 |
+
|
| 343 |
+
<table><tr><td>Methods</td><td>Validation Accuracy</td><td>Test Accuracy</td></tr><tr><td>R-GCN</td><td>40.84±0.41</td><td>39.77±0.46</td></tr><tr><td>SIGN</td><td>40.68±0.10</td><td>40.46±0.12</td></tr><tr><td>HGT</td><td>49.84±0.47</td><td>49.27±0.61</td></tr><tr><td>R-GSN</td><td>51.82±0.41</td><td>50.32±0.37</td></tr><tr><td>HGConv</td><td>53.00±0.18</td><td>50.45±0.17</td></tr><tr><td>R-HGNN</td><td>53.61±0.22</td><td>52.04±0.26</td></tr><tr><td>NARS</td><td>53.72±0.09</td><td>52.40±0.16</td></tr><tr><td>NARS-GAMLP</td><td>55.52±0.08</td><td>54.01±0.21</td></tr></table>
|
| 344 |
+
|
| 345 |
+
# B ADDITIONAL EXPERIMENTS
|
| 346 |
+
|
| 347 |
+
# B.1 EXPERIMENTS ON OGBN-MAG
|
| 348 |
+
|
| 349 |
+
Compared Baselines. Ogbn-mag dataset is a heterogeneous graph consists of 1,939,743 nodes and 21,111,007 edges of different types. For comparison, we choose eight baseline methods from the OGB ogbn-mag leaderboard: R-GCN (Schlichtkrull et al., 2018), SIGN (Frasca et al., 2020), HGT (Hu et al., 2020), R-GSN (Wu et al., 2021), HGConv (Yu et al., 2020a), R-HGNN (Yu et al., 2021), and NARS (Yu et al., 2020b).
|
| 350 |
+
|
| 351 |
+
Adapt GAMLP to Heterogeneous Graphs. In its original design, GAMLP does not support training on heterogeneous graphs. Here we imitate the model design of NARS to adapt GAMLP to heterogeneous graphs.
|
| 352 |
+
|
| 353 |
+
First, we sample subgraphs from the original heterogeneous graphs according to relation types and regard the subgraph as a homogeneous graph although it may have different kinds of nodes and edges. Then, on each subgraph, the propagated features of different steps are generated. The propagated features of the same propagation step across different subgraphs are aggregated using 1-d convolution. After that, aggregated features of different steps are fed into our GAMLP to get the final results. This variant of our GAMLP is called NARS-GAMLP as it mimics the design of NARS.
|
| 354 |
+
|
| 355 |
+
As ogbn-mag dataset only contains node features for “paper” nodes, we here adopt the ComplEx algorithm (Trouillon et al., 2017) to generate features for other nodes.
|
| 356 |
+
|
| 357 |
+
Experiment Results. We report the validation and test accuracy of our proposed GAMLP on the ogbn-mag dataset in Table 9. It can be seen from the results that NARS-GAMLP achieves great performance on the heterogeneous graph ogbn-mag, outperforming the performance of the strongest single model baseline NARS by a large margin of $1 . 6 1 \%$ .
|
| 358 |
+
|
| 359 |
+

|
| 360 |
+
Figure 5: Test accuracy when the propagation depth increases from 10 to 100.
|
| 361 |
+
|
| 362 |
+

|
| 363 |
+
Figure 6: The average attention weights of propagated features of different steps on 60 randomly selected nodes from ogbn-products.
|
| 364 |
+
|
| 365 |
+
# B.2 DEEP PROPAGATION IS POSSIBLE
|
| 366 |
+
|
| 367 |
+
Equipped with the learnable node-wise propagation scheme, our GAMLP can still maintain high predictive accuracy even when the propagation depth is over 50. Here, we evaluate the predictive accuracy of our proposed GAMLP(JK) at propagation depth 10, 30, 50, 80, 100 on the PubMed dataset. The performance of JK-Net and SGC are also reported as baselines. The experimental results in Fig. 5 show that even at propagation depth equals 100, the predictive accuracy of our GAMLP(JK) still exceeds $8 0 . 0 \%$ , higher than the predictive accuracy of most baselines in Table 1. At the same time, the predictive accuracy of SGC and JK-Net both drops rapidly when propagation depth increases from 10 to 100.
|
| 368 |
+
|
| 369 |
+
# B.3 INTERPRETABILITY OF THE ATTENTION MECHANISM
|
| 370 |
+
|
| 371 |
+
GAMLP can adaptively and effectively combine multi-scale propagated features for each node. To demonstrate this, Fig. 6 shows the average attention weights of propagated features of GAMLP(JK) according to the number of steps and degrees of input nodes, where the maximum step is 6. In this experiment, we randomly select 20 nodes for each degree range (1-4, 5-8, 9-12) and plot the relative weight based on the maximum value. We get two observations from the heat map: 1) The 1-step and 2-step propagated features are always of great importance, which shows that GAMLP captures the local information as those widely 2-layer methods do; 2) The weights of propagated features with larger steps drop faster as the degree grows, indicating that our attention mechanism could prevent high-degree nodes from including excessive irrelevant nodes, leading to over-smoothing. From the two observations, we conclude that GAMLP can identify the different RF demands of nodes and explicitly weight each propagated feature.
|
| 372 |
+
|
| 373 |
+
Table 10: Overview of the Datasets
|
| 374 |
+
|
| 375 |
+
<table><tr><td>Dataset</td><td>#Nodes</td><td>#Features</td><td>#Edges</td><td>#Classes</td><td>#Train/Val/Test</td><td>Task type</td><td>Description</td></tr><tr><td>Cora</td><td>2,708</td><td>1,433</td><td>5,429</td><td>7</td><td>140/500/1000</td><td>Transductive</td><td>citation network</td></tr><tr><td>Citeseer</td><td>3,327</td><td>3,703</td><td>4,732</td><td>6</td><td>120/500/1000</td><td>Transductive</td><td>citation network</td></tr><tr><td>Pubmed</td><td>19,717</td><td>500</td><td>44,338</td><td>3</td><td>60/500/1000</td><td>Transductive</td><td>citation network</td></tr><tr><td>Amazon Computer</td><td>13,381</td><td>767</td><td>245,778</td><td>10</td><td>200/300/12881</td><td>Transductive</td><td>co-purchase graph</td></tr><tr><td>Amazon Photo</td><td>7,487</td><td>745</td><td>119,043</td><td>8</td><td>160/240/7,087</td><td>Transductive</td><td>co-purchase graph</td></tr><tr><td>Coauthor CS</td><td>18,333</td><td>6,805</td><td>81,894</td><td>15</td><td>300/450/17,583</td><td>Transductive</td><td>co-authorship graph</td></tr><tr><td>Coauthor Physics</td><td>34,493</td><td>8,415</td><td>247,962</td><td>5</td><td>100/150/34,243</td><td>Transductive</td><td>co-authorship graph</td></tr><tr><td>ogbn-products</td><td>2,449,029</td><td>100</td><td>61,859,140</td><td>47</td><td>196k/49k/2204k</td><td>Transductive</td><td>co-purchase graph</td></tr><tr><td>ogbn-papers100M</td><td>111,059,956</td><td>128</td><td>1,615,685,872</td><td>172</td><td>1207k/125k/214k</td><td>Transductive</td><td>citation network</td></tr><tr><td>ogbn-mag</td><td>1,939,743</td><td>128</td><td>21,111,007</td><td>349</td><td>626k/66k/37k</td><td>Transductive</td><td>citation network</td></tr><tr><td>PPI</td><td>56,944</td><td>50</td><td>818,716</td><td>121</td><td>45k/6k/6k</td><td>Inductive</td><td>protein interactions network</td></tr><tr><td>Flickr</td><td>89,250</td><td>500</td><td>899,756</td><td>7</td><td>44k/22k/22k</td><td>Inductive</td><td>image network</td></tr><tr><td>Reddit</td><td>232.965</td><td>602</td><td>11,606,919</td><td>41</td><td>155k/23k/54k</td><td>Inductive</td><td>social network</td></tr></table>
|
| 376 |
+
|
| 377 |
+
Table 11: Ablation study of choices for $\alpha _ { l }$ on the ogbn-products dataset.
|
| 378 |
+
B.4 CHOICES FOR $\alpha _ { l }$ IN THE LAST RESIDUAL CONNECTION
|
| 379 |
+
|
| 380 |
+
<table><tr><td>Choices</td><td>Test Accuracy</td></tr><tr><td>Fixed weight</td><td>82.56±0.43</td></tr><tr><td>Linear-decreasing weight</td><td>82.72±0.93</td></tr><tr><td>Cosine function</td><td>83.59±0.05</td></tr></table>
|
| 381 |
+
|
| 382 |
+
Our first choice for the that GAMLP still enco $\alpha _ { l }$ in the last residual connection module is ters the over-fitting issue on some datas $\begin{array} { r } { \alpha _ { l } = \frac { L - l } { L } } \end{array}$ . However, we find we instead choose $\begin{array} { r } { \alpha _ { l } = \cos ( \frac { \pi l } { 2 L } ) } \end{array}$ to give more penalties to labels at large propagation steps. We provide the performance comparison on the ogbn-products dataset in Table 11. Three weighting schemes for the last residual connection module are tested: "Cosine function" stands for $\begin{array} { r } { \alpha _ { l } = \cos ( \frac { \pi l } { 2 L } ) } \end{array}$ , the one in GAMLP; "Linear-decreasing weight" stands for $\begin{array} { r } { \alpha _ { l } = \frac { L - l } { L } } \end{array}$ ; and "Fixed weight" stands for $\alpha _ { l } = 0 . 7$ . Table 11 shows that the weighting scheme GAMLP adopts, $\begin{array} { r } { \alpha _ { l } = \cos ( \frac { \pi l } { 2 L } ) } \end{array}$ , outperforms the other two options.
|
| 383 |
+
|
| 384 |
+
# C DETAILED EXPERIMENT SETUP
|
| 385 |
+
|
| 386 |
+
# C.1 EXPERIMENT ENVIRONMENT
|
| 387 |
+
|
| 388 |
+
We provide detailed information about the datasets we adopted during the experiment in Table 10. To alleviate the influence of randomness, we repeat each method ten times and report the mean performance and the standard deviations. For the largest ogbn-papers100M dataset, we run each method five times instead. The experiments are conducted on a machine with Intel(R) Xeon(R) Platinum 8255C $\mathrm { P U } @ 2 . 5 0 \mathrm { G H z }$ , and a single Tesla V100 GPU with 32GB GPU memory. The operating system of the machine is Ubuntu 16.04. As for software versions, we use Python 3.6, Pytorch 1.7.1, and CUDA 10.1. The hyper-parameters in each baseline are set according to the original paper if available. Please refer to Appendix C.2 for the detailed hyperparameter settings for our GAMLP.
|
| 389 |
+
|
| 390 |
+
# C.2 DETAILED HYPERPARAMETERS
|
| 391 |
+
|
| 392 |
+
We provide the detailed hyperparameter setting on GAMLP in Table 12, 13 and 14 to help reproduce the results. To reproduce the experimental results of GAMLP, just follow the same hyperparameter setting yet only run the first stage.
|
| 393 |
+
|
| 394 |
+
Table 12: Detailed hyperparameter setting on OGB datasets.
|
| 395 |
+
|
| 396 |
+
<table><tr><td rowspan=1 colspan=1>Datasets</td><td rowspan=1 colspan=1>attention type</td><td rowspan=1 colspan=1>hidden size</td><td rowspan=1 colspan=1>num layer in JK</td><td rowspan=1 colspan=1>num layer</td><td rowspan=1 colspan=1>activation</td></tr><tr><td rowspan=1 colspan=1>ogb-products</td><td rowspan=1 colspan=1>Recursive</td><td rowspan=1 colspan=1>512</td><td rowspan=1 colspan=1>/</td><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>leakyrelu,a=0.2</td></tr><tr><td rowspan=1 colspan=1>ogb-papers100M</td><td rowspan=1 colspan=1>JK</td><td rowspan=1 colspan=1>1280</td><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>6</td><td rowspan=1 colspan=1>sigmoid</td></tr><tr><td rowspan=1 colspan=1>ogb-mag</td><td rowspan=1 colspan=1>JK</td><td rowspan=1 colspan=1>512</td><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>leaky relu,a=0.2</td></tr></table>
|
| 397 |
+
|
| 398 |
+
Table 13: Detailed hyperparameter setting on OGB datasets.
|
| 399 |
+
|
| 400 |
+
<table><tr><td rowspan=1 colspan=1>Datasets</td><td rowspan=1 colspan=1>hops</td><td rowspan=1 colspan=1>hops for label</td><td rowspan=1 colspan=1>input dropout</td><td rowspan=1 colspan=1> attention dropout</td><td rowspan=1 colspan=1>dropout</td></tr><tr><td rowspan=1 colspan=1>ogb-products</td><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>10</td><td rowspan=1 colspan=1>0.2</td><td rowspan=1 colspan=1>0.5</td><td rowspan=1 colspan=1>0.5</td></tr><tr><td rowspan=1 colspan=1>ogb-papers100M</td><td rowspan=1 colspan=1>12</td><td rowspan=1 colspan=1>10</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>0.5</td><td rowspan=1 colspan=1>0.5</td></tr><tr><td rowspan=1 colspan=1>ogb-mag</td><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1>0.1</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>0.5</td></tr></table>
|
| 401 |
+
|
| 402 |
+
Table 14: Detailed hyperparameter setting on OGB datasets.
|
| 403 |
+
|
| 404 |
+
<table><tr><td rowspan=1 colspan=1>Datasets</td><td rowspan=1 colspan=1>beta</td><td rowspan=1 colspan=1>patience</td><td rowspan=1 colspan=1>lr</td><td rowspan=1 colspan=1>batch size</td><td rowspan=1 colspan=1>epochs</td></tr><tr><td rowspan=1 colspan=1>ogb-products</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>300</td><td rowspan=1 colspan=1>0.001</td><td rowspan=1 colspan=1>50000</td><td rowspan=1 colspan=1>400</td></tr><tr><td rowspan=1 colspan=1>ogb-papers100M</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>60</td><td rowspan=1 colspan=1>0.0001</td><td rowspan=1 colspan=1>5000</td><td rowspan=1 colspan=1>400</td></tr><tr><td rowspan=1 colspan=1>ogb-mag</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>100</td><td rowspan=1 colspan=1>0.001</td><td rowspan=1 colspan=1>10000</td><td rowspan=1 colspan=1>400</td></tr></table>
|
md/dev/2hMEdc35xZ6/2hMEdc35xZ6.md
ADDED
|
@@ -0,0 +1,452 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# DEFECT TRANSFER GAN: DIVERSE DEFECT SYNTHESIS FOR DATA AUGMENTATION
|
| 2 |
+
|
| 3 |
+
Anonymous authors Paper under double-blind review
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
Large amounts of data are a common requirement for many deep learning approaches. However, data is not always equally available at large scale for all classes. For example, on highly optimized production lines, defective samples are hardly acquired while non-defective samples come almost for free. The defects however often seem to resemble each other, e.g., scratches on different products may only differ in few characteristics. In this work, we propose to make use of the shared characteristics by transferring a stylized defect-specific content from one type of background product to another. Moreover, the stochastic variations of the shared characteristics are captured, which also allows generating novel defects from random noise. These synthetic defective samples enlarge the dataset and increase the diversity of defects on the target product. Experiments demonstrate that our model is able to disentangle the defect-specific content from the background of an image without pixel-level labels. We present convincing results on images from real industrial production lines. Also, we show consistent gains of using our method to enlarge training sets in classification tasks.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Automated Visual Inspection (AVI) is vital for quality control in modern production lines. Despite the fact that AVI has been studied for decades, it remains a challenging task with many open research questions await to be answered. One of the main challenges in data-driven AVI is the acquisition of suitable training data. This is for two reasons: First, collecting a vast amount of labelled data is usually labor-intensive and time-consuming. In many cases, even experts are required to identify where and what to look for. However, the acquired label information is task-specific and cannot be reused or transferred to a new task in most cases. Thus, the tedious labelling process must be repeated for each new product, even if its defect is similar to other products in people’s eyes. Second, in real-world scenarios such as highly optimized production lines, a more severe problem emerges: data imbalance. Only very few defective parts are produced by design. Moreover, the acquired anomaly images from a single product are lacking diversity and may not capture the full defect distribution. Training a robust deep neural network model in such conditions is very challenging.
|
| 12 |
+
|
| 13 |
+
Since collecting sufficient real-world defective samples is impractical, algorithms to synthesize required images became a focus in research. Image synthesis through Generative Adversarial Networks (GANs) (Goodfellow et al., 2014) has shown promising performance in recent years. But it also requires large amounts of balanced data which are not available in most industrial use cases, in particular for irregular defect patterns and large variation. Therefore, GANs tend to overfit to the training examples when trained with little data (Karras et al., 2020a).
|
| 14 |
+
|
| 15 |
+
In this work, we tackle these issues by exploiting cross-domain information: we first define two sets of domains—foreground domains and background domains. The foreground domain describes a set of images that contains a specific foreground content to be grouped into a distinctive category, and each content has a different style. The background domain instead is considered as a group of images that shares similar structural appearance over the whole image. For example, we can set foreground domains as defect types and background domains as product types while the styles of defects indicate their artistic looks such as light or heavy strokes. Building upon StarGAN v2 (Choi et al., 2020), the concept underlying this work is to transfer and generate foreground contents with a variety of styles across different background domains, as illustrated in Figure 1.
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
Figure 1: The underlying concept of DT-GAN is to transfer and generate foreground contents with a variety of artistic styles (e.g., light / heavy strokes) across different background domains.
|
| 19 |
+
|
| 20 |
+
The contributions of this work are three-fold: First, we introduce Defect Transfer GAN (DT-GAN), a model that learns transferring existing foreground content and generating novel contents onto different backgrounds at the same time. In the real-world scenario, it allows defect inspection networks to learn from a variety of synthetic defective images by composing the foreground defects together with various non-defective images from different products. Second, DT-GAN is able to disentangle the foreground defect-specific content and the defect-irrelevant background in a weakly-supervised manner. Third, extensive experiments show that our method can generate diverse and real-looking defective samples even for products with only 20 real defective images. These defective images generated by DT-GAN boost the performance in defect inspection networks significantly.
|
| 21 |
+
|
| 22 |
+
# 2 RELATED WORK
|
| 23 |
+
|
| 24 |
+
GANs have shown their power in many computer vision tasks such as image synthesis (Luciˇ c et al., ´ 2019), style translation (Johnson et al., 2016), super-resolution (Ledig et al., 2017), image impainting (Pathak et al., 2016) and many other applications. To quantify the performance of GANs, visual quality and the diversity of generated images are considered as two of the most important criteria. Recent models address these requirements either by dedicated loss functions (Mao et al., 2019b; Yang et al., 2019) or architectural design (Brock et al., 2019). StyleGAN v2 (Karras et al., 2020b), the latest state-of-the-art model in image synthesis, introduces stochastic variation in image generating process by adding per-pixel noise after each convolution. However, it is non-trivial to adapt the model to transform given input images due to the design of the generator.
|
| 25 |
+
|
| 26 |
+
In contrast, image-to-image translation methods (Isola et al., 2017) provide a way to recover the connection between inputs and the generated images while encouraging diversity. For example, Zhu et al. (2017b) and Huang et al. (2018) impose consistent mappings in latent space to achieve the goal. Some approaches (Ma et al., 2019; Park et al., 2019) use reference images as guidance to generate diverse outputs. Mokady et al. (2020) further extends the translation task from styles to contents. It learns to identify a specific content in a given input (e.g., a specific pair of glasses) and transfer it to the target image. However, aforementioned methods only consider the translation between two domains and their extension to multiple domains is non-trivial.
|
| 27 |
+
|
| 28 |
+
Surface defect detection is one of the important tasks in real-world industrial manufacturing. It aims at identifying and classifying defects with the help of machine vision. Traditional methods (Ngan et al., 2011) build models upon hand-crafted feature extractors, which are unstable and outperformed by deep learning based models. However, the performance and generalization ability of deep learning approaches are restricted due to limited number of defective samples in real-world scenarios. Data augmentation aims to enrich the training dataset by introducing different kinds of invariance for the model to capture. Several recent works (Niu et al., 2020; Zhang et al., 2021) have proposed to adopt GANs as a data augmentation method to generate realistic defective samples. Among them, Defect-GAN (Zhang et al., 2021) tries to capture the stochastic variation within defects by mimicking the defacement and restoration processes. However, it still learns a deterministic mapping between inputs and outputs while DT-GAN achieves multi-modality by varying styles. Moreover, our method can generate realistic defects with sophisticated patterns copied from real-world defective samples.
|
| 29 |
+
|
| 30 |
+

|
| 31 |
+
Figure 2: Overview of all modules in DT-GAN.
|
| 32 |
+
|
| 33 |
+
# 3 METHODOLOGY
|
| 34 |
+
|
| 35 |
+
Our primary aim is to perform unpaired image-to-image translation across multiple foreground domains within a single model. In our use case, the foreground domains refer to the defect types, which means we want to achieve translations between different types of defects while the background remains unaffected. We assume that there is always an adequate amount of normal samples (e.g., non-defective) available, while anomaly samples are rare and hard to acquire.
|
| 36 |
+
|
| 37 |
+
# 3.1 PROPOSED FRAMEWORK
|
| 38 |
+
|
| 39 |
+
Our framework builds on StarGAN v2, a multimodal image-to-image translation model. Given an input image $\textbf { x } \in { \mathcal { X } }$ and an arbitrary domain $y \in \mathcal { V }$ , StarGAN v2 generates a domain specific style code in a learned style space and outputs an image that is stylized to fit the domain of $y$ . Its network architecture consists of four modules: a generator, a mapping network, a style encoder and a discriminator. We modify and extend all four modules (see Figure 2) and describe the key differences in details as below.
|
| 40 |
+
|
| 41 |
+
Style-Content Separation. Given a latent code $\mathbf { z }$ and a domain $y$ , the mapping network $M$ (Figure 2(b)) generates a style code $\mathbf { s } = M _ { y } ( \mathbf { z } )$ and a domain specific content $\mathbf { c } = M _ { y } ( \mathbf { z } )$ in different branches. It is worth mentioning that $M _ { y }$ here denotes an output of $M$ corresponding to the domain $y$ . This feature allows our method to separately model the structural appearance (i.e. content) and its artistic looks (i.e. style), which is essential because applying different styles to the same content enriches the diversity of outputs. By randomly sampling $\mathbf { z }$ from a standard normal distribution and $y$ from all available foreground domains, $M$ is able to produce diverse style codes and domain specific contents.
|
| 42 |
+
|
| 43 |
+
The encoder $E$ (Figure 2(c)) extracts the style code $\mathbf { s } = E _ { y } ( \mathbf { x } )$ and the domain specific content $\mathbf { c } = E _ { y } ( \mathbf { x } )$ from an given image $\mathbf { x }$ , which reflect the characteristics of reference images instead of randomly sampled noise.
|
| 44 |
+
|
| 45 |
+
Foreground/Background (FG/BG) Disentanglement. The generator $G$ (Figure 2(a)) translates an input image x into an output image $G ( \mathbf { x } , \widetilde { \mathbf { s } } , \widetilde { \mathbf { c } } )$ according to given domain specific style code es and content ec, which are provided either by the mapping network $M$ when generating from random noise or by the style-content encoder $E$ when transferring an existing content from a reference image. To achieve a FG/BG disentanglement, we split the channels of the three-dimensional feature map (i.e., $H \times W \times C$ ) at the bottle neck of $G$ into two parts. The model is then forced to encode the background into the first channels and the domain specific content cˆ into the latter channels by classification losses as discussed in Section 3.2. cˆ can then be replaced with content ec from the target domain. The adaptive instance normalization (AdaIN) (Huang & Belongie, 2017) is then used to inject es into ec during the decoding process while the background $B G _ { G } ( \mathbf { x } )$ is decoded separately. StarGAN v2 learns $\mathbf { F G }$ and BG together which leads to a conditional relationship between both. Our disentanglement and separate encoding break this conditioning and therefore enable our method to freely combine FG and BG as well as learn the full variation of FG content. Finally, $B G _ { G } ( \mathbf { x } )$ and ec are concatenated together and then fused before output.
|
| 46 |
+
|
| 47 |
+
Multi-task discriminator with auxiliary classifiers. The discriminator $D$ (Figure 2(d)) is a multitask discriminator with two auxiliary classifiers: a foreground domain classifier and a background domain classifier. This feature strengthens the disentanglement of FG and BG by first ensuring the input image $\mathbf { x }$ contains a domain specific content that can be recognized by the foreground domain classifier independent of the background. Later, each branch $D _ { y }$ in the multi-task discriminator $D$ is trained to determine if an image $\mathbf { x }$ is a real image of its foreground domain or a fake image $G ( \mathbf { x } , \mathbf { s } , \mathbf { c } )$ generated by $G$ . Apart from that, one extra branch $B G _ { \mathrm { c l s } }$ is attached to decide whether the background information of the input images is well preserved.
|
| 48 |
+
|
| 49 |
+
Content Transfer. Mokady et al. (2020) introduced a concept that a model should be able to identity the difference between two domains when one of the domains contains a feature that the other does not have. We refer to this concept as ‘anchor’ and extend to multiple domains $( > 2 )$ by the FG/BG disentanglement, the multi-task discriminator and the foreground content classifier in $D$ . We treat domain Normal as the anchor domain i.e. set the domain specific content to zero, because a normal image has no domain specific content in our definition. As a result, we can now transfer contents between all combination of FG and BG domains (see Figure 10).
|
| 50 |
+
|
| 51 |
+
Compared to StarGAN v2, our method not only models style codes and contents separately but also disentangles the foreground and background of an image in a weakly-supervised manner. These features allow explicit control over output images by combining desired style codes and contents from one of the subnetworks with the input images. Therefore, it leads to higher variance regarding the location, structural pattern and artistic style of defects in the synthetic images of DT-GAN.
|
| 52 |
+
|
| 53 |
+
# 3.2 TRAINING OBJECTIVES
|
| 54 |
+
|
| 55 |
+
Given an image $\mathbf { x } \in \mathcal { X }$ , its original foreground domain $y \in \mathcal { V }$ and its background domain $p \in \mathcal { P }$ , the following objectives are used to train our framework.
|
| 56 |
+
|
| 57 |
+
Adversarial loss. In the training phase, a noise vector $\mathbf { z } \in { \mathcal { Z } }$ and a target foreground domain $\widetilde y \in \mathcal { V }$ are sampled randomly. Both of them are fed to $M$ , producing a target style code $\widetilde { \mathbf { s } }$ and a target content ec as follows: $\widetilde { \mathbf { s } } , \widetilde { \mathbf { c } } = M _ { \widetilde { y } } ( \mathbf { z } )$ . Goal of the training is to ensure that $\widetilde { \mathbf { s } }$ and ec are sampled from the distribution over styles and contents of the target domain $\widetilde { y }$ . The generator $G$ then combines an image $\mathbf { x }$ with $\widetilde { \mathbf { s } }$ and $\widetilde { \mathbf c }$ and learns to generate an output image $G ( \mathbf { x } , \widetilde { \mathbf { s } } , \widetilde { \mathbf { c } } )$ that is indistinguishable from real images in the target domain $\widetilde { y }$ . We encourage this behavior by using an adversarial loss same as in Choi et al. (2020)
|
| 58 |
+
|
| 59 |
+
$$
|
| 60 |
+
\mathcal { L } _ { \mathrm { a d v } } = \mathbb { E } _ { { \mathbf { x } } , y } \big [ \log D _ { y } ( { \mathbf { x } } ) \big ] + \mathbb { E } _ { { \mathbf { x } } , \widetilde { y } , { \mathbf { z } } } [ \log \left( 1 - D _ { \widetilde { y } } ( G ( { \mathbf { x } } , \widetilde { { \mathbf { s } } } , \widetilde { { \mathbf { c } } } ) ) \right) ] ,
|
| 61 |
+
$$
|
| 62 |
+
|
| 63 |
+
where $D _ { y }$ and $D _ { \widetilde { y } }$ are the output branches of $D$ that correspond to the source domain $y$ and the target domain $\widetilde { y }$ , respectively.
|
| 64 |
+
|
| 65 |
+
Style-content reconstruction loss. Similar to StarGAN v2, to enforce the generator $G$ takes the style code $\widetilde { \mathbf { s } }$ and the domain specific content ec into consideration during the generation process, we employ a style-content reconstruction loss
|
| 66 |
+
|
| 67 |
+
$$
|
| 68 |
+
\begin{array} { r } { \mathcal { L } _ { \mathrm { s t y . c o n } } = \mathbb { E } _ { \mathbf { x } , \widetilde { y } , \mathbf { z } } \big [ \| \widetilde { \mathbf { s } } - S _ { E } ( G ( \mathbf { x } , \widetilde { \mathbf { s } } , \widetilde { \mathbf { c } } ) ) \| _ { 1 } \big ] + \mathbb { E } _ { \mathbf { x } , \widetilde { y } , \mathbf { z } } \big [ \| \widetilde { \mathbf { c } } - C _ { E } ( G ( \mathbf { x } , \widetilde { \mathbf { s } } , \widetilde { \mathbf { c } } ) ) \| _ { 1 } \big ] . } \end{array}
|
| 69 |
+
$$
|
| 70 |
+
|
| 71 |
+
This objective urges the style-content encoder $E$ to recover $\widetilde { \mathbf { s } }$ and c from $G ( \mathbf { x } , \widetilde { \mathbf { s } } , \widetilde { \mathbf { c } } )$ . Here, the stylecontent encoder $E$ learns a mapping from an image to its style and content domains, which allows $G$ to synthesize an image with given s and c from reference images at test time.
|
| 72 |
+
|
| 73 |
+
Diversity loss. In order to further boost the diversity of output images from $G$ , we introduce a loss that encourages diversity as follows: for a pair of random latent codes $\mathbf { z } _ { 1 }$ and $\mathbf { z } _ { 2 }$ we compute $\widetilde { \mathbf { s } } _ { i } , \widetilde { \mathbf { c } } _ { i } = M _ { \widetilde { y } } ( \mathbf { z } _ { i } )$ for $i \in \{ 1 , 2 \}$ and enforce a different outcome of the generator $G$ for differently mixed style and content input pairs:
|
| 74 |
+
|
| 75 |
+
$$
|
| 76 |
+
\begin{array} { r l } & { \mathcal { L } _ { \mathrm { d s } } = \mathbb { E } _ { \mathbf { x } , \widetilde { y } , \mathbf { z } _ { 1 } , \mathbf { z } _ { 2 } } \left[ \| G ( \mathbf { x } , \widetilde { \mathbf { s } } _ { 1 } , \widetilde { \mathbf { c } } _ { 2 } ) - G ( \mathbf { x } , \widetilde { \mathbf { s } } _ { 2 } , \widetilde { \mathbf { c } } _ { 1 } ) \| _ { 1 } \right] } \\ & { \quad \quad + \mathbb { E } _ { \mathbf { x } , \widetilde { y } , \mathbf { z } _ { 1 } , \mathbf { z } _ { 2 } } \left[ \| G ( \mathbf { x } , \widetilde { \mathbf { s } } _ { 1 } , \widetilde { \mathbf { c } } _ { 1 } ) - G ( \mathbf { x } , \widetilde { \mathbf { s } } _ { 2 } , \widetilde { \mathbf { c } } _ { 2 } ) \| _ { 1 } \right] } \\ & { \quad \quad + \sum _ { m , n , o } \left[ \mathbb { E } _ { \mathbf { x } , \widetilde { y } , \mathbf { z } _ { 1 } , \mathbf { z } _ { 2 } } \left[ \| G ( \mathbf { x } , \widetilde { \mathbf { s } } _ { m } , \widetilde { \mathbf { c } } _ { n } ) - G ( \mathbf { x } , \widetilde { \mathbf { s } } _ { o } , \widetilde { \mathbf { c } } _ { o } ) \| _ { 1 } \right] \right] , } \end{array}
|
| 77 |
+
$$
|
| 78 |
+
|
| 79 |
+
where $m , n \in \{ 1 , 2 | m \neq n \}$ and $o \in \{ 1 , 2 \}$ . Driven by this term, the generator $G$ is forced to discover meaningful style features and contents that eventually lead to diversity in generated images.
|
| 80 |
+
|
| 81 |
+
We ignore the denominator ${ \left\| { \bf z } _ { 1 } - { \bf z } _ { 2 } \right\| } _ { 1 }$ of the original diversity loss (Mao et al., 2019a) for stable training as in StarGAN v2.
|
| 82 |
+
|
| 83 |
+
Cycle consistency loss. To ensure that the generated image $G ( \mathbf { x } , \widetilde { \mathbf { s } } , \widetilde { \mathbf { c } } )$ preserves the domaininvariant properties of its input image $\mathbf { x }$ , we impose the cycle consistency loss (Zhu et al., 2017a)
|
| 84 |
+
|
| 85 |
+
$$
|
| 86 |
+
\mathcal { L } _ { \mathrm { c y c } } = \mathbb { E } _ { { \mathbf { x } } , y , \widetilde { y } , { \mathbf { z } } } \big [ | | { \mathbf { x } } - G ( G ( { \mathbf { x } } , \widetilde { { \mathbf { s } } } , \widetilde { { \mathbf { c } } } ) , \widehat { { \mathbf { s } } } , \widehat { { \mathbf { c } } } ) | | _ { 1 } \big ] ,
|
| 87 |
+
$$
|
| 88 |
+
|
| 89 |
+
where $\hat { \bf s } , \hat { \bf c } = E _ { y } ( { \bf x } )$ is the extracted style code and domain specific content of the input image $\mathbf { x }$ , and $y$ is the original domain of $\mathbf { x }$ . By learning to reconstruct the input image $\mathbf { x }$ with given style code ˆs and content cˆ, the generator $G$ is then further encouraged to disentangle the background, the domain specific content and the style code.
|
| 90 |
+
|
| 91 |
+
Content consistency loss. Besides the cycle consistency loss, we apply another constraint to enforce that the detached domain specific content from $G$ is consistent with the one retrieved from $E$ according to
|
| 92 |
+
|
| 93 |
+
$$
|
| 94 |
+
\begin{array} { r } { \mathcal { L } _ { \mathrm { c o n . c y c } } = \mathbb { E } _ { \mathbf { x } , y , \widetilde { y } , \mathbf { z } } \left[ \left\| F G _ { G } ( \mathbf { x } ) - \widehat { \mathbf { c } } \right\| _ { 1 } \right] + \mathbb { E } _ { \mathbf { x } , y , \widetilde { y } , \mathbf { z } } \left[ \left\| F G _ { G } ( G ( \mathbf { x } , \widetilde { \mathbf { s } } , \widetilde { \mathbf { c } } ) ) - \widetilde { \mathbf { c } } \right\| _ { 1 } \right] , } \end{array}
|
| 95 |
+
$$
|
| 96 |
+
|
| 97 |
+
where $\hat { \mathbf { c } } = E _ { y } ( \mathbf { x } ) , \widetilde { \mathbf { c } } = E _ { \widetilde { y } } ( \mathbf { x } ) , F G _ { G } ( \mathbf { x } )$ and $F G _ { G } ( G ( \mathbf { x } , \widetilde { \mathbf { s } } , \widetilde { \mathbf { c } } ) )$ are the pop-out domain specific content from input image $\mathbf { x }$ and generated image $G ( \mathbf { x } , \widetilde { \mathbf { s } } , \widetilde { \mathbf { c } } )$ , respectively.
|
| 98 |
+
|
| 99 |
+
Classification losses. We employ two classification losses: the first one is the foreground content classification loss
|
| 100 |
+
|
| 101 |
+
$$
|
| 102 |
+
\mathcal { L } _ { \mathrm { F G . c l s } } = \mathbb { E } _ { \mathbf { x } _ { \mathrm { r e a l } } , y } \Big [ - \log D _ { \mathrm { F G . c l s } } \big ( y | \mathbf { x } _ { \mathrm { r e a l } } \big ) \Big ] + \mathbb { E } _ { \mathbf { x } _ { \mathrm { f a k e } } , \widetilde { y } } \Big [ - \log D _ { \mathrm { F G . c l s } } \big ( \widetilde { y } | \mathbf { x } _ { \mathrm { f a k e } } \big ) \Big ] \ ,
|
| 103 |
+
$$
|
| 104 |
+
|
| 105 |
+
which aims to ensure that the domain specific content is properly encoded and carries enough information from the target domain. The second one is the background classification loss
|
| 106 |
+
|
| 107 |
+
$$
|
| 108 |
+
\mathcal { L } _ { \mathrm { B G } . \mathrm { c l s } } = \mathbb { E } _ { \mathbf { x } _ { \mathrm { r e a l } } , p } \big [ - \log D _ { \mathrm { B G } . \mathrm { c l s } } ( p | \mathbf { x } _ { \mathrm { r e a l } } ) \big ] + \mathbb { E } _ { \mathbf { x } _ { \mathrm { f a k e } } , p } \big [ - \log D _ { \mathrm { B G } . \mathrm { c l s } } ( p | \mathbf { x } _ { \mathrm { f a k e } } ) \big ] \ ,
|
| 109 |
+
$$
|
| 110 |
+
|
| 111 |
+
where $p$ is the corresponding background type of $\mathbf { x } _ { \mathrm { r e a l } }$ and $\mathbf { x } _ { \mathrm { f a k e } }$ . With the help of this objective, the generator $G$ learns to preserve the domain-invariant characteristics of its input image $\mathbf { x }$ while dissociating the foreground domain specific part.
|
| 112 |
+
|
| 113 |
+
Full objective. Our full objective functions can be summarized as
|
| 114 |
+
|
| 115 |
+
$$
|
| 116 |
+
\begin{array} { r l } { \underset { G , F , E } { \operatorname* { m i n } } \underset { D } { \operatorname* { m a x } } } & { \mathcal { L } _ { \mathrm { a d v } } + \lambda _ { \mathrm { s t y } . \mathrm { c o n } } \mathcal { L } _ { \mathrm { s t y } . \mathrm { c o n } } - \lambda _ { \mathrm { d s } } \mathcal { L } _ { \mathrm { d s } } + \lambda _ { \mathrm { c y c } } \mathcal { L } _ { \mathrm { c y c } } + } \\ & { \lambda _ { \mathrm { c o n . c y c } } \mathcal { L } _ { \mathrm { c o n . c y c } } + \lambda _ { \mathrm { F G . c l s } } \mathcal { L } _ { \mathrm { F G . c l s } } + \lambda _ { \mathrm { B G . c l s } } \mathcal { L } _ { \mathrm { B G . c l s } } \ , } \end{array}
|
| 117 |
+
$$
|
| 118 |
+
|
| 119 |
+
where $\lambda _ { \mathrm { s t y } }$ , $\lambda _ { \mathrm { d s } }$ , $\lambda _ { \mathrm { c y c } }$ , $\lambda _ { \mathrm { c o n \mathrm { { - } c y c } } }$ , $\lambda _ { \mathrm { F G \mathrm { - } c l s } }$ and $\lambda _ { \mathrm { B G \mathrm { { - } c l s } } }$ are the hyperparameters for each term.
|
| 120 |
+
|
| 121 |
+
# 4 EXPERIMENTS
|
| 122 |
+
|
| 123 |
+
We evaluated the images generated by DT-GAN through a series of experiments both quantitatively and qualitatively. Finally, we demonstrate the benefits of our generated images when being used as data augmentation for a defect classification task on limited data.
|
| 124 |
+
|
| 125 |
+
Dataset. All experiments were performed on a real industrial dataset: a Surface Defect Inspection (SDI) dataset that contains three different kinds of products from production lines and samples from each product are classified into three mutually exclusive classes: Normal, Scratch and Spot. All of the images are grayscale. Detailed statistics of the dataset are summarized in Appendix A. Note that only the training set was used in GAN training, the test set was left untouched for final evaluation in classifier training. For a fair comparison, all images were resized to $1 2 8 \times 1 2 8$ resolution for both GAN training and classifier training, which was also the highest resolution used in the baselines for image generation. For comparison, we also conducted experiments on the widely used MVTec Anomaly Detection dataset (Bergmann et al., 2019) in Appendix E.4.
|
| 126 |
+
|
| 127 |
+
# 4.1 DEFECT GENERATION
|
| 128 |
+
|
| 129 |
+
Baselines. As discussed in Section 3, DT-GAN can either use the mapping network to randomly generate styles and defects, or it can use the style-content encoder to extract both from reference images. We refer to these cases as ‘latent-guided’ and ‘reference-guided’, respectively.
|
| 130 |
+
|
| 131 |
+
Since the two ways of guidance are fundamentally different, we evaluated them against two sets of baselines: Our reference-guided image generation was compared to Mokady et al. (2020) and StarGAN v2, because both of them can perform a reference-guided translation. Note that Mokady et al. (2020) can only translate between two domains while StarGAN v2 and DT-GAN can achieve multi-domain translation within a single model. Images generated through the latent-guided part of DT-GAN were compared to state-of-the-art GANs in image synthesis: BigGAN (Brock et al., 2019) and StyleGAN v2 (Karras et al., 2020b). We set BigGAN to condition on defect types during training while StyleGAN v2 was trained unconditionally. All baselines were trained from scratch with the public implementations provided by the authors1.
|
| 132 |
+
|
| 133 |
+
# 4.1.1 QUANTITATIVE EVALUATION
|
| 134 |
+
|
| 135 |
+
Metrics. We employed the commonly used frechet inception distance (FID) (Heusel et al., 2017) to evaluate both the visual quality and the diversity of the generated images. We also report the kernel inception distance (KID) (Binkowski et al., 2018) which is a more stable metric for small sets of images like our SDI dataset. Lower FID and KID scores indicate better performance.
|
| 136 |
+
|
| 137 |
+
Both scores are shown in Table 1. We observe that methods like BigGAN and StyleGAN v2, which perform defect synthesis purely based on latent codes, generally provide unsatisfactory results on the SDI dataset, presumably due to the small number of defective samples that were available. These methods then struggle to capture the complex and irregular patterns of defects. We also experimented with augmentation methods for GAN training (Karras et al., 2020a; Zhao et al., 2020) but did not find a consistent improvement (see Appendix E.2). We thus only report the best scores.
|
| 138 |
+
|
| 139 |
+
Reference-guided synthesis methods like Mokady et al. (2020) and StarGAN v2 seem to generate more realistic images. The scores of StarGAN v2 on a single product are omitted here because generating images with specified background is not possible due to its network design—the product type changes in output images, which we refer to as ‘identity-shift’. As seen in Table 1, our method achieves better scores in all cases. We believe this is due to the fact that our method allows free combination of foreground defects and backgrounds, making the generated images more diverse even with a small number of training samples.
|
| 140 |
+
|
| 141 |
+
Table 1: Quantitative comparison of DT-GAN with baseline image synthesis methods using FID and KID. Note that the reported values are not comparable between columns, because they were calculated on different training sets.
|
| 142 |
+
|
| 143 |
+
<table><tr><td rowspan="2">Method</td><td colspan="4">FID↓</td><td colspan="4">KID↓</td></tr><tr><td>A</td><td>B</td><td>C</td><td>All</td><td>A</td><td>B</td><td>C</td><td>All</td></tr><tr><td>Mokady (2020)</td><td>68.69</td><td>66.90</td><td>36.21</td><td>58.63</td><td>0.050</td><td>0.036</td><td>0.030</td><td>0.036</td></tr><tr><td>StarGAN v2</td><td>1</td><td></td><td>1</td><td>37.70</td><td>-</td><td>1</td><td>1</td><td>0.013</td></tr><tr><td>StyleGAN v2</td><td>90.10</td><td>52.95</td><td>138.09</td><td>35.34</td><td>0.072</td><td>0.027</td><td>0.186</td><td>0.013</td></tr><tr><td>BigGAN + DiffAug</td><td>218.74</td><td>134.41</td><td>270.89</td><td>155.88</td><td>0.220</td><td>0.121</td><td>0.378</td><td>0.099</td></tr><tr><td>Ours</td><td>58.43</td><td>36.44</td><td>22.68</td><td>29.73</td><td>0.025</td><td>0.013</td><td>0.012</td><td>0.009</td></tr></table>
|
| 144 |
+
|
| 145 |
+
# 4.1.2 QUALITATIVE EVALUATION
|
| 146 |
+
|
| 147 |
+
We present a qualitative comparison with the baseline methods in latent-guided image synthesis in Figure 3. To make a fair comparison, we trained StyleGAN v2 and BigGAN on each product separately to have control on background products. Note however, that images from DT-GAN were always obtained from a single model. We can see that some generated samples from StyleGAN v2 do not contain clear defects, and samples from BigGAN present abnormal grid patterns. Both methods do not take images as inputs but generate synthetic images according to a given latent code which contains information for both FG and BG. This conditioning leads to limited diversity in the output images. On the other hand, StarGAN v2 performs translation based on input images but suffers from the same entanglement issue. Thus, it fails to preserve the background, which results in artifacts or identity-shift in its outputs. Our network architecture that disentangles foreground and background seems to mitigate these issues. See Appendix E.4 for more images.
|
| 148 |
+
|
| 149 |
+

|
| 150 |
+
Figure 3: Qualitative comparison of latent-guided image synthesis results. In each subfigure: on the left, defective images are fully generated from random noise. On the right, random defects are synthesized onto given normal samples. Note that BigGAN\* denotes it was trained with DiffAug.
|
| 151 |
+
|
| 152 |
+

|
| 153 |
+
Figure 4: Qualitative comparison of reference-guided image synthesis results on the SDI dataset. Each method transforms the given source images into target foreground domains (e.g., Scratches) with the styles and contents extracted from the reference images.
|
| 154 |
+
|
| 155 |
+
Also for reference-guided image synthesis, where we used different background and foreground reference images as illustrated in Figure 4, only our method produces high quality images with preserved background from the source and transferred foreground defect from the reference.
|
| 156 |
+
|
| 157 |
+
Ablation study. We visually demonstrate the effect of each component we added to DT-GAN compared to StarGAN v2 in Figure 5, using the examples of both latent- and reference-guided image synthesis from Normal to Scratches. The quantitative evaluation can be found in Appendix E.3.
|
| 158 |
+
|
| 159 |
+
Column (a) corresponds to StarGAN v2 and highlights the drawback of entangled FG/BG again (i.e. the identity-shift in the background). We first tackle this problem by modeling the style code and foreground content explicitly and feeding them separately to the generator. This leads to a better preservation of the background structure in column (b) for the reference-guided subnetwork, but not for the latent-guided synthesis on the bottom of Figure 5. Thus, we add a foreground classifier in the discriminator in (c) to ensure the output image contains the desired foreground content (scratch). Similarly, we introduce a background classifier to the discriminator in column (d). Note that the additional product type labels can be acquired automatically from production lines.
|
| 160 |
+
|
| 161 |
+
For column (e), we add the separate decoders for foreground and background in the generator which are fused only in the end. This enhances the preservation of background characteristics like lighting even more. Imposing an additional penalty for foreground content extracted from a normal sample as described in Section 3.1 leads to another visual improvement of the foreground edges for reference-guided synthesis in column (f). Finally, inspired by StyleGAN, we incorporate adaptive noise injection to the mapping network, which significantly boosts the performance of our latentguided image synthesis as shown in column (g).
|
| 162 |
+
|
| 163 |
+
Styling. We visually demonstrate the effect of style codes in our method by randomly sampling those and combining them with fixed reference background and foreground images in Figure 6, where a variety of artistic styles can be seen on the output columns.
|
| 164 |
+
|
| 165 |
+

|
| 166 |
+
Figure 5: Ablation study. (a) The baseline StarGAN v2. (b) $^ +$ Style-Content branches. (c) $^ +$ Foreground classifier. (d) $^ +$ Background classifier. (e) $^ +$ Separately decoding foreground and background in $G$ . (f) $^ +$ Anchor foreground domain (e.g. Normal). (g) $^ +$ Noise injection in Mapping Network.
|
| 167 |
+
|
| 168 |
+

|
| 169 |
+
Figure 6: Visual effect of randomly sampled style codes on fixed pairs of reference background (Source) and foreground (Content) images.
|
| 170 |
+
|
| 171 |
+
# 4.2 DT-GAN FOR DATA AUGMENTATION
|
| 172 |
+
|
| 173 |
+
We also evaluated our method as a data augmentation method for defect classification on the SDI dataset. We defined one task ‘general’, where the classifier was trained on images from all products at once, while task ‘single product’ only used the subset of images for one product.
|
| 174 |
+
|
| 175 |
+
Besides, we incrementally varied the amount of real Normal data available for classifier training: 4500, 6600, 12000 and 18600. In the case of defective images, all of them were always used due to the small amount unless otherwise specified. As backbone we used a ResNet-50 (He et al., 2016a) with ImageNet pretrained weights. For experiments with synthetic data, we attached an auxiliary domain classifier to the network through a Gradient Reversal Layer (Ganin & Lempitsky, 2015).
|
| 176 |
+
|
| 177 |
+
Table 2: Quantitative comparison of the baseline methods on defect classification task at the scale of 12000 images/class. The reported values are the achieved error rates $( \% )$ over five runs.
|
| 178 |
+
|
| 179 |
+
<table><tr><td>Method</td><td>ResNet-50</td><td>EfficientNet-b4</td></tr><tr><td>No-Aug</td><td>21.64±1.24</td><td>12.06±0.64</td></tr><tr><td>Trad-Aug</td><td>12.58±0.81</td><td>9.33±0.73</td></tr><tr><td>Mokady (2020)</td><td>11.11±1.19</td><td>13.26±1.13</td></tr><tr><td>StarGAN v2</td><td>13.07±1.30</td><td>12.25±0.79</td></tr><tr><td>StyleGAN v2</td><td>11.55±1.79</td><td>11.68±0.76</td></tr><tr><td>BigGAN+DiffAug</td><td>11.45±0.61</td><td>12.06±0.50</td></tr><tr><td>Ours</td><td>9.9±0.69</td><td>9.14±1.02</td></tr></table>
|
| 180 |
+
|
| 181 |
+
Since the SDI dataset is highly imbalanced, we oversampled the minority classes (Ling et al., 1998) unless the data was balanced through synthetic images. Additionally, we always applied traditional data augmentation techniques like random horizontal flips, jittering and lighting (Shorten & Khoshgoftaar, 2019) except where noted. All following results were evaluated by the achieved error rates over five runs with different random seeds.
|
| 182 |
+
|
| 183 |
+
Effectiveness of synthetic data. We first compare classifier performance for no augmentation (NoAug), traditional data augmentation (Trad-Aug), and a combination of traditional augmentation with synthetic images for GAN methods including DT-GAN. We also introduce a stronger backbone, EfficientNet-b4 (Tan & Le, 2019), to demonstrate that our results are not confined to a specific network. Table 2 shows that our method is the only one that improves performance for both backbones, presumably due to the combination of high visual image quality and diversity in our samples.
|
| 184 |
+
|
| 185 |
+
Table 3: Experimental results on using different amount of synthetic images generated by DT-GAN to train classifiers. The left-most column stands for number of samples per class to be classified. The training set of the baselines is balanced by oversampling while ours is by synthetic images.
|
| 186 |
+
|
| 187 |
+
<table><tr><td rowspan="2">Dataset Size</td><td colspan="2">20A</td><td colspan="2">All</td></tr><tr><td>Trad-Aug</td><td>Ours</td><td>Trad-Aug</td><td>Ours</td></tr><tr><td>4500</td><td>15.55±0.63</td><td>14.28±1.25</td><td>12.75±0.61</td><td>11.04±0.76</td></tr><tr><td>6600</td><td>16.69±0.76</td><td>14.41±3.12</td><td>13.07±1.57</td><td>10.60±0.48</td></tr><tr><td>12000</td><td>16.95±1.02</td><td>14.22±1.53</td><td>12.05±0.81</td><td>9.90±0.69</td></tr><tr><td>18600</td><td>16.12±2.19</td><td>15.36±0.86</td><td>12.37±0.32</td><td>10.21±0.96</td></tr></table>
|
| 188 |
+
|
| 189 |
+
Impact of dataset size. Motivated by the limited availability of data in real-world production scenarios, we therefore evaluated DT-GAN for data augmentation on a subset of the full SDI dataset (All), which only contains 20 defective samples in product A for each defect type (20A). In this case, DT-GAN was also trained on the reduced subset. As shown in Table 3, there is a clear improvement when synthetic images from DT-GAN are used as data augmentation, even for the extremely limited data subset. Further results on single product classifiers can be found in Appendix E.1.
|
| 190 |
+
|
| 191 |
+
Table 4: Cross-domain effect on single product classifiers trained with reference-guided synthetic images at the scale of 12000 images/class.
|
| 192 |
+
|
| 193 |
+
<table><tr><td></td><td>Trad-Aug</td><td>vA</td><td>VB</td><td>vC</td><td>vABC</td></tr><tr><td>A</td><td>13.81±2.36</td><td>11.81±2.65</td><td>12.72±2.87</td><td>11.99±1.63</td><td>11.09±3.49</td></tr><tr><td>B</td><td>6.80±1.64</td><td>6.40±1.34</td><td>6.60±1.52</td><td>6.59±1.34</td><td>5.60±1.34</td></tr><tr><td>C</td><td>16.57±3.20</td><td>13.14±2.81</td><td>11.23±0.80</td><td>14.85±1.73</td><td>11.42±0.96</td></tr></table>
|
| 194 |
+
|
| 195 |
+
Cross-domain effect. We hypothesized that limited data can be counteracted by transferring defects across multiple background products, if there are at least some defects that occur on multiple products (See Appendix E.1 for further discussion). We tested this approach by comparing the performance of classifiers trained on synthetic images with defects from a specific source (vA, vB, vC) to classifiers trained on images with defects from all products (vABC). As we can see in Table 4, the best performances are reached by the models that take over defects from other products. We interpret this as support for our hypothesis and its practical usefulness.
|
| 196 |
+
|
| 197 |
+
# 5 CONCLUSION
|
| 198 |
+
|
| 199 |
+
We propose a novel method, DT-GAN, which allows diverse defect synthesis both by generating from randomly sampled noise and by following the guidance of given reference images. Due to explicit style-content separation and FG/BG disentanglement, DT-GAN achieves higher image fidelity, better variance in defects and full control over background and foreground while being sample-efficient. We demonstrated the feasibility and benefits of DT-GAN on a real industrial defect classification task and the results show our method provides consistent gains even with limited data and boosts the performance of classifiers compared to state-of-the-art image synthesis methods. For future investigation, we aim to represent defects more explicitly (e.g., localization) to improve the explainability of the model and also enhance the model transferability to unseen products.
|
| 200 |
+
|
| 201 |
+
# REPRODUCIBILITY STATEMENT
|
| 202 |
+
|
| 203 |
+
We aim for full reproducibility by publishing the source code and dataset with the final version of the paper. Besides, we provide descriptions of the training details in Appendix B, the evaluation setup in Appendix C and the network architecture in Appendix D.
|
| 204 |
+
|
| 205 |
+
REFERENCES
|
| 206 |
+
Paul Bergmann, Michael Fauser, David Sattlegger, and Carsten Steger. Mvtec ad — a comprehensive real-world dataset for unsupervised anomaly detection. In 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 9584–9592, 2019. doi: 10.1109/CVPR.2019.00982.
|
| 207 |
+
Mikolaj Binkowski, Danica J. Sutherland, Michael Arbel, and A. Gretton. Demystifying MMD GANs. ArXiv, abs/1801.01401, 2018.
|
| 208 |
+
Andrew Brock, Jeff Donahue, and K. Simonyan. Large scale gan training for high fidelity natural image synthesis. ArXiv, abs/1809.11096, 2019.
|
| 209 |
+
Yuhua Chen, Wen Li, Christos Sakaridis, Dengxin Dai, and Luc Van Gool. Domain adaptive faster rcnn for object detection in the wild. 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 3339–3348, 2018.
|
| 210 |
+
Yunjey Choi, Youngjung Uh, Jaejun Yoo, and Jung-Woo Ha. Stargan v2: Diverse image synthesis for multiple domains. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), June 2020.
|
| 211 |
+
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.
|
| 212 |
+
Yaroslav Ganin and Victor Lempitsky. Unsupervised domain adaptation by backpropagation. In Francis Bach and David Blei (eds.), Proceedings of the 32nd International Conference on Machine Learning, volume 37 of Proceedings of Machine Learning Research, pp. 1180–1189, Lille, France, 07–09 Jul 2015. PMLR. URL https://proceedings.mlr.press/v37/ ganin15.html.
|
| 213 |
+
Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial networks. In NeurIPS, 2014.
|
| 214 |
+
Kaiming He, X. Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 770–778, 2016a.
|
| 215 |
+
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Identity mappings in deep residual networks, 2016b. URL http://arxiv.org/abs/1603.05027. cite arxiv:1603.05027Comment: ECCV 2016 camera-ready.
|
| 216 |
+
Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and S. Hochreiter. Gans trained by a two time-scale update rule converge to a local nash equilibrium. In NIPS, 2017.
|
| 217 |
+
Xun Huang and Serge Belongie. Arbitrary style transfer in real-time with adaptive instance normalization. In Proceedings of the IEEE International Conference on Computer Vision (ICCV), Oct 2017.
|
| 218 |
+
Xun Huang, Ming-Yu Liu, Serge J. Belongie, and J. Kautz. Multimodal unsupervised image-toimage translation. ArXiv, abs/1804.04732, 2018.
|
| 219 |
+
Phillip Isola, Jun-Yan Zhu, Tinghui Zhou, and Alexei A. Efros. Image-to-image translation with conditional adversarial networks. 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 5967–5976, 2017.
|
| 220 |
+
Justin Johnson, Alexandre Alahi, and Li Fei-Fei. Perceptual losses for real-time style transfer and super-resolution, 2016.
|
| 221 |
+
|
| 222 |
+
Tero Karras, Miika Aittala, Janne Hellsten, Samuli Laine, Jaakko Lehtinen, and Timo Aila. Training generative adversarial networks with limited data, 2020a.
|
| 223 |
+
|
| 224 |
+
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 (CVPR), June 2020b.
|
| 225 |
+
|
| 226 |
+
Alex Krizhevsky and Geoffrey Hinton. Learning multiple layers of features from tiny images. Technical Report 0, University of Toronto, Toronto, Ontario, 2009.
|
| 227 |
+
|
| 228 |
+
Christian Ledig, Lucas Theis, Ferenc Huszar, 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 CVPR, 2017.
|
| 229 |
+
|
| 230 |
+
Charles Ling, , Charles X. Ling, and Chenghui Li. Data mining for direct marketing: Problems and solutions. In In Proceedings of the Fourth International Conference on Knowledge Discovery and Data Mining (KDD-98, pp. 73–79. AAAI Press, 1998.
|
| 231 |
+
|
| 232 |
+
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.
|
| 233 |
+
|
| 234 |
+
Mario Luciˇ c, Michael Tschannen, Marvin Ritter, Xiaohua Zhai, Olivier Bachem, and Sylvain Gelly. ´ High-fidelity image generation with fewer labels. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pp. 4183–4192. PMLR, 09–15 Jun 2019. URL https://proceedings.mlr.press/v97/lucic19a.html.
|
| 235 |
+
|
| 236 |
+
Liqian Ma, Xu Jia, Stamatios Georgoulis, Tinne Tuytelaars, and Luc Van Gool. Exemplar guided unsupervised image-to-image translation with semantic consistency. In ICLR, 2019.
|
| 237 |
+
|
| 238 |
+
Qi Mao, Hsin-Ying Lee, Hung-Yu Tseng, Siwei Ma, and Ming-Hsuan Yang. Mode seeking generative adversarial networks for diverse image synthesis. 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 1429–1437, 2019a.
|
| 239 |
+
|
| 240 |
+
Qi Mao, Hsin-Ying Lee, Hung-Yu Tseng, Siwei Ma, and Ming-Hsuan Yang. Mode seeking generative adversarial networks for diverse image synthesis. In CVPR, 2019b.
|
| 241 |
+
|
| 242 |
+
Ron Mokady, Sagie Benaim, Lior Wolf, and Amit Bermano. Masked based unsupervised content transfer. In International Conference on Learning Representations, 2020. URL https:// openreview.net/forum?id $=$ BJe-91BtvH.
|
| 243 |
+
|
| 244 |
+
Henry Y. T. Ngan, Grantham K. H. Pang, and Nelson H. C. Yung. Review article: Automated fabric defect detection-a review. Image Vision Comput., 29(7):442–458, June 2011. ISSN 0262- 8856. doi: 10.1016/j.imavis.2011.02.002. URL https://doi.org/10.1016/j.imavis. 2011.02.002.
|
| 245 |
+
|
| 246 |
+
Shuanlong Niu, Bin Li, Xinggang Wang, and Hui Lin. Defect image sample generation with gan for improving defect recognition. IEEE Transactions on Automation Science and Engineering, 17(3):1611–1622, 2020. doi: 10.1109/TASE.2020.2967415.
|
| 247 |
+
|
| 248 |
+
Taesung Park, Ming-Yu Liu, Ting-Chun Wang, and Jun-Yan Zhu. Semantic image synthesis with spatially-adaptive normalization. In CVPR, 2019.
|
| 249 |
+
|
| 250 |
+
Adam Paszke, Sam Gross, Soumith Chintala, Gregory Chanan, Edward Yang, Zach DeVito, Zeming Lin, Alban Desmaison, Luca Antiga, and Adam Lerer. Automatic differentiation in pytorch. 2017.
|
| 251 |
+
|
| 252 |
+
Deepak Pathak, Philipp Krahenb ¨ uhl, Jeff Donahue, Trevor Darrell, and Alexei A. Efros. Context ¨ encoders: Feature learning by inpainting. 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 2536–2544, 2016.
|
| 253 |
+
|
| 254 |
+
Sebastian Ruder. An overview of gradient descent optimization algorithms. arXiv preprint arXiv:1609.04747, 2016.
|
| 255 |
+
|
| 256 |
+
Connor Shorten and T. Khoshgoftaar. A survey on image data augmentation for deep learning. Journal of Big Data, 6:1–48, 2019.
|
| 257 |
+
|
| 258 |
+
Mingxing Tan and Quoc Le. EfficientNet: Rethinking model scaling for convolutional neural networks. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pp. 6105–6114. PMLR, 09–15 Jun 2019. URL https://proceedings.mlr. press/v97/tan19a.html.
|
| 259 |
+
|
| 260 |
+
Dingdong Yang, Seunghoon Hong, Yunseok Jang, Tiangchen Zhao, and Honglak Lee. Diversitysensitive conditional generative adversarial networks. In ICLR, 2019.
|
| 261 |
+
|
| 262 |
+
Gongjie Zhang, Kaiwen Cui, Tzu-Yi Hung, and Shijian Lu. Defect-gan: High-fidelity defect synthesis for automated defect inspection. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision (WACV), pp. 2524–2534, January 2021.
|
| 263 |
+
|
| 264 |
+
Shengyu Zhao, Zhijian Liu, Ji Lin, Jun-Yan Zhu, and Song Han. Differentiable augmentation for data-efficient gan training, 2020.
|
| 265 |
+
|
| 266 |
+
Jun-Yan Zhu, Taesung Park, Phillip Isola, and Alexei A. Efros. Unpaired image-to-image translation using cycle-consistent adversarial networks. In Proceedings of the IEEE International Conference on Computer Vision (ICCV), Oct 2017a.
|
| 267 |
+
|
| 268 |
+
Jun-Yan Zhu, Richard Zhang, Deepak Pathak, Trevor Darrell, Alexei A. Efros, O. Wang, and E. Shechtman. Toward multimodal image-to-image translation. In NIPS, 2017b.
|
| 269 |
+
|
| 270 |
+
# A THE SURFACE DEFECT INSPECTION DATASET
|
| 271 |
+
|
| 272 |
+
The Surface Defect Inspection (SDI) dataset consists of 20,414 images at $1 2 8 \times 1 2 8$ resolution. It contains three background domains—product A, product $\mathbf { B }$ and product C, each can be further classified into three foreground domains—Normal, Scratches and Spots. Figure 7 shows example images of the SDI dataset. To be noticed that the dataset is highly imbalanced not only between normal and defective samples but also between different products as shown in Table 5. This sets a more challenging task when training deep neural networks like GANs and downstream classifiers.
|
| 273 |
+
|
| 274 |
+
For each foreground and background domains, we randomly select 50 images for a joint validation/test set, which is then further split into separate sets in the ratio of 3:7, and use all remaining images as training sets for GAN and classifier training. We present the distribution of the training set when training DT-GAN in Table 6. Note that the normal samples used in GAN training are only a subset of all available samples in Normal and we keep the rest of them for generating defective samples at test time. For classifier training, we show the statistics in Table 7, where the number of normal samples involved in classifier training increase incrementally. The validation set is used to select the best model during classifier training while the test set is left untouched until the final evaluation. Both of the validation and test set are inaccessible by DT-GAN.
|
| 275 |
+
|
| 276 |
+
Table 5: Distribution of the full SDI dataset.
|
| 277 |
+
|
| 278 |
+
<table><tr><td></td><td colspan="3">Overview</td></tr><tr><td></td><td>A</td><td>B</td><td>C</td></tr><tr><td>Normal</td><td>6250</td><td>6250</td><td>6250</td></tr><tr><td>Scratches</td><td>340</td><td>167</td><td>121</td></tr><tr><td>Spots</td><td>108</td><td>670</td><td>258</td></tr></table>
|
| 279 |
+
|
| 280 |
+
Table 6: The training set for DT-GAN and the baseline image synthesis methods.
|
| 281 |
+
|
| 282 |
+
<table><tr><td></td><td colspan="3">Overview</td></tr><tr><td></td><td>A</td><td>B</td><td>C</td></tr><tr><td>Normal</td><td>700</td><td>700</td><td>700</td></tr><tr><td>Scratches</td><td>290</td><td>117</td><td>71</td></tr><tr><td>Spots</td><td>58</td><td>620</td><td>208</td></tr></table>
|
| 283 |
+
|
| 284 |
+
Table 7: The training, validation and test set for classifier training, where $N$ increases incrementally—1500, 2200, 4000 and 6200.
|
| 285 |
+
|
| 286 |
+
<table><tr><td></td><td colspan="3">Train</td><td colspan="3">Validation</td><td colspan="3">Test</td></tr><tr><td></td><td>A</td><td>B</td><td>C</td><td>A</td><td>B</td><td>C</td><td>A</td><td>B</td><td>C</td></tr><tr><td>Normal</td><td>N</td><td>N</td><td>N</td><td>12</td><td>18</td><td>15</td><td>38</td><td>32</td><td>35</td></tr><tr><td>Scratches</td><td>290</td><td>117</td><td>71</td><td>14</td><td>16</td><td>15</td><td>36</td><td>34</td><td>35</td></tr><tr><td>Spots</td><td>58</td><td>620</td><td>208</td><td>14</td><td>16</td><td>15</td><td>36</td><td>34</td><td>35</td></tr></table>
|
| 287 |
+
|
| 288 |
+
# B TRAINING DETAILS
|
| 289 |
+
|
| 290 |
+
DT-GAN. We follow the training scheme as described in StarGAN v2 with minor modifications. To fit the model on a single Nvidia GTX TITAN X, the batch size is reduced to four while the model is still trained for 100,000 iterations. The training time is about three and a half days on the dedicated GPU with the modified network architecture2 and loss functions mentioned in Section 3 in PyTorch (Paszke et al., 2017). We set $\lambda _ { \mathrm { s t y } } = 1$ , $\lambda _ { \mathrm { d s } } = 1$ , $\lambda _ { \mathrm { c y c } } = 1$ , $\lambda _ { \mathrm { c o n . c y c } } = 1$ , $\lambda _ { \mathrm { c l s } } = 1$ and $\lambda _ { \mathrm { B G . c l s } } = 1$ for the SDI dataset. All other design choices remain the same as in StarGAN v2.
|
| 291 |
+
|
| 292 |
+
Classifiers. We train all the classifiers that use ResNet-50 as backbone for 100 epochs with the SGD optimizer (Ruder, 2016) and batch size 256. The initial learning rate is 0.001, momentum is 0.9 and weight decay is 1e-4. A learning rate scheduler is set to reduce the learning rate by factor of 0.1 when the validation loss stops decreasing for 5 epochs. The same setting also applies to EfficientNet-b4, except the batch size is reduced to 128. Although DT-GAN can synthesize realistic defective samples, we notice that there still exists a domain gap between the generated samples and the real samples. To explore the full potential of the generated samples, we attach an auxiliary source classifier to distinguish between synthetic and real samples. Then, this classifier is connected to the backbone (e.g. ResNet-50) through a Gradient Reversal Layer. With the help of the Gradient Reversal Layer, the backbone is forced to extract the shared features between synthetic and real samples, which ensures all training samples are effectively learned.
|
| 293 |
+
|
| 294 |
+

|
| 295 |
+
Figure 7: Overview of the SDI dataset.
|
| 296 |
+
|
| 297 |
+
We design a two-layer perceptron that connects to the average pooling layer in ResNet-50 as shown in Figure 8. Note that the usual fully connected layer after the average pooling in ResNet-50 remains the same and is not affected by the extra branch we added. Inspired by Chen et al. (2018), a threelayer perceptron is used for EfficientNet-b4 instead as shown in Figure 9. Its layers are initialized with a random normal distribution, where the standard deviation is set to 0.01 for the first two layers and 0.05 for the output layer. The biases for all layers are set to 0.
|
| 298 |
+
|
| 299 |
+

|
| 300 |
+
Figure 8: ResNet-50 with GRL.
|
| 301 |
+
|
| 302 |
+

|
| 303 |
+
Figure 9: EfficientNet-b4 with GRL.
|
| 304 |
+
|
| 305 |
+
# C EVALUATION SETUP
|
| 306 |
+
|
| 307 |
+
Generated samples from DT-GAN. DT-GAN requires images as input for generating synthetic data. At test time, we translated each Normal image in the SDI dataset into four defective images: two with Scratches and two with Spots. The translations were performed by two subnetworks: by the mapping network $M$ using random noise (‘latent-guided’) and by the style-content encoder $E$ using a reference image (‘reference-guided’). We first randomly sampled one latent code for each defective foreground domain. Similarly, we also randomly sampled one reference image from the training set for each defective foreground domain. The corresponding style codes and defect contents were then produced by the two subnetworks respectively and fed to the generator for target image generation.
|
| 308 |
+
|
| 309 |
+
We conducted classification experiments separately on images generated from the two subnetworks and a mixture set of both (i.e. $50 \%$ from each subnetwork). Experiments show consistent gains of using synthetic images generated from DT-GAN (Table 8). We observe that the latent-guided synthetic images in general perform better than the reference-guided one, while the mixture set provides more stable results with regard to the standard deviation. Presumably the mixture set benefits from the combination of samples from reference-guided synthesis, which are well aligned with the original defect distribution, and the samples from latent-guided synthesis, i.e. from random noise, which adds novel but plausible defects to the dataset. In the main text, we report the results of the mixture set for all experiments, including the quantitative evaluation of DT-GAN.
|
| 310 |
+
|
| 311 |
+
Table 8: Classification results with regard to the synthetic images generated from the two subnetworks and the mixture set.
|
| 312 |
+
|
| 313 |
+
<table><tr><td rowspan="2">Dataset Size</td><td colspan="4">All</td></tr><tr><td>Trad-Aug</td><td>Latent</td><td>Reference</td><td>Mix</td></tr><tr><td>4500</td><td>12.75±0.61</td><td>10.72±0.96</td><td>11.48±0.88</td><td>11.04±0.76</td></tr><tr><td>6600</td><td>13.07±1.57</td><td>10.34±1.86</td><td>11.55±1.64</td><td>10.60±0.48</td></tr><tr><td>12000</td><td>12.05±0.81</td><td>9.90±1.26</td><td>10.40±0.99</td><td>9.90±0.69</td></tr><tr><td>18600</td><td>12.37±0.32</td><td>11.04±1.26</td><td>12.12±0.75</td><td>10.21±0.96</td></tr></table>
|
| 314 |
+
|
| 315 |
+
Frechet inception distance (FID) and Kernel inception distance (KID). ´ We used the feature vectors from the last average pooling layer of the ImageNet pretrained Inception-V3 to calculate both scores. For each test image from the Normal domain, we translated it into a synthetic defective image of each defect domain. The style codes and contents for the translation were acquired in two ways: by randomly sampling from the standard normal distribution and by randomly sampling a reference image from the train set of a defect domain. To calculate the FID and KID score, we generated 4000 defective samples per product per defect domain for each way of guidance, and formed the mixture set by randomly sampling 2000 images per product per defect domain from each way. The reported FID and KID scores were then computed between the defective images in the training set and the mixture set of synthetic defective images. The same procedure was applied when computing scores on single product subsets of the SDI dataset. For example, for product A, we calculated the scores between the defective image of product A in the training set and the mixture set of synthetic defective images of product A.
|
| 316 |
+
|
| 317 |
+
# D NETWORK ARCHITECTURE
|
| 318 |
+
|
| 319 |
+
In this section, we provide the architectural details of all four modules in DT-GAN.
|
| 320 |
+
|
| 321 |
+
Table 9: Generator architecture.
|
| 322 |
+
|
| 323 |
+
<table><tr><td colspan="7">(a)Encoder</td></tr><tr><td>Layer</td><td colspan="2">Resample</td><td>Norm</td><td colspan="3">Output Shape</td></tr><tr><td>Image x</td><td colspan="2"></td><td>-</td><td colspan="3">128 × 128×3</td></tr><tr><td>Conv 1×1</td><td colspan="2"></td><td>-</td><td colspan="3">128 ×128 ×128</td></tr><tr><td>ResBlk</td><td colspan="2">AvgPool</td><td>IN</td><td colspan="3">64× 64×256</td></tr><tr><td>ResBlk</td><td colspan="2">AvgPool</td><td>IN</td><td colspan="3">32 × 32 × 512</td></tr><tr><td>ResBlk</td><td colspan="2">AvgPool</td><td>IN</td><td colspan="3">16 × 16 × 512</td></tr><tr><td>ResBlk</td><td colspan="2"></td><td>IN</td><td colspan="3">16 ×16× 512</td></tr><tr><td>ResBlk</td><td colspan="2"></td><td>IN</td><td colspan="3">16 ×16 × 512</td></tr><tr><td colspan="3">(b) Background Decoder</td><td colspan="5">(c) Foreground Decoder</td></tr><tr><td>Layer</td><td>Resample</td><td>Norm</td><td> Output Shape</td><td>Layer</td><td>Resample Norm</td><td>Output Shape</td></tr><tr><td>Input</td><td></td><td>-</td><td>16 × 16 × 448</td><td>Input ResBlk</td><td></td><td>16 × 16 × 64</td></tr><tr><td>ResBlk</td><td></td><td>IN 16 ×16× 448 16 ×16× 512</td><td>ResBlk</td><td></td><td>AdaIN</td><td>16 ×16× 64</td></tr><tr><td>ResBlk</td><td></td><td>IN</td><td></td><td>=</td><td>AdaIN</td><td>16 × 16 × 256</td></tr><tr><td>ResBlk</td><td>=</td><td>IN</td><td>16 ×16 × 512</td><td>ResBlk</td><td>AdaIN</td><td>16 ×16× 256</td></tr><tr><td>ResBlk</td><td>Upsample</td><td>IN</td><td>32 × 32×512</td><td>ResBlk Upsample ResBlk</td><td>AdaIN</td><td>32 × 32 × 256</td></tr><tr><td>ResBlk ResBlk</td><td>Upsample Upsample</td><td>IN IN</td><td>64 × 64× 256 128 × 128× 448</td><td>Upsample</td><td>AdaIN</td><td>64×64×128</td></tr><tr><td></td><td></td><td></td><td>ResBlk</td><td>Upsample</td><td>AdaIN</td><td>128 ×128 × 64</td></tr><tr><td colspan="7">(d) Fusion</td></tr><tr><td>Layer</td><td colspan="2">Resample</td><td colspan="2">Norm</td><td colspan="2">Output Shape</td></tr><tr><td>Input</td><td colspan="2"></td><td colspan="2"></td><td colspan="2">128 × 128 × (448 + 64)</td></tr><tr><td>Conv 1×1</td><td colspan="2"></td><td colspan="2"></td><td colspan="2">128 × 128× 3</td></tr></table>
|
| 324 |
+
|
| 325 |
+
Table 10: Mapping network architecture.
|
| 326 |
+
|
| 327 |
+
<table><tr><td>Layer</td><td></td><td>Activation</td><td></td><td></td><td></td><td>Output Shape</td></tr><tr><td>Latent z</td><td></td><td>=</td><td></td><td></td><td></td><td>16</td></tr><tr><td>Linear</td><td></td><td>ReLU</td><td></td><td></td><td></td><td>512</td></tr><tr><td>Linear</td><td></td><td>ReLU</td><td></td><td></td><td></td><td>512</td></tr><tr><td>Linear</td><td></td><td>ReLU</td><td></td><td></td><td></td><td>512</td></tr><tr><td>Linear</td><td></td><td>ReLU</td><td></td><td></td><td></td><td>512</td></tr><tr><td colspan="3">(b) Style Code</td><td colspan="5">(c) Content</td></tr><tr><td>Layer</td><td>Activation</td><td> Output Shape</td><td>Layer</td><td>Resample Activation</td><td></td><td>Noise</td><td> Output Shape</td></tr><tr><td>Input</td><td>=</td><td>512</td><td>Input</td><td></td><td></td><td>=</td><td>512</td></tr><tr><td>Linear</td><td>ReLU</td><td>512</td><td>Reshape</td><td></td><td>-</td><td>-</td><td>1×1×512</td></tr><tr><td>Linear</td><td>ReLU</td><td>512</td><td>ResBlk</td><td>Upsample</td><td>IN</td><td>True</td><td>2×2×512</td></tr><tr><td>Linear</td><td>ReLU</td><td>512</td><td>ResBlk</td><td>Upsample</td><td>IN</td><td>True</td><td>4×4×512</td></tr><tr><td>Linear</td><td>1</td><td>64</td><td>ResBlk</td><td>Upsample</td><td>IN</td><td>True</td><td>8×8×256</td></tr><tr><td></td><td></td><td></td><td>ResBlk</td><td>Upsample</td><td>IN</td><td>True</td><td>16 ×16×128</td></tr><tr><td></td><td></td><td></td><td>Conv 1×1</td><td>=</td><td>IN</td><td>True</td><td>16 × 16× 64</td></tr></table>
|
| 328 |
+
|
| 329 |
+
Generator (Table 9). For the SDI dataset, the encoder part of the generator consists of three downsampling blocks and two intermediate blocks (Table 9 (a)), all of them are pre-activation residual units (He et al., 2016b). Then the encoded feature map is split channel-wise into background (Table 9 (b)) and foreground (Table 9 (c)). Both of them are then carried through separate decoders. We use the instance normalization (IN) and the adaptive instance normalization (AdaIN) as indicated. The style code is injected into all AdaIN layers to modulate the affine transformations. Note that
|
| 330 |
+
|
| 331 |
+
Table 11: Style-content encoder and discriminator architectures.
|
| 332 |
+
|
| 333 |
+
<table><tr><td colspan="6">(a)SharedLayers</td></tr><tr><td>Layer</td><td colspan="2">Resample</td><td colspan="2">Norm</td><td>Output Shape</td></tr><tr><td>Input x</td><td colspan="2"></td><td colspan="2"></td><td>128 × 128 ×3</td></tr><tr><td>Conv 1×1</td><td colspan="2">1</td><td colspan="2"></td><td>128 × 128 × 64</td></tr><tr><td>ResBlk</td><td colspan="2">AvgPool</td><td colspan="2"></td><td>64 × 64× 256</td></tr><tr><td>ResBlk</td><td colspan="2">AvgPool</td><td colspan="2"></td><td>32 × 32×512</td></tr><tr><td>ResBlk</td><td colspan="2">AvgPool</td><td colspan="2"></td><td>16 ×16 × 512</td></tr><tr><td>(b) Style Code /Discriminator and BG Classifier</td><td></td><td></td><td colspan="3">(c) Content /FG Classifier</td></tr><tr><td>Layer</td><td>Resample Norm</td><td>Output Shape</td><td>Layer</td><td>Resample Norm</td><td>Output Shape</td></tr><tr><td>Input</td><td>-</td><td>16 ×16× 512</td><td>Input</td><td></td><td>16 ×16× 512</td></tr><tr><td>ResBlk</td><td>AvgPool</td><td>8×8×512</td><td colspan="2">LReLU</td><td>16 ×16 × 512</td></tr><tr><td>ResBlk</td><td>AvgPool</td><td>4×4×512</td><td colspan="2">Conv 1×1*K</td><td>16×16×64*K</td></tr><tr><td>LReLU</td><td></td><td>4×4×512</td><td colspan="2"></td><td></td></tr><tr><td>Conv 4×4</td><td></td><td>1×1×512</td><td colspan="2"></td><td></td></tr><tr><td>LReLU</td><td></td><td>1×1×512</td><td colspan="4"></td></tr><tr><td>Reshape</td><td></td><td>512</td><td colspan="4"></td></tr><tr><td>Linear *K</td><td></td><td>D*K</td><td colspan="4"></td></tr></table>
|
| 334 |
+
|
| 335 |
+
AdaIN is only used in the foreground decoder. The outputs of both decoders are only fused in the end (Table 9 (d)).
|
| 336 |
+
|
| 337 |
+
Mapping Network (Table 10). The mapping network consists of four shared linear layers (Table 10 (a)) and two separate branches: one for generating style codes (Table 10(b)) and one for contents (Table 10(c)). Each of them is further divided into $K$ output branches, where $K$ denotes the number of domains. The dimension of the input, the output style code and the output content is set to 16, 64, and $1 6 \times 1 6 \times 6 4$ , respectively. The latent code is sampled from the standard normal distribution. Note that we apply per-pixel noise after each convolution in the content branch, which we have observed to increase the diversity of generated defects significantly (cf. Figure 5 (g)).
|
| 338 |
+
|
| 339 |
+
Style-Content Encoder (Table 11). The style-content encoder consists of a CNN (Table 11 (a)) with two branches (Table 11 (b) and (c)) as in the mapping network. Each branch has $K$ outputs, where $K$ is the number of domains. Three pre-activation residual blocks are shared among two branches, followed by a specific structure for each branch. The output dimension $D$ in Table 11 is set to 64, which denotes the dimension of the style code.
|
| 340 |
+
|
| 341 |
+
Discriminator (Table 11). The discriminator is a multi-task discriminator with two auxiliary classifiers for the foreground content and the background. The structure is almost identical to the stylecontent encoder, except $D$ is set to 1 for real/fake classification. The background classifier acts in parallel to final linear layer in Table 11 (b) and provides the logits for background classification. The foreground classifier instead acts on top of the output in Table 11 (c) and four more pre-activation residual layers are applied to encode the content into logits for foreground content classification.
|
| 342 |
+
|
| 343 |
+
# E ADDITIONAL RESULTS
|
| 344 |
+
|
| 345 |
+
# E.1 ADDITIONAL RESULTS ON THE SDI DATASET
|
| 346 |
+
|
| 347 |
+
We provide additional reference-guided image synthesis results on the SDI dataset in Figure 10. We demonstrate all the possible transfers among all foreground domains. Both style codes and contents are extracted from the reference images. To be noted that DT-GAN can append and remove foreground defects not only onto Normal samples but also to defective samples. For example, in the fifth column of Figure 10, the original scratch in the source image is removed and only the defects from the reference images are presented in the output images.
|
| 348 |
+
|
| 349 |
+
Besides, we present additional evaluations showing the effectiveness of our synthetic data according to Table 3. As seen in Table 12, the synthetic images from DT-GAN also boost the performance in single product classifiers, where the classifiers were trained on the subset of images for one product (A, B, C) instead of the full dataset (ABC).
|
| 350 |
+
|
| 351 |
+

|
| 352 |
+
Figure 10: Reference-guided image synthesis results on the SDI dataset. The first row and the first column are the real images sampled from the dataset, while the rest are synthetic images generated by the proposed DT-GAN. Our model provides translations between different foreground domains (Normal, Scratches and Spots) with styles and contents extracted from reference images while the backgrounds from source images are well preserved.
|
| 353 |
+
|
| 354 |
+
As discussed in Section 4.2, we assumed that the data-insufficiency problem can be mitigated by transferring defects across multiple background products. To examine if this assumption holds, we compared the performance of classifiers trained on synthetic images with defects from a specific source (vA, vB, vC) to classifiers trained on images with defects from all products (vABC). The results on the cross-domain effect with regard to different sizes of the training set are shown in Table 13. We again notice that using our synthetic data is beneficial. Moreover, in most cases the performance is further improved by exploiting cross-domain information (i.e. by transferring defects from other products). We interpret this as support for our assumption and the practical usefulness of our method in the real-world scenario. The case of cross-domain image synthesis when the desired combination is not presented in the training set is covered in the study on the MVTec Anomaly Detection dataset (Bergmann et al., 2019) (see Appendix E.4).
|
| 355 |
+
|
| 356 |
+
Table 12: Quantitative results for DT-GAN as a data augmentation method to train general and single product classifiers. The left-most column indicates the number of samples per class, including all images from the training set plus increasing amounts of synthetic images. In the first row, 20A refers to the case of 20 real defective samples for product A, while All refers to the full training set.
|
| 357 |
+
|
| 358 |
+
<table><tr><td rowspan="3">Dataset Size</td><td colspan="8">20A</td></tr><tr><td colspan="2">A</td><td colspan="2">B</td><td colspan="2">C</td><td colspan="2">ABC</td></tr><tr><td>Trad-Aug</td><td>Ours</td><td>Trad-Aug</td><td>Ours</td><td>Trad-Aug</td><td>Ours</td><td>Trad-Aug</td><td>Ours</td></tr><tr><td>4500</td><td>35.09±2.62 27.64±3.12</td><td></td><td>7.8±1.48</td><td>5.6±1.67</td><td></td><td></td><td>15.24±1.90 13.14±1.7015.55±0.63 14.28±1.25</td><td></td></tr><tr><td>6600</td><td>39.64±2.28 27.64±1.65</td><td></td><td>8.8±1.64</td><td>6.2±1.64</td><td>15.81±1.731</td><td></td><td></td><td>12.38±1.6516.69±0.76 14.41±3.12</td></tr><tr><td>12000</td><td>34.18±4.39 28.55±7.32</td><td></td><td>5.8±0.45</td><td>5.6±1.14</td><td></td><td></td><td>16.19±1.17 10.86±1.28 16.95±1.02 14.22±1.53</td><td></td></tr><tr><td>18600</td><td>39.45±7.06 32.55±5.04</td><td></td><td>7.2±0.84</td><td>5.2±1.10</td><td></td><td></td><td>14.86±0.85 13.14±2.06 16.12±2.19 15.36±0.86</td><td></td></tr><tr><td rowspan="3">Dataset Size</td><td colspan="8">All</td></tr><tr><td>A</td><td></td><td colspan="2">B</td><td colspan="2">C</td><td colspan="2">ABC</td></tr><tr><td>Trad-Aug</td><td>Ours</td><td>Trad-Aug</td><td></td><td>Ours</td><td>Trad-Aug</td><td>Ours</td><td>Trad-Aug</td><td>Ours</td></tr><tr><td>4500</td><td>16.00±1.041</td><td>10.18±1.75 8.79±0.45</td><td></td><td>5.60±1.51</td><td></td><td></td><td></td><td>17.13±6.62 14.09±2.2712.75±0.61 11.04±0.76</td></tr><tr><td>6600</td><td>14.90±1.38</td><td>10.54±1.22 7.60±1.51</td><td></td><td>6.80±3.11</td><td>15.23±2.33 11.42±0</td><td></td><td></td><td>13.07±1.57 10.60±0.48</td></tr><tr><td>12000</td><td>13.81±2.36</td><td>6.72±1.65 6.80±1.64</td><td></td><td>4.60±0</td><td>16.57±3.20 13.90±2.5712.05±0.81</td><td></td><td></td><td>9.90±0.69</td></tr><tr><td>18600</td><td>13.63±2.22 10.54±2.45 6.80±1.79</td><td></td><td></td><td></td><td></td><td></td><td></td><td>4.99±1.87 15.62±0.85 11.61±1.24 12.37±0.32 10.21±0.96</td></tr></table>
|
| 359 |
+
|
| 360 |
+
Table 13: Cross-domain effect on single product classifiers trained with reference-guided synthetic images at all scales. Note that here A, B and C stand for 3 products in the SDI dataset while vA, vB, vC and vABC indicate the defects are copied from which reference set.
|
| 361 |
+
|
| 362 |
+
<table><tr><td rowspan="2">Dataset Size</td><td colspan="5">A</td></tr><tr><td>Trad-Aug</td><td>vA</td><td>vB</td><td>vC</td><td>vABC</td></tr><tr><td>4500</td><td>16.00±1.04</td><td>12.90±2.61</td><td>13.08±1.65</td><td>14.90±2.46</td><td>15.27±3.49</td></tr><tr><td>6600</td><td>14.90±1.38</td><td>13.99±1.89</td><td>11.26±1.04</td><td>14.36±4.04</td><td>16.00±2.85</td></tr><tr><td>12000</td><td>13.81±2.36</td><td>11.81±2.65</td><td>12.72±2.87</td><td>11.99±1.63</td><td>11.09±3.49</td></tr><tr><td>18600</td><td>13.63±2.22</td><td>12.72±5.22</td><td>14.36±3.83</td><td>14.18±5.05</td><td>13.81±8.56</td></tr><tr><td>Dataset</td><td colspan="5">B</td></tr><tr><td>Size</td><td>Trad-Aug</td><td>vA</td><td>vB</td><td>vC</td><td>VABC</td></tr><tr><td>4500</td><td>8.79±0.45</td><td>7.80±2.15</td><td>5.60±1.14</td><td>10.19±0.84</td><td>6.79±1.30</td></tr><tr><td>6600</td><td>7.60±1.51</td><td>6.80±1.65</td><td>7.80±1.10</td><td>8.00±2.34</td><td>6.00±1.41</td></tr><tr><td>12000</td><td>6.80±1.64</td><td>6.40±1.34</td><td>6.60±1.52</td><td>6.59±1.34</td><td>5.60±1.34</td></tr><tr><td>18600</td><td>6.80±1.79</td><td>6.19±1.78</td><td>4.40±1.14</td><td>6.60±1.95</td><td>5.99±1.58</td></tr><tr><td>Dataset</td><td colspan="5">C</td></tr><tr><td>Size</td><td>Trad-Aug</td><td>vA</td><td>VB</td><td>vC</td><td>vABC</td></tr><tr><td>4500</td><td>17.14±4.62</td><td>14.85±0.52</td><td>16.76±2.58</td><td>13.90±1.98</td><td>12.00±1.59</td></tr><tr><td>6600</td><td>15.23±2.33</td><td>13.14±1.24</td><td>13.90±2.29</td><td>14.28±1.34</td><td>12.57±1.57</td></tr><tr><td>12000</td><td>16.57±3.20</td><td>13.14±2.81</td><td>11.23±0.80</td><td>14.85±1.73</td><td>11.42±0.96</td></tr><tr><td>18600</td><td>15.62±0.85</td><td>13.71±1.73</td><td>15.99±6.75</td><td>12.57±3.26</td><td>12.95±2.98</td></tr></table>
|
| 363 |
+
|
| 364 |
+
# E.2 ADDITIONAL FID AND KID RESULTS ON THE SDI DATASET
|
| 365 |
+
|
| 366 |
+
We provide additional results in the case of training GANs with augmentation methods in Table 14. Augmentation methods like ADA (Karras et al., 2020a) or DiffAug (Zhao et al., 2020) are proposed to adapt GAN training to limited data. We applied these augmentation methods to StyleGAN v2 and BigGAN, because these state-of-art image synthesis methods are not optimized for small dataset. However, incorporating the augmentation methods in training GANs on the SDI dataset is not always beneficial. The performance of StyleGAN v2 is largely degraded when using ADA, potentially due to the conflict between augmentation methods and the decentralized location of defects—in the SDI dataset, defects can occur anywhere on the surface. This is in contrast to datasets that were used to evaluate the aforementioned augmentation methods in GANs, where the objects are centralized (e.g., ImageNet (Deng et al., 2009), Cifar (Krizhevsky & Hinton, 2009)) and their attributes (e.g., beard, eye glasses in CelebA (Liu et al., 2015)) only occur in specific images parts.
|
| 367 |
+
|
| 368 |
+
Table 14: Quantitative comparison of DT-GAN with baseline image synthesis methods using FID and KID. Note that the reported values are not comparable between columns, because they are calculated on different training sets. The scores of StarGAN v2 on single products are omitted because generating images with specified background is not possible due to its network design.
|
| 369 |
+
|
| 370 |
+
<table><tr><td rowspan="2">Method</td><td colspan="4">FID↓</td><td colspan="4">KID↓</td></tr><tr><td>A</td><td>B</td><td>C</td><td>All</td><td>A</td><td>B</td><td>C</td><td>All</td></tr><tr><td>Mokady et al. (2020)</td><td>68.69</td><td>66.90</td><td>36.21</td><td>58.63</td><td>0.050</td><td>0.036</td><td>0.030</td><td>0.036</td></tr><tr><td>StarGAN v2</td><td>-</td><td>-</td><td>1</td><td>37.70</td><td>1</td><td>-</td><td>1</td><td>0.013</td></tr><tr><td>StyleGAN v2</td><td>90.10</td><td>52.95</td><td>138.09</td><td>35.34</td><td>0.072</td><td>0.027</td><td>0.186</td><td>0.013</td></tr><tr><td>StyleGAN v2 + ADA</td><td>149.66</td><td>42.75</td><td>135.69</td><td>76.16</td><td>0.138</td><td>0.019</td><td>0.191</td><td>0.055</td></tr><tr><td>BigGAN</td><td>235.66</td><td>192.89</td><td>193.61</td><td>151.43</td><td>0.248</td><td>0.199</td><td>0.276</td><td>0.115</td></tr><tr><td>BigGAN + DiffAug</td><td>218.74</td><td>134.41</td><td>270.89</td><td>155.88</td><td>0.220</td><td>0.121</td><td>0.378</td><td>0.099</td></tr><tr><td>Ours</td><td>58.43</td><td>36.44</td><td>22.68</td><td>29.73</td><td>0.025</td><td>0.013</td><td>0.012</td><td>0.009</td></tr></table>
|
| 371 |
+
|
| 372 |
+
# E.3 ABLATION STUDY WITH REGARD TO FID AND KID SCORES
|
| 373 |
+
|
| 374 |
+
We report the FID and KID scores of the ablation study in Table 15. We notice that both subnetworks show positive correlation to each modification except for structural change as in (a) and (e) . Among the two subnetworks, the reference-guided subnetwork outperforms the latent-guided one in the beginning, which is due to the fact that transferring existing contents is easier than generating them from random noise. This effect is also observed in Figure 5. However, the performance of the latentguided subnetwork improves significantly after applying per-pixel noise injection. The subnetwork can now output non-deterministic foreground contents even for a fixed input vector which results in better visual quality and higher diversity of generated defects. In the main text, the scores of the mixture set are reported.
|
| 375 |
+
|
| 376 |
+
Table 15: Ablation study with regard to FID and KID scores.
|
| 377 |
+
|
| 378 |
+
<table><tr><td rowspan="2"></td><td colspan="3">FID↓</td><td colspan="3">KID↓</td></tr><tr><td>Latent</td><td>Reference</td><td>Mix</td><td>Latent</td><td>Reference</td><td>Mix</td></tr><tr><td>(a) Baseline StarGAN v2</td><td>37.73</td><td>37.99</td><td>37.70</td><td>0.013</td><td>0.013</td><td>0.013</td></tr><tr><td>(b)+ Style-Content branches</td><td>43.90</td><td>32.61</td><td>33.36</td><td>0.017</td><td>0.011</td><td>0.011</td></tr><tr><td>(c)+Foreground classifier</td><td>37.14</td><td>32.34</td><td>27.69</td><td>0.014</td><td>0.011</td><td>0.008</td></tr><tr><td>(d) + Background classifier</td><td>34.12</td><td>32.50</td><td>30.23</td><td>0.011</td><td>0.011</td><td>0.010</td></tr><tr><td>(e)+ Separately decoding foreground and background in G</td><td>48.52</td><td>38.11</td><td>34.79</td><td>0.017</td><td>0.015</td><td>0.011</td></tr><tr><td>(f) + Anchor foreground domain (e.g. No rmal)</td><td>43.66</td><td>37.45</td><td>32.15</td><td>0.019</td><td>0.015</td><td>0.011</td></tr><tr><td></td><td>33.05</td><td></td><td></td><td>0.009</td><td>0.011</td><td></td></tr><tr><td>(g)+ Noise injection in Mapping Network</td><td></td><td>34.42</td><td>29.73</td><td></td><td></td><td>0.009</td></tr></table>
|
| 379 |
+
|
| 380 |
+
# E.4 ADDITIONAL RESULTS ON THE MVTEC ANOMALY DETECTION DATASET
|
| 381 |
+
|
| 382 |
+
The MVTec Anomaly Detection dataset (Bergmann et al., 2019) contains 15 different object and texture categories for anomaly detection. The dataset is formed of non-defective image for training and both non-defective and defective images with various kinds of defects for testing. The pixel-level annotations of all defective images are also provided. It is worth noting that the MVTec Anomaly Detection dataset is relatively small scale in number of images, where the number of training images is ranging from 60 to 391. Moreover, the number of defective images for each defect category in the test set is varying only from 8 to 30, which is relatively limited considering the sophisticated pattern of defects.
|
| 383 |
+
|
| 384 |
+
We conducted image synthesis experiments on a subset of MVTec Anomaly Detection dataset, where we selected four texture categories: Carpet, Leather, Wood and Tile for our targeted scenario i.e. surface defects. Furthermore, we aggregated some of the original defect types defined in the MVTec Anomaly Detection dataset into scratches and spots according to their visual appearance. We then simply added the subset of the MVTec Anomaly Detection dataset to the training set together with the SDI dataset for training DT-GAN. Details of the resulting dataset are shown in Table 17. Note that the small scale of available data posts a major challenge for training generative models.
|
| 385 |
+
|
| 386 |
+
Quantitative Evaluation. We present additional quantitative results on the subset of the MVTec Anomaly Detection dataset in Table 16, following the same evaluation setup as described in Appendix C. As shown in Table 16, our method achieves the best scores in Carpet and Wood, which supports our claim that DT-GAN generates synthetic images with higher fidelity and more diverse defect. However, we also observe that StyleGAN v2 seems to outperform our method in Leather and Tile.
|
| 387 |
+
|
| 388 |
+
Please note that FID and KID are not optimized to evaluate such a small dataset, there the results should only be interpreted together with the qualitative results.
|
| 389 |
+
|
| 390 |
+
Note the we again omit the FID and KID of StarGAN v2 because it is not cable of generating images for a specified product due to the ‘identity-shift’, which is also explained in detail in the qualitative evaluation.
|
| 391 |
+
|
| 392 |
+
Table 16: Quantitative comparison of DT-GAN with baseline image synthesis methods using FID and KID. Note that the reported values are not comparable between columns, because they were calculated on different training sets.
|
| 393 |
+
|
| 394 |
+
<table><tr><td rowspan="2">Method</td><td colspan="4">FID↓</td><td colspan="4">KID↓</td></tr><tr><td>Carpet</td><td>Leather</td><td>Tile</td><td>Wood</td><td>Carpet</td><td>Leather</td><td>Tile</td><td>Wood</td></tr><tr><td>Mokady (2020)</td><td>41.87</td><td>60.26</td><td>275.12</td><td>81.71</td><td>0.04</td><td>0.03</td><td>0.29</td><td>0.04</td></tr><tr><td>StarGAN v2</td><td>1</td><td></td><td></td><td></td><td>1</td><td></td><td>=</td><td>1</td></tr><tr><td>StyleGAN v2</td><td>51.37</td><td>51.60</td><td>225.96</td><td>140.01</td><td>0.05</td><td>0.03</td><td>0.23</td><td>0.12</td></tr><tr><td>BigGAN + DiffAug</td><td>34.47</td><td>101.70</td><td>391.54</td><td>113.32</td><td>0.03</td><td>0.07</td><td>0.42</td><td>0.07</td></tr><tr><td>Ours</td><td>22.79</td><td>86.13</td><td>321.35</td><td>75.83</td><td>0.01</td><td>0.07</td><td>0.36</td><td>0.03</td></tr></table>
|
| 395 |
+
|
| 396 |
+
Qualitative Evaluation. For qualitative results, we again discuss the ‘latent-guided’ and ‘referenceguided’ synthesis separately.
|
| 397 |
+
|
| 398 |
+
We present the ‘latent-guided’ image synthesis results of StyleGAN v2 in Figure 11 and Figure 12 and BigGAN in Figure 13 and Figure 14. The results are acquired by training one model for each product and then generating 16 images from randomly sampled latent codes from each of them. As pointed out in Section 4.1.2, both methods can not adapt well on small dataset. They suffer from model collapsing and show signs of overfitting by generating images similar to the training data. For example, StyleGAN v2 generates images either with no clear defect or identical to the training set (e.g., Leather in Figure 11 and Product B in Figure 12). The overfitting we observe here also explains the better FID and KID scores in Table 16. For Tile, we can see clear signs of mode collapse in the generated Tile images of StyleGAN v2. Similarly, BigGAN produces images with single mode and abnormal patterns (e.g., grid structure and gray edges). Unlike StyleGAN v2 and BigGAN, StarGAN v2 and our method both require images as input (i.e. Source). Therefore, we randomly sampled two Normal images and applied eight defects which are generated from randomly sampled latent codes to each of them. As seen in Figure 15 and Figure 16, StarGAN v2 fails to preserve the background from the given input images due to the highly entangled FG and BG. Also it fails to generates legit and diverse defects without separately modeling the style and the content. In contrast to aforementioned methods, our DT-GAN produces images with higher fidelity and more diversity in defect patterns as shown in Figure 17 and Figure 18. We believe this again prove the importance of style-content separation and FG/BG disentanglement, which we introduce in Section 3.1.
|
| 399 |
+
|
| 400 |
+
For ‘reference-guided’ image synthesis, the results of Mokady et al. (2020) are shown in Figure 19 and Figure 20 while the results of StarGAN v2 are in Figure 21 and Figure 22. We can observe a clear shift in color in all the outputs from Mokady et al. (2020). Moreover, Mokady et al. (2020) can only transfer content between two domains. In order to perform translation from a non-defective sample to a defective one, we trained a model for each type of defect and for each product. This sums up to be 13 models (Scratches and Spots for 6 categories and Scratches only for Tile). The results from the intended use within one background domain can be found on the diagonal and are marked in red in both Figure 19 and Figure 20. We still show the images that we feed in images from other background domains. As expected, the model then fails to preserve the background of given source images and introduce artifacts to the outputs. Similarly, StarGAN v2 does not preserve the background from the input images. Without style-content separation and FG/BG disentanglement, we observe that StarGAN v2 encodes the background characteristics together with the foreground content of the reference images, which results in identity-shits in its output images. Moreover, the output images either show no clear defect or contain abnormal patterns which sabotage the fidelity. On the contrary, our method can faithfully transfer the foreground content of reference images across given background of different products as shown in Figure 23 and Figure 24, which demonstrate the effectiveness of the style-content separation and FG/BG disentanglement we introduced in Section 3.1.
|
| 401 |
+
|
| 402 |
+
It is also worth noting that our method can perform cross-domain image synthesis even the desired combination is not presented in the training set. We demonstrate this on product Tile, which only has images with Scratches but no Spots. As shown in Figure 18 and Figure 24, DT-GAN can generated spots one given Tile images. However, this kind of transformation is most useful when the desired combination is reasonable for the downstream applications.
|
| 403 |
+
|
| 404 |
+
Limitation and Future Work. We have demonstrated the feasibility of the proposed DT-GAN by incorporating more products from the MVTec Anomaly Detection dataset in our training procedure. Intensive experiments have shown that the generated images from DT-GAN yielded better results compared to the baseline image synthesis methods. However, we noticed that despite the diverse patterns of the generated defects, DT-GAN tends to apply the styles learned from the SDI dataset also to the samples from the MVTec Anomaly Detection dataset. For example, we can observe some ”halo” effects in Leather and Wood in Figure 18 and some of the generated scratches in Figure 17 and Figure 23 are rather weakly pronounced. We hypothesize this can be counteracted by explicitly localizing the defect and enforcing the model to learn conditional relationships between ‘styles’ and different backgrounds. We aim to address these issues in future work.
|
| 405 |
+
|
| 406 |
+
Table 17: Overview of our formation of the MVTec Anomaly Detection sub-dataset. The first column represents the original defect types in the MVTec Anomaly Detection dataset while the first row stands for the defect types in our targeted scenario. We list the ID of samples we took from the MVTec Anomaly Detection dataset and show the number of samples in row Sum.
|
| 407 |
+
|
| 408 |
+
<table><tr><td colspan="3">(a) Carpet</td></tr><tr><td></td><td>Scratches</td><td>Spots</td></tr><tr><td>Color</td><td>011,012,014,016, 017</td><td>000,003,004,007,015,018</td></tr><tr><td>Thread</td><td>000-018</td><td></td></tr><tr><td>Hole</td><td>-</td><td>000 - 016</td></tr><tr><td>Sum</td><td>24</td><td>23</td></tr><tr><td colspan="3">(b) Leather</td></tr><tr><td></td><td>Scratches</td><td>Spots</td></tr><tr><td>Color</td><td>001,003,005,007,009,011,013,015,018</td><td>000,002,006,008,010,012,014</td></tr><tr><td>Cut</td><td>000 -018 000 - 006,009 - 016</td><td>-</td></tr><tr><td>Fold Glue</td><td></td><td>000 - 002,005-009,011-015,018</td></tr><tr><td>Poke</td><td>003,009,010,016,017</td><td>000-017</td></tr><tr><td>Sum</td><td></td><td>39</td></tr><tr><td></td><td>48</td><td></td></tr><tr><td colspan="3">(c) Tile</td></tr><tr><td></td><td>Scratches</td><td>Spots</td></tr><tr><td>Crack</td><td>000 - 016</td><td>二</td></tr><tr><td>Sum</td><td>17</td><td>0</td></tr><tr><td colspan="3">(d) Wood</td></tr><tr><td></td><td>Scratches</td><td>Spots</td></tr><tr><td>Color</td><td>003,005</td><td></td></tr><tr><td>Scratch</td><td>001-006,008- 010,013 -016,018- 020</td><td>000 - 016</td></tr><tr><td>Hole</td><td>=</td><td>000 - 004,006-009</td></tr><tr><td>Combined</td><td>008</td><td>001,002,009</td></tr><tr><td>Sum</td><td>19</td><td>12</td></tr></table>
|
| 409 |
+
|
| 410 |
+
# Randomly Sampled Defects (Scratches)
|
| 411 |
+
|
| 412 |
+

|
| 413 |
+
Figure 11: Latent-guided image synthesis results of StyleGAN v2 on the SDI dataset and the MVTec AD dataset. We train a model for each product and generate 16 Scratches images from randomly sampled latent codes.
|
| 414 |
+
|
| 415 |
+

|
| 416 |
+
Figure 12: Latent-guided image synthesis results of StyleGAN v2 on the SDI dataset and the MVTec AD dataset. We train a model for each product and generate 16 Spots images from randomly sampled latent codes.
|
| 417 |
+
|
| 418 |
+

|
| 419 |
+
Figure 13: Latent-guided image synthesis results of BigGAN with DiffAug on the SDI dataset and the MVTec AD dataset. We train a model for each product and generate 16 Scratches images from randomly sampled latent codes.
|
| 420 |
+
|
| 421 |
+

|
| 422 |
+
Figure 14: Latent-guided image synthesis results of BigGAN with DiffAug on the SDI dataset and the MVTec AD dataset. We train a model for each product and generate 16 Spots images from randomly sampled latent codes.
|
| 423 |
+
|
| 424 |
+

|
| 425 |
+
Figure 15: Latent-guided image synthesis results of StarGAN v2 on the SDI dataset and the MVTec AD dataset. The model is trained on a joint set of aforementioned datasets and performs translation from Normal to Scratches. Note that without the style-content separation and the FG/BG disentanglement, StarGAN v2 not only fails to preserve the background from the given Source image but also fail to generates legit defects.
|
| 426 |
+
|
| 427 |
+

|
| 428 |
+
Figure 16: Latent-guided image synthesis results of StarGAN v2 on the SDI dataset and the MVTec AD dataset. The model is trained on a joint set of aforementioned datasets and performs translation from Normal to Spots. Note that without the style-content separation and the FG/BG disentanglement, StarGAN v2 not only fails to preserve the background from the given Source image but also fail to generates legit defects.
|
| 429 |
+
|
| 430 |
+

|
| 431 |
+
Figure 17: Latent-guided image synthesis results of DT-GAN on the SDI dataset and the MVTec AD dataset. The model is trained on a joint set of aforementioned datasets and performs translation from Normal to Scratches. Note the our model takes input Source images as background and only synthesizes the foreground defects from randomly sampled latent code compared to StyleGAN v2 and BigGAN.
|
| 432 |
+
|
| 433 |
+

|
| 434 |
+
Figure 18: Latent-guided image synthesis results of DT-GAN on the SDI dataset and the MVTec AD dataset. The model is trained on a joint set of aforementioned datasets and performs translation from Normal to Spots. Note the our model takes input Source images as background and only synthesizes the foreground defects from randomly sampled latent code compared to StyleGAN v2 and BigGAN.
|
| 435 |
+
|
| 436 |
+

|
| 437 |
+
Figure 19: Reference-guided image synthesis results of Mokady et al. (2020) on the SDI dataset and the MVTec AD dataset. We train a model for each product and each defect type. Then we translate Normal images to Scratches by taking the Source as background and applying the foreground defect from Reference to it.
|
| 438 |
+
|
| 439 |
+

|
| 440 |
+
Figure 20: Reference-guided image synthesis results of Mokady et al. (2020) on the SDI dataset and the MVTec AD dataset. We train a model for each product and each defect type. Then we translate Normal images to Spots by taking the Source as background and applying the foreground defect from Reference to it.
|
| 441 |
+
|
| 442 |
+

|
| 443 |
+
Figure 21: Reference-guided image synthesis results StarGAN v2 on the SDI dataset and the MVTec AD dataset. The model is trained on a joint set of aforementioned datasets and performs translation from Normal to Scratches by taking the Source as background and applying the foreground defect from Reference to it. Note that without the style-content separation and the FG/BG disentanglement, StarGAN v2 not only fails to preserve the background from the given Source image but also fail to generates legit defects.
|
| 444 |
+
|
| 445 |
+

|
| 446 |
+
Figure 22: Reference-guided image synthesis results of StarGAN v2 on the SDI dataset and the MVTec AD dataset. The model is trained on a joint set of aforementioned datasets and performs translation from Normal to Spots by taking the Source as background and applying the foreground defect from Reference to it. Note that without the style-content separation and the FG/BG disentanglement, StarGAN v2 not only fails to preserve the background from the given Source image but also fail to generates legit defects.
|
| 447 |
+
|
| 448 |
+

|
| 449 |
+
Figure 23: Reference-guided image synthesis results DT-GAN on the SDI dataset and the MVTec AD dataset. The model is trained on a joint set of aforementioned datasets and performs translation from Normal to Scratches by taking the Source as background and applying the foreground defect from Reference to it.
|
| 450 |
+
|
| 451 |
+

|
| 452 |
+
Figure 24: Reference-guided image synthesis results of DT-GAN on the SDI dataset and the MVTec AD dataset. The model is trained on a joint set of aforementioned datasets and performs translation from Normal to Spots by taking the Source as background and applying the foreground defect from Reference to it.
|
md/dev/3jooF27-0Wy/3jooF27-0Wy.md
ADDED
|
@@ -0,0 +1,618 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# FLEXCONV: CONTINUOUS KERNEL CONVOLUTIONSWITH DIFFERENTIABLE KERNEL SIZES
|
| 2 |
+
|
| 3 |
+
David W. Romero∗,1, Robert-Jan Bruintjes∗,2, Erik J. Bekkers3, Jakub M. Tomczak1, Mark Hoogendoorn1, Jan C. van Gemert2 1 Vrije Universiteit Amsterdam 2 Delft University of Technology 3 University of Amsterdam The Netherlands d.w.romeroguzman@vu.nl, r.bruintjes@tudelft.nl
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
When designing Convolutional Neural Networks (CNNs), one must select the size of the convolutional kernels before training. Recent works show CNNs benefit from different kernel sizes at different layers, but exploring all possible combinations is unfeasible in practice. A more efficient approach is to learn the kernel size during training. However, existing works that learn the kernel size have a limited bandwidth. These approaches scale kernels by dilation, and thus the detail they can describe is limited. In this work, we propose FlexConv, a novel convolutional operation with which high bandwidth convolutional kernels of learnable kernel size can be learned at a fixed parameter cost. FlexNets model long-term dependencies without the use of pooling, achieve state-of-the-art performance on several sequential datasets, outperform recent works with learned kernel sizes, and are competitive with much deeper ResNets on image benchmark datasets. Additionally, FlexNets can be deployed at higher resolutions than those seen during training. To avoid aliasing, we propose a novel kernel parameterization with which the frequency of the kernels can be analytically controlled. Our novel kernel parameterization shows higher descriptive power and faster convergence speed than existing parameterizations. This leads to important improvements in classification accuracy.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
The kernel size of a convolutional layer defines the region from which features are computed, and is a crucial choice in their design. Commonly, small kernels (up to $7 \mathrm { p x }$ ) are used almost exclusively and are combined with pooling to model long term dependencies (Simonyan & Zisserman, 2014; Szegedy et al., 2015; He et al., 2016; Tan & Le, 2019). Recent works indicate, however, that CNNs benefit from using convolutional kernels (i) of varying size at different layers (Pintea et al., 2021; Tomen et al., 2021), and $( i i )$ at the same resolution of the data (Peng et al., 2017; Cordonnier et al., 2019; Romero et al., 2021). Unfortunately, most CNNs represent convolutional kernels as tensors of discrete weights and their size must be fixed prior to training. This makes exploring different kernel sizes at different layers difficult and time-consuming due to $( i )$ the large search space, and (ii) the large number of weights required to construct large kernels.
|
| 12 |
+
|
| 13 |
+
A more efficient way to tune different kernel sizes at different layers is to learn them during training. Existing methods define a discrete weighted set of basis functions, e.g., shifted Delta-Diracs (Fig. 2b, Dai et al. (2017)) or Gaussian functions (Fig. 2c, Jacobsen et al. (2016); Shelhamer et al. (2019); Pintea et al. (2021)). During training they learn dilation factors over the basis functions to increase the kernel size, which crucially limits the bandwidth of the resulting kernels.
|
| 14 |
+
|
| 15 |
+
In this work, we present the Flexible Size Continuous Kernel Convolution (FlexConv), a convolutional layer able to learn high bandwidth convolutional kernels of varying size during training (Fig. 1). Instead of using discrete weights, we provide a continuous parameterization of convolutional kernels via a small neural network (Romero et al., 2021). This parameterization allows us to model continuous functions of arbitrary size with a fixed number of parameters. By multiplying the response of the neural network with a Gaussian mask, the size of the kernel can be learned during training (Fig. 2a). This allows us to produce detailed kernels of small sizes (Fig. 3), and tune kernel sizes efficiently.
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
Figure 1: The Flexible Size Continuous Kernel Convolution (FlexConv). FlexConv defines convolutional kernels as the multiplication of a continuous convolutional kernel $\mathtt { M L P } ^ { \psi }$ , with a Gaussian mask of local support $w _ { \mathrm { g a u s s } }$ : $\boldsymbol { \psi } ( x , y ) = w _ { \mathrm { g a u s s } } ( x , y ; \theta _ { \mathrm { m a s k } } ) \cdot \mathtt { M L P } ^ { \boldsymbol { \psi } } ( x , y )$ . By learning the parameters =of the mask, the size of the convolutional kernel can be optimized during training. See also Fig. 7.
|
| 19 |
+
|
| 20 |
+
FlexConvs can be deployed at higher resolutions than those observed during training, simply by using a more densely sampled grid of kernel indices. However, the high bandwidth of the kernel can lead FlexConv to learn kernels that show aliasing at higher resolutions, if the kernel bandwidth exceeds the Nyquist frequency. To solve this problem, we propose to parameterize convolutional kernels as Multiplicative Anisotropic Gabor Networks (MAGNets). MAGNets are a new class of Multiplicative Filter Networks (Fathony et al., 2021) that allows us to analyze and control the frequency spectrum of the generated kernels. We use this analysis to regularize FlexConv against aliasing. With this regularization, FlexConvs can be directly deployed at higher resolutions with minimal accuracy loss. Furthermore, MAGNets provide higher descriptive power and faster convergence speed than existing continuous kernel parameterizations (Schütt et al., 2017; Finzi et al., 2020; Romero et al., 2021). This leads to important improvements in classification accuracy (Sec. 4).
|
| 21 |
+
|
| 22 |
+
Our experiments show that CNNs with FlexConvs, coined FlexNets, achieve state-of-the-art across several sequential datasets, match performance of recent works with learnable kernel sizes with less compute, and are competitive with much deeper ResNets (He et al., 2016) when applied on image benchmark datasets. Thanks to the ability of FlexConvs to generalize across resolutions, FlexNets can be efficiently trained at low-resolution to save compute, e.g., $1 6 \times 1 6$ CIFAR images, and be deployed on the original data resolution with marginal accuracy loss, e.g., $3 2 \times 3 2$ CIFAR images.
|
| 23 |
+
|
| 24 |
+
In summary, our contributions are:
|
| 25 |
+
|
| 26 |
+
• We introduce the Flexible Size Continuous Kernel Convolution (FlexConv), a convolution operation able to learn high bandwidth convolutional kernels of varying size end-to-end. • Our proposed Multiplicative Anisotropic Gabor Networks (MAGNets) allow for analytic control of the properties of the generated kernels. This property allows us to construct analytic alias-free convolutional kernels that generalize to higher resolutions, and to train FlexNets at low resolution and deploy them at higher resolutions. Moreover, MAGNets show higher descriptive power and faster convergence speed than existing kernel parameterizations. • CNN architectures with FlexConvs (FlexNets) obtain state-of-the-art across several sequential datasets, and match recent works with learnable kernel size on CIFAR-10 with less compute.
|
| 27 |
+
|
| 28 |
+
# 2 RELATED WORK
|
| 29 |
+
|
| 30 |
+
Adaptive kernel sizes. Loog & Lauze (2017) regularize the scale of convolutional kernels for filter learning. For image classification, adaptive kernel sizes have been proposed via learnable pixel-wise offsets (Dai et al., 2017), learnable padding operations (Han et al., 2018), learnable dilated Gaussian functions (Shelhamer et al., 2019; Xiong et al., 2020; Tabernik et al., 2020; Nguyen, 2020) and scalable Gaussian derivative filters (Pintea et al., 2021; Tomen et al., 2021; Lindeberg, 2021). These approaches either dilate discrete kernels (Fig. 2b), or use discrete weights on dilated basis functions (Fig. 2c). Using dilation crucially limits the bandwidth of the resulting kernels. In contrast, FlexConvs are able to construct high bandwidth convolutional kernels of varying size with a fixed parameter count. Larger kernels are obtained simply by passing more positions to the kernel network (Fig. 1).
|
| 31 |
+
|
| 32 |
+
Continuous kernel convolutions. Discrete convolutional kernel parameterizations assign an independent weight to each specific position in the kernel. Continuous convolutional kernels, on the other hand, view convolutional kernels as continuous functions parameterized via a small neural network $\mathtt { M L P } ^ { \psi } \colon \mathbb { R } ^ { \mathrm { D } } \mathbb { R } ^ { \mathrm { N _ { o u t } \times N _ { i n } } }$ , with D the data dimensionality. This defines a convolutional kernel for which arbitrary input positions can be queried. Continuous kernels have primarily been used to handle irregularly-sampled data locally, e.g., molecular data (Simonovsky & Komodakis, 2017; Schütt et al., 2017) and point-clouds (Thomas et al., 2018; Wang et al., 2018; Shi et al., 2019).
|
| 33 |
+
|
| 34 |
+

|
| 35 |
+
Figure 2: Existing approaches increase the size of convolutional kernels via (learnable) parametric dilations, e.g., by deformation (b) or by Gaussian blur (c). However, dilation limits the bandwidth of the dilated kernel and with it, the amount of detail it can describe. Contrarily, FlexNets extend their kernels by passing a larger vector of positions to the neural network parameterizing them. As a result, FlexConvs are able to learn high bandwidth convolutional kernels of varying size end-to-end (a).
|
| 36 |
+
|
| 37 |
+

|
| 38 |
+
Figure 3: The importance of dynamic sizes in continuous kernel convolutions. Consider a neural network predicting pixel values at each position. If the entire image is considered, the network must use part of its capacity to learn to predict zeros outside of the flower region, which in turn degrades the quality of the approximation in the region of interest (b). Importantly, the better the localization of the flower, the higher the approximation fidelity becomes. FlexNets learn the size of their convolutional kernels at each layer during training, and thus $( i )$ use the capacity of the kernel efficiently, (ii) converge faster to good approximations, and $( i i i )$ are faster in execution –via dynamic cropping–.
|
| 39 |
+
|
| 40 |
+
Recently, Romero et al. (2021) introduced the Continuous Kernel Convolution (CKConv) as a tool to model long-term dependencies. CKConv uses a continuous kernel parameterization to construct convolutional kernels as big as the input signal with a constant parameter cost. Contrarily, FlexConvs jointly learn the convolutional kernel as well as its size. This leads to important advantages in terms of expressivity (Fig. 3), convergence speed and compute costs of the operation.
|
| 41 |
+
|
| 42 |
+
Implicit neural representations. Parameterizing a convolutional kernel via a neural network can be seen as learning an implicit neural representation of the underlying convolutional kernel (Romero et al., 2021). Implicit neural representations construct continuous data representations by encoding data in the weights of a neural network (Park et al., 2019; Sitzmann et al., 2020; Fathony et al., 2021).
|
| 43 |
+
|
| 44 |
+
We replace the SIREN (Sitzmann et al., 2020) kernel parameterization used in Romero et al. (2021) by our Multiplicative Anisotropic Gabor Networks: a new class of Multiplicative Filter Networks (Fathony et al., 2021). MFNs allow for analytic control of the resulting representations, and allow us to construct analytic alias-free convolutional kernels. The higher expressivity and convergence speed of MAGNets lead to accuracy improvements in CNNs using them as kernel parameterization.
|
| 45 |
+
|
| 46 |
+
# 3 METHOD
|
| 47 |
+
|
| 48 |
+
In this section, we introduce our approach. First, we introduce FlexConv and the Gaussian mask. Next, we introduce our Multiplicative Anisotropic Gabor Networks (MAGNets) and provide a description of our regularization technique used to control the spectral components of the generated kernel.
|
| 49 |
+
|
| 50 |
+
# 3.1 FLEXIBLE SIZE CONTINUOUS KERNEL CONVOLUTION (FLEXCONV)
|
| 51 |
+
|
| 52 |
+
To learn the kernel size during training, FlexConvs define their convolutional kernels $\psi$ as the product of the output of a neural network $\mathtt { M L P } ^ { \psi }$ with a Gaussian mask of local support. The neural network $\mathtt { M L P } ^ { \psi }$ parameterizes the kernel, and the Gaussian mask parameterizes its size (Fig. 1).
|
| 53 |
+
|
| 54 |
+
Anisotropic Gaussian mask. Let $\begin{array} { r } { G ( x ; \mu _ { \mathrm { X } } , \sigma _ { \mathrm { X } } ^ { 2 } ) { : = } \exp \left\{ - \frac { 1 } { 2 } \sigma _ { \mathrm { X } } ^ { - 2 } ( x - \mu _ { \mathrm { X } } ) ^ { 2 } \right\} } \end{array}$ be a Gaussian function parameterized by a mean-variance tuple $( \mu _ { \mathrm { X } } , \sigma _ { \mathrm { X } } ^ { 2 } )$ . The anisotropic Gaussian mask is defined as:
|
| 55 |
+
|
| 56 |
+
$$
|
| 57 |
+
w _ { \mathrm { g a u s s } } ( x , y ; \{ \mu _ { \mathrm { X } } , \sigma _ { \mathrm { X } } ^ { 2 } , \mu _ { \mathrm { Y } } , \sigma _ { \mathrm { Y } } ^ { 2 } \} ) = G ( x ; \mu _ { \mathrm { X } } , \sigma _ { \mathrm { X } } ^ { 2 } ) G ( y ; \mu _ { \mathrm { Y } } , \sigma _ { \mathrm { Y } } ^ { 2 } ) .
|
| 58 |
+
$$
|
| 59 |
+
|
| 60 |
+
By learning $( \mu _ { \mathrm { X } } , \sigma _ { \mathrm { X } } ^ { 2 } )$ and $( \mu _ { \mathrm { Y } } , \sigma _ { \mathrm { Y } } ^ { 2 } )$ independently, anisotropic non-centered windows can be learne
|
| 61 |
+
|
| 62 |
+
3.2 MULTIPLICATIVE ANISOTROPIC GABOR NETWORKS (MAGNETS)
|
| 63 |
+
|
| 64 |
+
In this section, we formalize our proposed parameterization for the kernel $\mathtt { M L P } ^ { \psi }$ . We start by introducing Multiplicative Filter Networks (Fathony et al., 2021), and present our MAGNets next.
|
| 65 |
+
|
| 66 |
+
Multiplicative Filter Networks (MFNs). Recently, Fathony et al. (2021) proposed to construct implicit neural representations as the linear combination of exponentially many basis functions $\mathbf { g }$ :
|
| 67 |
+
|
| 68 |
+
$$
|
| 69 |
+
\begin{array} { r l r l } & { \mathbf { h } ^ { ( 1 ) } = \mathbf { g } \big ( [ x , y ] ; \theta ^ { ( 1 ) } \big ) } & & { \quad \mathbf { g } : \mathbb { R } ^ { 2 } \to \mathbb { R } ^ { \mathrm { N _ { h i d } } } } \\ & { \mathbf { h } ^ { ( l ) } = \big ( \mathbf { W } ^ { ( l ) } \mathbf { h } ^ { ( l - 1 ) } + \mathbf { b } ^ { ( l ) } \big ) \cdot \mathbf { g } \big ( [ x , y ] ; \theta ^ { ( l ) } \big ) } & & { \quad \mathbf { W } ^ { ( l ) } \in \mathbb { R } ^ { \mathrm { N _ { h i d } } \times \mathrm { N _ { h i d } } } , \mathbf { b } ^ { ( l ) } \in \mathbb { R } ^ { \mathrm { N _ { h i d } } } } \\ & { \psi ( x , y ) = \mathbf { W } ^ { ( \mathrm { L } ) } \mathbf { h } ^ { ( \mathrm { L } - 1 ) } + \mathbf { b } ^ { ( \mathrm { L } ) } \quad } & & { \quad \mathbf { W } ^ { ( \mathrm { L } ) } \in \mathbb { R } ^ { \mathrm { N } \times \mathrm { N _ { h i d } } } , \mathbf { b } ^ { ( \mathrm { L } ) } \in \mathbb { R } ^ { \mathrm { N } } } \end{array}
|
| 70 |
+
$$
|
| 71 |
+
|
| 72 |
+
where $\left\{ \pmb { \theta } ^ { ( l ) } , \mathbf { W } ^ { ( l ) } , \mathbf { b } ^ { ( l ) } \right\}$ depict the learnable parameters of the bases and the affine transformations, and $\mathrm { { N , N _ { h i d } } }$ depict the number of output and hidden channels, respectively. Depending on the selection of $\mathbf { g }$ , MFNs obtain approximations comparable to those of SIRENs (Sitzmann et al., 2020) with faster convergence rate. The most successful instantiation of MNFs are the Multiplicative Gabor Network (MGN): MFNs constructed with isotropic Gabor functions as basis $\mathbf { g }$ (in Eq. 2):
|
| 73 |
+
|
| 74 |
+
$$
|
| 75 |
+
\mathbf { g } \big ( [ x , y ] ; \pmb { \theta } ^ { ( l ) } \big ) = \exp \Bigg ( - \frac { \gamma ^ { ( l ) } } { 2 } \Big [ \big ( x - \pmb { \mu } ^ { ( l ) } \big ) ^ { 2 } + \big ( y - \pmb { \mu } ^ { ( l ) } \big ) ^ { 2 } \Big ] \Bigg ) \mathrm { S i n } \big ( \mathbf { W } _ { \mathbf { g } } ^ { ( l ) } \cdot [ x , y ] + \mathbf { b } _ { \mathbf { g } } ^ { ( l ) } \big ) ,
|
| 76 |
+
$$
|
| 77 |
+
|
| 78 |
+
Note that, by setting $\mathrm { N { = } N _ { o u t } { \times } N _ { i n } }$ , an MFN can parameterize a convolutional kernel with $\mathrm { { N } } _ { \mathrm { { i n } } }$ input and $\mathrm { N _ { o u t } }$ output channels. Fathony et al. (2021) show that MFNs are equivalent to a linear combination of exponentially many basis functions $\mathbf { g }$ . This allows us to analytically derive properties of MFN representations, and plays a crucial role in the derivation of alias-free MAGNets (Sec. 3.3).
|
| 79 |
+
|
| 80 |
+
Multiplicative Anisotropic Gabor Networks (MAGNets). Our MAGNet formulation is based on the observation that isotropic Gabor functions, i.e., with equal $\gamma$ for the horizontal and vertical directions, are undesirable as basis for the construction of MFNs. Whenever a frequency is required along a certain direction, an isotropic Gabor function automatically introduces that frequency in both directions. As a result, other bases must counteract this frequency in the direction where the frequency is not required, and thus the capacity of the MFN is not used optimally (Daugman, 1988).
|
| 81 |
+
|
| 82 |
+
Following the original formulation of the 2D Gabor functions (Daugman, 1988), we alleviate this limitation by using anisotropic Gabor functions instead:
|
| 83 |
+
|
| 84 |
+
$$
|
| 85 |
+
\begin{array} { r l } & { \displaystyle \mathbf { g } \big ( [ x , y ] ; \pmb \theta ^ { ( l ) } \big ) = \exp \Bigg ( - \frac { 1 } { 2 } \Big [ \Big ( \gamma _ { _ \mathrm { X } } ^ { ( l ) } \big ( x - \pmb \mu _ { _ \mathrm { X } } ^ { ( l ) } \big ) \Big ) ^ { 2 } + \Big ( \gamma _ { _ \mathrm { Y } } ^ { ( l ) } \big ( y - \pmb \mu _ { _ \mathrm { Y } } ^ { ( l ) } \big ) \Big ) ^ { 2 } \Big ] \Bigg ) \mathrm { S i n } \Big ( \mathbf { W } _ { \Xi } ^ { ( l ) } \big [ x , y \big ] + \mathbf { b } _ { \mathrm { g } } ^ { ( l ) } \Big ) } \\ & { \displaystyle \pmb \theta ^ { ( l ) } = \Big \{ \gamma _ { _ \mathrm { X } } ^ { ( l ) } \in \mathbb { R } ^ { \mathrm { N _ { h i d } } } , \gamma _ { _ \mathrm { Y } } ^ { ( l ) } \in \mathbb { R } ^ { \mathrm { N _ { h i d } } } , \mu _ { _ \mathrm { X } } ^ { ( l ) } \in \mathbb { R } ^ { \mathrm { N _ { h i d } } } , \mu _ { _ \mathrm { Y } } ^ { ( l ) } \in \mathbb { R } ^ { \mathrm { N _ { h i d } } } , \mathbf { W } _ { \Xi } ^ { ( l ) } \in \mathbb { R } ^ { \mathrm { N _ { h i d } } \times 2 } , \mathbf { b } _ { \mathrm { g } } ^ { ( l ) } \in \mathbb { R } ^ { \mathrm { N _ { h i d } } } \Big \} . } \end{array}
|
| 86 |
+
$$
|
| 87 |
+
|
| 88 |
+
The resulting Multiplicative Anisotropic Gabor Network (MAGNet) obtains better control upon frequency components introduced to the approximation, and demonstrates important improvements in terms of descriptive power and convergence speed (Sec. 4).
|
| 89 |
+
|
| 90 |
+
MAGNet initialization. Fathony et al. (2021) proposes to initialize MGNs by drawing the size of the Gaussian envelopes, i.e., the $\gamma ^ { ( l ) }$ term, from a Gamma $\left( \alpha \cdot \mathrm { L } ^ { - 1 } , \beta \right)$ distribution at every layer $l \in [ 1 , . . , \mathrm { L } - 1 ]$ . We observe however that this initialization does not provide much variability on the ∈initial extension of the Gaussian envelopes and in fact, most of them cover a large portion of the space at initialization. T stimulate diversity, we initialize the $\{ \gamma _ { \mathrm { X } } ^ { ( l ) } , \gamma _ { \mathrm { Y } } ^ { ( l ) } \}$ terms by a $\mathrm { G a m m a } ( \alpha l ^ { - 1 } , \beta )$ $l$ -th layer. We observe that our proposed initialization consistently leads to better accuracy than the initialization of Fathony et al. (2021) across all tasks considered. (Sec. 4).
|
| 91 |
+
|
| 92 |
+
# 3.3 ANALYTIC ALIAS-FREE MAGNETS
|
| 93 |
+
|
| 94 |
+
FlexConvs can be deployed at higher resolutions than those observed during training, simply by sampling the underlying continuous representation of the kernel more densely, and accounting for the
|
| 95 |
+
|
| 96 |
+
change in sampling rate. Consider a D-dimensional input signal $f _ { \mathrm { r } ^ { ( 1 ) } }$ with resolution $\mathrm { r } ^ { ( 1 ) }$ . FlexConv learns a kernel $\psi _ { \mathrm { r } ^ { ( 1 ) } }$ that can be inferred at a higher resolution $\mathrm { r } ^ { ( 2 ) }$ (Romero et al., 2021):
|
| 97 |
+
|
| 98 |
+
$$
|
| 99 |
+
\biggl ( f _ { \mathrm { r } ^ { ( 2 ) } } * \psi _ { \mathrm { r } ^ { ( 2 ) } } \biggr ) \approx \left( \frac { \mathrm { \bar { r } ^ { \left( 1 \right) } } } { \mathrm { r } ^ { \left( 2 \right) } } \right) ^ { \mathrm { D } } \biggl ( f _ { \mathrm { r } ^ { ( 1 ) } } * \psi _ { \mathrm { r } ^ { ( 1 ) } } \biggr ) .
|
| 100 |
+
$$
|
| 101 |
+
|
| 102 |
+
Note however, that Eq. 9 holds approximately. This is due to aliasing artifacts which can appear if the frequencies in the learned kernel surpass the Nyquist criterion of the target resolution. Consequently, an anti-aliased parameterization is vital to construct kernels that generalize well to high resolutions.
|
| 103 |
+
|
| 104 |
+
Towards alias-free implicit neural representations. We observe that SIRENs as well as unconstrained MFNs and MAGNets exhibit aliasing when deployed on resolutions higher than the training resolution, which hurts performance of the model. An example kernel with aliasing is shown in Fig. 8.
|
| 105 |
+
|
| 106 |
+
To combat aliasing, we would like to control the representation learned by MAGNets. MAGNets –and MFNs in general– construct implicit neural representations that can be seen as a linear combination of basis functions. This property allows us to analytically derive and study the properties of the resulting neural representation. Here, we use this property to derive the maximum frequency of MAGNet-generated kernels, so as to regularize MAGNets against aliasing during training. We analytically derive the maximum frequency of a MAGNet, and penalize it whenever it exceeds the Nyquist frequency of the training resolution. We note that analytic derivations are difficult for other implicit neural representations, e.g., SIRENs, due to stacked layer-wise nonlinearities.
|
| 107 |
+
|
| 108 |
+
Maximum frequency of MAGNets. The maximum frequency component of a MAGNet is given by:
|
| 109 |
+
|
| 110 |
+
$$
|
| 111 |
+
f _ { \mathrm { M A G N e t } } ^ { + } = \sum _ { l = 1 } ^ { \mathrm { L } } \operatorname* { m a x } _ { i _ { l } } \left( \left( \operatorname* { m a x } _ { j } \frac { \mathbf { W } _ { \mathrm { g } , i _ { l } , j } ^ { ( l ) } } { 2 \pi } \right) + \frac { \sigma _ { \mathrm { c u t } } \operatorname* { m i n } \{ \gamma _ { \mathrm { X } , i _ { l } } ^ { ( l ) } , \gamma _ { \mathrm { Y } , i _ { l } } ^ { ( l ) } \} } { 2 \pi } \right) ,
|
| 112 |
+
$$
|
| 113 |
+
|
| 114 |
+
where L corresponds to the number of layers, W(l)g , $\mathbf { W } _ { \mathrm { g } } ^ { ( l ) } , \gamma _ { \mathrm { X } } ^ { ( l ) } , \gamma _ { \mathrm { Y } } ^ { ( l ) }$ to the MAGNet parameters as defined in Eq. 8, and $\sigma _ { \mathrm { c u t } } { = } 2$ stdev to the cut-off frequency of the Gaussian envelopes in the Gabor filters. A formal treatment as well as the derivations can be found in Appx. A.1.
|
| 115 |
+
|
| 116 |
+
Effect of the FlexConv mask. The Gaussian mask used to localize the response of the MAGNet also has an effect on the frequency spectrum. Hence, the maximum frequency of a FlexConv kernel is:
|
| 117 |
+
|
| 118 |
+
$$
|
| 119 |
+
f _ { \mathrm { F l e x C o n v } } ^ { + } = f _ { \mathrm { M A G N e t } } ^ { + } + f _ { w _ { \mathrm { g a u s s } } } ^ { + } , \mathrm { w i t h } f _ { w _ { \mathrm { g a u s s } } } ^ { + } = \frac { \sigma _ { \mathrm { c u t } } } { \operatorname* { m a x } \{ \sigma _ { \mathrm { X } } , \sigma _ { \mathrm { Y } } \} 2 \pi } .
|
| 120 |
+
$$
|
| 121 |
+
|
| 122 |
+
Here, $\sigma _ { \mathrm { X } } , \sigma _ { \mathrm { Y } }$ correspond to the mask parameters (Eq. 1). Intuitively, multiplication with the mask blurs in the frequency domain, as it is equivalent to convolution with the Fourier transform of the mask.
|
| 123 |
+
|
| 124 |
+
Aliasing regularization of FlexConv kernels. With the analytic derivation of $f _ { \mathrm { F l e x C o n v } } ^ { + }$ we penalize the generated kernels to have frequencies smaller or equal to their Nyquist frequency $\hat { f } _ { \mathrm { N y q } } ( k )$ via:
|
| 125 |
+
|
| 126 |
+
$$
|
| 127 |
+
\begin{array} { r } { \mathcal { L } _ { \mathrm { H F } } = | | \operatorname* { m a x } \{ f _ { \mathrm { F l e x C o n v } } ^ { + } , f _ { \mathrm { N y q } } ( k ) \} - f _ { \mathrm { N y q } } ( k ) | | ^ { 2 } , \mathrm { w i t h } f _ { \mathrm { N y q } } ( k ) = \frac { k - 1 } { 4 } . } \end{array}
|
| 128 |
+
$$
|
| 129 |
+
|
| 130 |
+
Here, $k$ depicts the size of the FlexConv kernel before applying the Gaussian mask, and is equal to the size of the input signal. In practice, we implement Eq. 25 by regularizing the individual MAGNet layers, as is detailed in Appx. A.2. To verify our method, Fig. 8 (Appx. A.1) shows that the frequency components of FlexNet kernels are properly regularized for aliasing.
|
| 131 |
+
|
| 132 |
+
# 4 EXPERIMENTS
|
| 133 |
+
|
| 134 |
+
We evaluate FlexConv across classification tasks on sequential and image benchmark datasets, and validate the ability of MAGNets to approximate complex functions. A complete description of the datasets used is given in Appx. B. Appx. D.2 reports the parameters used in all our experiments.1
|
| 135 |
+
|
| 136 |
+
# 4.1 WHAT KIND OF FUNCTIONS CAN MAGNETS APPROXIMATE?
|
| 137 |
+
|
| 138 |
+
Bandwidth of methods with learnable sizes. First, we compare the bandwidth of MAGNet against N-Jet (Pintea et al., 2021) by optimizing each to fit simple targets: (i) Gabor filters of known frequency, (ii) random noise and (iii) an a $1 1 \times 1 1$ AlexNet kernel from the first layer (Krizhevsky et al., 2012). Fig. 4 shows that, even with 9 orders of Gaussian derivatives, N-Jets cannot fit high frequency signals in large kernels. Crucially, N-Jet models require many Gaussian derivative orders to model high frequency signals in large kernels: a hyperparameter which proportionally increases their inference time and parameter count. MAGNets, on the other hand, accurately model large high frequency signals. This allows FlexNets to learn large kernels with high frequency components.
|
| 139 |
+
|
| 140 |
+

|
| 141 |
+
Figure 4: Left: Final MSE after fitting each model to Gabor filters of different frequencies. N-Jets cannot fit high frequencies. Right: Kernels learned by each model. SIREN and MAGNet can fit all targets. MAGNet-S: a small MAGNet of size akin to N-Jets, still does well on the Gabor and AlexNet targets.
|
| 142 |
+
|
| 143 |
+
Table 1: Test accuracy and ablation studies on sMNIST, pMNIST, sCIFAR10 and npCIFAR10.
|
| 144 |
+
|
| 145 |
+
<table><tr><td>MODEL</td><td>SIZE</td><td>SMNIST</td><td>PMNIST</td><td>sCIFAR10</td><td>NPCIFAR10</td></tr><tr><td>DilRNN (Chang et al.,2017)</td><td>44K</td><td>98.0</td><td>96.1</td><td></td><td></td></tr><tr><td>IndRNN (Li et al., 2018)</td><td>83K</td><td>99.0</td><td>96.0</td><td></td><td></td></tr><tr><td>TCN (Bai et al.,2018a)</td><td>70K</td><td>99.0</td><td>97.2</td><td></td><td></td></tr><tr><td>r-LSTM(Trinh et al.,2018)</td><td>0.5M</td><td>98.4</td><td>95.2</td><td>72.2</td><td></td></tr><tr><td>Self-Att. (Trinh et al.,2018)</td><td>0.5M</td><td>98.9</td><td>97.9</td><td>62.2</td><td></td></tr><tr><td>TrellisNet (Bai et al.,2018b)</td><td>8M</td><td>99.20</td><td>98.13</td><td>73.42</td><td></td></tr><tr><td>URLSTM(Gu et al.,2020b)</td><td>-</td><td>99.28</td><td>96.96</td><td>71.00</td><td></td></tr><tr><td>URGRU + Zoneout (Gu et al.,2020b)</td><td>-</td><td>99.27</td><td>96.51</td><td>74.40</td><td></td></tr><tr><td>HiPPO (Gu et al.,2020a)</td><td>0.5M</td><td></td><td>98.30</td><td></td><td></td></tr><tr><td>Lipschitz RNN (Erichson et al.,2020)</td><td>158K</td><td>99.4</td><td>97.3</td><td>64.2</td><td>59.0</td></tr><tr><td>coRNN(Rusch& Mishra,2020)</td><td>134K</td><td>99.4</td><td>97.3</td><td>-</td><td>59.0</td></tr><tr><td>UnICORNN(Rusch& Mishra,2021)</td><td>135K</td><td>-</td><td>98.4</td><td>-</td><td>62.4</td></tr><tr><td>pLMU(Chilkuri & Eliasmith,2021)</td><td>165K</td><td>-</td><td>98.49</td><td>-</td><td>-</td></tr><tr><td>CKCNN-2</td><td>98K</td><td>99.31</td><td>98.00</td><td>62.25</td><td>60.5</td></tr><tr><td>CKCNN-2-Big</td><td>1M</td><td>99.32</td><td>98.54</td><td>63.74</td><td>62.2</td></tr><tr><td>CKTCNFOURIER-2</td><td>105K</td><td>99.44</td><td>98.40</td><td>68.28</td><td>66.26</td></tr><tr><td>CKTCNGABOR-2</td><td>106K</td><td>99.52</td><td>98.38</td><td>69.26</td><td>67.37</td></tr><tr><td>CKTCNMAGNET-2</td><td>105K</td><td>99.55</td><td>98.57</td><td>74.58</td><td>67.52</td></tr><tr><td>FlexTCN-2</td><td>108K</td><td>99.60</td><td>98.61</td><td>78.99</td><td>67.11</td></tr><tr><td>FlexTCN-4</td><td>241K</td><td>99.60</td><td>98.72</td><td>80.26</td><td>67.42</td></tr><tr><td>FlexTCN-6</td><td>375K</td><td>99.62</td><td>98.63</td><td>80.82</td><td>69.87</td></tr><tr><td>FlexTCNSIREN-6</td><td>343K</td><td>99.03</td><td>95.36</td><td>69.24</td><td>57.27</td></tr><tr><td>FlexTCNFourier-6</td><td>370K</td><td>99.49</td><td>97.97</td><td>74.79</td><td>67.35</td></tr><tr><td>FlexTCNGabor-6</td><td>373K</td><td>99.50</td><td>98.37</td><td>78.36</td><td>67.56</td></tr><tr><td>FlexTCNMAGNet-6</td><td>375K</td><td>99.62</td><td>98.63</td><td>80.82</td><td>69.87</td></tr></table>
|
| 146 |
+
|
| 147 |
+
Expressivity of MLP parameterizations. Next, we compare the descriptive power and convergence speed of MAGNets, Gabor MFNs, Fourier MFNs and SIRENs for image approximation. To this end, we fit the images in the Kodak dataset (Kodak, 1991) with each of these methods. Our results (Tab. 5) show that MAGNets outperform all other methods, and converge faster to good approximations.
|
| 148 |
+
|
| 149 |
+
# 4.2 CLASSIFICATION TASKS
|
| 150 |
+
|
| 151 |
+
Network specifications. Here, we specify our networks for all our classification experiments. We parameterize all our convolutional kernels as the superposition of a 3-layer MAGNet and a learnable anisotropic Gaussian mask. We construct two network instances for sequential and image datasets respectively: FlexTCNs and FlexNets. Both are constructed by taking the structure of a baseline network –TCN (Bai et al., 2018a) or CIFARResNet (He et al., 2016)–, removing all internal pooling layers, and replacing convolutional kernels by FlexConvs. The FlexNet architecture is shown in Fig. 10 and varies only in the number of channels and blocks, e.g., FlexNet-16 has 7 blocks. Akin to Romero et al. (2021) we utilize the Fourier theorem to speed up convolutions with large kernels.
|
| 152 |
+
|
| 153 |
+
Mask initialization. We initialize the FlexConv masks to be small. Preliminary experiments show this leads to better performance, faster execution, and faster training convergence. For sequences, the mask center is initialized at the last kernel position to prioritize the last information seen.
|
| 154 |
+
|
| 155 |
+
Time series and sequential data. First we evaluate FlexTCNs on sequential classification datasets, for which long-term dependencies play an important role. We validate our approach on intrinsic discrete data: sequential MNIST, permuted MNIST (Le et al., 2015), sequential CIFAR10 (Chang et al., 2017), noise-padded CIFAR10 (Chang et al., 2019), as well as time-series data: CharacterTrajectories (CT) (Bagnall et al., 2018), SpeechCommands (Warden, 2018) with raw waveform (SC_raw) and MFCC input representations (SC).
|
| 156 |
+
|
| 157 |
+
Table 2: Test accuracy on CT, SC and SC_raw
|
| 158 |
+
|
| 159 |
+
<table><tr><td>MODEL</td><td>SIZE</td><td>CT</td><td>SC</td><td>SC_RAW</td></tr><tr><td>GRU-ODE</td><td>89K</td><td>96.2</td><td>44.8</td><td>~10.0</td></tr><tr><td>GRU-△t</td><td>89K</td><td>97.8</td><td>20.0</td><td>~10.0</td></tr><tr><td>GRU-D</td><td>89K</td><td>95.9</td><td>23.9</td><td>~10.0</td></tr><tr><td>ODE-RNN</td><td>89K</td><td>97.1</td><td>93.2</td><td>~10.0</td></tr><tr><td>NCDE</td><td>89K</td><td>98.8</td><td>88.5</td><td>~10.0</td></tr><tr><td>CKCNN</td><td>100K</td><td>99.53</td><td>95.27</td><td>71.66</td></tr><tr><td>CKTCNFourier</td><td></td><td>=</td><td>95.65</td><td>74.90</td></tr><tr><td>CKTCNGabor</td><td></td><td>=</td><td>96.66</td><td>78.10</td></tr><tr><td>CKTCNMAGNet</td><td>105K</td><td>99.53</td><td>97.01</td><td>80.69</td></tr><tr><td>FlexTCN-2</td><td>105sK</td><td>99.53</td><td>97.10</td><td>88.03</td></tr><tr><td>FlexTCN-4</td><td>239K</td><td>99.53</td><td>97.73</td><td>90.45</td></tr><tr><td>FlexTCN-6</td><td>373K</td><td>99.53</td><td>97.67</td><td>91.73</td></tr><tr><td>FlexTCNSIREN-6</td><td>370K</td><td>-</td><td>95.83</td><td>85.73</td></tr><tr><td>FlexTCNFourier-6</td><td>342K</td><td></td><td>97.62</td><td>91.02</td></tr><tr><td>FlexTCNGabor-6</td><td>373K</td><td></td><td>97.35</td><td>91.50</td></tr><tr><td>FlexTCNMAGNet-6</td><td>373K</td><td></td><td>97.67</td><td>91.73</td></tr></table>
|
| 160 |
+
|
| 161 |
+
Table 3: Results on CIFAR-10. Results from \*original works and $^ \dagger$ single run.
|
| 162 |
+
|
| 163 |
+
<table><tr><td>MODEL</td><td>SIZE</td><td>CIFAR-10 Acc.</td><td>TIME (SEC/EPOCH)</td></tr><tr><td>CIFARResNet-44</td><td>0.66M</td><td>92.9*+</td><td>22</td></tr><tr><td>DCN-gji</td><td>0.47M</td><td>89.7±0.3*</td><td>-</td></tr><tr><td>N-Jet-CIFARResNet32</td><td>0.52M</td><td>92.3 ±0.3*</td><td>-</td></tr><tr><td>N-Jet-ALLCNN</td><td>1.07M</td><td>92.5± 0.1*</td><td>-</td></tr><tr><td>FlexNet-16 w/ conv.(k = 3)</td><td>0.17M</td><td>89.5 ± 0.3</td><td>41</td></tr><tr><td>FlexNet-16 w/conv. (k = 33)</td><td>20.0M</td><td>78.0± 0.3</td><td>242</td></tr><tr><td>FlexNet-16 w/N-Jet</td><td>0.70M</td><td>91.7 ± 0.1</td><td>409</td></tr><tr><td>CKCNN-16</td><td>0.63M</td><td>72.1 ± 0.2</td><td>68</td></tr><tr><td>CKCNNMAGNet-16</td><td>0.67M</td><td>86.8 ± 0.6</td><td>102</td></tr><tr><td>FlexNetsIREN-16</td><td>0.63M</td><td>89.0± 0.3</td><td>89</td></tr><tr><td>FlexNetGabor-16</td><td>0.67M</td><td>91.9 ± 0.2</td><td>161</td></tr><tr><td>FlexNetGabor-16 +anis. Gauss.</td><td>0.67M</td><td>92.0 ± 0.1</td><td>147</td></tr><tr><td>FlexNetGabor-16 +Gabor init.</td><td>0.67M</td><td>92.0± 0.2</td><td>150</td></tr><tr><td>FlexNet-16</td><td>0.67M</td><td>92.2 ± 0.1</td><td>127</td></tr></table>
|
| 164 |
+
|
| 165 |
+
Our results are summarized in Tables 1 and 2. FlexTCNs with two residual blocks obtain state-ofthe-art results on all tasks considered. In addition, depth further improves performance. FlexTCN-6 improves the current state-of-the-art on sCIFAR10 and npCIFAR10 by more than $6 \%$ . On the difficult SC_raw dataset –with sequences of length 16000–, FlexTCN-6 outperform the previous state-of-the-art by $2 0 . 0 7 \%$ : a remarkable improvement.
|
| 166 |
+
|
| 167 |
+
Furthermore, we conduct ablation studies by changing the parameterization of $\mathtt { M L P } ^ { \psi }$ , and switching off the learnable kernel size ("CKTCNs") and considering global kernel sizes instead. CKTCNs and FlexTCNs with MAGNet kernels outperform corresponding models with all other kernel parameterizations: SIRENs (Sitzmann et al., 2020), MGNs and MFNs (Fathony et al., 2021). Moreover, we see a consistent improvement with respect to CKCNNs (Romero et al., 2021) by using learnable kernel sizes. This shows that both MAGNets and learnable kernel sizes contribute to the performance of FlexTCNs. Note that in 1D, MAGNets are equivalent to MGNs. However, MAGNets consistently perform better than MGNs. This improvement in accuracy is a result of our MAGNet initialization.
|
| 168 |
+
|
| 169 |
+
Image classification. Next, we evaluate FlexNets for image classification on CIFAR-10 (Krizhevsky et al., 2009). Additional experiments on Imagenet-32, MNIST and STL-10 can be found in Appx. C.
|
| 170 |
+
|
| 171 |
+
Table 3 shows our results on CIFAR-10. FlexNets are competitive with pooling-based methods such as CIFARResNet (He et al., 2016) and outperform learnable kernel size method DCNs (Tomen et al., 2021). In addition, we compare using N-Jet layers of order three (as in Pintea et al. (2021)) in FlexNets against using MAGNet kernels. We observe that N-Jet layers lead to worse performance, and are significantly slower than FlexConv layers with MAGNet kernels. The low accuracy of N-Jet layers is likely to be linked to the fact that FlexNets do not use pooling. Consequently, N-Jets are forced to learn large kernels with high-frequencies, which we show N-Jets struggle learning in Sec. 4.1.
|
| 172 |
+
|
| 173 |
+
To illustrate the effect of learning kernel sizes, we also compare FlexNets against FlexNets with large and small discrete convolutional kernels (Tab. 3). Using small kernel sizes is parameter efficient, but is not competitive with FlexNets. Large discrete kernels on the other hand require a copious amount of parameters and lead to significantly worse performance. These results indicate that the best solution is somewhere in the middle and varying kernel sizes can learn the optimal kernel size for the task at hand.
|
| 174 |
+
|
| 175 |
+
Similar to the sequential case, we conduct ablation studies on image data with learnable, nonlearnable kernel sizes and different kernel parameterizations. Table 3 shows that FlexNets outperform CKCNNs with corresponding kernel parameterizations. In addition, a clear difference in performance is apparent for MAGNets with respect to other parameterizations. These results corroborate that both MAGNets and FlexConvs contribute to the performance of FlexNets. Moreover, Tab. 3 illustrates the effect of the two contributions of MAGNet over MGN: anisotropic Gabor filters, and our improved initialization. Our results in image data are in unison with our previous results for sequential data (Tabs. 1, 2) and illustrate the value of the proposed improvements in MAGNets.
|
| 176 |
+
|
| 177 |
+

|
| 178 |
+
Figure 5: Alias-free FlexNet-16 on CIFAR-10. We report change in accuracy between source and target resolutions, directly after upsampling (left) and after fine-tuning (right) (means over five runs).
|
| 179 |
+
|
| 180 |
+
# 4.3 ALIAS-FREE FLEXNETS
|
| 181 |
+
|
| 182 |
+
Regularizing the FlexConv mask. Though including f+wgauss in the frequency analysis of MAGNets is crucial for the accuracy of the derivation, including the FlexConv mask in aliasing regularization is undesirable, as it steers the model to learn large kernels in order to minimize the loss (see Eq. 25). However, excluding the mask from regularization could compromise the ability of FlexNet to generalize to higher resolutions. Here, we experiment with this trade-off.
|
| 183 |
+
|
| 184 |
+
Accuracy change after fine-tuning
|
| 185 |
+
Table 4: Alias-free FlexNets on CIFAR-10.
|
| 186 |
+
|
| 187 |
+
<table><tr><td>MODEL</td><td>SIZE</td><td colspan="2">CIFAR-10 ACC.</td></tr><tr><td></td><td></td><td>16 px</td><td>△16px 32 px</td></tr><tr><td>CIFARResNet-44</td><td>0.66M</td><td>85.8 ± 0.2</td><td>-31.6 ± 1.3</td></tr><tr><td>FlexNet-16 w/ conv. (k = 3) FlexNet-16 w/conv.(k = 33)</td><td>0.17M 20.0M</td><td>85.3± 0.2</td><td>-21.2 ± 1.0</td></tr><tr><td>FlexNet-16 w/N-Jets</td><td>0.70M</td><td>67.7 ± 0.6 86.4 ± 0.2</td><td>-57.1 ± 1.6 -5.5 ± 1.3</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td>CKCNN-16SIREN FlexNet-16sIREN</td><td>0.63m 0.63M</td><td>45.9 ± 1.0 70.4 ± 0.8</td><td>-15.8 ± 1.2</td></tr><tr><td></td><td></td><td></td><td>-50.0 ± 16.9</td></tr><tr><td>FlexNet-16 w/o reg.</td><td>0.67M</td><td>86.4 ± 0.4</td><td>-34.4 ± 14.3</td></tr><tr><td>FlexNet-16 w/reg.j fMAGNet FlexNet-16w/reg.JeConv</td><td>0.67M</td><td>86.5 ± 0.1</td><td>-3.8 ± 2.0</td></tr><tr><td></td><td>0.67M</td><td>85.1 ± 0.3</td><td>-3.3 ± 0.3</td></tr></table>
|
| 188 |
+
|
| 189 |
+
Figure 5 shows accuracy change between ten source and target resolution combinations on CIFAR-10, both for including and excluding the FlexConv mask in the aliasing regularization. We train at the source resolution for 100 epochs, before testing the model at the target resolution with the upsampling described in Sec. 3.3. Next, we adjust $f _ { \mathrm { N y q } } ( k )$ to the target resolution, and finetune each model for 100 epochs at the target resolution.
|
| 190 |
+
|
| 191 |
+
We find that regularizing just $f _ { \mathrm { M A G N e t } } ^ { + }$ yields a trade-off. It increases the accuracy difference
|
| 192 |
+
|
| 193 |
+
between low and high resolution inference, but also increases the fine-tune accuracy at the target resolution.We therefore choose to, by default, regularize $f _ { \mathrm { M A G N e t } } ^ { + }$ only.
|
| 194 |
+
|
| 195 |
+
Results of our alias-free FlexNet training on CIFAR-10 are in Table 4. We observe that the performance of a FlexNet trained without aliasing regularization largely breaks down when the dataset is upscaled. However, with our aliasing regularization most of the performance is retained.
|
| 196 |
+
|
| 197 |
+
Comparatively, FlexNet retains more of the source resolution performance than FlexNets with N-Jet layers, while baselines degrade drastically at the target resolution. Fig. 8 shows the effect of aliasing regularization on the frequency components of FlexConv.
|
| 198 |
+
|
| 199 |
+
Training at lower resolutions saves compute. We can train alias-free FlexNets at lower resolutions. To verify that this saves compute, we time the first 32 batches of training a FlexNet-7 on CIFAR-10. We compare against training on $1 6 \times 1 6$ images (downsampled before training). On 16x16 images, each batch takes $1 7 9 \mathrm { m s }$ $\left( \pm { } 7 \mathrm { m s } \right)$ . On $3 2 \mathrm { x } 3 2$ images, each batch takes $2 2 2 \mathrm { m s }$ $( \pm 9 \mathrm { { m s } ) }$ . Therefore, we save $24 \%$ training time when training FlexNets alias-free at half the native CIFAR-10 resolution.
|
| 200 |
+
|
| 201 |
+
# 5 DISCUSSION
|
| 202 |
+
|
| 203 |
+
Learned kernel sizes match conventional priors. Commonly, CNNs use architectures of small kernels and pooling layers. This allows convolutions to build a progressively growing receptive field. With learnable kernel sizes, FlexNet could learn a different prior over receptive fields, e.g., large kernels first, and small kernels next. However, FlexNets learn to increase kernel sizes progressively (Fig. 6), and match the network design that has been popular since AlexNet (Krizhevsky et al., 2012).
|
| 204 |
+
|
| 205 |
+
Mask initialization as a prior for feature importance. The initial values of the FlexConv mask can be used to prioritize information at particular input regions. For instance, initializing the center of mask on the first element of sequential FlexConvs can be used to prioritize information from the far past. This prior is advantageous for tasks such as npCIFAR10. We observe that using this prior on npCIFAR10 leads to much faster convergence and better results $6 8 . 3 3 \%$ acc. w/ FlexTCN-2).
|
| 206 |
+
|
| 207 |
+

|
| 208 |
+
Figure 6: Learned FlexConv masks for FlexNets with 3, 5 and 7 residual blocks. FlexNets learn very small kernels at shallow layers, which become larger as a function of depth.
|
| 209 |
+
|
| 210 |
+
MAGNet regularization as prior induction. MAGNets allow for analytic control of the properties of the resulting representations. We use this property to generate alias-free kernels. However, other desiderata could be induced, e.g., smoothness, for the construction of implicit neural representations.
|
| 211 |
+
|
| 212 |
+
Benefits of cropping and the influence of PyTorch. Dynamic cropping adjust the computational cost of the convolutions on the fly. For a signal of size M and a cropped kernel size $\mathrm { k \Omega }$ , this incurs in savings from $\mathrm { O } ( \mathrm { M } ^ { 2 ^ { D } } )$ to $\mathrm { O ( M ^ { D } k ^ { D } ) }$ relative to using global kernel sizes $\mathrm { ( O ( M ^ { 4 } ) }$ to $\mathrm { O } ( \mathrm { M } ^ { 2 } \mathrm { k } ^ { 2 } )$ in 2D). We test this theoretical speed up in a controlled environment for the Speech Commands and CIFAR10 datasets. Cropping reduces the per-epoch run time by a factor of $1 1 . 8 \mathrm { x }$ and $5 . 5 \mathrm { x }$ for Speech Commands and CIFAR-10, respectively. Interestingly, however, both run times become similar if the flag torch.backends.cudnn.benchmark is activated, with global kernel sizes being sometimes faster. This is because this flag tells PyTorch to optimize the convolution algorithms used under the hood, and some of these CUDA algorithms seem to be faster than our masking strategy on Python.
|
| 213 |
+
|
| 214 |
+
# 6 LIMITATIONS
|
| 215 |
+
|
| 216 |
+
Dynamic kernel sizes: computation and memory cost of convolutions with large kernels. Performing convolutions with large convolutional kernels is a compute-intensive operation. FlexConvs are initialized with small kernel sizes and their inference cost is relatively small at the start of training. However, despite the cropping operations used to improve computational efficiency (Figs. 1, 3, Tab. 3), the inference time may increase to up to double as the learned masks increase in size. At the cost of more memory, convolutions can be sped up by performing them in the frequency domain. However, we observe that this does not bring gains for the image data considered because FFT convolutions are faster only for very large convolutional kernels (in the order of hundreds of pixels).
|
| 217 |
+
|
| 218 |
+
Remaining accuracy drop in alias-free FlexNets. Some drop in accuracy is still observed when using alias-free FlexNets at a higher test resolutions (Tab. 4). Although more evidence is needed, this may be caused by aliasing effects introduced by ReLU (Vasconcelos et al., 2021), or changes in the activation statistics of the feature maps passed to global average pooling (Touvron et al., 2019).
|
| 219 |
+
|
| 220 |
+
# 7 CONCLUSION
|
| 221 |
+
|
| 222 |
+
We propose FlexConv, a convolutional operation able to learn high bandwidth convolutional kernels of varying size during training at a fixed parameter cost. We demonstrate that FlexConvs are able to model long-term dependencies without the need of pooling, and shallow pooling-free FlexNets achieve state-of-the-art performance on several sequential datasets, match performance of recent works with learned kernel sizes with less compute, and are competitive with much deeper ResNets on image benchmark datasets. In addition, we show that our alias-free convolutional kernels allow FlexNets to be deployed at higher resolutions than seen during training with minimal precision loss.
|
| 223 |
+
|
| 224 |
+
Future work. MAGNets give control over the bandwidth of the kernel. We anticipate that this control has more uses, such as fighting sub-sampling aliasing (Zhang, 2019; Kayhan & Gemert, 2020; Karras et al., 2021). With the ability to upscale FlexNets to different input image sizes comes the possibility of transfer learning representations between previously incompatible datasets, such as CIFAR-10 and Imagenet. In a similar vein, the automatic adaptation of FlexConv to the kernel sizes required for the task at hand may make it possible to generalize the FlexNet architecture across different tasks and datasets. Neural architecture search (Zoph & Le, 2016) could see benefits from narrowing the search space to exclude kernel size and pooling layers. In addition, we envisage additional improvements from structural developments of FlexConvs such as attentive FlexNets.
|
| 225 |
+
|
| 226 |
+
# REPRODUCIBILITY STATEMENT
|
| 227 |
+
|
| 228 |
+
We hope to inspire others to use and reproduce our work. We publish the source code of this work, for which the link is provided in Sec. 4.2. Sec. 4 and Appx. D.1 detail FlexNet, its hyperparameters and optimization procedure. The full derivation of the aliasing regularization objective is included in Appx. A.1. We report means over multiple runs for many experiments, to ensure the reported results are fair and reproducible, and do not rely on tuning of the random seed. All datasets used in our experiments are publicly available. If any questions remain, we welcome one and all to contact the corresponding author.
|
| 229 |
+
|
| 230 |
+
# ACKNOWLEDGMENTS
|
| 231 |
+
|
| 232 |
+
We thank Nergis Tömen for her valuable insights regarding signal processing principles for FlexConv, and Silvia-Laura Pintea for explanations and access to code of her work Pintea et al. (2021). We thank Yerlan Idelbayev for the use of the CIFARResNet code.
|
| 233 |
+
|
| 234 |
+
This work is co-supported by the Qualcomm Innovation Fellowship granted to David W. Romero. David W. Romero sincerely thanks Qualcomm for his support. David W. Romero is financed as part of the Efficient Deep Learning (EDL) programme (grant number P16-25), partly funded by the Dutch Research Council (NWO). Robert-Jan Bruintjes is financed by the Dutch Research Council (NWO) (project VI.Vidi.192.100). All authors sincerely thank everyone involved in funding this work.
|
| 235 |
+
|
| 236 |
+
This work was partially carried out on the Dutch national infrastructure with the support of SURF Cooperative. We used Weights & Biases (Biewald, 2020) for experiment tracking and visualizations.
|
| 237 |
+
|
| 238 |
+
# REFERENCES
|
| 239 |
+
|
| 240 |
+
Anthony Bagnall, Hoang Anh Dau, Jason Lines, Michael Flynn, James Large, Aaron Bostrom, Paul Southam, and Eamonn Keogh. The uea multivariate time series classification archive, 2018. arXiv preprint arXiv:1811.00075, 2018.
|
| 241 |
+
|
| 242 |
+
Shaojie Bai, J Zico Kolter, and Vladlen Koltun. An empirical evaluation of generic convolutional and recurrent networks for sequence modeling. arXiv preprint arXiv:1803.01271, 2018a.
|
| 243 |
+
|
| 244 |
+
Shaojie Bai, J Zico Kolter, and Vladlen Koltun. Trellis networks for sequence modeling. arXiv preprint arXiv:1810.06682, 2018b.
|
| 245 |
+
|
| 246 |
+
Lukas Biewald. Experiment tracking with weights and biases, 2020. URL https://www.wandb. com/. Software available from wandb.com.
|
| 247 |
+
|
| 248 |
+
Bo Chang, Minmin Chen, Eldad Haber, and Ed H Chi. Antisymmetricrnn: A dynamical system view on recurrent neural networks. arXiv preprint arXiv:1902.09689, 2019.
|
| 249 |
+
|
| 250 |
+
Shiyu Chang, Yang Zhang, Wei Han, Mo Yu, Xiaoxiao Guo, Wei Tan, Xiaodong Cui, Michael Witbrock, Mark A Hasegawa-Johnson, and Thomas S Huang. Dilated recurrent neural networks. In Advances in neural information processing systems, pp. 77–87, 2017.
|
| 251 |
+
|
| 252 |
+
Narsimha Chilkuri and Chris Eliasmith. Parallelizing legendre memory unit training. arXiv preprint arXiv:2102.11417, 2021.
|
| 253 |
+
|
| 254 |
+
Patryk Chrabaszcz, Ilya Loshchilov, and Frank Hutter. A downsampled variant of imagenet as an alternative to the CIFAR datasets. CoRR, abs/1707.08819, 2017. URL http://arxiv.org/ abs/1707.08819.
|
| 255 |
+
|
| 256 |
+
Adam Coates, Andrew Ng, and Honglak Lee. An analysis of single-layer networks in unsupervised feature learning. In Proceedings of the fourteenth international conference on artificial intelligence and statistics, pp. 215–223. JMLR Workshop and Conference Proceedings, 2011.
|
| 257 |
+
|
| 258 |
+
Jean-Baptiste Cordonnier, Andreas Loukas, and Martin Jaggi. On the relationship between selfattention and convolutional layers. arXiv preprint arXiv:1911.03584, 2019.
|
| 259 |
+
|
| 260 |
+
Jifeng Dai, Haozhi Qi, Yuwen Xiong, Yi Li, Guodong Zhang, Han Hu, and Yichen Wei. Deformable convolutional networks. In Proceedings of the IEEE international conference on computer vision, pp. 764–773, 2017.
|
| 261 |
+
|
| 262 |
+
J.G. Daugman. Complete discrete 2-d gabor transforms by neural networks for image analysis and compression. IEEE Transactions on Acoustics, Speech, and Signal Processing, 36(7):1169–1179, 1988. doi: 10.1109/29.1644.
|
| 263 |
+
|
| 264 |
+
N Benjamin Erichson, Omri Azencot, Alejandro Queiruga, Liam Hodgkinson, and Michael W Mahoney. Lipschitz recurrent neural networks. arXiv preprint arXiv:2006.12070, 2020.
|
| 265 |
+
|
| 266 |
+
Rizal Fathony, Anit Kumar Sahu, Devin Willmott, and J Zico Kolter. Multiplicative filter networks. In International Conference on Learning Representations, 2021. URL https://openreview. net/forum?id ${ . } = { }$ OmtmcPkkhT.
|
| 267 |
+
|
| 268 |
+
Marc Finzi, Samuel Stanton, Pavel Izmailov, and Andrew Gordon Wilson. Generalizing convolutional neural networks for equivariance to lie groups on arbitrary continuous data. arXiv preprint arXiv:2002.12880, 2020.
|
| 269 |
+
|
| 270 |
+
Albert Gu, Tri Dao, Stefano Ermon, Atri Rudra, and Christopher Ré. Hippo: Recurrent memory with optimal polynomial projections. arXiv preprint arXiv:2008.07669, 2020a.
|
| 271 |
+
|
| 272 |
+
Albert Gu, Caglar Gulcehre, Thomas Paine, Matt Hoffman, and Razvan Pascanu. Improving the gating mechanism of recurrent neural networks. In International Conference on Machine Learning, pp. 3800–3809. PMLR, 2020b.
|
| 273 |
+
|
| 274 |
+
Anders Hald. De moivre’s normal approximation to the binomial, 1733, and its generalization. A History of Parametric Statistical Inference from Bernoulli to Fisher, 1713–1935, pp. 17–24, 2007.
|
| 275 |
+
|
| 276 |
+
Shizhong Han, Zibo Meng, Zhiyuan Li, James O’Reilly, Jie Cai, Xiaofeng Wang, and Yan Tong. Optimizing filter size in convolutional neural networks for facial action unit recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2018.
|
| 277 |
+
|
| 278 |
+
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.
|
| 279 |
+
|
| 280 |
+
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.
|
| 281 |
+
|
| 282 |
+
Jorn-Henrik Jacobsen, Jan Van Gemert, Zhongyu Lou, and Arnold WM Smeulders. Structured receptive fields in cnns. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2610–2619, 2016.
|
| 283 |
+
|
| 284 |
+
HM Kabir, Moloud Abdar, Seyed Mohammad Jafar Jalali, Abbas Khosravi, Amir F Atiya, Saeid Nahavandi, and Dipti Srinivasan. Spinalnet: Deep neural network with gradual input. arXiv preprint arXiv:2007.03347, 2020.
|
| 285 |
+
|
| 286 |
+
Tero Karras, Miika Aittala, Samuli Laine, Erik Härkönen, Janne Hellsten, Jaakko Lehtinen, and Timo Aila. Alias-free generative adversarial networks. arXiv preprint arXiv:2106.12423, 2021.
|
| 287 |
+
|
| 288 |
+
Osman Semih Kayhan and Jan C. van Gemert. On translation invariance in cnns: Convolutional layers can exploit absolute spatial location. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), June 2020.
|
| 289 |
+
|
| 290 |
+
Patrick Kidger, James Morrill, James Foster, and Terry Lyons. Neural controlled differential equations for irregular time series. arXiv preprint arXiv:2005.08926, 2020.
|
| 291 |
+
|
| 292 |
+
Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
|
| 293 |
+
|
| 294 |
+
Kodak. Kodak dataset, 1991. URL http://r0k.us/graphics/kodak/.
|
| 295 |
+
|
| 296 |
+
Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. Technical report, 2009.
|
| 297 |
+
|
| 298 |
+
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. URL https://proceedings.neurips.cc/paper/2012/file/ c399862d3b9d6b76c8436e924a68c45b-Paper.pdf.
|
| 299 |
+
|
| 300 |
+
Quoc V Le, Navdeep Jaitly, and Geoffrey E Hinton. A simple way to initialize recurrent networks of rectified linear units. arXiv preprint arXiv:1504.00941, 2015.
|
| 301 |
+
|
| 302 |
+
Yann LeCun and Corinna Cortes. MNIST handwritten digit database. 2010. URL http://yann. lecun.com/exdb/mnist/.
|
| 303 |
+
|
| 304 |
+
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.
|
| 305 |
+
|
| 306 |
+
Shuai Li, Wanqing Li, Chris Cook, Ce Zhu, and Yanbo Gao. Independently recurrent neural network (indrnn): Building a longer and deeper rnn. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 5457–5466, 2018.
|
| 307 |
+
|
| 308 |
+
Min Lin, Qiang Chen, and Shuicheng Yan. Network in network. arXiv preprint arXiv:1312.4400, 2013.
|
| 309 |
+
|
| 310 |
+
Tony Lindeberg. Scale-covariant and scale-invariant gaussian derivative networks. In Scale Space and Variational Methods in Computer Vision :, volume 12679 of Springer Lecture Notes in Computer Science, pp. 3–14. Springer Nature, 2021. ISBN 978-3-030-75548-5. doi: 10.1007/ 978-3-030-75549-2_1. URL https://arxiv.org/abs/2011.14759. Not duplicate with DiVA 1505585QC 20210317.
|
| 311 |
+
|
| 312 |
+
Marco Loog and Francois Lauze. Supervised scale-regularized linear convolutionary filters. In Gabriel Brostow Tae-Kyun Kim, Stefanos Zafeiriou and Krystian Mikolajczyk (eds.), Proceedings of the British Machine Vision Conference (BMVC), pp. 162.1–162.11. BMVA Press, September 2017. ISBN 1-901725-60-X. doi: 10.5244/C.31.162. URL https://dx.doi.org/10. 5244/C.31.162.
|
| 313 |
+
|
| 314 |
+
Ilya Loshchilov and Frank Hutter. Sgdr: Stochastic gradient descent with warm restarts. arXiv preprint arXiv:1608.03983, 2016.
|
| 315 |
+
|
| 316 |
+
Chunjie Luo, Jianfeng Zhan, Lei Wang, and Wanling Gao. Extended batch normalization. arXiv preprint arXiv:2003.05569, 2020.
|
| 317 |
+
|
| 318 |
+
Vittorio Mazzia, Francesco Salvetti, and Marcello Chiaberge. Efficient-capsnet: Capsule network with self-attention routing. arXiv preprint arXiv:2101.12491, 2021.
|
| 319 |
+
|
| 320 |
+
Duc Nguyen. Robust deep learning for computer vision to counteract data scarcity and label noise. PhD thesis, 01 2020.
|
| 321 |
+
|
| 322 |
+
Jeong Joon Park, Peter Florence, Julian Straub, Richard Newcombe, and Steven Lovegrove. Deepsdf: Learning continuous signed distance functions for shape representation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 165–174, 2019.
|
| 323 |
+
|
| 324 |
+
Chao Peng, Xiangyu Zhang, Gang Yu, Guiming Luo, and Jian Sun. Large kernel matters–improve semantic segmentation by global convolutional network. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 4353–4361, 2017.
|
| 325 |
+
|
| 326 |
+
Silvia L Pintea, Nergis Tomen, Stanley F Goes, Marco Loog, and Jan C van Gemert. Resolution learning in deep convolutional networks using scale-space theory. arXiv preprint arXiv:2106.03412, 2021.
|
| 327 |
+
|
| 328 |
+
David W Romero, Anna Kuzina, Erik J Bekkers, Jakub M Tomczak, and Mark Hoogendoorn. Ckconv: Continuous kernel convolution for sequential data. arXiv preprint arXiv:2102.02611, 2021.
|
| 329 |
+
|
| 330 |
+
T Konstantin Rusch and Siddhartha Mishra. Coupled oscillatory recurrent neural network (cornn): An accurate and (gradient) stable architecture for learning long time dependencies. arXiv preprint arXiv:2010.00951, 2020.
|
| 331 |
+
|
| 332 |
+
T Konstantin Rusch and Siddhartha Mishra. Unicornn: A recurrent model for learning very long time dependencies. arXiv preprint arXiv:2103.05487, 2021.
|
| 333 |
+
|
| 334 |
+
Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, Alexander C. Berg, and Li Fei-Fei. ImageNet Large Scale Visual Recognition Challenge. International Journal of Computer Vision (IJCV), 115 (3):211–252, 2015. doi: 10.1007/s11263-015-0816-y.
|
| 335 |
+
|
| 336 |
+
Kristof Schütt, Pieter-Jan Kindermans, Huziel Enoc Sauceda Felix, Stefan Chmiela, Alexandre Tkatchenko, and Klaus-Robert Müller. Schnet: A continuous-filter convolutional neural network for modeling quantum interactions. In Advances in neural information processing systems, pp. 991–1001, 2017.
|
| 337 |
+
|
| 338 |
+
Evan Shelhamer, Dequan Wang, and Trevor Darrell. Blurring the line between structure and learning to optimize and adapt receptive fields. ArXiv, abs/1904.11487, 2019.
|
| 339 |
+
|
| 340 |
+
Shaoshuai Shi, Zhe Wang, Jianping Shi, Xiaogang Wang, and Hongsheng Li. From points to parts: 3d object detection from point cloud with part-aware and part-aggregation network. arXiv preprint arXiv:1907.03670, 2019.
|
| 341 |
+
|
| 342 |
+
Martin Simonovsky and Nikos Komodakis. Dynamic edge-conditioned filters in convolutional neural networks on graphs. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 3693–3702, 2017.
|
| 343 |
+
|
| 344 |
+
Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014.
|
| 345 |
+
|
| 346 |
+
Vincent Sitzmann, Julien Martel, Alexander Bergman, David Lindell, and Gordon Wetzstein. Implicit neural representations with periodic activation functions. Advances in Neural Information Processing Systems, 33, 2020.
|
| 347 |
+
|
| 348 |
+
Nitish Srivastava, Geoffrey Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. Dropout: A simple way to prevent neural networks from overfitting. Journal of Machine Learning Research, 15(56):1929–1958, 2014. URL http://jmlr.org/papers/v15/ srivastava14a.html.
|
| 349 |
+
|
| 350 |
+
Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 1–9, 2015.
|
| 351 |
+
|
| 352 |
+
Domen Tabernik, Matej Kristan, and Ales Leonardis. Spatially-adaptive filter units for compact and efficient deep neural networks. International Journal of Computer Vision, 128, 09 2020. doi: 10.1007/s11263-019-01282-1.
|
| 353 |
+
|
| 354 |
+
Mingxing Tan and Quoc Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In International Conference on Machine Learning, pp. 6105–6114. PMLR, 2019.
|
| 355 |
+
|
| 356 |
+
Nathaniel Thomas, Tess Smidt, Steven Kearnes, Lusann Yang, Li Li, Kai Kohlhoff, and Patrick Riley. Tensor field networks: Rotation-and translation-equivariant neural networks for 3d point clouds. arXiv preprint arXiv:1802.08219, 2018.
|
| 357 |
+
|
| 358 |
+
Nergis Tomen, Silvia-Laura Pintea, and Jan Van Gemert. Deep continuous networks. 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. 10324–10335. PMLR, 18–24 Jul 2021. URL https://proceedings.mlr.press/v139/tomen21a.html.
|
| 359 |
+
|
| 360 |
+
Hugo Touvron, A. Vedaldi, M. Douze, and H. Jégou. Fixing the train-test resolution discrepancy. In NeurIPS, 2019.
|
| 361 |
+
|
| 362 |
+
Trieu H Trinh, Andrew M Dai, Minh-Thang Luong, and Quoc V Le. Learning longer-term dependencies in rnns with auxiliary losses. arXiv preprint arXiv:1803.00144, 2018.
|
| 363 |
+
|
| 364 |
+
Cristina Vasconcelos, Hugo Larochelle, Vincent Dumoulin, Rob Romijnders, Nicolas Le Roux, and Ross Goroshin. Impact of aliasing on generalization in deep convolutional networks. arXiv preprint arXiv:2108.03489, 2021.
|
| 365 |
+
|
| 366 |
+
Shenlong Wang, Simon Suo, Wei-Chiu Ma, Andrei Pokrovsky, and Raquel Urtasun. Deep parametric continuous convolutional neural networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2589–2597, 2018.
|
| 367 |
+
|
| 368 |
+
Pete Warden. Speech commands: A dataset for limited-vocabulary speech recognition. arXiv preprint arXiv:1804.03209, 2018.
|
| 369 |
+
|
| 370 |
+
Zhitong Xiong, Yuan Yuan, Nianhui Guo, and Qi Wang. Variational context-deformable convnets for indoor scene parsing. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), June 2020.
|
| 371 |
+
|
| 372 |
+
Sergey Zagoruyko and Nikos Komodakis. Wide residual networks. arXiv preprint arXiv:1605.07146, 2016.
|
| 373 |
+
|
| 374 |
+
Richard Zhang. Making convolutional networks shift-invariant again. In International conference on machine learning, pp. 7324–7334. PMLR, 2019.
|
| 375 |
+
|
| 376 |
+
Barret Zoph and Quoc V Le. Neural architecture search with reinforcement learning. arXiv preprint arXiv:1611.01578, 2016.
|
| 377 |
+
|
| 378 |
+

|
| 379 |
+
Figure 7: Example kernels, generated step by step. FlexConv samples a kernel from $\mathtt { M I P } ^ { \psi }$ (a), which is attenuated by an anistropic Gaussian envelope with learned parameters $\pmb \theta ^ { ( l ) }$ (b), creating (c) which is cropped to contain only values of $> 0 . 1$ (d).
|
| 380 |
+
|
| 381 |
+
# A ALIAS-FREE FLEXCONV REGULARIZATION
|
| 382 |
+
|
| 383 |
+
In this section we provide the complete derivation and analysis for our FlexConv regularization against aliasing. First, we derive the analytic maximum frequency component of a FlexConv kernel. Next, we compute the Nyquist frequency of a FlexConv kernel, and subsequently show how to combine the previous results into a regularization term to train alias-free FlexConvs.
|
| 384 |
+
|
| 385 |
+
# A.1 ANALYZING THE FREQUENCY SPECTRUM OF FLEXCONV
|
| 386 |
+
|
| 387 |
+
In order to make FlexConv alias-free (Sec. 3.3), we need to compute the maximum frequency component of the kernels generated by a MAGNet, so that we can regularize it during training. In this section we analytically derive this maximum frequency component from the parameters of the MAGNet.
|
| 388 |
+
|
| 389 |
+
Recall that MAGNets generate a kernel $\psi ( x , y )$ through of a succession of anisotropic Gabor filters and linear layers (Sec. 3.2, Eqs. 2–7):
|
| 390 |
+
|
| 391 |
+
$$
|
| 392 |
+
\begin{array} { r l r l } & { \mathbf { h } ^ { ( 1 ) } = \mathbf { g } \big ( [ x , y ] ; \theta ^ { ( 1 ) } \big ) } & & { \mathbf { g } \colon \mathbb { R } ^ { 2 } \to \mathbb { R } ^ { \mathrm { N _ { h i d } } } } \\ & { \mathbf { h } ^ { ( l ) } = \big ( \mathbf { W } ^ { ( l ) } \mathbf { h } ^ { ( l - 1 ) } + \mathbf { b } ^ { ( l ) } \big ) \cdot \mathbf { g } \big ( [ x , y ] ; \theta ^ { ( l ) } \big ) } & & { \mathbf { W } ^ { ( l ) } \in \mathbb { R } ^ { \mathrm { N _ { h i d } \times N _ { h i d } } } , \mathbf { b } ^ { ( l ) } \in \mathbb { R } ^ { \mathrm { N _ { h i d } } } } \\ & { \psi ( x , y ) = \mathbf { W } ^ { ( \mathrm { L } ) } \mathbf { h } ^ { ( \mathrm { L } - 1 ) } + \mathbf { b } ^ { ( \mathrm { L } ) } } & & { \mathbf { W } ^ { ( \mathrm { L } ) } \in \mathbb { R } ^ { ( \mathrm { N _ { o u t } \times N _ { \mathrm { i n } } } ) \times \mathrm { N _ { h i d } } } , \mathbf { b } ^ { ( \mathrm { L } ) } \in \mathbb { R } ^ { ( \mathrm { N _ { o u t } \times N _ { \mathrm { i n } } } ) } } \\ & { \mathbf { g } \big ( [ x , y ] ; \theta ^ { ( l ) } \big ) = \mathrm { e x p } \Bigg ( - \displaystyle \frac { 1 } { 2 } \Big [ \Big ( \gamma _ { \mathrm { X } } ^ { ( l ) } \big ( x - \mu _ { \mathrm { X } } ^ { ( l ) } \big ) \Big ) ^ { 2 } + \Big ( \gamma _ { \mathrm { Y } } ^ { ( l ) } \big ( y - \mu _ { \mathrm { Y } } ^ { ( l ) } \big ) \Big ) ^ { 2 } \Big ] \Bigg ) \mathrm { S i n } \big ( \mathbf { W } _ { \mathrm { g } } ^ { ( l ) } [ x , y ] + \mathbf { b } _ { \mathrm { g } } ^ { ( l ) } \big ) } \\ & \theta ^ { ( l ) } = \Big \{ \gamma _ { \mathrm { X } } ^ { ( l ) } \in \mathbb { R } ^ { \mathrm { N _ { h i d } } } , \gamma _ { \mathrm { Y } } ^ { ( l ) } \in \mathbb { R } ^ { \mathrm { N _ { h i d } } } , \mu _ { \mathrm { X } } ^ { ( l ) } \in \mathbb { R } ^ { \mathrm { N _ { h i d } } } , \mu _ { \mathrm { Y } } ^ \end{array}
|
| 393 |
+
$$
|
| 394 |
+
|
| 395 |
+
To analyse the maximum frequency component $f _ { \mathrm { M A G N e t } } ^ { + }$ , we analyse the frequency components of the Gabor filters used in MAGNet, and retain their maximum. We then plug the found frequency component into the analysis of Fathony et al. (2021) to show how the frequency responses of Gabor filters and linear layers interact in MFNs. Finally, we add the effect of the FlexConv Gaussian mask to our analysis to obtain the maximum frequency component ot the final FlexConv kernel $f _ { \mathrm { F l e x C o n v } } ^ { + }$ .
|
| 396 |
+
|
| 397 |
+
Sine term in Gabor filters. In a Gabor filter, the sine term is multiplied with a Gaussian envelope. The frequency (in radians) of a sine function of the form $\mathrm { S i n } ( { \pmb w } ^ { T } [ x , \overset { \cdot } { y } ] + b )$ is given by $\pmb { w }$ . We divide by $2 \pi$ to convert the frequency units to Hertz, for compatibility with the rest of the analysis. For 2D inputs, the maximum frequency component of the sine function correspond to the largest frequency in the two input dimensions:
|
| 398 |
+
|
| 399 |
+
$$
|
| 400 |
+
f _ { \mathrm { S i n } } ^ { + } = \operatorname* { m a x } _ { j } \frac { w _ { j } } { 2 \pi } .
|
| 401 |
+
$$
|
| 402 |
+
|
| 403 |
+
The sine terms in MAGNets have multiple output channels: $\mathrm { S i n } \big ( \mathbf { W } _ { \mathrm { g } } \cdot [ x , y ] + \mathbf { b } _ { \mathrm { g } } ^ { ( l ) } \big )$ . Effectively, we compute the sine term independently for each channel:
|
| 404 |
+
|
| 405 |
+
$$
|
| 406 |
+
f _ { \mathrm { S i n } , i } ^ { + } = \operatorname* { m a x } _ { j } \frac { \mathbf { W } _ { \mathrm { g } , i , j } } { 2 \pi } .
|
| 407 |
+
$$
|
| 408 |
+
|
| 409 |
+

|
| 410 |
+
(c) Regularizing f +FlexConv, block 4 of 7.
|
| 411 |
+
Figure 8: Example kernels from FlexNet-16 models trained (i) without regularization, (ii) with aliasing regularization of $f _ { \mathrm { M A G N e t } } ^ { + }$ , (iii) with aliasing regularization of $f _ { \mathrm { F l e x C o n v } } ^ { + }$ . In the columns, from left to right: (i) original kernel at $3 3 \times 3 3$ , (ii) FFT of the original kernel, (iii) kernel inferred at $6 5 \times 6 5$ , to find aliasing effects, (iiii) FFT of the $6 5 \times 6 5$ kernel, with the solid line showing the Nyquist frequency of the $3 3 \times 3 3$ kernel, and the red dotted line showing the maximum frequency component ×as computed by our analysis. For $f _ { \mathrm { F l e x C o n v } } ^ { + }$ the maximum frequency matches almost exactly with the Nyquist frequency, showing that our aliasing regularization works. For $f _ { \mathrm { M A G N e t } } ^ { + }$ , the maximum frequency is slightly higher than the Nyquist frequency, as the FlexConv mask is not included in the frequency term derivation. This is reflected in the slightly worse resolution generalization results reported in Sec. 4.3. Furthermore, some aliasing effects are still apparent for the aliasing regularized models, as discussed in Sec. 6.
|
| 412 |
+
|
| 413 |
+
Gaussian term in Gabor filters. In a Gabor filter, a Gaussian envelope modulates a sine term. Let us assume for now that the Gaussian envelope is isotropic, rather than anisotropic as in MAGNets, and has single-channel output. By applying the convolution theorem, the sine term is equivalently convolved with the Fourier transform of the Gaussian envelope in the frequency domain. Since the Fourier transform of a Gaussian envelope is another Gaussian envelope, the application of a Gaussian envelope amounts to blurring with a Gaussian kernel in the frequency domain. The size of the envelope in the Fourier domain $\sigma _ { \mathrm { F } }$ can be derived from the standard deviation of the Guassian envelope in the spatial domain $\sigma _ { \mathrm { T } }$ as follows:
|
| 414 |
+
|
| 415 |
+
$$
|
| 416 |
+
\sigma _ { \mathrm { T } } \sigma _ { \mathrm { F } } = \frac { 1 } { 2 \pi } \Rightarrow \sigma _ { \mathrm { F } } = \frac { 1 } { 2 \pi \sigma _ { \mathrm { T } } } .
|
| 417 |
+
$$
|
| 418 |
+
|
| 419 |
+
Gaussian blurs induce impulse signals to have a long tail. Consequently, we must define a cutoff point for this tail in terms of standard deviations to derive the maximum added frequency induced by the blur. We describe the cutoff point as $\sigma _ { \mathrm { c u t } } \in \mathbb { N }$ . Typical choices for $\sigma _ { \mathrm { c u t } }$ are known as the ∈empirical, or the "68-95-99.7" rule (Hald, 2007). We choose a standard of two standard deviations, i.e., $\sigma _ { \mathrm { c u t } } { = } 2$ , which covers $9 5 \%$ of the mass of the Gaussian envelope.
|
| 420 |
+
|
| 421 |
+
For an isotropic Gabor filter with $\gamma { = } \sigma _ { \mathrm { T } } ^ { - 1 }$ , the maximum frequency of its Gaussian envelope $f _ { \mathrm { e n v } } ^ { + }$ is:
|
| 422 |
+
|
| 423 |
+
$$
|
| 424 |
+
f _ { \mathrm { e n v } } ^ { + } = \frac { \sigma _ { \mathrm { c u t } } } { 2 \pi ( \sigma _ { \mathrm { T } } ) ^ { - 1 } } = \frac { \sigma _ { \mathrm { c u t } } \gamma } { 2 \pi } .
|
| 425 |
+
$$
|
| 426 |
+
|
| 427 |
+
Anisotropic envelopes. Our analysis so far assumes an isotropic Gaussian envelope in the Gabor filter. However, we need to account for the anisotropic Gaussian envelopes in MAGNets. Anisotropic filters have not one but two $\gamma$ parameters: $\{ \gamma _ { \mathrm { X } } , \gamma _ { \mathrm { Y } } \}$ . The smallest of these will contribute most to $f _ { \mathrm { e n v } } ^ { + }$ , as it will blur the most, so it is sufficient to compute $f _ { \mathrm { e n v } } ^ { + }$ only using the smallest of the two $\gamma$ terms:
|
| 428 |
+
|
| 429 |
+
$$
|
| 430 |
+
f _ { \mathrm { e n v } } ^ { + } \big ( \gamma _ { X } , \gamma _ { Y } \big ) = f _ { \mathrm { e n v } } ^ { + } \big ( \operatorname* { m i n } \{ \gamma _ { X } , \gamma _ { Y } \} \big ) .
|
| 431 |
+
$$
|
| 432 |
+
|
| 433 |
+
The other assumption we made before was to work with single-channel outputs. MAGNets however use multi-channel outputs with independent Gaussian terms. The maximum frequency of multichannel Gaussian envelopes is given by:
|
| 434 |
+
|
| 435 |
+
$$
|
| 436 |
+
f _ { \mathrm { e n v } , i } ^ { + } ( \gamma _ { \mathrm { X } } , \gamma _ { \mathrm { Y } } ) = f _ { \mathrm { e n v } } ^ { + } \left( \operatorname* { m i n } \{ \gamma _ { \mathrm { X } , i } , \gamma _ { \mathrm { Y } , i } \} \right) = \frac { \sigma _ { \mathrm { c u t } } \operatorname* { m i n } \{ \gamma _ { \mathrm { X } , i } , \gamma _ { \mathrm { Y } , i } \} } { 2 \pi } ,
|
| 437 |
+
$$
|
| 438 |
+
|
| 439 |
+
where the subscript $i$ indexes the channels of the multi-channel Gaussian envelopes.
|
| 440 |
+
|
| 441 |
+
Maximum frequency component of anisotropic Gabor filters. Finally, the maximum frequency component of the $i$ -th channel of an anisotropic Gabor filter $\mathbf { g }$ is given by:
|
| 442 |
+
|
| 443 |
+
$$
|
| 444 |
+
\begin{array} { r l } & { f _ { \mathrm { G a b o r } , i } ^ { + } = f _ { \mathrm { S i n } , i } ^ { + } ( \mathbf { W } _ { \mathrm { g } } ) + f _ { \mathrm { e n v } , i } ^ { + } ( \gamma _ { \mathrm { X } } , \gamma _ { \mathrm { Y } } ) } \\ & { ~ = \left( \displaystyle \operatorname* { m a x } _ { j } \frac { \mathbf { W } _ { \mathrm { g } , i , j } } { 2 \pi } \right) + \frac { \sigma _ { \mathrm { c u t } } \operatorname* { m i n } \left\{ \gamma _ { \mathrm { X } , i } , \gamma _ { \mathrm { Y } , i } \right\} } { 2 \pi } . } \end{array}
|
| 445 |
+
$$
|
| 446 |
+
|
| 447 |
+
Figure 9 illustrates the frequency spectrum of an example Gabor filter.
|
| 448 |
+
|
| 449 |
+
Maximum frequency component of a MAGNet. Fathony et al. (2021) characterize the expansion of each term of the isotropic Gabor layers in MFNs in the final MFN output. In Eq. 25, Fathony et al. (2021) demonstrate that the MFN representation contains a set of sine frequencies $\overline { { \omega } }$ given by:
|
| 450 |
+
|
| 451 |
+
$$
|
| 452 |
+
\overline { { \omega } } = \left\{ s _ { \mathrm { L } } \omega _ { i _ { \mathrm { L } } } ^ { ( \mathrm { L } ) } + s _ { \mathrm { L } - 1 } \omega _ { i _ { \mathrm { L } - 1 } } ^ { ( \mathrm { L } - 1 ) } + \cdots + s _ { l } \omega _ { i _ { 2 } } ^ { ( 2 ) } + \omega _ { i _ { 1 } } ^ { ( 1 ) } \right\} .
|
| 453 |
+
$$
|
| 454 |
+
|
| 455 |
+
Here, the indexes $i _ { 1 } , i _ { 2 } , \cdots , i _ { \mathrm { L - 1 } }$ range over all possible indices of each hidden unit of each layer of an MFN, and $s _ { 2 } , \cdots , s _ { \mathrm { L } } \in \{ - 1 , + 1 \}$ range over all $2 ^ { \mathrm { L - 1 } }$ possible binary signs. In other words, ∈Fathony et al. (2021) demonstrate that the representation of an MFN at a particular layer contains an exponential combination of all possible positive and negative combinations of the frequencies of the sine terms in each hidden unit at each layer in the MFN up to the current layer.
|
| 456 |
+
|
| 457 |
+
The original analysis uses these terms to argue that MFNs model exponentially many terms through a linear amount of layers. For our purpose of computing the frequency response of the MAGNet generated kernel, we can plug our derivation of the frequencies of the Gabor filter $f _ { \mathrm { G a b o r } }$ into $\overline { { \omega } }$ to compute the frequency spectrum of the generated kernel:
|
| 458 |
+
|
| 459 |
+
$$
|
| 460 |
+
{ \pmb f } _ { \mathrm { M A G N e t } } ^ { + } = \left\{ s _ { \mathrm { L } } f _ { \mathrm { G a b o r } , i _ { \mathrm { L } } } ^ { ( \mathrm { L } ) } + s _ { \mathrm { L } - 1 } f _ { \mathrm { G a b o r } , i _ { \mathrm { L } - 1 } } ^ { ( \mathrm { L } - 1 ) } + \cdots + s _ { 2 } f _ { \mathrm { G a b o r } , i _ { 2 } } ^ { ( 2 ) } + f _ { \mathrm { G a b o r } , i _ { 1 } } ^ { ( 1 ) } \right\} .
|
| 461 |
+
$$
|
| 462 |
+
|
| 463 |
+

|
| 464 |
+
Figure 9: Decomposition of a Gabor filter and its frequency spectrum. Top row: a decomposition of a Gabor filter (right) into its Gaussian term (left) and its sine term (center). Bottom row: frequency responses for each respective filter. The Fourier transform of a Gaussian envelope is a Gaussian envelope (blue circles show $\sigma { \mathcal { F } }$ for $h = \lbrace 1 , 2 \rbrace$ ). The Fourier transform of a sine pattern is a collection of symmetrical impulse signals (red box shows the Nyquist frequency). The Gaussian envelope blurs the frequency response of the sine term (purple boxes show the frequency response for $h = \{ \bar { 1 } , 2 , 3 \}$ ).
|
| 465 |
+
|
| 466 |
+
As stated before, we are only interested in the maximum frequency in the frequency spectrum. We can therefore simplify Eq. 18 in two ways. First, we simplify over MAGNet layers by taking the maximum value of the spectrum, which is the sum over all layers using only the positive binary signs in $s _ { \mathrm { L } }$ (Eq. 19). Next, we simplify over channel indices by retaining only the channel index that results in the highest frequency (Eq. 20). The maximum frequency of a MAGNet is shown in Eq. 21:
|
| 467 |
+
|
| 468 |
+
$$
|
| 469 |
+
\begin{array} { r l } & { f _ { \mathrm { M A G M v e t } } ^ { + } = \{ ( + 1 ) f _ { \mathrm { G a b o r } , i _ { 2 } } ^ { + ( \mathrm { L } ) } + ( + 1 ) f _ { \mathrm { G a b o r } , i _ { 1 } - 1 } ^ { + ( \mathrm { L } ) } + \cdots + ( + 1 ) f _ { \mathrm { G a b o r } , i _ { 2 } } ^ { + ( 2 ) } + f _ { \mathrm { G a b o r } , i _ { 1 } } ^ { + ( 1 ) } \} } \\ & { \qquad = \{ f _ { \mathrm { G a b o r } , i _ { 1 } } ^ { + ( \mathrm { L } ) } + f _ { \mathrm { G a b o r } , i _ { 1 } - 1 } ^ { + ( \mathrm { L } ) } + \cdots + f _ { \mathrm { G a b o r } , i _ { 2 } } ^ { + ( 2 ) } + f _ { \mathrm { G a b o r } , i _ { 1 } } ^ { + ( 1 ) } \} } \\ & { f _ { \mathrm { M A G N e t } } ^ { + } = \displaystyle \operatorname* { m a x } _ { i _ { \perp } } ( f _ { \mathrm { G a b o r } , i _ { 2 } } ^ { + ( \mathrm { L } ) } ) + \operatorname* { m a x } _ { i _ { 1 } , \mathrm { L } - 1 } ( f _ { \mathrm { G a b o r } , i _ { 1 } - 1 } ^ { + ( \mathrm { L } ) } ) \cdots + \displaystyle \operatorname* { m a x } _ { i _ { 2 } } ( f _ { \mathrm { G a b o r } , i _ { 2 } } ^ { + ( 2 ) } ) + \operatorname* { m a x } _ { i _ { 1 } } ( f _ { \mathrm { G a b o r } , i _ { 1 } } ^ { + ( 1 ) } ) } \\ & { \qquad = \displaystyle \sum _ { l = 1 } ^ { \mathrm { L } } \operatorname* { m a x } ( f _ { \mathrm { G a b o r } , i _ { 1 } } ^ { + ( l ) } ) } \\ & \qquad = \displaystyle \sum _ { l = 1 } ^ { \mathrm { L } } \operatorname* { m a x } _ { i _ { l } } ( ( \operatorname* { m a x } _ { j } \frac { \mathbf { W } _ { \mathrm { g } , i _ { 1 } , j } ^ { ( l ) } } { 2 \pi } ) + \frac \sigma _ { \mathrm { c u t } } \operatorname* { m i n } \{ \gamma _ { \mathrm { X } , i _ { 1 } } ^ { ( l ) } , \gamma _ \mathrm { Y } , i \end{array}
|
| 470 |
+
$$
|
| 471 |
+
|
| 472 |
+
Effect of the Gaussian mask in the frequency components of a FlexConv. FlexConvs attenuate the MAGNet output with a Gaussian mask. The Gaussian mask (Eq. 1) works analogously to the Gaussian envelope term in the Gabor filter: it blurs the frequency components of the generated kernel with standard deviation $\sigma _ { \mathrm { F } }$ . Therefore, we can reuse our derivation for the Gaussian envelope of the
|
| 473 |
+
|
| 474 |
+
Gabor filter (Eq. 15). The maximum frequency component of a FlexConv kernel is given by:
|
| 475 |
+
|
| 476 |
+
$$
|
| 477 |
+
\begin{array} { r l } & { f _ { \mathrm { H e x C o n v } } ^ { + } = f _ { \mathrm { M A G N e t } } ^ { + } + f _ { \mathrm { e n v } } ^ { + } } \\ & { \phantom { f _ { \mathrm { M A G N e t } } ^ { + } + \frac { \sigma _ { \mathrm { c u t } } \operatorname* { m i n } \left\{ \sigma _ { \mathrm { X } } ^ { - 1 } , \sigma _ { \mathrm { Y } } ^ { - 1 } \right\} } { 2 \pi } } = f _ { \mathrm { M A G N e t } } ^ { + } + \frac { \sigma _ { \mathrm { c u t } } } { \operatorname* { m a x } \left\{ \sigma _ { \mathrm { X } } , \sigma _ { \mathrm { Y } } \right\} 2 \pi } } \\ & \phantom { f _ { \mathrm { M A G N e t } } ^ { - } + \frac { \sigma _ { \mathrm { m a x } } } { l _ { u } } \left( \left( \operatorname* { m a x } _ { j } \frac { \mathbf { W } _ { \mathbf { g } , i _ { l } , j } ^ { ( l ) } } { 2 \pi } \right) + \frac { \sigma _ { \mathrm { c u t } } \operatorname* { m i n } \left\{ \gamma _ { \mathrm { X } , i _ { l } } ^ { ( l ) } , \gamma _ { \mathrm { Y } , i _ { l } } ^ { ( l ) } \right\} } { 2 \pi } \right) + \frac { \sigma _ { \mathrm { c u t } } } { \operatorname* { m a x } \left\{ \sigma _ { \mathrm { X } } , \sigma _ { \mathrm { Y } } \right\} 2 \pi } . } \end{array}
|
| 478 |
+
$$
|
| 479 |
+
|
| 480 |
+
Visualization of regularized kernels. Fig. 8 shows example kernels from FlexNets trained with aliasing regularization. The frequency domain plots confirm the accuracy of our frequency component regularization.
|
| 481 |
+
|
| 482 |
+
# A.2 REGULARIZING THE FREQUENCY RESPONSE OF FLEXCONV
|
| 483 |
+
|
| 484 |
+
Nyquist frequency of a FlexConv kernel. Given the sampling rate $f _ { \mathrm { s } }$ of the kernel, we can compute its Nyquist frequency $f _ { \mathrm { N y q } }$ as:
|
| 485 |
+
|
| 486 |
+
$$
|
| 487 |
+
f _ { \mathrm { N y q } } = \frac { 1 } { 2 } f _ { s }
|
| 488 |
+
$$
|
| 489 |
+
|
| 490 |
+
To compute the sampling rate, we note that the kernel coordinates input to our MAGNet stretch over a $[ - 1 , 1 ] ^ { \mathrm { D } }$ domain. For a kernel of length $k$ , we therefore sample one point in every $f _ { s } = \frac { k - 1 } { 2 }$ units.
|
| 491 |
+
|
| 492 |
+
Knowing the sampling rate in terms of the kernel size allows us to express the Nyquist frequency in terms of the (pre-masked) kernel size:
|
| 493 |
+
|
| 494 |
+
$$
|
| 495 |
+
f _ { \mathrm { N y q } } ( k ) = \frac { 1 } { 2 } \frac { k - 1 } { 2 } = \frac { k - 1 } { 4 } .
|
| 496 |
+
$$
|
| 497 |
+
|
| 498 |
+
Note that the kernel size in a FlexConv is initialized to be equal to the resolution of the data, if it is odd. For even resolutions, it corresponds to the resolution of the data plus one.
|
| 499 |
+
|
| 500 |
+
Constructing the regularization term. We train FlexConv with a regularization term on the frequency response of the generated kernel to ensure that aliasing effects do not distort the performance of the model when it is inferred at a higher resolution. This section details the implementation of the regularization function.
|
| 501 |
+
|
| 502 |
+
From the parameters of each FlexConv module, we compute $f _ { \mathrm { F l e x C o n v } } ^ { + }$ according to Eq. 22. For the amount of standard deviations to use in determining $f _ { \mathrm { e n v } } ^ { + }$ (Eq. 15) we use $h = 2$ . From the kernel size $k$ of the FlexConv module we compute $f _ { \mathrm { N y q } } ( k )$ = according to Eq. 24. We then apply an L2 regularizer over the amount that $f _ { \mathrm { F l e x C o n v } } ^ { + }$ exceeds $f _ { \mathrm { N y q } } ( k )$ :
|
| 503 |
+
|
| 504 |
+
$$
|
| 505 |
+
\begin{array} { r } { \mathcal { L } _ { \mathrm { H F } } = | | \operatorname* { m a x } \{ f _ { \mathrm { F l e x C o n v } } ^ { + } , f _ { \mathrm { N y q } } ( k ) \} - f _ { \mathrm { N y q } } ( k ) | | ^ { 2 } . } \end{array}
|
| 506 |
+
$$
|
| 507 |
+
|
| 508 |
+
We weight $\mathcal { L } _ { \mathrm { H F } }$ by $\lambda = 0 . 1$ when adding it to our loss function.
|
| 509 |
+
|
| 510 |
+
Improved implementation. Eq. 25 contains a sum over the $\mathrm { L }$ layers of the MAGNet. In practice, we prefer to regularize each layer $l \in \mathrm { L }$ separately, so that the gradients of the regularization of different layers are not dependent on each other. We therefore implement the anti-aliasing regularization by regularizing each MAGNet layer independently, and spreading the $f _ { \mathrm { e n v } } ^ { + }$ term from the gaussian mask uniformly over all MAGNet layers:
|
| 511 |
+
|
| 512 |
+
$$
|
| 513 |
+
\begin{array} { r l } & { \mathcal { L } _ { \mathrm { H F } , l } = \Vert \operatorname* { m a x } \left\{ f _ { \mathrm { M A G N e t } , l } ^ { + } + \frac { f _ { \mathrm { e n v } } ^ { + } } { \mathrm { L } } , \frac { f _ { \mathrm { N y q } } ( k ) } { \mathrm { L } } \right\} - \frac { f _ { \mathrm { N y q } } ( k ) } { \mathrm { L } } \Vert ^ { 2 } } \\ & { \qquad = \Vert \operatorname* { m a x } \left\{ \underset { i _ { l } } { \operatorname* { m a x } } \left( f _ { \mathrm { G a b o r } , i _ { l } } ^ { + ( l ) } \right) + \frac { f _ { \mathrm { e n v } } ^ { + } } { \mathrm { L } } , \frac { f _ { \mathrm { N y q } } ( k ) } { \mathrm { L } } \right\} - \frac { f _ { \mathrm { N y q } } ( k ) } { \mathrm { L } } \Vert ^ { 2 } . } \end{array}
|
| 514 |
+
$$
|
| 515 |
+
|
| 516 |
+
In the code, we refer to this method as the together method, versus the summed method of Eq. 25. In preliminary experiments, we observed improved performance of anti-aliasing training when using the together method. All of our experiments anti-aliasing experiments therefore use the together setting.
|
| 517 |
+
|
| 518 |
+
# B DATASET DESCRIPTION
|
| 519 |
+
|
| 520 |
+
# B.1 IMAGE FITTING DATASETS
|
| 521 |
+
|
| 522 |
+
Kodak dataset. The Kodak dataset (Kodak, 1991) consists of 24 natural images of size $7 6 8 \times 5 1 2$ .
|
| 523 |
+
This dataset is a popular benchmark used for compression and image fitting methods.
|
| 524 |
+
|
| 525 |
+
# B.2 SEQUENTIAL DATASETS
|
| 526 |
+
|
| 527 |
+
Sequential and Permuted MNIST. The sequential MNIST dataset (sMNIST) (Le et al., 2015)takes the $2 8 \times 2 8$ images from the original MNIST dataset (LeCun et al., 1998), and presents them as a sequence of 784 pixels. The goal of this task is to perform digit classification given the representation of the last sequence element of a sequential model. Consequently, good predictions require the model to preserve long-term dependencies up to 784 steps in the past.
|
| 528 |
+
|
| 529 |
+
The permuted MNIST dataset (pMNIST) additionally changes the order of all the sMNIST sequences by a random permutation. Consequently, models can no longer rely on local features to construct good feature representations. As a result, the classification problem becomes more difficult, and the importance of long-term dependencies more pronounced.
|
| 530 |
+
|
| 531 |
+
Sequential and Noise-Padded CIFAR10. The sequential CIFAR10 dataset (sCIFAR10) (Chang et al., 2017) takes the $3 2 \times 3 2$ images from the original CIFAR10 dataset (Krizhevsky et al., 2009) and presents them as a sequence of 1,024 pixels. The goal of this task is to perform image classification given the representation of the last sequence element of a sequential model. This task is more difficult than sMNIST, as a larger memory horizon is required to solve the task and more complex structures and intra-class variations are present in the data (Bai et al., 2018b).
|
| 532 |
+
|
| 533 |
+
The noise-padded CIFAR10 dataset (npCIFAR10) (Chang et al., 2019) flattens the images from the original CIFAR10 dataset (Krizhevsky et al., 2009) along their rows to create a sequence of length 32, and 96 channels $( 3 2 \mathrm { r o w s } \times 3 $ channels). Next, these sequences are concatenated with 968 entries of noise to form the final sequences of length 1000. As for sCIFAR10, the goal of the task is to perform image classification given the representation of the last sequence element of a sequential model.
|
| 534 |
+
|
| 535 |
+
CharacterTrajectories. The CharacterTrajectories dataset is part of the UEA time series classification archive (Bagnall et al., 2018). It consists of 2858 time series of length 182 and 3 channels representing the $x , y$ positions, and the tip force of a pen while writing Latin alphabet characters in a single stroke. The goal is to classify out of 20 classes the written character using the time series data.
|
| 536 |
+
|
| 537 |
+
Speech Commands. The Speech Commands dataset (Warden, 2018) consists of 105,809 onesecond audio recordings of 35 spoken words sampled at 16kHz. Following Kidger et al. (2020), we extract 34975 recordings from ten spoken words to construct a balanced classification problem. We refer to this dataset as SpeechCommands_raw, or SC_raw for short. Furhtermore, we utilize the preprocessing steps of Kidger et al. (2020) and extract mel-frequency cepstrum coefficients from the raw data. The resulting dataset, abreviated SC, consists of time series of length 101, and 20 channels.
|
| 538 |
+
|
| 539 |
+
# B.3 IMAGE BENCHMARK DATASETS
|
| 540 |
+
|
| 541 |
+
MNIST. The MNIST hadwritten digits datset (LeCun & Cortes, 2010) consists of 70,000 grayscale handwritten digits of size $2 8 \times 2 8$ , divided into a training and test sets of 60,000 and 10,000 images, respectively. The goal of the task is to classify these digits as one of the ten possible digits $( 0 , 1 , . . 8 , 9 )$ .
|
| 542 |
+
|
| 543 |
+
CIFAR-10 The CIFAR-10 dataset (Krizhevsky et al., 2009) consists of 60,000 natural images from 10 classes of size $3 2 \times 3 2$ , divided into training and test sets of 50,000 and 10,000 images, respectively.
|
| 544 |
+
|
| 545 |
+
STL-10. The STL-10 dataset (Coates et al., 2011) is a subset of the ImageNet dataset (Krizhevsky et al., 2012) consisting of 5,000 natural images from 10 classes of size $9 6 \times 9 6$ , divided into trainint and test sets of 4,500 and 500 images, respectively.
|
| 546 |
+
|
| 547 |
+
ImageNet-k. The Imagenet-k (Chrabaszcz et al., 2017) dataset is derived from the ImageNet dataset Russakovsky et al. (2015) by downsampling all samples to a resolution $\mathrm { ~ k ~ } \in \ [ 6 4 , 3 2 , 1 6 , 8 ]$ . The ∈dataset contains 1000 classes with 1,281,167 training samples and 50,000 validation samples.
|
| 548 |
+
|
| 549 |
+
Table 5: Average PSNR for fitting of images in the Kodak dataset. Both our improved initialization scheme, as well as the inclusion of anisotropic Gabor functions lead to better reconstructions.
|
| 550 |
+
|
| 551 |
+
<table><tr><td>MODEL</td><td>#PARAMS</td><td>IMPROVED INIT</td><td>PSNR</td></tr><tr><td>SIREN</td><td>7.14K</td><td>-</td><td>25.665</td></tr><tr><td>MFNFourier</td><td>7.40K</td><td>-</td><td>23.276</td></tr><tr><td>MFNGabor</td><td>7.11K</td><td>X √</td><td>25.361 25.606</td></tr><tr><td></td><td></td><td></td><td>25.791</td></tr><tr><td>MAGNet</td><td>7.36K</td><td>X</td><td>25.893</td></tr></table>
|
| 552 |
+
|
| 553 |
+
Table 6: Full results on CIFAR-10. We report results over three runs per setting. CIFARResNet-44 w/ CKConv is a CIFARResNet-44 where all convolutional layers are replaced with CKConvs with $k = 3$ . =CIFARResNet-44 w/ FlexConv is a CIFARResNet-44 where all convolutional layers are replaced with FlexConv with learned kernel size, except for the shortcut connections of the strided convolutional layers, which are pointwise convolutions. \*Results are taken from the respective original works instead of reproduced. †Results are from single run.
|
| 554 |
+
|
| 555 |
+
<table><tr><td>MODEL</td><td>SIZE</td><td>CIFAR-10 Acc.</td></tr><tr><td>DCN-gji (Tomen et al., 2021)</td><td>0.47M</td><td>89.7 ± 0.3*</td></tr><tr><td>N-Jet-CIFARResNet32 (Pintea et al.,2021)</td><td>0.52M</td><td>92.3 ± 0.3*</td></tr><tr><td>N-Jet-ALLCNN(Pintea et al.,2021)</td><td>1.07M</td><td>92.5± 0.1*</td></tr><tr><td>CIFARResNet-44 (He et al.,2016)</td><td>0.66M</td><td>92.9*†</td></tr><tr><td>CIFARResNet-44 (He et al.,2016)(our reproduction)</td><td>0.66M</td><td>90.9 ± 0.2</td></tr><tr><td>CIFARResNet-44 w/ CKConv (k = 3)</td><td>2.58M</td><td>86.1 ± 0.9</td></tr><tr><td>CIFARResNet-44 w/FlexConv</td><td>2.58M</td><td>81.6 ± 0.8</td></tr><tr><td>FlexNet-7 w/conv.(k = 3)</td><td>0.17M</td><td>89.5 ± 0.3</td></tr><tr><td>FlexNet-7w/ conv.(k = 33)</td><td>20.0M</td><td>78.0 ± 0.3</td></tr><tr><td>FlexNet-7 w/N-Jet (Pintea et al.,2021)</td><td>0.70M</td><td>91.7 ± 0.1</td></tr><tr><td>CKCNNSIREN-3</td><td>0.26M</td><td>72.4*</td></tr><tr><td>CKCNNFourier-3</td><td>0.27M</td><td>83.8*</td></tr><tr><td>CKCNNGabor-3</td><td>0.28M</td><td>85.6*</td></tr><tr><td>CKCNNMAGNet-3</td><td>0.28M</td><td>86.2*</td></tr><tr><td>CKCNN-7</td><td>0.63M</td><td>71.7*</td></tr><tr><td>CKCNNFourier-7</td><td>0.63M</td><td>84.6*</td></tr><tr><td>CKCNNGabor-7</td><td>0.67M</td><td>87.7*</td></tr><tr><td>CKCNNMAGNet-7</td><td>0.67M</td><td>85.9*</td></tr><tr><td>FlexNetsIREN-7</td><td>0.63M</td><td>88.9*</td></tr><tr><td>FlexNetFourier-7</td><td>0.66M</td><td>91.6*</td></tr><tr><td>FlexNetGabor-7</td><td>0.67M</td><td>92.0*</td></tr><tr><td>FlexNet-3</td><td>0.27M</td><td>90.4± 0.2</td></tr><tr><td>FlexNet-5</td><td>0.44M</td><td>91.0 ± 0.5</td></tr><tr><td>FlexNet-7</td><td>0.67M</td><td>92.2 ± 0.1</td></tr></table>
|
| 556 |
+
|
| 557 |
+
# C ADDITIONAL EXPERIMENTS
|
| 558 |
+
|
| 559 |
+
# C.1 IMAGE CLASSIFICATION
|
| 560 |
+
|
| 561 |
+
CIFAR-10. Tab. 6 shows all results for our CIFAR-10 experiments, including more ablations.
|
| 562 |
+
|
| 563 |
+
ImageNet-32. Results for the ImageNet-32 experiment are shown in Table 7. FlexNets are slightly worse than CIFARResNet-32 (He et al., 2016) with slightly less parameters. However, the results reported by Chrabaszcz et al. (2017) for Wide ResNets (Zagoruyko & Komodakis, 2016) outperform FlexNets by a significant margin.
|
| 564 |
+
|
| 565 |
+
Table 7: Results on ImageNet-32. \*Results are taken from the respective original works instead of reproduced. †Results are from a single run.
|
| 566 |
+
|
| 567 |
+
<table><tr><td>MODEL</td><td>SIZE</td><td colspan="2">IMAGENET-32 ToP-1</td></tr><tr><td>CIFARResNet-32</td><td>0.53M</td><td>26.41 ± 0.13</td><td>ToP-5 49.37 ± 0.15</td></tr><tr><td>WRN-28-1</td><td>0.44M</td><td>32.03*+</td><td>57.51*+</td></tr><tr><td>FlexNet-5</td><td>0.44M</td><td>24.9 ± 0.4</td><td>47.7 ± 0.6</td></tr></table>
|
| 568 |
+
|
| 569 |
+
Table 8: Results for alias-free FlexNets on CIFAR-10 and ImageNet-k. $\Delta$ denotes difference in accuracy.
|
| 570 |
+
|
| 571 |
+
<table><tr><td rowspan="2">MODEL</td><td rowspan="2">SIZE</td><td colspan="2">IMAGENET-K TOP-1</td></tr><tr><td>k =16</td><td>△k=16k=32</td></tr><tr><td>CIFARResNet-32</td><td>0.52m</td><td>16.1 ± 0.0</td><td>-11.6 ± 0.4</td></tr><tr><td>FlexNet-5 w/N-Jets</td><td>0.46M</td><td>15.7 ± 0.1</td><td>-1.9 ± 0.4</td></tr><tr><td>FlexNet-5</td><td>0.44M</td><td>14.9 ± 0.1</td><td>-1.9 ± 1.7</td></tr></table>
|
| 572 |
+
|
| 573 |
+
Table 9: Results on MNIST. We train each model with three different seeds and report mean and standard deviation. \*Results are taken from the respective original works instead of reproduced. $^ \dagger$ Results are from single run.
|
| 574 |
+
|
| 575 |
+
<table><tr><td>MODEL</td><td>SIZE</td><td>MNIST Acc.</td></tr><tr><td>Efficient-CapsNet (Mazzia et al.,2021)</td><td>0.16M</td><td>99.8*†</td></tr><tr><td>Network in Network (Lin et al.,2013)</td><td>N/A</td><td>99.6*+</td></tr><tr><td>VGG-5 (results from Kabir et al. (2020))</td><td>3.65M</td><td>99.7*+</td></tr><tr><td>FlexNet-16</td><td>0.67M</td><td>99.7 ± 0.0</td></tr></table>
|
| 576 |
+
|
| 577 |
+
Alias-free ImageNet-32. We report results for alias-free FlexNets on ImageNet-k (Chrabaszcz et al., 2017) in Table 8, to verify the results of alias-free training at a larger scale. We find that FlexConv and N-Jet both mostly retain classification accuracy between source and target resolution, while CIFARResNet-32 degrades drastically.
|
| 578 |
+
|
| 579 |
+
MNIST and STL-10. We additionally report results on MNIST (Tab. 9) and STL-10 (Tab. 10. We choose these dataset for the difference in image sizes of the training data. On MNIST, though performance on MNIST is quite saturated, we are competitive with state of the art methods. On STL-10 we are significantly worse than the baseline CIFARResNet from (Luo et al., 2020), though with significantly less parameters. We were not able to prepare a more relevant baseline for this experiment.
|
| 580 |
+
|
| 581 |
+
# D EXPERIMENTAL DETAILS
|
| 582 |
+
|
| 583 |
+
# D.1 FLEXNET
|
| 584 |
+
|
| 585 |
+
We propose an image classification architecture named FlexNet (Fig. 10), consisting of a stack of FlexConv blocks followed by a global average pooling layer and a linear layer. FlexNets are named "FlexNet-L" where $\mathrm { L }$ indicates the amount of layers in the architecture.
|
| 586 |
+
|
| 587 |
+
FlexBlock. Each FlexBlock consists of two FlexConvs with BatchNorm (Ioffe & Szegedy, 2015) and dropout (Srivastava et al., 2014) $\langle d = 0 . 2 \rangle$ ) as well as a residual connection. The width of a block $i$ is determined by scaling a base amount $c$ by progressively increasing factors: $c _ { i } = [ c , c \times 1 . 5 , c \times$ $1 . 5 , c \times 2 . 0 , c \times 2 . 0 ] ( i )$ . The default configuration of FlexNet uses $c = 2 2$ . In FlexNet-N-Jet models, we scale $c$ to match the amount of parameters of the FlexNet in the comparison.
|
| 588 |
+
|
| 589 |
+
Table 10: Results on STL-10. We train each model with three different seeds and report mean and standard deviation. \*Results are taken from Luo et al. (2020). $^ \dagger$ Results are from single run.
|
| 590 |
+
|
| 591 |
+
<table><tr><td>MODEL</td><td>SIZE</td><td>STL-10 ACC.</td></tr><tr><td>CIFARResNet-18</td><td>11.2M</td><td>81.0*+</td></tr><tr><td>FlexNet-16</td><td>0.67M</td><td>68.6 ± 0.7</td></tr></table>
|
| 592 |
+
|
| 593 |
+

|
| 594 |
+
Figure 10: FlexNet architecture. FlexNet-L consists of L FlexBlocks, where each FlexBlock is a residual block of FlexConvs.
|
| 595 |
+
|
| 596 |
+
FlexConv initialization. We initialize the FlexConv mask variances small, at $\sigma _ { \mathrm { X } } ^ { 2 } , \sigma _ { \mathrm { Y } } ^ { 2 } = 0 . 1 2 5$ . For initializing MAGNet, we initialize the Gaussian envelopes as discussed in Sec. 3.2. We initialize the linear layer weights by the same Gamma distribution as used for the enveloped, modulated by a scaling factor of 25.6. We found that this value of the scaling factor, rather than a higher one, helped in reducing the performance of alias-free models. We initialize the bias of the linear layers by $\mathcal { U } ( - \pi , \pi )$ .
|
| 597 |
+
|
| 598 |
+
CIFAR-10. In FlexNet-16 models for CIFAR-10 we use $c = 2 4$ to approximate the parameter count of CIFARResNets in the experiment.
|
| 599 |
+
|
| 600 |
+
# D.2 OPTIMIZATION
|
| 601 |
+
|
| 602 |
+
We use Adam (Kingma & Ba, 2014) to optimize FlexNet. Unless otherwise specified, we use a learning rate of 0.01 with a cosine annealing scheme (Loshchilov & Hutter, 2016) with five warmup epochs. We use a different learning rate of $0 . 1 \times$ the regular learning rate for the FlexConv Gaussian mask parameters. We do not use weight decay, unless otherwise specified.
|
| 603 |
+
|
| 604 |
+
Kodak. We overfit on each image of the dataset for 20,000 iterations. To this end, we use a learning rate of 0.01 without any learning rate scheme. We observe that SIRENs diverge with this learning rate and thus, reduce the learning rate to 0.001 for these models.
|
| 605 |
+
|
| 606 |
+
CIFAR-10. We train for 350 epochs with a batch size of 64. We use the data augmentation from He et al. (2016) when training CIFAR-10: a four pixel padding, followed by a random 32 pixel crop and a random horizontal flip.
|
| 607 |
+
|
| 608 |
+
ImageNet-32. We train for 350 epochs with a batch size of 2048. We use the same data augmentation as used for CIFAR-10. We do use a weight decay of 1e−5 for ImageNet-32 training.
|
| 609 |
+
|
| 610 |
+
Sequential and Permuted MNIST. We train for 200 epochs with a batch size of 64 and a learning rate of 0.01. We use a weight decay of 1e 5.
|
| 611 |
+
|
| 612 |
+
Sequential and Noise-Padded CIFAR-10. For sequential CIFAR-10, we train for 200 epochs with a batch size of 64, a learning rate of 0.001 and a weight decay of 1e 5. For noise-padded CIFAR-10, we train for 300 epochs with a batch size of 32, a learning rate of 0.01 and no weight decay.
|
| 613 |
+
|
| 614 |
+
Speech Commands and CharTrajectories. We train for 300 epochs with a batch size of 32 and a learning rate of 0.001. For CharTrajectories, we use a weight decay of 1e 5.
|
| 615 |
+
|
| 616 |
+
# D.3 ROTATED GAUSSIAN MASKS
|
| 617 |
+
|
| 618 |
+
MAGNets use anisotropic Gaussian terms in the Gabor filters, which yields improvements in descriptive power and convergence speed (Sec. 3.2). For the same reason, we explore making the anisotropic FlexConv Gaussian mask steerable, by including an additional vector of learnable angle parameters $\phi ^ { ( l ) } \in \mathbb { R } ^ { \mathrm { N _ { \mathrm { h i d } } } }$ that rotates the Gaussian masks. Although preliminary experiments show rotated masks ∈lead to slight additional improvements, the computational overhead required to rotate the masks is large. Consequently, we do not consider rotated Gaussian masks in our final experiments.
|
md/dev/3mRwyG5one/3mRwyG5one.md
ADDED
|
@@ -0,0 +1,387 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# DINO: DETR WITH IMPROVED DENOISING ANCHOR BOXES FOR END-TO-END OBJECT DETECTION
|
| 2 |
+
|
| 3 |
+
Anonymous authors Paper under double-blind review
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
We present DINO (DETR with Improved deNoising anchOr boxes), a strong endto-end object detector. DINO improves over previous DETR-like models in performance and efficiency by using a contrastive way for denoising training, a look forward twice scheme for box prediction, and a mixed query selection method for anchor initialization. DINO achieves 49.4AP in 12 epochs and 51.3AP in 24 epochs on COCO with a ResNet-50 backbone and multi-scale features, yielding a significant improvement of $\mathbf { + 6 . 0 A P }$ and $+ 2 . 7 \mathbf { A P }$ , respectively, compared to DNDETR, the previous best DETR-like model. DINO scales well in both model size and data size. Without bells and whistles, after pre-training on the Objects365 dataset with a SwinL backbone, DINO obtains the best results on both COCO val2017 (63.2AP) and test-dev (63.3AP) with model size under 1 billion parameters. Compared to other models on the leaderboard, DINO achieves better results with smaller model size and pre-training data size. The code will be available.
|
| 8 |
+
|
| 9 |
+

|
| 10 |
+
Figure 1: AP on COCO compared with other detection models. (a) Comparison to models with a ResNet-50 backbone w.r.t. training epochs. Models marked with DC5 use a dilated larger resolution feature map. Other models use multi-scale features. (b) Comparison to SOTA models w.r.t. pretraining data size and model size. SOTA models are from the COCO test-dev leaderboard. In the legend we list the backbone pre-training data size (first number) and detection pre-training data size (second number). $^ *$ means the data size is not disclosed.
|
| 11 |
+
|
| 12 |
+
# 1 INTRODUCTION
|
| 13 |
+
|
| 14 |
+
Object detection is a fundamental task in computer vision. Remarkable progress has been accomplished by classical convolution-based object detection algorithms (Ren et al., 2017; Tian et al., 2019; Lin et al., 2020; Bochkovskiy et al., 2020; Ge et al., 2021). Despite that such algorithms normally include hand-designed components like anchor generation and non-maximum suppression (NMS), they yield the best detection models such as DyHead (Dai et al., 2021a), Swin (Liu et al., 2021b) and SwinV2 (Liu et al., 2021a) with $\mathrm { H T C + + }$ (Chen et al., 2019a), as evidenced on the COCO test-dev leaderboard (pap).
|
| 15 |
+
|
| 16 |
+
In contrast to classical detection algorithms, DETR (Carion et al., 2020) is a novel Transformerbased detection algorithm. It eliminates the need of hand-designed components and achieves comparable performance with optimized classical detectors like Faster RCNN (Ren et al., 2017). Different from previous detectors, DETR models object detection as a set prediction task and assigns labels by bipartite graph matching. It leverages learnable queries to probe the existence of objects and combine features from an image feature map like soft ROI pooling (Liu et al., 2022).
|
| 17 |
+
|
| 18 |
+
Despite its promising performance, it converges slow and the meaning of queries is unclear. To address such problems, many methods have been proposed, such as introducing deformable attention (Zhu et al., 2021), decoupling positional and content information (Meng et al., 2021), providing spatial priors (Gao et al., 2021; Yao et al., 2021; Wang et al., 2021), etc. Recently, DAB-DETR (Liu et al., 2022) proposes to formulate DETR queries as dynamic anchor boxes (DAB), which bridges the gap between classical anchor-based detectors and DETR-like ones. DN-DETR (Li et al., 2022) further accelerate convergence by introducing a denoising (DN) technique. These improvements promote the development of DETR-like models, while it remains not on the list of first-choice detectors in the field.
|
| 19 |
+
|
| 20 |
+
The best detection models nowadays are based on improved classical detectors like DyHead (Dai et al., 2021b) and HTC (Chen et al., 2019a). For example, the best result presented in SwinV2 (Liu et al., 2021a) was trained with the $\mathrm { H T C + + }$ (Chen et al., 2019a; Liu et al., 2021b) framework. Two main reasons contribute to the phenomenon: 1) Previous DETR-like models are inferior to the improved classical detectors. Most classical detectors have been well studied and highly optimized, leading to a better performance compared with the newly developed DETR-like models. 2) The performance of DETR-like model has not been tested on large backbone with large-scale pre-training data. We aim to address both concerns in this paper.
|
| 21 |
+
|
| 22 |
+
Specifically, by improving the denoising training, query initialization, and box prediction, we design a new DETR-like model based on DN-DETR, DAB-DETR, and Deformable DETR. We name our model as DINO (DETR with Improved deNoising anchOr box). As shown in Fig. 1, the comparison on COCO shows the superior performance of DINO. In particular, DINO demonstrates a strong performance, setting a new record of 63.3 AP for models with less than 1 billion parameters on the COCO test-dev leaderboard (pap).
|
| 23 |
+
|
| 24 |
+
As a DETR-like model, DINO contains a backbone, a multi-layer Transformer encoder, a multi-layer Transformer decoder, and multiple prediction heads. Following DAB-DETR, we formulate queries in decoder as dynamic anchor boxes and refine them step-by-step across decoder layers. Following DN-DETR, we add ground truth labels and boxes with noises into the Transformer decoder layers to help stabilize bipartite matching during training. We also adopt deformable attention (Zhu et al., 2021) for its computational efficiency. Moreover, we propose three new methods as follows. First, to reduce duplicate predictions, we propose a contrastive denoising training by adding both positive and negative samples of the same ground truth at the same time. After adding two different noises to the same ground truth box, we mark the box with a smaller noise as positive and the other as negative. The contrastive denoising training helps the model to predict more precise boxes and avoid duplicate outputs of the same target. Second, to overcome the shortsightedness of refining boxes in each decoder layer, which is a greedy way proposed in Deformable DETR, while keeping the advantages of fast convergence, we propose a new look forward twice scheme to correct the updated parameters with gradients from later layers. Third, the dynamic anchor box formulation of queries links DETR-like models with classical two-stage models. Hence we propose a mixed query selection method, which helps better initialize the queries. We select initial anchor boxes as positional queries from the output of the encoder, similar to (Zhu et al., 2021; Yao et al., 2021). However, we leave the content queries learnable queries aligned with CDN part where queries are also learnable queries which encourages the first decoder layer to focus on the spatial prior.
|
| 25 |
+
|
| 26 |
+
We validate the effectiveness of DINO with extensive experiments on the COCO (Lin et al., 2014) detection benchmarks. As shown in Fig. 1, DINO achieves 49.4AP in 12 epochs and 51.3AP in 24 epochs with ResNet-50 multi-scale features, yielding a significant improvement of $+ 6 . 0 \mathrm { A P }$ and $+ 2 . 7 \mathrm { A P }$ , respectively, compared to the previous best DETR-like model DN-DETR. In addition, DINO scales well in both model size and data size. After pre-training on the Objects365 (Shao et al., 2019) data set with a SwinL (Liu et al., 2021b) backbone, DINO achieves impressive results on both COCO val2017 (63.2AP) and test-dev (63.3AP) benchmarks, as shown in Table 4. Our DINO reduces the model size to 1/15 compared to SwinV2-G (Liu et al., 2021a). Moreover, DINO outperforms Florence (Yuan et al., 2021) with only 1/60 backbone pre-training dataset and 1/5 detection pre-training dataset.
|
| 27 |
+
|
| 28 |
+
To summarize, our contributions are three-fold. 1) We design a new end-to-end DETR-like object detector with several novel techniques, including contrastive denoising training, look forward twice, and mixed query selection for different parts of the DINO model. 2) We conduct intensive ablation studies to validate the effectiveness of different design choices in DINO. As a result, DINO achieves 49.4AP in 12 epochs and 51.3AP in 24 epochs with ResNet-50 and multi-scale features, significantly outperforming the previous best DETR-like model DN-DETR. 3) We show that, without bells and whistles, DINO can achieve the best performance on public benchmarks with model size under 1 billion parameters. After pre-training on the Objects365 (Shao et al., 2019) dataset with a SwinL (Liu et al., 2021b) backbone, DINO achieves 63.2AP on COCO val2017 and 63.3AP on COCO test-dev benchmarks.
|
| 29 |
+
|
| 30 |
+
# 2 RELATED WORK
|
| 31 |
+
|
| 32 |
+
Classical Object Detectors: Early convolution-based object detectors are either two-stage or onestage models, based on hand-crafted anchors or reference points. Two-stage models (Ren et al., 2015; He et al., 2017) usually use an region proposal network (RPN) (Ren et al., 2015) to propose potential boxes, which are then refined in the second stage. One-stage models (Redmon & Farhadi, 2017; 2018) directly output offsets relative to predefined anchors. Recently, some convolutionbased models such as $\mathrm { H T C + + }$ (Chen et al., 2019a) and Dyhead (Dai et al., 2021a) have achieved top performance on the COCO 2017 (Lin et al., 2014). The performance of convolution-based models, however, rely on the way they generate anchors and need hand-designed components like NMS.
|
| 33 |
+
|
| 34 |
+
DETR and Its Variants: Carion et al. (Carion et al., 2020) proposed a Transformer-based endto-end object detector named DETR (DEtection TRansformer) without using hand-designed components like anchor design and NMS. Many follow-up papers have attempted to address the slow training convergence issue of DETR introduced by decoder cross-attention. For instance, Dai et al. (Dai et al., 2021a) proposed a dynamic decoder to focus on important regions from multiple feature levels. Another line of works is towards a deeper understanding of decoder queries in DETR. Many papers associate queries with spatial position from different perspectives. Deformable DETR (Zhu et al., 2021) predicts 2D anchor points and designs a deformable attention module that only attends to certain sampling points around a reference point. DAB-DETR (Liu et al., 2022) further extends 2D anchor points to 4D anchor box coordinates to represent queries and dynamically update boxes in each decoder layer. Recently, DN-DETR (Li et al., 2022) introduces a denoising training method to speed up DETR training. It feeds noise-added ground-truth labels and boxes into the decoder and trains the model to reconstruct the original ones. Our work is based on DAB-DETR and DN-DETR, and also adopts deformable attention for its computational efficiency.
|
| 35 |
+
|
| 36 |
+
Large-scale Pre-training for Object Detection: The best performing detectors nowadays are mostly achieved with large backbones pre-trained on large-scale data. For example, Swin V2 (Liu et al., 2021a) extends its backbone size to 3.0 billion parameters and pre-trains its models with 70M privately collected images. Florence (Yuan et al., 2021) first pre-trains its backbone with 900M privately curated image-text pairs and then pre-trains its detector with 9M images with annotated or pseudo boxes. In contrast, DINO achieves better results with a publicly available SwinL (Liu et al., 2021b) backbone and a public dataset Objects365 (Shao et al., 2019) (1.7M annotated images) only.
|
| 37 |
+
|
| 38 |
+
# 3 DINO: DETR WITH IMPROVED DENOISING ANCHOR BOXES
|
| 39 |
+
|
| 40 |
+
# 3.1 PRELIMINARIES
|
| 41 |
+
|
| 42 |
+
As studied in Conditional DETR (Meng et al., 2021) and DAB-DETR (Liu et al., 2022), queries in DETR (Carion et al., 2020) are formed by two parts: a positional part and a content part, which are referred to as positional queries and content queries in this paper. DAB-DETR explicitly formulates each positional query in DETR as a 4D anchor box $( x , y , w , h )$ , where $x$ and $y$ are the center coordinates of the box and $w$ and $h$ correspond to its width and height. Such an explicit anchor box formulation makes it easy to dynamically refine anchor boxes layer by layer in the decoder.
|
| 43 |
+
|
| 44 |
+
DN-DETR (Li et al., 2022) introduces a denoising (DN) training method to accelerate the training convergence of DETR-like models. It shows that the slow convergence problem in DETR is caused by the instability of bipartite matching. To mitigate this problem, DN-DETR proposes to additionally feed noised ground-truth (GT) labels and boxes into the Transformer decoder and train the model to reconstruct the ground-truth ones. The noise $( \Delta x , \Delta y , \Delta w , \Delta h )$ is constrained by $\begin{array} { r } { | \Delta x | < \frac { \lambda w } { 2 } } \end{array}$ , $\begin{array} { r } { | \Delta y | < \frac { \lambda h } { 2 } } \end{array}$ , $| \Delta w | < \lambda w$ , and $| \Delta y | < \lambda h$ , where $( x , y , w , h )$ denotes a GT box and $\lambda ^ { 1 }$ is a hyper-parameter to control the scale of noise. Since DN-DETR view decoder queries as anchors, a noised GT box can be viewed as a special anchor with a GT box nearby as $\lambda$ is usually small. In addition to the orginal DETR queries, DN-DETR adds a DN part which feeds noised GT labels and boxes into the decoder to provide an auxiliary DN loss. The DN loss effectively stabilizes and speeds up the DETR training and can be plugged into any DETR-like models.
|
| 45 |
+
|
| 46 |
+

|
| 47 |
+
Figure 2: The framework of our proposed DINO model. Our improvements are mainly in the Transformer encoder and decoder. The top-K encoder features in the last layer are selected to initialize the positional queries for the Transformer decoder. Our decoder also contains a Contrastive DeNoising (CDN) part with both positive and negative examples.
|
| 48 |
+
|
| 49 |
+
Deformable DETR (Zhu et al., 2021) is another early work to speed up the convergence of DETR. To compute deformable attention, it introduces the concept of reference point so that deformable attention can attend to a small set of key sampling points around a reference. The reference point concept makes it possible to develop several techniques to further improve the DETR performance. The first technique is query selection (or “two stage”), which selects features and reference boxes from the encoder as inputs to the decoder directly. The second technique is iterative bounding box refinement with a careful gradient detachment design between two decoder layers. We call this gradient detachment technique “look forward once” in our paper.
|
| 50 |
+
|
| 51 |
+
Following DAB-DETR and DN-DETR, DINO formulates the positional queries as dynamic anchor boxes and is trained with an extra DN loss. DINO additionally introduces three methods, which will be described in Sec. 3.3, Sec. 3.4, and Sec. 3.5, respectively.
|
| 52 |
+
|
| 53 |
+
# 3.2 MODEL OVERVIEW
|
| 54 |
+
|
| 55 |
+
As a DETR-like model, DINO is an end-to-end architecture which contains a backbone, a multilayer Transformer (Vaswani et al., 2017) encoder, a multi-layer Transformer decoder, and multiple prediction heads. The overall pipeline is shown in Fig. 2. Given an image, we extract multi-scale features with a backbone, and then feed them into the Transformer encoder with corresponding positional embeddings. After feature enhancement with the encoder layers, we propose a new mixed query selection strategy to initialize anchors as positional queries for the decoder. Note that this strategy does not initialize content queries but leaves them learnable. More details of mixed query selection are available in Sec. 3.5. With the initialized anchors and the learnable content queries, we use the deformable attention (Zhu et al., 2021) to combine the features of the encoder outputs and update the queries layer-by-layer. The final outputs are formed with refined anchor boxes and classification results predicted by refined content features. As in DN-DETR, we have an extra DN branch to perform denoising training. Beyond the standard DN method, we propose a new contrastive denoising training approach by taking into account hard negative samples, which will be presented in Sec. 3.3. To overcome the shortsightedness of the greedy way for box refinement in previous works, a novel look forward twice method is proposed to pass gradients between adjacent layers, which will be described in Sec. 3.4.
|
| 56 |
+
|
| 57 |
+
# 3.3 CONTRASTIVE DENOISING TRAINING
|
| 58 |
+
|
| 59 |
+

|
| 60 |
+
Figure 3: The structure of CDN group and a demonstration of positive and negative examples. Although both positive and negative examples are 4D anchors that can be represented as points in 4D space, we illustrate them as points in 2D space on concentric squares for simplicity. Assuming the square center is a GT box, points inside the inner square are regarded as a positive example and points between the inner square and the outer square are viewed as negative examples.
|
| 61 |
+
|
| 62 |
+
DN-DETR is effective in stabilizing training and accelerating convergence. With the help of DeNoising (DN) queries, it learns to make predictions based on noised Ground-Truth (GT) boxes, which leads to fast convergence. However, each DN query in DN-DETR is matched with a GT box and lacks the ability to predict background for “no object”. Since predicting background is also important for DETR-like model to reduce duplicate predictions, we propose a Contrastive DeNoising (CDN) approach to rejecting hard negative examples. To maximize the utilization of denoising queries, we also propose to use adaptive number of denoising groups.
|
| 63 |
+
|
| 64 |
+
Implementation: DN-DETR has a hyper-parameter $\lambda$ to control the noise scale. The generated noises are no larger than $\lambda$ as DN-DETR wants the model to reconstruct the ground truth (GT) from moderately noised queries. In our method, we have two hyper-parameters $\lambda _ { 1 }$ and $\lambda _ { 2 }$ , where $\lambda _ { 1 } < \lambda _ { 2 }$ . As shown in the concentric squares in Fig. 3, we generate two types of CDN queries: positive queries and negative queries. Positive queries within the inner square have a noise scale smaller than $\lambda _ { 1 }$ and are expected to reconstruct their corresponding ground truth boxes. Negative queries between the inner and outer squares have a noise scale larger than $\lambda _ { 1 }$ and smaller than $\lambda _ { 2 }$ . They are expected to predict “no object”. We usually adopt a small $\lambda _ { 2 }$ because hard negative samples closer to GT boxes can better help the model suppress duplicate predictions. As shown in Fig. 3, each CDN group has a set of positive queries and negative queries. If an image has $n$ GT boxes, a CDN group will have $2 \times n$ queries with each GT box generating both a positive and a negative queries. Similar to DN-DETR, we also use multiple CDN groups to improve the effectiveness of our method. The reconstruction losses are $l _ { 1 }$ and GIOU losses for box regression and focal loss (Lin et al., 2020) for classification. The loss to classify negative samples as background is also focal loss. Furthermore, to better utilize DN queries. We improve DN-DETR’s design of using a fixed number of denoising groups with an adaptive number of denoising groups. For each image, we fix the total number of denoising queries as $N$ . For an image with $n$ objects, the number of CDN groups is $\textstyle { \frac { N } { 2 n } }$ .
|
| 65 |
+
|
| 66 |
+
Analysis: The reason why CDN works is because it explicitly introduces hard negative examples that are very similar to positive example. Such negative examples encourage the model to learn subtle differences between positive and negative boxes for more precise box predictions. The ability to distinguish positive and negative example also enables the model to further reduce duplicate predictions on the basis of DETR. DETR eliminates the need of using NMS to suppress duplicate boxes. Instead, it relies on bipartite matching to pick up only one query for each GT box and suppress other queries by pushing them away or lowering their confidence. However, the suppressed queries are normally not hard negative. As a result, DETR cannot completely avoid duplicate boxes, especially for low confidence boxes. CDN addresses this issue by introducing explicitly designed negative queries, which further enhance the effect of bipartite matching on avoiding duplicate boxes. For example, on the COCO dataset, we compare CDN with its counterpart DN, both using 300 predictions. The numbers of duplicate predictions for each method are shown in Table 3.3. For all the thresholds from 0 to 0.3, CDN constantly predicts fewer duplicate boxes than DN.
|
| 67 |
+
|
| 68 |
+
<table><tr><td></td><td>Threshold</td><td>0.00</td><td>0.05</td><td>0.10</td><td>0.15</td><td>0.20</td><td>0.25</td><td>0.30</td></tr><tr><td>DN</td><td>total</td><td>292.65</td><td>158.51 31.53</td><td>59.91</td><td>24.16</td><td>10.26</td><td>3.94</td><td>0.52</td></tr><tr><td>CDN</td><td>duplicate total duplicate</td><td>67.91 292.65 53.72</td><td>164.62</td><td>9.63 60.21</td><td>3.53 23.45</td><td>1.30 9.90</td><td>0.53 3.83</td><td>0.26 0.62</td></tr></table>
|
| 69 |
+
|
| 70 |
+
Table 1: For a fair comparison, we only change CDN to DN and keep other hyper-parameters unchanged. For each model, we choose the top 300 predictions and filter them according to confidence scores with 7 thresholds from 0 to 0.3. For each threshold $t _ { i }$ , “total” and “duplicate” denote the numbers of total and duplicate predictions with scores greater than $t _ { i }$ , respectively. We view predictions with IoU $> 0 . 8$ as duplicate predictions.
|
| 71 |
+
|
| 72 |
+

|
| 73 |
+
Figure 4: (a)(b) Comparison of box update in Deformable DETR and our method. (c) APs of look forward once and look forward twice in each decoder layer. “LFO” and “LFT” denote look forward once and look forward twice, respectively.
|
| 74 |
+
|
| 75 |
+
# 3.4 LOOK FORWARD TWICE
|
| 76 |
+
|
| 77 |
+
We propose a new approach to improving box prediction in this section. The iterative box refinement in Deformable DETR blocks gradient back propagation to stabilize training. We name the method look forward once since the parameters of the $i$ -th decoder layer $L _ { i }$ are updated based on the auxiliary loss of boxes $b _ { i } ^ { ( p r e d ) }$ only, as shown in Fig 4 (a), where $b _ { i } ^ { ( p r e d ) }$ denotes the predicted boxes in $L _ { i }$ . Such a parameter update approach is a greedy method, in which each decoder layer approximates ground truth boxes individually while trying not to influence its previous layers by blocking gradient. Such a method stabilizes training and helps convergence in early training stages. However, it may lead to a sub optimal result. On the other hand, allowing gradient to propagate from all latter layers will make the model hard to converge. To address this issue, we propose to only allow $L _ { i - 1 }$ to be influenced by gradients from itself and $L _ { i }$ as shown in 4 (b). Since parameters in $L _ { i - 1 }$ are optimized to approximate ground truth boxes in both $L _ { i - 1 }$ and $L _ { i }$ , we name our method as look forward twice, which is more comprehensive compared with the look forward once method.
|
| 78 |
+
|
| 79 |
+
Implementation: We compare the implementations of look forward once (LFO) and look forward twice (LFT) as follows. Since LFO and LFT share the same process from $b _ { i - 1 } ^ { \prime }$ to $b _ { i } ^ { \prime }$ , we first show this process. Denote $b _ { i - 1 } ^ { \prime }$ and $b _ { i - 1 }$ as the boxes before and after stopping gradient. We have
|
| 80 |
+
|
| 81 |
+
$$
|
| 82 |
+
b _ { i - 1 } = \mathrm { s g } \left[ b _ { i - 1 } ^ { \prime } \right] ,
|
| 83 |
+
$$
|
| 84 |
+
|
| 85 |
+
where $\mathrm { s g } [ \cdot ]$ denotes stopping gradient. $b _ { i - 1 }$ is used as the input anchor box in $L _ { i }$ to obtain $\Delta { b } _ { i }$ as follows.
|
| 86 |
+
|
| 87 |
+
$$
|
| 88 |
+
\Delta b _ { i } = L _ { i } ( b _ { i - 1 } ; \theta _ { i } ) ,
|
| 89 |
+
$$
|
| 90 |
+
|
| 91 |
+
where $L _ { i }$ denotes the $i$ -th Decoder layer with $\theta _ { i }$ as its parameters. We ignore other inputs to $L _ { i }$ for simplicity. $b _ { i } ^ { \prime }$ is obtained as follows.
|
| 92 |
+
|
| 93 |
+
$$
|
| 94 |
+
b _ { i } ^ { \prime } = \sigma \left( \sigma ^ { - 1 } ( b _ { i - 1 } ) + \Delta b _ { i } \right) .
|
| 95 |
+
$$
|
| 96 |
+
|
| 97 |
+
where $\sigma ( \cdot )$ and $\sigma ^ { - 1 }$ denote the sigmoid and inverse sigmoid functions. Note that such a box update approach is to guarantee that the updated boxes have normalized $x , y , w , h$ values between 0 and 1. Equation 3 is marked with green line in Fig. 4(a) where gradients are propagated from $b _ { i } ^ { ( p r e d ) }$ to $\theta _ { i }$ through $\Delta { b } _ { i }$ . In LFO, the prediction $b _ { i } ^ { ( p r e d ) }$ is equal to $b _ { i } ^ { \prime }$ . While in LFT, we update box predictions $b _ { i } ^ { ( p r e d ) }$ based on $b _ { i - 1 } ^ { \prime }$ instead of $b _ { i - 1 }$ as follows.
|
| 98 |
+
|
| 99 |
+
$$
|
| 100 |
+
b _ { i } ^ { ( p r e d ) } = \sigma \left( \sigma ^ { - 1 } ( b _ { i - 1 } ^ { \prime } ) + \Delta b _ { i } \right) ,
|
| 101 |
+
$$
|
| 102 |
+
|
| 103 |
+
Equation 4 is marked with green line in Fig. 4(b). Similarly, $b _ { i + 1 } ^ { ( p r e d ) }$ is obtained as follows.
|
| 104 |
+
|
| 105 |
+
$$
|
| 106 |
+
b _ { i + 1 } ^ { ( p r e d ) } = \sigma \left( \sigma ^ { - 1 } ( b _ { i } ^ { \prime } ) + \Delta b _ { i + 1 } \right) = \sigma \left( \sigma ^ { - 1 } ( b _ { i - 1 } ^ { \prime } ) + \Delta b _ { i } + \Delta b _ { i + 1 } \right)
|
| 107 |
+
$$
|
| 108 |
+
|
| 109 |
+
Equation 5 is marked with red line in Fig. 4(b), where the gradients from $b _ { i + 1 } ^ { ( p r e d ) }$ are propagated to
|
| 110 |
+
|
| 111 |
+
Fig. 4 (c) shows a comparison of the performances of look forward once (LFO) and look forward twice (LFT) in different layers. For layer 0 to 2, LFO performs better than LFT. While LFT exceeds LFO in layer 3 to 6. This observation verifies our intuition that LFT sacrifices performance in early layers to achieve better final performance.
|
| 112 |
+
|
| 113 |
+
# 3.5 MIXED QUERY SELECTION
|
| 114 |
+
|
| 115 |
+

|
| 116 |
+
Figure 5: Comparison of three different query initialization methods. “static” means that queries will keep the same for different images in inference. A common implementation for these static queries is to make them learnable. Note that in (b) the selected reference points go through a positional encoding and linear transform to obtain the query embeddings as implemented in deformable DETR.
|
| 117 |
+
|
| 118 |
+
In DETR (Carion et al., 2020) and DN-DETR (Li et al., 2022), decoder queries are static embeddings without taking any encoder features from an individual image, as shown in Fig. 5 (a). They learn anchors or positional queries from training data and set the content queries as 0 vectors. Deformable DETR (Zhu et al., 2021) learns both the positional and content queries, which is another implementation of static query initialization. To further improve the performance, Deformable DETR (Zhu et al., 2021) has a query selection variant (or ”two-stage”). It selects positions with top $K$ classification scores as reference points and the content queries are linear transform of the positional embeddings of the reference points. In addition, features in the selected positions go through a classification head and a box head to calculate auxiliary loss. We call the implementation in Deformable DETR as vanilla query selection as shown in Fig. 5. Vanilla query selection helps the model converge especially in early training epochs. However, its content queries are not aligned with those in CDN part—the content queries in CDN part are learnable class embeddings. Therefore, we propose to use selected positions as anchors and learnable query embeddings as the content queries. We call our method as mixed query selection. We show in Table 5 that our simple and intuitive method achieves better result.
|
| 119 |
+
|
| 120 |
+
# 4 EXPERIMENTS
|
| 121 |
+
|
| 122 |
+
# 4.1 SETUP
|
| 123 |
+
|
| 124 |
+
Dataset and Backbone: We conduct evaluation on the COCO 2017 object detection dataset (Lin et al., 2014), which is split into train2017 and val2017 (also called minival). We report results with two different backbones: ResNet-50 (He et al., 2016) pre-trained on ImageNet-1k (Deng et al., 2009) and SwinL (Liu et al., 2021b) pre-trained on ImageNet-22k (Deng et al., 2009). DINO with ResNet-50 is trained on train2017 without extra data, while DINO with SwinL is first pretrained on Object365 (Shao et al., 2019) and then fine-tuned on train2017. We also report the test-dev results for DINO with SwinL.
|
| 125 |
+
|
| 126 |
+
Implementation Details: In appendix F, we provide implementation details, including all the hyperparameters and engineering techniques used in our models.
|
| 127 |
+
|
| 128 |
+
# 4.2 MAIN RESULTS
|
| 129 |
+
|
| 130 |
+
12-epoch setting: With our improved anchor box denoising and training losses, the training process can be significantly accelerated. As shown in Table 2, we compare our method with strong baselines including both convolution-based methods (Ren et al., 2015; Chen et al., 2019a; Dai et al., 2021a) and DETR-like methods (Carion et al., 2020; Zhu et al., 2021; Dai et al., 2021b; Liu et al., 2022; Li et al., 2022). For a fair comparison, we report both GFLOPS and FPS tested on the same A100 NVIDIA GPU for all the models listed in Table 2. All methods except for DETR and DAB-DETR use multi-scale features. For those without multi-scale features, we report their results with ResNetDC5 which has a better performance for its use of a dilated larger resolution feature map. Since some methods adopt 5 scales of feature maps and some adopt 4, we report our results with both 4 and 5 scales of feature maps.
|
| 131 |
+
|
| 132 |
+
Table 2: Results for DINO and other detection models with the ResNet50 backbone on COCO val2017 trained with 12 epochs (the so called $1 \times$ setting). For models without multi-scale features, we test their GFLOPS and FPS for their best model ResNet-50-DC5. DINO uses 900 queries. † indicates models that use 900 queries or 300 queries with 3 patterns which has similar effect with 900 queries. Other DETR-like models except DETR (100 queries) uses 300 queries. ∗ indicates that they are tested using the mmdetection Chen et al. (2019b) framework.
|
| 133 |
+
|
| 134 |
+
<table><tr><td>Model</td><td>Epochs</td><td>AP</td><td>AP50</td><td>AP75</td><td>APs</td><td>APM</td><td>APL</td><td>GFLOPS</td><td>Params</td><td>FPS</td></tr><tr><td>Faster-RCNN(5scale) Ren et al. (2015)</td><td>12</td><td>37.9</td><td>58.8</td><td>41.1</td><td>22.4</td><td>41.1</td><td>49.1</td><td>207</td><td>40M</td><td>21*</td></tr><tr><td>DETR(DC5) Carion et al. (2020)</td><td>12</td><td>15.5</td><td>29.4</td><td>14.5</td><td>4.3</td><td>15.1</td><td>26.7</td><td>225</td><td>41M</td><td>20</td></tr><tr><td>Deformable DETR(4scale)Zhu et al.(2021)</td><td>12</td><td>41.1</td><td></td><td></td><td></td><td></td><td></td><td>196</td><td>40M</td><td>24</td></tr><tr><td>DAB-DETR(DC5)† Liu et al. (2022)</td><td>12</td><td>38.0</td><td>60.3</td><td>39.8</td><td>19.2</td><td>40.9</td><td>55.4</td><td>256</td><td>44M</td><td>17</td></tr><tr><td>Dynamic DETR(5scale) Dai et al.(2021b)</td><td>12</td><td>42.9</td><td>61.0</td><td>46.3</td><td>24.6</td><td>44.9</td><td>54.4</td><td></td><td>58M</td><td></td></tr><tr><td>Dynamic Head(5scale) Dai et al. (2021a)</td><td>12</td><td>43.0</td><td>60.7</td><td>46.8</td><td>24.7</td><td>46.4</td><td>53.9</td><td>1</td><td>一</td><td></td></tr><tr><td>HTC(5scale) Chen et al. (2019a)</td><td>12</td><td>42.3</td><td></td><td></td><td></td><td></td><td>一</td><td>441</td><td>80M</td><td>5*</td></tr><tr><td>DN-Deformable-DETR(4scale)† Li et al. (2022)</td><td>12</td><td>43.4</td><td>61.9</td><td>47.2</td><td>24.8</td><td>46.8</td><td>59.4</td><td>265</td><td>48M</td><td>23</td></tr><tr><td>DINO-4scale†</td><td>12</td><td>49.0(±5.6)</td><td>66.6</td><td>53.5</td><td>32.0(+7.2)</td><td>52.3</td><td>63.0</td><td>279</td><td>47M</td><td>24</td></tr><tr><td>DINO-5scale†</td><td>12</td><td>49.4(±6.0)</td><td>66.9</td><td>53.8</td><td>32.3(+7.5)</td><td>52.5</td><td>63.9</td><td>860</td><td>47M</td><td>10</td></tr></table>
|
| 135 |
+
|
| 136 |
+
<table><tr><td>Model</td><td>Epochs</td><td>AP</td><td>AP50</td><td>AP75</td><td>APs</td><td>APM</td><td>APL</td></tr><tr><td>Faster-RCNN Ren et al. (2015)</td><td>108</td><td>42.0</td><td>62.4</td><td>44.2</td><td>20.5</td><td>45.8</td><td>61.1</td></tr><tr><td>DETR(DC5) Zhu et al. (2021)</td><td>500</td><td>43.3</td><td>63.1</td><td>45.9</td><td>22.5</td><td>47.3</td><td>61.1</td></tr><tr><td>Deformable DETR Zhu et al. (2021)</td><td>50</td><td>46.2</td><td>65.2</td><td>50.0</td><td>28.8</td><td>49.2</td><td>61.7</td></tr><tr><td>SMCA-R Gao et al. (2021)</td><td>50</td><td>43.7</td><td>63.6</td><td>47.2</td><td>24.2</td><td>47.0</td><td>60.4</td></tr><tr><td>TSP-RCNN-R Sun et al.(2020)</td><td>96</td><td>45.0</td><td>64.5</td><td>49.6</td><td>29.7</td><td>47.7</td><td>58.0</td></tr><tr><td>Dynamic DETR(5scale) Dai et al. (2021a)</td><td>50</td><td>47.2</td><td>65.9</td><td>51.1</td><td>28.6</td><td>49.3</td><td>59.1</td></tr><tr><td>DAB-Deformable-DETR Liu et al. (2022)</td><td>50</td><td>46.9</td><td>66.0</td><td>50.8</td><td>30.1</td><td>50.4</td><td>62.5</td></tr><tr><td>DN-Deformable-DETR Li et al. (2022)</td><td>50</td><td>48.6</td><td>67.4</td><td>52.7</td><td>31.0</td><td>52.0</td><td>63.7</td></tr><tr><td>DINO-4scale</td><td>24</td><td>50.4(+1.8)</td><td>68.3</td><td>54.8</td><td>33.3</td><td>53.7</td><td>64.8</td></tr><tr><td>DINO-5scale</td><td>24</td><td>51.3(+2.7)</td><td>69.1</td><td>56.0</td><td>34.5</td><td>54.2</td><td>65.8</td></tr><tr><td>DINO-4scale</td><td>36</td><td>50.9(+2.3)</td><td>69.0</td><td>55.3</td><td>34.6</td><td>54.1</td><td>64.6</td></tr><tr><td>DINO-5scale</td><td>36</td><td>51.2(+2.6)</td><td>69.0</td><td>55.8</td><td>35.0</td><td>54.3</td><td>65.3</td></tr></table>
|
| 137 |
+
|
| 138 |
+
Table 3: Results for DINO and other detection models with the ResNet-50 backbone on COCO val2017 trained with more epochs (24, 36, or more).
|
| 139 |
+
|
| 140 |
+
As shown in Table 2, our method yields an improvement of $+ 5 . 6$ AP under the same setting using ResNet-50 with 4-scale feature maps and $+ 6 . 0$ AP with 5-scale feature maps. Our 4-scale model does not introduce much overhead in computation and the number of parameters. Moreover, our method performs especially well for small objects, gaining $+ 7 . 2$ AP with 4 scales and $+ 7 . 5$ AP with 5 scales.
|
| 141 |
+
|
| 142 |
+
Comparison with the best models with a ResNet-50 backbone: To validate the effectiveness of our method in improving both convergence speed and performance, we compare our method with several strong baselines using the same ResNet-50 backbone. Despite the most common 50-epoch setting, we adopt the 24 $( 2 \times )$ and 36 $( 3 \times )$ epoch settings since our method converges faster and yields only a smaller additional gain with 50-epoch training. The results in Table 3 show that, using only 24 epochs, our method achieves an improvement of $+ 1 . 8$ AP and $+ 2 . 7$ AP with 4 and 5 scales, respectively. Moreover, using 36 epochs in the $3 \times$ setting, the improvement increases to $+ 2 . 3$ and $+ 2 . 6$ AP with 4 and 5 scales, respectively. The convergence curve comparison is shown in Fig. 6. We also show our results using SwinL backbone without bells and whistles in Appendix B.
|
| 143 |
+
|
| 144 |
+
# 4.3 COMPARISON WITH SOTA MODELS
|
| 145 |
+
|
| 146 |
+
To compare with SOTA results, we use the publicly available SwinL (Liu et al., 2021b) backbone pre-trained on ImageNet-22K. We first pre-train DINO on the Objects365 (Shao et al., 2019) dataset and then fine-tune it on COCO. As shown in Table 4, DINO achieves the best results of 63.2AP and 63.3AP on COCO val2017 and test-dev with model size under 1 billion parameters, which demonstrate its strong scalability to larger model size and data size. Note that all the previous SOTA models in Table 4 do not use Transformer decoder-based detection heads $\mathrm { \Phi { H T C + + } }$ (Chen et al., 2019a) and DyHead (Dai et al., 2021a)). It is the first time that an end-to-end Transformer detector is established as a SOTA model on the leaderboard (pap). Compared with the previous SOTA
|
| 147 |
+
|
| 148 |
+

|
| 149 |
+
Figure 6: Training convergence curves evaluated on COCO val2017 for DINO and two previous state-ofthe-art models with ResNet-50 using multi-scale features.
|
| 150 |
+
|
| 151 |
+
<table><tr><td>Method</td><td>Params</td><td>Backbone Pre-training Dataset</td><td>Detection Pre-training Dataset</td><td>Use Mask</td><td>End-to-end </td><td>val2017 (AP) w/o TTA</td><td>w/ TTA</td><td>test-dev (AP) w/o TTA w/ TTA</td></tr><tr><td>SwinL Liu et al. (2021b)</td><td>284M</td><td>IN-22K-14M</td><td>0365</td><td>√</td><td></td><td>58.0</td><td>57.7</td><td>58.7</td></tr><tr><td>DyHead Dai et al. (2021a)</td><td>≥ 284M</td><td>IN-22K-14M</td><td>Unknown*</td><td></td><td></td><td>58.4</td><td></td><td>60.6</td></tr><tr><td>Soft Teacher+SwinL Xu et al. (2021)</td><td>284M</td><td>IN-22K-14M</td><td>0365</td><td>√</td><td></td><td>60.7</td><td></td><td>61.3</td></tr><tr><td>GLIP Li et al. (2021)</td><td>≥ 284M</td><td>IN-22K-14M</td><td>FourODs Li et al. (2021),GoldG+ Kamath et al. (2021)</td><td></td><td></td><td>60.8</td><td></td><td>61.5</td></tr><tr><td>Florence-CoSwin-HYuan et al. (2021)</td><td>≥ 637M</td><td>FLD-900M Yuan et al. (2021)</td><td>FLD-9M Yuan et al. (2021)</td><td></td><td></td><td>62.0</td><td></td><td>62.4</td></tr><tr><td>SwinV2-G Liu et al. (2021a)</td><td>3.0B</td><td>IN-22K-ext-70M Liu et al. (2021a)</td><td>0365</td><td>√</td><td></td><td>62.5</td><td></td><td>63.1</td></tr><tr><td>DINO-SwinL(Ours)</td><td>218M</td><td>IN-22K-14M</td><td>0365</td><td></td><td>√</td><td>63.2</td><td>63.2</td><td>63.3</td></tr></table>
|
| 152 |
+
|
| 153 |
+
Table 4: Comparison of the best detection models on MS-COCO. Similar to DETR Carion et al. (2020), we use the term “end-to-end” to indicate if a model is free from hand-crafted components like RPN and NMS. The term “use mask” means whether a model is trained with instance segmentation annotations. We use the terms “IN” and $" \mathrm { O } 3 6 5 "$ to denote the ImageNet Deng et al. (2009) and Objects365 Shao et al. (2019) datasets, respectively. Note that $" \mathrm { O } 3 6 5 "$ is a subset of “FourODs” and “FLD-9M”. \* DyHead does not disclose the details of the datasets used for model pre-training.
|
| 154 |
+
|
| 155 |
+
models, we use a much smaller model size $( 1 / 1 5$ parameters compared with SwinV2-G (Liu et al., 2021a)), backbone pre-training data size $1 / 6 0$ images compared with Florence), and detection pretraining data size $\mathrm { { . 1 / 5 } }$ images compared with Florence), while achieving better results. In addition, our reported performance without test time augmentation (TTA) is a neat result without bells and whistles. These results effectively show the superior detection performance of DINO compared with traditional detectors.
|
| 156 |
+
|
| 157 |
+
# 4.4 ABLATION
|
| 158 |
+
|
| 159 |
+
<table><tr><td>#Row</td><td>QS</td><td>CDN</td><td>LFT</td><td>AP</td><td>AP50</td><td>AP75</td><td>APs</td><td>APM</td><td>APL</td></tr><tr><td>1.Optimized DN-Deformable DETR† Li et al. (2022)</td><td>No</td><td></td><td></td><td>46.3</td><td>63.8</td><td>50.3</td><td>28.2</td><td>49.6</td><td>61.7</td></tr><tr><td>2.Row1+CDN*</td><td>No</td><td>√</td><td></td><td>47.2</td><td>65.0</td><td>51.2</td><td>29.4</td><td>50.7</td><td>62.5</td></tr><tr><td>3.Row2+vanilla query selection Zhu et al. (2021)</td><td>Vanilla</td><td>√</td><td></td><td>47.8</td><td>65.6</td><td>52.5</td><td>31.1</td><td>51.1</td><td>62.5</td></tr><tr><td>4.Row2+mixed query selection</td><td>Mixed</td><td>√</td><td></td><td>48.6</td><td>66.0</td><td>52.9</td><td>31.3</td><td>51.9</td><td>62.7</td></tr><tr><td>5.DINO (ours,Row4+look forward twice)</td><td>Mixed</td><td>√</td><td>√</td><td>49.0</td><td>66.6</td><td>53.5</td><td>32.0</td><td>52.3</td><td>63.0</td></tr></table>
|
| 160 |
+
|
| 161 |
+
Table 5: Ablation comparison of the proposed algorithm components. We use the terms “QS”, “CDN”, and “LFT” to denote “Query Selection”, “Contrastive De-Noising Training”, and “Look Forward Twice”, respectively. † We propose an optimized DN-Deformable DETR with our technical improvements. The technical details are shown in Appendix A. ∗ We also use adaptive number of denoising groups here.
|
| 162 |
+
|
| 163 |
+
Effectiveness of New Algorithm Components: We validate the effectiveness of our proposed methods in Table 5. We build an optimized DN-Deformable DETR as our strong baseline, which performs better than the one in Table 2. We include all the pipeline optimization and engineering techniques (see section 4.1 and Appendix F) in the strong baseline. The result of the strong baseline is available in Table 5 Row 1. According to Table 5, our three new methods in DINO further improve the performance significantly even without considering any engineering techniques.
|
| 164 |
+
|
| 165 |
+
# 5 CONCLUSION
|
| 166 |
+
|
| 167 |
+
In this paper, we have presented a strong end-to-end Transformer detector DINO with contrastive denoising training, look forward twice, and mixed query selection, which significantly improves both the training efficiency and the final detection performance. As a result, DINO outperforms all previous ResNet-50-based models on COCO val2017 in both the 12-epoch and the 36-epoch settings using multi-scale features. Motivated by the improvement, we further explored to train DINO with a stronger backbone on a larger dataset and achieved a strong result, 63.3 AP on COCO 2017 test-dev. This result establishes DETR-like models as a mainstream detection framework, not only for its novel end-to-end detection optimization, but also for its superior performance.
|
| 168 |
+
|
| 169 |
+
# REFERENCES
|
| 170 |
+
|
| 171 |
+
Papers with code - coco test-dev benchmark (object detection). URL https:// paperswithcode.com/sota/object-detection-on-coco.
|
| 172 |
+
|
| 173 |
+
Alexey Bochkovskiy, Chien-Yao Wang, and Hong-Yuan Mark Liao. Yolov4: Optimal speed and accuracy of object detection. arXiv preprint arXiv:2004.10934, 2020.
|
| 174 |
+
|
| 175 |
+
Zhaowei Cai and Nuno Vasconcelos. Cascade r-cnn: Delving into high quality object detection. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 6154–6162, 2018.
|
| 176 |
+
|
| 177 |
+
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, pp. 213–229. Springer, 2020.
|
| 178 |
+
|
| 179 |
+
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 Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 4974–4983, 2019a.
|
| 180 |
+
|
| 181 |
+
Kai Chen, Jiaqi Wang, Jiangmiao Pang, Yuhang Cao, Yu Xiong, Xiaoxiao Li, Shuyang Sun, Wansen Feng, Ziwei Liu, Jiarui Xu, et al. Mmdetection: Open mmlab detection toolbox and benchmark. arXiv preprint arXiv:1906.07155, 2019b.
|
| 182 |
+
|
| 183 |
+
Tianqi Chen, Bing Xu, Chiyuan Zhang, and Carlos Guestrin. Training deep nets with sublinear memory cost. arXiv preprint arXiv:1604.06174, 2016.
|
| 184 |
+
|
| 185 |
+
Xiyang Dai, Yinpeng Chen, Bin Xiao, Dongdong Chen, Mengchen Liu, Lu Yuan, and Lei Zhang. Dynamic head: Unifying object detection heads with attentions. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 7373–7382, 2021a.
|
| 186 |
+
|
| 187 |
+
Xiyang Dai, Yinpeng Chen, Jianwei Yang, Pengchuan Zhang, Lu Yuan, and Lei Zhang. Dynamic detr: End-to-end object detection with dynamic attention. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pp. 2988–2997, October 2021b.
|
| 188 |
+
|
| 189 |
+
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.
|
| 190 |
+
|
| 191 |
+
Peng Gao, Minghang Zheng, Xiaogang Wang, Jifeng Dai, and Hongsheng Li. Fast convergence of detr with spatially modulated co-attention. arXiv preprint arXiv:2101.07448, 2021.
|
| 192 |
+
|
| 193 |
+
Zheng Ge, Songtao Liu, Feng Wang, Zeming Li, and Jian Sun. Yolox: Exceeding yolo series in 2021. arXiv preprint arXiv:2107.08430, 2021.
|
| 194 |
+
|
| 195 |
+
Agrim Gupta, Piotr Dollar, and Ross Girshick. Lvis: A dataset for large vocabulary instance seg- ´ mentation, 2019.
|
| 196 |
+
|
| 197 |
+
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 770–778, 2016.
|
| 198 |
+
|
| 199 |
+
Kaiming He, Georgia Gkioxari, Piotr Dollar, and Ross Girshick. Mask r-cnn. In ´ Proceedings of the IEEE international conference on computer vision, pp. 2961–2969, 2017.
|
| 200 |
+
|
| 201 |
+
Aishwarya Kamath, Mannat Singh, Yann LeCun, Ishan Misra, Gabriel Synnaeve, and Nicolas Carion. Mdetr – modulated detection for end-to-end multi-modal understanding. arXiv: Computer Vision and Pattern Recognition, 2021.
|
| 202 |
+
|
| 203 |
+
Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
|
| 204 |
+
|
| 205 |
+
Feng Li, Hao Zhang, Shilong Liu, Jian Guo, Lionel M Ni, and Lei Zhang. Dn-detr: Accelerate detr training by introducing query denoising. arXiv preprint arXiv:2203.01305, 2022.
|
| 206 |
+
|
| 207 |
+
Liunian Harold Li, Pengchuan Zhang, Haotian Zhang, Jianwei Yang, Chunyuan Li, Yiwu Zhong, Lijuan Wang, Lu Yuan, Lei Zhang, Jenq-Neng Hwang, et al. Grounded language-image pretraining. arXiv preprint arXiv:2112.03857, 2021.
|
| 208 |
+
|
| 209 |
+
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 ´ European conference on computer vision, pp. 740–755. Springer, 2014.
|
| 210 |
+
|
| 211 |
+
Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollar. Focal loss for dense object detection. IEEE Transactions on Pattern Analysis and Machine Intelligence, 42(2):318– 327, 2020.
|
| 212 |
+
|
| 213 |
+
Shilong Liu, Feng Li, Hao Zhang, Xiao Yang, Xianbiao Qi, Hang Su, Jun Zhu, and Lei Zhang. DABDETR: Dynamic anchor boxes are better queries for DETR. arXiv preprint arXiv:2201.12329, 2022.
|
| 214 |
+
|
| 215 |
+
Ze Liu, Han Hu, Yutong Lin, Zhuliang Yao, Zhenda Xie, Yixuan Wei, Jia Ning, Yue Cao, Zheng Zhang, Li Dong, et al. Swin transformer v2: Scaling up capacity and resolution. arXiv preprint arXiv:2111.09883, 2021a.
|
| 216 |
+
|
| 217 |
+
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 Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 10012–10022, 2021b.
|
| 218 |
+
|
| 219 |
+
Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017.
|
| 220 |
+
|
| 221 |
+
Depu Meng, Xiaokang Chen, Zejia Fan, Gang Zeng, Houqiang Li, Yuhui Yuan, Lei Sun, and Jingdong Wang. Conditional detr for fast training convergence. arXiv preprint arXiv:2108.06152, 2021.
|
| 222 |
+
|
| 223 |
+
Paulius Micikevicius, Sharan Narang, Jonah Alben, Gregory Diamos, Erich Elsen, David Garcia, Boris Ginsburg, Michael Houston, Oleksii Kuchaiev, Ganesh Venkatesh, and Hao Wu. Mixed precision training, 2018.
|
| 224 |
+
|
| 225 |
+
Joseph Redmon and Ali Farhadi. Yolo9000: better, faster, stronger. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 7263–7271, 2017.
|
| 226 |
+
|
| 227 |
+
Joseph Redmon and Ali Farhadi. Yolov3: An incremental improvement. arXiv preprint arXiv:1804.02767, 2018.
|
| 228 |
+
|
| 229 |
+
Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. Advances in neural information processing systems, 28, 2015.
|
| 230 |
+
|
| 231 |
+
Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. IEEE Transactions on Pattern Analysis and Machine Intelligence, 39(6):1137–1149, 2017.
|
| 232 |
+
|
| 233 |
+
Hamid Rezatofighi, Nathan Tsoi, JunYoung Gwak, Amir Sadeghian, Ian Reid, and Silvio Savarese. Generalized intersection over union: A metric and a loss for bounding box regression. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 658–666, 2019.
|
| 234 |
+
|
| 235 |
+
Shuai Shao, Zeming Li, Tianyuan Zhang, Chao Peng, Gang Yu, Xiangyu Zhang, Jing Li, and Jian Sun. Objects365: A large-scale, high-quality dataset for object detection. In Proceedings of the IEEE/CVF international conference on computer vision, pp. 8430–8439, 2019.
|
| 236 |
+
|
| 237 |
+
Zhiqing Sun, Shengcao Cao, Yiming Yang, and Kris Kitani. Rethinking transformer-based set prediction for object detection. arXiv preprint arXiv:2011.10881, 2020.
|
| 238 |
+
|
| 239 |
+
Zhi Tian, Chunhua Shen, Hao Chen, and Tong He. Fcos: Fully convolutional one-stage object detection. In 2019 IEEE/CVF International Conference on Computer Vision (ICCV), pp. 9627– 9636, 2019.
|
| 240 |
+
|
| 241 |
+
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.
|
| 242 |
+
Yingming Wang, Xiangyu Zhang, Tong Yang, and Jian Sun. Anchor detr: Query design for transformer-based detector. arXiv preprint arXiv:2109.07107, 2021.
|
| 243 |
+
Mengde Xu, Zheng Zhang, Han Hu, Jianfeng Wang, Lijuan Wang, Fangyun Wei, Xiang Bai, and Zicheng Liu. End-to-end semi-supervised object detection with soft teacher. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 3060–3069, 2021.
|
| 244 |
+
Zhuyu Yao, Jiangbo Ai, Boxun Li, and Chi Zhang. Efficient detr: Improving end-to-end object detector with dense prior. arXiv preprint arXiv:2104.01318, 2021.
|
| 245 |
+
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 preprint arXiv:2111.11432, 2021.
|
| 246 |
+
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: The Ninth International Conference on Learning Representations, 2021.
|
| 247 |
+
|
| 248 |
+
# A OPTIMIZED DN-DEFORMABLE DETR
|
| 249 |
+
|
| 250 |
+
The optimized DN-Deformable DETR differs from the original DN-Deformable DETR in the following three parts. Firstly, the optimized DN-Deformable DETR adopts deformable attention in both encoder and decoder while the original one only adopts deformable attention in encoder. With deformable attention in decoder, the optimized one is able to use more decoder queries. For example, we use 900 here. Secondly, the optimized one use different weight for matcher and loss, while the original one follows DETR to use same weight for loss and matcher. For example, we use class weight 1.0 for loss and 2.0 for matcher. Finally, we set dropout rate to be 0. We find these three technical improvements can improve the performance.
|
| 251 |
+
|
| 252 |
+
# B RESULTS USING SWINL BACKBONE WITHOUT PRE-TRAINING ON OBJECT 365
|
| 253 |
+
|
| 254 |
+
We also evaluate our method on COCO val2017 with SwinL as backbone without pre-training on Object 365. The results are without any bells and whistles. We compare with other methods using Swin-L backbone.
|
| 255 |
+
|
| 256 |
+
Table 6: Results for DINO and other detection models with the SwinL backbone on COCO val2017.
|
| 257 |
+
|
| 258 |
+
<table><tr><td>Model</td><td>Epochs</td><td>AP</td><td>AP50</td><td>AP75</td><td>APs</td><td>APM</td><td>APL</td></tr><tr><td>Cascade Mask RCNN-SwinL Cai & Vasconcelos (2018) HTC++-SwinL Chen et al. (2019a)</td><td>1 1</td><td>55.0</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>DINO-4scale-SwinL</td><td>36</td><td>57.1 58.0</td><td>1 76.7</td><td>1 63.4</td><td>一 41.3</td><td>1 61.9</td><td>1 73.7</td></tr><tr><td>DINO-5scale-SwinL</td><td>36</td><td>58.5</td><td>77.0</td><td>64.1</td><td>41.5</td><td>62.3</td><td>74.0</td></tr></table>
|
| 259 |
+
|
| 260 |
+
# C TEST TIME AUGMENTATIONS (TTA)
|
| 261 |
+
|
| 262 |
+
We aim to build an end-to-end detector that is free from hand-crafted components. However, to compare with traditional detection models, we also explore the use of TTA in DETR-like models. We only use it in our large model with the SwinL backbone. Our TTA does not obtain an inspiring gain compared with traditional detectors, but we hope our exploration may provide some insights for future studies.
|
| 263 |
+
|
| 264 |
+
We adopt multi-scale test and horizontal flip as TTA. However, the way of ensembling different augmentations in our method is different from that in traditional methods which usually output duplicate boxes. In traditional methods, the ensembling is done by first gathering predictions from all augmentations and ranked by a confidence score. Then, duplicate boxes are found and eliminated by NMS or box voting. The reason why predictions from all augmentations are gathered first is that duplicate boxes appear not only among different augmentations but also within one augmentation. This ensembling method decreases the performance for our method since DETR-like methods are not prone to output duplicate boxes since their set-based prediction loss inhibits duplicate predictions and ensembling may incorrectly remove true positive predictions (Carion et al., 2020). To address this issue, we designed a one-to-one ensembling method. Assume we have $n$ augmentations $A u g _ { 0 } , A u g _ { 1 } , . . . , A u g _ { n - 1 }$ , where $A u g _ { i }$ has predictions $\mathbf { O } ^ { i }$ and a pre-defined hyper-parameter weight $w ^ { i }$ . $\mathbf { O } ^ { i } = \left\{ \left( b _ { 0 } ^ { i } , l _ { 0 } ^ { i } , s _ { 0 } ^ { i } \right) , \left( b _ { 1 } ^ { i } , l _ { 1 } ^ { i } , s _ { 1 } ^ { i } \right) , . . . , \left( b _ { m - 1 } ^ { i } , l _ { m - 1 } ^ { i } , s _ { m - 1 } ^ { i } \right) \right\}$ where $b _ { j } ^ { i } , l _ { j } ^ { i }$ and ${ \bf \bar { \boldsymbol { s } } } _ { j } ^ { i }$ denote the $j$ -th boundbox, label and score, respectively. We let $A u g _ { 0 }$ be the main augmentation which is the most reliable one. For each prediction in ${ \bf O } ^ { 0 }$ , we select the prediction with the highest $I O U$ from predictions of each of other augmentations $\mathbf { O } ^ { 1 } , . . . , \mathbf { O } ^ { n - 1 }$ and make sure the $I O U$ is higher than a predefined threshold. Finally, we ensemble the selected boxes through weighted average as follows
|
| 265 |
+
|
| 266 |
+
$$
|
| 267 |
+
b = \frac { 1 } { \sum I ^ { i } } \sum _ { i = o } ^ { n - 1 } I ^ { i } w ^ { i } s _ { i d x ( i ) } ^ { i } b _ { i d x ( i ) } ^ { i }
|
| 268 |
+
$$
|
| 269 |
+
|
| 270 |
+
where $I ^ { i } = 1$ when there is at least one box in $\mathbf { O } ^ { i }$ with IOU higher than the threshold and $I ^ { i } = 0$ otherwise. $i d x ( i )$ denotes the index of the selected box in $\mathbf { O } ^ { i }$ .
|
| 271 |
+
|
| 272 |
+
# D TRAINING EFFICIENCY
|
| 273 |
+
|
| 274 |
+
We provide the GPU memory and training time for our base model in Table 7. All results are reported on 8 Nvidia A100 GPUs with ResNet-50 (He et al., 2016). The results demonstrate that our models are not only effective but also efficient for training.
|
| 275 |
+
|
| 276 |
+
<table><tr><td>Model</td><td>#images per GPU</td><td>Traning Time</td><td>GPU Mem.</td><td>Epoch</td><td>AP</td></tr><tr><td>Faster RCNN (Ren et al., 2015)*</td><td>8</td><td>~ 60min/ep</td><td>13GB</td><td>108</td><td>42.0</td></tr><tr><td>DETR(Carion et al.,2020)</td><td>8</td><td>~16min/ep</td><td>26GB</td><td>300</td><td>41.2</td></tr><tr><td>Deformable DETR (Zhu et al., 2021)*</td><td>2</td><td>~ 55min/ep</td><td>16GB</td><td>50</td><td>45.4</td></tr><tr><td>DINO(Ours)</td><td>2</td><td>~ 55min/ep</td><td>16GB</td><td>12</td><td>49.0</td></tr></table>
|
| 277 |
+
|
| 278 |
+
Table 7: Training efficieny for different models with ResNet-50 backbone. All models are trianed with 8 Nvidia A100 GPUs. All results are reported by us. \* The results of Faster RCNN are tested with the mmdetection framework. ⋆ We use the vanilla Deformable DETR without two-stage and bbox refinement during testing.
|
| 279 |
+
|
| 280 |
+
# E ADDITIONAL ANALYSIS ON OUR MODEL COMPONENTS
|
| 281 |
+
|
| 282 |
+
<table><tr><td rowspan=1 colspan=1>#Encoder/Decoder</td><td rowspan=1 colspan=1>6/6</td><td rowspan=1 colspan=1>4/6</td><td rowspan=1 colspan=1>3/6</td><td rowspan=1 colspan=1>2/6</td><td rowspan=1 colspan=1>6/4</td><td rowspan=1 colspan=1>6/2</td><td rowspan=1 colspan=1>2/4</td><td rowspan=1 colspan=1>2/2</td></tr><tr><td rowspan=1 colspan=1>AP</td><td rowspan=1 colspan=1>47.4</td><td rowspan=1 colspan=1>46.2</td><td rowspan=1 colspan=1>45.8</td><td rowspan=1 colspan=1>45.4</td><td rowspan=1 colspan=1>46.0</td><td rowspan=1 colspan=1>44.4</td><td rowspan=1 colspan=1>44.1</td><td rowspan=1 colspan=1>41.2</td></tr></table>
|
| 283 |
+
|
| 284 |
+
Table 8: Ablation on the numbers of encoder layers and decoder layers with the ResNet-50 backbone on COCO val2017. We use the 12-epoch setting and $1 0 0 \mathrm { D N }$ queries without negative samples here.
|
| 285 |
+
|
| 286 |
+
Analysis on the Number of Encoder and Decoder Layers: We also investigate the influence of varying numbers of encoder and decoder layers. As shown in Table 8, decreasing the number of decoder layers hurts the performance more significantly. For example, using the same 6 encoder layers while decreasing the number of decoder layers from 6 to 2 leads to a 3.0 AP drop. This performance drop is expected as the boxes are dynamically updated and refined through each decoder layer to get the final results. Moreover, we also observe that compared with other DETR-like models like Dynamic DETR (Dai et al., 2021a) whose performance drops by 13.8AP (29.1 vs 42.9) when decreasing the number of decoder layers to 2, the performance drop of DINO is much smaller. This is because our mixed query selection approach feeds the selected boxes from the encoder to enhance the decoder queries. Therefore, the decoder queries are well initialized and not deeply coupled with decoder layer refinement.
|
| 287 |
+
|
| 288 |
+
<table><tr><td rowspan=1 colspan=1>#Denoising query</td><td rowspan=1 colspan=1>100 CDN</td><td rowspan=1 colspan=1>1000 DN</td><td rowspan=1 colspan=1>200DN</td><td rowspan=1 colspan=1>100 DN</td><td rowspan=1 colspan=1>50 DN</td><td rowspan=1 colspan=1>10 DN</td><td rowspan=1 colspan=1>No DN</td></tr><tr><td rowspan=1 colspan=1>AP</td><td rowspan=1 colspan=1>47.9</td><td rowspan=1 colspan=1>47.6</td><td rowspan=1 colspan=1>47.4</td><td rowspan=1 colspan=1>47.4</td><td rowspan=1 colspan=1>46.7</td><td rowspan=1 colspan=1>46.0</td><td rowspan=1 colspan=1>45.1</td></tr></table>
|
| 289 |
+
|
| 290 |
+
Table 9: Ablation on number of denoising queries with the ResNet-50 backbone on COCO validation. Note that $1 0 0 { \mathrm { C N D } }$ query pairs contains 200 queries which are 100 positive and 100 negative queries.
|
| 291 |
+
|
| 292 |
+
Analysis on Query Denoising: We continue to investigate the influence of query denoising by varying the number of denoising queries. We use the optimized dynamic denoising group (detailed in Appendix F.1). As shown in Table 9, when we use less than 100 denoising queries, increasing the number can lead to a significant performance improvement. However, continuing to increase the DN number after 100 yields only a small additional or even worse performance improvement. We also analysis the effect of the number of encoder and decoder Layers in Appendix E.
|
| 293 |
+
|
| 294 |
+
# F MORE IMPLEMENTATION DETAILS
|
| 295 |
+
|
| 296 |
+
# F.1 ADAPTIVE DN GROUPS
|
| 297 |
+
|
| 298 |
+
In DN-DETR, all the GT objects (label+box) in one image are collected as one GT group for denoising. To improve the DN training efficiency, multiple noised versions of the GT group in an image are used during training. In DN-DETR, the number of groups is set to five or ten according to different model sizes. As DETR-like models adopt mini-batch training, the total number of DN queries for each image in one batch is padded to the largest one in the batch. Considering that the number of objects in one image in COCO dataset ranges from 1 to 80, this design is inefficient and results in excessive memory consumption. To address this problem, we propose to fix the number of DN queries and dynamically adjust the number of groups for each image according to its number of objects.
|
| 299 |
+
|
| 300 |
+
# F.2 LARGE-SCALE MODEL PRE-TRIANING
|
| 301 |
+
|
| 302 |
+
Objects365 (Shao et al., 2019) is a large-scale detection data set with over $1 . 7 M$ annotated images for training and 80, 000 annotated images for validation. To use the data more efficiently, We select the first 5, 000 out of 80, 000 validation images as our validation set and add the others to training. We pre-train DINO on Objects365 for 26 epochs using 64 Nvidia A100 GPUs and fine-tune the model on COCO for 18 epochs using 16 Nvidia A100 GPUS. Each GPU has a local batch size of 1 image only. In the fine-tuning stage, we enlarge the image size to $1 . 5 \times$ (i.e., with max size $1 2 0 0 \times 2 0 0 0 \textcircled { \cdot }$ ). This adds around 0.5 AP to the final result. To reduce the GPU memory usage, we leverage checkpointing (Chen et al., 2016) and mixed precision (Micikevicius et al., 2018) during training. Moreover, we use $1 0 0 0 \mathrm { D N }$ queries for this large model.
|
| 303 |
+
|
| 304 |
+
# F.3 OTHER IMPLEMENTATION DETAILS
|
| 305 |
+
|
| 306 |
+
# F.3.1 BASIC HYPER-PARAMETERS.
|
| 307 |
+
|
| 308 |
+
For hyper-parameters, as in DN-DETR, we use a 6-layer Transformer encoder and a 6-layer Transformer decoder and 256 as the hidden feature dimension. We set the initial learning rate (lr) as $1 \times 1 0 ^ { - 4 }$ and adopt a simple lr scheduler, which drops lr at the 11-th, 20-th, and 30-th epoch by multiplying 0.1 for the 12, 24, and 36 epoch settings with RestNet50, respectively. We use the AdamW (Kingma & Ba, 2014; Loshchilov & Hutter, 2017) optimizer with weight decay of $1 \times 1 0 ^ { - 4 }$ and train our model on Nvidia A100 GPUs with batch size 16. Since DN-DETR (Li et al., 2022) adopts 300 decoder queries and 3 patterns (Wang et al., 2021), we use $3 0 0 \times 3 = 9 0 0$ decoder queries with the same computation cost. Learning schedules of our DINO with SwinL are available in the appendix.
|
| 309 |
+
|
| 310 |
+
# F.3.2 LOSS FUNCTION.
|
| 311 |
+
|
| 312 |
+
We use the L1 loss and GIOU (Rezatofighi et al., 2019) loss for box regression and focal loss (Lin et al., 2020) with $\alpha = 0 . 2 5 , \gamma = 2$ for classification. As in DETR (Carion et al., 2020), we add auxiliary losses after each decoder layer. Similar to Deformable DETR (Zhu et al., 2021), we add extra intermediate losses after the query selection module, with the same components as for each decoder layer. We use the same loss coefficients as in DAB-DETR (Liu et al., 2022) and DNDETR (Li et al., 2022), that is, 1.0 for classification loss, 5.0 for L1 loss, and 2.0 for GIOU loss.
|
| 313 |
+
|
| 314 |
+
# F.3.3 DETAILED MODEL COMPONENTS.
|
| 315 |
+
|
| 316 |
+
We also optimize the detection pipeline used in DAB-DETR (Liu et al., 2022) and DN-DETR (Li et al., 2022). Following DN-Deformable-DETR (Li et al., 2022), we use the same multi-scale approach as in Deformable DETR (Zhu et al., 2021) and adopt the deformable attention. DN-DETR uses different prediction heads with unshared parameters in different decoder layers. In addition, we introduce dynamic denoising group to increase denoising training efficiency and alleviate memory overhead (see Appendix F.1). In this work, we find that using a shared prediction head will add additional performance improvement. This also leads to a reduction of about one million parameters.
|
| 317 |
+
|
| 318 |
+
Table 10: Hyper-parameters used in our models.
|
| 319 |
+
|
| 320 |
+
<table><tr><td rowspan=1 colspan=1>Item</td><td rowspan=1 colspan=1>Value</td></tr><tr><td rowspan=1 colspan=1>Ir</td><td rowspan=1 colspan=1>0.0001</td></tr><tr><td rowspan=1 colspan=1>lr_backbone</td><td rowspan=1 colspan=1>1e-05</td></tr><tr><td rowspan=1 colspan=1>weight_decay</td><td rowspan=1 colspan=1>0.0001</td></tr><tr><td rowspan=1 colspan=1>clip_max_norm</td><td rowspan=1 colspan=1>0.1</td></tr><tr><td rowspan=1 colspan=1>pe_temperature</td><td rowspan=1 colspan=1>20</td></tr><tr><td rowspan=1 colspan=1>enc_layers</td><td rowspan=1 colspan=1>6</td></tr><tr><td rowspan=1 colspan=1>dec_layers</td><td rowspan=1 colspan=1>6</td></tr><tr><td rowspan=1 colspan=1>dim_feedforward</td><td rowspan=1 colspan=1>2048</td></tr><tr><td rowspan=1 colspan=1>hidden_dim</td><td rowspan=1 colspan=1>256</td></tr><tr><td rowspan=1 colspan=1>dropout</td><td rowspan=1 colspan=1>0.0</td></tr><tr><td rowspan=1 colspan=1>nheads</td><td rowspan=1 colspan=1>8</td></tr><tr><td rowspan=1 colspan=1>num_queries</td><td rowspan=1 colspan=1>900</td></tr><tr><td rowspan=1 colspan=1>enc_n_points</td><td rowspan=1 colspan=1>4</td></tr><tr><td rowspan=1 colspan=1>dec_n_points</td><td rowspan=1 colspan=1>4</td></tr><tr><td rowspan=1 colspan=1>transformer_activation</td><td rowspan=1 colspan=1>"relu"</td></tr><tr><td rowspan=1 colspan=1>batch_norm_type</td><td rowspan=1 colspan=1>"FrozenBatchNorm2d"</td></tr><tr><td rowspan=1 colspan=1>set_cost_class</td><td rowspan=1 colspan=1>2.0</td></tr><tr><td rowspan=1 colspan=1>set_cost_bbox</td><td rowspan=1 colspan=1>5.0</td></tr><tr><td rowspan=1 colspan=1>set_cost_giou</td><td rowspan=1 colspan=1>2.0</td></tr><tr><td rowspan=1 colspan=1>cls_loss_coef</td><td rowspan=1 colspan=1>1.0</td></tr><tr><td rowspan=1 colspan=1>bbox_loss_coef</td><td rowspan=1 colspan=1>5.0</td></tr><tr><td rowspan=1 colspan=1>giou_loss_coef</td><td rowspan=1 colspan=1>2.0</td></tr><tr><td rowspan=1 colspan=1>focal_alpha</td><td rowspan=1 colspan=1>0.25</td></tr><tr><td rowspan=1 colspan=1>dn_box_noise_scale</td><td rowspan=1 colspan=1>0.4</td></tr><tr><td rowspan=1 colspan=1>dn_label_noise_ratio</td><td rowspan=1 colspan=1>0.5</td></tr></table>
|
| 321 |
+
|
| 322 |
+
In addition, we find the conditional queries (Meng et al., 2021) used in DAB-DETR does not suit our model and we do not include them in our final model.
|
| 323 |
+
|
| 324 |
+
# F.3.4 TRAINING AUGMENTATION.
|
| 325 |
+
|
| 326 |
+
We use the same random crop and scale augmentation during training following DETR (Carion et al., 2020). For example, we randomly resize an input image with its shorter side between 480 and 800 pixels and its longer side at most 1333. For DINO with SwinL, we pre-train the model using the default setting, but finetune using $1 . 5 \times$ larger scale (shorter side between 720 and 1200 pixels and longer side at most 2000 pixels) to compare with models on the leaderboard (pap). Without using any other tricks, we achieve the result of 63.1 on $\mathtt { v a l } 2 0 1 7$ and 63.2 on test-dev without test time augmentation (TTA) (see Appendix C), outperforming the previous state-of-the-art result 63.1 achieved by SwinV2 (Liu et al., 2021a) with a much neater solution.
|
| 327 |
+
|
| 328 |
+
# F.3.5 MULTI-SCALE SETTING.
|
| 329 |
+
|
| 330 |
+
For our 4-scale models, we extract features from stages 2, 3, and 4 of the backbone and add an extra feature by down-sampling the output of the stage 4. An additional feature map of the backbone stage 1 is used for our 5-scale models. For hyper-parameters, we set $\lambda _ { 1 } = 1 . 0$ and $\lambda _ { 2 } = 2 . 0$ and use 100 CDN pairs which contain 100 positive queries and 100 negative queries.
|
| 331 |
+
|
| 332 |
+
# F.4 DETAILED HYPER-PARAMETERS
|
| 333 |
+
|
| 334 |
+
We list the hyper-parameters for those who want to reproduce our results in Table 10.
|
| 335 |
+
|
| 336 |
+
Table 11: The inference speed and computation cost of our laege model.
|
| 337 |
+
|
| 338 |
+
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>#parameters</td><td rowspan=1 colspan=1>GFLOPs</td><td rowspan=1 colspan=1>FPs</td></tr><tr><td rowspan=1 colspan=1>DINO-Swin-L-4Scale</td><td rowspan=1 colspan=1>217.6</td><td rowspan=1 colspan=1>1284.5</td><td rowspan=1 colspan=1>8.1</td></tr><tr><td rowspan=1 colspan=1>DINO-Swin-L-5Scale</td><td rowspan=1 colspan=1>217.2</td><td rowspan=1 colspan=1>703.5</td><td rowspan=1 colspan=1>12.8</td></tr></table>
|
| 339 |
+
|
| 340 |
+
Table 12: The experiments of Look Forward Three (LF3) and Four times (LF4).
|
| 341 |
+
|
| 342 |
+
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>#epochs</td><td rowspan=1 colspan=1>AP</td><td rowspan=1 colspan=1>AP50</td><td rowspan=1 colspan=1>AP75</td><td rowspan=1 colspan=1>APs</td><td rowspan=1 colspan=1>APM</td><td rowspan=1 colspan=1>APL</td></tr><tr><td rowspan=1 colspan=1>DINO-LFT</td><td rowspan=1 colspan=1>12</td><td rowspan=1 colspan=1>49.0</td><td rowspan=1 colspan=1>66.6</td><td rowspan=1 colspan=1>53.5</td><td rowspan=1 colspan=1>32.0</td><td rowspan=1 colspan=1>52.3</td><td rowspan=1 colspan=1>63.0</td></tr><tr><td rowspan=1 colspan=1>DINO-LF3</td><td rowspan=1 colspan=1>12</td><td rowspan=1 colspan=1>48.3</td><td rowspan=1 colspan=1>65.5</td><td rowspan=1 colspan=1>52.7</td><td rowspan=1 colspan=1>31.2</td><td rowspan=1 colspan=1>51.7</td><td rowspan=1 colspan=1>62.5</td></tr><tr><td rowspan=1 colspan=1>DINO-LF4</td><td rowspan=1 colspan=1>12</td><td rowspan=1 colspan=1>48.2</td><td rowspan=1 colspan=1>65.4</td><td rowspan=1 colspan=1>52.9</td><td rowspan=1 colspan=1>30.4</td><td rowspan=1 colspan=1>51.8</td><td rowspan=1 colspan=1>62.9</td></tr></table>
|
| 343 |
+
|
| 344 |
+
# G INFERENCE SPEED AND GFLOPS
|
| 345 |
+
|
| 346 |
+
We list the inference cost of our 4-scale and 5-scale model with Swin-L backbones in Table 11. Note that our model for Table 4 is a 5-scale model.
|
| 347 |
+
|
| 348 |
+
# H WHY DINO IMPROVES AP ON SMALL OBJECTS BY LARGE
|
| 349 |
+
|
| 350 |
+
There are several reasons for the large AP improvement on small objects $( \mathsf { A P } _ { s } )$
|
| 351 |
+
|
| 352 |
+
1. In Table 5, our optimized DN-Deformable DETR has $\mathsf { A P } _ { s }$ of 28.2 which is $+ 3 . 4$ higher than that of the original DN-Deformable DETR in Table 2. The original one uses dense attention in the decoder while the optimized one uses deformable attention which is better for local attention and therefore improves $\mathsf { A P } _ { s }$ . In addition, we fixed a problem in the original DN-Deformable DETR’s Transformer encoder—their deformable attention is not properly initialized using the initialization method in Deformable DETR. The Transformer encoder is a critical component that processes multi-scale image features and multi-scale image features are critical for small objects. Therefore, the optimized one has higher $\boldsymbol { \mathrm { A P } _ { s } }$ .
|
| 353 |
+
2. In Table 5, we can see that CDN improves $\mathsf { A P } _ { s }$ by 1.2. By introducing negative noised queries, CDN encourages the model to pick up the anchor nearest to the center of a GT box to make predictions and explicitly suppresses farther anchors. Since small object detection is more sensitive to the quality of anchors, DINO with high-quality anchors can achieve better $\mathsf { A P } _ { s }$ .
|
| 354 |
+
3. Query selection improves $\mathsf { A P } _ { s }$ by 1.9. Query selection provides high-quality anchor initialization which is especially beneficial to small objects. The reason is similar to reason 2 that small object detection is more sensitive to the quality of anchors.
|
| 355 |
+
|
| 356 |
+
# I MORE DETAILS ABOUT LOOK FORWARD TWICE (LFT)
|
| 357 |
+
|
| 358 |
+
We propose LFT because the original Look Forward Once scheme for box refinement is greedy, which will lead to sub-optimal results. We propose LFT to make the model far-sighted. But there is a trade-off. When we increase the number of layers to ”look forward”, the model becomes harder to converge. We conduct experiments of Look Forward Three and Four times as shown in Table 12. The results become worse when we continue to increase the number of layers to “look forward”.
|
| 359 |
+
|
| 360 |
+
Following is a detailed explanation of why LFT is worse than LFO in layers 0 to 2 but outperforms LFO in layers 3 to 6 as shown in Fig. 4.
|
| 361 |
+
|
| 362 |
+
There are actually three factors affecting the performance of layer $i$
|
| 363 |
+
|
| 364 |
+
1. The performance of layer $i - 1$ . Since the predictions of layer $i$ are based on predictions of layer $i - 1$ , better predictions in layer $i - 1$ lead to better predictions in layer $i$ . 2. Whether allows gradients to backpropagate from layer $i$ to layer $i - 1$ . Allowing the gradient to propagate to layer $i - 1$ helps performance in layer $i$ .
|
| 365 |
+
|
| 366 |
+
3. Whether allows gradients backpropagate from layer $i + 1$ to layer $i$ . Allowing gradient to propagate from layer $i + 1$ to layer $i$ jeopardizes performance in layer $i$ .
|
| 367 |
+
|
| 368 |
+
For layer 0, there is no layer $i - 1$ , so factors 1 and 2 do not affect the performance. According to factor 3, LFO is better than LFT.
|
| 369 |
+
|
| 370 |
+
For layers 1 to 5, LFO has an advantage in factor 3 and LFT has an advantage in factor 2. Because factor 2 affects the performance more than factor 3, The gap between LFT is narrowed down from layer 0 to 2 and LFT exceeds LFO in layer 3.
|
| 371 |
+
|
| 372 |
+
In the last layer (when $i = 6$ ), there is no layer $i + 1$ (factor 3 does not affect the result) and LFT has the advantage in both factors 1 and 2. Therefore, LFT exceeds LFO in the last layer.
|
| 373 |
+
|
| 374 |
+
# J VISUALIZATIONS
|
| 375 |
+
|
| 376 |
+

|
| 377 |
+
Figure 7: Visualization of cases DINO outperforms DN-DETR.
|
| 378 |
+
|
| 379 |
+
We present a comparison of visualizations in Fig. 7. The results show that our DINO has better predictions than DN-DETR.
|
| 380 |
+
|
| 381 |
+
# K LVIS RESULTS
|
| 382 |
+
|
| 383 |
+
To evaluate DINO’s performance on other detection datasets, we conducted experiments on more challenging LVIS (Gupta et al., 2019) dataset.
|
| 384 |
+
|
| 385 |
+
Table 13: The results on LVIS val v1.0. ∗ denotes zero-shot results. † denotes DINO is trained for 12 epochs and is not fully conveged.
|
| 386 |
+
|
| 387 |
+
<table><tr><td rowspan=2 colspan=1>Model</td><td rowspan=2 colspan=1>Backbone</td><td rowspan=1 colspan=4>Val v1.0</td></tr><tr><td rowspan=1 colspan=1>AP</td><td rowspan=1 colspan=1>APr</td><td rowspan=1 colspan=1>APc</td><td rowspan=1 colspan=1>APf</td></tr><tr><td rowspan=1 colspan=1>Supervised-RFS (Gupta etal., 2019)</td><td rowspan=1 colspan=1>R50</td><td rowspan=1 colspan=1>25.4</td><td rowspan=1 colspan=1>12.3</td><td rowspan=1 colspan=1>24.3</td><td rowspan=1 colspan=1>32.4</td></tr><tr><td rowspan=1 colspan=1>MaskRCNN-LOCE (He et al., 2017)</td><td rowspan=1 colspan=1>R50</td><td rowspan=1 colspan=1>27.4</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>1</td></tr><tr><td rowspan=1 colspan=1>GLIP*(Li et al., 2021)</td><td rowspan=1 colspan=1>Swin-L</td><td rowspan=1 colspan=1>26.9</td><td rowspan=1 colspan=1>17.1</td><td rowspan=1 colspan=1>23.3</td><td rowspan=1 colspan=1>35.4</td></tr><tr><td rowspan=1 colspan=1>DINOt</td><td rowspan=1 colspan=1>R50</td><td rowspan=1 colspan=1>31.2</td><td rowspan=1 colspan=1>24.5</td><td rowspan=1 colspan=1>29.8</td><td rowspan=1 colspan=1>35.7</td></tr></table>
|
md/dev/45L_dgP48Vd/45L_dgP48Vd.md
ADDED
|
@@ -0,0 +1,410 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# GRAPH-AUGMENTED NORMALIZING FLOWS FOR ANOMALY DETECTION OF MULTIPLE TIME SERIES
|
| 2 |
+
|
| 3 |
+
Enyan Dai∗ Pennsylvania State University emd5759@psu.edu
|
| 4 |
+
|
| 5 |
+
Jie Chen† MIT-IBM Watson AI Lab, IBM Research chenjie@us.ibm.com
|
| 6 |
+
|
| 7 |
+
# ABSTRACT
|
| 8 |
+
|
| 9 |
+
Anomaly detection is a widely studied task for a broad variety of data types; among them, multiple time series appear frequently in applications, including for example, power grids and traffic networks. Detecting anomalies for multiple time series, however, is a challenging subject, owing to the intricate interdependencies among the constituent series. We hypothesize that anomalies occur in low density regions of a distribution and explore the use of normalizing flows for unsupervised anomaly detection, because of their superior quality in density estimation. Moreover, we propose a novel flow model by imposing a Bayesian network among constituent series. A Bayesian network is a directed acyclic graph (DAG) that models causal relationships; it factorizes the joint probability of the series into the product of easy-to-evaluate conditional probabilities. We call such a graph-augmented normalizing flow approach GANF and propose joint estimation of the DAG with flow parameters. We conduct extensive experiments on real-world datasets and demonstrate the effectiveness of GANF for density estimation, anomaly detection, and identification of time series distribution drift.
|
| 10 |
+
|
| 11 |
+
# 1 INTRODUCTION
|
| 12 |
+
|
| 13 |
+
Anomaly detection (Pimentel et al., 2014; Ruff et al., 2018) is the task of identifying unusual samples that significantly deviate from the majority of the data instances. It is applied in a broad variety of domains, including risk management (Aven, 2016), video surveillance (Kiran et al., 2018), adversarial example detection (Grosse et al., 2017), and fraud detection (Roy & George, 2017). Representative classical methods for anomaly detection are one-class support vector machines (Scholkopf ¨ et al., 2001) and kernel density estimation (Parzen, 1962; Kim & Scott, 2012). These methods rely on handcrafted features and often are not robust for high-dimensional data (e.g., images, speech signals, and time series). In recent years, inspired by the success of deep learning for complex data, many deep anomaly detection methods were proposed and they are remarkably effective in applications (Ruff et al., 2018; Sabokrou et al., 2018; Goyal et al., 2020).
|
| 14 |
+
|
| 15 |
+
Apart from these demonstrated applications, increasing demand exists for the anomaly detection of even more complex data; i.e., multiple time series. They contain a set of multivariate time series that often interact with each other in a system. A prominent example of the source of multiple time series is the power grid, where each constituent series is the grid state over time, recorded by a sensor deployed at a certain geographic location. The grid state includes many attributes; e.g., current magnitude and angle, voltage magnitude and angle, and frequency. Time series readings from sensors at nearby locations are often correlated and their behavior may be causal under cascading effects. Anomaly detection amounts to timely identifying abnormal grid conditions such as generator trip and insulator damage.
|
| 16 |
+
|
| 17 |
+
Anomaly detection of multiple time series is rather challenging, due to high dimensionality, interdependency, and label scarcity. First, a straightforward approach is to concatenate the constituent series along the attribute dimension and apply a detection method for multivariate time series. However, when the system contains many constituents, the resulting data suffer high dimensionality. Second, constituent series bear intricate interdependencies, which may be implicit and challenging to model. When an explicit graph topology is known, graph neural networks are widely used to digest the relational information (Seo et al., 2016; Li et al., 2018b; Yu et al., 2018; Zhao et al., 2019). However, a graph may not always be known (because, for example, it is sensitive information) and hence graph structure learning becomes an indispensable component of the solution (Kipf et al., 2018; Wu et al., 2020; Shang et al., 2021; Deng & Hooi, 2021). Third, labeling information is often limited. Even if certain labels are present, in practice, many anomalies may still stay unidentified because labeling is laborious and expensive. Hence, unsupervised approaches are the most suitable choice. However, albeit many unsupervised detection methods were proposed (Ruff et al., 2018; Sabokrou et al., 2018; Malhotra et al., 2016; Hendrycks et al., 2019), they are not effective for multiple time series.
|
| 18 |
+
|
| 19 |
+
In this work, we explore the use of normalizing flows (Dinh et al., 2016; Papamakarios et al., 2017) for anomaly detection, based on a hypothesis that anomalies often lie on low density regions of the data distribution. Normalizing flows are a class of deep generative models for learning the underlying distribution of data samples. They are unsupervised and they resolve the label scarcity challenge aforementioned. An advantage of normalizing flows is that they are particularly effective in estimating the density of any sample. A recent work by Rasul et al. (2021) extends normalizing flows for time series data by expressing the density of a series through successive conditioning on historical data and applying conditional flows to learn each conditional density, paving ways to build sophisticated flows for multiple time series.
|
| 20 |
+
|
| 21 |
+
We address the high dimensionality and interdependency challenges by learning the relational structure among constituent series. To this end, Bayesian networks (Pearl, 1985; 2000) that model causal relationships of variables are a principled choice. A Bayesian network is a directed acyclic graph (DAG) where a node is conditionally independent of its non-descendents given its parents. Such a structure allows factorizing the intractable joint density of all graph nodes into a product of easyto-evaluate conditional densities of each node. Hence, learning the relational structure among constituent series amounts to identifying a DAG that maximizes the densities of observed data.
|
| 22 |
+
|
| 23 |
+
We propose a novel framework, GANF (Graph-Augmented Normalizing Flow), to augment a normalizing flow with graph structure learning and to apply it for anomaly detection. There are nontrivial technical problems to resolve to materialize this framework: (i) How does one inject a graph into a normalizing flow, which essentially maps one distribution to another? (ii) How does one learn a DAG, which is a discrete object, inside a continuous flow model? The solution we take is to factorize the density of a multiple time series along the attribute, the temporal, and the series dimensions and use a graph-based dependency encoder to model the conditional densities resulting from factorization. Therein, the graph adjacency matrix is a continuous variable and we impose a differentiable constraint to ensure that the corresponding graph is acyclic (Zheng et al., 2018; Yu et al., 2019). We propose a joint training algorithm to optimize both the graph adjacency matrix and the flow parameters.
|
| 24 |
+
|
| 25 |
+
In addition to resolving the high dimensionality and interdependency challenges, an advantage of modeling the relational graph structure among constituent series is that one can easily observe the dynamics of the data distribution from the graph. For time series datasets that span a long period, one naturally questions if the distribution changes over time. The graph structure is a useful indicator of distribution drift. We will study the graph evolution empirically observed.
|
| 26 |
+
|
| 27 |
+
We highlight the following contributions of this work:
|
| 28 |
+
|
| 29 |
+
• We propose a framework to augment a normalizing flow with graph structure learning, to model interdependencies exhibited inside multiple time series.
|
| 30 |
+
• We apply the augmented flow model to detect anomalies in multiple time series data and perform extensive empirical evaluation to demonstrate its effectiveness on real-world data sets.
|
| 31 |
+
• We study the evolution of the learned graph structure and identify distribution drift in time series data that span a long time period.
|
| 32 |
+
|
| 33 |
+
# 2 RELATED WORK
|
| 34 |
+
|
| 35 |
+
Anomaly Detection. Anomaly detection is a widely studied subject owing to its diverse applications. Recently, inspired by the success of deep learning, several deep anomaly detection methods are proposed and they achieve remarkable success on complex data, such as individual time series (Malhotra et al., 2016), images (Sabokrou et al., 2018), and videos (Ionescu et al., 2019). These methods generally fall under three categories: deep one-class models, generative model-based methods, and transformation-based methods. Deep one-class models (Ruff et al., 2018; Wu et al., 2019) treat normal instances as the target class and identify instances that do not belong to this class. In generative model-based methods (Malhotra et al., 2016; Nguyen et al., 2019; Li et al., 2018a), an autoencoder or a generative adversarial network is used to model the data distribution. Then, an anomaly measure is defined, such as the reconstruction error in autoencoding. Transformationbased methods (Golan & El-Yaniv, 2018; Hendrycks et al., 2019) are based on the premise that transformations applied to normal instances can be identified while anomalies not. Various transformations such as rotations and affine transforms have been investigated. On the other hand, anomaly detection of multiple time series is under explored. Recently, Deng & Hooi (2021) study the use of graph neural networks in combination with structure learning to detect anomalies. Our method substantially differs from this work in that the learned structure is a Bayesian network, which allows density estimation. Moreover, the Bayesian network identifies conditional dependencies among the constituent series and induces a better interpretation of the graph as well as the data distribution.
|
| 36 |
+
|
| 37 |
+
Normalizing Flows. Normalizing flows are generative models that normalize complex real-world data distributions to “standard” distributions by using a sequence of invertible and differentiable transformations. Dinh et al. (2016) introduce a widely used normalizing flow architecture— RealNVP—for density estimation. Various extensions and improvements are proposed (Papamakarios et al., 2017; Hoogeboom et al., 2019; Kingma & Dhariwal, 2018). For example, Papamakarios et al. (2017) view an autoregressive model as a normalizing flow. To model temporal data, Rasul et al. (2021) use sequential models to parameterize conditional flows. Moreover, graph normalizing flows are proposed to handle graph structured data and improve predictions and generations (Liu et al., 2019). In contrast, normalizing flows for multiple time series are rarely studied in the literature. In this work, we develop a graph-augmented flow for density estimation and anomaly detection of multiple time series.
|
| 38 |
+
|
| 39 |
+
# 3 PRELIMINARIES
|
| 40 |
+
|
| 41 |
+
We first recall key concepts and familiarize the reader with notations to be used throughout the paper.
|
| 42 |
+
|
| 43 |
+
# 3.1 NORMALIZING FLOWS
|
| 44 |
+
|
| 45 |
+
Let $\mathbf { x } \in \mathbb { R } ^ { D }$ be a $D$ -dimensional random variable. A normalizing flow is a vector-valued invertible mapping $\mathbf { f } ( \mathbf { x } ) : \mathbb { R } ^ { D } \mathbb { R } ^ { D }$ that normalizes the distribution of $\mathbf { x }$ to a “standard” distribution (or called base distribution). This distribution is usually taken to be an isotropic Gaussian or other ones that are easy to sample from and whose density is easy to evaluate. Let ${ \bf z } = { \bf f } ( { \bf x } )$ with probability density function $q ( \mathbf { z } )$ . With the change-of-variable formula, we can express the density of the $\mathbf { x }$ , $p ( \mathbf { x } )$ , by:
|
| 46 |
+
|
| 47 |
+
$$
|
| 48 |
+
\begin{array} { r } { \log p ( \mathbf { x } ) = \log q ( \mathbf { f } ( \mathbf { x } ) ) + \log | \operatorname* { d e t } \nabla _ { \mathbf { x } } \mathbf { f } ( \mathbf { x } ) | . } \end{array}
|
| 49 |
+
$$
|
| 50 |
+
|
| 51 |
+
In practical uses, the Jacobian determinant in (1) needs be easy to compute, so that the density $p ( \mathbf { x } )$ can be evaluated. Moreover, as a generative model, the invertibility of $\mathbf { f }$ allows drawing new instances $\mathbf { x } = \mathbf { f } ^ { - 1 } ( \mathbf { z } )$ through sampling the base distribution. One example of such f is the masked autoregressive flow (Papamakarios et al., 2017), which yields $\mathbf { z } = [ z _ { 1 } , \dots , z _ { D } ]$ from $\mathbf { x } = [ x _ { 1 } , \dots , x _ { D } ]$ through
|
| 52 |
+
|
| 53 |
+
$$
|
| 54 |
+
z _ { i } = ( x _ { i } - \mu _ { i } ( \mathbf { x } _ { 1 : i - 1 } ) ) \exp ( \alpha _ { i } ( \mathbf { x } _ { 1 : i - 1 } ) ) ,
|
| 55 |
+
$$
|
| 56 |
+
|
| 57 |
+
where $\mu _ { i }$ and $\alpha _ { i }$ are neural networks such as the multilayer perceptron.
|
| 58 |
+
|
| 59 |
+
A flow may be augmented with conditional information $\mathbf { h } \in \mathbb { R } ^ { d }$ with a possibly different dimension. Such a flow is a conditional flow and is denoted by $\textbf { f } : \mathbb { R } ^ { D } \times \mathbb { R } ^ { d } \overset { \cdot } { } \mathbb { R } ^ { D }$ . The log-density of $\mathbf { x }$ conditioned on $\mathbf { h }$ admits the following formula:
|
| 60 |
+
|
| 61 |
+
$$
|
| 62 |
+
\begin{array} { r } { \log p ( { \mathbf x } | { \mathbf h } ) = \log q ( { \mathbf f } ( { \mathbf x } ; { \mathbf h } ) ) + \log | \operatorname* { d e t } \nabla _ { { \mathbf x } } { \mathbf f } ( { \mathbf x } ; { \mathbf h } ) | . } \end{array}
|
| 63 |
+
$$
|
| 64 |
+
|
| 65 |
+
We now consider a normalizing flow for time series. Let $\mathbf { X } = [ \mathbf { x } _ { 1 } , \mathbf { x } _ { 2 } , \ldots , \mathbf { x } _ { T } ]$ denote a time series of length $T$ , where $\mathbf { x } _ { t } \in \mathbb { R } ^ { D }$ . Through successive conditioning, the density of the time series can be written as:
|
| 66 |
+
|
| 67 |
+
$$
|
| 68 |
+
p ( \mathbf { X } ) = p ( \mathbf { x } _ { 1 } ) p ( \mathbf { x } _ { 2 } | \mathbf { x } _ { < 2 } ) \cdot \cdot \cdot p ( \mathbf { x } _ { T } | \mathbf { x } _ { < T } ) ,
|
| 69 |
+
$$
|
| 70 |
+
|
| 71 |
+
where $\mathbf { x } _ { < t }$ denotes all variables before time $t$ . When the conditional probabilities are parameterized, Rasul et al. (2021) propose to model each $p ( \mathbf { x } _ { t } | \mathbf { x } _ { < t } )$ as $p ( \mathbf x _ { t } | \mathbf h _ { t - 1 } )$ , where $\mathbf { h } _ { t - 1 }$ summarizes the
|
| 72 |
+
|
| 73 |
+
past information $\mathbf { x } _ { < t }$ . For example, $\mathbf { h } _ { t - 1 }$ is the hidden state of a recurrent neural network before accepting input $\mathbf { x } _ { t }$ . Then, a conditional normalizing flow can be applied to evaluate each $p ( \mathbf x _ { t } | \mathbf h _ { t - 1 } )$ .
|
| 74 |
+
|
| 75 |
+
# 3.2 BAYESIAN NETWORKS
|
| 76 |
+
|
| 77 |
+
Let $X ^ { i }$ denote a general random variable, either scalar valued, vector valued, or even matrix valued. A Bayesian network of $n$ variables $( X ^ { 1 } , \ldots , X ^ { n } )$ is a directed acyclic graph of the variables as nodes. Let A denote the weighted adjacency matrix of the graph, where $\mathbf { A } _ { i j } \neq 0$ if $X ^ { j }$ is the parent of $X ^ { i }$ . A Bayesian network describes the conditional independence among variables. Specifically, a node $X ^ { i }$ is conditionally independent of its non-descendents given its parents. In other words, the density of the joint distribution of $( X ^ { 1 } , \ldots , X ^ { n } )$ is
|
| 78 |
+
|
| 79 |
+
$$
|
| 80 |
+
p ( X ^ { 1 } , \ldots , X ^ { n } ) = \prod _ { i = 1 } ^ { n } p ( X ^ { i } | \operatorname { p a } ( X ^ { i } ) ) ,
|
| 81 |
+
$$
|
| 82 |
+
|
| 83 |
+
where $\operatorname { p a } ( X ^ { i } ) = \{ X ^ { j } : \mathbf { A } _ { i j } \neq 0 \}$ denotes the set of parents of $X ^ { i }$
|
| 84 |
+
|
| 85 |
+
# 4 PROBLEM STATEMENT
|
| 86 |
+
|
| 87 |
+
In this paper, we focus on unsupervised anomaly detection with multiple time series. The training set $\mathcal { D }$ consists of only unlabeled instances and we assume that the majority of them are not anomalies. Each instance $\mathcal { X } \in \mathcal { D }$ contains $n$ constituent series with $D$ attributes and of length $T$ ; i.e., $\mathcal { X } =$ $( \mathbf { X } ^ { 1 } , \mathbf { X } ^ { 2 } , \ldots , \mathbf { X } ^ { n } )$ where $\mathbf { X } ^ { i } \in \mathbb { R } ^ { T \times D }$ . We use a Bayesian network (DAG) to model the relational structure of the constituent series $\mathbf { X } ^ { i }$ and augment a normalizing flow to compute the density of $\mathcal { X }$ through a factorization in the form (5). Let $\bar { \mathbf { A } } \in \mathbb { R } ^ { n \times n }$ be the adjacency matrix of the DAG and let $\mathcal { F } : ( \mathcal { X } , \mathbf { A } ) \mathcal { Z }$ denote the augmented flow. Because anomaly points tend to have low densities, we propose to conduct unsupervised anomaly detection by evaluating the density of a multiple time series computed through the augmented flow. The problem is formulated as the following.
|
| 88 |
+
|
| 89 |
+
Problem 1. Given a training set $\mathcal { D } = \{ \mathcal { X } _ { i } \} _ { i = 1 } ^ { | \mathcal { D } | }$ of multiple time series, we aim to simultaneously learn the adjacency matrix A of the Bayesian Network that represents the conditional dependencies among the constituent series, as well as the correspondingly graph-augmented normalizing flow $\mathcal { F } : ( \mathcal { X } , \mathbf { A } ) \mathcal { Z }$ , which is used to estimate the density of an instance $\mathcal { X }$ . Here, $\mathcal { Z }$ is a random variable with $a$ “simple” distribution, such as the anisotropic Gaussian.
|
| 90 |
+
|
| 91 |
+
# 5 METHOD
|
| 92 |
+
|
| 93 |
+
In this section, we materialize the graph-augmented normalizing flow $\mathcal { F } : ( \mathcal { X } , \mathbf { A } ) \mathcal { Z }$ introduced in the problem statement and use it to compute the density of a multiple time series $\mathcal { X }$ . The central idea is factorization: we factorize $p ( \mathcal { X } )$ along the series dimension by using a Bayesian network and then factorize along the temporal dimension by using conditional normalizing flows. Then, we employ a novel graph-based dependency encoder to parameterize the conditional probabilities resulting from the factorization. The DAG used for factorization is a discrete object and is usually intractable to learn; however, the discrete structure is reflected in the dependency encoder through a graph adjacency matrix A that is differentiable. Moreover, the requirement that A must correspond to a DAG can be expressed as a differentiable equation. Hence, one can jointly optimize A and the flow components by using gradient based optimization. Once $\mathcal { F }$ is learned, the density $p ( \mathcal { X } )$ is straightforwardly evaluated for anomaly detection. An illustration of the framework GANF is shown in Figure 1.
|
| 94 |
+
|
| 95 |
+
# 5.1 FACTORIZATION
|
| 96 |
+
|
| 97 |
+
Figure 1 shows a toy example of a Bayesian network as a DAG. Based on (5), the density of a multiple time series $\mathbf { \dot { \mathcal { X } } } = ( \hat { \mathbf { X } } ^ { 1 } , \mathbf { X } ^ { 2 } , \dots , \mathbf { \bar { X } } ^ { n } )$ can be computed as the product of $p ( \mathbf { X } ^ { i } | \mathbf { \theta } \mathrm { p a } ( \mathbf { X } ^ { i } ) )$ for all nodes, where recall that $\operatorname { p a } ( \mathbf { X } ^ { i } )$ denotes the set of parents of $\mathbf { X } ^ { i }$ . Then, following Rasul et al. (2021), we further factorize each conditional density along the temporal dimension. Specifically, for a time step $t$ , $\mathbf { x } _ { t } ^ { i }$ depends on its past history as well as its parents in the DAG. We write
|
| 98 |
+
|
| 99 |
+
$$
|
| 100 |
+
p ( \mathcal { X } ) = \prod _ { i = 1 } ^ { n } p ( \mathbf { X } ^ { i } | \mathbf { \ p a } ( \mathbf { X } ^ { i } ) ) = \prod _ { i = 1 } ^ { n } \prod _ { t = 1 } ^ { T } p ( \mathbf { x } _ { t } ^ { i } | \mathbf { \ p a } ( \mathbf { x } ^ { i } ) _ { 1 : t } , \mathbf { x } _ { 1 : t - 1 } ^ { i } ) ,
|
| 101 |
+
$$
|
| 102 |
+
|
| 103 |
+

|
| 104 |
+
Figure 1: Illustration of a Bayesian network and the proposed framework GANF.
|
| 105 |
+
|
| 106 |
+
where $\mathbf { x } _ { 1 : t - 1 } ^ { i }$ denotes the history of node $i$ before time $t$ , and $\mathrm { p a } ( \mathbf { x } ^ { i } ) _ { 1 : t } = \{ \mathbf { x } _ { 1 : t } ^ { j } : \mathbf { A } _ { i j } \neq 0 \}$ . In the next subsection, we will parameterize each conditional density $p ( \mathbf { x } _ { t } ^ { i } \mid \mathrm { p a } ( \mathbf { x } ^ { i } ) _ { 1 : t } , \mathbf { x } _ { 1 : t - 1 } ^ { i } )$ by using a graph-based dependency encoder. Note that so far the factorization (6) has been based on the discrete structure of the Bayesian network. The dependency encoder we introduce next, however, uses the adjacency matrix A in a differentiable manner, which is sufficient to ensure that $\mathbf { x } _ { t } ^ { i }$ will not depend on nodes other than its parents and itself.
|
| 107 |
+
|
| 108 |
+
# 5.2 NEURAL NETWORK PARAMETERIZATION
|
| 109 |
+
|
| 110 |
+
According to Sec. 3.1, conditional densities $p ( \mathbf { x } _ { t } ^ { i } \mid \mathrm { p a } ( \mathbf { x } ^ { i } ) _ { 1 : t } , \mathbf { x } _ { 1 : t - 1 } ^ { i } )$ can be learned by using conditional normalizing flows. However, the conditional information $\mathrm { p a } ( \mathbf { x } ^ { i } ) _ { 1 : t }$ and $\mathbf { x } _ { 1 : t - 1 } ^ { i }$ cannot be directly used for parameterization, because its size is not fixed. Therefore, as is illustrated in Figure 1, we design a graph-based dependency encoder to summarize the conditional information into a fixed length vector $\bar { \mathbf { d } } _ { t } ^ { i } \in \mathbb { R } ^ { d }$ . Then, a conditional normalizing flow is used to evaluate $p ( \mathbf { x } _ { t } ^ { i } | \mathbf { d } _ { t } ^ { i } )$ , which is equivalent to $\breve { p } ( \mathbf { x } _ { t } ^ { i } | \mathrm { \ p a } ( \mathbf { x } ^ { i } ) _ { 1 : t } , \mathbf { x } _ { 1 : t - 1 } ^ { i } )$ .
|
| 111 |
+
|
| 112 |
+
Dependency Encoder. Since the history has an arbitrary length, we first employ a recurrent neural network (RNN) to map multiple time steps to a vector of fixed length. For a time series $\mathbf { x } _ { 1 : t } ^ { i }$ , the recurrent model abstracts it into a hidden state $\mathbf { h } _ { t } ^ { i } \in \mathbb { R } ^ { d }$ through the following recurrence
|
| 113 |
+
|
| 114 |
+
$$
|
| 115 |
+
\mathbf h _ { t } ^ { i } = \mathbf { R N N } ( \mathbf x _ { t } ^ { i } , \mathbf h _ { t - 1 } ^ { i } ) ,
|
| 116 |
+
$$
|
| 117 |
+
|
| 118 |
+
where $\mathbf { h } _ { t } ^ { i }$ summarizes the time series up to step $t$ . The RNN can be any sequential model, such as the LSTM (Hochreiter & Schmidhuber, 1997) and in a broad sense a transformer (Vaswani et al., 2017). We let the RNN parameters be shared across all nodes in the DAG to avoid overfitting and to reduce computational costs.
|
| 119 |
+
|
| 120 |
+
With (7), the conditional information of $\mathbf { x } _ { t } ^ { i }$ is all summarized in $\{ \mathbf { h } _ { t } ^ { j } : \mathbf { A } _ { i j } \neq 0 \} \cup \{ \mathbf { h } _ { t - 1 } ^ { i } \}$ . Inspired by the success of GCN (Kipf & Welling, 2016) in node representation learning through neighborhood aggregation, we design a graph convolution layer to aggregate hidden states of the parents for dependency encoding. This layer produces dependency representations $\mathbf { D } _ { t } = ( \mathbf { d } _ { t } ^ { 1 } , \dots , \mathbf { \bar { d } } _ { t } ^ { n } )$ for all constituent series at time $t$ :
|
| 121 |
+
|
| 122 |
+
$$
|
| 123 |
+
\mathbf { D } _ { t } = \operatorname { R e L U } ( \mathbf { A } \mathbf { H } _ { t } \mathbf { W } _ { 1 } + \mathbf { H } _ { t - 1 } \mathbf { W } _ { 2 } ) \cdot \mathbf { W } _ { 3 } ,
|
| 124 |
+
$$
|
| 125 |
+
|
| 126 |
+
where $\mathbf { H } _ { t } \ = \ ( \mathbf { h } _ { t } ^ { 1 } , \ldots , \mathbf { h } _ { t } ^ { n } )$ contains all the hidden states at time $t$ . Here, $\mathbf { W } _ { 1 } ~ \in ~ \mathbb { R } ^ { d \times d }$ and $\mathbf { W } _ { 2 } ~ \in ~ \mathbb { R } ^ { d \times d }$ are parameters to transform the aggregated representations of the parents and the node’s historical information, respectively; while $\mathbf { \check { W } } _ { 3 } ^ { - } \in \mathbb { R } ^ { d \times d }$ is an additional transformation to improve the dependency representation.
|
| 127 |
+
|
| 128 |
+
Density Estimation. With the dependency encoder, we obtain the representations ${ \bf d } _ { t } ^ { i }$ of the conditional information. Then, a normalizing flow $\mathbf { f } : \mathbb { R } ^ { D } \times \mathbb { R } ^ { d } \to \mathbb { R } ^ { D }$ conditioned on ${ \bf d } _ { t } ^ { i }$ is applied to model each $p ( \mathbf { x } _ { t } ^ { i } | \mathrm { \ p a } ( \mathbf { x } ^ { i } ) _ { 1 : t } , \mathbf { x } _ { 1 : t - 1 } ^ { i } )$ . Similar to the computation of the hidden states, the parameters of the conditional flow are also shared among nodes, to avoid overfitting. Based on (3), the conditional density of $\mathbf { x } _ { t } ^ { i }$ can be written as:
|
| 129 |
+
|
| 130 |
+
$$
|
| 131 |
+
\log p ( \mathbf { x } _ { t } ^ { i } \mid \operatorname { p a } ( \mathbf { x } ^ { i } ) _ { 1 : t } , \mathbf { x } _ { 1 : t - 1 } ^ { i } ) = \log p ( \mathbf { x } _ { t } ^ { i } \mid \mathbf { d } _ { t } ^ { i } ) = \log q ( \mathbf { f } ( \mathbf { x } _ { t } ^ { i } ; \mathbf { d } _ { t } ^ { i } ) ) + \log \mid \operatorname* { d e t } \nabla _ { \mathbf { x } _ { t } ^ { i } } \mathbf { f } ( \mathbf { x } _ { t } ^ { i } ; \mathbf { d } _ { t } ^ { i } ) \mid ,
|
| 132 |
+
$$
|
| 133 |
+
|
| 134 |
+
where $q ( \mathbf { z } )$ is chosen to be the standard normal $\mathcal { N } ( \mathbf { z } | \mathbf { 0 } , \mathbf { I } )$ with $\textbf { z } \in \mathbb { R } ^ { D }$ . The conditional flow f can be any effective one proposed by the literature, such as RealNVP (Dinh et al., 2016) and
|
| 135 |
+
|
| 136 |
+
MAF (Papamakarios et al., 2017). Combining (9) and (6), we obtain the log-density of a multiple time series $\mathcal { X }$ :
|
| 137 |
+
|
| 138 |
+
$$
|
| 139 |
+
\log p ( \mathcal { X } ) = \sum _ { i = 1 } ^ { n } \sum _ { t = 1 } ^ { T } \Big [ \log q ( \mathbf { f } ( \mathbf { x } _ { t } ^ { i } ; \mathbf { d } _ { t } ^ { i } ) ) + \log | \operatorname* { d e t } \nabla _ { \mathbf { x } _ { t } ^ { i } } \mathbf { f } ( \mathbf { x } _ { t } ^ { i } ; \mathbf { d } _ { t } ^ { i } ) | \Big ] .
|
| 140 |
+
$$
|
| 141 |
+
|
| 142 |
+
Anomaly Measure. Because anomalies deviate significantly from the majority of the data instances, we hypothesize that their densities are low. Thus, we use the density computed by (10) as the anomaly measure, where a lower density indicates a more likely anomaly. Apart from evaluating the density for the entire $\mathcal { X }$ , the computation also produces conditional densities $\log p ( \mathbf { X } ^ { i } | \operatorname { p a } ( \mathbf { X } ^ { i } ) ) =$ $\begin{array} { r } { \sum _ { t = 1 } ^ { T } \log p ( \mathbf { x } _ { t } ^ { i } | \mathbf { d } _ { t } ^ { i } ) } \end{array}$ for each constituent series $\mathbf { X } ^ { i }$ . We use this conditional density as the anomaly measure for constituent series. A low density $p ( \mathcal { X } )$ is caused by one or a few low conditional densities $p ( \mathbf { X } ^ { i } | \operatorname { p a } ( \mathbf { X } ^ { i } ) )$ in the Bayesian network, suggesting that abnormal behaviors could be traced to individual series.
|
| 143 |
+
|
| 144 |
+
# 5.3 JOINT TRAINING
|
| 145 |
+
|
| 146 |
+
Learning a Bayesian network is a challenging combinatorial problem, due to the intractable search space superexponential in the number of nodes. A recent work by Zheng et al. (2018) proposes the equation $\operatorname { t r } ( e ^ { \mathbf { A } \circ \mathbf { A } } ) = n$ that characterizes the acyclicity of the corresponding graph of A, where $e$ is matrix exponential and $\circ$ denotes element-wise multiplication. We will impose this equation as a constraint in the training of GANF.
|
| 147 |
+
|
| 148 |
+
Training Objective. Following the training of a usual normalizing flow, the joint density (likelihood) of the observed data is the training objective, which is equivalent to the Kullback–Leibler divergence between the true distribution of data and the flow recovered distribution. Together with the DAG constraint, the optimization problem reads
|
| 149 |
+
|
| 150 |
+
$$
|
| 151 |
+
\operatorname* { m i n } _ { \mathbf { A } , \theta } \mathcal { L } ( \mathbf { A } , \theta ) = \frac { 1 } { | \mathcal { D } | } \sum _ { i = 1 } ^ { | \mathcal { D } | } - \log p ( \mathcal { X } _ { i } ) ,
|
| 152 |
+
$$
|
| 153 |
+
|
| 154 |
+
where $\pmb \theta$ contains all neural network parameters, including those of the dependency encoder and the normalizing flow. Here, the DAG constraint $h ( \mathbf { A } )$ admits an easy-to-evaluate gradient $\nabla h ( { \mathbf A } ) =$ $( e ^ { \mathbf { A } \circ \mathbf { A } } ) ^ { T } \circ \mathsf { 2 } \mathbf { A }$ , which allows a gradient based optimizer to solve (11).
|
| 155 |
+
|
| 156 |
+
Training Algorithm. Problem (11) is a nonlinear equality-constrained optimization. Such problems are extensively studied and the augmented Lagrangian method (Bertsekas, 1999; Yu et al., 2019) is one of the most widely used approaches. The augmented Lagrangian is defined as
|
| 157 |
+
|
| 158 |
+
$$
|
| 159 |
+
\mathcal { L } _ { c } = \mathcal { L } ( { \bf A } , \pmb \theta ) + \lambda h ( { \bf A } ) + \frac { c } { 2 } | h ( { \bf A } ) | ^ { 2 } ,
|
| 160 |
+
$$
|
| 161 |
+
|
| 162 |
+
where $\lambda$ and $c$ denote the Lagrange multiplier and the penalty parameter, respectively. The general idea of the method is to gradually increase the penalty parameter to ensure that the constraint is eventually satisfied. Over iterations, $\lambda$ as a dual variable will converge to the Lagrangian multiplier of (11). The update rule at the $k$ th iteration reads the following:
|
| 163 |
+
|
| 164 |
+
$$
|
| 165 |
+
\mathbf { A } ^ { k } , \theta ^ { k } = \arg \operatorname* { m i n } _ { \mathbf { A } , \theta } \mathcal { L } _ { c ^ { k } } ; \quad \lambda ^ { k + 1 } = \lambda ^ { k } + c ^ { k } h ( \mathbf { A } ^ { k } ) ; \quad c ^ { k + 1 } = \left\{ \begin{array} { l l } { \eta c ^ { k } } & { \mathrm { i f } \left| h ( \mathbf { A } ^ { k } ) \right| > \gamma \left| h ( \mathbf { A } ^ { k - 1 } ) \right| ; } \\ { c ^ { k } } & { \mathrm { e l s e } , } \end{array} \right.
|
| 166 |
+
$$
|
| 167 |
+
|
| 168 |
+
where $\eta \in \left( 1 , + \infty \right)$ and $\gamma \in \mathsf { \Gamma } ( 0 , 1 )$ are hyperparameters to be tuned. We set $\eta$ and $\gamma$ as 10 and 0.5, respectively. The subproblem of optimizing A and $\pmb { \theta }$ can be solved by using the Adam optimizer (Kingma & Ba, 2014). The training algorithm is summarized in Appendix A.
|
| 169 |
+
|
| 170 |
+
# 6 EXPERIMENTS
|
| 171 |
+
|
| 172 |
+
In this section, we conduct a comprehensive set of experiments to validate the effectiveness of the proposed GANF framework. In particular, they are designed to answer the following questions:
|
| 173 |
+
|
| 174 |
+
• Q1: Can GANF accurately detect anomalies and estimate densities?
|
| 175 |
+
• Q2: Does the proposed graph structure learning help? Is the framework sufficiently flexible to include various normalizing flow backbones?
|
| 176 |
+
• Q3: What can one observe for a dataset spanning a long time? E.g., does the graph pattern change?
|
| 177 |
+
|
| 178 |
+
# 6.1 SETTINGS
|
| 179 |
+
|
| 180 |
+
Datasets. To evaluate the effectiveness of GANF for anomaly detection and density estimation, we conduct experiments on two power grid datasets, one water system dataset, and one traffic dataset.
|
| 181 |
+
|
| 182 |
+
• PMU-B and PMU-C: These two datasets correspond to two separate interconnects of the U.S. power grid, containing time series recorded by 38 and 132 phasor measurement units (PMUs), respectively. We process one-year data at the frequency of one second to form a ten-month training set, one-month validation set, and one-month test set. Each multiple time series is obtained by shifting a one-minute window. Additionally, to investigate distribution drift, we shift a one-month window to obtain multiple training/validation/test sets (12 in total, because of availability of twoyear data). Sparse grid events (anomalies) labeled by domain experts exist for evaluation; but note that the labels are both noisy and incomplete. These datasets are proprietary.
|
| 183 |
+
|
| 184 |
+
• SWaT: We also use a public dataset for evaluation. The Secure Water Treatment (SWaT) dataset originates from an operational water treatment test-bed coordinated with Singapore’s Public Utility Board (Goh et al., 2016). The data collects 51 sensor recordings lasting four days, at the frequency of one second. A total of 36 attacks were conducted, resulting in approximately $11 \%$ time steps as anomaly ground truths. We use a sliding window of 60 seconds to construct series data and perform a 60/20/20 chronological split for training, validation, and testing, respectively.
|
| 185 |
+
|
| 186 |
+
• METR-LA: This dataset is also public; it contains speed records of 207 sensors deployed on the highways of Los Angles, CA (Li et al., 2018b). No anomaly labels exist however and we use this dataset for exploratory analysis only. Results are deferred to Appendix E.
|
| 187 |
+
|
| 188 |
+
Evaluation metrics (under noisy labels). For SWaT, which offers reliable ground truths, we use the standard ROC and AUC metrics for evaluation. For the two PMU datasets, however, the resolution of the time series and the granularity of the events result in rather noisy ground truths. Hence, we adapt ROC for noisy labels. We smooth the time point of a “ground truth” event (anomaly) by introducing probabilities to the label. Specifically, the probability that a multiple time series starting at time t is a ground truth anomaly is maxi{exp(− (t−ti)2σ2 ) , where $t _ { i }$ is the starting time of the ith labeled anomaly. Then, when computing the confusion matrix, we sum probabilities rather than counting 0/1s. The smoothing window $\sigma$ is chosen to be 6 time steps.
|
| 189 |
+
|
| 190 |
+
Baselines. We compare with the following representative, state-of-the-art deep methods.
|
| 191 |
+
|
| 192 |
+
• EncDecAD (Malhotra et al., 2016): In this method, an autoencoder based on LSTM is trained. The reconstruction error is used as the anomaly measure.
|
| 193 |
+
• DeepSVDD (Ruff et al., 2018): This method minimizes the volume of a hypersphere that encloses the representations of data. Samples distant from the hypersphere center are considered anomalies.
|
| 194 |
+
• ALOCC (Sabokrou et al., 2020): In this GAN-based method, the generator learns to reconstruct normal instances, while the discriminator works as an anomaly detector.
|
| 195 |
+
• DROCC (Goyal et al., 2020): This method performs adversarial training to learn robust representations of data and identifies anomalies.
|
| 196 |
+
• DeepSAD (Ruff et al., 2020): This method extends DeepSVDD with a semi-supervised loss term for training. We use noisy labels as supervision.
|
| 197 |
+
|
| 198 |
+
To apply these baselines on multiple time series, we concatenate the constituent series along the attribute dimension (resulting in high-dimensional series) and use LSTM or CNN as the backbones. On the other hand, for the proposed method, we use LSTM as the RNN model and MAF as the normalizing flow. See Appendix C for more implementation details.
|
| 199 |
+
|
| 200 |
+
# 6.2 PERFORMANCE OF ANOMALY DETECTION AND DENSITY ESTIMATION
|
| 201 |
+
|
| 202 |
+
Table 1: AUC-ROC $( \% )$ of anomaly detection.
|
| 203 |
+
|
| 204 |
+
<table><tr><td>Dataset</td><td>EncDecAD</td><td>DeepSVDD</td><td>ALOCC</td><td>DROCC</td><td>DeepSAD</td><td>GANF</td></tr><tr><td>PMU-B</td><td>55.6±1.8</td><td>55.6±3.3</td><td>62.9±2.2</td><td>58.6±3.0</td><td>63.7±0.9</td><td>67.5±0.8</td></tr><tr><td>PMU-C</td><td>53.7±0.5</td><td>56.9±0.9</td><td>60.9±1.3</td><td>61.9±2.7</td><td>60.1±1.4</td><td>70.6±3.3</td></tr><tr><td>SWaT</td><td>76.5±0.7</td><td>68.8±2.0</td><td>75.4±2.3</td><td>73.3±1.6</td><td>75.4±1.2</td><td>79.6±0.9</td></tr></table>
|
| 205 |
+
|
| 206 |
+

|
| 207 |
+
Figure 2: ROC curves of anomaly detection on various datasets.
|
| 208 |
+
|
| 209 |
+

|
| 210 |
+
Figure 3: Qualitative evaluation of GANF on PMU-C. (a) Distribution of log-densities on the test set (note in log scale). (b) Anomaly detection results for a week in the test set.
|
| 211 |
+
|
| 212 |
+
To answer Q1, we evaluate quantitatively and qualitatively on datasets with labels.
|
| 213 |
+
|
| 214 |
+
Anomaly detection. We compare GANF with the aforementioned baselines in Table 1, where standard deviations of the AUC scores are additionally reported through five random repetitions of model training. The table suggests an overwhelmingly high AUC score achieved by GANF. Observations follow. (i) GANF outperforms generative model-based methods (EncDecAD and ALOCC). Being a generative model as well, normalizing flows augmented with a graph structure leverage the interdependencies of constituent series more effectively, leading to a substantial improvement in detection. (ii) GANF significantly outperforms deep one-class models (DeepSVDD and DROCC), corroborating the appeal of using densities for detection. (iii) GANF also performs better than the semi-supervised method DeepSAD, probably because such methods rely on high quality labels for supervision (especially in the case of label scarcity) and they are less effective facing noisy labels.
|
| 215 |
+
|
| 216 |
+
Besides a single score, we also plot the ROC curve in Figure 2. One sees that the curve of GANF dominates those of others. This behavior is generally more salient in the low false-alarm regime.
|
| 217 |
+
|
| 218 |
+
Density estimation. We investigate the densities estimated by GANF, shown in Figure 3. Distributions of the log-densities in the test set are shown in Figure 3a. We use log-density as the anomaly measure; the lower the more likely. Note that the vertical axis is in the log-scale. One sees that a log-density of 16 approximately separates the majority normal instances from the minority anomalies. To cross-verify that the instances with low densities are suspiciously anomalous, we investigate Figure 3b, which is a temporal plot of log-densities for a week, overlaid with given labels. From this plot, one sees that the noisily labeled series generally have low densities or are near a low density time step. Additionally, GANF discovers a few suspicious time steps with low densities undetected earlier. These new discoveries raise interest to power system experts for analysis and archiving.
|
| 219 |
+
|
| 220 |
+
# 6.3 ABLATION STUDY
|
| 221 |
+
|
| 222 |
+
Table 2: Performance of variants of the proposed method.
|
| 223 |
+
|
| 224 |
+
<table><tr><td>Dataset</td><td>Metrics</td><td>GANF\G</td><td>GANF\D</td><td>GANF\T</td><td>GANFRNVP</td><td>GANF</td></tr><tr><td>PMU-B</td><td>AUC-ROC</td><td>0.641</td><td>0.643</td><td>0.653</td><td>0.661</td><td>0.678</td></tr><tr><td></td><td>Log-Density</td><td>15.31</td><td>8.70</td><td>15.09</td><td>15.90</td><td>16.22</td></tr><tr><td>PMU-C</td><td>AUC-ROC</td><td>0.630</td><td>0.544</td><td>0.688</td><td>0.703</td><td>0.705</td></tr><tr><td></td><td>Log-Density</td><td>15.55</td><td>8.94</td><td>15.70</td><td>17.06</td><td>16.98</td></tr></table>
|
| 225 |
+
|
| 226 |
+

|
| 227 |
+
Figure 4: Evolution of the learned DAG on PMU-B over time.
|
| 228 |
+
|
| 229 |
+

|
| 230 |
+
Figure 5: Evolution of edge weights in the DAG learned by GANF over time (PMU-B).
|
| 231 |
+
|
| 232 |
+
To answer Q2, we conduct an ablation study (including varying architecture components) to investigate impacts of DAG structure learning and the flexibility of the GANF framework. To investigate the power of modeling pairwise relationship, we train a variant GANF\G that factorizes $\begin{array} { r } { p ( \mathcal { X } ) = \prod _ { i = 1 } ^ { n ^ { * } } p ( \mathbf { X } ^ { i } ) } \end{array}$ ; i.e., assuming independence among constituent series. To investigate the effectiveness of graph structure learning, we train a variant GANF\D that decomposes the joint density as $\begin{array} { r } { p ( \mathbf { \mathcal { X } } ) \mathbf { \bar { \Phi } } = \prod _ { i = 1 } ^ { n } p ( \mathbf { X } ^ { i } | \mathbf { X } ^ { < i } ) } \end{array}$ ; i.e., a full decomposition without a DAG. It is equivalent to concatenating the series along the attribute dimension and running MAF on the resulting series. To verify the contribution of joint training of $\mathbf { A }$ and $\pmb { \theta }$ , we train a variant GANF\T where A is separately learned by using NOTEARS (Zheng et al., 2018). To prove the flexibility of GANF, we replace the MAF-based normalizing flow by RealNVP, denoted as GANFRNVP.
|
| 233 |
+
|
| 234 |
+
Results are presented in Table 2. Apart from AUC-ROC, the log-density is also reported. Observations follow. (i) GANF significantly outperforms GANF\G and GANF\D, corroborating the importance of interdependency modeling among constituent series. Note that GANF\D results in particularly poor performance in general, likely because the high dimensional input (resulting from concatenating too many series) impedes the learning of normalizing flows. (iii) GANF\T is slightly better than GANF\G, because of the presence of relational modeling, but it cannot match the performance of GANFRNVP and GANF that jointly train the DAG and the flow. (ii) These latter two models are the best for both datasets and both metrics. MAF works more often better than RealNVP.
|
| 235 |
+
|
| 236 |
+
# 6.4 EVOLUTION OF THE DAG STRUCTURE
|
| 237 |
+
|
| 238 |
+
To answer Q3, we investigate how the learned DAG evolves by shifting the train/validation/test sets month by month. The graphs within the first three-month shiftings are shown in Figure 4 and more can be found in Appendix F. In addition to the graph structure, we plot in Figure 5 the learned edge weights over time, one column per edge. The appearance and disappearance of edges demonstrate changes of the conditional independence structure among constituent series over time, suggesting data distribution drift (i.e., a change of internal data generation mechanism). It is interesting to observe the seasonal effect. The columns (edges) in Figure 5 can be loosely grouped in three clusters: those persisting the entire year, those appearing in the first half of the year, and those existing more briefly (e.g., within a season). Such a pattern plausibly correlates with electricity consumption, which is also seasonal. Were spatial information of the PMUs known, these identified DAGs would help mapping the seasonal patterns to geography and help planning a more resilient grid.
|
| 239 |
+
|
| 240 |
+
# 7 CONCLUSIONS
|
| 241 |
+
|
| 242 |
+
In this paper, we present a graph-augmented normalizing flow GANF for anomaly detection of multiple time series. The graph is materialized as a Bayesian network, which models the conditional dependencies among constituent time series. A graph-based dependency decoder is designed to summarize the conditional information needed by the normalizing flow that calculates series density. Anomalies are detected through identifying instances with low density. Extensive experiments on real-world datasets demonstrate the effectiveness of the framework. Ablation studies confirm the contribution of the learned graph structure in anomaly detection. Additionally, we investigate the evolution of the graph and offer insights of distribution drift over time.
|
| 243 |
+
|
| 244 |
+
# ACKNOWLEDGMENT AND DISCLAIMER
|
| 245 |
+
|
| 246 |
+
This material is based upon work supported by the Department of Energy under Award Number(s) DE-OE0000910. This report was prepared as an account of work sponsored by an agency of the United States Government. Neither the United States Government nor any agency thereof, nor any of their employees, makes any warranty, express or implied, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness of any information, apparatus, product, or process disclosed, or represents that its use would not infringe privately owned rights. Reference herein to any specific commercial product, process, or service by trade name, trademark, manufacturer, or otherwise does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United States Government or any agency thereof. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or any agency thereof.
|
| 247 |
+
|
| 248 |
+
# REFERENCES
|
| 249 |
+
|
| 250 |
+
Terje Aven. Risk assessment and risk management: Review of recent advances on their foundation. European Journal of Operational Research, 253(1):1–13, 2016.
|
| 251 |
+
|
| 252 |
+
Dimitri P. Bertsekas. Nonlinear Programming. Athena Scientific, 2nd edition, 1999.
|
| 253 |
+
|
| 254 |
+
Ailin Deng and Bryan Hooi. Graph neural network-based anomaly detection in multivariate time series. In AAAI, 2021.
|
| 255 |
+
|
| 256 |
+
Laurent Dinh, Jascha Sohl-Dickstein, and Samy Bengio. Density estimation using real nvp. arXiv preprint arXiv:1605.08803, 2016.
|
| 257 |
+
|
| 258 |
+
Jonathan Goh, Sridhar Adepu, Khurum Nazir Junejo, and Aditya Mathur. A dataset to support research in the design of secure water treatment systems. In International conference on critical information infrastructures security, pp. 88–99. Springer, 2016.
|
| 259 |
+
|
| 260 |
+
Izhak Golan and Ran El-Yaniv. Deep anomaly detection using geometric transformations. arXiv preprint arXiv:1805.10917, 2018.
|
| 261 |
+
|
| 262 |
+
Sachin Goyal, Aditi Raghunathan, Moksh Jain, Harsha Vardhan Simhadri, and Prateek Jain. Drocc: Deep robust one-class classification. In International Conference on Machine Learning, pp. 3711–3721. PMLR, 2020.
|
| 263 |
+
|
| 264 |
+
Kathrin Grosse, Praveen Manoharan, Nicolas Papernot, Michael Backes, and Patrick McDaniel. On the (statistical) detection of adversarial examples. arXiv preprint arXiv:1702.06280, 2017.
|
| 265 |
+
|
| 266 |
+
Dan Hendrycks, Mantas Mazeika, Saurav Kadavath, and Dawn Song. Using self-supervised learning can improve model robustness and uncertainty. arXiv preprint arXiv:1906.12340, 2019.
|
| 267 |
+
|
| 268 |
+
Sepp Hochreiter and Jurgen Schmidhuber. Long short-term memory. ¨ Neural computation, 9(8): 1735–1780, 1997.
|
| 269 |
+
|
| 270 |
+
Emiel Hoogeboom, Rianne Van Den Berg, and Max Welling. Emerging convolutions for generative normalizing flows. In International Conference on Machine Learning, pp. 2771–2780. PMLR, 2019.
|
| 271 |
+
|
| 272 |
+
Radu Tudor Ionescu, Fahad Shahbaz Khan, Mariana-Iuliana Georgescu, and Ling Shao. Objectcentric auto-encoders and dummy anomalies for abnormal event detection in video. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 7842–7851, 2019.
|
| 273 |
+
|
| 274 |
+
JooSeuk Kim and Clayton D Scott. Robust kernel density estimation. The Journal of Machine Learning Research, 13(1):2529–2565, 2012.
|
| 275 |
+
|
| 276 |
+
Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
|
| 277 |
+
|
| 278 |
+
Diederik P Kingma and Prafulla Dhariwal. Glow: Generative flow with invertible 1x1 convolutions. arXiv preprint arXiv:1807.03039, 2018.
|
| 279 |
+
|
| 280 |
+
Thomas Kipf, Ethan Fetaya, Kuan-Chieh Wang, Max Welling, and Richard Zemel. Neural relational inference for interacting systems. In ICML, 2018.
|
| 281 |
+
|
| 282 |
+
Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. arXiv preprint arXiv:1609.02907, 2016.
|
| 283 |
+
|
| 284 |
+
B Ravi Kiran, Dilip Mathew Thomas, and Ranjith Parakkal. An overview of deep learning based methods for unsupervised and semi-supervised anomaly detection in videos. Journal of Imaging, 4(2):36, 2018.
|
| 285 |
+
|
| 286 |
+
Dan Li, Dacheng Chen, Jonathan Goh, and See-kiong Ng. Anomaly detection with generative adversarial networks for multivariate time series. arXiv preprint arXiv:1809.04758, 2018a.
|
| 287 |
+
|
| 288 |
+
Yaguang Li, Rose Yu, Cyrus Shahabi, and Yan Liu. Diffusion convolutional recurrent neural network: Data-driven traffic forecasting. In ICLR, 2018b.
|
| 289 |
+
|
| 290 |
+
Jenny Liu, Aviral Kumar, Jimmy Ba, Jamie Kiros, and Kevin Swersky. Graph normalizing flows. arXiv preprint arXiv:1905.13177, 2019.
|
| 291 |
+
|
| 292 |
+
Pankaj Malhotra, Anusha Ramakrishnan, Gaurangi Anand, Lovekesh Vig, Puneet Agarwal, and Gautam Shroff. Lstm-based encoder-decoder for multi-sensor anomaly detection. arXiv preprint arXiv:1607.00148, 2016.
|
| 293 |
+
|
| 294 |
+
Duc Tam Nguyen, Zhongyu Lou, Michael Klar, and Thomas Brox. Anomaly detection with multiple-hypotheses predictions. In International Conference on Machine Learning, pp. 4800– 4809. PMLR, 2019.
|
| 295 |
+
|
| 296 |
+
George Papamakarios, Theo Pavlakou, and Iain Murray. Masked autoregressive flow for density estimation. arXiv preprint arXiv:1705.07057, 2017.
|
| 297 |
+
|
| 298 |
+
Emanuel Parzen. On estimation of a probability density function and mode. The annals of mathematical statistics, 33(3):1065–1076, 1962.
|
| 299 |
+
|
| 300 |
+
Judea Pearl. Bayesian networks: A model of self-activated memory for evidential reasoning. In Proceedings of the 7th Conference of the Cognitive Science Society, 1985.
|
| 301 |
+
|
| 302 |
+
Judea Pearl. Causality: Models, Reasoning, and Inference. Cambridge University Press, 2000.
|
| 303 |
+
|
| 304 |
+
Marco AF Pimentel, David A Clifton, Lei Clifton, and Lionel Tarassenko. A review of novelty detection. Signal Processing, 99:215–249, 2014.
|
| 305 |
+
|
| 306 |
+
Kashif Rasul, Abdul-Saboor Sheikh, Ingmar Schuster, Urs Bergmann, and Roland Vollgraf. Multivariate probabilistic time series forecasting via conditioned normalizing flows. In ICLR, 2021.
|
| 307 |
+
|
| 308 |
+
Riya Roy and K Thomas George. Detecting insurance claims fraud using machine learning techniques. In 2017 International Conference on Circuit, Power and Computing Technologies (ICCPCT), pp. 1–6. IEEE, 2017.
|
| 309 |
+
|
| 310 |
+
Lukas Ruff, Robert Vandermeulen, Nico Goernitz, Lucas Deecke, Shoaib Ahmed Siddiqui, Alexander Binder, Emmanuel Muller, and Marius Kloft. Deep one-class classification. In¨ International conference on machine learning, pp. 4393–4402. PMLR, 2018.
|
| 311 |
+
|
| 312 |
+
Lukas Ruff, Robert A. Vandermeulen, Nico Gornitz, Alexander Binder, Emmanuel M ¨ uller, Klaus- ¨ Robert Muller, and Marius Kloft. Deep semi-supervised anomaly detection. In ¨ International Conference on Learning Representations, 2020. URL https://openreview.net/forum? id $=$ HkgH0TEYwH.
|
| 313 |
+
|
| 314 |
+
Mohammad Sabokrou, Mohammad Khalooei, Mahmood Fathy, and Ehsan Adeli. Adversarially learned one-class classifier for novelty detection. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 3379–3388, 2018.
|
| 315 |
+
|
| 316 |
+
Mohammad Sabokrou, Mahmood Fathy, Guoying Zhao, and Ehsan Adeli. Deep end-to-end oneclass classifier. IEEE transactions on neural networks and learning systems, 32(2):675–684, 2020.
|
| 317 |
+
|
| 318 |
+
Bernhard Scholkopf, 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.
|
| 319 |
+
|
| 320 |
+
Youngjoo Seo, Michael Defferrard, Pierre Vandergheynst, and Xavier Bresson. Structured sequence ¨ modeling with graph convolutional recurrent networks. arXiv:1612.07659, 2016.
|
| 321 |
+
|
| 322 |
+
Chao Shang, Jie Chen, and Jinbo Bi. Discrete graph structure learning for forecasting multiple time series. In ICLR, 2021.
|
| 323 |
+
|
| 324 |
+
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.
|
| 325 |
+
|
| 326 |
+
Peng Wu, Jing Liu, and Fang Shen. A deep one-class neural network for anomalous event detection in complex scenes. IEEE transactions on neural networks and learning systems, 31(7):2609– 2622, 2019.
|
| 327 |
+
|
| 328 |
+
Zonghan Wu, Shirui Pan, Guodong Long, Jing Jiang, Xiaojun Chang, and Chengqi Zhang. Connecting the dots: Multivariate time series forecasting with graph neural networks. In KDD, 2020.
|
| 329 |
+
|
| 330 |
+
Bing Yu, Haoteng Yin, and Zhanxing Zhu. Spatio-temporal graph convolutional networks: A deep learning framework for traffic forecasting. In IJCAI, 2018.
|
| 331 |
+
|
| 332 |
+
Yue Yu, Jie Chen, Tian Gao, and Mo Yu. DAG-GNN: DAG structure learning with graph neural networks. In ICML, 2019.
|
| 333 |
+
|
| 334 |
+
Ling Zhao, Yujiao Song, Chao Zhang, Yu Liu, Pu Wang, Tao Lin, Min Deng, and Haifeng Li. T-GCN: A temporal graph convolutional network for traffic prediction. IEEE Transactions on Intelligent Transportation Systems, 2019.
|
| 335 |
+
|
| 336 |
+
Xun Zheng, Bryon Aragam, Pradeep Ravikumar, and Eric P. Xing. DAGs with NO TEARS: Continuous optimization for structure learning. In NeurIPS, 2018.
|
| 337 |
+
|
| 338 |
+
# A TRAINING ALGORITHM
|
| 339 |
+
|
| 340 |
+
We summarize the training method in Algorithm 1.
|
| 341 |
+
|
| 342 |
+
Algorithm 1 Training Algorithm of GANF
|
| 343 |
+
Input: Training set $\mathcal { D }$ , hyperparameters $\eta$ and $\gamma$
|
| 344 |
+
Output: GANF $\mathcal { F }$ and adjacency matrix A of the DAG
|
| 345 |
+
1: Initialize $c \gets 0$ and initialize $\lambda$ randomly
|
| 346 |
+
2: for $k = 0 , 1 , 2 , \ldots$ do
|
| 347 |
+
3: Compute $\mathbf { A } ^ { k }$ and $\pmb { \theta } ^ { k }$ as a minimizer of (12) by using the Adam optimizer, where the loss $\mathcal { L }$ and the constraint $h$ are defined in (11), the log-density $\log p ( \mathcal { X } )$ is defined in (10), the dependency representation ${ \bf d } _ { t } ^ { i }$ is defined in (8), the hidden state $\mathbf { h } _ { t } ^ { i }$ is defined in (7), and the conditional flow f is RealNVP or MAF
|
| 348 |
+
4: Update Lagrange multiplier $\lambda \gets \lambda + c h ( \mathbf { A } ^ { k } )$
|
| 349 |
+
5: if $k > 0$ and $| h ( { \bf A } ^ { k } ) | > \gamma | h ( { \bf A } ^ { k - 1 } ) |$ then
|
| 350 |
+
6: $c \eta c$
|
| 351 |
+
7: end if
|
| 352 |
+
8: if $h ( \mathbf { A } ^ { k } ) = = 0$ then
|
| 353 |
+
9: break
|
| 354 |
+
10: end if
|
| 355 |
+
11: end for
|
| 356 |
+
12: return A and $\mathcal { F }$ (including f , the neural network (8), and the RNN (7))
|
| 357 |
+
|
| 358 |
+
# B CODE
|
| 359 |
+
|
| 360 |
+
Code is available at https://github.com/EnyanDai/GANF.
|
| 361 |
+
|
| 362 |
+
C ADDITIONAL DETAILS OF EXPERIMENT SETTINGS
|
| 363 |
+
|
| 364 |
+
C.1 IMPLEMENTATION DETAILS OF GANF.
|
| 365 |
+
|
| 366 |
+
An LSTM is used as the RNN model in the dependency encoder. For normalizing flows, we use MAF with six flow blocks. All hidden dimensions as set as 32. The initial learning rate is set as 0.001 for the adjacency matrix A and the model parameters $\pmb \theta$ . Learning rate decay is 0.1. To avoid gradient explosion, we clip the gradients whose values are larger than 1.0.
|
| 367 |
+
|
| 368 |
+
For hyperparameter tuning, we select the hyperparameters that yield the highest log-density on the validation set. Specifically, we conduct grid search by varying the number of normalizing flow blocks from $\{ 1 , 2 , 4 , 6 , 8 \}$ , the learning rate from $\left. 0 . 0 0 3 , 0 . 0 0 1 , 0 . 0 0 0 3 , 0 . 0 0 0 1 \right.$ , and the hidden dimension from $\{ 1 6 , 3 2 , 6 4 , 1 2 8 \}$ .
|
| 369 |
+
|
| 370 |
+
C.2 IMPLEMENTATION DETAILS OF BASELINES.
|
| 371 |
+
|
| 372 |
+
• EncDecAD (Malhotra et al., 2016): This method is applied for anomaly detection on time series. Thus, we concatenate constituent series along the attribute dimension and adopt the code released by the authors in https://github.com/chickenbestlover/ RNN-Time-series-Anomaly-Detection.
|
| 373 |
+
• DeepSVDD (Ruff et al., 2018): To handle time series data, we replace the backbone to an LSTM based on the official implementation https://github.com/lukasruff/ Deep-SVDD-PyTorch.
|
| 374 |
+
• ALOCC (Sabokrou et al., 2020): We use the official implementation released by the authors in https://github.com/khalooei/ALOCC-CVPR2018. We replace the two-dimensional convolution to one-dimensional convolution to build a GAN for time series data.
|
| 375 |
+
• DROCC (Goyal et al., 2020): Similar to other baselines, this method is proposed for tabular data and image data. We replace the backbone to LSTM to deal with multiple time series by revising the encoder in https://github.com/microsoft/EdgeML/tree/master/pytorch.
|
| 376 |
+
• DeepSAD (Ruff et al., 2020): This is a semi-supervised approach, which requires labeling. We utilize the noisy labels in PMU-B and PMU-C as supervision. We use LSTM as the
|
| 377 |
+
|
| 378 |
+
backbone, based on the official implementation in https://github.com/lukasruff/ Deep-SAD-PyTorch.
|
| 379 |
+
|
| 380 |
+
All hyperparameters of the baselines are tuned based on the validation set to make fair comparisons.
|
| 381 |
+
|
| 382 |
+
# D TIME COMPLEXITY ANALYSIS
|
| 383 |
+
|
| 384 |
+
The GANF framework involves Bayesian network structure learning, which is known to be highly challenging, owing to the intractable search space superexponential in the number of graph nodes. In this work, we formulate a continuous optimization of the graph structure, so that the training of GANF is more scalable. In what follows, we analyze the time complexity.
|
| 385 |
+
|
| 386 |
+
Recall that each instance $\mathcal { X }$ of the multiple time series dataset contains $n$ constituent series with $D$ attributes and of length $T$ ; i.e., $\mathcal { X } = \left( \mathbf { \bar { X } } ^ { 1 } , \mathbf { X } ^ { 2 } , \ldots , \mathbf { X } ^ { n } \right)$ where $\mathbf { X } ^ { i } \in \mathbb { R } ^ { T \times D }$ . In the evaluation of the model, the dominant costs appear in running the dependency encoder and the normalizing flow. For the dependency encoder, an RNN is first deployed to map the multiple time series to hidden vectors; the time complexity is $O ( n T D )$ . Then, graph convolution is conducted to obtain dependency vectors; the convolution cost is $O ( n ^ { 2 } T )$ . For the normalizing flow module, the time complexity is $O ( n T D )$ . Therefore, the time complexity of computing log-density of one instance is $O ( n T ( D + n ) )$ . If we use a batch size $B$ for training, the time cost of calculating the augmented Lagrangian $\mathcal { L } ( \mathbf { A } , \pmb \theta )$ in (12) is $O ( n B T ( D + n ) )$ . Additionally, the time cost of calculating the constraint $\underline { { h } } ( \mathbf { A } )$ is ${ \dot { O } } ( n ^ { 3 } )$ . Thus, the overall time complexity of one training iteration is $O ( n ( B T D +$ $B T n + n ^ { 2 } )$ ).
|
| 387 |
+
|
| 388 |
+
# E RESULTS FOR METR-LA
|
| 389 |
+
|
| 390 |
+
METR-LA contains speed records of 207 sensors deployed on the highways of Los Angles, CA (Li et al., 2018b). The records are in four months at the frequency of five minutes. We shift a one-hour window to obtain multiple time series. The first three months are used for training and the last month is split in halves for validation and testing. No anomaly labels exist however and we use this dataset for exploratory analysis only.
|
| 391 |
+
|
| 392 |
+

|
| 393 |
+
Figure 6: Density estimation for METR-LA.
|
| 394 |
+
|
| 395 |
+
Figure 6a shows the traffic speed on four main highways on June 13, 2012. Each speed is the average over all sensors on the same highway. We observe that despite spatial proximity, the speeds vary significantly around 4PM (rush hour) but they are unanimously high around 5AM and 8PM– 12AM. The estimated densities, shown in Figure 6b, tracks this pattern rather closely, with rush hours corresponding to low density and night traffics corresponding to high density. Note the nature of traffic: speed varies smoothly on the macroscopic level and hence does density, too. Such a phenomenon is in striking contrast to power systems where events are rare and abrupt.
|
| 396 |
+
|
| 397 |
+
# F ADDITIONAL ANOMALY DETECTION RESULTS ON PMU DATASETS
|
| 398 |
+
|
| 399 |
+
See Figure 7 and Figure 8 for additional anomaly detection results on the test sets of PMU-C and PMU-B, respectively. The observations are rather similar to those of Figure 3b.
|
| 400 |
+
|
| 401 |
+

|
| 402 |
+
Figure 7: Additional anomaly detection results on the test set of PMU-C.
|
| 403 |
+
|
| 404 |
+

|
| 405 |
+
Figure 8: Anomaly detection results on the test set of PMU-B.
|
| 406 |
+
|
| 407 |
+
# G ADDITIONAL RESULTS FOR DAG EVOLUTION
|
| 408 |
+
|
| 409 |
+

|
| 410 |
+
Figure 9: Evolution of the learned DAG on PMU-B over time.
|
md/dev/4oXTQ6m_ws8/4oXTQ6m_ws8.md
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# THE ROLE OF IMAGENET CLASSES IN FRECHET ´ INCEPTION DISTANCE
|
| 2 |
+
|
| 3 |
+
Tuomas Kynka¨anniemi ¨
|
| 4 |
+
Aalto University
|
| 5 |
+
tuomas.kynkaanniemi@aalto.fi
|
| 6 |
+
Tero Karras
|
| 7 |
+
NVIDIA
|
| 8 |
+
tkarras@nvidia.com
|
| 9 |
+
Miika Aittala
|
| 10 |
+
NVIDIA
|
| 11 |
+
maittala@nvidia.com
|
| 12 |
+
Timo Aila
|
| 13 |
+
NVIDIA
|
| 14 |
+
taila@nvidia.com
|
| 15 |
+
|
| 16 |
+
Jaakko Lehtinen Aalto University & NVIDIA jlehtinen@nvidia.com
|
| 17 |
+
|
| 18 |
+
# ABSTRACT
|
| 19 |
+
|
| 20 |
+
Frechet Inception Distance (FID) is the primary metric for ranking models in data- ´ driven generative modeling. While remarkably successful, the metric is known to sometimes disagree with human judgement. We investigate a root cause of these discrepancies, and visualize what FID “looks at” in generated images. We show that the feature space that FID is (typically) computed in is so close to the ImageNet classifications that aligning the histograms of Top- $N$ classifications between sets of generated and real images can reduce FID substantially — without actually improving the quality of results. Thus, we conclude that FID is prone to intentional or accidental distortions. As a practical example of an accidental distortion, we discuss a case where an ImageNet pre-trained FastGAN achieves a FID comparable to StyleGAN2, while being worse in terms of human evaluation.
|
| 21 |
+
|
| 22 |
+
# 1 INTRODUCTION
|
| 23 |
+
|
| 24 |
+
Generative modeling has been an extremely active research topic in recent years. Many prominent model types, such as generative adversarial networks (GAN) (Goodfellow et al., 2014), variational autoencoders (VAE) (Kingma & Welling, 2014), autoregressive models (van den Oord et al., 2016b;a), flow models (Dinh et al., 2017; Kingma & Dhariwal, 2018) and diffusion models (SohlDickstein et al., 2015; Song & Ermon, 2019; Ho et al., 2020) have seen significant improvement. Additionally, these models have been applied to a rich set of downstream tasks, such as realistic image synthesis (Brock et al., 2019; Razavi et al., 2019; Esser et al., 2021; Karras et al., 2019; 2020b;a; 2021), unsupervised domain translation (Zhu et al., 2017; Choi et al., 2020; Kim et al., 2020), image super resolution (Ledig et al., 2017; Bell-Kligler et al., 2019; Saharia et al., 2021), image editing (Park et al., 2019; 2020; Huang et al., 2022) and generating images based on a text prompt (Ramesh et al., 2021; Nichol et al., 2022; Ramesh et al., 2022; Saharia et al., 2022).
|
| 25 |
+
|
| 26 |
+
Given the large number of applications and rapid development of the models, designing evaluation metrics for benchmarking their performance is an increasingly important topic. It is crucial to reliably rank models and pinpoint improvements caused by specific changes in the models or training setups. Ideally, a generative model should produce samples that are indistinguishable from the training set, while covering all of its variation. To quantitatively measure these aspects, numerous metrics have been proposed, including Inception Score (IS) (Salimans et al., 2016), Frechet Inception Dis- ´ tance (FID) (Heusel et al., 2017), Kernel Inception Distance (KID) (Binkowski et al., 2018), and Precision/Recall (Sajjadi et al., 2018; Kynka¨anniemi et al., 2019; Naeem et al., 2020). Among these ¨ metrics, FID continues to be the primary tool for quantifying progress.
|
| 27 |
+
|
| 28 |
+
The key idea in FID (Heusel et al., 2017) is to separately embed real and generated images to a vision-relevant feature space, and compute a distance between the two distributions, as illustrated in Figure 1. In practice, the feature space is the penultimate layer (pool3, 2048 features) of an ImageNet (Deng et al., 2009) pre-trained Inception-V3 classifier network (Szegedy et al., 2016), and the distance is computed as follows. The distributions of real and generated embeddings are separately approximated by multivariate Gaussians, and their alignment is quantified using the Frechet ´ (equivalently, the 2-Wasserstein or earth mover’s) distance (Dowson & Landau, 1982)
|
| 29 |
+
|
| 30 |
+

|
| 31 |
+
Figure 1: Overview of the Frechet Inception Distance (FID) (Heusel et al., 2017). First, the real ´ and generated images are separately passed through a pre-trained classifier network, typically the Inception-V3 (Szegedy et al., 2016), to produce two sets of feature vectors. Then, both distributions of features are approximated with multivariate Gaussians, and FID is defined as the Frechet distance ´ between the two Gaussians. In Section 3, we will compute alternative FIDs in the feature spaces of logits and class probabilities, instead of the usual pre-logit space.
|
| 32 |
+
|
| 33 |
+
$$
|
| 34 |
+
\mathrm { F I D } \left( \mu _ { \mathrm { r } } , \Sigma _ { \mathrm { r } } , \mu _ { \mathrm { g } } , \Sigma _ { \mathrm { g } } \right) = \left\| \mu _ { \mathrm { r } } - \mu _ { \mathrm { g } } \right\| _ { 2 } ^ { 2 } + \mathrm { T r } \left( \Sigma _ { \mathrm { r } } + \Sigma _ { \mathrm { g } } - 2 \left( \Sigma _ { \mathrm { r } } \Sigma _ { \mathrm { g } } \right) ^ { \frac { 1 } { 2 } } \right) ,
|
| 35 |
+
$$
|
| 36 |
+
|
| 37 |
+
where $( \mu _ { \mathrm { r } } , \Sigma _ { \mathrm { r } } )$ , and $( \mu _ { \mathrm { g } } , \Sigma _ { \mathrm { g } } )$ denote the sample mean and covariance of the embeddings of the real and generated data, respectively, and $\operatorname { T r } ( \cdot )$ indicates the matrix trace. By measuring the distance between the real and generated embeddings, FID is a clear improvement over IS that ignores the real data altogether. FID has been found to correlate reasonably well with human judgments of the fidelity of generated images (Heusel et al., 2017; Xu et al., 2018; Lucic et al., 2018), while being conceptually simple and fast to compute.
|
| 38 |
+
|
| 39 |
+
Unfortunately, FID conflates the resemblance to real data and the amount of variation to a single value (Sajjadi et al., 2018; Kynka¨anniemi et al., 2019), and its numerical value is significantly af-¨ fected by various details, including the sample count (Binkowski et al., 2018; Chong & Forsyth, 2020), the exact instance of the feature network, and even low-level image processing (Parmar et al., 2022). Appendix A gives numerical examples of these effects. Furthermore, several authors (Karras et al., 2020b; Morozov et al., 2021; Nash et al., 2021; Borji, 2022; Alfarra et al., 2022) observe that there exists a discrepancy in the model ranking between human judgement and FID in nonImageNet data, and proceed to introduce alternative metrics. Complementary to these works, we focus on elucidating why these discrepancies exist and what exactly is the role of ImageNet classes.
|
| 40 |
+
|
| 41 |
+
The implicit assumption in FID is that the feature space embeddings have general perceptual relevance. If this were the case, an improvement in FID would indicate a corresponding perceptual improvement in the generated images. While feature spaces with approximately this property have been identified (Zhang et al., 2018), there are several reasons why we doubt that FID’s feature space behaves like this. First, the known perceptual feature spaces have very high dimensionality $( { \sim } 6 \mathbf { M } )$ , partially because they consider the spatial position of features in addition to their presence. Unfortunately, there may be a contradiction between perceptual relevance and distribution statistics. It is not clear how much perceptual relevance small feature spaces (2048D for FID) can have, but it is also hard to see how distribution statistics could be compared in high-dimensional feature spaces using a finite amount of data. Second, FID’s feature space is specialized to ImageNet classification, and it is thus allowed to be blind to any image features that fail to help with this goal. Third, FID’s feature space (“pre-logits”) is only one affine transformation away from the logits, from which a softmax produces the ImageNet class probabilities. We can thus argue that the features correspond almost directly to ImageNet classes (see Appendix B). Fourth, ImageNet classifiers are known to base their decisions primarily on textures instead of shapes (Geirhos et al., 2019; Hermann et al., 2020).
|
| 42 |
+
|
| 43 |
+
Together, these properties have important practical consequences that we set out to investigate. In Section 2 we use a gradient-based visualization technique, Grad-CAM (Selvaraju et al., 2017), to visualize what FID “looks at” in generated images, and observe that its fixation on the most prominent ImageNet classes makes it more interested in, for example, seat belts and suits, than the human faces in FFHQ (Karras et al., 2019). It becomes clear that when a significant domain gap exists between a dataset of interest and ImageNet, many of the activations related to ImageNet class templates are rather coincidental. We call such poorly fitting templates fringe features or fringe classes. As matching the distribution of such fringe classes between real and generated images becomes an obvious way of manipulating FID, we examine such “attacks” in detail in Section 3. The unfortunate outcome is that FID can be significantly improved – with hardly any improvement in the generated images – by selecting a subset of images that happen to match some number of fringe features with the real data. We conclude with an example of practical relevance in Section 4, showing that FID can be unreliable when ImageNet pre-trained discriminators (Sauer et al., 2021; Kumari et al., 2022) are used in GANs. Some of the improvement in FID comes from accidental leaking of ImageNet features, and the consequent better reproduction of ImageNet-like aspects in the real data. We hope that the new tools we provide open new opportunities to better understand the existing evaluation metrics and develop new ones in the future. Code is available at https://github.com/kynkaat/role-of-imagenet-classes-in-fid.
|
| 44 |
+
|
| 45 |
+

|
| 46 |
+
Figure 2: Visualizing which regions of an image FID is the most sensitive to. We augment the pre-computed feature statistics with a newly generated image, compute the FID, and use GradCAM (Selvaraju et al., 2017) to visualize the spatial importance in low-resolution feature maps that are subsequently upsampled to match the input resolution.
|
| 47 |
+
|
| 48 |
+
# 2 WHAT DOES FID LOOK AT IN AN IMAGE?
|
| 49 |
+
|
| 50 |
+
We will now inspect which parts of an image FID is the most sensitive to. We rely on GradCAM (Selvaraju et al., 2017) that has been extensively used for visualizing the parts of an image that contribute the most to the decisions of a classifier. We want to use it similarly for visualizing which parts of one generated image contribute the most to FID. A key challenge is that FID is defined only between large sets of images (50k), not for a single image. We address this difficulty by pre-computing the required statistics for a set of 49,999 generated images, and augmenting them with the additional image of interest. We then use Grad-CAM to visualize the parts of the image that have the largest influence on FID. We will first explain our visualization technique in more detail, followed by observations from individual images, and from aggregates of images.
|
| 51 |
+
|
| 52 |
+
Our visualization technique Figure 2 gives an outline of our visualization technique. Assume we have pre-computed the mean and covariance statistics $( \mu _ { \mathrm { r } } , \Sigma _ { \mathrm { r } } )$ and $( \mu _ { \mathrm { g } } , \Sigma _ { \mathrm { g } } )$ for 50,000 real and 49,999 generated images, respectively. These Gaussians are treated as constants in our visualization. Now, we want to update the statistics of the generated images by adding one new image. Computing the FID from the updated statistics allows us to visualize which parts of the added image influence it the most. Given an image, we feed it through the Inception-V3 network to get activations $A ^ { k }$ before the pool3 layer. The spatial resolution here is $8 \times 8$ and there are 2048 feature maps. The spatial averages of these feature maps correspond to the 2048-dimensional feature space where FID is calculated. We then update the pre-computed statistics $( \mu _ { \mathrm { g } } , \Sigma _ { \mathrm { g } } )$ by including the features $f$ of the new sample (Pebay, 2008): (µ′g = N−1N $\begin{array} { r } { ( \pmb { \mu } _ { \mathrm { g } } ^ { \prime } = \frac { N - 1 } { N } \pmb { \mu } _ { \mathrm { g } } + \frac { 1 } { N } \pmb { f } , \pmb { \Sigma } _ { \mathrm { g } } ^ { \prime } = \frac { N - 2 } { N - 1 } \pmb { \Sigma } _ { \mathrm { g } } + \frac { 1 } { N } ( \pmb { f } - \pmb { \mu } _ { \mathrm { g } } ) ^ { T } ( \pmb { f } - \pmb { \mu } _ { \mathrm { g } } ) ) } \end{array}$ . Here, $N = 5 0 , 0 0 0$ is the size of the updated set. To complete the forward pass, we evaluate FID using these modified statistics.
|
| 53 |
+
|
| 54 |
+

|
| 55 |
+
Figure 3: StyleGAN2 generated images along with heatmap visualizations of the image regions that FID considers important in FFHQ (top) and LSUN CAT (bottom). Yellow indicates regions that are more important and blue regions that are less important, i.e., modifying the content of the yellow regions affects FID most strongly. As many of the yellow areas are completely outside the intended subject, we sought an explanation from the ImageNet Top-3 class predictions. FID is very strongly focused on the area that corresponds to the predicted Top-1 class — whatever that may be. We discuss the qualitative difference between FFHQ and LSUN CAT in the main text.
|
| 56 |
+
|
| 57 |
+
In a backward pass, we first estimate the importance $\pmb { \alpha } _ { k }$ for each of the $k$ feature maps as
|
| 58 |
+
|
| 59 |
+
$$
|
| 60 |
+
\alpha _ { k } = \frac { 1 } { 8 \times 8 } \sum _ { i } \sum _ { j } \left. \frac { \partial \mathrm { F I D } ( \mu _ { \mathrm { r } } , \Sigma _ { \mathrm { r } } , \mu _ { \mathrm { g } } ^ { \prime } , \Sigma _ { \mathrm { g } } ^ { \prime } ) } { \partial A _ { i j } ^ { k } } \right. ^ { 2 }
|
| 61 |
+
$$
|
| 62 |
+
|
| 63 |
+
Then, an $8 \times 8$ -pixel spatial importance map is computed as a linear combination $\textstyle \sum _ { k } \alpha _ { k } A ^ { k }$ . Note that Selvaraju et al. (2017) originally suggested using a ReLU to only visualize the regions that have a positive effect on the probability of a given class; we do not employ this trick, since we are interested in visualizing both positive and negative effects on FID. Additionally, we upsample the importance map using Lanczos filtering to match the dimensions of the input image. Finally, we convert the values of the importance map to a heatmap visualization. See Appendix C for comparisons of our FID heatmaps and standard Grad-CAM.
|
| 64 |
+
|
| 65 |
+
Observations from individual images Figure 3 shows heatmaps of the most important regions for FID in FFHQ (Karras et al., 2019) and LSUN CAT (Yu et al., 2015). Given that in FFHQ the goal is to generate realistic human faces, the regions FID considers most important seem rather unproductive. They are typically outside the person’s face. To better understand why this might happen, recall that ImageNet does not include a “person” or a “face” category. Instead, some other fringe features (and thus classes) are necessarily activated for each generated image. Interestingly, we observe that the heatmaps seem to correspond very well with the areas that the image’s ImageNet Top-1 class prediction would occupy. Note that these ImageNet predictions were not used when computing the heatmap; they are simply a tool for understanding what FID was focusing on. As a low FID mandates that the distributions of the most prominent fringe classes are matched between real and generated images, one has to wonder how relevant it really is to match the distributions of “seat belt” or “oboe” in this dataset. In any case, managing to perform such matching would seem to open a possible loophole in FID; we will investigate this further in Section 3.
|
| 66 |
+
|
| 67 |
+
In contrast to human faces, ImageNet does include multiple categories of cats. This helps FID to much better focus on the subject matter in LSUN CAT, although some fringe features from the image background are still getting picked up, and a very low FID would require that “washbasin”, etc. are similarly detected in real and generated images.
|
| 68 |
+
|
| 69 |
+

|
| 70 |
+
Figure 4: (a) Distribution of the ImageNet Top-1 classes, predicted by Inception-V3, for real and StyleGAN2 generated images in FFHQ. (b) Mean images and Grad-CAM heatmaps among all classes, and images classified as “bow tie”, “seat belt” and “mortarboard”. These were computed from generated images. Strikingly, when averaging over all classes, FID is the most sensitive to ImageNet objects that are located outside the face area.
|
| 71 |
+
|
| 72 |
+
Observations from aggregates of images Figure 4a shows the distribution of ImageNet Top-1 classifications for real and generated images in FFHQ. Typically, the predicted classes are accessories, but their presence might be correlated with persons in the images. In a further test, we calculated a heatmap of the average sensitivity over $5 0 \mathrm { k }$ generated images. Figure 4b shows average images and heatmaps for all classes, and for images that are classified to some specific class (e.g., “bow tie”). If we average over all classes, FID is the most sensitive to other areas of the image than the human face. If we compute a heatmap of the average sensitivity within a class, they highlight the regions where the corresponding ImageNet class is typically located in the images. Appendix C provides additional single image and average heatmaps. It also provides further validation that the image regions FID is the most sensitive to are correctly highlighted by our approach.
|
| 73 |
+
|
| 74 |
+
In related work, van Steenkiste et al. (2020) found that in images with multiple salient objects, FID focuses on only one of them and hypothesized that the metric could be easily fooled by a generative model that focuses on some image statistics (e.g., generating the correct number of objects) rather than content. They believe that this is because Inception-V3 is trained on a single object classification.
|
| 75 |
+
|
| 76 |
+
# 3 PROBING THE PERCEPTUAL NULL SPACE IN FID
|
| 77 |
+
|
| 78 |
+
Our findings with Grad-CAM raise an interesting question: to what extent could FID be improved by merely nudging the generator to produce images that get classified to the same ImageNet classes as the real data? As we are interested in a potential weakness in FID, we furthermore want this nudging to happen so that the generated results do not actually improve in any real sense. In our terminology, operations that change FID without changing the generated results in a perceptible way are exploiting the perceptual null space of FID.
|
| 79 |
+
|
| 80 |
+
We will first test a simple Top-1 (ImageNet classification) histogram matching between real and generated data. As this has only a modest impact on FID, we proceed to develop a more general distribution resampling method. This approach manages to reduce FID very significantly, indicating that there exists a large perceptual null space in FID. We then explore the role of other likely class labels, in addition to the Top-1 label, by aligning the Top- $N$ histograms. In Section 4 we observe that this theoretical weakness also has practical relevance.
|
| 81 |
+
|
| 82 |
+
In our experiments, we use StyleGAN2 auto-config trained in $2 5 6 \times 2 5 6$ resolution without adaptive discriminator augmentation (ADA). The only exception is AFHQ-V2 DOG, where we enable ADA and train in $5 1 2 \times 5 1 2$ resolution.1 Following standard practice, we compute FID against the training set, using $5 0 \mathrm { k }$ randomly chosen real and generated images and the official TensorFlow version of Inception-V3.2 A difference between our FIDs for StyleGAN2 and the ones reported by Karras et al. (2020a) is caused by the use of different training configurations.
|
| 83 |
+
|
| 84 |
+
Table 1: Results of Top-1 histogram matching. We compare the FID of randomly sampled images (FID) against ones that have been resampled to match the Top-1 histogram of the training data $\mathrm { ( F I D ^ { T o p - 1 } } \cdot$ ). The numbers represent averages over five FID evaluations. Additionally, we report the corresponding numbers by replacing the Inception-V3 feature space with ResNet-50 $\mathrm { ( F I D _ { R e s N e t - 5 0 } ) }$ , SwAV $\mathrm { ( F I D _ { S w A V } ) }$ , and CLIP features $\mathrm { ( F I D _ { C L I P } ) }$ . Note that we use these alternative feature spaces only when computing FID; the resampling is still done using Inception-V3. The numerical values between different features spaces are not comparable.
|
| 85 |
+
|
| 86 |
+
<table><tr><td>Dataset</td><td>FID</td><td>FIDTop-1</td><td>FIDResNet-50</td><td></td><td>FIDswAV</td><td>FIDSA</td><td>FIDcLIP</td><td>FIDCLI Top-1</td></tr><tr><td>FFHQ</td><td>5.30</td><td>4.70 (-11.3%)</td><td>6.11</td><td>5.59 (-8.5%)</td><td>1.42</td><td>1.41 (-0.7%)</td><td>2.76</td><td>2.74 (-0.7%)</td></tr><tr><td>LSUN CAT</td><td>8.25</td><td>7.37 (-10.7%)</td><td>12.33</td><td>11.29 (-8.4%)</td><td>2.99</td><td>2.96 (-1.0%)</td><td>8.94</td><td>8.83 (-1.2%)</td></tr><tr><td>LSUN CAR</td><td>5.65</td><td>5.17 (-8.5%)</td><td>8.79</td><td>8.51 (-3.2%)</td><td>2.39</td><td>2.38 (-0.4%)</td><td>7.75</td><td>7.73 (-0.3%)</td></tr><tr><td>LSUN PLACES</td><td>12.96</td><td>11.76 (-9.3%)</td><td>15.20</td><td>13.61 (-10.5%)</td><td>3.12</td><td>3.02 (-3.2%)</td><td>16.35</td><td>16.17 (-1.1%)</td></tr><tr><td>AFHQ-V2 DOG</td><td>10.25</td><td>9.39 (-8.4%)</td><td>13.71</td><td>13.19 (-3.8%)</td><td>2.78</td><td>2.77 (-0.4%)</td><td>4.25</td><td>4.16 (-2.1%)</td></tr></table>
|
| 87 |
+
|
| 88 |
+
Top-1 histogram matching Based on the Grad-CAM visualizations in Section 2, one might suspect that to achieve a low FID, it would be sufficient to match the Top-1 class histograms between the sets of real and generated images. We tested this hypothesis by computing the Top-1 histogram for $5 0 \mathrm { k }$ real images, and then sampling an equal number of unique generated images for each Top-1 class. This was done by looking at the class probabilities at the output of the Inception-V3 classifier (Figure 1), and discarding the generated images that fall into a bin that is already full. Over multiple datasets, this simple Top-1 histogram matching consistently improves FID, by $\sim 1 0 \%$ (Table 1).
|
| 89 |
+
|
| 90 |
+
Does this mean that the set of generated images actually improved? A genuine improvement should also be clearly visible in FIDs computed using alternative feature spaces. To this end, we calculated FIDs in the feature spaces of a ResNet-50 ImageNet classifier $( \mathrm { F I D } _ { \mathrm { R e s N e t } - 5 0 } )$ (He et al., 2016), selfsupervised SwAV classifier $\mathrm { ( F I D _ { S w A V } ) }$ (Caron et al., 2020; Morozov et al., 2021), and CLIP image encoder $\mathrm { ( F I D _ { C L I P } ) }$ (Radford et al., 2021; Sauer et al., 2021).3 Interestingly, $\mathrm { F I D } _ { \mathrm { R e s N e t - } 5 0 }$ drops almost as much as the original FID, even though the resampling was carried out with the Inception-V3 features. This makes sense because both feature spaces are necessarily very sensitive to the ImageNet classes. $\mathrm { F I D } _ { \mathrm { S w A V } }$ drops substantially less, probably because it was never trained to classify the ImageNet data. The muted decrease in $\mathrm { F I D } _ { \mathrm { C L I P } }$ is also in line with expectations because CLIP never saw ImageNet data; it was trained with a different task of matching images with captions. 4 We can thus conclude that the observed decrease in FID is closely related to the degree of ImageNet pre-training, and that the alternative feature spaces fail to confirm a clear increase in the result quality.
|
| 91 |
+
|
| 92 |
+
As a ten percent reduction in FID may not be significant enough for a human observer to draw reliable conclusions from the sets of generated images, we proceed to generalize the histogram matching to induce a much larger drop in FID.
|
| 93 |
+
|
| 94 |
+
Matching all fringe features We will now design a general technique for resampling the distribution of generated images, with the goal of approximately matching all fringe features. We will subsequently modify this approach to do Top- $. N$ histogram matching, as extending the simple “draw samples until it falls into the right bin”-approach for Top- $N$ would be computationally infeasible.
|
| 95 |
+
|
| 96 |
+
Our idea is to first generate a larger set of candidate images $5 \times$ oversampling), and then carefully select a subset of these candidates so that FID decreases. We approach this by directly optimizing FID as follows. First, we select a candidate set of 250k generated images and compute their Inception-V3 features. We then assign a non-negative scalar weight $w _ { i }$ to each generated image, and optimize the weights to minimize FID computed from weighted means and covariances of the generated images. After optimization, we use the weights as sampling probabilities and draw 50k random samples with replacement from the set of $2 5 0 \mathrm { k }$ candidate images. More precisely, we optimize
|
| 97 |
+
|
| 98 |
+
$$
|
| 99 |
+
\operatorname* { m i n } _ { \pmb { w } } \left( \left\| \pmb { \mu } _ { \mathrm { r } } - \pmb { \mu } _ { \mathrm { g } } ( \pmb { w } ) \right\| _ { 2 } ^ { 2 } + \operatorname { T r } \left( \pmb { \Sigma } _ { \mathrm { r } } + \pmb { \Sigma } _ { \mathrm { g } } ( \pmb { w } ) - 2 \left( \pmb { \Sigma } _ { \mathrm { r } } \pmb { \Sigma } _ { \mathrm { g } } ( \pmb { w } ) \right) ^ { \frac { 1 } { 2 } } \right) \right) ,
|
| 100 |
+
$$
|
| 101 |
+
|
| 102 |
+
where $\begin{array} { r } { \mu _ { \mathrm { g } } ( { \pmb w } ) = \frac { \sum _ { i } w _ { i } { \pmb f } _ { i } } { \sum _ { i } w _ { i } } } \end{array}$ and $\begin{array} { r l r } { \Sigma _ { \mathrm { g } } ( w ) } & { { } = } & { \frac { 1 } { \sum _ { i } w _ { i } } \sum _ { i } w _ { i } \left( f _ { i } - \mu _ { \mathrm { g } } ( w ) \right) ^ { T } \left( f _ { i } - \mu _ { \mathrm { g } } ( w ) \right) } \end{array}$ are the weighted mean and covariance of generated features $f _ { i }$ , respectively. In practice, we optimize the weights in Equation 3 via gradient descent. We parameterize the weights as $\log ( w _ { i } )$ to avoid negative values and facilitate easy conversion to probabilities. Note that we do not optimize the parameters of the generator network, only the sampling weights that are assigned to each generated image in the candidate set. Optimizing FID directly in this way is a form of adversarial attack, but not nearly as strong as modifying the images or the generator to directly attack the Inception-V3 network. In any case, our goal is only to elucidate the perceptual null space in FID, and we do not advocate this resampling step to improve the quality of models (Issenhuth et al., 2022; Humayun et al., 2022).
|
| 103 |
+
|
| 104 |
+
Table 2: Results of matching all fringe features. We compare the FID of randomly sampled images (FID) against ones that have been resampled to approximately match all fringe features with the training data $\mathrm { ( F I D ^ { P L } ) }$ ). The numbers represent averages over ten FID evaluations. $\mathrm { F I D } _ { \mathrm { R e s N e t - } 5 0 }$ , $\mathrm { F I D } _ { \mathrm { S w A V } }$ , $\mathrm { F I D } _ { \mathrm { C L I P } }$ match the descriptions in Table 1. The gray column $\mathrm { ( F I D ^ { L } ) }$ shows an additional experiment where the resampling is done using logits instead of the usual pre-logits.
|
| 105 |
+
|
| 106 |
+
<table><tr><td>Dataset</td><td>FID</td><td>FIDPL</td><td></td><td>FIDL</td><td>FIDResNet-50</td><td></td><td>FIDResNet-50</td><td>FIDswAV</td><td>FID5wAV</td><td></td><td>FIDcLIP</td><td>FIDCLIP</td></tr><tr><td>FFHQ</td><td>5.30</td><td>1.78 (-66.4%) 2.22 (-58.1%)</td><td></td><td></td><td></td><td>6.11</td><td>3.85 (-37.0%)</td><td></td><td>1.42</td><td>1.24 (-12.7%)</td><td>2.76</td><td>2.64 (-4.3%)</td></tr><tr><td>LSUN CAT</td><td>8.25</td><td>3.05 (-63.0%) 3.88 (-53.0%)</td><td></td><td></td><td></td><td>12.33</td><td>7.17 (-41.8%)</td><td></td><td>2.99</td><td>2.71 (-9.4%)</td><td>8.94</td><td>7.98 (-10.7%)</td></tr><tr><td>LSUN CAR</td><td>5.65</td><td>2.11 (-62.7%)</td><td></td><td>2.59 (-54.2%)</td><td></td><td>8.79</td><td>5.88 (-33.1%)</td><td></td><td>2.39</td><td>2.15 (-10.0%)</td><td>7.75</td><td>7.33 (-5.4%)</td></tr><tr><td>LSUN PLACES</td><td>12.96</td><td>3.59 (-72.3%) 4.43(-65.8%)</td><td></td><td></td><td></td><td>15.20</td><td>9.35 (-38.5%)</td><td></td><td>3.12</td><td>2.60 (-16.7%)</td><td>16.35</td><td>14.54 (−11.1%)</td></tr><tr><td>AFHQ-V2 DOG</td><td>10.25</td><td>5.92 (-42.2%) 6.27 (-38.8%)</td><td></td><td></td><td></td><td>13.71</td><td>11.38 (-17.1%)</td><td></td><td>2.78</td><td>2.62 (-5.8%)</td><td>4.25</td><td>4.04 (-4.9%)</td></tr></table>
|
| 107 |
+
|
| 108 |
+

|
| 109 |
+
Figure 5: Uncurated random StyleGAN2 samples from images with (a) the smallest $1 0 \%$ of weights and (b) the largest $1 0 \%$ of weights after optimizing the weights to improve FID. Both sets contain both realistic images and images with clear visual artifacts in roughly equal proportions. See Appendix D for a larger sample.
|
| 110 |
+
|
| 111 |
+
Table 2 shows that FIDs can be drastically reduced using this approach. An improvement by as much as $60 \%$ would be considered a major breakthrough in generative modeling, and it should be completely obvious when looking at the generated images. Yet, the uncurated grids in Appendix D fail to demonstrate an indisputable improvement. To confirm the visual result quantitatively, we again compute FIDs of the resampled distributions in the alternative feature spaces. We see a substantially smaller improvement in feature spaces that did not use ImageNet classifier pre-training. While it is possible that the generated results actually improved in some minor way, we can nevertheless conclude that a vast majority of the improvement in FID occurred in its perceptual null space, and that this null space is therefore quite large. In other words, FID can be manipulated to a great extent through the ImageNet classification probabilities, without meaningfully improving the generated results.
|
| 112 |
+
|
| 113 |
+
Figure 5 further shows images that obtain small and large weights in the optimization; it is not obvious that there is a visual difference between the sets, indicating that the huge improvement in FID $( - 6 6 . 4 \% )$ cannot be simply attributed to discarding images with clear artifacts. Appendix D also shows that the resampling fools KID just as thoroughly as FID, even though we do not directly optimize KID.
|
| 114 |
+
|
| 115 |
+
Finally, it makes only a small difference whether the weight optimization is done in the typical pre-logit space (denoted $\mathrm { F I D } ^ { \mathrm { P L } }$ ) or in the logit space $\mathrm { ( F I D ^ { L } ) }$ , confirming that these spaces encode approximately the same information. Figure 1 illustrates the difference between these spaces.
|
| 116 |
+
|
| 117 |
+
Top- $N$ histogram matching The drastic FID reduction observed in the previous section provides clues about the upper bound of the size of the perceptual null space. We will now further explore the nature of this null space by extending our resampling method to approximate Top- $N$ histogram matching. Then, by sweeping over $N$ , we can gain further insights to how important the top classification results are for FID.
|
| 118 |
+
|
| 119 |
+

|
| 120 |
+
Figure 6: Softly matching Top-N class distributions in FFHQ through resampling. FID (solid curves, left-hand $y$ scale) decreases sharply with increasing number $N$ of classes included in the Top-N indicator vectors. At the same time, $\mathrm { F I D } _ { \mathrm { C L I P } }$ (dashed curves, right-hand $y$ scale) remains almost constant, indicating that the apparent improvements in FID are superfluous. The orange control curves have been computed from classes in the middle of the sorted probability vectors, indicating that the top classes indeed have a much stronger influence. As the numerical values of FID and $\mathrm { F I D } _ { \mathrm { C L I P } }$ are not comparable, the left and right $y$ axes have been normalized such that the relative changes are represented accurately.
|
| 121 |
+
|
| 122 |
+
We implement this by carrying out the weight optimization in the space of class probabilities (see Figure 1). We furthermore binarize the class probability vectors by identifying the $N$ classes with the highest probabilities and setting the corresponding entries to 1 and the rest to 0. These vectors now indicate, for each image, the Top- $N$ classes, while discarding their estimated probabilities. By matching the statistics of these indicator vectors between real and generated distributions, we optimize the co-occurrence of Top- $. N$ classes. The result of the weight optimization is therefore an approximation of Top- $N$ histogram matching. With $N = 1$ , the results approximately align with simple histogram matching (Table 1). Note that the binarization is done before the weight optimization begins, and thus we don’t need its (non-computable) gradients.
|
| 123 |
+
|
| 124 |
+
Figure 6 shows how FID (computed in the usual pre-logit space) changes as we optimize Top- $N$ histogram matching with increasing $N$ . We observe that even with small values of $N$ , FID improves rapidly, and converges to a value slightly higher than was obtained by optimizing the weights in the pre-logit space $\mathrm { \bar { F } I D } ^ { \mathrm { P L } }$ in Table 2). This demonstrates that FID is, to a significant degree, determined by the co-occurrence of top ImageNet classes. Furthermore, it illustrates that FID is the most interested in a handful of features whose only purpose is to help with ImageNet classification, not on some careful analysis of the whole image. As a further validation of this tendency, we also computed a similar optimization using binarized vectors computed using $N$ classes chosen from the middle5 of the sorted probabilities (orange curves in Figure 6). The results show that the top classes have a significantly higher influence on FID than those ranked lower by the Inception-V3 classifier. Finally, as before, we present a control $\mathrm { F I D } _ { \mathrm { C L I P } }$ (dashed curves) that shows that CLIP’s feature space is almost indifferent to the apparent FID improvements yielded by the better alignment of Top- $N$ ImageNet classes. Though we only present results for FFHQ here, qualitative behavior is similar for LSUN CAT/PLACES/CAR, and AFHQ-V2 DOG (see Appendix D).
|
| 125 |
+
|
| 126 |
+
# 4 PRACTICAL EXAMPLE: IMAGENET PRE-TRAINED GANS
|
| 127 |
+
|
| 128 |
+
Our experiments indicate that it is certainly possible that some models receive unrealistically low FID simply because they happen to reproduce the (inconsequential) ImageNet class distribution detected in the training data. Perhaps the most obvious way this could happen in practice is when ImageNet pre-training is used for a GAN discriminator (Sauer et al., 2021; Kumari et al., 2022). This approach has been observed to lead to much faster convergence and significant improvements in FID, but since the discriminator is readily sensitive to the ImageNet classes, maybe it also guides the generator to replicate them? Perhaps a part of the improvement is in the perceptual nullspace of FID?
|
| 129 |
+
|
| 130 |
+

|
| 131 |
+
Figure 7: Uncurated samples from (a) Projected FastGAN and (b) StyleGAN2. Both models achieve similar FID even though the Projected FastGAN samples contain more artifacts. In contrast, Projected FastGAN has significantly higher $\mathrm { F I D } _ { \mathrm { C L I P } }$ , consistent with the observed quality differential.
|
| 132 |
+
|
| 133 |
+
We study this in the same context as Sauer et al. (2021) by training a Projected FastGAN (Liu et al., 2021; Sauer et al., 2021) that uses an ImageNet pre-trained EfficientNet (Tan & Le, 2019) as a feature extractor of the discriminator, and compare it against StyleGAN2 in FFHQ.6
|
| 134 |
+
|
| 135 |
+
The human preference study conducted by Sauer et al. (2021) concludes that despite the dramatic improvements in FID, Projected FastGAN tends to generate lower quality and less diverse FFHQ samples than StyleGAN2. We verify this by comparing samples from Projected FastGAN and StyleGAN2 in a setup where FIDs are roughly comparable and the models reproduce a similar degree of variation as measured by Recall (Kynka¨anniemi et al., 2019). Visual inspection of uncurated sam- ¨ ples (Figure 7) indeed reveals that Projected FastGAN produces much more distortions in the human faces than StyleGAN2 (see Appendix E for larger image grids).
|
| 136 |
+
|
| 137 |
+
In this iso-FID comparison, $\mathrm { F I D } _ { \mathrm { C L I P } }$ agrees with human assessment – StyleGAN2 is rated significantly better than Projected FastGAN. It therefore seems clear that Projected FastGAN has lower FID than it should have, confirming that at least some of its apparent improvements are in the perceptual null space. We believe that the reason for this is the accidental leak of information from the pre-trained network, causing the model to replicate the ImageNet-like aspects in the training data more keenly. This observation does not mean that ImageNet pre-training is a bad idea, but it does mean that such pre-training can make FID unreliable in practice.
|
| 138 |
+
|
| 139 |
+
We suspect similar interference can happen when the ImageNet pre-trained classifiers are used to curate the training data (DeVries et al., 2020) or as a part of the sampling process (Watson et al., 2022).
|
| 140 |
+
|
| 141 |
+
# 5 CONCLUSIONS
|
| 142 |
+
|
| 143 |
+
The numerical values of FID have a number of important uses. Large values indicate training failures quite reliably, and FID appears highly dependable when monitoring the convergence of a training run. FID improvements obtained through hyperparameter sweeps or other trivial changes generally seem to translate to better (subjective) results, even when the distributions are well aligned.7 The caveats arise when two sufficiently different architectures and/or training setups are compared. If one of them is, for some reason, inclined to better reproduce the fringe features, it can lead to a much lower FIDs without a corresponding improvement in the human-observable quality.
|
| 144 |
+
|
| 145 |
+
Particular care should be exercised when introducing ImageNet pre-training to generative models (Sauer et al., 2021; 2022; Kumari et al., 2022), as it may compromise the validity of FID as a quality metric. This effect is difficult to quantify because the current widespread metrics (KID and Precision/Recall) also rely on the feature spaces of ImageNet classifiers. As a partial solution, the FID improvements should at least be verified using a non-ImageNet trained Frechet distance. Viable ´ alternative feature spaces include CLIP (Radford et al., 2021; Sauer et al., 2021), self-supervised SwAV (Caron et al., 2020; Morozov et al., 2021), and an uninitialized network (Naeem et al., 2020; Sauer et al., 2022). We hope that our methods help examine the properties of these feature spaces in future work.
|
| 146 |
+
|
| 147 |
+
# ACKNOWLEDGEMENTS
|
| 148 |
+
|
| 149 |
+
We thank Samuli Laine for helpful comments. This work was partially supported by the European Research Council (ERC Consolidator Grant 866435), and made use of computational resources provided by the Aalto Science-IT project and the Finnish IT Center for Science (CSC).
|
| 150 |
+
|
| 151 |
+
# REFERENCES
|
| 152 |
+
|
| 153 |
+
Mart´ın Abadi, Ashish Agarwal, Paul Barham, Eugene Brevdo, Zhifeng Chen, Craig Citro, Greg S. Corrado, Andy Davis, Jeffrey Dean, Matthieu Devin, Sanjay Ghemawat, Ian Goodfellow, Andrew Harp, Geoffrey Irving, Michael Isard, Yangqing Jia, Rafal Jozefowicz, Lukasz Kaiser, Manjunath Kudlur, Josh Levenberg, Dandelion Mane, Rajat Monga, Sherry Moore, Derek Murray, Chris ´ Olah, Mike Schuster, Jonathon Shlens, Benoit Steiner, Ilya Sutskever, Kunal Talwar, Paul Tucker, Vincent Vanhoucke, Vijay Vasudevan, Fernanda Viegas, Oriol Vinyals, Pete Warden, Martin Wat- ´ tenberg, Martin Wicke, Yuan Yu, and Xiaoqiang Zheng. TensorFlow: Large-Scale Machine Learning on Heterogeneous Systems, 2015. URL https://www.tensorflow.org/.
|
| 154 |
+
|
| 155 |
+
Motasem Alfarra, Juan C. Perez, Anna Fr ´ uhst ¨ uck, Philip H. S. Torr, Peter Wonka, and Bernard ¨ Ghanem. On the Robustness of Quality Measures for GANs. In Proc. ECCV, 2022.
|
| 156 |
+
|
| 157 |
+
Sefi Bell-Kligler, Assaf Shocher, and Michal Irani. Blind Super-Resolution Kernel Estimation using an Internal-GAN. In Proc. NeurIPS, 2019.
|
| 158 |
+
|
| 159 |
+
Mikolaj Binkowski, Danica J. Sutherland, Michael Arbel, and A. Gretton. Demystifying MMD GANs. In Proc. ICLR, 2018.
|
| 160 |
+
|
| 161 |
+
Ali Borji. Pros and cons of GAN evaluation measures: New developments. Comput. Vis. Image Underst., 2022.
|
| 162 |
+
|
| 163 |
+
Andrew Brock, Jeff Donahue, and K. Simonyan. Large Scale GAN Training for High Fidelity Natural Image Synthesis. In Proc. ICLR, 2019.
|
| 164 |
+
|
| 165 |
+
Mathilde Caron, Ishan Misra, Julien Mairal, Priya Goyal, Piotr Bojanowski, and Armand Joulin. Unsupervised Learning of Visual Features by Contrasting Cluster Assignments. In Proc. NeurIPS, 2020.
|
| 166 |
+
|
| 167 |
+
Yunjey Choi, Youngjung Uh, Jaejun Yoo, and Jung-Woo Ha. StarGAN v2: Diverse Image Synthesis for Multiple Domains. In Proc. CVPR, 2020.
|
| 168 |
+
|
| 169 |
+
Min Jin Chong and D. Forsyth. Effectively Unbiased FID and Inception Score and Where to Find Them. In Proc. CVPR, 2020.
|
| 170 |
+
|
| 171 |
+
J. Deng, W. Dong, R. Socher, L.-J. Li, K. Li, and L. Fei-Fei. ImageNet: A Large-Scale Hierarchical Image Database. In Proc. CVPR, 2009.
|
| 172 |
+
|
| 173 |
+
Terrance DeVries, Michal Drozdzal, and Graham W Taylor. Instance Selection for GANs. In Proc. NeurIPS, 2020.
|
| 174 |
+
|
| 175 |
+
Laurent Dinh, Jascha Sohl-Dickstein, and Samy Bengio. Density Estimation using Real NVP. In Proc. ICLR, 2017.
|
| 176 |
+
|
| 177 |
+
D. Dowson and B. Landau. The Frechet distance between multivariate normal distributions. ´ Journal of Multivariate Analysis, 12:450–455, 1982.
|
| 178 |
+
|
| 179 |
+
Patrick Esser, Robin Rombach, and Bjorn Ommer. Taming Transformers for High-Resolution Image ¨ Synthesis. In Proc. CVPR, 2021.
|
| 180 |
+
|
| 181 |
+
Kenji Fukumizu, Arthur Gretton, Xiaohai Sun, and Bernhard Scholkopf. Kernel Measures of Con- ¨ ditional Dependence. In Proc. NIPS, 2007.
|
| 182 |
+
|
| 183 |
+
Robert Geirhos, Patricia Rubisch, Claudio Michaelis, Matthias Bethge, Felix Wichmann, and Wieland Brendel. ImageNet-trained CNNs are biased towards texture; increasing shape bias improves accuracy and robustness. In Proc. ICLR, 2019.
|
| 184 |
+
|
| 185 |
+
Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative Adversarial Networks. In Proc. NIPS, 2014.
|
| 186 |
+
Arthur Gretton, Karsten M. Borgwardt, Malte J. Rasch, Bernhard Scholkopf, and Alexander Smola. ¨ A Kernel Two-Sample Test. Journal of Machine Learning Research, 2012.
|
| 187 |
+
Kaiming He, X. Zhang, Shaoqing Ren, and Jian Sun. Deep Residual Learning for Image Recognition. In Proc. CVPR, 2016.
|
| 188 |
+
Katherine L. Hermann, Ting Chen, and Simon Kornblith. The Origins and Prevalence of Texture Bias in Convolutional Neural Networks. In Proc. NeurIPS, 2020.
|
| 189 |
+
Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and Sepp Hochreiter. GANs Trained by a Two Time-Scale Update Rule Converge to a Local Nash Equilibrium. In Proc. NIPS, 2017.
|
| 190 |
+
Jonathan Ho, Ajay Jain, and P. Abbeel. Denoising Diffusion Probabilistic Models. In Proc. NeurIPS, 2020.
|
| 191 |
+
Xun Huang, Arun Mallya, Ting-Chun Wang, and Ming-Yu Liu. Multimodal Conditional Image Synthesis with Product-of-Experts GANs. In Proc. ECCV, 2022.
|
| 192 |
+
Ahmed Imtiaz Humayun, Randall Balestriero, and Richard Baraniuk. MaGNET: Uniform Sampling from Deep Generative Network Manifolds Without Retraining. In Proc. ICLR, 2022.
|
| 193 |
+
Thibaut Issenhuth, Ugo Tanielian, David Picard, and Jeremie Mary. Latent reweighting, an almost free improvement for GANs. In Proc. WACV, 2022.
|
| 194 |
+
Tero Karras, S. Laine, and Timo Aila. A Style-Based Generator Architecture for Generative Adversarial Networks. In Proc. CVPR, 2019.
|
| 195 |
+
Tero Karras, Miika Aittala, Janne Hellsten, Samuli Laine, Jaakko Lehtinen, and Timo Aila. Training Generative Adversarial Networks with Limited Data. In Proc. NeurIPS, 2020a.
|
| 196 |
+
Tero Karras, Samuli Laine, Miika Aittala, Janne Hellsten, Jaakko Lehtinen, and Timo Aila. Analyzing and Improving the Image Quality of StyleGAN. In Proc. CVPR, 2020b.
|
| 197 |
+
Tero Karras, Miika Aittala, Samuli Laine, Erik Hark ¨ onen, Janne Hellsten, Jaakko Lehtinen, and ¨ Timo Aila. Alias-Free Generative Adversarial Networks. In Proc. NeurIPS, 2021.
|
| 198 |
+
Junho Kim, Minjae Kim, Hyeonwoo Kang, and KwangHee Lee. U-GAT-IT: Unsupervised Generative Attentional Networks with Adaptive Layer-Instance Normalization for Image-to-Image Translation. In Proc. ICLR, 2020.
|
| 199 |
+
Diederik P. Kingma and Prafulla Dhariwal. Glow: Generative Flow with Invertible 1x1 Convolutions. In Proc. NeurIPS, 2018.
|
| 200 |
+
Diederik P. Kingma and Max Welling. Auto-Encoding Variational Bayes. In Proc. ICLR, 2014.
|
| 201 |
+
Nupur Kumari, Richard Zhang, Eli Shechtman, and Jun-Yan Zhu. Ensembling Off-the-shelf Models for GAN Training. In Proc. CVPR, 2022.
|
| 202 |
+
Tuomas Kynka¨anniemi, Tero Karras, Samuli Laine, Jaakko Lehtinen, and Timo Aila. Improved ¨ Precision and Recall Metric for Assessing Generative Models. In Proc. NeurIPS, 2019.
|
| 203 |
+
Christian Ledig, Lucas Theis, Ferenc Huszar, Jose Caballero, Andrew P. Aitken, Alykhan Tejani, ´ J. Totz, Zehan Wang, and W. Shi. Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network. In Proc. CVPR, 2017.
|
| 204 |
+
Bingchen Liu, Yizhe Zhu, Kunpeng Song, and Ahmed Elgammal. Towards Faster and Stabilized GAN Training for High-fidelity Few-shot Image Synthesis. In Proc. ICLR, 2021.
|
| 205 |
+
Mario Lucic, Karol Kurach, Marcin Michalski, S. Gelly, and O. Bousquet. Are GANs Created Equal? A Large-Scale Study. In Proc. NeurIPS, 2018.
|
| 206 |
+
|
| 207 |
+
Stanislav Morozov, Andrey Voynov, and Artem Babenko. On Self-Supervised Image Representations for GAN Evaluation. In Proc. ICLR, 2021.
|
| 208 |
+
|
| 209 |
+
Muhammad Ferjad Naeem, Seong Joon Oh, Youngjung Uh, Yunjey Choi, and Jaejun Yoo. Reliable Fidelity and Diversity Metrics for Generative Models. In Proc. ICML, 2020.
|
| 210 |
+
|
| 211 |
+
Charlie Nash, Jacob Menick, S. Dieleman, and P. Battaglia. Generating Images with Sparse Representations. In Proc. ICML, 2021.
|
| 212 |
+
|
| 213 |
+
Alex Nichol, Prafulla Dhariwal, Aditya Ramesh, Pranav Shyam, Pamela Mishkin, Bob McGrew, Ilya Sutskever, and Mark Chen. GLIDE: Towards Photorealistic Image Generation and Editing with Text-Guided Diffusion Models. In Proc. ICML, 2022.
|
| 214 |
+
|
| 215 |
+
Taesung Park, Ming-Yu Liu, T. Wang, and Jun-Yan Zhu. Semantic Image Synthesis With SpatiallyAdaptive Normalization. In Proc. CVPR, 2019.
|
| 216 |
+
|
| 217 |
+
Taesung Park, Jun-Yan Zhu, O. Wang, Jingwan Lu, E. Shechtman, Alexei A. Efros, and Richard Zhang. Swapping Autoencoder for Deep Image Manipulation. In Proc. NeurIPS, 2020.
|
| 218 |
+
|
| 219 |
+
Gaurav Parmar, Richard Zhang, and Jun-Yan Zhu. On Aliased Resizing and Surprising Subtleties in GAN Evaluation. In Proc. CVPR, 2022.
|
| 220 |
+
|
| 221 |
+
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 Proc. NeurIPS, 2019.
|
| 222 |
+
|
| 223 |
+
Philippe Pierre Pebay. Formulas for robust, one-pass parallel computation of covariances and arbitrary-order statistical moments. Technical Report SAND2008-6212, Sandia National Laboratories, 2008.
|
| 224 |
+
|
| 225 |
+
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 Proc. ICML, 2021.
|
| 226 |
+
|
| 227 |
+
Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-Shot Text-to-Image Generation. In Proc. ICML, 2021.
|
| 228 |
+
|
| 229 |
+
Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical TextConditional Image Generation with CLIP Latents. CoRR, abs/2204.06125, 2022.
|
| 230 |
+
|
| 231 |
+
Ali Razavi, Aaron van den Oord, and Oriol Vinyals. Generating Diverse High-Fidelity Images with ¨ VQ-VAE-2. In Proc. NeurIPS, 2019.
|
| 232 |
+
|
| 233 |
+
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.
|
| 234 |
+
|
| 235 |
+
Chitwan Saharia, William Chan, Saurabh Saxena, Lala Li, Jay Whang, Emily Denton, Seyed Kamyar Seyed Ghasemipour, Burcu Karagol Ayan, S. Sara Mahdavi, Rapha Gontijo Lopes, Tim Salimans, Jonathan Ho, David J Fleet, and Mohammad Norouzi. Photorealistic Text-to-Image Diffusion Models with Deep Language Understanding. CoRR, abs/2205.11487, 2022.
|
| 236 |
+
|
| 237 |
+
Mehdi S. M. Sajjadi, Olivier Bachem, Mario Lucic, Olivier Bousquet, and Sylvain Gelly. Assessing Generative Models via Precision and Recall. In Proc. NeurIPS, 2018.
|
| 238 |
+
|
| 239 |
+
Tim Salimans, I. Goodfellow, Wojciech Zaremba, Vicki Cheung, Alec Radford, and Xi Chen. Improved Techniques for Training GANs. In Proc. NIPS, 2016.
|
| 240 |
+
|
| 241 |
+
Axel Sauer, Kashyap Chitta, Jens Muller, and Andreas Geiger. Projected GANs Converge Faster. In ¨ In Proc. NeurIPS, 2021.
|
| 242 |
+
|
| 243 |
+
Axel Sauer, Katja Schwarz, and Andreas Geiger. StyleGAN-XL: Scaling StyleGAN to Large Diverse Datasets. In Proc. TOG, 2022.
|
| 244 |
+
|
| 245 |
+
Ramprasaath R. Selvaraju, Abhishek Das, Ramakrishna Vedantam, Michael Cogswell, Devi Parikh, and Dhruv Batra. Grad-CAM: Visual Explanations from Deep Networks via Gradient-Based Localization. In Proc. ICCV, 2017.
|
| 246 |
+
Jascha Sohl-Dickstein, Eric A. Weiss, Niru Maheswaranathan, and S. Ganguli. Deep Unsupervised Learning using Nonequilibrium Thermodynamics. In Proc. ICML, 2015.
|
| 247 |
+
Yang Song and Stefano Ermon. Generative Modeling by Estimating Gradients of the Data Distribution. In Proc. NeurIPS, 2019.
|
| 248 |
+
Christian Szegedy, V. Vanhoucke, S. Ioffe, Jonathon Shlens, and Z. Wojna. Rethinking the Inception Architecture for Computer Vision. In Proc. CVPR, 2016.
|
| 249 |
+
Mingxing Tan and Quoc V. Le. EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks. In Proc. ICML, 2019.
|
| 250 |
+
Aaron van den Oord, Nal Kalchbrenner, and Koray Kavukcuoglu. Pixel Recurrent Neural Networks. ¨ In Proc. ICML, 2016a.
|
| 251 |
+
Aaron van den Oord, Nal Kalchbrenner, Oriol Vinyals, Lasse Espeholt, Alex Graves, and Koray ¨ Kavukcuoglu. Conditional Image Generation with PixelCNN Decoders. In Proc. NIPS, 2016b.
|
| 252 |
+
Sjoerd van Steenkiste, Karol Kurach, Jurgen Schmidhuber, and Sylvain Gelly. Investigating object ¨ compositionality in Generative Adversarial Networks. Neural Networks, 2020.
|
| 253 |
+
Daniel Watson, William Chan, Jonathan Ho, and Mohammad Norouzi. Learning Fast Samplers for Diffusion Models by Differentiating Through Sample Quality. In Proc. ICLR, 2022.
|
| 254 |
+
Qiantong Xu, Gao Huang, Yang Yuan, Chuan Guo, Yu Sun, Felix Wu, and Kilian Q. Weinberger. An Empirical Study on Evaluation Metrics of Generative Adversarial Networks. ArXiv, abs/1806.07755, 2018.
|
| 255 |
+
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. CoRR, abs/1506.03365, 2015.
|
| 256 |
+
Richard Zhang, Phillip Isola, Alexei A Efros, Eli Shechtman, and Oliver Wang. The Unreasonable Effectiveness of Deep Features as a Perceptual Metric. In Proc. CVPR, 2018.
|
| 257 |
+
Jun-Yan Zhu, Taesung Park, Phillip Isola, and Alexei A Efros. Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks. In Proc. ICCV, 2017.
|
| 258 |
+
|
| 259 |
+
<table><tr><td>Sample size</td><td>FFHQ</td><td>LSUN Cat</td></tr><tr><td>5k+5k</td><td>11.65 ± 0.04</td><td>17.38 ± 0.13</td></tr><tr><td>10k+10k</td><td>8.31 ±0.06</td><td>12.42 ± 0.06</td></tr><tr><td>50k + 50k</td><td>5.30 ± 0.04</td><td>8.25 ±0.04</td></tr><tr><td>All + 50k</td><td>5.14 ± 0.04</td><td>7.83 ± 0.03</td></tr></table>
|
| 260 |
+
|
| 261 |
+
(a) Number of samples
|
| 262 |
+
|
| 263 |
+
<table><tr><td></td><td>FFHQ</td><td>LSUN Cat</td></tr><tr><td>TensorFlow</td><td>5.30 ± 0.04</td><td>8.25 ±0.04</td></tr><tr><td>PyTorch</td><td>3.69 ± 0.05</td><td>6.64 ± 0.03</td></tr></table>
|
| 264 |
+
|
| 265 |
+
# (b) Inception-V3 instance
|
| 266 |
+
|
| 267 |
+
Figure 8: FID is very sensitive to (a) the number samples (real $^ +$ generated) and (b) the exact instance of the Inception-V3 network. The tables report the mean $\pm$ standard deviation of FID for a given StyleGAN2 generator over ten evaluations with different random seeds.
|
| 268 |
+
|
| 269 |
+
# A NUMERICAL SENSITIVITY OF FID
|
| 270 |
+
|
| 271 |
+
Previous work has uncovered various details that have a surprisingly large effect on the exact value of FID (Binkowski et al., 2018; Lucic et al., 2018; Parmar et al., 2022; Chong & Forsyth, 2020). These observations are important to acknowledge because reproducing results from comparison methods is not always possible and one might be forced to resort to copying the reported FID results. In that case, even small differences in the FID evaluation protocol might cause erroneous rankings between models.
|
| 272 |
+
|
| 273 |
+
Number of samples and bias. FID depends strongly on the number of samples used in evaluation (Figure 8a). Therefore it is crucial to standardize to a specific number of real and generated samples (Binkowski et al., 2018).
|
| 274 |
+
|
| 275 |
+
Network architecture. FID is also very sensitive to the chosen feature network instance or type. Many deep learning frameworks (e.g. PyTorch (Paszke et al., 2019), Tensorflow (Abadi et al., 2015)) provide their own versions of the Inception-V3 network with distinct weights. Figure 8b shows that FID is surprisingly sensitive to the exact instance of the Inception-V3 network. The discrepancies are certainly large enough to confuse with state-of-the-art performance. In practice, the official Tensorflow network must be used for comparable results.8
|
| 276 |
+
|
| 277 |
+
Lucic et al. (2018) reported that the ranking of models with FID is not sensitive to the selected network architecture – it only has an effect on the absolute value range of FIDs, but the relative ordering of the models remains approximately the same. However, our tests with $\mathrm { F I D } _ { \mathrm { C L I P } }$ indicate that this observation likely holds only between different ImageNet classifier networks.
|
| 278 |
+
|
| 279 |
+
Image processing flaws. Before feeding images to the Inception-V3, they need to be resized to $2 9 9 \times 2 9 9$ resolution. Parmar et al. (2022) noted that the image resize functions of the most commonly used deep learning libraries (Paszke et al., 2019; Abadi et al., 2015) introduce aliasing artifacts due to poor pre-filtering. They demonstrate that this aliasing has a noticeable effect on FID.
|
| 280 |
+
|
| 281 |
+

|
| 282 |
+
Figure 9: We observe nearly perfect correlation between FIDs computed from pre-logit features and classification logits since these two are separated by only one affine transformation. Each point corresponds to a single StyleGAN2 training snapshot in $2 5 6 \times 2 5 6$ resolution.
|
| 283 |
+
|
| 284 |
+

|
| 285 |
+
Figure 10: (a) Adding Gaussian noise to regions that are important for FID (blue curve) leads to the larger increase compared to adding noise in unimportant regions. (b) Image showing regions FID considers as the most important and noise added to different regions at scale 0.05. We recommend zooming in (b) to better assess the noise.
|
| 286 |
+
|
| 287 |
+
# B CORRELATION BETWEEN PRE-LOGITS AND LOGITS FID
|
| 288 |
+
|
| 289 |
+
Figure 9 demonstrates that FIDs calculated from the pre-logits and logits are highly correlated. The high correlation is explained by the fact that these two spaces are separated by only one affine transformation and without any non-linearities. Note that this test is only a guiding experiment to help find out to what FID is sensitive to and it is not guaranteed to hold for different GAN architectures or training setups.
|
| 290 |
+
|
| 291 |
+
# C WHAT DOES FID LOOK AT IN AN IMAGE?
|
| 292 |
+
|
| 293 |
+
Validation of FID sensitivity heatmaps. To validate how reliably our sensitivity heatmaps highlight the most important regions for FID, we perform an additional experiment where we add Gaussian noise to either important or unimportant areas, while keeping the other clean without noise. To cancel out effects that may arise from adding different amounts of noise, measured in pixel area, we divide the pixels of the images equally between the important and unimportant regions.
|
| 294 |
+
|
| 295 |
+
Figure 10a shows FID when we add an increasing amount of Gaussian noise to different regions of the images and Figure 10b demonstrates the appearance of the noisy images. Adding noise everywhere in the image is an upper bound how greatly FID can increase in this test setup. Adding noise to the important regions leads to larger increase in FID, compared to adding noise to the unimportant regions.
|
| 296 |
+
|
| 297 |
+
Additional FID sensitivity heatmaps. Figure 11 presents more FID sensitivity heatmaps for individual StyleGAN2 generated images using FFHQ and LSUN CAT and their corresponding ImageNet Top-1 classifications in the top left corner. For both datasets the regions for which FID is the most sensitive to are highly localized and correlate strongly with the Top-1 class.
|
| 298 |
+
|
| 299 |
+
Figure 12 shows additional mean images and heatmaps for StyleGAN2 generated images for FFHQ that get classified to a certain class. On average FID is the most sensitive to the pixel locations where the Top-1 class is intuitively located and relatively insensitive to the human faces.
|
| 300 |
+
|
| 301 |
+
Comparison to Grad-CAM. Figures 13 and 14 compare our FID sensitivity heatmaps to standard Grad-CAM heatmaps (Selvaraju et al., 2017) for FFHQ and LSUN CAT, respectively. Grad-CAM heatmaps, computed using classification probabilities, highlight similar regions in the images as our FID sensitivity heatmaps, showing that the important regions for ImageNet classification overlap heavily with regions that are important for FID. Additionally, Figure 15 shows mean images and FID heatmaps, as well as mean Top-1 Grad-CAM heatmaps for StyleGAN2 generated FFHQ images.
|
| 302 |
+
|
| 303 |
+

|
| 304 |
+
Figure 11: Heatmaps of the most important regions for FID for StyleGAN2 images in (a) FFHQ and (b) LSUN CAT, along with their Top-1 classification annotated in the top left corner of each image.
|
| 305 |
+
|
| 306 |
+

|
| 307 |
+
Figure 12: Mean images and heatmaps of regions that are the most important for FID with StyleGAN2 images in FFHQ that get classified to some class, e.g., “lipstick”. The heatmaps highlight the regions of Top-1 classes that are typically located outside the face area.
|
| 308 |
+
|
| 309 |
+

|
| 310 |
+
Figure 13: Comparison of our FID sensitivity heatmaps with standard Grad-CAM in FFHQ. The Grad-CAM heatmaps highlight the most important areas for Top-1, Top-2, and Top-3 classification. We also show an average Grad-CAM heatmap weighted according to the classification probabilities.
|
| 311 |
+
|
| 312 |
+

|
| 313 |
+
Figure 14: Comparison of our FID sensitivity heatmaps with standard Grad-CAM in LSUN CAT. The Grad-CAM heatmaps highlight the most important areas for Top-1, Top-2, and Top-3 classification. We also show an average Grad-CAM heatmap weighted according to the classification probabilities.
|
| 314 |
+
|
| 315 |
+

|
| 316 |
+
Figure 15: Top: Average of StyleGAN2-generated FFHQ images whose Top-1 classification matches the given class, e.g., “bow tie”. Middle: Average heatmaps of regions that are the most important for FID. Bottom: Corresponding average Grad-CAM heatmaps computed for the Top-1 class.
|
| 317 |
+
|
| 318 |
+
# D PROBING THE PERCEPTUAL NULL SPACE IN FID
|
| 319 |
+
|
| 320 |
+
Pseudocode and implementation details. Algorithm 1 shows the pseudocode for our resampling method. Function OPTIMIZE-RESAMPLING-WEIGHTS optimizes the per-image sampling weights such that FID between real and weighted generated features is minimized. The inputs to the function are sets of features for real and generated images $ { \boldsymbol { F } } _ { \mathrm { r } }$ and $F _ { \mathrm { g } }$ , respectively, learning rate $\alpha$ and maximum number of iterations $T$ . Note that the features do not have to be the typical pre-logits features where standard FID is calculated; they can be, e.g., logits or binarized class probabilities. First, we calculate the statistics of real features (lines 3-4) and then initialize the per-image logparameterized weights $w _ { i }$ to zeros (line 7). Then, for $T$ iterations we calculate the weighted mean and covariance of generated features (lines 11-12) and update the weights via gradient descent to minimize FID (line 15). After optimization the log-parameterized weights can be transformed into sampling probabilities with $\begin{array} { r } { p _ { i } = \frac { e ^ { w _ { i } } } { \sum _ { j } e ^ { w _ { j } } } } \end{array}$ , where $p _ { i }$ is the probability of sampling ith feature. We sample with replacement according to these probabilities to calculate our resampled FIDs $\mathrm { ( F I D ^ { P L } }$ , FIDL, FIDPLCLIP) with 50k real and generated features.
|
| 321 |
+
|
| 322 |
+
In practice, we use features of $5 0 \mathrm { k }$ real and $2 5 0 \mathrm { k }$ generated images for all datasets, except for AFHQ-V2 DOG where we use 4678 real and $2 5 \mathrm { k }$ generated images. We use learning rate $\alpha = 1 0 . 0$ when optimizing pre-logits features and $\alpha = 5 . 0$ when optimizing logits or binarized class probabilities. We optimize the weights until convergence, which typically requires ${ \sim } 1 0 0 \mathrm { k }$ iterations. We select the weights that lead to the smallest FID with $5 0 \mathrm { k }$ real and $5 0 \mathrm { k }$ generated features that are sampled according to the optimized weights. In the optimization, we do not apply exponential moving average to the weights or learning rate decay. We use 32GB NVIDIA Tesla V100 GPU to run our resampling experiments. One weight optimization run with $5 0 \mathrm { k }$ real and $2 5 0 \mathrm { k }$ generated features takes approximately 48h where most the execution time goes into calculating the matrix square root in FID with eigenvalue decomposition. Code is available at https://github.com/kynkaat/role-of-imagenet-classes-in-fid.
|
| 323 |
+
|
| 324 |
+
Image grids for Top-1 matching and pre-logits resampling. Figure 16 shows uncurated image grids when we sample StyleGAN2 generated images randomly, after Top-1 histogram matching, and after matching all fringe features. Even though FID drops very significantly, the visual appearance of the generated images remains largely unchanged. $\mathrm { F I D } _ { \mathrm { C L I P } }$ also fails to confirm the improvement indicated by FID.
|
| 325 |
+
|
| 326 |
+
In Figure 17, we show a larger set of images that obtain a small or large weight after optimizing FID in the pre-logits feature space. A low FID after resampling cannot be attributed to simply removing images with clear visual artifacts.
|
| 327 |
+
|
| 328 |
+
Effect of pre-logits resampling on KID. Table 3 shows that resampling in the pre-logits feature space also strongly decreases Kernel Inception Distance (KID) (Binkowski et al., 2018), and a Kernel Inception Distance that is calculated using the radial basis function (RBF) kernel (RBF-KID). While the standard KID compares the first three moments (Binkowski et al., 2018), RBF-KID considers all moments, because the RBF kernel is a characteristic kernel (Gretton et al., 2012; Fukumizu et al., 2007). The metrics are computed in the same feature space as FID and therefore we hypothesize that they share approximately the same perceptual null space. To calculate RBF-KID, we used RBF scatter parameter $\textstyle { \dot { \gamma } } = { \frac { 1 } { d } }$ , where $d = 2 0 4 8$ is the dimensionality of Inception-V3 pre-logits. We experimented with different scatter parameter values $( \gamma \in \{ \frac { 1 } { 8 d } , \frac { 1 } { 4 d } , \frac { 1 } { 2 d } , \frac { 1 } { d } , \frac { 2 } { d } , \frac { 4 } { d } , \frac { 8 } { d } \} )$ and observed that they all lead to similar qualitative behavior.
|
| 329 |
+
|
| 330 |
+
Top- $N$ histogram matching. We show further results from approximate Top- $. N$ histogram matching in LSUN CAT/CAR/PLACES and AFHQ-V2 DOG in Figure 18. FID can be consistently improved by aligning the Top- $. N$ histograms of real and generated images. Furthermore, the largest decrease in FID can be obtained by including information of the most probable classes.
|
| 331 |
+
|
| 332 |
+
E PRACTICAL EXAMPLE: IMAGENET PRE-TRAINED GANS
|
| 333 |
+
|
| 334 |
+
Figure 19 shows larger image grids for StyleGAN2 and Projected FastGAN in FFHQ.
|
| 335 |
+
|
| 336 |
+
<table><tr><td>Algorithm1Resamplingalgorithmpseudocode.</td><td></td></tr><tr><td>2: Calculate feature statistics of reals.</td><td>1:function OPTIMIZE-RESAMPLING-WEIGHTS(F.,Fg,α,T)</td></tr><tr><td>3:</td><td>μ←∑ifi</td></tr><tr><td>4:</td><td>Σ←[F-1∑(fi-μ)T (f-μr)</td></tr><tr><td>5:</td><td></td></tr><tr><td>6:</td><td>Initialize log-parameterized per-image weights w to zeros.</td></tr><tr><td>7:</td><td>Wi=O,∀i</td></tr><tr><td>8:</td><td></td></tr><tr><td>9:</td><td>forTiterationsdo Compute weighted mean and covariance of generated features.</td></tr><tr><td>10:</td><td>Mewif</td></tr><tr><td>11:</td><td>μg(w)← ∑iewi</td></tr><tr><td>12:</td><td>∑g(w)← 1 Σiew(f-μg(w))T(f-μg(w)) ewi</td></tr><tr><td>13:</td><td></td></tr><tr><td>14:</td><td>Update the weights.</td></tr><tr><td>15:</td><td>w ←w-αVωFID(μr,Σr,μg(w),Σg(w))</td></tr><tr><td>16:</td><td></td></tr><tr><td>17:</td><td>return w</td></tr></table>
|
| 337 |
+
|
| 338 |
+
Table 3: Optimizing FID also decreases KID and RBF-KID significantly. We compare the KIDs of randomly sampled images (KID, RBF-KID) against KIDs computed by resampling according to the weights obtained from optimizing FID in the pre-logits features $( \mathrm { K I D } ^ { \mathrm { P L } }$ , RBF- ${ \bf K I D } ^ { \mathrm { P L } }$ ). The numbers represent averages over ten evaluations.
|
| 339 |
+
|
| 340 |
+
<table><tr><td>Dataset</td><td>FID</td><td>FIDPL</td><td>KIDx103</td><td>KIDPL×10³</td><td>RBF-KID×10³</td><td>RBF-KIDPL</td><td>×103</td></tr><tr><td>FFHQ</td><td>5.30</td><td>1.78 (-66.4%)</td><td>1.52</td><td>0.19 (-87.5%)</td><td>0.67</td><td>0.08</td><td>(-88.1%)</td></tr><tr><td>LSUN CAT</td><td>8.25</td><td>3.05 (-63.0%)</td><td>3.00</td><td>0.37 (-87.7%)</td><td>1.32</td><td>0.16</td><td>(-87.9%)</td></tr><tr><td>LSUN CAR</td><td>5.65</td><td>2.11 (-62.7%)</td><td>2.49</td><td>0.32 (-87.1%)</td><td>1.19</td><td>0.16</td><td>(-86.6%)</td></tr><tr><td>LSUN PLACES</td><td>12.96</td><td>3.59 (-72.3%)</td><td>7.43</td><td>0.31 (-95.8%)</td><td>3.04</td><td>0.14</td><td>(-95.4%)</td></tr><tr><td>AFHQ-V2 DOG</td><td>10.25</td><td>5.92 (-42.2%)</td><td>2.05</td><td>0.12 (-94.1%)</td><td>1.04</td><td>0.06</td><td>(-94.2%)</td></tr></table>
|
| 341 |
+
|
| 342 |
+

|
| 343 |
+
|
| 344 |
+

|
| 345 |
+
(a) Random sample (FID = 5.30, Recall = 0.46, FIDCLIP = 2.76)
|
| 346 |
+
|
| 347 |
+

|
| 348 |
+
(b) Top-1 matching (FID = 4.70, Recall = 0.45, FIDCLIP = 2.74)
|
| 349 |
+
(c) Pre-logits resampling $\mathrm { ( F I D = 1 } . 7 8$ , Recall $= 0 . 4 0$ , $\mathrm { F I D } _ { \mathrm { C L I P } } = 2 . 6 4 )$
|
| 350 |
+
Figure 16: FID can be drastically reduced by using our resampling approach without improving the visual fidelity of the generated images in any obvious way. (a) Randomly sampled StyleGAN2 images (b) Randomly sampled StyleGAN2 images after Top-1 histogram matching (c) StyleGAN2 images sampled according to the weights obtained by matching all fringe features.
|
| 351 |
+
|
| 352 |
+

|
| 353 |
+
|
| 354 |
+

|
| 355 |
+
(a) Images with small weights
|
| 356 |
+
(b) Images with large weights
|
| 357 |
+
Figure 17: Random StyleGAN2 images sampled among (a) the smallest $1 0 \%$ of weights and (b) the largest $1 0 \%$ of weights. Both sets contain realistic looking images and images with visual artifacts.
|
| 358 |
+
|
| 359 |
+

|
| 360 |
+
Figure 18: Additional results from aligning Top-N class histograms. For all datasets adding information from the Top-N ImageNet classes consistently leads to the largest decrease in FID while $\mathrm { F I D } _ { \mathrm { C L I P } }$ remains almost unchanged.
|
| 361 |
+
|
| 362 |
+

|
| 363 |
+
Figure 19: Uncurated samples of (a) Projected FastGAN and (b) StyleGAN2 generated images. While Projected FastGAN achieves a better FID, the samples contain more distortions and artifacts.
|
md/dev/6at6rB3IZm/6at6rB3IZm.md
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Towards Understanding Grokking: An Effective Theory of Representation Learning
|
| 2 |
+
|
| 3 |
+
Ziming Liu, Ouail Kitouni, Niklas Nolte, Eric J. Michaud, Max Tegmark, Mike Williams Department of Physics, Institute for AI and Fundamental Interactions, MIT {zmliu,kitouni,nnolte,ericjm,tegmark,mwill}@mit.edu
|
| 4 |
+
|
| 5 |
+
# Abstract
|
| 6 |
+
|
| 7 |
+
We aim to understand grokking, a phenomenon where models generalize long after overfitting their training set. We present both a microscopic analysis anchored by an effective theory and a macroscopic analysis of phase diagrams describing learning performance across hyperparameters. We find that generalization originates from structured representations whose training dynamics and dependence on training set size can be predicted by our effective theory in a toy setting. We observe empirically the presence of four learning phases: comprehension, grokking, memorization, and confusion. We find representation learning to occur only in a “Goldilocks zone” (including comprehension and grokking) between memorization and confusion. We find on transformers the grokking phase stays closer to the memorization phase (compared to the comprehension phase), leading to delayed generalization. The Goldilocks phase is reminiscent of “intelligence from starvation” in Darwinian evolution, where resource limitations drive discovery of more efficient solutions. This study not only provides intuitive explanations of the origin of grokking, but also highlights the usefulness of physics-inspired tools, e.g., effective theories and phase diagrams, for understanding deep learning.
|
| 8 |
+
|
| 9 |
+
# 1 Introduction
|
| 10 |
+
|
| 11 |
+
Perhaps the central challenge of a scientific understanding of deep learning lies in accounting for neural network generalization. Power et al. [1] recently added a new puzzle to the task of understanding generalization with their discovery of grokking. Grokking refers to the surprising phenomenon of delayed generalization where neural networks, on certain learning problems, generalize long after overfitting their training set. It is a rare albeit striking phenomenon that violates common machine learning intuitions, raising three key puzzles:
|
| 12 |
+
|
| 13 |
+
Q1 The origin of generalization: When trained on the algorithmic datasets where grokking occurs, how do models generalize at all?
|
| 14 |
+
Q2 The critical training size: Why does the training time needed to “grok” (generalize) diverge as the training set size decreases toward a critical point?
|
| 15 |
+
Q3 Delayed generalization: Under what conditions does delayed generalization occur?
|
| 16 |
+
|
| 17 |
+
We provide evidence that representation learning is central to answering each of these questions. Our answers can be summarized as follows:
|
| 18 |
+
|
| 19 |
+
A1 Generalization can be attributed to learning a good representation of the input embeddings, i.e., a representation that has the appropriate structure for the task and which can be predicted from the theory in Section 3. See Figures 1 and 2.
|
| 20 |
+
A2 The critical training set size corresponds to the least amount of training data that can determine such a representation (which, in some cases, is unique up to linear transformations).
|
| 21 |
+
|
| 22 |
+

|
| 23 |
+
Figure 1: Visualization of the first two principal components of the learned input embeddings at different training stages of a transformer learning modular addition. We observe that generalization coincides with the emergence of structure in the embeddings. See Section 4.2 for the training details.
|
| 24 |
+
|
| 25 |
+
A3 Grokking is a phase between “comprehension” and “memorization” phases and it can be remedied with proper hyperparmeter tuning, as illustrated by the phase diagrams in Figure 6.
|
| 26 |
+
|
| 27 |
+
This paper is organized as follows: In Section 2, we introduce the problem setting and build a simplified toy model. In Section 3, we will use an effective theory approach, a useful tool from theoretical physics, to shed some light on questions Q1 and Q2 and show the relationship between generalization and the learning of structured representations. In Section 4, we explain Q3 by displaying phase diagrams from a grid search of hyperparameters and show how we can “de-delay” generalization by following intuition developed from the phase diagram. We discuss related work in Section 5, followed by conclusions in Section 6.1
|
| 28 |
+
|
| 29 |
+
# 2 Problem Setting
|
| 30 |
+
|
| 31 |
+
Power et al. [1] observe grokking on a less common task – learning “algorithmic” binary operations. Given some binary operation ◦, a network is tasked with learning the map $( a , b ) \mapsto c$ where $c = a \circ b$ . They use a decoder-only transformer to predict the second to last token in a tokenized equation of the form “<lhs> <op> <rhs> <eq> <result> <eos>”. Each token is represented as a 256-dimensional embedding vector. The embeddings are learnable and initialized randomly. After the transformer, a final linear layer maps the output to class logits for each token.
|
| 32 |
+
|
| 33 |
+
Toy Model We primarily study grokking in a simpler toy model, which still retains the key behaviors from the setup of [1]. Although [1] treated this as a classification task, we study both regression (mean-squared error) and classification (cross-entropy). The basic setup is as follows: our model takes as input the symbols $a , b$ and maps them to trainable embedding vectors $\mathbf { E } _ { a } , \mathbf { E } _ { b } \in \mathbb { R } ^ { d _ { \mathrm { i n } } }$ . It then sums $\mathbf { E } _ { a } , \mathbf { E } _ { b }$ and sends the resulting vector through a “decoder” MLP. The target output vector, denoted $\mathbf { Y } _ { c } \in \mathbb { R } ^ { d _ { \mathrm { o u t } } }$ is a fixed random vector (regression task) or a one-hot vector (classification task). Our model architecture can therefore be compactly described as $( a , b ) \mapsto \operatorname { D e c } ( \mathbf { E } _ { a } + \mathbf { E } _ { b } )$ , where the embeddings $\mathbf { E _ { * } }$ and the decoder are trainable. Despite its simplicity, this toy model can generalize to all abelian groups (discussed in Appendix B). In sections 3-4.1, we consider only the binary operation of addition. We consider modular addition in Section 4.2 to generalize some of our results to a transformer architecture and study general non-abelian operations in Appendix H.
|
| 34 |
+
|
| 35 |
+
Dataset In our toy setting, we are concerned with learning the addition operation. A data sample corresponding to $i + j$ is denoted as $( i , j )$ for simplicity. If $i , j \in \{ 0 , \ldots , p - 1 \}$ , there are in total $p ( p + 1 ) / 2$ different samples since we consider $i + j$ and $j + i$ to be the same sample. A dataset $D$ is a set of non-repeating data samples. We denote the full dataset as $D _ { 0 }$ and split it into a training dataset $D$ and a validation dataset $D ^ { \prime }$ , i.e., $D \bigcup D ^ { \prime } = D _ { 0 } , D \bigcap D ^ { \prime } = \emptyset$ . We define training data fraction $= | D | / | D _ { 0 } |$ where $| \cdot |$ denotes the cardinality of the set.
|
| 36 |
+
|
| 37 |
+

|
| 38 |
+
|
| 39 |
+
Figure 2: Visualization of the learned set of embeddings $( p = 1 1 $ ) and the decoder function associated with it for the case of 2D embeddings. Axes refer to each dimension of the learned embeddings. The decoder is evaluated on a grid of points in embedding-space and the color at each point represents the highest probability class. For visualization purposes, the decoder is trained on inputs of the form $( \mathbf { E } _ { i } + \mathbf { \bar { E } } _ { j } ) / 2$ . One can read off the output of the decoder when fed the operation $i \circ j$ from this figure simply by taking the midpoint between the respective embeddings of $i$ and $j$ .
|
| 40 |
+
|
| 41 |
+

|
| 42 |
+
(d) Generalization in toy modular addition
|
| 43 |
+
|
| 44 |
+
# 3 Why Generalization Occurs: Representations and Dynamics
|
| 45 |
+
|
| 46 |
+
We can see that generalization appears to be linked to the emergence of highly-structured embeddings in Figure 2. In particular, Figure 2 (a, b) shows parallelograms in toy addition, and (c, d) shows a circle in toy modular addition. We now restrict ourselves to the toy addition setup and formalize a notion of representation quality and show that it predicts the model’s performance. We then develop a physics-inspired effective theory of learning which can accurately predict the critical training set size and training trajectories of representations. The concept of an effective theory in physics is similar to model reduction in computational methods in that it aims to describe complex phenomena with simple yet intuitive pictures. In our effective theory, we will model the dynamics of representation learning not as gradient descent of the true task loss but rather a simpler effective loss function $\ell _ { \mathrm { e f f } }$ which depends only on the representations in embedding space and not on the decoder.
|
| 47 |
+
|
| 48 |
+
# 3.1 Representation quality predicts generalization for the toy model
|
| 49 |
+
|
| 50 |
+
A rigorous definition for structure in the learned representation is necessary. We propose the following definition,
|
| 51 |
+
|
| 52 |
+
Definition 1. $( i , j , m , n )$ is a $\delta$ -parallelogram in the representation $\mathbf { R } \equiv \left[ \mathbf { E } _ { 0 } , \cdots , \mathbf { E } _ { p - 1 } \right] i f$
|
| 53 |
+
|
| 54 |
+
$$
|
| 55 |
+
| ( \mathbf { E } _ { i } + \mathbf { E } _ { j } ) - ( \mathbf { E } _ { m } + \mathbf { E } _ { n } ) | \leq \delta .
|
| 56 |
+
$$
|
| 57 |
+
|
| 58 |
+
In the following derivations, we can take $\delta$ , which is a small threshold to tolerate numerical errors, to be zero.
|
| 59 |
+
|
| 60 |
+
Proposition 1. When the training loss is zero, any parallelogram $( i , j , m , n )$ in representation R satisfies $i + j = m + n$ .
|
| 61 |
+
|
| 62 |
+
Proof. Suppose that this is not the case, i.e., suppose $\mathbf { E } _ { i } + \mathbf { E } _ { j } = \mathbf { E } _ { m } + \mathbf { E } _ { n }$ but $i + j \neq m + n$ , then $\mathbf { Y } _ { i + j } = \bar { \mathrm { D e c } } ( \mathbf { E } _ { i } + \mathbf { E } _ { j } ) = \mathrm { D e c } ( \mathbf { E } _ { m } + \mathbf { E } _ { n } ) = \bar { \mathbf { Y } } _ { m + n }$ where the first and last equalities come from the zero training loss assumption. However, since $i + j \neq m + n$ , we have $\mathbf { Y } _ { i + j } \neq \mathbf { Y } _ { n + m }$ (almost surely in the regression task), a contradiction. □
|
| 63 |
+
|
| 64 |
+

|
| 65 |
+
Figure 3: We compute accuracy (of the full dataset) either measured empirically Acc, or predicted from the representation of the embeddings $\widehat { \mathrm { A c c } }$ . These two accuracies as a function of training data fraction are plotted in (a)(b), and their agreement is shown in (c).
|
| 66 |
+
|
| 67 |
+
It is convenient to define the permissible parallelogram set associated with a training dataset $D$ (“permissible” means consistent with $100 \%$ training accuracy) as
|
| 68 |
+
|
| 69 |
+
$$
|
| 70 |
+
P _ { 0 } ( D ) = \{ ( i , j , m , n ) | ( i , j ) \in D , ( m , n ) \in D , i + j = m + n \} .
|
| 71 |
+
$$
|
| 72 |
+
|
| 73 |
+
For simplicity, we denote $P _ { 0 } \equiv P _ { 0 } ( D _ { 0 } )$ . Given a representation $\mathbf { R }$ , we can check how many permissible parallelograms actually exist in $\mathbf { R }$ within error $\delta$ , so we define the parallelogram set corresponding to $\mathbf { R }$ as
|
| 74 |
+
|
| 75 |
+
$$
|
| 76 |
+
\begin{array} { r } { P ( \mathbf { R } , \delta ) = \{ ( i , j , m , n ) | ( i , j , m , n ) \in P _ { 0 } , | ( \mathbf { E } _ { i } + \mathbf { E } _ { j } ) - ( \mathbf { E } _ { m } + \mathbf { E } _ { n } ) | \leq \delta \} . } \end{array}
|
| 77 |
+
$$
|
| 78 |
+
|
| 79 |
+
For brevity we will write $P ( \mathbf { R } )$ , suppressing the dependence on $\delta$ . We define the representation quality index (RQI) as
|
| 80 |
+
|
| 81 |
+
$$
|
| 82 |
+
\mathrm { R Q I } ( \mathbf { R } ) = \frac { | P ( \mathbf { R } ) | } { | P _ { 0 } | } \in [ 0 , 1 ] .
|
| 83 |
+
$$
|
| 84 |
+
|
| 85 |
+
We will use the term linear representation or linear structure to refer to a representation whose embeddings are of the form $\mathbf { E } _ { k } = \mathbf { a } + k \mathbf { b } \left( k = 0 , \cdots , p - 1 ; \mathbf { a } , \mathbf { b } \in \mathbb { R } ^ { d _ { \mathrm { i n } } } \right)$ . A linear representation has $\operatorname { R Q I } = 1$ , while a random representation (sampled from, say, a normal dstribution) has $\mathrm { R Q I } = 0$ with high probability.
|
| 86 |
+
|
| 87 |
+
Quantitatively, we denote the “predicted accuracy” $\widehat { \mathrm { A c c } }$ as the accuracy achievable on the whole dataset given the representation $\mathbf { R }$ (see Appendix D for the full details). In Figure 3, we see that the predicted $\widehat { \mathrm { A c c } }$ aligns well with the true accuracy Acc, establishing good evidence that structured representation of input embeddings leads to generalization. We use an example to illustrate the origin of generalization here. In the setup of Figure 2 (b), suppose the decoder can achieve zero training loss and $\mathbf { E } _ { 6 } + \mathbf { E } _ { 8 }$ is a training sample hence $\mathrm { D e c } ( { \bf E } _ { 6 } + { \bf E } _ { 8 } ) = { \bf Y } _ { 1 4 }$ . At validation time, the decoder is tasked with predicting a validation sample $\mathbf { E } _ { 5 } + \mathbf { E } _ { 9 }$ . Since $( 5 , 9 , 6 , 8 )$ forms a parallelogram such that $\mathbf { E } _ { 5 } + \mathbf { E } _ { 9 } = \mathbf { E } _ { 6 } + \mathbf { E } _ { 8 }$ , the decoder can predict the validation sample correctly because $\mathrm { D e c } ( \mathbf { E } _ { 5 } + \mathbf { E } _ { 9 } ) = \mathrm { D e c } ( \mathbf { E } _ { 6 } + \mathbf { E } _ { 8 } ) = \mathbf { Y } _ { 1 4 } ,$ .
|
| 88 |
+
|
| 89 |
+
# 3.2 The dynamics of embedding vectors
|
| 90 |
+
|
| 91 |
+
Suppose that we have an ideal model $\mathcal { M } ^ { * } = ( \mathrm { D e c } ^ { * } , { \bf R } ^ { * } )$ such that:2
|
| 92 |
+
|
| 93 |
+
• (1) ${ \mathfrak { M } } ^ { * }$ can achieve zero training loss;
|
| 94 |
+
• (2) ${ \mathfrak { M } } ^ { * }$ has an injective decoder, i.e., $\mathrm { D e c } ^ { * } ( \mathbf { x } _ { 1 } ) \neq \mathrm { D e c } ^ { * } ( \mathbf { x } _ { 2 } )$ for any $\mathbf { x } _ { 1 } \neq \mathbf { x } _ { 2 }$ .
|
| 95 |
+
|
| 96 |
+
Then Proposition 2 provides a mechanism for the formation of parallelograms.
|
| 97 |
+
|
| 98 |
+

|
| 99 |
+
Figure 4: (a) The effective theory predicts a phase transition in the probability of obtaining a linear representation around $r _ { c } = 0 . 4$ . (b) Empirical results display a phase transition of RQI around $r _ { c } = 0 . 4$ , in agreement with the theory (the blue line shows the median of multiple random seeds). The evolution of 1D representations predicted by the effective theory or obtained from neural network training (shown in (c) and (d) respectively) agree creditably well.
|
| 100 |
+
|
| 101 |
+
Proposition 2. If a training set $D$ contains two samples $( i , j )$ and $( m , n )$ with $i + j = m + n $ then ${ \mathfrak { M } } ^ { * }$ learns a representation $\mathbf { R } ^ { * }$ such that $\mathbf { E } _ { i } + \mathbf { E } _ { j } = \mathbf { E } _ { m } + \mathbf { E } _ { n }$ , i.e., $( i , j , m , n )$ forms $a$ parallelogram.
|
| 102 |
+
|
| 103 |
+
Proof. Due to the zero training loss assumption, we have $\mathrm { D e c } ^ { * } ( \mathbf { E } _ { i } + \mathbf { E } _ { j } ) = \mathbf { Y } _ { i + j } = \mathbf { Y } _ { m + n } =$ $\mathrm { D e c } ^ { * } ( \mathbf { E } _ { m } + \mathbf { E } _ { n } )$ . Then the injectivity of ${ \mathrm { D e c } } ^ { * }$ implies $\mathbf { E } _ { i } + \mathbf { E } _ { j } = \mathbf { E } _ { m } + \mathbf { \bar { E } } _ { n }$ .
|
| 104 |
+
|
| 105 |
+
The dynamics of the trained embedding vectors are determined by various factors interacting in complex ways, for instance: the details of the decoder architecture, the optimizer hyperparameters, and the various kinds of implicit regularization induced by the training procedure. We will see that the dynamics of normalized quantities, namely, the normalized embeddings at time $t$ , defined as $\begin{array} { r } { \tilde { \mathbf { E } } _ { k } ^ { ( t ) } = \frac { \mathbf { E } _ { k } ^ { ( t ) } - \mu _ { t } } { \sigma _ { t } } } \end{array}$ , where $\begin{array} { r } { \mu _ { t } = \frac { 1 } { p } \sum _ { k } \mathbf { E } _ { k } ^ { ( t ) } } \end{array}$ and $\begin{array} { r } { \sigma _ { t } = \frac { 1 } { p } \sum _ { k } | \mathbf { E } _ { k } ^ { ( t ) } - \mu _ { t } | ^ { 2 } } \end{array}$ , can be qualitatively described by a simple effective loss (in the physics effective theory sense). We will assume that the normalized embedding vectors obey a gradient flow for an effective loss function of the form
|
| 106 |
+
|
| 107 |
+
$$
|
| 108 |
+
\frac { d \tilde { \mathbf { E } } _ { i } } { d t } = - \frac { \partial \ell _ { \mathrm { e f f } } } { \partial \tilde { \mathbf { E } } _ { i } } ,
|
| 109 |
+
$$
|
| 110 |
+
|
| 111 |
+
$$
|
| 112 |
+
\ell _ { \mathrm { e f f } } = \frac { \ell _ { 0 } } { Z _ { 0 } } , \quad \ell _ { 0 } \equiv \sum _ { ( i , j , m , n ) \in P _ { 0 } ( D ) } | \tilde { \mathbf { E } } _ { i } + \tilde { \mathbf { E } } _ { j } - \tilde { \mathbf { E } } _ { m } - \tilde { \mathbf { E } } _ { n } | ^ { 2 } / | P _ { 0 } ( D ) | , \quad Z _ { 0 } \equiv \sum _ { k } | \tilde { \mathbf { E } } _ { k } | ^ { 2 } ,
|
| 113 |
+
$$
|
| 114 |
+
|
| 115 |
+
where $| \cdot |$ denotes Euclidean vector norm. Note that the embeddings do not collapse to the trivial solution $\mathbf { E } _ { 0 } = \cdot \cdot \cdot = \mathbf { E } _ { p - 1 } = 0$ unless initialized as such, because two conserved quantities exist, as proven in Appendix F:
|
| 116 |
+
|
| 117 |
+
$$
|
| 118 |
+
\mathbf { C } = \sum _ { k } \mathbf { E } _ { k } , \quad Z _ { 0 } = \sum _ { k } | \mathbf { E } _ { k } | ^ { 2 } .
|
| 119 |
+
$$
|
| 120 |
+
|
| 121 |
+
We shall now use the effective dynamics to explain empirical observations such as the existence of a critical training set size for generalization.
|
| 122 |
+
|
| 123 |
+
Degeneracy of ground states (loss optima) We define ground states as those representations satisfying $\ell _ { \mathrm { e f f } } = 0$ , which requires the following linear equations to hold:
|
| 124 |
+
|
| 125 |
+
$$
|
| 126 |
+
A ( P ) = \{ \mathbf { E } _ { i } + \mathbf { E } _ { j } = \mathbf { E } _ { m } + \mathbf { E } _ { n } | ( i , j , m , n ) \in P \} .
|
| 127 |
+
$$
|
| 128 |
+
|
| 129 |
+
Since each embedding dimension obeys the same set of linear equations, we will assume, without loss of generality, that $d _ { \mathrm { i n } } = 1$ . The dimension of the null space of $A ( P )$ , denoted as $n _ { 0 }$ , is the number of degrees of freedom of the ground states. Given a set of parallelograms implied by a training dataset $D$ , the nullity of $A ( P ( D ) )$ could be obtained by computing the singular values $0 \leq \sigma _ { 1 } \leq \cdot \cdot \cdot \leq \sigma _ { p }$ We always have $n _ { 0 } \geq 2$ , i.e., $\sigma _ { 1 } = \sigma _ { 2 } = 0$ because the nullity of $A ( P _ { 0 } )$ , the set of linear equations given by all possible parallelograms, is $\mathrm { N u l l i t y } ( A ( P _ { 0 } ) ) = 2$ which can be attributed to two degrees of freedom (translation and scaling). If $n _ { 0 } = 2$ , the representation is unique up to translations and scaling factors, and the embeddings have the form $\mathbf { E } _ { k } = \mathbf { a } + k \mathbf { b }$ . Otherwise, when $n _ { 0 } > 2$ , the representation is not constrained enough such that all the embeddings lie on a line.
|
| 130 |
+
|
| 131 |
+
We present theoretical predictions alongside empirical results for addition $\boldsymbol { p } = 1 0 ^ { \circ } ,$ ) in Figure 4. As shown in Figure 4 (a), our effective theory predicts that the probability that the training set implies a unique linear structure (which would result in perfect generalization) depends on the training data fraction and has a phase transition around $r _ { c } = 0 . 4$ . Empirical results from training different models are shown in Figure 4 (b). The number of steps to reach $\mathrm { R Q I } > 0 . 9 5$ is seen to have a phase transition at $r _ { c } = 0 . 4$ , agreeing with the proposed effective theory and with the empirical findings in [1].
|
| 132 |
+
|
| 133 |
+
Time towards the linear structure We define the Hessian matrix of $\ell _ { 0 }$ as
|
| 134 |
+
|
| 135 |
+
$$
|
| 136 |
+
\mathbf { H } _ { i j } = \frac { 1 } { Z _ { 0 } } \frac { \partial ^ { 2 } \ell _ { 0 } } { \partial \mathbf { E } _ { i } \partial \mathbf { E } _ { j } } ,
|
| 137 |
+
$$
|
| 138 |
+
|
| 139 |
+
Note that $\begin{array} { r } { \ell _ { \mathrm { e f f } } = \frac { 1 } { 2 } \mathbf { R } ^ { T } \mathbf { H } \mathbf { R } } \end{array}$ , $\mathbf { R } = [ \mathbf { E } _ { 0 } , \mathbf { E } _ { 1 } , \cdots , \mathbf { E } _ { p - 1 } ]$ , so the gradient descent is linear, i.e.,
|
| 140 |
+
|
| 141 |
+
$$
|
| 142 |
+
\frac { d \mathbf { R } } { d t } = - \mathbf { H } \mathbf { R } .
|
| 143 |
+
$$
|
| 144 |
+
|
| 145 |
+
If $\mathbf { H }$ has eigenvalues $\lambda _ { i } = \sigma _ { i } ^ { 2 }$ (sorted in increasing order) and eigenvectors $\bar { \bf v } _ { i }$ , and we have the initial condition $\begin{array} { r } { { \bf R } ( t = 0 ) = \sum _ { i } a _ { i } { \bar { \bf v } } _ { i } } \end{array}$ , then we have $\begin{array} { r } { { \bf R } ( t ) = \sum _ { i } a _ { i } \bar { \bf v } _ { i } e ^ { - \lambda _ { i } t } } \end{array}$ . The first two eigenvalues vanish and $t _ { h } = 1 / \lambda _ { 3 }$ determines the timescale for the slowest component to decrease by a factor of $e$ . We call $\lambda _ { 3 }$ the grokking rate. When the step size is $\eta$ , the corresponding number of steps is $n _ { h } = t _ { h } / \eta = 1 / ( \lambda _ { 3 } \bar { \eta _ { } } )$ .
|
| 146 |
+
|
| 147 |
+
We verify the above analysis with empirical results. Figure 4 (c)(d) show the trajectories obtained from the effective theory and from neural network training, respectively. The 1D neural representation in Figure 4 (d) are manually normalized to zero mean and unit variance. The two trajectories agree qualitatively, and it takes about $3 n _ { h }$ steps for two trajectories to converge to the linear structure. The quantitative differences might be due to the absence of the decoder in the effective theory, which assumes the decoder to take infinitesimal step sizes.
|
| 148 |
+
|
| 149 |
+
Dependence of grokking on data size Note that $\ell _ { \mathrm { e f f } }$ involves averaging over parallelograms in the training set, it is dependent on training data size, so is $\lambda _ { 3 }$ . In Figure 5 (a), we plot the dependence of $\lambda _ { 3 }$ on training data fraction. There are many datasets with the same data size, so $\lambda _ { 3 }$ is a probabilistic function of data size.
|
| 150 |
+
|
| 151 |
+
Two insights on grokking can be extracted from this plot: (i) When the data fraction is below some threshold (around 0.4), $\lambda _ { 3 }$ is zero with high probability, corresponding to no generalization. This again verifies our critical point in Figure 4. (ii) When data size is above the threshold, $\lambda _ { 3 }$ (on average) is an increasing function of data size. This implies that grokking time $t \sim 1 / \lambda _ { 3 }$ decreases as training data size becomes larger, an important observation from [1].
|
| 152 |
+
|
| 153 |
+
To verify our effective theory, we compare the grokking steps obtained from real neural network training (defined as steps to $\mathrm { R Q I } > 0 . 9 5 $ , and those predicted by our theory $\begin{array} { r } { t _ { \mathrm { t h } } \sim \frac { 1 } { \lambda _ { 3 } \eta } } \end{array}$ $\dot { \eta }$ is the embedding learning rate), shown in Figure 5 (b). The theory agrees qualitatively with neural networks, showing the trend of decreasing grokking steps as increasing data size. The quantitative differences might be explained as the gap between our effective loss and actual loss.
|
| 154 |
+
|
| 155 |
+
Limitations of the effective theory While our theory defines an effective loss based on the Euclidean distance between embeddings $\mathbf { E } _ { i } + \mathbf { E } _ { j }$ and $ { \mathbf { E } } _ { n } + { \mathbf { E } } _ { m }$ , one could imagine generalizing the theory to define a broader notion of parallogram given by some other metric on the representation space. For instance, if we have a decoder like in Figure 2 (d) then the distance between distinct representations within the same “pizza slice” is low, meaning that representations arranged not in parallelograms w.r.t. the Euclidean metric may be parallelograms with respect to the metric defined by the decoder.
|
| 156 |
+
|
| 157 |
+
# 4 Delayed Generalization: A Phase Diagram
|
| 158 |
+
|
| 159 |
+
So far, we have (1) observed empirically that generalization on algorithmic datasets corresponds with the emergence of well-structured representations, (2) defined a notion of representation quality in a toy setting and shown that it predicts generalization, and (3) developed an effective theory to describe the learning dynamics of the representations in the same toy setting. We now study how optimizer hyperparameters affect high-level learning performance. In particular, we develop phase diagrams for how learning performance depends on the representation learning rate, decoder learning rate and the decoder weight decay. These parameters are of interest since they most explicitly regulate a kind of competition between the encoder and decoder, as we elaborate below.
|
| 160 |
+
|
| 161 |
+

|
| 162 |
+
Figure 5: Effective theory explains the dependence of grokking time on data size, for the addition task. (a) Dependence of $\lambda _ { 3 }$ on training data fraction. Above the critical data fraction (around 0.4), as data size becomes larger, $\lambda _ { 3 }$ increases hence grokking time $t \sim 1 / \lambda _ { 3 }$ (predicted by our effective theory) decreases. (b) Comparing grokking steps (defined as $\mathrm { R Q I } > 0 . 9 5 ) ,$ predicted by the effective theory with real neural network results. $\eta = 1 \bar { 0 } ^ { - 3 }$ is the learning rate of the embeddings.
|
| 163 |
+
|
| 164 |
+
# 4.1 Phase diagram of a toy model
|
| 165 |
+
|
| 166 |
+
Training details We update the representation and the decoder with different optimizers. For the 1D embeddings, we use the Adam optimizer with learning rate $[ 1 0 ^ { - 5 } , 1 0 ^ { - 2 } ]$ and zero weight decay. For the decoder, we use an AdamW optimizer with the learning rate in $[ 1 0 ^ { - 5 } , 1 0 ^ { - 2 } ]$ and the weight decay in [0, 10] (regression) or $[ 0 , 2 0 ]$ (classification). For training/validation spliting, we choose 45/10 for non-modular addition $\begin{array} { r } { p = 1 0 , } \end{array}$ ) and 24/12 for the permutation group $S _ { 3 }$ . We hard-code addition or matrix multiplication (details in Appendix H) in the decoder for the addition group and the permutation group, respectively.
|
| 167 |
+
|
| 168 |
+
For each choice of learning rate and weight decay, we compute the number of steps to reach high $( 9 0 \% )$ training/validation accuracy. The 2D plane is split into four phases: comprehension, grokking, memorization and confusion, defined in Table 1 in Appendix A. Both comprehension and grokking are able to generalize (in the “Goldilocks zone”), although the grokking phase has delayed generalization. Memorization is also called overfitting, and confusion means failure to even memorize training data. Figure 6 shows the phase diagrams for the addition group and the permutation group. They display quite rich phenomena.
|
| 169 |
+
|
| 170 |
+
Competition between representation learning and decoder overfitting In the regression setup of the addition dataset, we show how the competition between representation learning and decoder learning (which depend on both learning rate and weight decay, among other things) lead to different learning phases in Figure 6 (a). As expected, a fast decoder coupled with slow representation learning (bottom right) lead to memorization. In the opposite extreme, although an extremely slow decoder coupled with fast representation learning (top left) will generalize in the end, the generalization time is long due to the inefficient decoder training. The ideal phase (comprehension) requires representation learning to be faster, but not too much, than the decoder.
|
| 171 |
+
|
| 172 |
+
Drawing from an analogy to physical systems, one can think of embedding vectors as a group of particles. In our effective theory from Section 3.2, the dynamics of the particles are described only by their relative positions, in that sense, structure forms mainly due to inter-particle interactions (in reality, these interactions are mediated by the decoder and the loss). The decoder plays the role of an environment exerting external forces on the embeddings. If the magnitude of the external forces are small/large one can expect better/worse representations.
|
| 173 |
+
|
| 174 |
+

|
| 175 |
+
Figure 6: Phase diagrams of learning for the addition group and the permutation group. (a) shows the competition between representation and decoder. (b)(c)(d): each phase diagram contains four phases: comprehension, grokking, memorization and confusion, defined in Table 1. In (b)(c)(d), grokking is sandwiched between comprehension and memorization.
|
| 176 |
+
|
| 177 |
+
Universality of phase diagrams We fix the embedding learning rate to be $1 0 ^ { - 3 }$ and sweep instead decoder weight decay in Figure 6 (b)(c)(d). The phase diagrams correspond to addition regression (b), addition classification (c) and permutation regression (d), respectively. Common phenomena emerge from these different tasks: (i) they all include four phases; (ii) The top right corner (a fast and capable decoder) is the memorization phase; (iii) the bottom right corner (a fast and simple decoder) is the confusion phase; (iv) grokking is sandwiched between comprehension and memorization, which seems to imply that it is an undesirable phase that stems from improperly tuned hyperparameters.
|
| 178 |
+
|
| 179 |
+
# 4.2 Beyond the toy model
|
| 180 |
+
|
| 181 |
+
We conjecture that many of the principles which we saw dictate the training dynamics in the toy model also apply more generally. Below, we will see how our framework generalizes to transformer architectures for the task of addition modulo $p$ , a minimal reproducible example of the original grokking paper [1].
|
| 182 |
+
|
| 183 |
+
We first encode $p = 5 3$ integers into 256D learnable embeddings, then pass two integers to a decoderonly transformer architecture. For simplicity, we do not encode the operation symbols here. The outputs from the last layer are concatenated and passed to a linear layer for classification. Training both the encoder and the decoder with the same optimizer (i.e., with the same hyperparameters) leads to the grokking phenomenon. Generalization appears much earlier once we lower the effective decoder capacity with weight decay (full phase diagram in Figure 7).
|
| 184 |
+
|
| 185 |
+
Early on, the model is able to perfectly fit the training set while having no generalization. We study the embeddings at different training times and find that neither PCA (shown in Figure 1) nor t-SNE (not shown here) reveal any structure. Eventually, validation accuracy starts to increase, and perfect generalization coincides with the PCA projecting the embeddings into a circle in 2D. Of course, no choice of dimensionality reduction is guaranteed to find any structure, and thus, it is challenging to show explicitly that generalization only occurs when a structure exists. Nevertheless, the fact that, when coupled with the implicit regularization of the optimizer for sparse solutions, such a clear structure appears in a simple PCA so quickly at generalization time suggests that our analysis in the toy setting is applicable here as well. This is also seen in the evolution of the entropy of the explained variance ratio in the PCA of the embeddings (defined as $\begin{array} { r } { S = - \sum _ { i } \sigma _ { i } \log \sigma _ { i } } \end{array}$ where $\sigma _ { i }$ is the fractional variance explained by the ith principal component). As seen in Figure 7, the entropy increases up to generalization time then decreases drastically afterwards which would be consistent with the conjecture that generalization occurs when a low-dimensional structure is discovered. The decoder then primarily relies on the information in this low-dimensional manifold and essentially “prunes” the rest of the high-dimensional embedding space. Another interesting insight appears when we project the embeddings at initialization onto the principal axes at the end of training. Some of the structure required for generalization exists before training hinting at a connection with the Lottery Ticket Hypothesis. See Appendix K for more details.
|
| 186 |
+
|
| 187 |
+

|
| 188 |
+
Figure 7: Left: Evolution of the effective dimension of the embeddings (defined as the exponential of the entropy) during training and evaluated over 100 seeds. Center: Effect of dropout on speeding up generalization. Right: Phase diagram of the transformer architecture. A scan is performed over the weight decay and learning rate of the decoder while the learning rate of the embeddings is kept fixed at $1 \mathrm { { 0 } ^ { - 3 } }$ (with zero weight decay).
|
| 189 |
+
|
| 190 |
+
In Figure 7 (right), we show a comparable phase diagram to Figure 6 evaluated now in the transformer setting. Note that, as opposed to the setting in [1], weight decay has only been applied to the decoder and not to the embedding layer. Contrary to the toy model, a certain amount of weight decay proves beneficial to generalization and speeds it up significantly. We conjecture that this difference comes from the different embedding dimensions. With a highly over-parameterized setting, a non-zero weight decay gives a crucial incentive to reduce complexity in the decoder and help generalize in fewer steps. This is subject to further investigation. We also explore the effect of dropout layers in the decoder blocks of the transformer. With a significant dropout rate, the generalization time can be brought down to under $1 0 ^ { 3 }$ steps and the grokking phenomenon vanishes completely. The overall trend suggests that constraining the decoder with the same tools used to avoid overfitting reduces generalization time and can avoid the grokking phenomenon. This is also observed in an image classification task where we were able to induce grokking. See Appendix J for more details.
|
| 191 |
+
|
| 192 |
+
# 4.3 Grokking Experiment on MNIST
|
| 193 |
+
|
| 194 |
+
We now demonstrate, for the first time, that grokking (significantly delayed generalization) is a more general phenomenon in machine learning that can occur not only on algorithmic datasets, but also on mainstream benchmark datasets. In particular, we exhibit grokking on MNIST in Figure 8 and demonstrate that we can control grokking by varying optimization hyperparameters. More details on the experimental setup are in Appendix J.
|
| 195 |
+
|
| 196 |
+
# 5 Related work
|
| 197 |
+
|
| 198 |
+
Relatively few works have analyzed the phenomenon of grokking. [2] describe the circuit that transformers use to perform modular addition, track its formation over training, and broadly suggest that grokking is related to the phenomenon of “phase changes” in neural network training. [3, 4] provided earlier speculative, informal conjectures on grokking [3, 4]. Our work is related to the following broad research directions:
|
| 199 |
+
|
| 200 |
+

|
| 201 |
+
Figure 8: Left: Training curves for a run on MNIST, in the setting where we observe grokking. Right: Phase diagram with the four phases of learning dynamics on MNIST.
|
| 202 |
+
|
| 203 |
+
Learning mathematical structures [5] trains a neural network to learn arithmetic operation from pictures of digits, but they do not observe grokking due to their abundant training data. Beyond arithmetic relations, machine learning has been applied to learn other mathematical structures, including geometry [6], knot theory [7] and group theory [8].
|
| 204 |
+
|
| 205 |
+
Double descent Grokking is somewhat reminiscent of the phenomena of “epoch-wise” double descent [9], where generalization can improve after a period of overfitting. [10] find that regularization can mitigate double descent, similar perhaps to how weight decay influences grokking.
|
| 206 |
+
|
| 207 |
+
Representation learning Representation learning lies at the core of machine learning [11–14]. Representation quality is usually measured by (perhaps vague) semantic meanings or performance on downstream tasks. In our study, the simplicity of arithmetic datasets allows us to define representation quality and study evolution of representations in a quantitative way.
|
| 208 |
+
|
| 209 |
+
Physics of learning Physics-inspired tools have proved to be useful in understanding deep learning from a theoretical perspective. These tools include effective theories [15, 16], conservation laws [17] and free energy principle [18]. In addition, statistical physics has been identified as a powerful tool in studying generalization in neural networks [19–22]. Our work connects a low-level understanding of models with their high-level performance. In a recent work, researchers at Anthropic [23], connect a sudden decrease in loss during training with the emergence of induction heads within their models. They analogize their work to statistical physics, since it bridges a “microscopic”, mechanistic understanding of networks with “macroscopic” facts about overall model performance.
|
| 210 |
+
|
| 211 |
+
# 6 Conclusion
|
| 212 |
+
|
| 213 |
+
We have shown how, in both toy models and general settings, that representation enables generalization when it reflects structure in the data. We developed an effective theory of representation learning dynamics (in a toy setting) which predicts the critical dependence of learning on the training data fraction. We then presented four learning phases (comprehension, grokking, memorization and confusion) which depend on the decoder capacity and learning speed (given by, among other things, learning rate and weight decay) in decoder-only architectures. While we have mostly focused on a toy model, we find preliminary evidence that our results generalize to the setting of [1].
|
| 214 |
+
|
| 215 |
+
Our work can be viewed as a step towards a statistical physics of deep learning, connecting the “microphysics” of low-level network dynamics with the “thermodynamics” of high-level model behavior. We view the application of theoretical tools from physics, such as effective theories [24], to be a rich area for further work. The broader impact of such work, if successful, could be to make models more transparent and predictable [23, 25, 26], crucial to the task of ensuring the safety of advanced AI systems.
|
| 216 |
+
|
| 217 |
+
# References
|
| 218 |
+
|
| 219 |
+
[1] Alethea Power, Yuri Burda, Harri Edwards, Igor Babuschkin, and Vedant Misra. Grokking: Generalization beyond overfitting on small algorithmic datasets. arXiv preprint arXiv:2201.02177, 2022.
|
| 220 |
+
[2] Neel Nanda and Tom Lieberum. A mechanistic interpretability analysis of grokking, 2022. URL https://www.alignmentforum.org/posts/N6WM6hs7RQMKDhYjB/ a-mechanistic-interpretability-analysis-of-grokking.
|
| 221 |
+
[3] Beren Millidge. Grokking ’grokking’. https://beren.io/ 2022-01-11-Grokking-Grokking/, 2022.
|
| 222 |
+
[4] Rohin Shah. Alignment Newsletter #159. https: //www.alignmentforum.org/posts/zvWqPmQasssaAWkrj/ an-159-building-agents-that-know-how-to-experiment-by#DEEP_LEARNING_, 2021.
|
| 223 |
+
[5] Yedid Hoshen and Shmuel Peleg. Visual learning of arithmetic operation. In AAAI, 2016.
|
| 224 |
+
[6] Yang-Hui He. Machine-learning mathematical structures. arXiv preprint arXiv:2101.06317, 2021.
|
| 225 |
+
[7] Sergei Gukov, James Halverson, Fabian Ruehle, and Piotr Sułkowski. Learning to unknot. Machine Learning: Science and Technology, 2(2):025035, 2021.
|
| 226 |
+
[8] Alex Davies, Petar Velickovi ˇ c, Lars Buesing, Sam Blackwell, Daniel Zheng, Nenad Tomašev, ´ Richard Tanburn, Peter Battaglia, Charles Blundell, András Juhász, et al. Advancing mathematics by guiding human intuition with ai. Nature, 600(7887):70–74, 2021.
|
| 227 |
+
[9] Preetum Nakkiran, Gal Kaplun, Yamini Bansal, Tristan Yang, Boaz Barak, and Ilya Sutskever. Deep double descent: Where bigger models and more data hurt. Journal of Statistical Mechanics: Theory and Experiment, 2021(12):124003, 2021.
|
| 228 |
+
[10] Preetum Nakkiran, Prayaag Venkat, Sham Kakade, and Tengyu Ma. Optimal regularization can mitigate double descent. arXiv preprint arXiv:2003.01897, 2020.
|
| 229 |
+
[11] Yoshua Bengio, Aaron Courville, and Pascal Vincent. Representation learning: A review and new perspectives. IEEE transactions on pattern analysis and machine intelligence, 35(8): 1798–1828, 2013.
|
| 230 |
+
[12] Yassine Ouali, Céline Hudelot, and Myriam Tami. An overview of deep semi-supervised learning. arXiv preprint arXiv:2006.05278, 2020.
|
| 231 |
+
[13] Jean-Bastien Grill, Florian Strub, Florent Altché, Corentin Tallec, Pierre Richemond, Elena Buchatskaya, Carl Doersch, Bernardo Avila Pires, Zhaohan Guo, Mohammad Gheshlaghi Azar, et al. Bootstrap your own latent-a new approach to self-supervised learning. Advances in Neural Information Processing Systems, 33:21271–21284, 2020.
|
| 232 |
+
[14] Phuc H Le-Khac, Graham Healy, and Alan F Smeaton. Contrastive representation learning: A framework and review. IEEE Access, 8:193907–193934, 2020.
|
| 233 |
+
[15] James Halverson, Anindita Maiti, and Keegan Stoner. Neural networks and quantum field theory. Machine Learning: Science and Technology, 2(3):035002, 2021.
|
| 234 |
+
[16] Daniel A Roberts, Sho Yaida, and Boris Hanin. The principles of deep learning theory. arXiv preprint arXiv:2106.10165, 2021.
|
| 235 |
+
[17] Daniel Kunin, Javier Sagastuy-Brena, Surya Ganguli, Daniel LK Yamins, and Hidenori Tanaka. Neural mechanics: Symmetry and broken conservation laws in deep learning dynamics. arXiv preprint arXiv:2012.04728, 2020.
|
| 236 |
+
[18] Yansong Gao and Pratik Chaudhari. A free-energy principle for representation learning. In International Conference on Machine Learning, pages 3367–3376. PMLR, 2020.
|
| 237 |
+
|
| 238 |
+
[19] Federica Gerace, Bruno Loureiro, Florent Krzakala, Marc Mézard, and Lenka Zdeborová. Generalisation error in learning with random features and the hidden manifold model. In International Conference on Machine Learning, pages 3452–3462. PMLR, 2020.
|
| 239 |
+
|
| 240 |
+
[20] Mohammad Pezeshki, Amartya Mitra, Yoshua Bengio, and Guillaume Lajoie. Multi-scale feature learning dynamics: Insights for double descent. In International Conference on Machine Learning, pages 17669–17690. PMLR, 2022.
|
| 241 |
+
|
| 242 |
+
[21] Sebastian Goldt, Bruno Loureiro, Galen Reeves, Florent Krzakala, Marc Mezard, and Lenka Zdeborova. The gaussian equivalence of generative models for learning with shallow neural networks. In Joan Bruna, Jan Hesthaven, and Lenka Zdeborova, editors, Proceedings of the 2nd Mathematical and Scientific Machine Learning Conference, volume 145 of Proceedings of Machine Learning Research, pages 426–471. PMLR, 16–19 Aug 2022. URL https: //proceedings.mlr.press/v145/goldt22a.html.
|
| 243 |
+
|
| 244 |
+
[22] R Kuhn and S Bos. Statistical mechanics for neural networks with continuous-time dynamics. Journal of Physics A: Mathematical and General, 26(4):831, 1993.
|
| 245 |
+
|
| 246 |
+
[23] Catherine Olsson, Nelson Elhage, Neel Nanda, Nicholas Joseph, Nova DasSarma, Tom Henighan, Ben Mann, Amanda Askell, Yuntao Bai, Anna Chen, Tom Conerly, Dawn Drain, Deep Ganguli, Zac Hatfield-Dodds, Danny Hernandez, Scott Johnston, Andy Jones, Jackson Kernion, Liane Lovitt, Kamal Ndousse, Dario Amodei, Tom Brown, Jack Clark, Jared Kaplan, Sam McCandlish, and Chris Olah. In-context learning and induction heads. Transformer Circuits Thread, 2022. https://transformer-circuits.pub/2022/in-context-learning-and-inductionheads/index.html.
|
| 247 |
+
|
| 248 |
+
[24] Daniel A. Roberts, Sho Yaida, and Boris Hanin. The Principles of Deep Learning Theory. Cambridge University Press, 2022. https://deeplearningtheory.com.
|
| 249 |
+
|
| 250 |
+
[25] Deep Ganguli, Danny Hernandez, Liane Lovitt, Nova DasSarma, Tom Henighan, Andy Jones, Nicholas Joseph, Jackson Kernion, Ben Mann, Amanda Askell, et al. Predictability and surprise in large generative models. arXiv preprint arXiv:2202.07785, 2022.
|
| 251 |
+
|
| 252 |
+
[26] Jacob Steinhardt. Future ML Systems Will Be Qualitatively Different. https://www. lesswrong.com/s/4aARF2ZoBpFZAhbbe/p/pZaPhGg2hmmPwByHc, 2022.
|
| 253 |
+
|
| 254 |
+
[27] Manzil Zaheer, Satwik Kottur, Siamak Ravanbakhsh, Barnabas Poczos, Russ R Salakhutdinov, and Alexander J Smola. Deep sets. Advances in neural information processing systems, 30, 2017.
|
| 255 |
+
|
| 256 |
+
[28] Vardan Papyan, XY Han, and David L Donoho. Prevalence of neural collapse during the terminal phase of deep learning training. Proceedings of the National Academy of Sciences, 117 (40):24652–24663, 2020.
|
| 257 |
+
|
| 258 |
+
[29] Wikipedia contributors. Thomson problem — Wikipedia, the free encyclopedia. https://en.wikipedia.org/w/index.php?title $=$ Thomson_problem&oldid= 1091431454, 2022. [Online; accessed 29-July-2022].
|
| 259 |
+
|
| 260 |
+
[30] Xinlei Chen and Kaiming He. Exploring simple siamese representation learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 15750–15758, 2021.
|
| 261 |
+
|
| 262 |
+
[31] Zhi-Qin John Xu, Yaoyu Zhang, and Yanyang Xiao. Training behavior of deep neural network in frequency domain. In International Conference on Neural Information Processing, pages 264–274. Springer, 2019.
|
| 263 |
+
|
| 264 |
+
[32] Yaoyu Zhang, Zhi-Qin John Xu, Tao Luo, and Zheng Ma. A type of generalization error induced by initialization in deep neural networks. In Mathematical and Scientific Machine Learning, pages 144–164. PMLR, 2020.
|
| 265 |
+
|
| 266 |
+
[33] Ziming Liu, Eric J. Michaud, and Max Tegmark. Omnigrok: Grokking beyond algorithmic data, 2022.
|
| 267 |
+
|
| 268 |
+
[34] Blake Woodworth, Suriya Gunasekar, Jason D. Lee, Edward Moroshko, Pedro Savarese, Itay Golan, Daniel Soudry, and Nathan Srebro. Kernel and rich regimes in overparametrized models. In Jacob Abernethy and Shivani Agarwal, editors, Proceedings of Thirty Third Conference on Learning Theory, volume 125 of Proceedings of Machine Learning Research, pages 3635–3673. PMLR, 09–12 Jul 2020. URL https://proceedings.mlr.press/v125/woodworth20a. html.
|
| 269 |
+
|
| 270 |
+
# Checklist
|
| 271 |
+
|
| 272 |
+
1. For all authors...
|
| 273 |
+
|
| 274 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
|
| 275 |
+
(b) Did you describe the limitations of your work? [Yes]
|
| 276 |
+
(c) Did you discuss any potential negative societal impacts of your work? [N/A]
|
| 277 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 278 |
+
|
| 279 |
+
2. If you are including theoretical results...
|
| 280 |
+
|
| 281 |
+
(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]
|
| 282 |
+
|
| 283 |
+
3. If you ran experiments...
|
| 284 |
+
|
| 285 |
+
(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]
|
| 286 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
|
| 287 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
|
| 288 |
+
(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 were run on a workstation with two NVIDIA A6000 GPUs within a few days.
|
| 289 |
+
|
| 290 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 291 |
+
|
| 292 |
+
(a) If your work uses existing assets, did you cite the creators? [N/A]
|
| 293 |
+
(b) Did you mention the license of the assets? [N/A]
|
| 294 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
|
| 295 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
|
| 296 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
|
| 297 |
+
|
| 298 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 299 |
+
|
| 300 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 301 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 302 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
md/dev/9-umxtNPx5E/9-umxtNPx5E.md
ADDED
|
@@ -0,0 +1,488 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# MASKED FREQUENCY MODELING FOR SELF-SUPERVISED VISUAL PRE-TRAINING
|
| 2 |
+
|
| 3 |
+
Jiahao Xie1,2, Wei $\mathbf { L i } ^ { 1 , 2 }$ , Xiaohang Zhan3, Ziwei ${ \bf L i u ^ { 1 , 2 } }$ , Yew Soon $\mathbf { O n g ^ { 2 , 4 } }$ , Chen Change Loy1,2
|
| 4 |
+
1S-Lab, NTU 2SCSE, NTU 3CUHK 4A\*STAR, Singapore
|
| 5 |
+
{jiahao003, wei.l, ziwei.liu, asysong, ccloy}@ntu.edu.sg
|
| 6 |
+
xiaohangzhan@outlook.com
|
| 7 |
+
|
| 8 |
+
# ABSTRACT
|
| 9 |
+
|
| 10 |
+
We present Masked Frequency Modeling (MFM), a unified frequency-domainbased approach for self-supervised pre-training of visual models. Instead of randomly inserting mask tokens to the input embeddings in the spatial domain, in this paper, we shift the perspective to the frequency domain. Specifically, MFM first masks out a portion of frequency components of the input image and then predicts the missing frequencies on the frequency spectrum. Our key insight is that predicting masked components in the frequency domain is more ideal to reveal underlying image patterns rather than predicting masked patches in the spatial domain, due to the heavy spatial redundancy. Our findings suggest that with the right configuration of mask-and-predict strategy, both the structural information within high-frequency components and the low-level statistics among low-frequency counterparts are useful in learning good representations. For the first time, MFM demonstrates that, for both ViT and CNN, a simple nonSiamese framework can learn meaningful representations even using none of the following: (i) extra data, (ii) extra model, (iii) mask token. Experimental results on image classification and semantic segmentation, as well as several robustness benchmarks show the competitive performance and advanced robustness of MFM compared with recent masked image modeling approaches. Furthermore, we also comprehensively investigate the effectiveness of classical image restoration tasks for representation learning from a unified frequency perspective and reveal their intriguing relations with our MFM approach. Project page: https://www.mmlab-ntu.com/project/mfm/index.html.
|
| 11 |
+
|
| 12 |
+
# 1 INTRODUCTION
|
| 13 |
+
|
| 14 |
+
Following the success of Masked Language Modeling (MLM) such as BERT (Devlin et al., 2019) in natural language processing (NLP), Masked Image Modeling (MIM) (Bao et al., 2022; He et al., 2022; Wei et al., 2022; Xie et al., 2022) has shown promising performance in self-supervised pretraining of visual models. Both MLM and MIM follow a common corrupt-and-predict paradigm – randomly masking a portion of input data and then learning to predict the missing parts. This simple recipe enables modern Transformer-based deep architectures (Vaswani et al., 2017; Dosovitskiy et al., 2020) to learn generalizable representations from ubiquitous unlabeled text or image data.
|
| 15 |
+
|
| 16 |
+
By default, current MIM methods such as BEiT (Bao et al., 2022), MAE (He et al., 2022) and SimMIM (Xie et al., 2022) perform masking in the spatial domain by excluding image patches randomly, a strategy inspired by MLM that performs masking on words (Figure 1(a-b)). However, unlike human-generated language that is succinct and highly semantic, raw pixel values in the spatial domain are of low information density. To cope with heavy spatial redundancy in images, MAE (He et al., 2022) shows that one would need to mask a very high proportion (e.g., $7 5 \%$ ) to encourage the learning of meaningful features.
|
| 17 |
+
|
| 18 |
+
Beyond masking image patches, which is a particular way of corruption, in this paper, we are interested in investigating the effectiveness of other corruption strategies for self-supervised representation learning. We first explore the corruption recipes commonly applied in low-level image processing tasks, including image super-resolution (SR), deblurring and denoising. As shown in
|
| 19 |
+
|
| 20 |
+

|
| 21 |
+
Figure 1: Comparison of masking recipes in Masked Language Modeling (MLM), Masked Image Modeling (MIM), low-level image processing and Masked Frequency Modeling (MFM). Note the differences of masked information among MIM, low-level image processing and MFM.
|
| 22 |
+
|
| 23 |
+
Figure 1(c), the downsampling, blur, and noise operations can degrade the exemplar image effectively in the spatial domain, thus potentially serving as useful corruption strategies. However, the corruption induced in the spatial domain prevents us from analyzing what specific information is corrupted and needs to be reconstructed. To better understand these low-level corruptions, we shift our attention from the spatial image domain to the frequency domain.
|
| 24 |
+
|
| 25 |
+
In the frequency domain, one could observe underlying patterns of an image not conveniently visible from raw pixel values. For example, the downsampling and blur operations dominantly remove the high-frequency image details, while adding noises tends to corrupt the full frequency spectrum of an image globally (Figure 1(c)).
|
| 26 |
+
|
| 27 |
+
Driven by this observation, we present a simple and effective masking strategy in the frequency domain for self-supervised visual representation learning, dubbed as Masked Frequency Modeling (MFM). Specifically, we first perform Fast Fourier Transform (FFT) to convert each input image into its frequency representation, i.e., frequency spectrum. We then mask a portion of frequencies on the frequency spectrum using a low-/high-pass filter. With inverse FFT (iFFT), we finally take the corrupted image with some of the frequencies attenuated as input. Our encoder is quite flexible as no mask tokens are inserted. Thus, MFM can embrace both the vision Transformer (ViT) (Dosovitskiy et al., 2020) and convolutional neural network (CNN) (LeCun et al., 1989) families. Our decoder is a lightweight linear layer that reconstructs the masked frequency values on the frequency spectrum via a frequency loss. As shown in Figure 1(d), an image with low or high frequencies attenuated would reveal entirely different patterns: the low-frequency components usually contain object smooth structure such as colors and styles, while the high-frequency counterparts largely depict the object outline or silhouette structure. Such unique properties of the frequency domain make it appealing for reducing information redundancy, thus creating a nontrivial and meaningful self-supervisory task.
|
| 28 |
+
|
| 29 |
+
Our contributions are summarized as follows:
|
| 30 |
+
|
| 31 |
+
1) We propose a new masked frequency modeling task to pre-train visual encoders in a selfsupervised manner. Our MFM is agnostic to the architectures, and we demonstrate the flexibility of applying MFM for both ViT and CNN families.
|
| 32 |
+
|
| 33 |
+
2) We contribute the first study of low-level corruption tasks for self-supervised learning (SSL) in frequency domain. We investigate the effectiveness of corruption strategies commonly adopted in low-level image processing tasks (i.e., SR, deblurring and denoising) for SSL from a unified frequency perspective and reveal that the representation learning capability of these corruption tasks actually depends on the architectures: they can achieve comparable and even better results than their supervised counterpart on ViT, but no gains are observed on CNN.
|
| 34 |
+
|
| 35 |
+
3) Extensive experiments show that our MFM can achieve competitive performance among existing MIM approaches on downstream tasks, such as image classification and semantic segmentation, while not using mask tokens or other more complex designs. Further analysis on several robustness benchmarks also exhibits more appealing robustness of the studied corruption tasks than MIM.
|
| 36 |
+
|
| 37 |
+
# 2 RELATED WORK
|
| 38 |
+
|
| 39 |
+
Masked language modeling and its auto-regressive variants, such as BERT (Devlin et al., 2019) and GPT (Radford et al., 2018; 2019; Brown et al., 2020), have achieved great success in pretraining large-scale language models in the NLP community. These approaches perform masking on the human-generated language by holding out random words and then predicting the missing content. This simple mask-word recipe has shown excellent ability in pre-training generalizable representations for broad NLP applications.
|
| 40 |
+
|
| 41 |
+
Masked image modeling leverages images corrupted by masking to learn useful representations. Pioneered with stacked autoencoders (Vincent et al., 2010) and context encoders (Pathak et al., 2016) using CNNs, recent approaches (Bao et al., 2022; He et al., 2022; Xie et al., 2022; Wei et al., 2022; Chen et al., 2022) follow the mask-word strategy in NLP to randomly mask image patches in the spatial domain using the vision Transformers (Dosovitskiy et al., 2020; Liu et al., 2021). Along with this mask-patch strategy, different types of prediction targets have been studied, including discrete tokens (Bao et al., 2022; Dong et al., 2021), raw pixels (He et al., 2022; Xie et al., 2022), and handcrafted features (Wei et al., 2022). Besides, iGPT (Chen et al., 2020a) takes a low-resolution image sequence as input and predicts missing pixels in an auto-regressive manner. Several methods (Zhou et al., 2022; El-Nouby et al., 2021) also integrate MIM into contrastive-based Siamese frameworks. Our work differs from previous approaches in that we perform masking in the frequency domain, which relies on none of the following: (i) extra data (Bao et al., 2022; Dong et al., 2021; Fang et al., 2022), (ii) extra model (Zhou et al., 2022; El-Nouby et al., 2021; Fang et al., 2022; Shi et al., 2022; Chen et al., 2022), or (iii) mask token (Bao et al., 2022; He et al., 2022; Xie et al., 2022; Wei et al., 2022; Chen et al., 2022). CIM (Fang et al., 2022) also does not use mask token. However, introducing an auxiliary generator to corrupt the input images adds nontrivial pre-training overhead. In contrast, our frequency-domain-based corruption strategy can achieve comparable performance with negligible computational cost.
|
| 42 |
+
|
| 43 |
+
Self-supervised learning mainly focuses on designing effective pretext tasks for pre-training (Doersch et al., 2015; Wang & Gupta, 2015; Noroozi & Favaro, 2016; Larsson et al., 2016; Zhang et al., 2016; 2017c; Noroozi et al., 2017; Bojanowski & Joulin, 2017; Pathak et al., 2017; Gidaris et al., 2018). Contrastive learning (Wu et al., 2018; He et al., 2020; Misra & Maaten, 2020; Chen et al., 2020b;c; Grill et al., 2020; Chen & He, 2021; Chen et al., 2021; Caron et al., 2021) has dominated the field over the past few years. Unlike the mask-and-predict pretext task, contrastive learning typically uses a Siamese framework and greatly relies on data augmentation.
|
| 44 |
+
|
| 45 |
+
Low-level image processing tasks, such as image super-resolution (Dong et al., 2015), deblurring (Zhang et al., 2022) and denoising (Zhang et al., 2017b), focus on restoring the high-fidelity image from its corrupted input. The corrupted images are usually generated with degradation transformations, which consist of downsampling, blur, noise and JPEG compression. Recent promising results of MIM motivate us to investigate the effectiveness of these corruption operations in the context of representation learning.
|
| 46 |
+
|
| 47 |
+
Frequency domain analysis has been widely adopted in many computer vision tasks, such as image generation (Jiang et al., 2021), domain adaptation (Xu et al., 2021), and image superresolution (Pang et al., 2020). Early studies (Oppenheim et al., 1979; Oppenheim & Lim, 1981; Piotrowski & Campbell, 1982; Hansen & Hess, 2007) have revealed that in the frequency domain, the phase component largely captures high-level semantics of the original signals, while the amplitude component mainly retains low-level statistics. As such, underlying image patterns can be more conveniently observed in the frequency representation, compared with the raw pixel values in the spatial domain. Motivated by the intriguing properties of the Fourier domain, we propose a novel mask-frequency recipe and conduct the first study w.r.t. masked information modeling in the frequency domain for image data.
|
| 48 |
+
|
| 49 |
+
# 3 APPROACH
|
| 50 |
+
|
| 51 |
+
Our masked frequency modeling (MFM) is a simple yet effective self-supervised pre-training approach, which masks out a portion of image frequency components and predicts the missing frequencies on the frequency spectrum. Figure 2 shows the overview of our approach. The framework consists of four components: masking strategy, encoder, decoder, and reconstruction target. We first detail each component of MFM in Section 3.1, and then discuss the relation of our approach with low-level image processing tasks in Section 3.2.
|
| 52 |
+
|
| 53 |
+

|
| 54 |
+
Figure 2: Overview of our MFM pre-training pipeline. We convert each input image into frequency domain via FFT and mask a portion of frequencies on the frequency spectrum via a low-pass (top) or high-pass (bottom) filter. After iFFT, the low-/high-pass filtered spatial images are then randomly fed to the encoder (e.g., ViT, CNN), with a lightweight one-layer head to predict the masked frequency values on the frequency spectrum via a frequency loss. The red circle denotes the selected mask radius, and the dice icon refers to the random sampling process of low-/high-pass filters, following a Bernoulli distribution.
|
| 55 |
+
|
| 56 |
+
# 3.1 MASKED FREQUENCY MODELING
|
| 57 |
+
|
| 58 |
+
Preliminary: Frequency representation of images. Given a single channel image1 x ∈ RH×W , we can obtain the corresponding frequency representation via 2D Discrete Fourier Transform $\mathcal { F } \left( x \right)$ :
|
| 59 |
+
|
| 60 |
+
$$
|
| 61 |
+
\mathcal { F } \left( x \right) \left( u , v \right) = \sum _ { h = 0 } ^ { H - 1 } \sum _ { w = 0 } ^ { W - 1 } x \left( h , w \right) e ^ { - i 2 \pi \left( \frac { u h } { H } + \frac { v w } { W } \right) } ,
|
| 62 |
+
$$
|
| 63 |
+
|
| 64 |
+
where $x \left( h , w \right)$ is the real pixel value at the coordinate of $( h , w )$ on the spatial image, $\mathcal { F } \left( \boldsymbol { x } \right) \left( u , v \right)$ is the complex frequency value at the coordinate of $( u , v )$ on the frequency spectrum, $e$ and $i$ are Euler’s number and the imaginary unit, respectively. Accordingly, ${ \mathcal { F } } ^ { { \bar { - } } 1 } \left( x \right)$ defines the inverse Fourier transform that maps spectral signals back into original image space. Both the Fourier transform and its inverse can be calculated efficiently using the FFT algorithm (Nussbaumer, 1981).
|
| 65 |
+
|
| 66 |
+
Masking strategy. We define a mask $M \in \{ 0 , 1 \} ^ { H \times W }$ , whose value is determined by a thresholding function that separates the low and high frequency components from $\mathcal { F } \left( x \right)$ according to a hyper-parameter, i.e., radius $r$ :
|
| 67 |
+
|
| 68 |
+
$$
|
| 69 |
+
M \left( u , v \right) = \left\{ \begin{array} { l l } { 1 , \mathrm { ~ i f ~ } d \left( \left( u , v \right) , \left( c _ { h } , c _ { w } \right) \right) < r } \\ { 0 , \mathrm { ~ o t h e r w i s e } } \end{array} \right.
|
| 70 |
+
$$
|
| 71 |
+
|
| 72 |
+
where $\left( { { c _ { h } } , { c _ { w } } } \right)$ denotes the center of the image, $d \left( \cdot , \cdot \right)$ denotes a certain distance criterion. Here, we use the Euclidean distance, i.e., a circle mask as default. Note that the mask shape is not solely restricted to a circle one, and we study the effects of different mask shapes in the experiment section.
|
| 73 |
+
|
| 74 |
+
With the predefined mask $M$ , we can easily obtain the decomposed low-pass filtered image $x _ { l }$ and the high-pass filtered counterpart $x _ { h }$ as follows:
|
| 75 |
+
|
| 76 |
+
$$
|
| 77 |
+
x _ { l } = \mathcal { F } ^ { - 1 } \left( \mathcal { F } \left( \boldsymbol { x } \right) \odot \boldsymbol { M } \right) , \quad x _ { h } = \mathcal { F } ^ { - 1 } \left( \mathcal { F } \left( \boldsymbol { x } \right) \odot \left( \mathbb { 1 } - \boldsymbol { M } \right) \right) ,
|
| 78 |
+
$$
|
| 79 |
+
|
| 80 |
+
where $\mathbb { 1 }$ is the all-ones matrix, $\odot$ is the Hadamard product between matrices. These filtered images are then randomly selected with a Bernoulli distribution and fed to an encoder as input2.
|
| 81 |
+
|
| 82 |
+
MFM encoder. The architecture of our encoder is quite flexible since we do not insert any mask tokens on the corrupted non-overlapping patch embeddings as in MIM (Bao et al., 2022; He et al., 2022; Xie et al., 2022; Wei et al., 2022). Therefore, our MFM can be applied on both ViT and CNN architectures without any special designs. In this paper, we mainly use a standard ViT (Dosovitskiy et al., 2020) as our encoder for a direct comparison with MIM methods. Specifically, we first divide a filtered spatial image into regular non-overlapping patches. Then, the encoder embeds the patches by linear projection with added positional embeddings. The combined embeddings are then processed via a series of self-attention-based Transformer blocks (Vaswani et al., 2017). We also consider a typical CNN architecture, i.e., ResNet-50 (He et al., 2016), to demonstrate the versatility of MFM. To this end, we simply send the filtered spatial image to the CNN encoder as input.
|
| 83 |
+
|
| 84 |
+
MFM decoder. The decoder accomplishes the frequency reconstruction task. It can be of arbitrary form as long as its input is compatible with the encoder’s output. Here, we simply adopt a lightweight linear layer as our decoder for efficiency, after which we perform FFT to convert each output image into the frequency domain for frequency reconstruction. The effect of different decoders is further studied in Appendix A.
|
| 85 |
+
|
| 86 |
+
Reconstruction target. Our MFM reconstructs the input by predicting the missing frequency values on the frequency spectrum. To faithfully recover the frequency values, we should define a frequency distance metric that considers both amplitude and phase as a loss function. Regarding each frequency value $\mathcal { F } \left( \boldsymbol { x } \right) \left( u , v \right)$ as a two-dimensional Euclidean vector $\bar { f }$ , one can easily derive that the magnitude of the vector corresponds to the amplitude while the angle corresponds to the phase. Inspired by Jiang et al. (2021), we thus define the frequency distance $\mathcal { D } \left( \cdot , \cdot \right)$ as the distance between the reconstructed vector $\vec { f _ { r } }$ and the original vector $\vec { f _ { o } }$ at each spectrum coordinate $( u , v )$ :
|
| 87 |
+
|
| 88 |
+
$$
|
| 89 |
+
\begin{array} { r l } & { \mathcal { D } \left( \vec { f } _ { r } , \vec { f } _ { o } \right) = \left\| \vec { f } _ { r } - \vec { f } _ { o } \right\| _ { 2 } ^ { \gamma } = \left| \mathcal { F } _ { r } \left( x \right) \left( u , v \right) - \mathcal { F } _ { o } \left( x \right) \left( u , v \right) \right| ^ { \gamma } } \\ & { \quad \quad \quad = \left( \left( \mathcal { R } _ { r } \left( x \right) \left( u , v \right) - \mathcal { R } _ { o } \left( x \right) \left( u , v \right) \right) ^ { 2 } + \left( \mathcal { T } _ { r } \left( x \right) \left( u , v \right) - \mathcal { T } _ { o } \left( x \right) \left( u , v \right) \right) ^ { 2 } \right) ^ { \gamma / 2 } , } \end{array}
|
| 90 |
+
$$
|
| 91 |
+
|
| 92 |
+
where $\mathcal { R } ( x )$ and $\mathcal { T } ( x )$ are the real and imaginary part of $\mathcal { F } ( x )$ , respectively, $\gamma$ is an exponent to control the sharpness of the distance function and is set to 1 by default. For each image, the final loss function, $i . e .$ , the average frequency distance of all spectrum positions can thus be written as:
|
| 93 |
+
|
| 94 |
+
$$
|
| 95 |
+
\mathcal { L } = \mathcal { D } \left( \mathcal { F } _ { r } \left( x \right) , \mathcal { F } _ { o } \left( x \right) \right) = \frac { 1 } { H W } \sum _ { u = 0 } ^ { H - 1 } \sum _ { v = 0 } ^ { W - 1 } \left| \mathcal { F } _ { r } \left( x \right) \left( u , v \right) - \mathcal { F } _ { o } \left( x \right) \left( u , v \right) \right| ^ { \gamma } .
|
| 96 |
+
$$
|
| 97 |
+
|
| 98 |
+
In practice, we compute the loss only on the masked area of the frequency spectrum instead of the full spectrum as the latter tends to decrease the accuracy according to our experiments.
|
| 99 |
+
|
| 100 |
+
# 3.2 RELATION WITH LOW-LEVEL IMAGE PROCESSING TASKS
|
| 101 |
+
|
| 102 |
+
The notion of recovering masked frequency components in MFM is reminiscent to the objectives in low-level image processing tasks, such as image super-resolution (SR), deblurring and denoising. In these tasks, a model takes a degraded image as input, and the aim is to restore the missing components. Different degradations corrupt different components in the frequency domain. As discussed in Section 1, for the image SR and deblurring tasks, most of the high-frequency components are removed while the low-frequency counterparts are retained; for the image denoising task, both lowand high-frequencies are significantly altered.
|
| 103 |
+
|
| 104 |
+
By analyzing the frequency spectrum of these tasks, we can observe how different frequencies of an image contribute to visual representation learning, thus gaining better insights on designing more effective learning objectives. Compared with these tasks, MFM provides a more general and unified frequency perspective to perform these low-level corruptions while being conceptually simpler: we directly remove certain frequencies on the frequency spectrum via a low-/high-pass filter. Our experiments show that MFM can achieve better performance than these tasks for representation learning. We will comprehensively study these tasks and show more details in the experiment section.
|
| 105 |
+
|
| 106 |
+
# 4 EXPERIMENTS
|
| 107 |
+
|
| 108 |
+
# 4.1 IMPLEMENTATION DETAILS
|
| 109 |
+
|
| 110 |
+
We use the vanilla ViT-Small (ViT-S/16), ViT-Base (ViT-B/16) and ResNet-50 models as the backbones in our study. We perform self-supervised pre-training on the ImageNet-1K (Deng et al., 2009) training set without labels. For ViT, our pre-training setting generally follows BEiT (Bao et al., 2022), while we only use random resized cropping $2 2 4 \times 2 2 4$ resolution) and flipping as data
|
| 111 |
+
|
| 112 |
+
Table 1: Ablations for MFM with ViT-B/16 on ImageNet-1K. All models are based on 300-epoch pre-training, and we report top-1 fine-tuning accuracy. Unless specified, the default settings are: the mask type is random (i.e., random sampling of low-/high-pass filters), the mask radius is 16, the mask shape is circle, the sampling ratio for low-pass filters is $50 \%$ (i.e., $50 \%$ for low-pass filters and $50 \%$ for high-pass counterparts), the reconstruction target is masked frequencies on the spectrum, and the loss function is a frequency loss with $\gamma = 1$ . Default entry is marked in gray .
|
| 113 |
+
|
| 114 |
+
(a) Mask type. Random sampling of both filters works the best.
|
| 115 |
+
|
| 116 |
+
(b) Mask radius. Using a fixed radius is enough.
|
| 117 |
+
|
| 118 |
+
<table><tr><td>Mask radius</td><td>Top-1 acc (%)</td></tr><tr><td>8</td><td>82.8</td></tr><tr><td>16</td><td>83.1</td></tr><tr><td>24</td><td>82.7</td></tr><tr><td>32</td><td>82.6</td></tr><tr><td>[8,24]</td><td>83.0</td></tr></table>
|
| 119 |
+
|
| 120 |
+
(c) Mask shape. A circle mask is more accurate.
|
| 121 |
+
|
| 122 |
+
<table><tr><td>Mask shape</td><td>Top-1 acc (%)</td></tr><tr><td>circle</td><td>83.1</td></tr><tr><td>square</td><td>82.9</td></tr><tr><td>rhombus</td><td>82.8</td></tr></table>
|
| 123 |
+
|
| 124 |
+
(e) Reconstruction target. Predicting only the masked frequencies yields better performance.
|
| 125 |
+
|
| 126 |
+
<table><tr><td>Mask type</td><td>Top-1 acc (%)</td></tr><tr><td>none</td><td>76.5</td></tr><tr><td>low-pass</td><td>82.4</td></tr><tr><td>high-pass</td><td>82.3</td></tr><tr><td>random</td><td>83.1</td></tr></table>
|
| 127 |
+
|
| 128 |
+
(d) Sampling ratio. Sampling low-/high-pass filters with an equal probability is effective.
|
| 129 |
+
|
| 130 |
+
(f) Loss function. A frequency loss works better than spatial loss.
|
| 131 |
+
|
| 132 |
+
<table><tr><td>Loss</td><td>Top-1 acc (%)</td></tr><tr><td>freq. (γ = 1)</td><td>83.1</td></tr><tr><td>freq.(γ = 2)</td><td>82.5</td></tr><tr><td>l1</td><td>82.3</td></tr><tr><td>l</td><td>82.2</td></tr></table>
|
| 133 |
+
|
| 134 |
+
<table><tr><td>Sampling ratio</td><td>Top-1 acc (%)</td></tr><tr><td>0.3</td><td>82.5</td></tr><tr><td>0.5</td><td>83.1</td></tr><tr><td>0.7</td><td>82.7</td></tr></table>
|
| 135 |
+
|
| 136 |
+
<table><tr><td>Reconstruction target</td><td>Top-1 acc (%)</td></tr><tr><td>masked spectrum</td><td>83.1</td></tr><tr><td>full spectrum</td><td>82.4</td></tr></table>
|
| 137 |
+
|
| 138 |
+
augmentation, with dropout and stochastic depth not applied. We also do not use relative position or layer scaling. After pre-training, we conduct supervised end-to-end fine-tuning on ImageNet-1K image classification and ADE20K (Zhou et al., 2017) semantic segmentation to evaluate the quality of learned representations, following BEiT (Bao et al., 2022). For ResNet-50, we adopt the same pre-training configuration as that in ViT without further parameter tuning. We provide the detailed pre-training and fine-tuning recipes in Appendix G.
|
| 139 |
+
|
| 140 |
+
# 4.2 MAIN PROPERTIES
|
| 141 |
+
|
| 142 |
+
We start by ablating our MFM using ViT-B/16 as the default backbone. All experiments are conducted with 300-epoch pre-training and 100-epoch fine-tuning on the ImageNet-1K dataset unless otherwise specified. Several intriguing properties are observed.
|
| 143 |
+
|
| 144 |
+
Masking strategy. We first study different masking strategies on the frequency spectrum. We consider two kinds of filters: low-pass filter (i.e., mask high frequencies), and high-pass filter (i.e., mask low frequencies). As shown in Table 1a, masking and predicting either high frequencies (“lowpass” entry) or low frequencies (“high-pass” entry) perform significantly better than simply encoding and reconstructing the original image (“none” entry). This indicates that both high-frequency and low-frequency components are useful in representation learning, where the former largely depicts the object structure information such as outline or silhouette and the latter usually captures low-level statistics such as colors and styles. A random variant, i.e., randomly selecting one filter from both low-pass and high-pass filters (“random” entry), benefits from all lens of frequencies, thus further improving the performance.
|
| 145 |
+
|
| 146 |
+
Mask radius. Table 1b studies the effect of mask radius, which controls the difficulty of our task. A larger radius leaves more frequencies for a low-pass filter while removes more frequencies for a high-pass filter. MFM works the best with a moderate difficulty. Using a fixed radius (e.g., 16) performs slightly better than a random one, i.e., the radius is uniformly sampled within a range (e.g., [8, 24]).
|
| 147 |
+
|
| 148 |
+
Mask shape. We study three centrosymmetric mask shapes in Table 1c. Different mask shapes focus on different masking directions. Take low-pass filter as an example, a square shape removes more frequencies in the horizontal and vertical direction, while a rhombus one removes more in the diagonal direction. The results demonstrate that a circle mask shape that pays an equal attention to each direction on the frequency spectrum performs the best. We hypothesize that the effect of different mask shapes is largely correlated with the category statistics of pre-training datasets.
|
| 149 |
+
|
| 150 |
+
Table 2: Comparison of SR, deblurring, denoising and MFM tasks with ViT-B/16 on ImageNet1K. All models are pre-trained for 300 epochs, and evaluated with top-1 fine-tuning accuracy. Corrupted image samples from ImageNet-1K training set with different degradation levels are visualized in both image and frequency domain. The studied hyper-parameter that controls the difficulty of degradation for each task is (a) downsampling scale factor, (b) Gaussian blur sigma, (c) Gaussian noise sigma, and (d) mask radius, respectively. More examples are provided in Appendix H. Zoom in for best view.
|
| 151 |
+
|
| 152 |
+
<table><tr><td>Task</td><td>Parameter</td><td>Top-l acc (%)</td></tr><tr><td rowspan="5">(a)SR</td><td>×2</td><td>82.1</td></tr><tr><td>×4</td><td>82.2</td></tr><tr><td>×8</td><td>82.4</td></tr><tr><td>×16</td><td>82.1</td></tr><tr><td>1</td><td>79.7</td></tr><tr><td rowspan="4">(b)Deblur</td><td>3</td><td>81.2</td></tr><tr><td>5</td><td>81.7</td></tr><tr><td>7</td><td>81.5</td></tr><tr><td></td><td></td></tr><tr><td rowspan="4">(c) Denoise</td><td>25</td><td>82.4</td></tr><tr><td>50</td><td>82.6</td></tr><tr><td>75</td><td>82.7</td></tr><tr><td>100</td><td>82.6</td></tr><tr><td rowspan="4">(d)MFM</td><td>8</td><td>82.8</td></tr><tr><td>16</td><td>83.1</td></tr><tr><td>24</td><td>82.7</td></tr><tr><td>32</td><td>82.6</td></tr></table>
|
| 153 |
+
|
| 154 |
+

|
| 155 |
+
|
| 156 |
+
Sampling ratio. Table 1d ablates different sampling ratios for low-/high-pass filters. Here, the sampling ratio denotes the probability of sampling a low-pass filter, following a Bernoulli distribution. The results show that simply sampling both filters with an equal probability works the best.
|
| 157 |
+
|
| 158 |
+
Reconstruction target. Table 1e compares two reconstruction targets: 1) predicting only the masked frequencies on the frequency spectrum as in our default setting, and 2) recovering both the masked and unmasked frequencies on the frequency spectrum. Predicting the masked spectrum performs better than reconstructing the full spectrum by a clear margin $8 3 . 1 \%$ vs. $8 2 . 4 \%$ . This suggests that predicting the invisible signals is a more favourable task in representation learning, which is in accordance with the observation in recent MIM approaches.
|
| 159 |
+
|
| 160 |
+
Loss function. Table 1f studies the design of loss functions. A frequency loss (freq.) performs better than a spatial loss $( \ell _ { 1 } , \ell _ { 2 } )$ , with $\gamma = 1$ working the best. It makes sense as directly predicting the missing frequencies in the frequency domain better aligns to our MFM task.
|
| 161 |
+
|
| 162 |
+
# 4.3 DIAGNOSIS OF LOW-LEVEL IMAGE PROCESSING TASKS
|
| 163 |
+
|
| 164 |
+
In this subsection, we study the representation learning capability of low-level image processing tasks from a unified frequency perspective. We examine three representative tasks: image superresolution (SR), deblurring, and denoising.
|
| 165 |
+
|
| 166 |
+
Setup. To ensure a direct comparison, we adopt the same pre-training and fine-tuning hyperparameters as MFM and only alter the types of image degradation during pre-training. Specifically, for the SR task, we first use its standard data pre-processing, i.e., bicubic downsampling, to downsample the input images by a scale factor. We then upsample them back to the original input size, i.e., $2 2 4 \times 2 2 4$ . For the deblurring task, we consider the commonly-used isotropic Gaussian filter and uniformly select the blur kernel size from $\{ 7 , 9 , 1 1 , 1 3 , 1 5 , 1 7 , 1 9 , 2 1 \}$ as suggested in Wang et al. (2021). For the denoising task, we employ the typical Gaussian noise. The intensity of both deblurring and denoising tasks is controlled by the standard deviation (i.e., sigma value) of the Gaussian distribution. For all tasks, the reconstruction target is the original image but in the frequency domain via the same frequency loss as MFM.
|
| 167 |
+
|
| 168 |
+
Observations. Table 2 shows the results with different levels of degradation for each task. We first notice that the optimal degradation level of each task in the context of representation learning is much heavier than its original task setting. For instance, a standard SR task usually has a downsampling factor within $\times 4$ , while we show that a much heavier $\times 8$ setting works the best. With right configuration of the task difficulty, all these tasks can achieve comparable or even better performance than their supervised counterpart (e.g., $8 1 . 8 \%$ in Touvron et al. (2021a)), indicating that these low-level tasks are more or less helpful in representation learning. In addition, we observe that representation learning benefits from all lens of frequencies. This can be verified by the superior performance of denoising over SR and deblurring. As visualized in the frequency spectrum of the example image, denoising tends to intensify all frequencies of the spectrum, while SR and deblurring only removes high-frequency components. Thus, the performance of denoising is much closer to MFM, as both utilize the full frequency spectrum. Attenuating and intensifying frequencies on the spectrum are essentially two different ways of performing corruption in the frequency domain. We believe other corruption types may also work well and leave this exploration for future work.
|
| 169 |
+
|
| 170 |
+
# 4.4 COMPARISON WITH PREVIOUS METHODS
|
| 171 |
+
|
| 172 |
+
# 4.4.1 IMAGE CLASSIFICATION
|
| 173 |
+
|
| 174 |
+
Table 3: ImageNet-1K top-1 fine-tuning accuracy of self-supervised models using ViT-S/16 and ViT-B/16 as the encoder. DINO and MoCo v3 use extra momentum encoder. BEiT requires extra 250M DALL-E data (Ramesh et al., 2021) to pre-train dVAE. BEiT and MAE also use mask tokens (inserted either in the encoder or the decoder). All entries are on an image size of $2 2 4 \times 2 2 4$ . We use the actual processed images/views to measure the effective pre-training epochs (Zhou et al., 2022). Scratch indicates the supervised baseline in Touvron et al. (2021a). †: doubled attention heads. ‡: our reproduced results with official code.
|
| 175 |
+
|
| 176 |
+
<table><tr><td>Method</td><td>Pre-train data</td><td>Extra model</td><td>Mask token</td><td>Epochs</td><td>ViT-S</td><td>ViT-B</td></tr><tr><td>Scratch (Touvron et al.,2021a)</td><td>=</td><td>=</td><td>-</td><td>-</td><td>79.9</td><td>81.8</td></tr><tr><td>MoCo v3 (Chen et al.,2021)</td><td>IN-1K</td><td>momentum ViT</td><td></td><td>600</td><td>81.4+</td><td>83.2</td></tr><tr><td>DINO (Caron et al.,2021)</td><td>IN-1K</td><td>momentum ViT</td><td>=</td><td>1600</td><td>81.5</td><td>82.8</td></tr><tr><td>BEiT (Bao et al.,2022)</td><td>IN-1K+DALL-E</td><td>dVAE</td><td>√</td><td>300</td><td>81.3</td><td>82.9</td></tr><tr><td>MAE (He et al.,2022)</td><td>IN-1K</td><td>-</td><td>√</td><td>300</td><td>80.6</td><td>82.9</td></tr><tr><td>SR</td><td>IN-1K</td><td></td><td></td><td>300</td><td>80.8</td><td>82.4</td></tr><tr><td>Deblur</td><td>IN-1K</td><td></td><td></td><td>300</td><td>79.4</td><td>81.7</td></tr><tr><td>Denoise</td><td>IN-1K</td><td></td><td></td><td>300</td><td>81.1</td><td>82.7</td></tr><tr><td>MFM</td><td>IN-1K</td><td></td><td></td><td>300</td><td>81.6</td><td>83.1</td></tr></table>
|
| 177 |
+
|
| 178 |
+
Table 4: ImageNet-1K top-1 fine-tuning accuracy of self-supervised models using ResNet-50 as the encoder. Table is split to three sub-tables for better placement. Results for other methods are taken from Fang et al. (2022) as we adopt the same fine-tuning recipe. †: modified ResNet-50 architecture.
|
| 179 |
+
|
| 180 |
+
(a) Training-from-scratch baselines.
|
| 181 |
+
|
| 182 |
+
(b) Fine-tuning for 100 epochs.
|
| 183 |
+
|
| 184 |
+
<table><tr><td>Method</td><td>Epochs</td><td>Top-1 acc (%)</td></tr><tr><td>RSB A3</td><td>-</td><td>78.1</td></tr><tr><td>SR</td><td>300</td><td>77.9</td></tr><tr><td>Deblur</td><td>300</td><td>78.0</td></tr><tr><td>Denoise</td><td>300</td><td>77.5</td></tr><tr><td>MFM</td><td>300</td><td>78.5</td></tr></table>
|
| 185 |
+
|
| 186 |
+
<table><tr><td>Method</td><td>Epochs</td><td>Top-1 acc (%)</td></tr><tr><td>Original90</td><td>=</td><td>75.3</td></tr><tr><td>PyTorch90</td><td></td><td>76.1</td></tr><tr><td>FixReS120</td><td></td><td>77.0</td></tr><tr><td>DeiT300</td><td></td><td>78.4</td></tr><tr><td></td><td></td><td>78.8</td></tr><tr><td>FAMS400</td><td></td><td>79.5</td></tr></table>
|
| 187 |
+
|
| 188 |
+
<table><tr><td colspan="3">(c) Fine-tuning for 300 epochs.</td></tr><tr><td>Method</td><td>Epochs</td><td>Top-1 acc (%)</td></tr><tr><td>RSB A2</td><td>-</td><td>79.8</td></tr><tr><td>SimSiam</td><td>400</td><td>79.1</td></tr><tr><td>MoCo v2</td><td>400</td><td>79.6</td></tr><tr><td>SimCLR</td><td>800</td><td>79.9</td></tr><tr><td>BYOL</td><td>400</td><td>80.0</td></tr><tr><td>SwAV</td><td>600</td><td>80.1</td></tr><tr><td>MFM</td><td>300</td><td>80.1</td></tr></table>
|
| 189 |
+
|
| 190 |
+
ViT. In Table 3, we compare the ImageNet-1K end-to-end fine-tuning results of self-supervised ViTS/16 and ViT-B/16 models. We fine-tune ViT-S/16 for 200 epochs, and ViT-B/16 for 100 epochs. Other self-supervised models use the same or longer fine-tuning schedule. Compared with other representative self-supervised learners, our MFM can achieve comparable performance with fewer pre-training epochs while using none of the following: (i) extra data, (ii) extra model, (iii) mask token. This demonstrates the great potential of masked frequency modeling.
|
| 191 |
+
|
| 192 |
+
ResNet-50. We demonstrate that MFM can also pre-train a high-capacity ResNet-50 model. We simply adopt the same pre-training settings as ViT. During fine-tuning, we generally follow the advanced vanilla ResNet “training from scratch” recipe in RSB (Wightman et al., 2021) except that we use the AdamW optimizer (Loshchilov & Hutter, 2017) following Fang et al. (2022). Table 4 shows the results. Different from ViT, we observe performance degeneration of low-level image processing tasks like SR, deblurring and denoising compared with the RSB training-from-scratch baseline (Table 4b). We hypothesize this discrepancy is due to the architectural difference between ViT and CNN. Compared with ViT, the convolution operation in CNN tends to be more effective in capturing high-frequency components. Thus, encouraging a CNN model to reconstruct high-frequency components of images brings no benefits to the performance. Instead, learning high-frequency information can compensate for the ability of ViT models in capturing the high-frequency components. In contrast, our MFM outperforms its supervised counterparts in both ViT and CNN architectures as it leverages both low- and high-frequency components. Even under a demanding training procedure, e.g., fine-tuning for 300 epochs (Table 4c), MFM can still improve the supervised RSB A2 baseline by $0 . 3 \%$ and surpass several representative contrastive-based self-supervised learning methods.
|
| 193 |
+
|
| 194 |
+
# 4.4.2 SEMANTIC SEGMENTATION
|
| 195 |
+
|
| 196 |
+
We evaluate MFM and low-level image processing tasks on the ADE20K semantic segmentation benchmark. We use UperNet (Xiao et al., 2018) and adopt the same setup following BEiT (Bao et al., 2022). All models are fine-tuned for 160K iterations with an input resolution of $5 1 2 \times 5 1 2$ . As shown in Table 5, our corruption-based models can achieve competitive performance compared with other representative self-supervised learners that are usually more expensive to compute.
|
| 197 |
+
|
| 198 |
+
Table 5: ADE20K semantic segmentation (mIoU) of ViT-B/16 models.
|
| 199 |
+
|
| 200 |
+
<table><tr><td>Method</td><td>mIoU</td></tr><tr><td>Supervised (Touvron et al.,2021a)</td><td>45.3</td></tr><tr><td>MoCo v3 (Chen et al.,2021) DINO (Caron et al.,2021)</td><td>47.2 46.8</td></tr><tr><td>BEiT (Bao et al.,2022) MAE (He et al., 2022)</td><td>47.7 48.1</td></tr><tr><td>SR</td><td>48.5</td></tr><tr><td>Deblur Denoise</td><td>47.0</td></tr><tr><td>MFM</td><td>47.6 48.6</td></tr></table>
|
| 201 |
+
|
| 202 |
+
Table 6: Robustness evaluation on six robustness benchmarks. We report top-1 accuracy of ViTB/16 (left) and ResNet-50 (right) models except for IN-C that uses the mean corruption error (mCE). The original ImageNet top-1 fine-tuning results are also appended for reference. The best results are in bold, and the second best results are underlined.
|
| 203 |
+
|
| 204 |
+
<table><tr><td rowspan="2">Method</td><td colspan="6">Robustness benchmarks</td><td rowspan="2">Orig.</td></tr><tr><td>FGSM</td><td>PGD</td><td>IN-C (↓)</td><td>IN-A</td><td>IN-R</td><td>IN-SK</td></tr><tr><td>Scratch</td><td>46.3</td><td>21.2</td><td>48.5</td><td>28.1</td><td>44.7</td><td>32.0</td><td>81.8</td></tr><tr><td>MAE</td><td>38.9</td><td>11.2</td><td>52.3</td><td>31.5</td><td>48.3</td><td>33.8</td><td>82.9</td></tr><tr><td>SR</td><td>46.1</td><td>21.5</td><td>46.3</td><td>29.1</td><td>49.2</td><td>35.5</td><td>82.4</td></tr><tr><td>Deblur</td><td>42.5</td><td>17.2</td><td>49.2</td><td>25.3</td><td>46.9</td><td>33.2</td><td>81.7</td></tr><tr><td>Denoise</td><td>47.6</td><td>24.3</td><td>47.8</td><td>30.7</td><td>48.4</td><td>34.8</td><td>82.7</td></tr><tr><td>MFM</td><td>47.7</td><td>24.4</td><td>47.5</td><td>32.7</td><td>48.6</td><td>34.8</td><td>83.1</td></tr></table>
|
| 205 |
+
|
| 206 |
+
<table><tr><td rowspan="2">Method</td><td colspan="6">Robustness benchmarks</td><td rowspan="2">Orig.</td></tr><tr><td>FGSM</td><td>PGD</td><td>IN-C (↓)</td><td>IN-A</td><td>IN-R</td><td>IN-SK</td></tr><tr><td>Scratch</td><td>20.2</td><td>3.4</td><td>77.0</td><td>6.6</td><td>36.0</td><td>25.0</td><td>78.1</td></tr><tr><td>SimMIM</td><td>16.8</td><td>2.1</td><td>77.0</td><td>5.7</td><td>34.9</td><td>24.2</td><td>77.7</td></tr><tr><td>SR</td><td>17.2</td><td>1.9</td><td>73.6</td><td>6.5</td><td>35.8</td><td>25.4</td><td>77.9</td></tr><tr><td>Deblur</td><td>17.2</td><td>2.0</td><td>74.8</td><td>8.2</td><td>37.2</td><td>26.5</td><td>78.0</td></tr><tr><td>Denoise</td><td>15.8</td><td>1.8</td><td>78.0</td><td>7.2</td><td>35.6</td><td>24.7</td><td>77.5</td></tr><tr><td>MFM</td><td>18.5</td><td>2.3</td><td>74.2</td><td>9.0</td><td>36.9</td><td>26.7</td><td>78.5</td></tr></table>
|
| 207 |
+
|
| 208 |
+
# 4.5 ROBUSTNESS EVALUATION
|
| 209 |
+
|
| 210 |
+
We evaluate the robustness of our models on a series of benchmarks in three aspects: (i) adversarial robustness, (ii) common corruption robustness, and (iii) out-of-distribution robustness. For (i), we study the adversarial examples generated by white-box attackers (e.g., FGSM (Goodfellow et al., 2014) and PGD (Madry et al., 2017)) on ImageNet-1K validation set as well as natural adversarial examples on ImageNet-A (Hendrycks et al., 2021b); for (ii), we evaluate on ImageNet-C (Hendrycks & Dietterich, 2019) that includes 15 types of algorithmically generated corruptions with five levels of severity; for (iii), we test on ImageNet-R (Hendrycks et al., 2021a) and ImageNet-Sketch (Wang et al., 2019) that contain images with naturally occurring distribution shifts. We evaluate the same models fine-tuned on original ImageNet-1K (ViT-B/16 in Table 3 and ResNet-50 in Table 4b) without any specialized fine-tuning on the different validation sets. As shown in Table 6, we can conclude three observations: 1) Transformer-based models (e.g., ViT) are more robust than the CNN counterparts (e.g., ResNet-50). 2) Corruption-based tasks (e.g., SR, Deblur, Denoise and MFM) are generally more robust than the MIM task (e.g., MAE and SimMIM). 3) MFM achieves the best trade-off between standard performance and robustness (the robustness of MFM always ranks within the top two, while the standard accuracy is the best).
|
| 211 |
+
|
| 212 |
+
# 5 CONCLUSION
|
| 213 |
+
|
| 214 |
+
In this work, we have studied the effectiveness of low-level image processing tasks for visual representation learning from a new frequency perspective and introduced a unified, flexible and robust self-supervised visual pre-training framework to perform image corruptions in the frequency domain. We show that without relying on mask tokens or more complex designs (e.g., discrete visual tokens), a simple mask-frequency strategy can achieve competitive performance for both ViT and CNN. We hope our unique frequency perspective can motivate the community to rethink the role of low-level tasks for unsupervised representation learning.
|
| 215 |
+
|
| 216 |
+
# ETHICS STATEMENT
|
| 217 |
+
|
| 218 |
+
The proposed method learns statistics of the training dataset and may reflect the biases in the data. Debiased measures thus have to be taken. The method may be deployed with large-scale models and data, causing negative impacts on the environment.
|
| 219 |
+
|
| 220 |
+
# REPRODUCIBILITY STATEMENT
|
| 221 |
+
|
| 222 |
+
We provide detailed hyper-parameter specifications for our experiments in the main text (Section 4) and the supplementary material (Appendix G) to ensure reproducibility. Code and models will be released at https://www.mmlab-ntu.com/project/mfm/index.html to facilitate future research.
|
| 223 |
+
|
| 224 |
+
# ACKNOWLEDGEMENTS
|
| 225 |
+
|
| 226 |
+
This work is supported by NTU NAP, MOE AcRF Tier 2 (MOE-T2EP20120-0001, MOET2EP20221-0012), and under the RIE2020 Industry Alignment Fund – Industry Collaboration Projects (IAF-ICP) Funding Initiative, as well as cash and in-kind contribution from the industry partner(s).
|
| 227 |
+
|
| 228 |
+
# REFERENCES
|
| 229 |
+
|
| 230 |
+
Mahmoud Assran, Mathilde Caron, Ishan Misra, Piotr Bojanowski, Florian Bordes, Pascal Vincent, Armand Joulin, Michael Rabbat, and Nicolas Ballas. Masked siamese networks for label-efficient learning. arXiv preprint arXiv:2204.07141, 2022.
|
| 231 |
+
|
| 232 |
+
Alexei Baevski, Wei-Ning Hsu, Qiantong Xu, Arun Babu, Jiatao Gu, and Michael Auli. Data2vec: A general framework for self-supervised learning in speech, vision and language. arXiv preprint arXiv:2202.03555, 2022.
|
| 233 |
+
|
| 234 |
+
Hangbo Bao, Li Dong, Songhao Piao, and Furu Wei. Beit: Bert pre-training of image transformers. In ICLR, 2022.
|
| 235 |
+
|
| 236 |
+
Maxim Berman, Herve J ´ egou, Andrea Vedaldi, Iasonas Kokkinos, and Matthijs Douze. Multigrain:´ a unified image embedding for classes and instances. arXiv preprint arXiv:1902.05509, 2019.
|
| 237 |
+
|
| 238 |
+
Piotr Bojanowski and Armand Joulin. Unsupervised learning by predicting noise. In ICML, 2017.
|
| 239 |
+
|
| 240 |
+
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.
|
| 241 |
+
|
| 242 |
+
Mathilde Caron, Hugo Touvron, Ishan Misra, Herve J ´ egou, Julien Mairal, Piotr Bojanowski, and ´ Armand Joulin. Emerging properties in self-supervised vision transformers. In ICCV, 2021.
|
| 243 |
+
|
| 244 |
+
Mark Chen, Alec Radford, Rewon Child, Jeffrey Wu, Heewoo Jun, David Luan, and Ilya Sutskever. Generative pretraining from pixels. In ICML, 2020a.
|
| 245 |
+
|
| 246 |
+
Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. In ICML, 2020b.
|
| 247 |
+
|
| 248 |
+
Xiaokang Chen, Mingyu Ding, Xiaodi Wang, Ying Xin, Shentong Mo, Yunhao Wang, Shumin Han, Ping Luo, Gang Zeng, and Jingdong Wang. Context autoencoder for self-supervised representation learning. arXiv preprint arXiv:2202.03026, 2022.
|
| 249 |
+
|
| 250 |
+
Xinlei Chen and Kaiming He. Exploring simple siamese representation learning. In CVPR, 2021.
|
| 251 |
+
|
| 252 |
+
Xinlei Chen, Haoqi Fan, Ross Girshick, and Kaiming He. Improved baselines with momentum contrastive learning. arXiv preprint arXiv:2003.04297, 2020c.
|
| 253 |
+
|
| 254 |
+
Xinlei Chen, Saining Xie, and Kaiming He. An empirical study of training self-supervised vision transformers. In ICCV, 2021.
|
| 255 |
+
|
| 256 |
+
Kevin Clark, Minh-Thang Luong, Quoc V Le, and Christopher D Manning. Electra: Pre-training text encoders as discriminators rather than generators. arXiv preprint arXiv:2003.10555, 2020.
|
| 257 |
+
|
| 258 |
+
Ekin D Cubuk, Barret Zoph, Jonathon Shlens, and Quoc V Le. Randaugment: Practical automated data augmentation with a reduced search space. In CVPRW, 2020.
|
| 259 |
+
|
| 260 |
+
Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In CVPR, 2009.
|
| 261 |
+
|
| 262 |
+
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In NAACL, 2019.
|
| 263 |
+
|
| 264 |
+
Carl Doersch, Abhinav Gupta, and Alexei A Efros. Unsupervised visual representation learning by context prediction. In ICCV, 2015.
|
| 265 |
+
|
| 266 |
+
Chao Dong, Chen Change Loy, Kaiming He, and Xiaoou Tang. Image super-resolution using deep convolutional networks. TPAMI, 2015.
|
| 267 |
+
|
| 268 |
+
Xiaoyi Dong, Jianmin Bao, Ting Zhang, Dongdong Chen, Weiming Zhang, Lu Yuan, Dong Chen, Fang Wen, and Nenghai Yu. Peco: Perceptual codebook for bert pre-training of vision transformers. arXiv preprint arXiv:2111.12710, 2021.
|
| 269 |
+
|
| 270 |
+
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, 2020.
|
| 271 |
+
|
| 272 |
+
Alaaeldin El-Nouby, Gautier Izacard, Hugo Touvron, Ivan Laptev, Herve Jegou, and Edouard ´ Grave. Are large-scale datasets necessary for self-supervised pre-training? arXiv preprint arXiv:2112.10740, 2021.
|
| 273 |
+
|
| 274 |
+
Yuxin Fang, Li Dong, Hangbo Bao, Xinggang Wang, and Furu Wei. Corrupted image modeling for self-supervised visual pre-training. arXiv preprint arXiv:2202.03382, 2022.
|
| 275 |
+
|
| 276 |
+
Spyros Gidaris, Praveer Singh, and Nikos Komodakis. Unsupervised representation learning by predicting image rotations. In ICLR, 2018.
|
| 277 |
+
|
| 278 |
+
Ian J Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. arXiv preprint arXiv:1412.6572, 2014.
|
| 279 |
+
|
| 280 |
+
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. In NeurIPS, 2020.
|
| 281 |
+
|
| 282 |
+
Bruce C Hansen and Robert F Hess. Structural sparseness and spatial phase alignment in natural scenes. JOSA A, 2007.
|
| 283 |
+
|
| 284 |
+
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, 2016.
|
| 285 |
+
|
| 286 |
+
Kaiming He, Haoqi Fan, Yuxin Wu, Saining Xie, and Ross Girshick. Momentum contrast for unsupervised visual representation learning. In CVPR, 2020.
|
| 287 |
+
|
| 288 |
+
Kaiming He, Xinlei Chen, Saining Xie, Yanghao Li, Piotr Dollar, and Ross Girshick. Masked ´ autoencoders are scalable vision learners. In CVPR, 2022.
|
| 289 |
+
|
| 290 |
+
Dan Hendrycks and Thomas Dietterich. Benchmarking neural network robustness to common corruptions and perturbations. arXiv preprint arXiv:1903.12261, 2019.
|
| 291 |
+
|
| 292 |
+
Dan Hendrycks, Steven Basart, Norman Mu, Saurav Kadavath, Frank Wang, Evan Dorundo, Rahul Desai, Tyler Zhu, Samyak Parajuli, Mike Guo, et al. The many faces of robustness: A critical analysis of out-of-distribution generalization. In ICCV, 2021a.
|
| 293 |
+
|
| 294 |
+
Dan Hendrycks, Kevin Zhao, Steven Basart, Jacob Steinhardt, and Dawn Song. Natural adversarial examples. In CVPR, 2021b.
|
| 295 |
+
|
| 296 |
+
Elad Hoffer, Tal Ben-Nun, Itay Hubara, Niv Giladi, Torsten Hoefler, and Daniel Soudry. Augment your batch: better training with larger batches. arXiv preprint arXiv:1901.09335, 2019.
|
| 297 |
+
|
| 298 |
+
Gao Huang, Yu Sun, Zhuang Liu, Daniel Sedra, and Kilian Q Weinberger. Deep networks with stochastic depth. In ECCV, 2016.
|
| 299 |
+
|
| 300 |
+
Liming Jiang, Bo Dai, Wayne Wu, and Chen Change Loy. Focal frequency loss for image reconstruction and synthesis. In ICCV, 2021.
|
| 301 |
+
|
| 302 |
+
Gustav Larsson, Michael Maire, and Gregory Shakhnarovich. Learning representations for automatic colorization. In ECCV, 2016.
|
| 303 |
+
|
| 304 |
+
Yann LeCun, Bernhard Boser, John S Denker, Donnie Henderson, Richard E Howard, Wayne Hubbard, and Lawrence D Jackel. Backpropagation applied to handwritten zip code recognition. Neural computation, 1989.
|
| 305 |
+
|
| 306 |
+
Hao Liu, Xinghua Jiang, Xin Li, Antai Guo, Deqiang Jiang, and Bo Ren. The devil is in the frequency: Geminated gestalt autoencoder for self-supervised visual pre-training. arXiv preprint arXiv:2204.08227, 2022.
|
| 307 |
+
|
| 308 |
+
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 ICCV, 2021.
|
| 309 |
+
|
| 310 |
+
Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017.
|
| 311 |
+
|
| 312 |
+
Aleksander Madry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras, and Adrian Vladu. Towards deep learning models resistant to adversarial attacks. arXiv preprint arXiv:1706.06083, 2017.
|
| 313 |
+
|
| 314 |
+
Ishan Misra and Laurens van der Maaten. Self-supervised learning of pretext-invariant representations. In CVPR, 2020.
|
| 315 |
+
|
| 316 |
+
Mehdi Noroozi and Paolo Favaro. Unsupervised learning of visual representations by solving jigsaw puzzles. In ECCV, 2016.
|
| 317 |
+
|
| 318 |
+
Mehdi Noroozi, Hamed Pirsiavash, and Paolo Favaro. Representation learning by learning to count. In ICCV, 2017.
|
| 319 |
+
|
| 320 |
+
Henri J Nussbaumer. The fast fourier transform. In Fast Fourier Transform and Convolution Algorithms, pp. 80–111. Springer, 1981.
|
| 321 |
+
|
| 322 |
+
A Oppenheim, Jae Lim, Gary Kopec, and SC Pohlig. Phase in speech and pictures. In ICASSP, 1979.
|
| 323 |
+
|
| 324 |
+
Alan V Oppenheim and Jae S Lim. The importance of phase in signals. Proc. IEEE, 1981.
|
| 325 |
+
|
| 326 |
+
Yingxue Pang, Xin Li, Xin Jin, Yaojun Wu, Jianzhao Liu, Sen Liu, and Zhibo Chen. Fan: frequency aggregation network for real image super-resolution. In ECCV, 2020.
|
| 327 |
+
|
| 328 |
+
Deepak Pathak, Philipp Krahenbuhl, Jeff Donahue, Trevor Darrell, and Alexei A Efros. Context encoders: Feature learning by inpainting. In CVPR, 2016.
|
| 329 |
+
|
| 330 |
+
Deepak Pathak, Ross Girshick, Piotr Dollar, Trevor Darrell, and Bharath Hariharan. Learning fea-´ tures by watching objects move. In CVPR, 2017.
|
| 331 |
+
|
| 332 |
+
Leon N Piotrowski and Fergus W Campbell. A demonstration of the visual importance and flexibility of spatial-frequency amplitude and phase. Perception, 1982.
|
| 333 |
+
|
| 334 |
+
Yada Pruksachatkun, Jason Phang, Haokun Liu, Phu Mon Htut, Xiaoyi Zhang, Richard Yuanzhe Pang, Clara Vania, Katharina Kann, and Samuel R Bowman. Intermediate-task transfer learning with pretrained models for natural language understanding: When and why does it work? In ACL, 2020.
|
| 335 |
+
|
| 336 |
+
Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving language understanding by generative pre-training. 2018.
|
| 337 |
+
|
| 338 |
+
Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. Language models are unsupervised multitask learners. OpenAI blog, 2019.
|
| 339 |
+
|
| 340 |
+
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, 2021.
|
| 341 |
+
|
| 342 |
+
Yuge Shi, N Siddharth, Philip Torr, and Adam R Kosiorek. Adversarial masking for self-supervised learning. In ICML, 2022.
|
| 343 |
+
|
| 344 |
+
Nitish Srivastava, Geoffrey Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. Dropout: a simple way to prevent neural networks from overfitting. JMLR, 2014.
|
| 345 |
+
|
| 346 |
+
Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In CVPR, 2016.
|
| 347 |
+
|
| 348 |
+
Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Herve J ´ egou. Training data-efficient image transformers & distillation through attention. In ´ ICML, 2021a.
|
| 349 |
+
|
| 350 |
+
Hugo Touvron, Matthieu Cord, Alexandre Sablayrolles, Gabriel Synnaeve, and Herve J ´ egou. Going ´ deeper with image transformers. In ICCV, 2021b.
|
| 351 |
+
|
| 352 |
+
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.
|
| 353 |
+
|
| 354 |
+
Pascal Vincent, Hugo Larochelle, Isabelle Lajoie, Yoshua Bengio, Pierre-Antoine Manzagol, and Leon Bottou. Stacked denoising autoencoders: Learning useful representations in a deep network ´ with a local denoising criterion. JMLR, 2010.
|
| 355 |
+
|
| 356 |
+
Haohan Wang, Songwei Ge, Zachary Lipton, and Eric P Xing. Learning robust global representations by penalizing local predictive power. In NeurIPS, 2019.
|
| 357 |
+
|
| 358 |
+
Xiaolong Wang and Abhinav Gupta. Unsupervised learning of visual representations using videos. In ICCV, 2015.
|
| 359 |
+
|
| 360 |
+
Xintao Wang, Liangbin Xie, Chao Dong, and Ying Shan. Real-esrgan: Training real-world blind super-resolution with pure synthetic data. In ICCVW, 2021.
|
| 361 |
+
|
| 362 |
+
Chen Wei, Haoqi Fan, Saining Xie, Chao-Yuan Wu, Alan Yuille, and Christoph Feichtenhofer. Masked feature prediction for self-supervised visual pre-training. In CVPR, 2022.
|
| 363 |
+
|
| 364 |
+
Ross Wightman, Hugo Touvron, and Herve J ´ egou. Resnet strikes back: An improved training ´ procedure in timm. arXiv preprint arXiv:2110.00476, 2021.
|
| 365 |
+
|
| 366 |
+
Zhirong Wu, Yuanjun Xiong, Stella X Yu, and Dahua Lin. Unsupervised feature learning via nonparametric instance discrimination. In CVPR, 2018.
|
| 367 |
+
|
| 368 |
+
Tete Xiao, Yingcheng Liu, Bolei Zhou, Yuning Jiang, and Jian Sun. Unified perceptual parsing for scene understanding. In ECCV, 2018.
|
| 369 |
+
|
| 370 |
+
Zhenda Xie, Zheng Zhang, Yue Cao, Yutong Lin, Jianmin Bao, Zhuliang Yao, Qi Dai, and Han Hu. Simmim: A simple framework for masked image modeling. In CVPR, 2022.
|
| 371 |
+
|
| 372 |
+
Qinwei Xu, Ruipeng Zhang, Ya Zhang, Yanfeng Wang, and Qi Tian. A fourier-based framework for domain generalization. In CVPR, 2021.
|
| 373 |
+
|
| 374 |
+
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 ICCV, 2019.
|
| 375 |
+
|
| 376 |
+
Hongyi Zhang, Moustapha Cisse, Yann N Dauphin, and David Lopez-Paz. mixup: Beyond empirical risk minimization. arXiv preprint arXiv:1710.09412, 2017a.
|
| 377 |
+
|
| 378 |
+
Kai Zhang, Wangmeng Zuo, Yunjin Chen, Deyu Meng, and Lei Zhang. Beyond a gaussian denoiser: Residual learning of deep cnn for image denoising. TIP, 2017b.
|
| 379 |
+
|
| 380 |
+
Kaihao Zhang, Wenqi Ren, Wenhan Luo, Wei-Sheng Lai, Bjorn Stenger, Ming-Hsuan Yang, and Hongdong Li. Deep image deblurring: A survey. arXiv preprint arXiv:2201.10700, 2022.
|
| 381 |
+
|
| 382 |
+
Richard Zhang, Phillip Isola, and Alexei A Efros. Colorful image colorization. In ECCV, 2016.
|
| 383 |
+
|
| 384 |
+
Richard Zhang, Phillip Isola, and Alexei A Efros. Split-brain autoencoders: Unsupervised learning by cross-channel prediction. In CVPR, 2017c.
|
| 385 |
+
|
| 386 |
+
Bolei Zhou, Hang Zhao, Xavier Puig, Sanja Fidler, Adela Barriuso, and Antonio Torralba. Scene parsing through ade20k dataset. In CVPR, 2017.
|
| 387 |
+
|
| 388 |
+
Jinghao Zhou, Chen Wei, Huiyu Wang, Wei Shen, Cihang Xie, Alan Yuille, and Tao Kong. ibot: Image bert pre-training with online tokenizer. In ICLR, 2022.
|
| 389 |
+
|
| 390 |
+
A MORE ABLATIONS
|
| 391 |
+
|
| 392 |
+
Table 7: More Ablations for MFM on ImageNet-1K. All models are pre-trained for 300 epochs, and evaluated with top-1 fine-tuning accuracy. Default entry (the same settings as in Table 1 of the main text) is marked in gray .
|
| 393 |
+
|
| 394 |
+
(a) Decoder depth. A simple linear layer performs the best with lower training costs (Transformer blocks have a hidden size of 384 with 12 heads).
|
| 395 |
+
|
| 396 |
+
(b) Masking in different domains. Frequency masking is a more flexible and unified option for different architectures.
|
| 397 |
+
|
| 398 |
+
<table><tr><td>Decoder</td><td>Blocks</td><td>Top-1 acc (%)</td></tr><tr><td>linear</td><td>1</td><td>83.1</td></tr><tr><td rowspan="4">Transformer blocks</td><td>1</td><td>83.0</td></tr><tr><td>2</td><td>83.1</td></tr><tr><td>4</td><td>83.1</td></tr><tr><td>8</td><td>83.1</td></tr></table>
|
| 399 |
+
|
| 400 |
+
<table><tr><td>Arch.</td><td>Task</td><td>Top-1 acc (%)</td></tr><tr><td rowspan="2">ViT-B/16</td><td>MIM</td><td>82.8</td></tr><tr><td>MFM</td><td>83.1</td></tr><tr><td rowspan="2">ResNet-50</td><td>MIM</td><td>77.7</td></tr><tr><td>MFM</td><td>78.5</td></tr></table>
|
| 401 |
+
|
| 402 |
+
Decoder depth. Table 7a ablates the effect of different decoders. MFM can work the best with a simple linear layer while benefiting from lower training costs compared with a deeper decoder.
|
| 403 |
+
|
| 404 |
+
Frequency masking vs. spatial masking. Considering that different design choices in existing masked image modeling (MIM) methods could affect the performance significantly, to eliminate the interference of other factors, we directly replace our frequency-domain-based masking with spatialdomain-based random patch masking for a fair comparison. The results are shown in Table 7b. Applying MIM to ResNet-50 leads to inferior performance even than the supervised baseline (i.e., $7 8 . 1 \%$ in RSB A3 (Wightman et al., 2021)). In contrast, MFM outperforms the supervised RSB baseline as well as the MIM counterpart regardless of architectures, demonstrating that frequency masking is indeed a more flexible and unified option for different architectures.
|
| 405 |
+
|
| 406 |
+
# B TRAINING TIME COMPARISON
|
| 407 |
+
|
| 408 |
+
We measure the pre-training time per epoch in Table 8. Note that MoCo v3 (Chen et al., 2021) and DINO (Caron et al., 2021) need to switch two global views and have four and 14 forward passes in total, respectively. BEiT (Bao et al., 2022), MAE (He et al., 2022) and MFM are 1-view methods without switching. MFM is relatively efficient compared with other MIM methods (e.g., BEiT) except for MAE. However, taking only visible patches as input breaks the regular 2D structure of images, which makes MAE only applicable to ViT. In contrast, MFM is agnostic to architectures and can be flexibly applied for both ViT and CNN families. Considering the flexibility and universality of MFM, a slightly increasing time over MAE is acceptable.
|
| 409 |
+
|
| 410 |
+
Table 8: Training time comparison. The time is measured on the same 8-GPU machine with the same batch size using ViT-B/16, counted in relative to our approach. †: BEiT requires an additional stage to pre-train dVAE, which is not included.
|
| 411 |
+
|
| 412 |
+
<table><tr><td>Method</td><td>Setup</td><td>Time per epoch</td></tr><tr><td>MoCo v3</td><td>2-view, 4-pass</td><td>1.84×</td></tr><tr><td>DINO</td><td>(2+10)-view,14-pass</td><td>2.04×</td></tr><tr><td>BEiT</td><td>1-view, 2-pass</td><td>1.53×+</td></tr><tr><td>MAE</td><td>1-view,1-pass</td><td>0.82×</td></tr><tr><td>MFM</td><td>1-view, 1-pass</td><td>1.00×</td></tr></table>
|
| 413 |
+
|
| 414 |
+
# C COMBINATION OF LOW-LEVEL IMAGE PROCESSING TASKS
|
| 415 |
+
|
| 416 |
+
In Table 1a of the main text, we have shown that randomly sampling low-/high-pass filters to predict both high and low frequencies benefits as MFM can make full use of the frequency spectrum, thus leading to better performance. Here, we further study the effect of combining low-level image processing tasks, i.e., SR, deblurring and denoising. Table 9 reports the ImageNet-1K top-1 finetuning accuracy of ViT-B/16 models. We find that combining these low-level corruptions does not bring similar benefits as MFM and even degrades the performance.
|
| 417 |
+
|
| 418 |
+
Table 9: Combination of SR, deblurring, denoising tasks using ViT-B/16 on ImageNet-1K. All models are pre-trained for 300 epochs, and evaluated with top-1 fine-tuning accuracy.
|
| 419 |
+
|
| 420 |
+
<table><tr><td>Task</td><td>Top-1 acc (%)</td></tr><tr><td>Individual task:</td><td></td></tr><tr><td>SR</td><td>82.4</td></tr><tr><td>Deblur</td><td>81.7</td></tr><tr><td>Denoise</td><td>82.7</td></tr><tr><td>Integrated task:</td><td></td></tr><tr><td>SR+Denoise</td><td>82.2</td></tr><tr><td>Deblur+Denoise</td><td>82.5</td></tr></table>
|
| 421 |
+
|
| 422 |
+
# D FURTHER DISCUSSION
|
| 423 |
+
|
| 424 |
+
Mask tokens. In MIM methods, mask tokens are learnable patch embeddings inserted in the position where the input tokens are masked out. They are highly coupled with the Transformer architecture and not directly applicable to CNNs. Introducing special mask tokens in any intermediate stage of CNN is infeasible, as the intrinsic dense-sliding-window paradigm in convolution layers brings information leakage between visual features in previous layers (Fang et al., 2022). Thus, the large CNN family cannot directly benefit from this pre-training scheme like Transformers. In contrast, our MFM performs masking in the frequency domain without relying on mask tokens. Thus, MFM is agnostic to the architectures and can be flexibly applied for broader ViT and CNN families.
|
| 425 |
+
|
| 426 |
+
Table 10: System-level comparison with Siamese-based hybrid MIM methods (e.g., iBOT (Zhou et al., 2022) and data2vec (Baevski et al., 2022)) using ViT-B/16 on ImageNet-1K. For a fair comparison, we re-implement iBOT without multi-crop augmentation (but keeping the two global views) and data2vec (Baevski et al., 2022) without additional losses of intermediate Transformer layers using their official code. Training costs are counted in relative to our approach. Note that MFM is agnostic to architectures while these hybrid methods are not.
|
| 427 |
+
|
| 428 |
+
<table><tr><td>Method</td><td>Pre-text task</td><td>#Views</td><td>#Epochs</td><td>Top-1 acc (%)</td><td>Training costs</td></tr><tr><td>iBOT</td><td>MIM+CL</td><td>2</td><td>300</td><td>82.0</td><td>2.14×</td></tr><tr><td>data2vec</td><td>MIM+CL</td><td>2</td><td>300</td><td>83.0</td><td>1.60×</td></tr><tr><td>MFM</td><td>MFM</td><td>1</td><td>300</td><td>83.1</td><td>1.00×</td></tr></table>
|
| 429 |
+
|
| 430 |
+
Comparison with hybrid MIM methods. A line of recent research (Zhou et al., 2022; Baevski et al., 2022; Assran et al., 2022) combines MIM with contrastive learning (CL) into a Siamese framework and achieves better performance than a single task. Apart from adopting a Siamese network, additional techniques used in these works include multi-crop augmentation in Zhou et al. (2022); Assran et al. (2022) and multiple losses of intermediate Transformer layers in Baevski et al. (2022), without which their performance will be degraded significantly as shown in Table 10 (we take iBOT and data2vec as examples here since most of these works are concurrent to ours). Therefore, to eliminate the interference of other design factors, we mainly compare with pure MIM methods in our study. More advanced techniques used in these works may also be incorporated into MFM to further improve the performance, which is beyond the focus of this work.
|
| 431 |
+
|
| 432 |
+
Concurrent work. A concurrent work (Liu et al., 2022) also involves self-supervised learning in the frequency domain. Our work differs from theirs in the following aspects: 1) It aims at improving upon existing MIM approaches by additionally designing a more complex frequency decoder and computing losses in both spatial and frequency domain. In contrast, we aim at exploring an alternative frequency corruption strategy beyond MIM. Our method does not rely on any existing MIM approaches and we show that MFM can also work well independently. 2) It is based on MAE (He et al., 2022) and still performs spatial masking with mask tokens. Thus, it is still not applicable to CNNs, whereas our frequency-domain-based masking strategy is agnostic to architectures. 3) As opposed to Liu et al. (2022) that mainly targets at improving MIM performance, we comprehensively study the effectiveness of low-level image processing tasks for representation learning from a unified frequency perspective and provide rather different insights that other low-level tasks beyond MIM can also work well.
|
| 433 |
+
|
| 434 |
+
Limitations. Our study has several limitations: 1) We mainly focus on the architectural flexibility and universality of MFM, while leaving the scaling behaviour under-explored. 2) We mainly evaluate the quality of learned representations on representative benchmarks, i.e., ImageNet-1K image classification and ADE20K semantic segmentation, following Bao et al. (2022). The transferability on more downstream tasks can be studied in future research. 3) Despite the intriguing properties of the Fourier domain, the redundancy in frequencies may still exist. More advanced information suppression strategies can be further explored. We believe that our MFM can also complement contrastive learning and MIM approaches to further improve the performance. We leave these explorations for future work.
|
| 435 |
+
|
| 436 |
+
Future work. In this paper, we have shown that MFM is a simple, unified and flexible selfsupervised pretext task for various architectures. Compared with MIM, MFM can embrace broader architectures (e.g., ViT, CNN, etc.) and has more appealing robustness. Some possible future research directions may include: 1) More self-supervised learning works in the frequency domain with different modalities (e.g., image, video, audio, etc.). 2) Combine MFM with existing contrastive learning and MIM paradigms to further improve the performance. 3) Apply MFM for model robustness analysis and calibration. 4) The idea of MFM may also be used in low-level image reconstruction and synthesis tasks.
|
| 437 |
+
|
| 438 |
+
# E PSEUDOCODE
|
| 439 |
+
|
| 440 |
+
# Algorithm 1 Pseudocode of MFM in a PyTorch-like style.
|
| 441 |
+
|
| 442 |
+
# f: backbone encoder (e.g., vit, cnn) $^ +$ linear prediction head
|
| 443 |
+
# mask: frequency mask of low-/high-pass filters sampled with a Bernoulli distribution, i.e., mask $=$ Bernoulli(p) ? m : 1 - m (m is defined in Eq. (2), p is the probability of sampling a low-pass filter m) gamma: exponent to control the sharpness of the frequency distance
|
| 444 |
+
for (x, mask) in loader: # load a minibatch $_ \textrm { x }$ with N samples $\qquad \mathrm { \vartriangle { \mathbf { \Sigma } } } \times \quad =$ aug(x) # random view, NxCxHxW # convert spatial domain into frequency domain x_freq $=$ fft2(x) # 2D FFT x_freq $=$ fftshift(x_freq, dim $\underline { { \underline { { \mathbf { \Pi } } } } } =$ (-2, -1)) # shift low frequency to the center x_freq $=$ x_freq $\star$ mask # mask a portion of frequencies x_freq $=$ ifftshift(x_freq, dim $\underline { { \boldsymbol { \mathbf { \Pi } } } } =$ (-2, -1)) # restore the original frequency order # convert frequency domain back into spatial domain x_corrupted $=$ ifft2(x_freq).real # 2D iFFT (only keep the real part) x_predicted $=$ f(x_corrupted) # predicted view, NxCxHxW loss $=$ FrequencyLoss(x_predicted, x, gamma) # frequency loss # only compute the frequency loss on the masked area loss $=$ (loss $\star$ (1 - mask)).sum() / (1 - mask).sum()
|
| 445 |
+
|
| 446 |
+
# update model loss.backward() update(f)
|
| 447 |
+
|
| 448 |
+
def FrequencyLoss(x, y, gamma): x_freq, y_freq $=$ fft2(x), fft2(y) # 2D FFT # shift low frequency to the center x_freq $=$ fftshift(x_freq, dim $1 { = }$ (-2, -1)) y_freq $=$ fftshift(y_freq, dim $\underline { { \underline { { \mathbf { \Pi } } } } } =$ (-2, -1)) # stack the real and imaginary parts along the last dimension x_freq $=$ stack([x_freq.real, x_freq.imag], -1) y_freq $=$ stack([y_freq.real, y_freq.imag], -1) # compute the frequency distance d = (x_freq - y_freq) \*\* 2 return (d[..., 0] + d[..., 1]) \*\* (0.5 \* gamma)
|
| 449 |
+
|
| 450 |
+

|
| 451 |
+
Figure 3: Example frequency spectrums of spatial-domain-based random patch masking from ImageNet-1K training set. The masking ratio is $7 5 \%$ . Performing patch-wise masking in the spatial domain incurs grid-wise artifacts on the frequency spectrum.
|
| 452 |
+
|
| 453 |
+
# F FREQUENCY SPECTRUM OF MIM
|
| 454 |
+
|
| 455 |
+
Figure 3 visualizes some example frequency spectrums of spatial-domain-based random patch masking used in MIM. Performing patch-wise masking in the spatial domain incurs grid-wise artifacts on the frequency spectrum, preventing further meaningful observations.
|
| 456 |
+
|
| 457 |
+
# G IMPLEMENTATION DETAILS
|
| 458 |
+
|
| 459 |
+
Pre-training. Table 11 summarizes the pre-training settings for vanilla ViT and ResNet-50 models. All experiments are conducted on 16 V100 32G GPUs for ViT models and 8 V100 32G GPUs for ResNet-50. The configurations are shared by different architectures, without specialized tuning. This demonstrates that MFM is general across architectures.
|
| 460 |
+
|
| 461 |
+
Fine-tuning. Table 12 and Table 13 summarize the fine-tuning settings for vanilla ViT and ResNet50 models, respectively. The configurations for ViT are shared across models, except that smaller models are fine-tuned longer. The configurations for ResNet-50 basically follow Wightman et al. (2021), except that we adopt the AdamW optimizer following Fang et al. (2022).
|
| 462 |
+
|
| 463 |
+
Semantic segmentation on ADE20K. We use UperNet (Xiao et al., 2018) following the configurations in BEiT (Bao et al., 2022). Specifically, we use AdamW as the optimizer and fine-tune for 160K iterations with a batch size of 16. We search the learning rate for all the results in Table 5 of the main text. The input resolution is $5 1 2 \times 5 1 2$ , and we use single-scale inference. As suggested in BEiT (Bao et al., 2022), we initialize all segmentation models using model weights after supervised fine-tuning on ImageNet-1K, following the common practice of BERT (Devlin et al., 2019) fine-tuning in NLP (Pruksachatkun et al., 2020).
|
| 464 |
+
|
| 465 |
+
Table 11: Pre-training settings for vanilla ViT-S/16, ViT-B/16 and ResNet-50 models on ImageNet-1K. Note that we adopt the same pre-training configurations across different architectures without further parameter tuning.
|
| 466 |
+
|
| 467 |
+
<table><tr><td>Configuration</td><td>Value</td></tr><tr><td>Optimizer</td><td>AdamW (Loshchilov & Hutter,2017)</td></tr><tr><td>Pre-training epochs</td><td>300</td></tr><tr><td>Peak learning rate</td><td>1.2e-3</td></tr><tr><td>Batch size</td><td>2048</td></tr><tr><td>Weight decay</td><td>0.05</td></tr><tr><td>Optimizer momentum</td><td>β1,β2 = 0.9,0.95 (Chen et al.,2020a)</td></tr><tr><td>Learning rate schedule</td><td>Cosine decay</td></tr><tr><td>Warmup epochs</td><td>20</td></tr><tr><td>Gradient clipping</td><td>3.0</td></tr><tr><td>Dropout (Srivastava et al., 2014)</td><td>X</td></tr><tr><td>Stochastic depth (Huang et al.,2016)</td><td>X</td></tr><tr><td>LayerScale (Touvron et al., 2021b)</td><td>X</td></tr><tr><td>Data augmentation</td><td>RandomResizedCrop</td></tr><tr><td>Pos.emb.in Transformer layers</td><td>1-D absolute pos. emb. (Dosovitskiy et al., 2020)</td></tr><tr><td>Patch size</td><td>16</td></tr><tr><td>Pre-training resolution</td><td>224</td></tr></table>
|
| 468 |
+
|
| 469 |
+
Table 12: Fine-tuning settings for vanilla ViT-S/16 and ViT-B/16 on ImageNet-1K. We fine-tune ViT-S/16 for 200 epochs, and ViT-B/16 for 100 epochs. All other hyper-parameters are the same.
|
| 470 |
+
|
| 471 |
+
<table><tr><td>Configuration</td><td>Value</td></tr><tr><td>Optimizer</td><td>AdamW (Loshchilov & Hutter,2017)</td></tr><tr><td>Fine-tuning epochs</td><td>200 (S),100 (B)</td></tr><tr><td>Peak learning rate</td><td>8e-3</td></tr><tr><td>Layer-wise learning rate decay (Bao et al.,2022)</td><td>0.8 (Clark et al., 2020)</td></tr><tr><td>Batch size</td><td>2048</td></tr><tr><td>Weight decay</td><td>0.05</td></tr><tr><td>Optimizer momentum</td><td>β1,β2 = 0.9,0.999</td></tr><tr><td>Learning rate schedule</td><td>Cosine decay</td></tr><tr><td>Warmup epochs</td><td>5</td></tr><tr><td>Loss function</td><td>Cross-entropy loss</td></tr><tr><td>Gradient clipping</td><td>X</td></tr><tr><td>Dropout (Srivastava et al., 2014)</td><td>X</td></tr><tr><td>Stochastic depth (Huang et al., 2016)</td><td>0.1</td></tr><tr><td>Mixup (Zhang et al., 2017a)</td><td>0.8</td></tr><tr><td>Cutmix (Yun et al.,2019)</td><td>1.0</td></tr><tr><td>Label smoothing (Szegedy et al., 2016)</td><td>0.1</td></tr><tr><td>Random augmentation (Cubuk et al., 2020)</td><td>9 /0.5</td></tr><tr><td>Patch size</td><td>16</td></tr><tr><td>Fine-tuning resolution</td><td>224</td></tr><tr><td>Test resolution</td><td>224</td></tr></table>
|
| 472 |
+
|
| 473 |
+
Table 13: Fine-tuning settings for vanilla ResNet-50 on ImageNet-1K. The hyper-parameters generally follow Wightman et al. (2021), except that we adopt the AdamW optimizer following Fang et al. (2022).
|
| 474 |
+
|
| 475 |
+
<table><tr><td>Configuration</td><td>100 epoch FT</td><td>300 epoch FT</td></tr><tr><td>Optimizer</td><td colspan="2">AdamW (Loshchilov & Hutter,2017)</td></tr><tr><td>Peak learning rate</td><td colspan="2">12e-3</td></tr><tr><td>Layer-wise learning rate decay (Bao et al., 2022)</td><td colspan="2">X</td></tr><tr><td>Batch size</td><td colspan="2">2048</td></tr><tr><td>Weight decay</td><td colspan="2">0.02</td></tr><tr><td>Learning rate schedule</td><td colspan="2">Cosine decay</td></tr><tr><td>Warmup epochs</td><td colspan="2">5</td></tr><tr><td>Loss function</td><td colspan="2">Binary cross-entropy loss</td></tr><tr><td>Gradient clipping</td><td colspan="2">X</td></tr><tr><td>Dropout (Srivastava et al.,2014)</td><td colspan="2">X</td></tr><tr><td>Stochastic depth (Huang et al., 2016)</td><td colspan="2">X</td></tr><tr><td>Mixup (Zhang et al.,2017a)</td><td colspan="2">0.1</td></tr><tr><td>Cutmix (Yun et al., 2019)</td><td>1.0</td><td></td></tr><tr><td>Label smoothing (Szegedy et al., 2016)</td><td>0.1</td><td>×</td></tr><tr><td>Repeated augmentation (Berman et al.,2O19; Hoffer et al., 2019)</td><td>X</td><td>√</td></tr><tr><td>Random augmentation (Cubuk et al., 2020)</td><td>6/0.5</td><td>7/0.5</td></tr><tr><td>Fine-tuning resolution</td><td>160</td><td>224</td></tr><tr><td>Test resolution</td><td colspan="2">224</td></tr><tr><td>Test crop ratio</td><td colspan="2">0.95</td></tr></table>
|
| 476 |
+
|
| 477 |
+
# H VISUALIZATION
|
| 478 |
+
|
| 479 |
+
We provide more qualitative results of corrupted images in Figure 4 following Table 2 in the main text, as well as recovered images using unseen ImageNet-1K (Figure 5) and COCO (Figure 6) validation images.
|
| 480 |
+
|
| 481 |
+

|
| 482 |
+
Figure 4: More visualizations of corrupted image samples from ImageNet-1K training set following Table 2 in the main text. We visualize both images and their frequency spectrums with different degradation levels. (a) SR, (b) Deblur (kernel size 21), (c) Denoise, (d) MFM. Each task achieves its best performance with a moderate degradation intensity. See Section 4.3 in the main text for more discussion. Zoom in for best view.
|
| 483 |
+
|
| 484 |
+

|
| 485 |
+
Figure 5: Example results of recovered images on ImageNet-1K validation set for SR, deblurring, denoising and MFM tasks. We visualize both images and their frequency spectrums. We use the best pre-trained model of each task in Table 2 of the main text for visualization, i.e., the downsampling scale factor is $\times 8$ for SR, the Gaussian blur sigma is 5 for Deblur, the Gaussian noise sigma is 75 for Denoise, and the mask radius is 16 for MFM†. Compared with SR, Deblur and Denoise, MFM can utilize both high-frequency and low-frequency information for prediction. Zoom in for best view. †As MFM only predicts the masked area of the frequency spectrum, we overlay the output with the visible frequency spectrum for better visual quality.
|
| 486 |
+
|
| 487 |
+

|
| 488 |
+
Figure 6: Example results of recovered images on COCO validation set for SR, deblurring, denoising and MFM tasks, using the models pre-trained on ImageNet-1K (the same model weights as in Figure 5). We visualize both images and their frequency spectrums. Zoom in for best view.
|
md/dev/A6X9y8n4sT/A6X9y8n4sT.md
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# One-2-3-45: Any Single Image to 3D Mesh in 45 Seconds without Per-Shape Optimization
|
| 2 |
+
|
| 3 |
+
Chao Xu2∗ Haian Jin3,4∗ Linghao Chen1,4∗ Mukund Varma T1 Zexiang Xu6 Hao Su1
|
| 4 |
+
|
| 5 |
+
1 UC San Diego 2 UCLA 3 Cornell University 4 Zhejiang University 5 Adobe Research
|
| 6 |
+
|
| 7 |
+
Project Website: http://one-2-3-45.com
|
| 8 |
+
|
| 9 |
+
# Abstract
|
| 10 |
+
|
| 11 |
+
Single image 3D reconstruction is an important but challenging task that requires extensive knowledge of our natural world. Many existing methods solve this problem by optimizing a neural radiance field under the guidance of 2D diffusion models but suffer from lengthy optimization time, 3D inconsistency results, and poor geometry. In this work, we propose a novel method that takes a single image of any object as input and generates a full 360-degree 3D textured mesh in a single feed-forward pass. Given a single image, we first use a view-conditioned 2D diffusion model, Zero123, to generate multi-view images for the input view, and then aim to lift them up to 3D space. Since traditional reconstruction methods struggle with inconsistent multi-view predictions, we build our 3D reconstruction module upon an SDF-based generalizable neural surface reconstruction method and propose several critical training strategies to enable the reconstruction of 360- degree meshes. Without costly optimizations, our method reconstructs 3D shapes in significantly less time than existing methods. Moreover, our method favors better geometry, generates more 3D consistent results, and adheres more closely to the input image. We evaluate our approach on both synthetic data and in-the-wild images and demonstrate its superiority in terms of both mesh quality and runtime. In addition, our approach can seamlessly support the text-to-3D task by integrating with off-the-shelf text-to-image diffusion models.
|
| 12 |
+
|
| 13 |
+
# 1 Introduction
|
| 14 |
+
|
| 15 |
+
Single image 3D reconstruction, the task of reconstructing a 3D model of an object from a single 2D image, is a long-standing problem in the computer vision community and is crucial for a wide range of applications, such as robotic object manipulation and navigation, 3D content creation, as well as AR/VR [47; 9; 92]. The problem is challenging as it requires not only the reconstruction of visible parts but also the hallucination of invisible regions. Consequently, this problem is often ill-posed and corresponds to multiple plausible solutions because of insufficient evidence from a single image. On the other hand, humans can adeptly infer unseen 3D content based on our extensive knowledge of the 3D world. To endow intelligent agents with this ability, many existing methods [31; 19; 25; 11; 87; 91; 16; 83; 39; 10; 37] exploit class-specific priors by training 3D generative networks on 3D shape datasets [4]. However, these methods often fail to generalize to unseen categories, and their reconstruction quality is constrained by the limited size of public 3D datasets.
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
Figure 1: One-2-3-45 reconstructs a full $3 6 0 ^ { \circ }$ mesh of any object in 45 seconds given a single image of it. In each example, we showcase the input image in the left column, alongside the generated textured and textureless meshes from three different views.
|
| 19 |
+
|
| 20 |
+
In this work, we pursue a generic solution to turn an image of any object, regardless of its category, into a high-quality 3D textured mesh. To achieve this, we propose a novel approach that can effectively utilize the strong priors learned by 2D diffusion models for 3D reconstruction. Compared to 3D data, 2D images are more readily available and scalable. Recent 2D generative models (e.g., DALLE [64; 63], Imagen [69], and Stable Diffusion [68]) and visual-language models (e.g., CLIP [61]) have made significant strides by pre-training on Internet-scale image datasets. Since they learn a wide range of visual concepts and possess strong priors about our 3D world, it is natural to marry 3D tasks with them. Consequently, an emerging body of research [26; 23; 52; 60; 36], as exemplified by DreamField [26], DreamFusion [60], and Magic3D [36], employs 2D diffusion models or vision language models to assist 3D generative tasks. The common paradigm of them is to perform per-shape optimization with differentiable rendering and the guidance of the CLIP model or 2D diffusion models. While many other 3D representations have been explored, neural fields are the most commonly used representation during optimization.
|
| 21 |
+
|
| 22 |
+
Although these optimization-based methods have achieved impressive results on both text-to-3D [60; 26; 36] and image-to-3D tasks [48; 72], they face some common dilemmas: (a) time-consuming. Pershape optimization typically involves tens of thousands of iterations of full-image volume rendering and prior model inferences, resulting in typically tens of minutes per shape. (b) memory intensive. Since the full image is required for the 2D prior model, the volume rendering can be memory-intensive when the image resolution goes up. (c) 3D inconsistent. Since the 2D prior model only sees a single view at each iteration and tries to make every view look like the input, they often generate 3D inconsistent shapes (e.g., with two faces, or the Janus problem [48; 60]). (d) poor geometry. Many methods utilize the density field as the representation in volume rendering. It is common that they produce good RGB renderings but extracting high-quality mesh tends to be difficult.
|
| 23 |
+
|
| 24 |
+
In this paper, instead of following the common optimization-based paradigm, we propose a novel approach to utilize 2D prior models for 3D modeling. At the heart of our approach is the combination of a 2D diffusion model with a cost-volume-based 3D reconstruction technique, enabling the reconstruction of a high-quality $3 6 0 ^ { \circ }$ textured mesh from a single image in a feed-forward pass without per-scene optimization. Specifically, we leverage a recent 2D diffusion model, Zero123 [41], which is fine-tuned on Stable Diffusion [68] to predict novel views of the input image given the camera transformation. We utilize it to generate multi-view predictions of the input single image so that we can leverage multi-view 3D reconstruction techniques to obtain a 3D mesh. There are two challenges associated with reconstruction from synthesized multi-view predictions: (a) the inherent lack of perfect consistency within the multi-view predictions, which can lead to severe failures in optimization-based methods such as NeRF methods [53; 5]. (b) the camera pose of the input image is required but unknown. To tackle them, we build our reconstruction module upon a cost volume-based neural surface reconstruction approach, SparseNeuS [45], which is a variant of MVSNeRF [6]. Additionally, we introduce a series of essential training strategies that enable the reconstruction of 360-degree meshes from inherently inconsistent multi-view predictions. We also propose an elevation estimation module that estimates the elevation of the input shape in Zero123’s canonical coordinate system, which is used to compute the camera poses required by the reconstruction module.
|
| 25 |
+
|
| 26 |
+
By integrating the three modules of multi-view synthesis, elevation estimation, and 3D reconstruction, our method can reconstruct 3D meshes of any object from a single image in a feed-forward manner. Without costly optimizations, our method reconstructs 3D shapes in significantly less time, e.g., in just 45 seconds. Our method favors better geometry due to the use of SDF representations, and generates more consistent 3D meshes, thanks to the camera-conditioned multi-view predictions. Moreover, our reconstruction adheres more closely to the input image compared to existing methods. See Figure 1 for some of our example results. We evaluate our method on both synthetic data and real images and demonstrate that our method outperforms existing methods in terms of both quality and efficiency.
|
| 27 |
+
|
| 28 |
+
# 2 Related Work
|
| 29 |
+
|
| 30 |
+
# 2.1 3D Generation Guided by 2D Prior Models
|
| 31 |
+
|
| 32 |
+
Recently, 2D generative models (e.g., DALL-E [64; 63], Imagen [69], and Stable Diffusion [68]) and vision-language models (e.g., CLIP [61]) have learned a wide range of visual concepts by pre-training on Internet-scale image datasets. They possess powerful priors about our 3D world and have inspired a growing body of research to employ 2D prior models for assisting 3D understanding [38; 40] and generative tasks. Exemplified by DreamField [26], DreamFusion [60], and Magic3D [36], a line of works follows the paradigm of per-shape optimization. They typically optimize a 3D representation (i.e., NeRF, mesh, SMPL human model) and utilize differentiable rendering to generate 2D images from various views. The images are then fed to the CLIP model [23; 26; 52; 35; 3; 32; 2; 28; 89; 43] or 2D diffusion model [60; 36; 72; 48; 13; 78; 88; 51; 99; 62; 75] for calculating the loss functions, which are used to guide the 3D shape optimization. In addition to optimization-based 3D shape generation, some works train a 3D generative model but leverage the embedding space of CLIP [8; 44; 71], and some works focus on generating textures or materials for input meshes using 2D models’ prior [52; 82; 7; 51; 67].
|
| 33 |
+
|
| 34 |
+
# 2.2 Single Image to 3D
|
| 35 |
+
|
| 36 |
+
Before the emergence of CLIP and large-scale 2D diffusion models, people often learn 3D priors from 3D synthetic data [4] or real scans [65]. Unlike 2D images, 3D data can be represented in various formats and numerous representation-specific 3D generative models have been proposed. By combining 2D image encoder and 3D generators, they generate 3D data in various representations, including 3D voxels [19; 85; 11; 87; 86; 91], point clouds [16; 94; 20; 1; 49; 96], polygon meshes [31; 79; 83; 56], and parametric models [59; 100; 101]. Recently, there has been an increasing number of work on learning to generate a 3D implicit field from a single image [90; 50; 70; 25; 58; 18; 21; 27; 55; 84; 54].
|
| 37 |
+
|
| 38 |
+
As previously mentioned, several recent works leverage 2D diffusion models to perform per-shape optimization, allowing for the text-to-3D task [60; 36; 26] given that diffusion models are typically conditioned on text. To enable the generation of 3D models from a single image, some works [48; 13; 51] utilize textual inversion [17], to find the best-matching text embedding for the input image, which is then fed into a diffusion model. NeuralLift-360 [24] adds a CLIP loss to enforce similarity between the rendered image and the input image. 3DFuse [72] finetunes the Stable Diffusion model with LoRA layers [24] and a sparse depth injector to ensure greater 3D consistency. A recent work
|
| 39 |
+
|
| 40 |
+

|
| 41 |
+
Figure 2: Our method consists of three primary components: (a) Multi-view synthesis: we use a view-conditioned 2D diffusion model, Zero123 [41], to generate multi-view images in a two-stage manner. The input of Zero123 includes a single image and a relative camera transformation, which is parameterized by the relative spherical coordinates $( \Delta \theta , \Delta \phi , \Delta r )$ . (b) Pose estimation: we estimate the elevation angle $\theta$ of the input image based on four nearby views generated by Zero123. We then obtain the poses of the multi-view images by combining the specified relative poses with the estimated pose of the input view. (c) 3D reconstruction: We feed the multi-view posed images to an SDF-based generalizable neural surface reconstruction module for $3 6 0 ^ { \circ }$ mesh reconstruction.
|
| 42 |
+
|
| 43 |
+
Zero123 [41; 73] finetunes the Stable Diffusion model [69] to generate a novel view of the input image based on relative camera pose. In addition to these methods, OpenAI trains a 3D native diffusion model Point-E [57], which uses several million internal 3D models to generate point clouds. Very recently, they published another model Shap-E [30] which is trained to generate parameters of implicit functions that can be used for producing textured meshes or neural radiance fields.
|
| 44 |
+
|
| 45 |
+
# 2.3 Generalizable Neural Reconstruction
|
| 46 |
+
|
| 47 |
+
Traditional NeRF-like methods [53; 80] use a neural network to represent a single scene and require per-scene optimization. However, some approaches aim to learn priors across scenes and generalize to novel scenes. These methods typically take a few source views as input and leverage 2D networks for extracting 2D features. The pixel features are then unprojected into 3D space, and a NeRF-based rendering pipeline is applied on top of them. In this way, they can generate a 3D implicit field given a few source views in a single feed-forward pass. Among the methods, some [81; 65; 22; 95; 93; 42; 34; 76; 77] directly aggregate 2D features with MLPs or transformers, while others explicitly construct the 3D feature/cost volume [6; 29; 98; 45], and utilize the voxel feature for decoding density and color. In addition to the density field representation, some methods such as SparseNeuS [45] and VolRecon [66] utilize SDF representations for geometry reconstruction.
|
| 48 |
+
|
| 49 |
+
# 3 Method
|
| 50 |
+
|
| 51 |
+
Our overall pipeline is illustrated in Figure 2. In Section 3.1, we introduce a view-conditioned 2D diffusion model, Zero123 [41], which is used to generate multi-view images. In Section 3.2, we show that traditional NeRF-based and SDF-based methods fail to reconstruct high-quality meshes from inconsistent multi-view predictions even given ground truth camera poses. Therefore, in Section 3.3, we propose a cost volume-based neural surface reconstruction module that can be trained to handle inconsistent multi-view predictions and reconstruct a 3D mesh in a single feed-forward pass. Specifically, we build upon the SparseNeuS [45] and introduce several critical training strategies to support $3 6 0 ^ { \circ }$ mesh reconstruction. Additionally, in Section 3.4, we demonstrate the necessity of estimating the pose of the input view in Zero123’s canonical space for 3D reconstruction. While the azimuth and radius can be arbitrarily specified, we propose a novel module that utilizes four nearby views generated by Zero123 to estimate the elevation of the input view.
|
| 52 |
+
|
| 53 |
+
# 3.1 Zero123: View-Conditioned 2D Diffusion
|
| 54 |
+
|
| 55 |
+
Recent 2D diffusion models [64; 69; 68] have demonstrated the ability to learn a wide range of visual concepts and strong priors by training on internet-scale data. While the original diffusion models mainly focused on the task of text-to-image, recent work [97; 24] has shown that fine-tuning pretrained models allows us to add various conditional controls to the diffusion models and generate images based on specific conditions. Several conditions, such as canny edges, user scribbles, depth, and normal maps, have already proven effective [97].
|
| 56 |
+
|
| 57 |
+

|
| 58 |
+
Figure 3: NeRF-based method [53] and SDF-based method [80] fail to reconstruct high-quality meshes given multi-view images predicted by Zero123. See Figure 1 for our reconstruction results.
|
| 59 |
+
|
| 60 |
+
The recent work Zero123 [41] shares a similar spirit and aims to add viewpoint condition control for the Stable Diffusion model [68]. Specifically, given a single RGB image of an object and a relative camera transformation, Zero123 aims to control the diffusion model to synthesize a new image under this transformed camera view. To achieve this, Zero123 fine-tunes the Stable Diffusion on paired images with their relative camera transformations, synthesized from a large-scale 3D dataset [12]. During the creation of the fine-tuning dataset, Zero123 assumes that the object is centered at the origin of the coordinate system and uses a spherical camera, i.e., the camera is placed on the sphere’s surface and always looks at the origin. For two camera poses $( \theta _ { 1 } , \phi _ { 1 } , r _ { 1 } )$ and $( \theta _ { 2 } , \phi _ { 2 } , r _ { 2 } )$ , where $\theta _ { i }$ , $\phi _ { i }$ , and $r _ { i }$ denote the polar angle, azimuth angle, and radius, their relative camera transformation is parameterized as $( \bar { \theta _ { 2 } } - \theta _ { 1 } , \bar { \phi } _ { 2 } - \phi _ { 1 } , r _ { 2 } - r _ { 1 } )$ . They aim to learn a model $f$ , such that $f ( x _ { 1 } , \theta _ { 2 } - \theta _ { 1 } , \phi _ { 2 } - \phi _ { 1 } , r _ { 2 } - r _ { 1 } )$ is perceptually similar to $x _ { 2 }$ , where $x _ { 1 }$ and $x _ { 2 }$ are two images of an object captured from different views. Zero123 finds that such fine-tuning enables the Stable Diffusion model to learn a generic mechanism for controlling the camera viewpoints, which extrapolates outside of the objects seen in the fine-tuning dataset.
|
| 61 |
+
|
| 62 |
+
# 3.2 Can NeRF Optimization Lift Multi-View Predictions to 3D?
|
| 63 |
+
|
| 64 |
+
Given a single image of an object, we can utilize Zero123 [41] to generate multi-view images, but can we use traditional NeRF-based or SDF-based methods [5; 80] to reconstruct high-quality 3D meshes from these predictions? We conduct a small experiment to test this hypothesis. Given a single image, we first generate 32 multi-view images using Zero123, with camera poses uniformly sampled from the sphere surface. We then feed the predictions to a NeRF-based method (TensoRF [53]) and an SDF-based method (NeuS [80]), which optimize density and SDF fields, respectively. However, as shown in Figure 3, both methods fail to produce satisfactory results, generating numerous distortions and floaters. This is primarily due to the inconsistency of Zero123’s predictions. In Figure 4, we compare Zero123’s predictions with ground-truth renderings. We can see that the overall PSNR is not very high, particularly when the input relative pose is large or the target pose is at unusual locations (e.g., from the bottom or the top). However, the mask IoU (most regions are greater than 0.95) and CLIP similarity are relatively good. This suggests that Zero123 tends to generate predictions that are perceptually similar to the ground truth and have similar contours or boundaries, but the pixel-level appearance may not be exactly the same. Nevertheless, such inconsistencies between the source views are already fatal to traditional optimization-based methods. Although the original Zero123 paper proposes another method for lifting its multi-view predictions, we will demonstrate in experiments that it also fails to yield perfect results and entails time-consuming optimization.
|
| 65 |
+
|
| 66 |
+
# 3.3 Neural Surface Reconstruction from Imperfect Multi-View Predictions
|
| 67 |
+
|
| 68 |
+
Instead of using optimization-based approaches, we base our reconstruction module on a generalizable SDF reconstruction method SparseNeuS [45], which is essentially a variant of the MVSNeRF [6] pipeline that combines multi-view stereo, neural scene representation, and volume rendering. As illustrated in Figure 2, our reconstruction module takes multiple source images with corresponding camera poses as input and generates a textured mesh in a single feed-forward pass. In this section, we will first briefly describe the network pipeline of the module and then explain how we train the module, select the source images, and generate textured meshes. Additionally, in Section 3.4, we will discuss how we generate the camera poses for the source images.
|
| 69 |
+
|
| 70 |
+

|
| 71 |
+
Figure 4: We analyze the prediction quality of Zero123 by comparing its predictions to ground truth renderings across various view transformations. For each view transformation, we report the average PSNR, mask IoU, and CLIP similarity of 100 shapes from the Objaverse [12] dataset. The prediction mask is calculated by considering foreground objects (i.e., non-white regions). Zero123 provides more accurate predictions when the view transformation is small.
|
| 72 |
+
|
| 73 |
+
As shown in Figure 2, our reconstruction module takes $m$ posed source images as input. The module begins by extracting $m$ 2D feature maps using a 2D feature network. Next, the module builds a 3D cost volume whose contents are computed by first projecting each 3D voxel to $m$ 2D feature planes and then fetching the variance of the features across the $m$ projected 2D locations. The cost volume is then processed using a sparse 3D CNN to obtain a geometry volume that encodes the underlying geometry of the input shape. To predict the SDF at an arbitrary 3D point, an MLP network takes the 3D coordinate and its corresponding interpolated features from the geometry encoding volume as input. To predict the color of a 3D point, another MLP network takes as input the 2D features at the projected locations, interpolated features from the geometry volume, and the viewing direction of the query ray relative to the viewing direction of the source images. The network predicts the blending weights for each source view, and the color of the 3D point is predicted as the weighted sum of its projected colors. Finally, an SDF-based rendering technique is applied on top of the two MLP networks for RGB and mask rendering [80]. In each iteration, we randomly choose one view to build the cost volume and another view for rendering supervision.
|
| 74 |
+
|
| 75 |
+
2-Stage Source View Selection and Groundtruth-Prediction Mixed Training. Although the original SparseNeuS [45] paper only demonstrated frontal view reconstruction, we have extended it to reconstruct 360-degree meshes in a single feed-forward pass by selecting source views in a particular way. Specifically, our reconstruction model is trained on a 3D object dataset while freezing Zero123. We follow Zero123 to normalize the training shapes and use a spherical camera model. For each shape, we first render $n$ ground-truth RGB images from $n$ camera poses uniformly placed on the sphere. For each of the $n$ views, we use Zero123 to predict four nearby views. During training, we feed all $4 \times n$ predictions with ground-truth poses into the reconstruction module and randomly choose one of the $n$ ground-truth RGB images views as the target view. We call this view selection strategy as 2-stage source view selection. We supervise the training with both the ground-truth RGB and mask values. In this way, the module can learn to handle the inconsistent predictions from Zero123 and reconstruct a consistent $3 6 0 ^ { \circ }$ mesh. We argue that our two-stage source view selection strategy is critical since uniformly choosing $n \times 4$ source views from the sphere surface would result in larger distances between the camera poses. However, cost volume-based methods [45; 29; 6] typically rely on very close source views to find local correspondences. Furthermore, as shown in Figure 4, when the relative pose is small (e.g., 10 degrees apart), Zero123 can provide very accurate and consistent predictions and thus can be used to find local correspondences and infer the geometry.
|
| 76 |
+
|
| 77 |
+
During training, we utilize $n$ ground-truth renderings in the initial stage. We find that employing $n$ predicted images at this stage would suffer from notable inconsistencies across different views, complicating the network’s ability to learn sharp details (see examples in ablation study). However, during inference, we can replace the $n$ ground-truth renderings with Zero123 predictions, as shown in Figure 2, the network can automatically generalize to some extent. We will show in the experiments that this groundtruth-prediction mixed training strategy is also important. To export the textured mesh, we use marching cubes [46] to extract the mesh from the predicted SDF field and query the color of the mesh vertices as described in [80]. Although our reconstruction module is trained on a 3D dataset, we find that it mainly relies on local correspondences and can generalize to unseen shapes very well.
|
| 78 |
+
|
| 79 |
+

|
| 80 |
+
Figure 5: Qualitative examples of One-2-3-45 for both synthetic and real images. Each triplet showcases an input image, a textured mesh, and a textureless mesh.
|
| 81 |
+
|
| 82 |
+
# 3.4 Camera Pose Estimation
|
| 83 |
+
|
| 84 |
+
Our reconstruction module requires camera poses for the $4 \times n$ source view images. Note that we adopt Zero123 for image synthesis, which parameterizes cameras in a canonical spherical coordinate frame, $( \theta , \phi , r )$ , where $\theta$ , $\phi$ and $r$ represent the elevation, azimuth, and radius. While we can arbitrarily adjust the azimuth angle $\phi$ and the radius $r$ of all source view images simultaneously, resulting in the rotation and scaling of the reconstructed object accordingly, this parameterization requires knowing the absolute elevation angle $\theta$ of one camera to determine the relative poses of all cameras in a standard XYZ frame. More specifically, the relative poses between camera $( \theta _ { 0 } , \phi _ { 0 } , r _ { 0 } )$ and camera $( \theta _ { 0 } + \Delta \theta , \phi _ { 0 } + \Delta \phi , r _ { 0 } )$ vary for different $\theta _ { 0 }$ even when $\Delta \theta$ and $\Delta \phi$ are the same. Because of this, changing the elevation angles of all source images together (e.g., by 30 degrees up or 30 degrees down) will lead to the distortion of the reconstructed shape (see Figure 10 for examples).
|
| 85 |
+
|
| 86 |
+
Therefore, we propose an elevation estimation module to infer the elevation angle of the input image. First, we use Zero123 to predict four nearby views of the input image. Then we enumerate all possible elevation angles in a coarse-to-fine manner. For each elevation candidate angle, we compute the corresponding camera poses for the four images and calculate a reprojection error for this set of camera poses to measure the consistency between the images and the camera poses. The elevation angle with the smallest reprojection error is used to generate the camera poses for all $4 \times n$ source views by combining the pose of the input view and the relative poses. Please refer to the appendix for details on how we calculate the reprojection error for a set of posed images.
|
| 87 |
+
|
| 88 |
+
# 4 Experiments
|
| 89 |
+
|
| 90 |
+
# 4.1 Implementation Details
|
| 91 |
+
|
| 92 |
+
For each input image, we generate $n = 8$ images by choosing camera poses uniformly placed on the sphere surface and then generate 4 local images $1 0 ^ { \circ }$ apart) for each of the 8 views, resulting in 32 source-view images for reconstruction. During training, we freeze the Zero123 [41] model and train our reconstruction module on the Objaverse-LVIS [12] dataset, which contains 46K 3D models in 1,156 categories. We use BlenderProc [14] to render ground-truth RGB images. For images with background, we utilize an off-the-shelf segmentation network SAM [33] with bounding-box prompts for background removal. Please refer to the appendix for more details.
|
| 93 |
+
|
| 94 |
+
# 4.2 Single Image to 3D Mesh
|
| 95 |
+
|
| 96 |
+
We present qualitative examples of our method in Figures 1 and 5, illustrating its effectiveness in handling both synthetic images and real images. We also compare One-2-3-45 with existing zero-shot single image 3D reconstruction approaches, including Point-E [57], Shap-E [30], Zero123 (Stable
|
| 97 |
+
|
| 98 |
+

|
| 99 |
+
Figure 6: We compare One-2-3-45 with Point-E [57], Shap-E [30], Zero123 (Stable Dreamfusion version) [41], 3DFuse [72], and RealFusion [48]. In each example, we present both the textured and textureless meshes. As 3DFuse [72] and RealFusion [48] do not natively support the export of textured meshes, we showcase the results of volume rendering instead.
|
| 100 |
+
|
| 101 |
+
Table 1: Quantitative Comparison on GSO [15] and Objaverse [12] datasets.
|
| 102 |
+
|
| 103 |
+
<table><tr><td></td><td>Prior Source</td><td>F-Score GSO Obj.</td><td>avg.</td><td>CLIP Similarity GSO Obj. avg.</td><td></td><td>Time</td></tr><tr><td>Point-E [57] Shap-E [30]</td><td>internal 3D data</td><td>81.0 81.0 83.4</td><td>81.0</td><td>74.3</td><td>78.5 76.4</td><td>78s 27s</td></tr><tr><td>Zero123+SD [41]</td><td></td><td></td><td>81.2 82.3</td><td>79.6</td><td>82.1 80.9</td><td></td></tr><tr><td></td><td>2D</td><td>75.1</td><td>69.9 72.5</td><td>71.0</td><td>72.7 71.9</td><td>~15min</td></tr><tr><td>RealFusion [48]</td><td>diffusion</td><td>66.7</td><td>59.3 63.0</td><td>69.3</td><td>69.5 69.4</td><td>~90min</td></tr><tr><td>3DFuse [72]</td><td></td><td>60.7 60.2</td><td>60.4</td><td>71.4</td><td>74.072.7</td><td>~30min</td></tr><tr><td></td><td>models</td><td>84.0</td><td></td><td></td><td>79.778.1</td><td>45s</td></tr><tr><td>Ours</td><td></td><td>83.1</td><td>83.5</td><td>76.4</td><td></td><td></td></tr></table>
|
| 104 |
+
|
| 105 |
+

|
| 106 |
+
Figure 7: Error distribution of predicted elevations. The median and average are 5.4 and 9.7 degrees.
|
| 107 |
+
|
| 108 |
+
Dreamfusion version) [41], 3DFuse [72], and RealFusion [48]. Among them, Point-E and Shap-E are two 3D native diffusion models released by OpenAI, which are trained on several million internal 3D data, while others are optimization-based approaches leveraging priors from Stable Diffusion [68].
|
| 109 |
+
|
| 110 |
+
Figure 6 presents the qualitative comparison. While most methods can generate plausible 3D meshes from a single image, notable differences exist among them in terms of geometry quality, adherence to the input, and overall 3D consistency. In terms of geometry quality, approaches like RealFusion [48] and 3DFuse [72], which optimize a neural radiance field, face challenges in extracting high-quality meshes. Likewise, Point-E [57] produces a sparse point cloud as its output, resulting in numerous holes on the reconstructed meshes. In contrast, our approach utilizes an SDF presentation and favors better geometry. Regarding adherence to the input, we observe that most baseline methods struggle to preserve the similarity to the input image. Although Shap-E performs slightly better, it still produces lots of failure cases (see the backpack without shoulder straps, distorted shoe, and stool with three legs). In contrast, our approach leverages a powerful 2D diffusion model to directly produce high-quality multi-view images, rather than relying on 3D space hallucination. This strategy provides better adherence to the input views, alleviates the burden of the 3D reconstruction module, and yields results that are more finely attuned to the input. Furthermore, many approaches encounter challenges in achieving consistent 3D results (also known as the Janus problem [48; 60]), as highlighted in the right figure (two-handle mug, multi-face Mario, and two-face backpack). One of the contributing factors to this issue is that several methods optimize each view independently, striving to make each view resemble the input. In contrast, our method capitalizes on the view-conditioned 2D diffusion model, inherently enhancing 3D consistency.
|
| 111 |
+
|
| 112 |
+

|
| 113 |
+
Figure 8: Ablations on training strategies of the reconstruction module and the number of views.
|
| 114 |
+
|
| 115 |
+

|
| 116 |
+
|
| 117 |
+
We also quantitatively compare the approaches on Objaverse [12] and GoogleScannedObjects (GSO) [15] datasets. For each dataset, we randomly choose 20 shapes and render a single image per shape for evaluation. To align the predictions with the ground-truth mesh, we linearly search the scaling factor and the rotation angle, apply Iterative Closest Point (ICP) for sampled point clouds, and select the one with the most number of inliers. We follow RealFusion [48] to report F-score (with a threshold of 0.05) and CLIP similarity, and the runtime on an A100 GPU. As shown in Table 1, our method outperforms all baseline approaches in terms of F-Score. As for CLIP similarity, we surpass all methods except a concurrent work Shap-E [30]. We find that CLIP similarity is very sensitive to the color distribution and less discriminative in local geometry variations (i.e., the number of legs of a stool, the number of handles of a mug). Regarding running time, our method demonstrates a notable advantage over optimization-based approaches and performs on par with 3D native diffusion models, such as Point-E [57] and Shap-E [30]. Specifically, our 3D reconstruction module reconstructs a 3D mesh in approximately 5 seconds, with the remaining time primarily spent on Zero123 predictions, which takes roughly 1 second per image on an A100 GPU.
|
| 118 |
+
|
| 119 |
+
# 4.3 Ablation Study
|
| 120 |
+
|
| 121 |
+
Training strategies. We ablate our training strategies in Figure 8. We found that without our 2-stage source view selection strategy, a network trained to consume 31 uniformly posed Zero123 predictions (fourth column) suffers from severe inconsistency among source views, causing the reconstruction module to fail completely. If we feed only 7 source views (sixth column) without the four nearby views, the reconstruction fails to capture local correspondence and cannot reconstruct fine-grained geometry. During training, we first render $n$ ground-truth renderings and then use Zero123 to predict four nearby views for each of them. If we train directly on $8 \times 4$ ground-truth renderings without Zero123 prediction during training (second column), it fails to generalize well to Zero123 predictions during inference, with many missing regions. Instead, if we replace the $n$ ground-truth renderings with $n$ Zero123 predictions during training (first column), the network fail to generate sharp details (see the strips of the backpack).
|
| 122 |
+
|
| 123 |
+

|
| 124 |
+
Figure 9: $3 6 0 ^ { \circ }$ reconstruction vs. multiview fusion. Meshes from different views are in different colors.
|
| 125 |
+
|
| 126 |
+

|
| 127 |
+
Figure 10: Incorrect elevations lead to distorted reconstruction. Our elevation estimation module can predict an accurate elevation of the input view.
|
| 128 |
+
|
| 129 |
+

|
| 130 |
+
Figure 11: Text to 3D. First row: “a bear in cowboy suit.” Second row: “a kungfu cat.” We utilize DALL-E 2 [63] to generate an image conditioned on the text and then lift it to 3D. We compare our method with Stable Dreamfusion [60] and 3DFuse [72]. For baselines, volume renderings are shown.
|
| 131 |
+
|
| 132 |
+
Elevation estimation. Our reconstruction module relies on accurate elevation angles of the input view. In Figure 10, we demonstrate the impact of providing incorrect elevation angles (e.g., altering the elevation angles of source views by $\pm 3 0 ^ { \circ }$ ), which results in distorted reconstruction results. Instead, utilizing our predicted elevation angles can perfectly match results with ground truth elevations. We also quantitatively test our elevation estimation module by rendering 1,700 images from random camera poses. As shown in Figure 7, our elevation estimation module predicts accurate elevations.
|
| 133 |
+
|
| 134 |
+
Number of source views. In Figure 8, we also investigate the impact of varying the number of source views on 3D reconstruction. We observe that our method is not very sensitive to the number of views as long as the reconstruction module is retrained with the corresponding setting.
|
| 135 |
+
|
| 136 |
+
$3 6 0 ^ { \circ }$ reconstruction vs. multi-view fusion. While our method reconstructs a $3 6 0 ^ { \circ }$ mesh in a single pass, most existing generalizable neural reconstruction approaches [45; 29; 6] primarily focus on frontal view reconstruction. An alternative approach is to independently infer the geometry for each view and subsequently fuse them together. However, we have observed that this strategy often struggles with multi-view fusion due to inconsistent Zero123 predictions, as illustrated in Figure 9.
|
| 137 |
+
|
| 138 |
+
# 4.4 Text to 3D Mesh
|
| 139 |
+
|
| 140 |
+
As shown in Figure 11, by integrating with off-the-shelf text-to-image 2D diffusion models [68; 63], our method can be naturally extended to support text-to-image-3D tasks and generate high-quality textured meshes in a short time. See supplementary for more examples.
|
| 141 |
+
|
| 142 |
+
# 5 Conclusion
|
| 143 |
+
|
| 144 |
+
In this paper, we present a novel method for reconstructing a high-quality $3 6 0 ^ { \circ }$ mesh of any object from a single image of it. In comparison to existing zero-shot approaches, our results exhibit superior geometry, enhanced 3D consistency, and a remarkable adherence to the input image. Notably, our approach reconstructs meshes in a single forward pass without the need for time-consuming optimization, resulting in significantly reduced processing time. Furthermore, our method can be effortlessly extended to support the text-to-3D task.
|
| 145 |
+
|
| 146 |
+
# Acknowledgments
|
| 147 |
+
|
| 148 |
+
This work is supported in part by gifts from Qualcomm. We would like to thank Ruoxi Shi, Xinyue Wei, Hansheng Chen, Jiayuan Gu, Fanbo Xiang, Xiaoshuai Zhang, and Yulin Liu for their helpful discussions and manuscript proofreading.
|
| 149 |
+
|
| 150 |
+
We would like to thank the following sketchfab users for the models used for the demo images in this paper: dimaponomar2019 (backpack), danielpeng (bag), pmlzbt233 (wooden barrel), felixyadomi (cactus), avianinda (burger), shedmon (robocat), ie-niels (stool), phucn (armchair), techCIR (mug), sabriny (fox). All models are CC-By licensed.
|
| 151 |
+
|
| 152 |
+
# References
|
| 153 |
+
|
| 154 |
+
[1] Panos Achlioptas, Olga Diamanti, Ioannis Mitliagkas, and Leonidas Guibas. Learning representations and generative models for 3d point clouds. In International conference on machine learning, pages 40–49. PMLR, 2018.
|
| 155 |
+
[2] Shivangi Aneja, Justus Thies, Angela Dai, and Matthias Nießner. Clipface: Text-guided editing of textured 3d morphable models. arXiv preprint arXiv:2212.01406, 2022.
|
| 156 |
+
[3] Zehranaz Canfes, M Furkan Atasoy, Alara Dirik, and Pinar Yanardag. Text and image guided 3d avatar generation and manipulation. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision, pages 4421–4431, 2023.
|
| 157 |
+
[4] 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 preprint arXiv:1512.03012, 2015.
|
| 158 |
+
[5] Anpei Chen, Zexiang Xu, Andreas Geiger, Jingyi Yu, and Hao Su. Tensorf: Tensorial radiance fields. In Computer Vision–ECCV 2022: 17th European Conference, Tel Aviv, Israel, October 23–27, 2022, Proceedings, Part XXXII, pages 333–350. Springer, 2022.
|
| 159 |
+
[6] Anpei Chen, Zexiang Xu, Fuqiang Zhao, Xiaoshuai Zhang, Fanbo Xiang, Jingyi Yu, and Hao Su. Mvsnerf: Fast generalizable radiance field reconstruction from multi-view stereo. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 14124– 14133, 2021.
|
| 160 |
+
[7] Dave Zhenyu Chen, Yawar Siddiqui, Hsin-Ying Lee, Sergey Tulyakov, and Matthias Nießner. Text2tex: Text-driven texture synthesis via diffusion models. arXiv preprint arXiv:2303.11396, 2023.
|
| 161 |
+
[8] Yen-Chi Cheng, Hsin-Ying Lee, Sergey Tulyakov, Alexander Schwing, and Liangyan Gui. Sdfusion: Multimodal 3d shape completion, reconstruction, and generation. arXiv preprint arXiv:2212.04493, 2022.
|
| 162 |
+
[9] Han-Pang Chiu, Leslie Pack Kaelbling, and Tomas Lozano-P ´ erez. Automatic class-specific 3d ´ reconstruction from a single image. CSAIL, pages 1–9, 2009.
|
| 163 |
+
[10] Gene Chou, Yuval Bahat, and Felix Heide. Diffusion-sdf: Conditional generative modeling of signed distance functions. 2023.
|
| 164 |
+
[11] Christopher B Choy, Danfei Xu, JunYoung Gwak, Kevin Chen, and Silvio Savarese. 3d-r2n2: A unified approach for single and multi-view 3d object reconstruction. In Computer Vision– ECCV 2016: 14th European Conference, Amsterdam, The Netherlands, October 11-14, 2016, Proceedings, Part VIII 14, pages 628–644. Springer, 2016.
|
| 165 |
+
[12] Matt Deitke, Dustin Schwenk, Jordi Salvador, Luca Weihs, Oscar Michel, Eli VanderBilt, Ludwig Schmidt, Kiana Ehsani, Aniruddha Kembhavi, and Ali Farhadi. Objaverse: A universe of annotated 3d objects. arXiv preprint arXiv:2212.08051, 2022.
|
| 166 |
+
[13] Congyue Deng, Chiyu Jiang, Charles R Qi, Xinchen Yan, Yin Zhou, Leonidas Guibas, Dragomir Anguelov, et al. Nerdi: Single-view nerf synthesis with language-guided diffusion as general image priors. arXiv preprint arXiv:2212.03267, 2022.
|
| 167 |
+
[14] Maximilian Denninger, Dominik Winkelbauer, Martin Sundermeyer, Wout Boerdijk, Markus Knauer, Klaus H. Strobl, Matthias Humt, and Rudolph Triebel. Blenderproc2: A procedural pipeline for photorealistic rendering. Journal of Open Source Software, 8(82):4901, 2023.
|
| 168 |
+
[15] Laura Downs, Anthony Francis, Nate Koenig, Brandon Kinman, Ryan Hickman, Krista Reymann, Thomas B McHugh, and Vincent Vanhoucke. Google scanned objects: A highquality dataset of 3d scanned household items. In 2022 International Conference on Robotics and Automation (ICRA), pages 2553–2560. IEEE, 2022.
|
| 169 |
+
[16] Haoqiang Fan, Hao Su, and Leonidas J Guibas. A point set generation network for 3d object reconstruction from a single image. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 605–613, 2017.
|
| 170 |
+
[17] Rinon Gal, Yuval Alaluf, Yuval Atzmon, Or Patashnik, Amit H Bermano, Gal Chechik, and Daniel Cohen-Or. An image is worth one word: Personalizing text-to-image generation using textual inversion. arXiv preprint arXiv:2208.01618, 2022.
|
| 171 |
+
[18] Jun Gao, Tianchang Shen, Zian Wang, Wenzheng Chen, Kangxue Yin, Daiqing Li, Or Litany, Zan Gojcic, and Sanja Fidler. Get3d: A generative model of high quality 3d textured shapes learned from images. Advances In Neural Information Processing Systems, 35:31841–31854, 2022.
|
| 172 |
+
[19] Rohit Girdhar, David F Fouhey, Mikel Rodriguez, and Abhinav Gupta. Learning a predictable and generative vector representation for objects. In Computer Vision–ECCV 2016: 14th European Conference, Amsterdam, The Netherlands, October 11-14, 2016, Proceedings, Part VI 14, pages 484–499. Springer, 2016.
|
| 173 |
+
[20] Thibault Groueix, Matthew Fisher, Vladimir G Kim, Bryan C Russell, and Mathieu Aubry. A papier-mach ˆ e approach to learning 3d surface generation. In ´ Proceedings of the IEEE conference on computer vision and pattern recognition, pages 216–224, 2018.
|
| 174 |
+
[21] Anchit Gupta, Wenhan Xiong, Yixin Nie, Ian Jones, and Barlas Oguz. 3dgen: Triplane latent ˘ diffusion for textured mesh generation. arXiv preprint arXiv:2303.05371, 2023.
|
| 175 |
+
[22] Philipp Henzler, Jeremy Reizenstein, Patrick Labatut, Roman Shapovalov, Tobias Ritschel, Andrea Vedaldi, and David Novotny. Unsupervised learning of 3d object categories from videos in the wild. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 4700–4709, 2021.
|
| 176 |
+
[23] Fangzhou Hong, Mingyuan Zhang, Liang Pan, Zhongang Cai, Lei Yang, and Ziwei Liu. Avatarclip: Zero-shot text-driven generation and animation of 3d avatars. arXiv preprint arXiv:2205.08535, 2022.
|
| 177 |
+
[24] Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. Lora: Low-rank adaptation of large language models. arXiv preprint arXiv:2106.09685, 2021.
|
| 178 |
+
[25] Zixuan Huang, Stefan Stojanov, Anh Thai, Varun Jampani, and James M Rehg. Planes vs. chairs: Category-guided 3d shape learning without any 3d cues. In Computer Vision–ECCV 2022: 17th European Conference, Tel Aviv, Israel, October 23–27, 2022, Proceedings, Part I, pages 727–744. Springer, 2022.
|
| 179 |
+
[26] Ajay Jain, Ben Mildenhall, Jonathan T Barron, Pieter Abbeel, and Ben Poole. Zero-shot text-guided object generation with dream fields. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 867–876, 2022.
|
| 180 |
+
[27] Wonbong Jang and Lourdes Agapito. Codenerf: Disentangled neural radiance fields for object categories. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 12949–12958, 2021.
|
| 181 |
+
[28] Nikolay Jetchev. Clipmatrix: Text-controlled creation of 3d textured meshes. arXiv preprint arXiv:2109.12922, 2021.
|
| 182 |
+
[29] Mohammad Mahdi Johari, Yann Lepoittevin, and Franc¸ois Fleuret. Geonerf: Generalizing nerf with geometry priors. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 18365–18375, 2022.
|
| 183 |
+
[30] Heewoo Jun and Alex Nichol. Shap-e: Generating conditional 3d implicit functions. arXiv preprint arXiv:2305.02463, 2023.
|
| 184 |
+
[31] Angjoo Kanazawa, Shubham Tulsiani, Alexei A Efros, and Jitendra Malik. Learning categoryspecific mesh reconstruction from image collectionsgirdhar2016learning. In Proceedings of the European Conference on Computer Vision (ECCV), pages 371–386, 2018.
|
| 185 |
+
[32] Nasir Khalid, Tianhao Xie, Eugene Belilovsky, and Tiberiu Popa. Text to mesh without 3d supervision using limit subdivision. arXiv preprint arXiv:2203.13333, 2022.
|
| 186 |
+
[33] Alexander Kirillov, Eric Mintun, Nikhila Ravi, Hanzi Mao, Chloe Rolland, Laura Gustafson, Tete Xiao, Spencer Whitehead, Alexander C Berg, Wan-Yen Lo, et al. Segment anything. arXiv preprint arXiv:2304.02643, 2023.
|
| 187 |
+
[34] Jona´s Kulh ˇ anek, Erik Derner, Torsten Sattler, and Robert Babu ´ ska. Viewformer: Nerf-free ˇ neural rendering from few images using transformers. In Computer Vision–ECCV 2022: 17th European Conference, Tel Aviv, Israel, October 23–27, 2022, Proceedings, Part XV, pages 198–216. Springer, 2022.
|
| 188 |
+
[35] Han-Hung Lee and Angel X Chang. Understanding pure clip guidance for voxel grid nerf models. arXiv preprint arXiv:2209.15172, 2022.
|
| 189 |
+
[36] Chen-Hsuan Lin, Jun Gao, Luming Tang, Towaki Takikawa, Xiaohui Zeng, Xun Huang, Karsten Kreis, Sanja Fidler, Ming-Yu Liu, and Tsung-Yi Lin. Magic3d: High-resolution text-to-3d content creation. arXiv preprint arXiv:2211.10440, 2022.
|
| 190 |
+
[37] Minghua Liu, Lu Sheng, Sheng Yang, Jing Shao, and Shi-Min Hu. Morphing and sampling network for dense point cloud completion. In Proceedings of the AAAI conference on artificial intelligence, volume 34, pages 11596–11603, 2020.
|
| 191 |
+
[38] Minghua Liu, Ruoxi Shi, Kaiming Kuang, Yinhao Zhu, Xuanlin Li, Shizhong Han, Hong Cai, Fatih Porikli, and Hao Su. Openshape: Scaling up 3d shape representation towards open-world understanding. arXiv preprint arXiv:2305.10764, 2023.
|
| 192 |
+
[39] Minghua Liu, Minhyuk Sung, Radomir Mech, and Hao Su. Deepmetahandles: Learning deformation meta-handles of 3d meshes with biharmonic coordinates. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 12–21, 2021.
|
| 193 |
+
[40] Minghua Liu, Yinhao Zhu, Hong Cai, Shizhong Han, Zhan Ling, Fatih Porikli, and Hao Su. Partslip: Low-shot part segmentation for 3d point clouds via pretrained image-language models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 21736–21746, 2023.
|
| 194 |
+
[41] Ruoshi Liu, Rundi Wu, Basile Van Hoorick, Pavel Tokmakov, Sergey Zakharov, and Carl Vondrick. Zero-1-to-3: Zero-shot one image to 3d object. arXiv preprint arXiv:2303.11328, 2023.
|
| 195 |
+
[42] Yuan Liu, Sida Peng, Lingjie Liu, Qianqian Wang, Peng Wang, Christian Theobalt, Xiaowei Zhou, and Wenping Wang. Neural rays for occlusion-aware image-based rendering. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 7824–7833, 2022.
|
| 196 |
+
[43] Zhengzhe Liu, Peng Dai, Ruihui Li, Xiaojuan Qi, and Chi-Wing Fu. Iss: Image as stetting stone for text-guided 3d shape generation. arXiv preprint arXiv:2209.04145, 2022.
|
| 197 |
+
[44] Zhengzhe Liu, Peng Dai, Ruihui Li, Xiaojuan Qi, and Chi-Wing Fu. Iss++: Image as stepping stone for text-guided 3d shape generation. arXiv preprint arXiv:2303.15181, 2023.
|
| 198 |
+
[45] Xiaoxiao Long, Cheng Lin, Peng Wang, Taku Komura, and Wenping Wang. Sparseneus: Fast generalizable neural surface reconstruction from sparse views. In Computer Vision–ECCV 2022: 17th European Conference, Tel Aviv, Israel, October 23–27, 2022, Proceedings, Part XXXII, pages 210–227. Springer, 2022.
|
| 199 |
+
[46] William E Lorensen and Harvey E Cline. Marching cubes: A high resolution 3d surface construction algorithm. ACM siggraph computer graphics, 21(4):163–169, 1987.
|
| 200 |
+
[47] Oier Mees, Maxim Tatarchenko, Thomas Brox, and Wolfram Burgard. Self-supervised 3d shape and viewpoint estimation from single images for robotics. In 2019 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), pages 6083–6089. IEEE, 2019.
|
| 201 |
+
[48] Luke Melas-Kyriazi, Christian Rupprecht, Iro Laina, and Andrea Vedaldi. Realfusion: 360 $\{ \backslash \deg \}$ reconstruction of any object from a single image. arXiv preprint arXiv:2302.10663, 2023.
|
| 202 |
+
[49] Luke Melas-Kyriazi, Christian Rupprecht, and Andrea Vedaldi. pc2: Projection—conditioned point cloud diffusion for single-image 3d reconstruction. arXiv preprint arXiv:2302.10668, 2023.
|
| 203 |
+
[50] Lars Mescheder, Michael Oechsle, Michael Niemeyer, Sebastian Nowozin, and Andreas Geiger. Occupancy networks: Learning 3d reconstruction in function space. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 4460–4470, 2019.
|
| 204 |
+
[51] Gal Metzer, Elad Richardson, Or Patashnik, Raja Giryes, and Daniel Cohen-Or. Latent-nerf for shape-guided generation of 3d shapes and textures. arXiv preprint arXiv:2211.07600, 2022.
|
| 205 |
+
[52] Oscar Michel, Roi Bar-On, Richard Liu, Sagie Benaim, and Rana Hanocka. Text2mesh: Text-driven neural stylization for meshes. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 13492–13502, 2022.
|
| 206 |
+
[53] 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. Communications of the ACM, 65(1):99–106, 2021.
|
| 207 |
+
[54] Paritosh Mittal, Yen-Chi Cheng, Maneesh Singh, and Shubham Tulsiani. Autosdf: Shape priors for 3d completion, reconstruction and generation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 306–315, 2022.
|
| 208 |
+
[55] Norman Muller, Andrea Simonelli, Lorenzo Porzi, Samuel Rota Bul ¨ o, Matthias Nießner, and \` Peter Kontschieder. Autorf: Learning 3d object radiance fields from single view observations. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 3971–3980, 2022.
|
| 209 |
+
[56] Charlie Nash, Yaroslav Ganin, SM Ali Eslami, and Peter Battaglia. Polygen: An autoregressive generative model of 3d meshes. In International conference on machine learning, pages 7220– 7229. PMLR, 2020.
|
| 210 |
+
[57] Alex Nichol, Heewoo Jun, Prafulla Dhariwal, Pamela Mishkin, and Mark Chen. Point-e: A system for generating 3d point clouds from complex prompts. arXiv preprint arXiv:2212.08751, 2022.
|
| 211 |
+
[58] Jeong Joon Park, Peter Florence, Julian Straub, Richard Newcombe, and Steven Lovegrove. Deepsdf: Learning continuous signed distance functions for shape representation. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 165–174, 2019.
|
| 212 |
+
[59] Georgios Pavlakos, Vasileios Choutas, Nima Ghorbani, Timo Bolkart, Ahmed AA Osman, Dimitrios Tzionas, and Michael J Black. Expressive body capture: 3d hands, face, and body from a single image. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 10975–10985, 2019.
|
| 213 |
+
[60] Ben Poole, Ajay Jain, Jonathan T Barron, and Ben Mildenhall. Dreamfusion: Text-to-3d using 2d diffusion. arXiv preprint arXiv:2209.14988, 2022.
|
| 214 |
+
[61] 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.
|
| 215 |
+
[62] Amit Raj, Srinivas Kaza, Ben Poole, Michael Niemeyer, Nataniel Ruiz, Ben Mildenhall, Shiran Zada, Kfir Aberman, Michael Rubinstein, Jonathan Barron, et al. Dreambooth3d: Subject-driven text-to-3d generation. arXiv preprint arXiv:2303.13508, 2023.
|
| 216 |
+
[63] 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.
|
| 217 |
+
[64] Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-shot text-to-image generation. In International Conference on Machine Learning, pages 8821–8831. PMLR, 2021.
|
| 218 |
+
[65] Jeremy Reizenstein, Roman Shapovalov, Philipp Henzler, Luca Sbordone, Patrick Labatut, and David Novotny. Common objects in 3d: Large-scale learning and evaluation of real-life 3d category reconstruction. In International Conference on Computer Vision, 2021.
|
| 219 |
+
[66] Yufan Ren, Fangjinhua Wang, Tong Zhang, Marc Pollefeys, and Sabine Susstrunk. Volrecon: ¨ Volume rendering of signed ray distance functions for generalizable multi-view reconstruction. arXiv preprint arXiv:2212.08067, 2022.
|
| 220 |
+
[67] Elad Richardson, Gal Metzer, Yuval Alaluf, Raja Giryes, and Daniel Cohen-Or. Texture: Text-guided texturing of 3d shapes. arXiv preprint arXiv:2302.01721, 2023.
|
| 221 |
+
[68] Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Bjorn Ommer. ¨ High-resolution image synthesis with latent diffusion models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10684–10695, 2022.
|
| 222 |
+
[69] Chitwan Saharia, William Chan, Saurabh Saxena, Lala Li, Jay Whang, Emily Denton, Seyed Kamyar Seyed Ghasemipour, Burcu Karagol Ayan, S Sara Mahdavi, Rapha Gontijo Lopes, et al. Photorealistic text-to-image diffusion models with deep language understanding. arXiv preprint arXiv:2205.11487, 2022.
|
| 223 |
+
[70] Shunsuke Saito, Zeng Huang, Ryota Natsume, Shigeo Morishima, Angjoo Kanazawa, and Hao Li. Pifu: Pixel-aligned implicit function for high-resolution clothed human digitization. In Proceedings of the IEEE/CVF international conference on computer vision, pages 2304–2314, 2019.
|
| 224 |
+
[71] Aditya Sanghi, Hang Chu, Joseph G Lambourne, Ye Wang, Chin-Yi Cheng, Marco Fumero, and Kamal Rahimi Malekshan. Clip-forge: Towards zero-shot text-to-shape generation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 18603–18613, 2022.
|
| 225 |
+
[72] Junyoung Seo, Wooseok Jang, Min-Seop Kwak, Jaehoon Ko, Hyeonsu Kim, Junho Kim, JinHwa Kim, Jiyoung Lee, and Seungryong Kim. Let 2d diffusion model know 3d-consistency for robust text-to-3d generation. arXiv preprint arXiv:2303.07937, 2023.
|
| 226 |
+
[73] Ruoxi Shi, Hansheng Chen, Zhuoyang Zhang, Minghua Liu, Chao Xu, Xinyue Wei, Linghao Chen, Chong Zeng, and Hao Su. Zero $^ { 1 2 3 + + }$ : a single image to consistent multi-view diffusion base model. arXiv preprint arXiv:2310.15110, 2023.
|
| 227 |
+
[74] Jiaming Sun, Zehong Shen, Yuang Wang, Hujun Bao, and Xiaowei Zhou. Loftr: Detector-free local feature matching with transformers. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 8922–8931, 2021.
|
| 228 |
+
[75] Junshu Tang, Tengfei Wang, Bo Zhang, Ting Zhang, Ran Yi, Lizhuang Ma, and Dong Chen. Make-it-3d: High-fidelity 3d creation from a single image with diffusion prior. arXiv preprint arXiv:2303.14184, 2023. rendering. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 15182–15192, 2021.
|
| 229 |
+
[77] Mukund Varma, Peihao Wang, Xuxi Chen, Tianlong Chen, Subhashini Venugopalan, and Zhangyang Wang. Is attention all that nerf needs? In The Eleventh International Conference on Learning Representations, 2022.
|
| 230 |
+
[78] Haochen Wang, Xiaodan Du, Jiahao Li, Raymond A Yeh, and Greg Shakhnarovich. Score jacobian chaining: Lifting pretrained 2d diffusion models for 3d generation. arXiv preprint arXiv:2212.00774, 2022.
|
| 231 |
+
[79] Nanyang Wang, Yinda Zhang, Zhuwen Li, Yanwei Fu, Wei Liu, and Yu-Gang Jiang. Pixel2mesh: Generating 3d mesh models from single rgb images. In Proceedings of the European conference on computer vision (ECCV), pages 52–67, 2018.
|
| 232 |
+
[80] 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. arXiv preprint arXiv:2106.10689, 2021.
|
| 233 |
+
[81] Qianqian Wang, Zhicheng Wang, Kyle Genova, Pratul P Srinivasan, Howard Zhou, Jonathan T Barron, Ricardo Martin-Brualla, Noah Snavely, and Thomas Funkhouser. Ibrnet: Learning multi-view image-based rendering. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 4690–4699, 2021.
|
| 234 |
+
[82] Jiacheng Wei, Hao Wang, Jiashi Feng, Guosheng Lin, and Kim-Hui Yap. Taps3d: Text-guided 3d textured shape generation from pseudo supervision, 2023.
|
| 235 |
+
[83] Chao Wen, Yinda Zhang, Zhuwen Li, and Yanwei Fu. Pixel2mesh $^ { + + }$ : Multi-view 3d mesh generation via deformation. In Proceedings of the IEEE/CVF international conference on computer vision, pages 1042–1051, 2019.
|
| 236 |
+
[84] Chao-Yuan Wu, Justin Johnson, Jitendra Malik, Christoph Feichtenhofer, and Georgia Gkioxari. Multiview compressive coding for 3d reconstruction. arXiv preprint arXiv:2301.08247, 2023.
|
| 237 |
+
[85] Jiajun Wu, Yifan Wang, Tianfan Xue, Xingyuan Sun, Bill Freeman, and Josh Tenenbaum. Marrnet: 3d shape reconstruction via 2.5 d sketches. Advances in neural information processing systems, 30, 2017.
|
| 238 |
+
[86] Haozhe Xie, Hongxun Yao, Xiaoshuai Sun, Shangchen Zhou, and Shengping Zhang. Pix2vox: Context-aware 3d reconstruction from single and multi-view images. In Proceedings of the IEEE/CVF international conference on computer vision, pages 2690–2698, 2019.
|
| 239 |
+
[87] Haozhe Xie, Hongxun Yao, Shengping Zhang, Shangchen Zhou, and Wenxiu Sun. Pix2vox $^ { + + }$ : Multi-scale context-aware 3d object reconstruction from single and multiple images. International Journal of Computer Vision, 128(12):2919–2935, 2020.
|
| 240 |
+
[88] Dejia Xu, Yifan Jiang, Peihao Wang, Zhiwen Fan, Yi Wang, and Zhangyang Wang. Neurallift360: Lifting an in-the-wild 2d photo to a 3d object with $\mathrm { 3 6 0 ~ \{ \backslash { d e g } \} }$ views. arXiv preprint arXiv:2211.16431, 2022.
|
| 241 |
+
[89] Jiale Xu, Xintao Wang, Weihao Cheng, Yan-Pei Cao, Ying Shan, Xiaohu Qie, and Shenghua Gao. Dream3d: Zero-shot text-to-3d synthesis using 3d shape prior and text-to-image diffusion models. arXiv preprint arXiv:2212.14704, 2022.
|
| 242 |
+
[90] Qiangeng Xu, Weiyue Wang, Duygu Ceylan, Radomir Mech, and Ulrich Neumann. Disn: Deep implicit surface network for high-quality single-view 3d reconstruction. Advances in neural information processing systems, 32, 2019.
|
| 243 |
+
[91] Farid Yagubbayli, Yida Wang, Alessio Tonioni, and Federico Tombari. Legoformer: Transformers for block-by-block multi-view 3d reconstruction. arXiv preprint arXiv:2106.12102, 2021.
|
| 244 |
+
[92] Daniel Yang, Tarik Tosun, Benjamin Eisner, Volkan Isler, and Daniel Lee. Robotic grasping through combined image-based grasp proposal and 3d reconstruction. In 2021 IEEE International Conference on Robotics and Automation (ICRA), pages 6350–6356. IEEE, 2021.
|
| 245 |
+
[93] Hao Yang, Lanqing Hong, Aoxue Li, Tianyang Hu, Zhenguo Li, Gim Hee Lee, and Liwei Wang. Contranerf: Generalizable neural radiance fields for synthetic-to-real novel view synthesis via contrastive learning. arXiv preprint arXiv:2303.11052, 2023.
|
| 246 |
+
[94] Yaoqing Yang, Chen Feng, Yiru Shen, and Dong Tian. Foldingnet: Point cloud auto-encoder via deep grid deformation. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 206–215, 2018.
|
| 247 |
+
[95] Alex Yu, Vickie Ye, Matthew Tancik, and Angjoo Kanazawa. pixelnerf: Neural radiance fields from one or few images. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 4578–4587, 2021.
|
| 248 |
+
[96] Xiaohui Zeng, Arash Vahdat, Francis Williams, Zan Gojcic, Or Litany, Sanja Fidler, and Karsten Kreis. Lion: Latent point diffusion models for 3d shape generation. arXiv preprint arXiv:2210.06978, 2022. [97] Lvmin Zhang and Maneesh Agrawala. Adding conditional control to text-to-image diffusion models, 2023. [98] Xiaoshuai Zhang, Sai Bi, Kalyan Sunkavalli, Hao Su, and Zexiang Xu. Nerfusion: Fusing radiance fields for large-scale scene reconstruction. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 5449–5458, 2022. [99] Zhizhuo Zhou and Shubham Tulsiani. Sparsefusion: Distilling view-conditioned diffusion for 3d reconstruction. In CVPR, 2023.
|
| 249 |
+
[100] Silvia Zuffi, Angjoo Kanazawa, and Michael J Black. Lions and tigers and bears: Capturing non-rigid, 3d, articulated shape from images. In Proceedings of the IEEE conference on Computer Vision and Pattern Recognition, pages 3955–3963, 2018.
|
| 250 |
+
[101] Silvia Zuffi, Angjoo Kanazawa, David W Jacobs, and Michael J Black. 3d menagerie: Modeling the 3d shape and pose of animals. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 6365–6373, 2017.
|
| 251 |
+
|
| 252 |
+
# Appendix
|
| 253 |
+
|
| 254 |
+
We first show more qualitative comparison in Section A, which is followed by a demonstration of additional examples on real-world images and the text-to-3D task in Sections B and C respectively. Furthermore, we present the details of our elevation estimation module in Section D, training and evaluation details in Section E. We finally show the failure cases and discuss the limitations in Section F.
|
| 255 |
+
|
| 256 |
+
# A More Qualitative Comparison
|
| 257 |
+
|
| 258 |
+

|
| 259 |
+
Figure 12: We compare One-2-3-45 with Point-E [57], Shap-E [30], Zero123 (Stable Dreamfusion version) [41], 3DFuse [72], and RealFusion [48]. In each example, we present both the textured and textureless meshes. As 3DFuse [72] and RealFusion [48] do not natively support the export of textured meshes, we showcase the results of volume rendering instead.
|
| 260 |
+
|
| 261 |
+
In Figure 12, we demonstrate more qualitative comparison on Objaverse [12] and GoogleScannedObjects (GSO) [15] datasets. Note that all test shapes are not seen during the training of our 3D reconstruction module.
|
| 262 |
+
|
| 263 |
+
# B More Examples on Real-World Images
|
| 264 |
+
|
| 265 |
+
In Figure 13, we showcase more examples on real-world images and compare our method with the concurrent method Shap-E [30]. The input images are from unsplash.com or captured by ourselves. Note that our results exhibit a closer adherence to the input image.
|
| 266 |
+
|
| 267 |
+
# C More Examples on Text-to-3D
|
| 268 |
+
|
| 269 |
+
In Figure 14, we present additional examples for the text-to-3D task. It is evident that existing approaches struggle to capture fine-grained details, such as a tree hollow, or achieve compositionality, as seen in examples like an orange stool with green legs, a pineapple-shaped Havana hat, or a rocking horse chair. In contrast, our method produces superior results that adhere more closely to the input text. We hypothesize that controlling such fine-grained attributes in the 3D space using existing optimization strategies is inherently challenging. However, by leveraging established 2D text-to-image diffusion models, our method becomes more effective in lifting a single 2D image to a corresponding 3D textured mesh.
|
| 270 |
+
|
| 271 |
+

|
| 272 |
+
Figure 13: We compare One-2-3-45 with Shap-E [30] on real-world images. In each example, we present the input image, generated textured and textureless meshes.
|
| 273 |
+
|
| 274 |
+
# D Details of Elevation Estimation
|
| 275 |
+
|
| 276 |
+
To estimate the elevation angle $\theta$ of the input image, we first utilize Zero123 [41] to predict four nearby views (10 degrees apart) of the input view. With these predicted views, we proceed to enumerate all possible elevation angles and compute the re-projection error for each candidate angle.
|
| 277 |
+
|
| 278 |
+

|
| 279 |
+
Figure 14: Text-to-3D: We compare our method against two native text-to-3D approaches Stable DreamFusion [60] and 3DFuse [72]. To enable text-to-3D, our method first uses a pretrained text-toimage model DALL-E 2 [63] to generate an image from input text (prompted with “3d model, long shot”), and then uplifts the image to a 3D textured mesh.
|
| 280 |
+
|
| 281 |
+
The re-projection error assesses the consistency between camera poses and image observations, akin to the bundle adjustment module employed in the Structure-from-Motion (SfM) pipeline.
|
| 282 |
+
|
| 283 |
+
Specifically, we enumerate all candidate elevation angles in a coarse-to-fine manner. In the coarse stage, we enumerate elevation angles with a 10-degree interval. Once we have determined the elevation angle $e ^ { * }$ associated with the smallest re-projection error, we proceed to the fine stage. In this stage, we enumerate elevation angle candidates ranging from $e ^ { * } - 1 0 ^ { \circ }$ to $e ^ { * } + 1 0 ^ { \circ }$ with a 1-degree interval. This coarse-to-fine design facilitates rapid estimation, completing the elevation estimation module in under 1 second for each shape.
|
| 284 |
+
|
| 285 |
+
Given a set of four predicted nearby views, we perform feature matching to identify corresponding keypoints across each pair of images (a total of six pairs) using an off-the-shelf module LoFTR [74]. For each elevation angle candidate, we calculate the camera pose for the input image by employing the spherical coordinate system with a radius of 1.2 and an azimuth angle of 0. Note that the azimuth angle $\phi$ and the radius $r$ can be arbitrarily adjusted, resulting in the rotation and scaling of the reconstructed object accordingly. Subsequently, we obtain the camera poses for the four predicted views by incorporating the specified delta poses.
|
| 286 |
+
|
| 287 |
+
Once we have the four posed images, we compute the re-projection error by enumerating triplet images. For each triplet of images $( a , b , c )$ sharing a set of keypoints $P$ , we consider each point $p \in P$ . Utilizing images $a$ and $b$ , we perform triangulation to determine the 3D location of $p$ . We then project the 3D point onto the third image $c$ and calculate the reprojection error, which is defined as the $l 1$ distance between the reprojected 2D pixel and the estimated keypoint in image $c$ . By enumerating all image triplets and their corresponding shared keypoints, we obtain the mean projection error for each elevation angle candidate.
|
| 288 |
+
|
| 289 |
+
# E Details of Training and Evaluation
|
| 290 |
+
|
| 291 |
+
Training We train the reconstruction module using the following loss function:
|
| 292 |
+
|
| 293 |
+
$$
|
| 294 |
+
\mathcal { L } = \mathcal { L } _ { r g b } + \lambda _ { 1 } \mathcal { L } _ { e i k o n a l } + \lambda _ { 2 } \mathcal { L } _ { s p a r s i t y }
|
| 295 |
+
$$
|
| 296 |
+
|
| 297 |
+
where $\mathcal { L } _ { r g b }$ represents the $l 1$ loss between the rendered and ground truth color, weighted by the sum of accumulated weights; $\mathcal { L } _ { e i k o n a l }$ and $\mathcal { L } _ { s p a r s i t y }$ are the Eikonal and sparsity terms, respectively, following SparseNeuS [45]. We empirically set the weights as $\lambda _ { 0 } = 1$ , $\lambda _ { 1 } = 0 . 1$ , and $\lambda _ { 2 } = 0 . 0 2$ . For $\lambda _ { 2 }$ , we adopt a linear warm-up strategy following SparseNeuS [45]. To train our reconstruction module, we utilize the LVIS subset of the Objaverse [12] dataset, which consists of 46k 3D models across 1,156 categories. The reconstruction module is trained for $3 0 0 \mathrm { k }$ iterations using two A10 GPUs, with the training process lasting approximately 6 days. It is important to note that our reconstruction module does not heavily rely on large-scale training data, as it primarily leverages local correspondence to infer the geometry, which is relatively easier to learn and generalize.
|
| 298 |
+
|
| 299 |
+
Evaluation We evaluate all baseline approaches using their official codebase. Since the approaches take only a single image as input, the predicted mesh may not have the same scale and transformation as the ground-truth mesh. To ensure a fair comparison, we employ the following process to align the predicted mesh with the ground-truth mesh. First, we align the up direction for the results generated by each approach. Next, for each generated mesh, we perform a linear search over scales and rotation angles along the up direction. After applying each pair of scale and $\mathbf { Z }$ -rotation, we utilize the Iterative Closest Point (ICP) algorithm to align the transformed mesh to the ground-truth mesh. Finally, we select the mesh with the largest number of inliers as the final alignment. This alignment process helps us establish a consistent reference frame for evaluating the predicted meshes across different approaches. To calculate CLIP similarity, we render both ground-truth and generated meshes, capturing 24 views around the 3D shape from fixed viewpoints - 12 views at $3 0 ^ { \circ }$ elevation and 12 views at $0 ^ { \circ }$ elevation.
|
| 300 |
+
|
| 301 |
+
# F Failure Cases and Limitations
|
| 302 |
+
|
| 303 |
+
Our method relies on Zero123 for generating multi-view images, which introduces challenges due to its occasional production of inconsistent results. In Figure 15, we present two typical cases that exemplify such inconsistencies. The first case involves an input view that lacks sufficient information, such as the back view of a fox. In this scenario, Zero123 struggles to generate consistent predictions for the invisible regions, such as the face of the fox. As a consequence, our method may encounter difficulties in accurately inferring the geometry for those regions. The second case involves an input view with ambiguous or complex structures, such as the pulp and peel of a banana. In such situations, Zero123’s ability to accurately infer the underlying geometry becomes limited. As a result, our method may be affected by the inconsistent predictions generated by Zero123. It is important to acknowledge that these limitations arise from the occasional scenarios, and they can impact the performance of our method in certain cases. Addressing these challenges and refining the reliability of Zero123’s predictions remain areas for further investigation and improvement.
|
| 304 |
+
|
| 305 |
+

|
| 306 |
+
Figure 15: Failure cases. Our method relies on Zero123 to generate multi-view images, and we encounter challenges when Zero123 generates inconsistent results. (a) The input view lacks sufficient information. (b) The input view contains ambiguous or complicated structures.
|
| 307 |
+
|
| 308 |
+
We have also noticed slight artifacts on the back side of our generated results. As one of the first works in combining view-conditioned 2D diffusion models with generalizable multi-view reconstruction, we believe that there is still ample room for exploring more advanced reconstruction techniques and incorporating additional regularizations. By doing so, we expect to significantly mitigate the minor artifacts and further enhance results in the future.
|
md/dev/ATiz_CDA66/ATiz_CDA66.md
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AdaptFormer: Adapting Vision Transformers for Scalable Visual Recognition
|
| 2 |
+
|
| 3 |
+
Shoufa Chen1⇤ Chongjian Ge1⇤ Zhan Tong2 Jiangliu Wang2 Yibing Song2 Jue Wang2 Ping Luo1
|
| 4 |
+
|
| 5 |
+
1The University of Hong Kong 2Tencent AI Lab
|
| 6 |
+
|
| 7 |
+
# Abstract
|
| 8 |
+
|
| 9 |
+
Pretraining Vision Transformers (ViTs) has achieved great success in visual recognition. A following scenario is to adapt a ViT to various image and video recognition tasks. The adaptation is challenging because of heavy computation and memory storage. Each model needs an independent and complete finetuning process to adapt to different tasks, which limits its transferability to different visual domains. To address this challenge, we propose an effective adaptation approach for Transformer, namely AdaptFormer, which can adapt the pre-trained ViTs into many different image and video tasks efficiently. It possesses several benefits more appealing than prior arts. Firstly, AdaptFormer introduces lightweight modules that only add less than $2 \%$ extra parameters to a ViT, while it is able to increase the ViT’s transferability without updating its original pre-trained parameters, significantly outperforming the existing $100 \%$ fully fine-tuned models on action recognition benchmarks. Secondly, it can be plug-and-play in different Transformers and scalable to many visual tasks. Thirdly, extensive experiments on five image and video datasets show that AdaptFormer largely improves ViTs in the target domains. For example, when updating just $1 . 5 \%$ extra parameters, it achieves about $10 \%$ and $19 \%$ relative improvement compared to the fully fine-tuned models on Something-Something v2 and HMDB51, respectively. Code is available at https://github.com/ShoufaChen/AdaptFormer.
|
| 10 |
+
|
| 11 |
+
# 1 Introduction
|
| 12 |
+
|
| 13 |
+
There is a growing interest in adopting a general neural model to tackle a large variety of different tasks since it benefits in reducing the need for task-specific model design and training. Recently, Transformer [81] demonstrates great potential in this goal considering its success in various fields, e.g., natural language processing (NLP) [27, 10, 82, 88], visual recognition [31, 79, 90, 63], dense prediction [83, 11, 98, 96, 86], Generative Adversarial Network (GAN) [52, 48], reinforcement learning (RL) [18, 16, 87], robotics [50, 25], and etc. However, existing literature in computer vision tend to focus on the same network with task-specific weights scenario, where a single network is used to train from scratch or fully fine-tune on a specific dataset, making it infeasible to maintain a separate model weight for every dataset when the number of task grows, especially for the increasing model capacity of state-of-the-art models (e.g., ViT-G/14 [93] with over 1.8 billion parameters).
|
| 14 |
+
|
| 15 |
+
Different from prior arts, we step into the direction of developing same network with almost same weights and achieve superior performance than the full-tuning approach by only tuning less than $2 \%$ parameters, with the remaining over $98 \%$ parameters shared across different tasks. There are two challenges to learning universal representations using a single model. The first one lies in the pre-training stage, which requires algorithms that can learn well-generalized representations that are easy to be applied to many tasks. Recent arts in self-supervised learning [12, 5, 43, 97, 85, 78, 35] can serve as a solution to this challenge. The second one, which is our main concern in this work, is to build an effective pipeline that can adapt the model obtained at the pre-training stage to various downstream tasks by tuning parameters as less as possible and keeping the left parameters frozen.
|
| 16 |
+
|
| 17 |
+
While fine-tuning pre-trained models has been widely studied in NLP [6, 46, 69, 70, 58, 56, 47, 92, 62, 42], this topic is seldomly explored in the vision, where full-tuning of model parameters is still the dominant strategy for adapting vision transformers. However, the full fine-tuning cannot satisfy the goal of universal representation as it assigns an independent set of weights for every task. Linear probing is a straightforward approach to maintaining the pre-trained model fixed by only tuning a specific lightweight classification head for every task. However, linear probing tends to have an unsatisfactory performance and misses the opportunity of pursuing strong but non-linear features [43], which indeed benefit deep learning. More recently, Bahng et.al., [4] aimed to adapt pre-trained models by modifying raw input pixel space. Jia et.al., [51] proposed Visual Prompt Tuning (VPT) to adapt transformer models for downstream vision tasks, which prepends several learnable parameters (prompts) to the patch embeddings and freezes the whole pre-trained backbone.
|
| 18 |
+
|
| 19 |
+
In this work, we propose a lightweight module, namely AdaptFormer, to adapt vision transformers by updating the weights of AdaptFormer. We introduce learnable parameters from the model perspective, which is different from VPT, which inserts learnable parameters into the token space. Our AdaptFormer is conceptually simple yet effective. It consists of two fully connected layers, a non-linear activation function, and a scaling factor. This module is set in parallel to the feed-forward network (FFN) of the original ViT model, as shown in Figure 2b. This design is turned out to be effective for model transfer when processing scalable visual tokens for both image and video data (i.e., image data consists of a small scale of visual tokens while video data consists of a large scale). As shown in Figure 1, compared with the full-tuning strategy, AdaptFormer achieves comparable per
|
| 20 |
+
|
| 21 |
+

|
| 22 |
+
Figure 1: Parameter-Accuracy trade-off. We leverage ViT-Base as backbone and report top-1 accuracy on SSv2 dataset. AdaptFormer can surpass full-tuning with only $0 . 2 \%$ tunable parameters. More detailed results are shown in Table 1.
|
| 23 |
+
|
| 24 |
+
formance on video recognition with only about $0 . 1 \%$ tunable parameters. Meanwhile, with less than $2 \%$ tunable parameters, AdaptFormer surpasses the full-tuning solution by about $10 \%$ on top-1 accuracy. Similar approaches are also proposed in fine-tuning pre-trained language models (PLMs) [6, 46, 70, 42].
|
| 25 |
+
|
| 26 |
+
The key contributions of this paper are summarized as follows: (1) We propose a simple yet effective framework, namely AdaptFormer, for adapting vision transformers to a large variety of downstream visual recognition tasks and avoiding catastrophic interference with each other. To the best of our knowledge, this is the first work that explores efficient fine-tuning in video action recognition. (2) We ablate many design choices and demonstrate the superior robustness of AdaptFormer when parameters scale up. (3) Extensive experiments on various downstream tasks demonstrate that AdaptFormer outperforms existing fine-tuning approaches significantly. By demonstrating the effectiveness of AdaptFormer on multiple visual benchmarks, we hope our work could inspire the research communities to rethink the fine-tuning mechanism in computer vision and make progress toward a flexible yet universal Transformer model for visual recognition.
|
| 27 |
+
|
| 28 |
+
# 2 Related Works
|
| 29 |
+
|
| 30 |
+
In the proposed AdaptFormer, we mainly introduce a plug-and-play module for efficiently fine-tuning the current vision Transformer models. In this section, we perform a literature review on related works from two perspectives, i.e., the vision Transformers, and efficient transfer learning for vision Transformers.
|
| 31 |
+
|
| 32 |
+
# 2.1 Transformer in Vision
|
| 33 |
+
|
| 34 |
+
The Transformer architecture is first introduced in [81] and has re-energized the natural language processing (NLP) field from then on [27, 10]. Inspired by its huge success, researches in the computer vision filed have also evolved into Transformer era since ViTs [31]. The strong capability of modeling long-range relation has facilitated Transformer in various vision tasks, including image classification [31, 63, 60], object detection [11, 98, 22], semantic/instance segmentation [86], video understanding [8, 2, 33, 57], point cloud modeling [95, 41], 3D Object Recognition [20] and even low-level processing [17, 59, 84]. Furthermore, transformers have advanced the vision recognition performance by a large-scale pretraining [21, 67, 13, 36, 43, 78, 71]. In such a situation, given the pre-trained Transformer models, which are more larger than the previously prevalent CNN backbones, one open question is how to fine-tune the big vision models so that they can be adapted into more specific down-stream tasks. To solve the open question, we propose AdaptFormer to transfer ViTs from the pre-trained pre-texts into the target tasks in a more effective and efficient way.
|
| 35 |
+
|
| 36 |
+
# 2.2 Efficient Transfer learning for Transformers
|
| 37 |
+
|
| 38 |
+
Transfer learning targets re-adopting a pre-trained model (either via the supervised or the unsupervised manner) as the starting point and further fine-tuning the specific model on a new task. In the NLP field, transferring the large pre-trained language models (PLMs) [27, 10] into downstream tasks has been the popular paradigm for a long time. Conventional arts [27, 10] set all the network parameters as learnable ones and adapt them to the target tasks. However, with the growth of model sizes and the complexity of the specific tasks, the conventional paradigm is inevitably limited by the huge computational burden. The NLP community has explored several ways for parameter-efficient transfer learning that only set a few parameters learnable and fine-tune them for efficiency. The pioneer works could be mainly categorized from the token [58, 56] and network perspectives [46, 47, 92, 40]. Basically speaking, the token-related methods [56, 58] typically prepend several learnable prefix vectors/tokens to the projected tokens within the multi-head self-attention layers (MHSA [81]). The philosophy behind it is to assist the pre-trained models in understanding downstream tasks with the guidance of extra token information. On the other hand, network-related methods [46, 47] integrate shallow modules to improve the model transferability. The introduced modules adapt the produced representations into the downstream tasks via features fusion.
|
| 39 |
+
|
| 40 |
+
Recently, with the emergence of a much more large-scale dataset [26, 72, 74, 66, 53], increasing researchers in computer vision have adopted the homologous paradigm, i.e., first pre-training and then fine-tuning, to advance the vision tasks. As for the second stage, traditional methods typically adopt the full-tuning arts in the downstream tasks. Rare attention has been drawn to the field of efficient adaptation, especially in the field of vision Transformers. Inspired by Prompting in NLP, [51] introduced the learnable tokens in exploring the efficient adaptation for ViTs. We empirically found that the performance of prompting is hindered by the scale of tokens. That is to say, for the tasks where the number of tokens is on a small scale, e.g., image classification, Prompting is efficient for improving the model transferability. However, for larger scale tokens, e.g., video understanding, Prompting presents limited potential. This observation motivates us to introduce AdaptFormer, which is effective in the scenarios of scalable visual tokens.
|
| 41 |
+
|
| 42 |
+
# 3 Approach
|
| 43 |
+
|
| 44 |
+
We propose AdaptFormer for efficiently transferring large pre-trained vision transformer models to downstream tasks, in both image and video domains. AdaptFormer attains strong transfer learning abilities by only fine-tuning a small number of extra parameters, circumventing catastrophic interference among tasks. We illustrate the overall framework of AdaptFormer in Figure 2b.
|
| 45 |
+
|
| 46 |
+
# 3.1 Preliminary and Notation
|
| 47 |
+
|
| 48 |
+
Vision Transformers (ViTs) are first introduced by [31] into vision recognition. A vanilla vision Transformer basically consists of a patch embedding layer and several consecutively connected encoders, as depicted in Figure 2a. Given an image $\boldsymbol { x } ^ { \setminus } \in \dot { \mathbb { R } } ^ { H \times W \times 3 }$ , the patch embedding layer first splits and flatten the sample $x$ into sequential patches $x _ { p } \in \mathbb { R } ^ { N \times ( P ^ { 2 } d ) }$ , where $( H , W )$ represents the height and width of the input image, $( P , P )$ is the resolution of each image patch, $d$ denotes the output channel, and $N = H W / P ^ { 2 }$ is the number of image tokens. The overall combination of a prepended [CLS] token and the image tokens $x _ { p }$ are further fed into Transformer encoders for attention calculation.
|
| 49 |
+
|
| 50 |
+

|
| 51 |
+
Figure 2: Comparison of previous full and our AdaptFormer fine-tuning. AdaptFormer is conceptually simple by replacing the original MLP block with AdaptMLP, which consists of two branches, including the frozen branch (left) and the trainable down $ \mathtt { u p }$ bottleneck module (right).
|
| 52 |
+
|
| 53 |
+
Each Transformer encoder mainly consists of two types of sub-layers, i.e., a multi-head self-attention layer (MHSA) and a MLP layer. In MHSA, the tokens are linearly projected and further re-formulated into three vectors, namely $Q , \pmb { K }$ and $V$ . The self-attention calculation is performed on $Q , \pmb { K }$ and $V$ by:
|
| 54 |
+
|
| 55 |
+
$$
|
| 56 |
+
x _ { \ell } ^ { \prime } = \mathrm { A t t e n t i o n } ( Q , K , V ) = \mathrm { S o f t m a x } ( \frac { Q K ^ { \top } } { \sqrt { d } } ) V ,
|
| 57 |
+
$$
|
| 58 |
+
|
| 59 |
+
where $ { \boldsymbol { { x } } } _ { \ell } ^ { \prime }$ are the tokens produced by MHSA at the $\ell$ -th layer. The output tokens $ { \boldsymbol { { x } } } _ { \ell } ^ { \prime }$ are further sent to a LayerNorm [3] and a MLP block which is consisted of two fully connected layers with a GELU activation [45] in between. This process is formally formulated as follows,
|
| 60 |
+
|
| 61 |
+
$$
|
| 62 |
+
x _ { \ell } = \mathrm { M L P } ( \mathrm { L N } ( x _ { \ell } ^ { \prime } ) ) + x _ { \ell } ^ { \prime } ,
|
| 63 |
+
$$
|
| 64 |
+
|
| 65 |
+
where $x _ { \ell }$ is the output of the $\ell$ -th encoder block. At the last transformer layer, the [CLS] is utilized for the final object recognition. We refer the readers to find more details in [31]. In our work, we replace the MLP layer with our AdaptMLP module for efficient fine-tuning purposes.
|
| 66 |
+
|
| 67 |
+
# 3.2 AdaptFormer
|
| 68 |
+
|
| 69 |
+
We propose a plug-and-play bottleneck module, namely AdaptMLP2. We denote the vision Transformer equipped with AdaptMLP as AdaptFormer.
|
| 70 |
+
|
| 71 |
+
Architecture. The design principle of AdaptFormer is simple yet effective, which is illustrated in Figure 2b. Compared to the vanilla full fine-tuning regime, AdaptFormer replaces the MLP block in the transformer encoder with AdaptMLP, which is consisted of two sub-branches. The MLP layer in the left branch is identical to the original network, while the right branch is an additionally introduced lightweight module for task-specific fine-tuning. Specifically, the right branch is designed to be a bottleneck structure for limiting the number of parameters purpose, which includes a down-projection layer with parameters $W _ { \mathrm { d o w n } } \in \mathbb { R } ^ { d \times \hat { d } }$ , an up-projection layer with parameters $W _ { \mathrm { u p } } \in \mathbb { R } ^ { \hat { d } \times d }$ , where $\hat { d }$ is the bottleneck middle dimension and satisfies $\hat { d } \ll d$ . In addition, there is a ReLU layer [1] between these projection layers for non-linear property. This bottleneck module is connected to the original MLP network (left branch) through the residual connection via a scale factor $s$ . For a specific input feature $ { \boldsymbol { { x } } } _ { \ell } ^ { \prime }$ , the right branch in AdaptMLP produces the adapted features, $\tilde { x } _ { \ell }$ , formally via:
|
| 72 |
+
|
| 73 |
+
$$
|
| 74 |
+
\begin{array} { r } { \tilde { x } _ { \ell } = \mathrm { R e L U } ( \mathrm { L N } ( x _ { \ell } ^ { \prime } ) \cdot W _ { \mathrm { d o w n } } ) \cdot W _ { \mathrm { u p } } . } \end{array}
|
| 75 |
+
$$
|
| 76 |
+
|
| 77 |
+
Then both the features $\tilde { x } _ { \ell }$ and $ { \boldsymbol { { x } } } _ { \ell } ^ { \prime }$ are fused with $x _ { \ell }$ by residual connection,
|
| 78 |
+
|
| 79 |
+
$$
|
| 80 |
+
x _ { \ell } = \mathrm { M L P } ( \mathrm { L N } ( x _ { \ell } ^ { \prime } ) ) + s \cdot \tilde { x } _ { \ell } + x _ { \ell } ^ { \prime } .
|
| 81 |
+
$$
|
| 82 |
+
|
| 83 |
+
Fine-tuning. During the fine-tuning phase, we only choose the newly added parameters to optimize and keep rest ones fixed. Specifically, the original model parts (blue blocks in Figure 2b) load weights from the pre-trained checkpoint and keeps parameters frozen. The newly added parameters (orange blocks) are updated on the specific data domain with the task-specific losses.
|
| 84 |
+
|
| 85 |
+
Inference. After fine-tuning, we still keep the shared parameters frozen as in the previous finetuning state, and additionally load the weights of the extra parameters that were fine-tuned in the previous stage. The single overall model is able to be adapted to multiple tasks with the assistance of lightweight introduced modules.
|
| 86 |
+
|
| 87 |
+
# 3.3 Discussion
|
| 88 |
+
|
| 89 |
+
Tunable parameters analysis. Our AdaptMLP module is lightweight. The total number of parameters introduced to per layer is $2 \times d \times \bar { \hat { d } } + \hat { d } + d$ , which includes biases parameters. The middle dimension $\hat { d }$ is a small value compared with $d$ (AdaptFormer still obtains a decent performance even when $\hat { d } = 1$ , as discussed in Sec. 4.5). Since most of the shared parameters are fixed and the number of newly introduced parameters is small $\leq 2 \%$ of the pre-trained model parameters), the total model size grows slowly when more downstream tasks are added.
|
| 90 |
+
|
| 91 |
+
Applicability. We note that AdaptMLP is a plug-and-play module that can be adaptively inserted into existing popular vision transformer architectures [31, 63, 83, 90, 23, 29] since all of the backbones share the same MLP layers even though they differ in the MHSA architectures (as shown in Figure 2b). Compared to our methods, we notice that recent prompt-related approaches insert trainable parameters into the token space, as illustrated in Figure 3. They prepend learnable parameters either into the embedded tokens before linear projection [58] or the key and value tokens after linear projection [51]. Therefore, the prompt-related method can not be straightforwardly adapted to special MHSA variants, especially for the one that takes the pyramid spatial information into account [63, 83]. Besides, we empirically observe that prompt-related methods perform not well when the number of patch tokens grows up from image to video scale, as shown in Figure 1.
|
| 92 |
+
|
| 93 |
+

|
| 94 |
+
Figure 3: Prompt tuning illustration.
|
| 95 |
+
|
| 96 |
+
In summary, we present a strategy for tuning a pre-trained vision Transformer on a set of scalable vision recognition tasks (e.g.image domain and video domain). It adds limited learnable parameters for tuning while achieving comparable or even better performance than the full-tuning strategy. Moreover, AdaptFormer could serve as a generic module for a large variety of recognition tasks.
|
| 97 |
+
|
| 98 |
+
Insights of architecture design. The MLP module is important for ViTs. As illustrated in [30], MLPs prevent ViTs from producing a rank-1 matrix. Also, MLPs stop the ViT output from degenerations. Inspired by the above analysis, we believe an effective ViT adaptation shall focus on its MLPs rather than multi-head self attentions. Meanwhile, we learn from the inception framework [76] that parallel design is an effective way for feature ensemble. With the parallel design, the domain-specific features produced by the adapter module can supplement the domain-agnostic features from the fixed branch for a better feature ensemble. Our following experiments will verify that the parallel performs better than the sequential design.
|
| 99 |
+
|
| 100 |
+
Besides, though many advanced Transformer-based models [63, 83, 34, 90] which have emerged since the success of ViT having different attention mechanisms within the Transformer block, they all share the similar MLPs (feed-forward network) structures. Therefore, our AdaptMLP can be easily plugged into these ViT variants. Moreover, AdaptMLP can also be applied to more recent attention-free models [77, 61, 19].
|
| 101 |
+
|
| 102 |
+
# 4 Experiments
|
| 103 |
+
|
| 104 |
+
We evaluate the effectiveness of AdaptFormer by conducting extensive visual recognition experiments in both the image and video domains. We first describe our experimental settings in Sec. 4.1, covering the pre-trained backbones, baseline methods, downstream tasks and training details. We then compare AdaptFormer with baseline methods and provide a thorough analysis in Sec. 4.2. In addition, we also conduct ablation studies to explore different experimental configurations and explain what makes for the superiority of AdaptFormer in Sec 4.5.
|
| 105 |
+
|
| 106 |
+
# 4.1 Experimental Settings
|
| 107 |
+
|
| 108 |
+
Pre-trained backbone. We adopt the plain Vision Transformer (ViT) [31], i.e., ViT-Base (ViT-B/16) as our backbone model and pre-train the model with both supervised and self-supervised approaches. Specifically, for image, we directly use the ImageNet-21k [26] supervised pre-trained model3 and MAE [43] self-supervised model4. For video, we take both supervised and self-supervised pre-trained models from VideoMAE [78]. More details about pre-training approaches and datasets can be found in Appendix.
|
| 109 |
+
|
| 110 |
+
Initialization of AdaptFormer. For the original networks, we directly load the weights pre-trained on the upstream tasks and keep them frozen/untouched during the fine-tuning process. For the newly added modules, the weights of down-projection layers are initialized with Kaiming Normal [44], while the biases of the additional networks and the weights of the up-projection layers are configured with zero initialization. The reason for the zero initialization of other layers is that in this way, the initial newly added parameters are initialized such that the new function resembles the original one at the start of the fine-tuning stage. We empirically found that if the initialization deviates too far from the identity function, the model is not stable to train.
|
| 111 |
+
|
| 112 |
+
Baseline methods. We compare AdaptFormer with three commonly used fine-tuning approaches, including (1)Linear probing: adding an extra linear layer on top of the backbone and tuning the added parameters for evaluation. (2) Full Fine-tuning: setting all the parameters learnable and tuning them together. (3) Visual Prompt Tuning (VPT): [51] fine-tuning the extra token parameters as shown in Figure 3.
|
| 113 |
+
|
| 114 |
+
Downstream tasks. We evaluate our AdaptFormer on both image and video recognition tasks to verify its effectiveness. The specific datasets leveraged in this work are presented in the following.
|
| 115 |
+
|
| 116 |
+
Image domain : CIFAR-100 [54] contains 50,000 training images and 10,000 validation images of resolution $3 2 \times 3 2$ with 100 labels. Street View House Numbers (SVHN) [37] is a digit classification benchmark dataset. In total, the dataset comprises over 600,000 labeled images, containing 73,257 training samples, 26,032 testing samples and 531,131 extra training data. The Food-101 [9] dataset consists of 101 food categories with a total of 101k images, including 750 training and 250 testing samples per category.
|
| 117 |
+
|
| 118 |
+
Video domain $:$ Something-Something V2 (SSv2) [39] is a large collection of video clips showing the people perform several normal actions in the daily life (e.g., moving stuff and opening the door). It consists of 168,913 training samples, 24,777 validation samples and 27,157 testing samples, making a total of 220,847 videos with 174 labels. HMDB51 [55] is composed of 6,849 videos with 51 categories, making a split of $3 . 5 \mathrm { k } / 1 . 5 \mathrm { k }$ train/val videos.
|
| 119 |
+
|
| 120 |
+
Implementation details. In this work, we use PyTorch toolkit [68] to conduct all experiments on NVIDIA V100 GPUs. Unless otherwise stated, we use $8 \times 8$ GPUs for video experiments and $1 \times 8$ GPUs for image experiments. Our default configurations follow the linear probing settings in [21, 43], which do not utilize many common regularization strategies, such as mixup [94], cutmix [91], color jittering and so on. More details can be found in Appendix.
|
| 121 |
+
|
| 122 |
+
# 4.2 Main Properties and Analysis
|
| 123 |
+
|
| 124 |
+
We compare the performance of different fine-tuning approaches in Table 1 with the backbones pre-trained via the self-supervised paradigms. The results show that AdaptFormer consistently surpasses linear probing and Visual Prompt tuning (VPT) methods. Specifically, AdaptFormer64 outperforms VPT on image benchmark CIFAR-100, SVHN, and Food-101, by $3 . 4 6 \%$ , $2 . 8 7 \%$ , and $4 . 6 3 \%$ respectively. On the more challenging video action recognition dataset SomethingSomething V2, the superiority becomes even more significant, i.e., about $15 \%$ . Note that even compared with the full fine-tuning strategy, our AdaptFormer still outperforms by about $5 \%$ Top-1 accuracy on SSv2 dataset. To summarize, our AdaptFormer is highly parameter-efficient, as well as yielding good performance with parameter size at most $2 \%$ times than the full fine-tuning manner.
|
| 125 |
+
|
| 126 |
+
Table 1: Fine-tuning with self-supervised pre-trained model. For tunable parameters, we also report the parameter percentage in the brackets. Besides, we report the top-1 accuracy on different dataset with the absolute value and the gap value relative to the full-tuning regime. † denotes $0 . 1 \times$ learning rate due to unstable training.
|
| 127 |
+
|
| 128 |
+
<table><tr><td>Method</td><td>Avg. Params (M)</td><td>CIFAR-100</td><td>Image SVHN</td><td>Food-101</td><td>Video</td></tr><tr><td>Full-tuning</td><td>86.04 (100%)</td><td>85.90</td><td>97.67†</td><td>SSv2 90.09† 53.97</td><td>HMDB51 46.41</td></tr><tr><td>Linear</td><td>0.07 (0.08%)</td><td>69.83 (-16.07) 66.91 (-30.76) 69.74 (-20.35)</td><td></td><td></td><td>29.23 (-24.74) 49.84 (+3.43)</td></tr><tr><td>VPT [51]</td><td>0.08 (0.09%)</td><td>82.44 (-3.46)</td><td>94.02 (-3.65)</td><td>82.98 (-7.11)</td><td>43.73 (-10.24) 52.67 (+6.26)</td></tr><tr><td>AdaptFormer-1</td><td>0.10 (0.12%)</td><td>83.52 (-2.38)</td><td>93.04 (-4.63)</td><td>83.64 (-6.45)</td><td>50.03 (-3.94) 51.68 (+5.27)</td></tr><tr><td>AdaptFormer-4</td><td>0.15 (0.17%)</td><td>84.83 (-1.07)</td><td>96.19 (-1.48)</td><td>85.42 (-4.67)</td><td>54.70 (+0.73) 51.81 (+5.40)</td></tr><tr><td>AdaptFormer-64</td><td>1.26 (1.46%)</td><td>85.90 (0.00)</td><td>96.89 (-0.78)</td><td>87.61 (-2.48)</td><td>59.02 (+5.05) 55.69 (+9.28)</td></tr></table>
|
| 129 |
+
|
| 130 |
+

|
| 131 |
+
Figure 4: The trend of performance as the number of tunable parameters grows up. The accuracy of VPT drops dramatically when the parameter number exceeds task-specific value, while AdaptFormer is robust to the increasing parameters.
|
| 132 |
+
|
| 133 |
+

|
| 134 |
+
Figure 5: Test accuracy of VPT [51] with different number of introduced tokens. The optimization procedure becomes unstable when the token number is equal or larger than eight on HMDB51 dataset [55].
|
| 135 |
+
|
| 136 |
+
# 4.3 Scaling Tunable Parameters Up
|
| 137 |
+
|
| 138 |
+
Even though there are only limited parameters introduced, one might also argue that more tunable parameters of AdaptFormer contribute to its higher accuracy compared with VPT [51]. We conduct experiments to make a comprehensive discussion on this aspect.
|
| 139 |
+
|
| 140 |
+
As described in Sec. 3.3, the number of tunable parameters can be adjusted by changing the number of introduced tokens for VPT, or the hidden feature dimension for AdaptFormer. As shown in Figure 4, we conduct experiments with a wide range of tunable parameters on both SSv2 and HMDB-51 datasets. Since AdaptFormer and VPT share the same number of parameters of classification head on a specific dataset, we only report the tunable parameters on the $\mathbf { X }$ -axis, which comes from the visual prompts (VPT) or weight/bias of the down-up fully-connected layers (AdaptFormer), without calculating the parameters of classification head. For VPT, the number of introduced tokens is chosen from {1, 2, 4, 8, 16, 32, 48, 64}. Similarly, the number of hidden dimensions in AdaptFormer is in {1, 2, 4, 8, 16, 32}. AdaptFormer has a slight performance gain or maintains the accuracy stably when the parameters scale up. On the contrary, the performance of VPT decreases dramatically when the parameters exceed the task-specific value. Moreover, choosing the most suitable number of token number becomes laborious since it might be task-specific (i.e.varying from one dataset to the other one). For example, the accuracy of VPT keeps going up when the number of tunable parameters increases up to 300K on SSv2, whereas it begins to drop when the number of tunable parameters exceeds 50K on HMDB-51.
|
| 141 |
+
|
| 142 |
+
Table 2: AdaptFormer for multi-label classification.
|
| 143 |
+
|
| 144 |
+
<table><tr><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>Params (M)</td><td rowspan=1 colspan=1>Params (M)NUS-WIDE [24]</td></tr><tr><td rowspan=1 colspan=1>Full-tuning</td><td rowspan=1 colspan=1>85.86 (100%)</td><td rowspan=1 colspan=1>61.26</td></tr><tr><td rowspan=1 colspan=1>LinearVPT [51]</td><td rowspan=1 colspan=1>0.06 (0.08%)0.07 (0.09%)</td><td rowspan=1 colspan=1>51.19 (-27.25)57.08 (-7.56)</td></tr><tr><td rowspan=1 colspan=1>AdaptFormer-1AdaptFormer-4AdaptFormer-64|1.25 (1.46%)</td><td rowspan=1 colspan=1>[0.09 (0.12%)0.15 (0.17%)AdaptFormer-64|1.25 (1.46%)</td><td rowspan=1 colspan=1>57.51 (-4.08)58.14 (-2.13)59.07 (-0.06)</td></tr></table>
|
| 145 |
+
|
| 146 |
+
We further study the optimization procedures of VPT by monitoring the test accuracy of the training stage. As shown in Figure 5, we gradually increase the number of tokens in VPT and plot the Top-1 accuracy of each epoch. The training stages are stable when the number of tokens is less than or equal to 4, e.g., {1, 2, 4}. However, when the number becomes 8 or larger, e.g., {8, 16, 32}, the training procedure collapses at about the tenth epoch and achieves poor performance at the end of the training stage. On the contrary, the optimization procedures of AdaptFormer are stable when the number of parameters varies across a large range, as shown in Table 3a. The top-1 accuracy fluctuates within $1 . 5 \%$ when the number of parameters increases from 0.44M ${ \dot { \mathsf { d i m } } } { = } 1 6$ ) to 4.87M ${ \tt d i m } { = } 2 5 6$ ).
|
| 147 |
+
|
| 148 |
+
# 4.4 Multi-Label Classification
|
| 149 |
+
|
| 150 |
+
We further conduct experiments on dataset with larger scale and diversity. Specifically, we evaluate AdaptFormer on NUS-WIDE [24] for multi-label classification. NUS-WIDE contains 269,648 images collected from Flicker, which are annotated with 81 visual concepts. Since some images are not available on Flicker, we only use 220,000 images following [7, 32]. We utilize mean average precision (mAP) as performance metric.
|
| 151 |
+
|
| 152 |
+
Settings and results. Our training settings mainly follow ASL [7]. Specifically, We trained all models for 40 epochs using Adam optimize and 1-cycle learning rate policy [73]. The maximal learning rate is 0.001. As shown in Table 2, though AdaptFormer-64 achieves a slightly lower mAP than fine-tuning, it significantly reduces the amount parameters that need to be updated (from 85.86 to 1.25M). Moreover, AdaptFormer has an clear advantage over other fine-tuning approaches including linear probing and VPT.
|
| 153 |
+
|
| 154 |
+
# 4.5 Ablation Studies
|
| 155 |
+
|
| 156 |
+
We ablate our AdaptFormer to study what properties make for a good AdaptFormer and observe several intriguing properties. The ablation studies conducted in this work are all performed on the SSv2 validation set [39].
|
| 157 |
+
|
| 158 |
+
Table 3: AdaptFormer ablation experiments with ViT-B/16 on SSv2. We report the top-1 accuracy on the val set. Most suitable settings are marked in color .
|
| 159 |
+
|
| 160 |
+
(a) Middle dimension $\hat { d }$ .
|
| 161 |
+
|
| 162 |
+
<table><tr><td>mid dim</td><td>#params top-1</td></tr><tr><td>1 0.16M 0.44M</td><td>50.03</td></tr><tr><td>16 32 0.73M</td><td>57.62</td></tr><tr><td>64 1.32M</td><td>58.27 59.02</td></tr><tr><td>256 4.87M</td><td>58.87</td></tr></table>
|
| 163 |
+
|
| 164 |
+
(b) AdaptMLP inserted layers and form.
|
| 165 |
+
|
| 166 |
+
<table><tr><td>layers</td><td></td><td>form#params top-1</td></tr><tr><td>1→6</td><td></td><td>parallel0.7350.48</td></tr><tr><td></td><td></td><td>7→12parallel 0.73 57.99</td></tr><tr><td></td><td></td><td>1 →12parallel 1.32 59.02</td></tr><tr><td></td><td></td><td>1 -→12 sequential 1.32 58.17</td></tr></table>
|
| 167 |
+
|
| 168 |
+
(c) Scaling factor s.
|
| 169 |
+
|
| 170 |
+
<table><tr><td></td><td>factor top-1</td></tr><tr><td>0.01</td><td>53.44</td></tr><tr><td>0.05</td><td>58.85</td></tr><tr><td>0.10 59.02</td><td></td></tr><tr><td></td><td>0.2058.89</td></tr></table>
|
| 171 |
+
|
| 172 |
+
Middle dimension. The middle dimension controls the number of introduced parameters by AdaptFormer. Lower middle dimensions introduce fewer parameters with a possible performance cost. We ablate AdaptFormer on the middle feature dimension to study this effects. As shown in Table 3a, the accuracy consistently improves when the middle dimension increases up to 64 and reaches the saturation point when the middle dimension is about 64 on SSv2 dataset. We note that our AdaptFormer can achieve a decent performance when the middle dimension reduces even to one, about $5 0 . 0 3 \%$ top-1 accuracy.
|
| 173 |
+
|
| 174 |
+
We conduct more extensive ablation studies on middle dimension in Appendix Table 10 and found that the optimal middle dimension varies per dataset. For example, the accuracy reaches saturation when the middle dimension equals 64 on SSv2, whereas for NUS-WIDE dataset, the mAP slightly improves when the middle dimension increases from 64 to 512. However, AdaptFormer with middle dimension as 512 has $0 . 7 5 \mathrm { m A P }$ higher (59.82 vs. $5 9 . 0 7 \mathrm { m A P }$ ) than the one with 64 at the cost of about 8 times more parameters. Therefore, we choose the middle dimension $\mathtt { . 0 4 }$ for both SSv2 and NUS-WIDE for a better trade-off.
|
| 175 |
+
|
| 176 |
+
Scaling factor. The scaling factor $s$ is introduced to balance the task-agnostic features (generated by the original frozen branch) and the task-specific features (generated by the tunable bottleneck branch). We evaluate AdaptFormer with multiple $s$ values and the results are summarized in Table 3c. Different from the scaling factor in NLP field which prefer $s$ larger than 1 (e.g., $s = 4$ in [42]), we empirically found that the $s$ should be $< 1$ for vision tasks, otherwise the fine-tuning would become unstable. Besides, we found that AdaptFormer achieves optimal performance with $s = 0 . 1$ . A larger or smaller $s$ would bring slight performance drop. Thus, we choose $s = 0 . 1 0$ as a default setting.
|
| 177 |
+
|
| 178 |
+
AdaptFormer position. As shown in Table 3b, we further ablate on the specific position to introduce the AdaptMLP block. We gradually increase the number of AdaptMLP layers with a step of three (start end, both included). We observe that the performance of AdaptFormer has a positive correlation with the number of added layers. In addition, AdaptFormer prefers the top part (the one far away from the input image) of the network to the bottom part when introducing the same number of layers, e.g., AdaptFormer with $7 \to 1 2$ obtains over $1 4 . 5 \%$ higher accuracy than $1 6$ , though both equipped with six AdaptMLP layers.
|
| 179 |
+
|
| 180 |
+
Insertion form. We study the insertion formulation by comparing the parallel and sequential instances which are illustrated in Figure 6. As shown in Table 3b, the parallel AdaptFormer is able to outperform the sequential one by $0 . 8 5 \%$ top-1 accuracy. The reason might be: (1) the parallel design maintains the original feature using an independent branch and aggregating updated context by element-wise scaled sum; (2) the sequential design is equivalent to adding more layers, which might cause optimization difficulty. Therefore, we adopt the parallel design as our default setting due to its superiority.
|
| 181 |
+
|
| 182 |
+

|
| 183 |
+
Figure 6: Illustration of the parallel and sequential insertion form. Comparison results are shown in Table 3b.
|
| 184 |
+
|
| 185 |
+

|
| 186 |
+
Figure 7: Performance with video frames number. AdaptFormer outperforms VPT and linear fine-tuning.
|
| 187 |
+
|
| 188 |
+
Number of frames. The number of embedded patch tokens increases linearly with the number of video frames for the plain ViT [31]. We conduct experiments with the different number of frames, i.e., {2, 4, 8} and the results are shown in Figure 7. We observe that increasing the number of frames is beneficial for all these three fine-tuning methods. However, AdaptFormer consistently outperforms the linear manner (e.g., $+ 3 0 \%$ top-1 accuracy on 8 input frames) and VPT method(e.g., $+ 1 4 \%$ top-1 accuracy on 8 input frames).
|
| 189 |
+
|
| 190 |
+
# 4.6 Towards Visual Recognition Generalist Agent
|
| 191 |
+
|
| 192 |
+
In the above experiments, we typically utilize a modality-specific pre-trained checkpoint for the corresponding downstream tasks. For example, we use Kinetics-400 (video domain) pretrained model for downstream video action recognition on Something-Something V2 and HMDB51 benchmarks. Besides, we use ImageNet-21K (image domain) pre-rained model for downstream image classification on CIFAR-100, SVHN and Food-101 benchmarks. Our AdaptFormer achieves superior performances in this same network with modality-specific weights scenario.
|
| 193 |
+
|
| 194 |
+
Next, we take a further step to ask what would happen if using the same network with the modality-agnostic weights for multiple tasks in the multi-modalities downstream tasks?
|
| 195 |
+
|
| 196 |
+
We use the model pre-trained on ImagNet-21k to do action recognition on SSv2. As shown in Table 4, AdaptFormer is robust to domain shift caused by modality. The experimental results show that the linear probe approach obtains a very poor accuracy (i.e., $6 . 5 6 \%$ top-1 accuracy) when fine-tuning on SSv2. Meanwhile,
|
| 197 |
+
|
| 198 |
+
Table 4: Fine-tuning on video data with image pre-trained model.
|
| 199 |
+
|
| 200 |
+
<table><tr><td>Method</td><td>Avg. Params (M)</td><td>Fine-tuning SSv2</td></tr><tr><td>Full-tuning</td><td>86.36</td><td>41.50</td></tr><tr><td>Linear</td><td>0.15</td><td>6.56</td></tr><tr><td>VPT [51]</td><td>0.16</td><td>16.94</td></tr><tr><td>AdaptFormer</td><td>1.33</td><td>46.06</td></tr></table>
|
| 201 |
+
|
| 202 |
+
VPT [51] achieves a better performance than linear probe but it is not decent (i.e., $1 6 . 9 4 \%$ top-1 accuracy). Our AdaptFormer, compared to the above two methods, attains a promising $4 6 . 0 6 \%$ top-1 accuracy, which is even higher than the full-tuning schedule $( + 4 . 5 6 \% )$ .
|
| 203 |
+
|
| 204 |
+
# 4.7 Visualization
|
| 205 |
+
|
| 206 |
+

|
| 207 |
+
Figure 8: t-SNE visualizations on SSv2 val dataset. We extract the final classification features from the top linear layer for t-SNE visualizations. The top-1 accuracy is reported in red, while the relative parameter (compared to the full fine-tuning strategy) is reported in blue.
|
| 208 |
+
|
| 209 |
+
To evaluate the quality of the produced features, we conduct t-SNE [80] visualizations on AdaptFormer and other baseline methods. The features are extracted from the SSv2 validation set via the ViT-Base backbone. Figure 8 shows that the linear fine-tuning and the VPT methods tend to output mixed features as shown in Figure 8(a)-(b). Compared with the above two methods, the full fine-tuning strategy performs well in projecting features. However, it consumes huge computational sources to tune the whole network parameters. Figure 8(d) validates that our AdaptFormer facilitates ViT-Base in generating more separable representations with fewer learnable parameters.
|
| 210 |
+
|
| 211 |
+
# 5 Conclusion
|
| 212 |
+
|
| 213 |
+
We present a conceptually simple yet effective framework, AdaptFormer, for efficiently adapting a pre-trained Vision Transformer (ViT) backbone to scalable vision recognition tasks. By introducing AdaptMLP, our AdaptFormer is able to fine-tune the lightweight modules for producing features adapted to multiple downstream tasks. The extensive experiments on five datasets, covering both the image and the video domains, validate that our proposed methods are able to increase the ViT’s transferability with little computational cost. We hope our work will inspire future research in exploring more efficient fine-tuning methods for large vision models. One limitation is that AdaptFormer is only employed in recognition tasks in this work, it’s unclear whether it can work well in tasks beyond recognition, e.g., object detection and semantic segmentation. We leave it for the future exploration. Since our method is specially designed for efficient fine-tuning, we do not foresee obvious undesirable ethical/social impacts at this moment.
|
| 214 |
+
|
| 215 |
+
Acknowledgment. This work is supported by CCF-Tencent Open Fund. Ping Luo is supported by the General Research Fund of HK No.27208720, No.17212120, and No.17200622.
|
| 216 |
+
|
| 217 |
+
References
|
| 218 |
+
[1] Abien Fred Agarap. Deep learning using rectified linear units (relu). arXiv preprint arXiv:1803.08375, 2018. 4
|
| 219 |
+
[2] Anurag Arnab, Mostafa Dehghani, Georg Heigold, Chen Sun, Mario Luciˇ c, and Cordelia Schmid. Vivit: A ´ video vision transformer. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 6836–6846, 2021. 3, 17
|
| 220 |
+
[3] Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016. 4
|
| 221 |
+
[4] Hyojin Bahng, Ali Jahanian, Swami Sankaranarayanan, and Phillip Isola. Visual prompting: Modifying pixel space to adapt pre-trained models. arXiv preprint arXiv:2203.17274, 2022. 2
|
| 222 |
+
[5] Hangbo Bao, Li Dong, and Furu Wei. Beit: Bert pre-training of image transformers. arXiv preprint arXiv:2106.08254, 2021. 2
|
| 223 |
+
[6] Ankur Bapna, Naveen Arivazhagan, and Orhan Firat. Simple, scalable adaptation for neural machine translation. arXiv preprint arXiv:1909.08478, 2019. 2
|
| 224 |
+
[7] Emanuel Ben-Baruch, Tal Ridnik, Nadav Zamir, Asaf Noy, Itamar Friedman, Matan Protter, and Lihi Zelnik-Manor. Asymmetric loss for multi-label classification. arXiv preprint arXiv:2009.14119, 2020. 8
|
| 225 |
+
[8] Gedas Bertasius, Heng Wang, and Lorenzo Torresani. Is space-time attention all you need for video understanding. arXiv preprint arXiv:2102.05095, 2021. 3
|
| 226 |
+
[9] Lukas Bossard, Matthieu Guillaumin, and Luc Van Gool. Food-101–mining discriminative components with random forests. In European Conference on Computer Vision, 2014. 6
|
| 227 |
+
[10] 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, 2020. 1, 3
|
| 228 |
+
[11] 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. 1, 3
|
| 229 |
+
[12] Mathilde Caron, Hugo Touvron, Ishan Misra, Hervé Jégou, Julien Mairal, Piotr Bojanowski, and Armand Joulin. Emerging properties in self-supervised vision transformers. In Proceedings of the International Conference on Computer Vision (ICCV), 2021. 2
|
| 230 |
+
[13] Mathilde Caron, Hugo Touvron, Ishan Misra, Hervé Jégou, Julien Mairal, Piotr Bojanowski, and Armand Joulin. Emerging properties in self-supervised vision transformers. In IEEE/CVF International Conference on Computer Vision, 2021. 3
|
| 231 |
+
[14] Joao Carreira, Eric Noland, Andras Banki-Horvath, Chloe Hillier, and Andrew Zisserman. A short note about kinetics-600. arXiv preprint arXiv:1808.01340, 2018. 18
|
| 232 |
+
[15] Joao Carreira and Andrew Zisserman. Quo vadis, action recognition? a new model and the kinetics dataset. In proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 6299–6308, 2017. 17
|
| 233 |
+
[16] Chang Chen, Yi-Fu Wu, Jaesik Yoon, and Sungjin Ahn. Transdreamer: Reinforcement learning with transformer world models. arXiv preprint arXiv:2202.09481, 2022. 1
|
| 234 |
+
[17] Hanting Chen, Yunhe Wang, Tianyu Guo, Chang Xu, Yiping Deng, Zhenhua Liu, Siwei Ma, Chunjing Xu, Chao Xu, and Wen Gao. Pre-trained image processing transformer. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2021. 3
|
| 235 |
+
[18] 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. 1
|
| 236 |
+
[19] Shoufa Chen, Enze Xie, Chongjian GE, Runjian Chen, Ding Liang, and Ping Luo. CycleMLP: A MLP-like architecture for dense prediction. In International Conference on Learning Representations, 2022. 5
|
| 237 |
+
[20] Shuo Chen, Tan Yu, and Ping Li. Mvt: Multi-view vision transformer for 3d object recognition. arXiv preprint arXiv:2110.13083, 2021. 3
|
| 238 |
+
[21] Xinlei Chen, Saining Xie, and Kaiming He. An empirical study of training self-supervised vision transformers. In IEEE/CVF International Conference on Computer Vision, 2021. 3, 6
|
| 239 |
+
[22] Cheng Chi, Fangyun Wei, and Han Hu. Relationnet++: Bridging visual representations for object detection via transformer decoder. Advances in Neural Information Processing Systems, 2020. 3
|
| 240 |
+
[23] 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 NeurIPS 2021, 2021. 5
|
| 241 |
+
[24] Tat-Seng Chua, Jinhui Tang, Richang Hong, Haojie Li, Zhiping Luo, and Yantao Zheng. Nus-wide: a real-world web image database from national university of singapore. In Proceedings of the ACM international conference on image and video retrieval, pages 1–9, 2009. 8
|
| 242 |
+
[25] Sudeep Dasari and Abhinav Gupta. Transformers for one-shot visual imitation. arXiv preprint arXiv:2011.05970, 2020. 1
|
| 243 |
+
[26] Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2009. 3, 6, 17, 18
|
| 244 |
+
[27] 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. 1, 3
|
| 245 |
+
[28] 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, pages 1422–1430, 2015. 17
|
| 246 |
+
[29] Xiaoyi Dong, Jianmin Bao, Dongdong Chen, Weiming Zhang, Nenghai Yu, Lu Yuan, Dong Chen, and Baining Guo. Cswin transformer: A general vision transformer backbone with cross-shaped windows, 2021. 5
|
| 247 |
+
[30] Yihe Dong, Jean-Baptiste Cordonnier, and Andreas Loukas. Attention is not all you need: Pure attention loses rank doubly exponentially with depth. In International Conference on Machine Learning, pages 2793–2803. PMLR, 2021. 5
|
| 248 |
+
[31] 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. 1, 3, 4, 5, 6, 9, 17, 18
|
| 249 |
+
[32] Thibaut Durand, Nazanin Mehrasa, and Greg Mori. Learning a deep convnet for multi-label classification with partial labels. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 647–657, 2019. 8
|
| 250 |
+
[33] Haoqi Fan, Bo Xiong, Karttikeya Mangalam, Yanghao Li, Zhicheng Yan, Jitendra Malik, and Christoph Feichtenhofer. Multiscale vision transformers. In IEEE/CVF International Conference on Computer Vision, 2021. 3
|
| 251 |
+
[34] Haoqi Fan, Bo Xiong, Karttikeya Mangalam, Yanghao Li, Zhicheng Yan, Jitendra Malik, and Christoph Feichtenhofer. Multiscale vision transformers. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 6824–6835, 2021. 5
|
| 252 |
+
[35] Christoph Feichtenhofer, Haoqi Fan, Yanghao Li, and Kaiming He. Masked autoencoders as spatiotemporal learners. arXiv preprint arXiv:2205.09113, 2022. 2
|
| 253 |
+
[36] Chongjian Ge, Youwei Liang, Yibing Song, Jianbo Jiao, Jue Wang, and Ping Luo. Revitalizing cnn attention via transformers in self-supervised visual representation learning. Advances in Neural Information Processing Systems, 2021. 3
|
| 254 |
+
[37] Ian J Goodfellow, Yaroslav Bulatov, Julian Ibarz, Sacha Arnoud, and Vinay Shet. Multi-digit number recognition from street view imagery using deep convolutional neural networks. arXiv preprint arXiv:1312.6082, 2013. 6
|
| 255 |
+
[38] 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. 17
|
| 256 |
+
[39] Raghav Goyal, Samira Ebrahimi Kahou, Vincent Michalski, Joanna Materzynska, Susanne Westphal, Heuna Kim, Valentin Haenel, Ingo Fruend, Peter Yianilos, Moritz Mueller-Freitag, et al. The" something something" video database for learning and evaluating visual common sense. In IEEE/CVF International Conference on Computer Vision, 2017. 6, 8
|
| 257 |
+
[40] Demi Guo, Alexander M Rush, and Yoon Kim. Parameter-efficient transfer learning with diff pruning. arXiv preprint arXiv:2012.07463, 2020. 3
|
| 258 |
+
[41] Meng-Hao Guo, Jun-Xiong Cai, Zheng-Ning Liu, Tai-Jiang Mu, Ralph R Martin, and Shi-Min Hu. Pct: Point cloud transformer. Computational Visual Media, 2021. 3
|
| 259 |
+
[42] Junxian He, Chunting Zhou, Xuezhe Ma, Taylor Berg-Kirkpatrick, and Graham Neubig. Towards a unified view of parameter-efficient transfer learning. In International Conference on Learning Representations, 2022. 2, 9
|
| 260 |
+
[43] Kaiming He, Xinlei Chen, Saining Xie, Yanghao Li, Piotr Dollár, and Ross Girshick. Masked autoencoders are scalable vision learners. arXiv preprint arXiv:2111.06377, 2021. 2, 3, 6, 17
|
| 261 |
+
[44] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Delving deep into rectifiers: Surpassing human-level performance on imagenet classification. In Proceedings of the IEEE international conference on computer vision, pages 1026–1034, 2015. 6
|
| 262 |
+
[45] Dan Hendrycks and Kevin Gimpel. Gaussian error linear units (gelus). arXiv preprint arXiv:1606.08415, 2016. 4
|
| 263 |
+
[46] 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. 2, 3
|
| 264 |
+
[47] Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. Lora: Low-rank adaptation of large language models. arXiv preprint arXiv:2106.09685, 2021. 2, 3
|
| 265 |
+
[48] Drew A Hudson and Larry Zitnick. Generative adversarial transformers. In International Conference on Machine Learning, pages 4487–4499. PMLR, 2021. 1
|
| 266 |
+
[49] Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In International conference on machine learning, pages 448–456. PMLR, 2015. 17
|
| 267 |
+
[50] Rishabh Jangir, Nicklas Hansen, Sambaran Ghosal, Mohit Jain, and Xiaolong Wang. Look closer: Bridging egocentric and third-person views with transformers for robotic manipulation. IEEE Robotics and Automation Letters, 2022. 1
|
| 268 |
+
[51] Menglin Jia, Luming Tang, Bor-Chun Chen, Claire Cardie, Serge Belongie, Bharath Hariharan, and Ser-Nam Lim. Visual prompt tuning. arXiv preprint arXiv:2203.12119, 2022. 2, 3, 5, 6, 7, 8, 10, 18, 19
|
| 269 |
+
[52] 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. 1
|
| 270 |
+
[53] Will Kay, Joao Carreira, Karen Simonyan, Brian Zhang, Chloe Hillier, Sudheendra Vijayanarasimhan, Fabio Viola, Tim Green, Trevor Back, Paul Natsev, et al. The kinetics human action video dataset. arXiv preprint arXiv:1705.06950, 2017. 3
|
| 271 |
+
[54] Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. Master’s thesis, Department of Computer Science, University of Toronto, 2009. 6
|
| 272 |
+
[55] Hildegard Kuehne, Hueihan Jhuang, Estíbaliz Garrote, Tomaso Poggio, and Thomas Serre. Hmdb: a large video database for human motion recognition. In IEEE/CVF International Conference on Computer Vision, 2011. 6, 7
|
| 273 |
+
[56] Brian Lester, Rami Al-Rfou, and Noah Constant. The power of scale for parameter-efficient prompt tuning. arXiv preprint arXiv:2104.08691, 2021. 2, 3
|
| 274 |
+
[57] Kunchang Li, Yali Wang, Gao Peng, Guanglu Song, Yu Liu, Hongsheng Li, and Yu Qiao. Uniformer: Unified transformer for efficient spatial-temporal representation learning. In International Conference on Learning Representations, 2022. 3, 21
|
| 275 |
+
[58] Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. arXiv preprint arXiv:2101.00190, 2021. 2, 3, 5
|
| 276 |
+
[59] Jingyun Liang, Jiezhang Cao, Guolei Sun, Kai Zhang, Luc Van Gool, and Radu Timofte. Swinir: Image restoration using swin transformer. In IEEE/CVF International Conference on Computer Vision, 2021. 3
|
| 277 |
+
[60] Youwei Liang, Chongjian Ge, Zhan Tong, Yibing Song, Jue Wang, and Pengtao Xie. Not all patches are what you need: Expediting vision transformers via token reorganizations. arXiv preprint arXiv:2202.07800, 2022. 3
|
| 278 |
+
[61] Hanxiao Liu, Zihang Dai, David So, and Quoc V Le. Pay attention to mlps. Advances in Neural Information Processing Systems, 34:9204–9215, 2021. 5
|
| 279 |
+
[62] Xiao Liu, Kaixuan Ji, Yicheng Fu, Zhengxiao Du, Zhilin Yang, and Jie Tang. P-tuning v2: Prompt tuning can be comparable to fine-tuning universally across scales and tasks. arXiv preprint arXiv:2110.07602, 2021. 2
|
| 280 |
+
[63] 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 Proceedings of the IEEE/CVF International Conference on Computer Vision, 2021. 1, 3, 5, 18
|
| 281 |
+
[64] Ze Liu, Jia Ning, Yue Cao, Yixuan Wei, Zheng Zhang, Stephen Lin, and Han Hu. Video swin transformer. arXiv preprint arXiv:2106.13230, 2021. 17, 18
|
| 282 |
+
[65] Ilya Loshchilov and Frank Hutter. Sgdr: Stochastic gradient descent with warm restarts. arXiv preprint arXiv:1608.03983, 2016. 17
|
| 283 |
+
[66] 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 European Conference on Computer Vision, 2018. 3
|
| 284 |
+
[67] Tian Pan, Yibing Song, Tianyu Yang, Wenhao Jiang, and Wei Liu. Videomoco: Contrastive video representation learning with temporally adversarial examples. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2021. 3
|
| 285 |
+
[68] 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 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. 6, 21
|
| 286 |
+
[69] Jonas Pfeiffer, Aishwarya Kamath, Andreas Rücklé, Kyunghyun Cho, and Iryna Gurevych. Adapterfusion: Non-destructive task composition for transfer learning. arXiv preprint arXiv:2005.00247, 2020. 2
|
| 287 |
+
[70] Jonas Pfeiffer, Andreas Rücklé, Clifton Poth, Aishwarya Kamath, Ivan Vulic, Sebastian Ruder, Kyunghyun ´ Cho, and Iryna Gurevych. Adapterhub: A framework for adapting transformers. arXiv preprint arXiv:2007.07779, 2020. 2
|
| 288 |
+
[71] 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, 2021. 3
|
| 289 |
+
[72] Tal Ridnik, Emanuel Ben-Baruch, Asaf Noy, and Lihi Zelnik-Manor. Imagenet-21k pretraining for the masses. arXiv preprint arXiv:2104.10972, 2021. 3, 19
|
| 290 |
+
[73] Leslie N Smith. A disciplined approach to neural network hyper-parameters: Part 1–learning rate, batch size, momentum, and weight decay. arXiv preprint arXiv:1803.09820, 2018. 8
|
| 291 |
+
[74] Chen Sun, Abhinav Shrivastava, Saurabh Singh, and Abhinav Gupta. Revisiting unreasonable effectiveness of data in deep learning era. In IEEE/CVF International Conference on Computer Vision, 2017. 3
|
| 292 |
+
[75] Ilya Sutskever, James Martens, George Dahl, and Geoffrey Hinton. On the importance of initialization and momentum in deep learning. In International conference on machine learning, pages 1139–1147. PMLR, 2013. 17
|
| 293 |
+
[76] Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 1–9, 2015. 5
|
| 294 |
+
[77] Ilya O Tolstikhin, Neil Houlsby, Alexander Kolesnikov, Lucas Beyer, Xiaohua Zhai, Thomas Unterthiner, Jessica Yung, Andreas Steiner, Daniel Keysers, Jakob Uszkoreit, et al. Mlp-mixer: An all-mlp architecture for vision. Advances in Neural Information Processing Systems, 34:24261–24272, 2021. 5
|
| 295 |
+
[78] Zhan Tong, Yibing Song, Jue Wang, and Limin Wang. Videomae: Masked autoencoders are data-efficient learners for self-supervised video pre-training. arXiv preprint arXiv:2203.12602, 2022. 2, 3, 6, 17
|
| 296 |
+
[79] Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Hervé Jégou. Training data-efficient image transformers & distillation through attention. arXiv preprint arXiv:2012.12877, 2020. 1
|
| 297 |
+
[80] Laurens Van der Maaten and Geoffrey Hinton. Visualizing data using t-sne. Journal of machine learning research, 9(11), 2008. 10
|
| 298 |
+
[81] 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, 2017. 1, 3
|
| 299 |
+
[82] Alex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R. Bowman. GLUE: A multi-task benchmark and analysis platform for natural language understanding. In International Conference on Learning Representations, 2019. 1
|
| 300 |
+
[83] Wenhai Wang, Enze Xie, Xiang Li, Deng-Ping Fan, Kaitao Song, Ding Liang, Tong Lu, Ping Luo, and Ling Shao. Pyramid vision transformer: A versatile backbone for dense prediction without convolutions. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 568–578, 2021. 1, 5
|
| 301 |
+
[84] Zhendong Wang, Xiaodong Cun, Jianmin Bao, and Jianzhuang Liu. Uformer: A general u-shaped transformer for image restoration. arXiv preprint arXiv:2106.03106, 2021. 3
|
| 302 |
+
[85] Chen Wei, Haoqi Fan, Saining Xie, Chao-Yuan Wu, Alan Yuille, and Christoph Feichtenhofer. Masked feature prediction for self-supervised visual pre-training. arXiv preprint arXiv:2112.09133, 2021. 2
|
| 303 |
+
[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. Advances in Neural Information Processing Systems, 2021. 1, 3
|
| 304 |
+
[87] Ruihan Yang, Minghao Zhang, Nicklas Hansen, Huazhe Xu, and Xiaolong Wang. Learning vision-guided quadrupedal locomotion end-to-end with cross-modal transformers. In International Conference on Learning Representations, 2022. 1
|
| 305 |
+
[88] Zhilin Yang, Zihang Dai, Yiming Yang, Jaime Carbonell, Russ R Salakhutdinov, and Quoc V Le. Xlnet: Generalized autoregressive pretraining for language understanding. Advances in neural information processing systems, 32, 2019. 1
|
| 306 |
+
[89] Yang You, Igor Gitman, and Boris Ginsburg. Large batch training of convolutional networks. arXiv preprint arXiv:1708.03888, 2017. 17
|
| 307 |
+
[90] Li Yuan, Yunpeng Chen, Tao Wang, Weihao Yu, Yujun Shi, Zi-Hang Jiang, Francis EH Tay, Jiashi Feng, and Shuicheng Yan. Tokens-to-token vit: Training vision transformers from scratch on imagenet. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 558–567, 2021. 1, 5
|
| 308 |
+
[91] 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 IEEE/CVF International Conference on Computer Vision, 2019. 6
|
| 309 |
+
[92] Elad Ben Zaken, Shauli Ravfogel, and Yoav Goldberg. Bitfit: Simple parameter-efficient fine-tuning for transformer-based masked language-models. arXiv preprint arXiv:2106.10199, 2021. 2, 3
|
| 310 |
+
[93] Xiaohua Zhai, Alexander Kolesnikov, Neil Houlsby, and Lucas Beyer. Scaling vision transformers. In CVPR, 2022. 1
|
| 311 |
+
[94] Hongyi Zhang, Moustapha Cisse, Yann N Dauphin, and David Lopez-Paz. mixup: Beyond empirical risk minimization. arXiv preprint arXiv:1710.09412, 2017. 6
|
| 312 |
+
[95] Hengshuang Zhao, Li Jiang, Jiaya Jia, Philip HS Torr, and Vladlen Koltun. Point transformer. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 16259–16268, 2021. 3
|
| 313 |
+
[96] Sixiao Zheng, Jiachen Lu, Hengshuang Zhao, Xiatian Zhu, Zekun Luo, Yabiao Wang, Yanwei Fu, Jianfeng Feng, Tao Xiang, Philip Torr, and Li Zhang. Rethinking semantic segmentation from a sequence-tosequence perspective with transformers. In CVPR, 2021. 1
|
| 314 |
+
[97] Jinghao Zhou, Chen Wei, Huiyu Wang, Wei Shen, Cihang Xie, Alan Yuille, and Tao Kong. ibot: Image bert pre-training with online tokenizer. International Conference on Learning Representations (ICLR), 2022. 2
|
| 315 |
+
[98] Xizhou Zhu, Weijie Su, Lewei Lu, Bin Li, Xiaogang Wang, and Jifeng Dai. Deformable detr: Deformable transformers for end-to-end object detection. arXiv preprint arXiv:2010.04159, 2020. 1, 3
|
md/dev/B72HXs80q4/B72HXs80q4.md
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# TAMING SPARSELY ACTIVATED TRANSFORMER WITH STOCHASTIC EXPERTS
|
| 2 |
+
|
| 3 |
+
Simiao Zuo†∗, Xiaodong $\mathbf { L i u } ^ { \diamond }$ , Jian Jiao, Young Jin ${ \bf K i m } ^ { \diamond }$ , Hany Hassan, Ruofei Zhang, Tuo Zhao† and Jianfeng Gao
|
| 4 |
+
|
| 5 |
+
†Georgia Institute of Technology Microsoft
|
| 6 |
+
{simiaozuo,tourzhao}@gatech.edu,
|
| 7 |
+
{xiaodl,jian.jiao,youki,hanyh,bzhang,jfgao}@microsoft.com
|
| 8 |
+
|
| 9 |
+
# ABSTRACT
|
| 10 |
+
|
| 11 |
+
Sparsely activated models (SAMs), such as Mixture-of-Experts (MoE), can easily scale to have outrageously large amounts of parameters without significant increase in computational cost. However, SAMs are reported to be parameter inefficient such that larger models do not always lead to better performance. While most on-going research focuses on improving SAMs models by exploring methods of routing inputs to experts, our analysis reveals that such research might not lead to the solution we expect, i.e., the commonly-used routing methods based on gating mechanisms do not work better than randomly routing inputs to experts. In this paper, we propose a new expert-based model, THOR (Transformer witH StOchastic ExpeRts). Unlike classic expert-based models, such as the Switch Transformer (Fedus et al., 2021), experts in THOR are randomly activated for each input during training and inference. THOR models are trained using a consistency regularized loss, where experts learn not only from training data but also from other experts as teachers, such that all the experts make consistent predictions. We validate the effectiveness of THOR on machine translation tasks. Results show that THOR models are more parameter efficient in that they significantly outperform the Transformer and MoE models across various settings. For example, in multilingual translation, THOR outperforms the Switch Transformer by 2 BLEU scores, and obtains the same BLEU score as that of a state-of-the-art MoE model (Kim et al., 2021) that is 18 times larger. Our code is publicly available at: https://github.com/microsoft/ Stochastic-Mixture-of-Experts.
|
| 12 |
+
|
| 13 |
+
# 1 INTRODUCTION
|
| 14 |
+
|
| 15 |
+
Large neural network models have shown to be effective in many natural language processing tasks such as machine translation (Lewis et al., 2020; Conneau & Lample, 2019), natural language understanding (Devlin et al., 2019; Liu et al., 2019; He et al., 2020), and natural language generation (Radford et al., 2019; Brown et al., 2020). These models are usually densely activated. That is, a model uses all its parameters to process all inputs. One drawback of these models is the prohibitive training cost. Moreover, the extreme size drastically reduces inference speed, further limiting the models’ practicality.
|
| 16 |
+
|
| 17 |
+
To address these issues, sparsely activated models (SAMs, Shazeer et al. 2017) have been proposed. A SAM adaptively selects a subset of its parameters for different inputs during model training and inference. This makes it possible to train SAMs that are an order of magnitude larger than densely activated models without significant increase in computational cost. For example, the sparsely activated GShard (Lepikhin et al., 2020) consists of over 600 billion parameters and the Switch Transformer (Fedus et al., 2021) 1.5 trillion parameters, while GPT-3 (Brown et al., 2020), which is arguably the largest densely activated model, consists of only 175 billion parameters.
|
| 18 |
+
|
| 19 |
+
The building block of SAMs is the expert layer, which contains an attention mechanism and multiple feed-forward neural networks (FFNs) in parallel. Each FFN is referred to as an expert. During training, an input is routed to a fixed number of experts, such that the number of floating point operations (FLOPs) of one forward pass remains constant, regardless of the total number of experts. Thus, training SAMs is much more cost-efficient than training densely activated models. For example, training of Switch-large (Fedus et al., 2021) and that of T5-large (Raffel et al., 2019) require the same forward FLOPs, despite that the former is 35 times larger (26.3 vs. 0.74 billion parameters).
|
| 20 |
+
|
| 21 |
+
However, SAMs have been reported to be parameter inefficient. For example, although the Switchlarge model is 35 times larger than T5-large, its performance on the GLUE benchmark (Wang et al., 2019a) is only slightly better (88.5 vs. 87.8). There are also cases where the performance of SAMs is even worse than smaller densely activated models. For example, the performance of Switchlarge is worse than T5-large on the ARC Reasoning Challenge (66.0 vs. 68.8) (Clark et al., 2018). In another example, although GShard (Lepikhin et al., 2020) shows substantial gains over densely activated models, a diminishing return with larger number of parameters has been observed.
|
| 22 |
+
|
| 23 |
+
Most on-going research has focused on improving SAMs by developing effective routing methods. Since only a subset of model parameters (i.e., experts) are updated for each input during training, we need to decide which experts to be activated given an input. Existing works (Shazeer et al., 2017; Lepikhin et al., 2020; Fedus et al., 2021; Yang et al., 2021) use a gating network for input routing. However, the gating mechanism suffers from the notorious load imbalance issue: the gate’s weight could collapse such that nearly all the inputs are routed to the same expert. Therefore, many methods are proposed to mitigate this issue, such as noisy gating (Shazeer et al., 2017), expert capacity (Lepikhin et al., 2020), load balancing loss (Lepikhin et al., 2020; Fedus et al., 2021), and $k$ Top-1 gating (Yang et al., 2021). However, these routing methods have not been proved effective to make SAMs more parameter efficient. To understand why SAMs are not parameter efficient, we analyze the performance of several classic MoE models. Our analysis reveals that a SAM does not always outperform a densely activated model of a similar size, confirming the results reported in Yang et al. (2021). Moreover, we also observe that the widely-used routing method based on the gating mechanism does not work better than randomly routing inputs to experts,
|
| 24 |
+
|
| 25 |
+
Inspired by our findings, we propose a new SAM, THOR (Transformer witH StOchastic ExpeRts). Unlike classic SAMs, such as the Switch Transformer, experts in THOR are randomly activated (with no need of any gating mechanism) for each input during training and inference. THOR models are trained by minimizing both the cross-entropy loss and a consistency regularization term, such that experts can learn not only from training data but also from other experts as teachers so that all the experts make consistent predictions.
|
| 26 |
+
|
| 27 |
+
To validate the effectiveness of THOR, we have conducted extensive experiments on machine translation using three settings: low-resource, rich-resource, and multilingual. Results show that THOR models outperform state-of-the-art MoE models by an average of 2 BLEU score on twelve low-resource translation tasks. In the rich-resource setting, THOR achieves new state-of-the-art results on the two widely-used translation benchmarks, WMT’16 En-De and WMT’14 En-Fr. On multilingual translation tasks, the THOR model with 300 million parameters achieves 2 BLEU score improvement over a state-of-the-art MoE model of the same size. Moreover, our model achieves state-of-the-art results on these tasks — the same BLEU score that is achieved by the Z-code MoE model (Kim et al., 2021) with 5.5 billion parameters (18 times larger).
|
| 28 |
+
|
| 29 |
+
# 2 BACKGROUND
|
| 30 |
+
|
| 31 |
+
Transformer. The Transformer (Vaswani et al., 2017) model has demonstrated its superior performance in many sequence-to-sequence natural language processing tasks, such as neural machine translation. The model contains an encoder and a decoder. The encoder consists of multiple encoder layers, each having an identical structure. An encoder layer employs a self-attention mechanism and a feed-forward neural network (FFN). The decoder is similarly constructed, except for an additional cross-attention mechanism in each decoder layer.
|
| 32 |
+
|
| 33 |
+
Sparsely Activated Models. The building block of SAMs is the expert layer, which is similar to the Transformer layer. Each of these expert layers contain an attention mechanism and multiple FFNs in parallel, where each FFN is referred to as an expert. Let $\{ E _ { i } \} _ { i = 1 } ^ { N }$ denote the experts, and $N$ denotes the total number of experts. A gating mechanism decides to which expert(s) an input should be routed. At each expert layer, given an input vector $x \in \mathbb { R } ^ { d }$ , where $d$ is the embedding dimension, the gate value of routing $x$ to expert $E _ { i }$ is
|
| 34 |
+
|
| 35 |
+
$$
|
| 36 |
+
p _ { i } ( { \ ' } x ) = [ \mathrm { S o f t m a x } \left( W _ { g } x \right) ] _ { i } ,
|
| 37 |
+
$$
|
| 38 |
+
|
| 39 |
+
where $W _ { g } \in \mathbb { R } ^ { N \times d }$ is the trainable weight matrix of the gating mechanism. Given the gate values $\{ p _ { i } ( x ) \} _ { i = 1 } ^ { N }$ , we select the top- $K$ experts to form an activated set of experts $\mathcal { T } \subset \{ 1 \cdots N \}$ , where $| \mathcal { T } | = K$ . Then the output $x _ { \mathrm { o u t } }$ of the expert layer is
|
| 40 |
+
|
| 41 |
+
$$
|
| 42 |
+
x _ { \mathrm { o u t } } = \sum _ { i \in \mathcal { T } } p _ { i } ( x ) E _ { i } ( x ) .
|
| 43 |
+
$$
|
| 44 |
+
|
| 45 |
+
Notice that in Eq. 2, input $x$ only activates $K$ instead of $N$ experts, where $K \ll N$ , e.g., $K = 2$ and $N = 2 0 4 8$ in GShard (Lepikhin et al., 2020). This implies that the number of FLOPs required for one forward pass does not increase with the number of experts $N$ . Therefore, SAMs can scale to an enormous size without any significant increase in training time and inference time.
|
| 46 |
+
|
| 47 |
+
The gate weight matrix $W _ { g }$ (Eq. 1) is trained together with the rest of the model parameters. Because there is no constraint on the learned weights, it is possible that $W _ { g }$ collapses such that one row dominates, i.e., all the inputs are routed to one expert. This problem is referred to as load imbalance. Existing works adopt various ad-hoc heuristics to mitigate this issue, e.g., adding Gaussian noise to Eq. 1 (noisy gating, Shazeer et al. 2017), limiting the maximum number of inputs that can be routed to an expert (expert capacity, Lepikhin et al. 2020), imposing a load balancing loss (Lepikhin et al., 2020; Fedus et al., 2021), and using linear assignment (Lewis et al., 2021). There are other works that remove the gating mechanism such that load imbalance is no longer an issue, e.g., by incorporating hash functions (Roller et al., 2021). Besides the load imbalance issue, there are also heated discussions on how to construct $\tau$ in Eq. 2. For example, Shazeer et al. (2017); Lepikhin et al. (2020); Yang et al. (2021) conjecture that routing inputs to $K > 1$ experts is necessary, while Fedus et al. (2021) argue that using $K = 1$ is sufficient and more computationally efficient.
|
| 48 |
+
|
| 49 |
+
# 3 ANALYSIS OF SPARSELY ACTIVATED MODELS
|
| 50 |
+
|
| 51 |
+
We investigate behavior of the gating mechanism of several classic MoE models. We conduct experiments on a multilingual translation task, $\{ \mathrm { D e } , \mathrm { V i } \} \to \mathrm { E n }$ . More details are presented in Appendix A.
|
| 52 |
+
|
| 53 |
+
We consider two MoE models proposed in Shen et al. (2019), referred to as MoE(dec) and MoE(tok), respectively, and three variants of the Switch Transformer proposed in Fedus et al. (2021). The number of experts is set to two for all the MoE models. We compare them with the Transformer (Vaswani et al., 2017) model of the same model size.
|
| 54 |
+
|
| 55 |
+
Figure 1 shows the validation losses and BLEU scores of three models: Transformer, MoE(dec), and MoE(tok). We see that the two MoE models perform very similarly, and neither outperforms the Transformer by a significant margin.
|
| 56 |
+
|
| 57 |
+
To interpret the results of Figure 1, we examine the load of each expert and the confidence scores of routing inputs to different experts. An expert’s load is defined as the proportion of inputs that are assigned to it. For an input that is routed to an expert, its routing confidence score (output of the gating mechanism) determines the level of preference, e.g., if the routing confidence score is 0.5, then the gate has no preference for either expert. For each expert, we compute the average routing confidence score over all the inputs assigned to it.
|
| 58 |
+
|
| 59 |
+
Figure 2 shows that after the early stage of training (i.e., the first 200 iterations), the gate weight collapses and nearly all the inputs are routed to expert 2. Also, the average routing confidence score of expert 2 is close to 1.0, which means that the gate strongly prefers expert 2 to expert 1. In this case, only one of the experts is sufficiently trained. Figure 3 depicts a different scenario, where the inputs are randomly dispatched to the experts. Notice that after approximately 4000 iterations, the two experts are equally loaded, and the probabilities of assigning any input to expert 1 and expert 2 are almost identical, indicating that the gating mechanism has no preference for either expert.
|
| 60 |
+
|
| 61 |
+
We have identified two behaviors of the gating mechanism: load imbalance and random routing. The former is also reported in recent papers (Shazeer et al., 2017; Lepikhin et al., 2020; Fedus et al., 2021). We further investigate the Switch Transformer (Fedus et al., 2021), which is a state-of-theart MoE variant that incorporates various methods to resolve the load imbalance issue. In addition, because behavior of the gating mechanism in the Switch Transformer mimics random routing (see Appendix A), we examine the effect of discarding the gate and randomly assigning inputs to experts. Figure 4 demonstrates the validation losses and BLEU scores of the Transformer and three variants of the Switch Transformer, where inputs are routed according to tokens (referred to as Switch(t)), sentences (Switch(s)), or are routed randomly (Switch(r)). Similar to the results in Figure 1, we see that the four models perform similarly. This shows that even after we alleviate load imbalance, model performance is not improved (i.e., the Switch Transformers do not outperform the vanilla Transformer), and the performance of the Switch Transformer does not vary much among different routing methods, including random routing.
|
| 62 |
+
|
| 63 |
+

|
| 64 |
+
Figure 1: Validation results of MoE(dec) and MoE(tok).
|
| 65 |
+
|
| 66 |
+

|
| 67 |
+
Figure 2: Gating mechanism of MoE(dec). Left: average routing confidence; Right: load of experts.
|
| 68 |
+
|
| 69 |
+

|
| 70 |
+
Figure 3: Gating mechanism of MoE(tok). Left: average routing confidence; Right: load of experts.
|
| 71 |
+
|
| 72 |
+

|
| 73 |
+
Figure 4: Performance of three variants of the Switch Transformer.
|
| 74 |
+
|
| 75 |
+
We remark that in this paper, we focus on natural language processing tasks, in particular neural machine translation. There are other works in different research fields (e.g., computer vision) that draw different conclusions than ours (Riquelme et al., 2021). We attribute this to the intrinsic differences between image classification and language generation, e.g., each input in the former belongs to a clearly-defined category, while no such knowledge exists in the latter.
|
| 76 |
+
|
| 77 |
+
In summary, the experiments reveal
|
| 78 |
+
|
| 79 |
+
• A sparsely activated model does not always outperform a densely activated model of the same model size.
|
| 80 |
+
• The widely-used routing method based on the gating mechanism does not work better than randomly routing inputs to experts.
|
| 81 |
+
|
| 82 |
+
# 4 THOR: TRANSFORMER WITH STOCHASTIC EXPERTS
|
| 83 |
+
|
| 84 |
+
The ineffectiveness of the gating mechanism, as shown in our experiments, motivates us to propose a new expert-based model, THOR (Transformer witH StOchastic ExpeRts). In THOR, a pair of experts are randomly selected and activated in each layer during a training iteration, and then all the inputs in a batch are processed using the same pair of experts. Our method drastically simplifies model design, and has two additional advantages. First, it eliminates the load imbalance issue because randomly selecting a pair of experts in each iteration allows each expert to have a fair chance to be sufficiently trained. The ad-hoc heuristics, such as the load balancing loss, as discussed in Section 2, are no longer needed. Second, unlike the gating mechanism, THOR does not introduce any additional model parameters.
|
| 85 |
+
|
| 86 |
+
One problem of THOR is that without a gating mechanism, experts need to be randomly selected during inference, and we may obtain inconsistent inference results due to different random seeds. For example, on a Czech-to-English translation dataset, our experiments show that randomness can result in a 0.5 BLEU score difference.
|
| 87 |
+
|
| 88 |
+
To address this issue, we introduce a consistency regularizer in the training objective of THOR. Concretely, let $N$ denotes the number of experts, $L$ the number of layers, and $\mathsf { \bar { E } } _ { i } ^ { l }$ an activated expert (which is a FFN) in layer $l$ , where $1 \leq i \leq N$ and $1 \le l \le L$ . We use $p = f ( \boldsymbol { x } ; \{ E _ { i } ^ { l } \} _ { l = 1 } ^ { L } )$ to indicate the prediction probability of input $x$ using the model $f$ where experts $\{ E _ { i } ^ { l } \} _ { l = 1 } ^ { L }$ are activated. Figure 5 illustrates one training iteration. Notice that instead of activating one expert for each layer in an iteration, we select to activate a pair of experts in THOR. As a result, we obtain two prediction probabilities produced by the two selections, respectively: $p _ { 1 } \ = \ f ( x ; \{ E _ { i } ^ { l } \} _ { l = 1 } ^ { L } ) )$ and $p _ { 2 } = f ( \boldsymbol { x } ; \{ E _ { j } ^ { l } \} _ { l = 1 } ^ { L } ) )$ . Then, the training objective of THOR with respect to training samples $( x , y )$ in the dataset $\bar { \mathcal { D } }$ is
|
| 89 |
+
|
| 90 |
+

|
| 91 |
+
Figure 5: Illustration of a training iteration with stochastic experts. For conciseness, we show a model with only one Transformer layer.
|
| 92 |
+
|
| 93 |
+
$$
|
| 94 |
+
\begin{array} { r l } & { \operatorname* { m i n } _ { ( x , y ) \in \mathcal { D } } \ell ( x , y ) = \mathrm { C E } ( p _ { 1 } ; y ) + \mathrm { C E } ( p _ { 2 } ; y ) + \alpha \mathrm { C R } ( p _ { 1 } ; p _ { 2 } ) , } \\ & { \quad \mathrm { ~ w h e r e ~ C R } ( p _ { 1 } ; p _ { 2 } ) = \displaystyle \frac { 1 } { 2 } \left( \mathrm { K L } ( p _ { 1 } \| p _ { 2 } ) + \mathrm { K L } ( p _ { 2 } \| p _ { 1 } ) \right) . } \end{array}
|
| 95 |
+
$$
|
| 96 |
+
|
| 97 |
+
Here, CE is the cross-entropy loss, the consistency regularizer CR is defined as the average of the two Kullback–Leibler (KL) divergence terms, and $\alpha$ is a hyper-parameter that controls the strength of the regularizer. In mini-batch SGD training, we randomly sample a pair of experts to activate at each layer for each batch. During inference, we can also randomly select an expert to activate at each layer for each input, similar to that in training. We can also use different expert-selection methods, such as expert-ensemble, as to be discussed in Section 5 (Table 5).
|
| 98 |
+
|
| 99 |
+
The THOR training objective of Eq. 3 forces all the experts to minimize training errors while making the same predictions as much as possible. Thus, in each training step, each expert optimizes its parameters by learning from both the training data (via minimizing the cross-entropy loss) and its paired expert as a teacher (via minimizing the KL divergence). Although these experts are learned to make consistent predictions, they converge to different (local) optima given the randomness introduced in training, e.g., initialization, mini-batch SGD, random routing, etc. Thus, every expert learns from a set of diverse teachers during the course of training, which helps to improve model’s performance. In addition, by penalizing experts that yield inconsistent predictions from the others, the consistency regularizer also helps reducing the variance of model prediction.
|
| 100 |
+
|
| 101 |
+
THOR is conceptually similar to dropout (Srivastava et al., 2014) since both methods route an input to some randomly selected sub-net components (i.e., experts in THOR and neurons in dropout). However, THOR differs from dropout in several important aspects, making it a better choice for efficient training and serving of large-scale neural models. First, THOR can be applied to both training and inference, while dropout is only used for training. Second, THOR is shown to be more robust in large-scale model training than dropout. For example, our models are less likely to overfit with the increase in the number of experts (see Figure 9). Third, THOR leads to a sparse model that is more structured than that of dropout, such that a large-scale THOR model can be much more easily trained using GPU clusters, e.g., by putting different experts on different GPUs in parallel.
|
| 102 |
+
|
| 103 |
+
# 5 EXPERIMENTS
|
| 104 |
+
|
| 105 |
+
We evaluate THOR on neural machine translation. We adopt three settings: low-resource translation, rich-resource translation, and multilingual translation. For low-resource and rich-resource translation, we train all the models using Fairseq1 (Ott et al., 2019). For multilingual translation, we use DeepSpeed $M o E ^ { 2 }$ (Kim et al., 2021) to implement the MoE models. All the experiments are conducted on NVIDIA V100 GPUs. Additional experiments, including model scale-up and comparison of inference speed, are deferred to Appendix D.
|
| 106 |
+
|
| 107 |
+
# 5.1 BASELINE
|
| 108 |
+
|
| 109 |
+
We use two baselines in the experiments.
|
| 110 |
+
|
| 111 |
+
• Transformer (Vaswani et al., 2017) achieves superior performance in many sequence-tosequence learning tasks, such as neural machine translation. • Switch Transformer (Fedus et al., 2021) is a state-of-the-art MoE model, which employs a gating mechanism to route inputs and uses a load balancing loss to reduce load imbalance.
|
| 112 |
+
|
| 113 |
+
To verify the effectiveness of the imposed consistency regularizer in Eq. 3, we also compare THOR with Transformer models trained using two popular regularization methods. We remark that these two methods share similar computational costs with THOR, i.e., they also require two forward passes in each training iteration.
|
| 114 |
+
|
| 115 |
+
• SMART (Jiang et al., 2020) utilizes a smoothness inducing adversarial regularizer to penalize the worst case difference between predictions of a clean input and a perturbed input. • R3F (Aghajanyan et al., 2020) uses a regularizer to reduce representational collapse. The method has shown to be effective in various natural language processing tasks.
|
| 116 |
+
|
| 117 |
+
All the methods are trained for the same number of FLOPs in the experiments for fair comparison.
|
| 118 |
+
|
| 119 |
+
# 5.2 LOW-RESOURCE TRANSLATION
|
| 120 |
+
|
| 121 |
+
We use six language pairs: English to Vietnamese, English to German, and English to French from IWSLT; English to Romanian, English to Latvian, and English to Czech from Europarl3. Dataset statistics are summarized in Table 6 (Appendix B).
|
| 122 |
+
|
| 123 |
+
Table 1: Experimental results on low resource datasets. The best result on each dataset is in bold.
|
| 124 |
+
|
| 125 |
+
<table><tr><td></td><td>En-Vi</td><td>Vi-En</td><td>En-De</td><td>De-En</td><td>En-Fr</td><td>Fr-En</td></tr><tr><td>Transformer (Vaswani et al., 2017)</td><td>31.3</td><td>29.4</td><td>28.1</td><td>34.8</td><td>39.2</td><td>38.1</td></tr><tr><td>SMART (Jiang et al., 2020)</td><td>32.5</td><td>30.5</td><td>29.3</td><td>35.8</td><td>40.0</td><td>38.8</td></tr><tr><td>R3F (Aghajanyan et al., 2020)</td><td>32.2</td><td>30.7</td><td>29.2</td><td>35.7</td><td>39.7</td><td>38.9</td></tr><tr><td>Switch (Fedus et al., 2021)</td><td>31.7</td><td>29.5</td><td>28.4</td><td>34.6</td><td>39.1</td><td>38.2</td></tr><tr><td>THOR</td><td>34.0</td><td>33.0</td><td>31.1</td><td>37.8</td><td>40.7</td><td>40.0</td></tr><tr><td></td><td>En-Ro</td><td>Ro-En</td><td>En-Lv</td><td>Lv-En</td><td>En-Cs</td><td>Cs-En</td></tr><tr><td>Transformer (Vaswani et al., 2017)</td><td>23.5</td><td>25.0</td><td>13.6</td><td>15.8</td><td>16.1</td><td>20.4</td></tr><tr><td>SMART (Jiang et al., 2020)</td><td>24.6</td><td>25.7</td><td>14.2</td><td>16.3</td><td>16.7</td><td>21.4</td></tr><tr><td>R3F (Aghajanyan et al., 2020)</td><td>23.8</td><td>25.8</td><td>14.4</td><td>16.3</td><td>16.8</td><td>21.6</td></tr><tr><td>Switch (Fedus et al., 2021)</td><td>23.8</td><td>24.4</td><td>13.8</td><td>16.1</td><td>16.1</td><td>20.6</td></tr><tr><td>THOR</td><td>25.2</td><td>27.1</td><td>15.2</td><td>17.4</td><td>17.6</td><td>22.4</td></tr></table>
|
| 126 |
+
|
| 127 |
+
To evaluate THOR with different model sizes, we use the Transformer-base (Vaswani et al., 2017) architecture on Europarl datasets, and a smaller model on IWSLT datasets. Compared with Transformer-base, the smaller model decreases the hidden dimension from 2048 to 1024, and decreases the number of heads from 8 to 4 with the dimension of each head doubled. We use two experts for the expert-based models. We remark that even though THOR increases the number of parameters, its inference speed (in terms of FLOPs) is the same as Transformer-base because only one expert is activated for each input. Interested readers refer to Appendix C for more details.
|
| 128 |
+
|
| 129 |
+
The experimental results in Table 1 show that performance of the Switch Transformer is on par with the vanilla Transformer, e.g., its average BLEU score on the 12 datasets is 26.3, the same as the Transformer. The results confirm that SAMs do not outperform densely activated models with similar model sizes. In contrast, THOR achieves more than 1.0 BLEU score improvement over the Switch Transformer in all the 12 tasks. THOR also significantly outperforms the models trained using the two competing regularization methods, SMART and R3F.
|
| 130 |
+
|
| 131 |
+
# 5.3 RICH-RESOURCE TRANSLATION
|
| 132 |
+
|
| 133 |
+
We use two widely adopted rich-resource translation benchmarks: English to German translation from WMT’16 and English to French translation from WMT’14. The former dataset consists of 4.5 million training sentence pairs, and the latter 36 million pairs. We follow the pre-processing steps in Ott et al. (2018).
|
| 134 |
+
|
| 135 |
+
To evaluate THOR , We use the Transformer-big architecture (Vaswani et al., 2017) and we set the number of experts for both THOR and the Switch Transformer to 4. Interested readers refer to Appendix C for more details.
|
| 136 |
+
|
| 137 |
+
Table 2 reports the BLEU scores and the sacreBLEU scores (Post, 2018) of different models. We see that THOR achieves new state-ofthe-art results in the setting where neither data augmentation nor pre-trained language model is used. Specifically, THOR lifts the previous state-of-the-art (Liu et al., 2020b;c) by 0.3 BLEU score on the En-De translation task and 0.1 BLEU score on the En-Fr translation task. THOR also significantly outperforms the models trained using the other two regularization methods, SMART (Jiang et al., 2020) and R3F (Aghajanyan et al., 2020). Similar to what is observed in low-resource translation, the Switch Transformer (Fedus et al., 2021) does not outperform the vanilla Transformer (Ott et al., 2018).
|
| 138 |
+
|
| 139 |
+
Table 2: BLEU and sacreBLEU scores on WMT’14 En-Fr and WMT’16 En-De. Results of Jiang et al. (2020), Aghajanyan et al. (2020), and Fedus et al. (2021) are from our implementation.
|
| 140 |
+
|
| 141 |
+
<table><tr><td>BLEU</td><td>En-De</td><td>En-Fr</td></tr><tr><td>Vas wani et al. (2017)</td><td>28.4</td><td>41.8</td></tr><tr><td>Ott et al. (2018)</td><td>29.3</td><td>43.2</td></tr><tr><td>Wang et al. (2019b)</td><td>29.6</td><td>一</td></tr><tr><td>Wu et al. (2019a)</td><td>29.7</td><td>43.2</td></tr><tr><td>So et al. (2019)</td><td>29.8</td><td>41.3</td></tr><tr><td>Jiang et al. (2020)</td><td>29.8</td><td>43.4</td></tr><tr><td>Wu et al. (2019b)</td><td>29.9</td><td>43.3</td></tr><tr><td>Aghajanyan et al. (2020)</td><td>29.4</td><td>43.3</td></tr><tr><td>Liu et al. (2020c)</td><td>30.1</td><td>43.8</td></tr><tr><td>Fedus et al. (2021)</td><td>29.3</td><td>43.0</td></tr><tr><td>THOR</td><td>30.4</td><td>43.8</td></tr><tr><td>sacreBLEU</td><td>En-De</td><td>En-Fr</td></tr><tr><td>Ott et al. (2018)</td><td>28.6</td><td>41.4</td></tr><tr><td> Jiang et al. (2020)</td><td>29.1</td><td>41.5</td></tr><tr><td>So et al. (2019)</td><td>29.2</td><td></td></tr><tr><td>Aghajanyan et al. (2020)</td><td>29.0</td><td>41.5</td></tr><tr><td>Liu et al. (2020c)</td><td>29.5</td><td>41.8</td></tr><tr><td>Fedus et al. (2021)</td><td>28.6</td><td>41.1</td></tr><tr><td>THOR</td><td>29.6</td><td>41.9</td></tr></table>
|
| 142 |
+
|
| 143 |
+
# 5.4 MULTILINGUAL TRANSLATION
|
| 144 |
+
|
| 145 |
+
We have collected 10 language pairs from WMT datasets, and built a $6 4 k$ -entry dictionary for all the languages. The detailed statistics are summarized in Table 7 (Appendix B). Please refer to Kim et al. (2021) for more details. We do not use multi-task learning or additional monolingual data in the experiments.
|
| 146 |
+
|
| 147 |
+
We use the following model architecture: the embedding dimension is set to 768 and the hidden dimension for the FFN is set to 3072; we use 12 encoder layers and 6 decoder layers, where each layer has 12 attention heads, and the dimension of each head is 64. We set the number of experts to 4 for both THOR and the Switch Transformer.
|
| 148 |
+
|
| 149 |
+
Table 3 reports the average BLEU score of translating English to other languages, translating other languages to English, and the overall score of the 20 tasks. We see that compared with the Switch
|
| 150 |
+
|
| 151 |
+
Transformer of the same size (i.e., 300 million parameters), our model achieves a 2-point improvement in the overall BLEU score. In addition, our model is far more parameter efficient than the Switch Transformer. The THOR model with 300 million parameters achieves the same BLEU score (24.4) that is achieved by the Switch Transformer with 5.5 billion parameters, which is more than 18 times larger.
|
| 152 |
+
|
| 153 |
+
Table 3: Multilingual translation results. Here $\mathbf { \vec { E } } ^ { \prime } \mathbf { \vec { \Sigma } }$ means the number of experts.
|
| 154 |
+
|
| 155 |
+
<table><tr><td></td><td>En-→Others</td><td>Others-En</td><td>Average</td></tr><tr><td>Switch (32E,5.5B)</td><td>一</td><td>一</td><td>24.4</td></tr><tr><td>Switch (4E,300M)</td><td>20.3</td><td>24.6</td><td>22.4</td></tr><tr><td>THOR (4E,300M)</td><td>21.4</td><td>27.4</td><td>24.4</td></tr></table>
|
| 156 |
+
|
| 157 |
+
Figure 6 shows BLEU scores in all the 20 translation tasks. Notice that THOR outperforms the baseline on 17 out of the 20 tasks. The improvement is in general more significant on the tasks with smaller datasets. For example, our model achieves BLEU score improvement of 4.7 and 6.7 on Gu-En $( 8 5 k )$ and Hi-En $( 2 6 4 k )$ , respectively. On the tasks with larger datasets, the improvement obtained by our model is less substantial, but still significant, e.g., $+ 0 . 9$ BLEU score on Cs-En $( 1 0 M )$ and $+ 1 . 1$ Fi-En $( 4 . 8 M )$ . For the only three tasks where our model underperforms the baseline, the gaps are small, e.g., $- 0 . 4 , - 0 . 2$ , and $- 0 . 4$ BLEU scores on En-Cs, En-De, and En-Fr, respectively.
|
| 158 |
+
|
| 159 |
+

|
| 160 |
+
Figure 6: Details of multilingual translation results.
|
| 161 |
+
|
| 162 |
+
# 5.5 ABLATION EXPERIMENTS
|
| 163 |
+
|
| 164 |
+
Training Objective. We examine the relative contributions of the three loss terms used in the THOR training objective of Eq. 3: $\mathrm { C E _ { 1 } }$ , $\mathrm { C E _ { 2 } }$ and CR. The result in Table 4 shows that the consistency regularizer CR is crucial to the model performance, and that dropping one of the two CE terms leads to only very small BLEU score loss since the two cross-entropy terms play the same role in training.
|
| 165 |
+
|
| 166 |
+
Inference Methods. We compare three inference methods: (1) Dispatch(s) uses sentencelevel random routing, where all tokens in one sentence are routed to the same expert; (2) Dispatch(t) uses token-level random routing, where tokens within a sentence are routed to different experts; (3) Ensemble, where each sentence is routed to all the $N$ experts, and the $N$ hidden representations in each layer are averaged. Note that the number of FLOPs is larger for Ensemble because we need to run forward pass for each input through $N$ experts. Table 5 shows that Dispatch(s) and Dispatch(t) perform similarly, and Ensemble yields the best BLEU score with a cost of longer inference time.
|
| 167 |
+
|
| 168 |
+
Table 4: Effect of the three loss terms in training object of Eq. 3, tested on Cs-En translation.
|
| 169 |
+
|
| 170 |
+
<table><tr><td>Loss terms</td><td>BLEU</td></tr><tr><td>CE1+CE2+CR</td><td>22.4</td></tr><tr><td>CE+CR</td><td>22.2</td></tr><tr><td>CEi+CE2 CE1</td><td>20.8 20.6</td></tr></table>
|
| 171 |
+
|
| 172 |
+
Table 5: Performance and costs of three inference methods, tested on CsEn translation.
|
| 173 |
+
|
| 174 |
+
<table><tr><td></td><td>BLEU</td><td>time</td></tr><tr><td>Dispatch(s)</td><td>22.4</td><td>×1</td></tr><tr><td>Dispatch(t)</td><td>22.4</td><td>×1</td></tr><tr><td>Ensemble</td><td>22.6</td><td>×N</td></tr></table>
|
| 175 |
+
|
| 176 |
+

|
| 177 |
+
Figure 7: Effect of the consistency regularization strength $\alpha$ on Cs-En translation.
|
| 178 |
+
|
| 179 |
+

|
| 180 |
+
Figure 8: Violin plot of performance consistency on CsEn translation.
|
| 181 |
+
|
| 182 |
+

|
| 183 |
+
Figure 9: BLEU vs. model size on De-En translation.
|
| 184 |
+
|
| 185 |
+
Regularization strength. To investigate the effect of the regularization strength $\alpha$ , we run experiments on the Cs-En translation dataset in the low-resource setting. Figure 7 shows that model performance is not very sensitive to $\alpha$ as long as the value is large enough, say $\alpha > 2 . 0$ .
|
| 186 |
+
|
| 187 |
+
Consistency of Model Prediction. We study the variance of model prediction due to the use of randomly activated experts during inference. We compare THOR and the Switch Transformer, where we remove the trained gate during inference. For each model, we compute the variance of model prediction based on 20 runs. As shown in Figure 8, THOR makes more consistent predictions than Switch Transformer due to the use of the consistency regularizer for model training. The variance of THOR is below 0.002, whereas the variance of Switch Transformer is 0.008, four times larger. We remark that by removing the trained router from the Switch Transformer, model performance only marginally decreases (from 20.6 to 20.4). This further indicates that a trained router may not be better than a random router.
|
| 188 |
+
|
| 189 |
+
Overfitting. We compare the THOR model and the Transformer model regarding how likely they overfit the training data when the model size increases. We run experiments on the De-En data in the low-resource setting, where the dropout rate of the FFNs in the Transformer is selected such that the number of parameters trained in one iteration is the same as the THOR model. As shown in Figure 9, THOR does not show any sign of overfitting — we observe a consistent improvement in BLEU score as we increase the number of experts from 2 to 8. In contrast, the Transformer model’s performance deteriorates as we increase the hidden dimension of its FFN from $2 k$ to $8 k$ . We remark that we also observe the overfitting phenomenon on larger datasets, e.g., the Transformer overfits on the Cs-En dataset when we set the hidden dimension of its FFN to $1 6 k$ .
|
| 190 |
+
|
| 191 |
+
# 6 CONCLUSION
|
| 192 |
+
|
| 193 |
+
We present a new expert-based sparsely activated model, THOR. Unlike existing SAMs, such as the Switch Transformer, experts in THOR are randomly activated for each input during training and inference. THOR models are trained using a consistency regularized loss, where every expert learns not only from training data but also from other experts as teachers so that all the experts make consistent predictions. As a result, not only can large-scale THOR models be trained and served as efficiently as classic MoE models, THOR models also demonstrate a better generalization capability in that they are more parameter-efficient, less likely to overfit, make more consistent predictions, and achieve better results consistently across different settings. We validate the effectiveness of THOR via a comprehensive empirical study on machine translation. In all the three settings (i.e., low-resource, rich-resource, and multilingual translation), THOR models significantly outperform the vanilla Transformer, and Switch Transformer, a state-of-the-art MoE model.
|
| 194 |
+
|
| 195 |
+
# ACKNOWLEDGMENTS
|
| 196 |
+
|
| 197 |
+
We thank Rukmini Lyer, Kevin Duh, Hao Cheng, Chunyuan Li, Johannes Gehrke, colleagues from Microsoft Bing Ads team and Microsoft Research for their valuable discussions and comments.
|
| 198 |
+
|
| 199 |
+
# REFERENCES
|
| 200 |
+
|
| 201 |
+
Armen Aghajanyan, Akshat Shrivastava, Anchit Gupta, Naman Goyal, Luke Zettlemoyer, and Sonal Gupta. Better fine-tuning by reducing representational collapse. ArXiv preprint, abs/2008.03156, 2020. URL https://arxiv.org/abs/2008.03156.
|
| 202 |
+
|
| 203 |
+
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 Hugo Larochelle, Marc’Aurelio Ranzato, Raia Hadsell, Maria-Florina 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. URL https://proceedings.neurips.cc/paper/2020/hash/ 1457c0d6bfcb4967418bfb8ac142f64a-Abstract.html.
|
| 204 |
+
|
| 205 |
+
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, abs/1803.05457, 2018. URL https://arxiv.org/abs/1803.05457.
|
| 206 |
+
|
| 207 |
+
Alexis Conneau and Guillaume Lample. Cross-lingual language model pretraining. In Hanna M. Wallach, Hugo Larochelle, Alina Beygelzimer, Florence d’Alche-Buc, Emily B. Fox, and Roman ´ Garnett (eds.), Advances in Neural Information Processing Systems 32: Annual Conference on Neural Information Processing Systems 2019, NeurIPS 2019, December 8-14, 2019, Vancouver, BC, Canada, pp. 7057–7067, 2019. URL https://proceedings.neurips.cc/paper/ 2019/hash/c04c19c2c2474dbf5f7ac4372c5b9af1-Abstract.html.
|
| 208 |
+
|
| 209 |
+
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 4171–4186, Minneapolis, Minnesota, 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-1423. URL https://aclanthology.org/N19-1423.
|
| 210 |
+
|
| 211 |
+
William Fedus, Barret Zoph, and Noam Shazeer. Switch transformers: Scaling to trillion parameter models with simple and efficient sparsity. ArXiv preprint, abs/2101.03961, 2021. URL https: //arxiv.org/abs/2101.03961.
|
| 212 |
+
|
| 213 |
+
Pengcheng He, Xiaodong Liu, Jianfeng Gao, and Weizhu Chen. Deberta: Decoding-enhanced bert with disentangled attention. ArXiv preprint, abs/2006.03654, 2020. URL https://arxiv. org/abs/2006.03654.
|
| 214 |
+
|
| 215 |
+
Haoming Jiang, Pengcheng He, Weizhu Chen, Xiaodong Liu, Jianfeng Gao, and Tuo Zhao. SMART: Robust and efficient fine-tuning for pre-trained natural language models through principled regularized optimization. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pp. 2177–2190, Online, 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.acl-main.197. URL https://aclanthology.org/2020. acl-main.197.
|
| 216 |
+
|
| 217 |
+
Young Jin Kim, Ammar Ahmad Awan, Alexandre Muzio, Andres Felipe Cruz Salinas, Liyang Lu, Amr Hendy, Samyam Rajbhandari, Yuxiong He, and Hany Hassan Awadalla. Scalable and efficient moe training for multitask multilingual models. ArXiv preprint, abs/2109.10465, 2021. URL https://arxiv.org/abs/2109.10465.
|
| 218 |
+
|
| 219 |
+
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.
|
| 220 |
+
|
| 221 |
+
Dmitry Lepikhin, HyoukJoong Lee, Yuanzhong Xu, Dehao Chen, Orhan Firat, Yanping Huang, Maxim Krikun, Noam Shazeer, and Zhifeng Chen. Gshard: Scaling giant models with conditional computation and automatic sharding. ArXiv preprint, abs/2006.16668, 2020. URL https: //arxiv.org/abs/2006.16668.
|
| 222 |
+
|
| 223 |
+
Mike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad, Abdelrahman Mohamed, Omer Levy, Veselin Stoyanov, and Luke Zettlemoyer. BART: Denoising sequence-to-sequence pretraining for natural language generation, translation, and comprehension. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pp. 7871–7880, Online, 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.acl-main.703. URL https://aclanthology.org/2020.acl-main.703.
|
| 224 |
+
|
| 225 |
+
Mike Lewis, Shruti Bhosale, Tim Dettmers, Naman Goyal, and Luke Zettlemoyer. Base layers: Simplifying training of large, sparse models. ArXiv preprint, abs/2103.16716, 2021. URL https://arxiv.org/abs/2103.16716.
|
| 226 |
+
|
| 227 |
+
Liyuan Liu, Haoming Jiang, Pengcheng He, Weizhu Chen, Xiaodong Liu, Jianfeng Gao, and Jiawei Han. On the variance of the adaptive learning rate and beyond. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020. OpenReview.net, 2020a. URL https://openreview.net/forum?id $\equiv$ rkgz2aEKDr.
|
| 228 |
+
|
| 229 |
+
Liyuan Liu, Xiaodong Liu, Jianfeng Gao, Weizhu Chen, and Jiawei Han. Understanding the difficulty of training transformers. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 5747–5763, Online, 2020b. Association for Computational Linguistics. doi: 10.18653/v1/2020.emnlp-main.463. URL https:// aclanthology.org/2020.emnlp-main.463.
|
| 230 |
+
|
| 231 |
+
Xiaodong Liu, Kevin Duh, Liyuan Liu, and Jianfeng Gao. Very deep transformers for neural machine translation. ArXiv preprint, abs/2008.07772, 2020c. URL https://arxiv.org/abs/ 2008.07772.
|
| 232 |
+
|
| 233 |
+
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, abs/1907.11692, 2019. URL https://arxiv.org/abs/1907. 11692.
|
| 234 |
+
|
| 235 |
+
Myle Ott, Sergey Edunov, David Grangier, and Michael Auli. Scaling neural machine translation. In Proceedings of the Third Conference on Machine Translation: Research Papers, pp. 1–9, Brussels, Belgium, 2018. Association for Computational Linguistics. doi: 10.18653/v1/W18-6301. URL https://aclanthology.org/W18-6301.
|
| 236 |
+
|
| 237 |
+
Myle Ott, Sergey Edunov, Alexei Baevski, Angela Fan, Sam Gross, Nathan Ng, David Grangier, and Michael Auli. fairseq: A fast, extensible toolkit for sequence modeling. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics (Demonstrations), pp. 48–53, Minneapolis, Minnesota, 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-4009. URL https://aclanthology.org/N19-4009.
|
| 238 |
+
|
| 239 |
+
Matt Post. A call for clarity in reporting BLEU scores. In Proceedings of the Third Conference on Machine Translation: Research Papers, pp. 186–191, Brussels, Belgium, 2018. Association for Computational Linguistics. doi: 10.18653/v1/W18-6319. URL https://aclanthology. org/W18-6319.
|
| 240 |
+
|
| 241 |
+
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.
|
| 242 |
+
|
| 243 |
+
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-totext transformer. ArXiv preprint, abs/1910.10683, 2019. URL https://arxiv.org/abs/ 1910.10683.
|
| 244 |
+
|
| 245 |
+
Carlos Riquelme, Joan Puigcerver, Basil Mustafa, Maxim Neumann, Rodolphe Jenatton, Andre Su- ´ sano Pinto, Daniel Keysers, and Neil Houlsby. Scaling vision with sparse mixture of experts. arXiv preprint arXiv:2106.05974, 2021. URL https://arxiv.org/abs/2106.05974.
|
| 246 |
+
|
| 247 |
+
Stephen Roller, Sainbayar Sukhbaatar, Arthur Szlam, and Jason Weston. Hash layers for large sparse models. ArXiv preprint, abs/2106.04426, 2021. URL https://arxiv.org/abs/ 2106.04426.
|
| 248 |
+
|
| 249 |
+
Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words with subword units. In Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 1715–1725, Berlin, Germany, 2016. Association for Computational Linguistics. doi: 10.18653/v1/P16-1162. URL https://aclanthology. org/P16-1162.
|
| 250 |
+
|
| 251 |
+
Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc V. Le, Geoffrey E. Hinton, and Jeff Dean. Outrageously large neural networks: The sparsely-gated mixtureof-experts layer. In 5th International Conference on Learning Representations, ICLR 2017, Toulon, France, April 24-26, 2017, Conference Track Proceedings. OpenReview.net, 2017. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ B1ckMDqlg.
|
| 252 |
+
|
| 253 |
+
Tianxiao Shen, Myle Ott, Michael Auli, and Marc’Aurelio Ranzato. Mixture models for diverse machine translation: Tricks of the trade. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, ICML 2019, 9- 15 June 2019, Long Beach, California, USA, volume 97 of Proceedings of Machine Learning Research, pp. 5719–5728. PMLR, 2019. URL http://proceedings.mlr.press/v97/ shen19c.html.
|
| 254 |
+
|
| 255 |
+
David R. So, Quoc V. Le, and Chen Liang. The evolved transformer. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, ICML 2019, 9-15 June 2019, Long Beach, California, USA, volume 97 of Proceedings of Machine Learning Research, pp. 5877–5886. PMLR, 2019. URL http://proceedings. mlr.press/v97/so19a.html.
|
| 256 |
+
|
| 257 |
+
Nitish Srivastava, Geoffrey Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. Dropout: a simple way to prevent neural networks from overfitting. The journal of machine learning research, 15(1):1929–1958, 2014.
|
| 258 |
+
|
| 259 |
+
Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In 2016 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2016, Las Vegas, NV, USA, June 27-30, 2016, pp. 2818–2826. IEEE Computer Society, 2016. doi: 10.1109/CVPR.2016.308. URL https: //doi.org/10.1109/CVPR.2016.308.
|
| 260 |
+
|
| 261 |
+
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Isabelle Guyon, Ulrike von Luxburg, Samy Bengio, Hanna M. Wallach, Rob Fergus, S. V. N. Vishwanathan, and Roman Garnett (eds.), Advances in Neural Information Processing Systems 30: Annual Conference on Neural Information Processing Systems 2017, December 4-9, 2017, Long Beach, CA, USA, pp. 5998–6008, 2017. URL https://proceedings.neurips.cc/paper/2017/hash/ 3f5ee243547dee91fbd053c1c4a845aa-Abstract.html.
|
| 262 |
+
|
| 263 |
+
Alex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R. Bowman. GLUE: A multi-task benchmark and analysis platform for natural language understanding. In 7th International Conference on Learning Representations, ICLR 2019, New Orleans, LA, USA, May 6-9, 2019. OpenReview.net, 2019a. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ rJ4km2R5t7.
|
| 264 |
+
|
| 265 |
+
Qiang Wang, Bei Li, Tong Xiao, Jingbo Zhu, Changliang Li, Derek F. Wong, and Lidia S. Chao. Learning deep transformer models for machine translation. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pp. 1810–1822, Florence, Italy, 2019b. Association for Computational Linguistics. doi: 10.18653/v1/P19-1176. URL https://aclanthology.org/P19-1176.
|
| 266 |
+
|
| 267 |
+
Felix Wu, Angela Fan, Alexei Baevski, Yann N. Dauphin, and Michael Auli. Pay less attention with lightweight and dynamic convolutions. In 7th International Conference on Learning Representations, ICLR 2019, New Orleans, LA, USA, May 6-9, 2019. OpenReview.net, 2019a. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ SkVhlh09tX.
|
| 268 |
+
|
| 269 |
+
Lijun Wu, Yiren Wang, Yingce Xia, Fei Tian, Fei Gao, Tao Qin, Jianhuang Lai, and Tie-Yan Liu. Depth growing for neural machine translation. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pp. 5558–5563, Florence, Italy, 2019b. Association for Computational Linguistics. doi: 10.18653/v1/P19-1558. URL https:// aclanthology.org/P19-1558.
|
| 270 |
+
|
| 271 |
+
An Yang, Junyang Lin, Rui Men, Chang Zhou, Le Jiang, Xianyan Jia, Ang Wang, Jie Zhang, Jiamang Wang, Yong Li, et al. Exploring sparse expert models and beyond. ArXiv preprint, abs/2105.15082, 2021. URL https://arxiv.org/abs/2105.15082.
|
| 272 |
+
|
| 273 |
+
# A ANALYSIS OF SPARSELY ACTIVATED MODELS
|
| 274 |
+
|
| 275 |
+
# A.1 TRAINING DETAILS
|
| 276 |
+
|
| 277 |
+
We consider two Mixture-of-Experts (MoE) models proposed in Shen et al. (2019), which are denoted “MoE(dec)” and “MoE(tok)”. In the first variant, each expert is a separate Transformer decoder. In the second variant, each expert is a different token, i.e., if we route the input to expert one, then we replace the $\left. b o s \right.$ (begin-of-sentence) token in the input sentence with a $\langle e x p e r t _ { 1 } \rangle$ token. Note that embeddings of these expert tokens are trained together with the rest of the model parameters. These models are equipped with an expectation-maximization optimization framework. Such a framework facilitates computing the probability of assigning an input to a specific expert according to the gating mechanism. Please refer to Shen et al. (2019) for details about these models.
|
| 278 |
+
|
| 279 |
+
We use a multilingual translation setting, where we adopt two datasets: De-En from IWSLT’14 and Vi-En from IWSLT’15. For each dataset, we use byte pair encoding (BPE, Sennrich et al. 2016) with 10, 000 merge operations for pre-processing. Then we concatenate the two pre-processed datasets. We learn a separate dictionary for En and $\mathrm { \bar { \{ D e + V i \} } }$ , which resulted in approximately $9 k$ and $1 2 k$ vocabularies, respectively.
|
| 280 |
+
|
| 281 |
+
For training, we use Adam (Kingma & Ba, 2015) as the optimizer and we set the learning rate to 0.001. We set the batch size to be equivalent to $6 4 k$ tokens, e.g., we use $8 k$ tokens per GPU with 8 GPUs. Other training details follow the Fairseq4 implementation. For inference, we use a beam size of 5 and a length penalty of 1.0.
|
| 282 |
+
|
| 283 |
+
# A.2 ADDITIONAL RESULTS
|
| 284 |
+
|
| 285 |
+
We also plot the average routing confidence score and the load of experts for Switch(s) and Switch(t), similar to Figure 2 and Figure 3. We first investigate the Switch Transformer without the load balancing loss.
|
| 286 |
+
|
| 287 |
+

|
| 288 |
+
Figure 10: Switch(s) w/o load balancing. Left: average routing confidence; Right: load of experts.
|
| 289 |
+
|
| 290 |
+

|
| 291 |
+
Figure 11: Switch(t) w/o load balancing. Left: average routing confidence; Right: load of experts.
|
| 292 |
+
|
| 293 |
+
Figure 10 shows the results for Switch(s) without the load balancing loss, where we route inputs to experts on the sentence-level. We see that after about $1 0 k$ training iterations, the average routing confidence score of expert 1 and expert 2 becomes similar, and both of these scores are around 0.60. Moreover, the load of the experts are not balanced, i.e., there is a $1 0 \%$ difference in the loads $( 5 5 \%$ vs. $4 5 \%$ ). We conclude that behavior of the gating mechanism of Switch(s) is similar to Figure 3, i.e., the gate is essentially randomly routing inputs to experts without any preference.
|
| 294 |
+
|
| 295 |
+
Figure 11 shows the results for Switch(t) without the load balancing loss, where we route inputs to experts on the token-level, i.e., different tokens within the same sentence may be routed to different experts. Similar to the Switch(s) case, the average routing confidence score of both of the two experts converges to around 0.55. This indicates that the gate do not prefer any expert given an input. Moreover, the load of the experts are not balanced, the same as in Figure 10. Based on these observations, we conclude that behavior of the gating mechanism of Switch(t) is also random routing.
|
| 296 |
+
|
| 297 |
+

|
| 298 |
+
Figure 12: Switch(s) w/ load balancing. Left: average routing confidence; Right: load of experts.
|
| 299 |
+
|
| 300 |
+

|
| 301 |
+
Figure 13: Switch(t) w/ load balancing. Left: average routing confidence; Right: load of experts.
|
| 302 |
+
|
| 303 |
+
Figure 12 and Figure 13 show behavior of the gating mechanism of Switch(s) and Switch(t) equipped with the load balancing loss, respectively. We see that the load balancing loss indeed balances the load for both Switch(s) and Switch(t), e.g., there is a less than $0 . 4 \%$ imbalance for Switch(s) and less than $0 . 2 \%$ imbalance for Switch(t). In comparison, the imbalance is around $1 0 \%$ for the two Switch Transformer variants without the load balancing loss. Also, similar to the case without the load balancing loss, the average routing confidence score converges to around 0.60 for Switch(s) and around 0.55 for Switch(t). Based on the observations, we conclude that behavior of the gating mechanism is still random routing when Switch(s) and Switch(t) are equipped with the load balancing loss.
|
| 304 |
+
|
| 305 |
+
# B DATASETS
|
| 306 |
+
|
| 307 |
+
Statistics of low-resource datasets are shown in Table 6. The English-Vietnamese, English-German, and English-French datasets are from5 IWSLT’14, ’15, and ’16, respectively. The training data of
|
| 308 |
+
|
| 309 |
+
English-Romanian, English-Latvian, and English-Czech are from Europarl6, and the validation and testing data are from WMT’17.
|
| 310 |
+
|
| 311 |
+
Statistics and data sources used in the multilingual translation task are shown in Table 7.
|
| 312 |
+
|
| 313 |
+
Table 6: Statistics of low resource translation datasets.
|
| 314 |
+
|
| 315 |
+
<table><tr><td></td><td>En-Vi</td><td>En-De</td><td>En-Fr</td><td>En-Ro</td><td>En-Lv</td><td>En-Cs</td></tr><tr><td>Train</td><td>117,055</td><td>160,239</td><td>218,256</td><td>390,746</td><td>591,631</td><td>619,029</td></tr><tr><td>Validation</td><td>5,098</td><td>7,283</td><td>8,453</td><td>1,900</td><td>1,949</td><td>2,902</td></tr><tr><td>Test</td><td>1,268</td><td>6,750</td><td>1,133</td><td>1,999</td><td>2.,001</td><td>3,005</td></tr></table>
|
| 316 |
+
|
| 317 |
+
Table 7: Statistics of multilingual translation datasets. The other language in the translation tasks is English (En) for all the datasets.
|
| 318 |
+
|
| 319 |
+
<table><tr><td>Language</td><td>Czech (Cs)</td><td>German (De)</td><td>Estonian (Et)</td><td>Finnish (Fi)</td><td>French (Fr)</td></tr><tr><td>Data source # Samples</td><td>WMT'19</td><td>WMT'19</td><td>WMT'18</td><td>WMT'19</td><td>WMT'15</td></tr><tr><td></td><td>10,273,696</td><td>4,613,192</td><td>695,227</td><td>4,838,576</td><td>9,999,995</td></tr><tr><td>Language</td><td>Gujarati (Gu)</td><td>Hindi (Hi)</td><td>Latvian (Lv)</td><td>Romanian (Ro)</td><td>Turkish (Tr)</td></tr><tr><td>Data source</td><td>WMT'19</td><td>WMT'14</td><td>WMT'17</td><td>WMT'16</td><td>WMT'18</td></tr><tr><td># Samples</td><td>85,688</td><td>264,199</td><td>1,444,235</td><td>540,562</td><td>182,269</td></tr></table>
|
| 320 |
+
|
| 321 |
+
# C TRAINING DETAILS
|
| 322 |
+
|
| 323 |
+
# C.1 LOW RESOURCE TRANSLATION
|
| 324 |
+
|
| 325 |
+
We build a joined dictionary for the source and target languages for each dataset. To facilitate this, we use byte pair encoding (BPE) with 10, 000 and 40, 000 split operations for the IWSLT and the WMT datasets, respectively. Other pre-processing steps follow the Fairseq implementation.
|
| 326 |
+
|
| 327 |
+
For training, the regularization strength is chosen to be $\alpha \ : = \ : 5 . 0$ . We set the batch size to be equivalent to $3 2 k$ tokens, i.e., if we have four GPUs, then we set the number of tokens on each GPU to be $4 k$ and accumulate gradients for two steps. We use Adam as the optimizer with $\beta _ { 1 } = 0 . 9$ , $\beta _ { 2 } = 0 . 9 8$ , and we set the learning rate to be 0.0015. We train the model for $4 0 k$ steps, and we test the model that yield the highest validation BLEU. For validation and testing, we use a beam size 5 and a length penalty 1.0. Other training and inference details follow the Fairseq implementation.
|
| 328 |
+
|
| 329 |
+
# C.2 RICH RESOURCE TRANSLATION
|
| 330 |
+
|
| 331 |
+
Strength of the consistency regularizer is set as $\alpha = 2 . 0$ . We use Adam (Kingma & Ba, 2015) as the optimizer with $\beta _ { 1 } = 0 . 9$ , $\beta _ { 2 } = 0 . 9 8$ , and the learning rate is chosen as 0.001. For inference, we use a beam size 4 and a length penalty 0.6 for En-De; we use a beam size 10 and a length penalty 1.0 for En-Fr. Other post-processing steps follow Ott et al. (2018). We report both the BLEU score and the sacreBLEU score (Post, 2018), where the latter is a safer token-agnostic version of BLEU.
|
| 332 |
+
|
| 333 |
+
# C.3 MULTILINGUAL TRANSLATION
|
| 334 |
+
|
| 335 |
+
For training, we set the batch size to be equivalent to 1.6 million tokens, e.g., 4096 tokens per GPU with 24 GPUs, and we accumulate gradients for 16 steps. We use RAdam (Liu et al., 2020a) as the optimizer with parameters $\beta _ { 1 } = 0 . 9$ and $\beta _ { 2 } = 0 . 9 8$ . The learning rate is set to be 0.05. Also, we set the dropout ratio to be 0.1, and we use label smoothed cross entropy (Szegedy et al., 2016) with a smoothing factor 0.1. The regularization strength is set to be $\alpha = 4 . 0$ . For inference, we use a beam size 5 and a length penalty 1.0.
|
| 336 |
+
|
| 337 |
+
# D ADDITIONAL EXPERIMENTS
|
| 338 |
+
|
| 339 |
+
We further test behavior of THOR and the Switch Transformer when we increase the number of experts. To avoid overfitting, we use a small model (Transformer-IWSLT) on the WMT’16 En-De translation dataset. In this experiment, the Transformer model has $4 8 M$ parameters, models with 2, 16, and 64 experts have $5 5 M$ , $1 4 3 M$ , and $4 5 6 M$ parameters, respectively.
|
| 340 |
+
|
| 341 |
+

|
| 342 |
+
Figure 14: Effects of the number of experts on WMT’16 En-De translation. Left: training perplexity (lower the better) with respect to wall-time (measured in GPU hours); Right: validation BLEU (higher the better) after training for 180 GPU hours with respect to the number of experts, where the size of Transformer does not change.
|
| 343 |
+
|
| 344 |
+
Figure 14 demonstrates the results. In Figure 14 (left), notice that the Switch Transformer trains faster than the vanilla Transformer, and this scaling property is more significant when we increase the number of experts.
|
| 345 |
+
|
| 346 |
+
From Figure 14 (right), we see that with 2 experts, the Switch Transformer behaves slightly worse the vanilla Transformer in terms of validation BLEU. However, when we increase the number of experts, performance of the Switch Transformer continues to improve and outperforms the vanilla Transformer with the same number of FLOPs. This indicates that in order for a sparsely activated model to outperform a densely activated one, we need to scale the former to contain much more parameters than the latter. Our observations are consistent with existing literature (Lepikhin et al., 2020; Fedus et al., 2021). For example, in Fedus et al. 2021, the sparsely activated Switch-base outperforms the densely activated T5-base using the same number of FLOPs. However, the former is more than 30 times larger (7.5 billion vs. 0.22 billion parameters).
|
| 347 |
+
|
| 348 |
+
Our method is more parameter efficient than the conventional methods. From Figure 14 (right), we see that THOR significantly outperforms the vanilla Transformer and the Switch Transformer even with only 2 experts. Moreover, when we increase the number of experts, performance of THOR also improves.
|
| 349 |
+
|
| 350 |
+
We also compare inference speed of Transformer, Switch Transformer, and THOR in Table 8. Note that for THOR , we use the Dispatch(s) method in Table 5. Note that the inference speed of Switch Transformer and THOR is slower than the vanilla Transformer because of the computation and communication overhead induced by input routing. Such an overhead is more noticeable when the number of experts is large. We remark that in Fedus et al. 2021, the speed of Switch-base is about half of T5-base (780 vs. 1600 samples per second).
|
| 351 |
+
|
| 352 |
+
Table 8: Inference speed (tokens/second).
|
| 353 |
+
|
| 354 |
+
<table><tr><td></td><td>Transformer</td><td colspan="3">Switch</td><td colspan="3">THOR</td></tr><tr><td># experts</td><td></td><td>2</td><td>16</td><td>64</td><td>2</td><td>16</td><td>64</td></tr><tr><td>Speed</td><td>15.2k</td><td>15.0k</td><td>10.4k</td><td>7.4k</td><td>15.1k</td><td>10.6k</td><td>7.5k</td></tr></table>
|
md/dev/Bl8CQrx2Up4/Bl8CQrx2Up4.md
ADDED
|
@@ -0,0 +1,393 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# COSFORMER : RETHINKING SOFTMAX IN ATTENTION
|
| 2 |
+
|
| 3 |
+
1Zhen Qin† $^ { 1 , 3 }$ Weixuan Sun† 1,4Hui Deng† 3Dongxu Li 1Yunshen Wei 1Baohong Lv
|
| 4 |
+
1Junjie Yan 2,5Lingpeng Kong 1,2Yiran Zhong∗
|
| 5 |
+
1SenseTime Research 2Shanghai AI Laboratory 3Australian National University
|
| 6 |
+
4Northwestern Polytechnical University 5The University of Hong Kong
|
| 7 |
+
{lastnamefirstname}@sensetime.com,lpk@cs.hku.hk
|
| 8 |
+
|
| 9 |
+
# ABSTRACT
|
| 10 |
+
|
| 11 |
+
Transformer has shown great successes in natural language processing, computer vision, and audio processing. As one of its core components, the softmax attention helps to capture long-range dependencies yet prohibits its scale-up due to the quadratic space and time complexity to the sequence length. Kernel methods are often adopted to reduce the complexity by approximating the softmax operator. Nevertheless, due to the approximation errors, their performances vary in different tasks/corpus and suffer crucial performance drops when compared with the vanilla softmax attention. In this paper, we propose a linear transformer called COSFORMER that can achieve comparable or better accuracy to the vanilla transformer in both casual and cross attentions. COSFORMER is based on two key properties of softmax attention: i). non-negativeness of the attention matrix; ii). a non-linear re-weighting scheme that can concentrate the distribution of the attention matrix. As its linear substitute, COSFORMER fulfills these properties with a linear operator and a cosine-based distance re-weighting mechanism. Extensive experiments on language modeling and text understanding tasks demonstrate the effectiveness of our method. We further examine our method on long sequences and achieve state-of-the-art performance on the Long-Range Arena benchmark. The source code is available at COSFORMER .
|
| 12 |
+
|
| 13 |
+
# 1 INTRODUCTION
|
| 14 |
+
|
| 15 |
+

|
| 16 |
+
Figure 1: Performance $y$ axis), speed $x$ axis), and memory footprint (circle sizes) of efficient transformers on the Long-Range Arena benchmark. The proposed COSFORMER achieves an all-around supremacy over competing methods in the top left quadrant.
|
| 17 |
+
|
| 18 |
+
With years of development, the transformer model (Vaswani et al., 2017) and its variants (Zaheer et al., 2020; Wang et al., 2020; Tay et al., 2020a) have been successfully adapted to three most popular artificial intelligence (AI) fields: i.e., natural language processing (Devlin et al., 2019; Liu et al., 2019), computer vision (Dosovitskiy et al., 2020; Carion et al., 2020; Liu et al., 2021) and audio processing (Schneider et al., 2019; Baevski et al., 2020). Compared with conventional recurrent (Hochreiter & Schmidhuber, 1997) and convolutional architectures (He et al., 2016), transformer-based architectures are generally more scalable to data volumes (Brown et al., 2020) and stronger in capturing global information with less inductive bias, thus excelling on many tasks.
|
| 19 |
+
|
| 20 |
+
Dot-product attention with softmax normalization is the cornerstone of the transformer to capture long-range dependencies. However, its quadratic space and time complexity with regard to the length of the sequence make its computational overhead prohibitive, especially for long inputs. To address this issue, numerous methods are proposed recently, such as the sparse attention matrix (Zaheer et al., 2020; Beltagy et al., 2020; Tay et al., 2020a; Kitaev et al., 2019; Child et al., 2019),lowrank representations (Wang et al., 2020) or kernel-based methods (Peng et al., 2020; Choromanski et al., 2020; Katharopoulos et al., 2020), among many others. These methods achieve reduced computational complexity with comparable performances when compared with the vanilla attention architecture on several selected tasks or corpus.
|
| 21 |
+
|
| 22 |
+
However, the improved efficiency is usually achieved via introducing additional yet often impractical assumptions on the attention matrix (Wang et al., 2020) or with valid approximation of softmax operation only within constrained theoretical bounds (Choromanski et al., 2020; Peng et al., 2020) Therefore, when their assumptions are unsatisfied or when approximation errors get accumulated, these methods may not always be advantageous over the vanilla architecture (Narang et al., 2021). Consequently, performance deficiencies in a broad application spectrum are often observed in these transformer variants, especially those with linear complexity. For example, the Performer (Choromanski et al., 2020), RFA (Peng et al., 2020) and Reformer (Kitaev et al., 2019) show less satisfactory performance on the GLUE benchmark (Wang et al., 2018) when compared with the vanilla architecture as suggested in our preliminary experiments (Tab. 2). Furthermore, many of these aforementioned methods are not applicable to casual attentions, which are critical for auto-regressive training. For example, techniques proposed in Linformer (Wang et al., 2020) and BigBird (Zaheer et al., 2020) are specific to cross attentions.
|
| 23 |
+
|
| 24 |
+
Since the softmax operator appears to be the main hurdle while efficient yet accurate approximation to softmax is difficult to achieve, one question naturally arises: “Can we replace the softmax operator with a linear function instead, while maintaining its key properties?”. By digging into the softmax attention, we find two key properties that affect its empirical performance: (i) elements in the attention matrix are non-negative (Tsai et al., 2019; Katharopoulos et al., 2020); (ii) the non-linear re-weighting scheme acts as a stabilizer for the attention weights (Titsias, 2016; Gao & Pavel, 2017; Jang et al., 2016). These findings reveal some new insights of the current approaches. For example, the linear transformer (Katharopoulos et al., 2020) achieves property (i) using an exponential linear unit (Clevert et al., 2016) activation function. However, due to lack of the re-weighting scheme, it underperforms other efficient transformer variants on the Long-Range Arena benchmark as shown in Figure 1 as well as the language modeling task (Table 2) based on our controlled experiments.
|
| 25 |
+
|
| 26 |
+
In this paper, we propose a new variant of linear transformer called COSFORMER that satisfies both of the above properties. Specifically, we enforce the non-negative property by passing the features to a ReLU (Agarap, 2018) activation function before computing the similarity scores. In this way, we encourage the model to avoid aggregating negatively-correlated contextual information. Further, we adopt a cos re-weighting scheme to stabilize the attention weights. This helps the model to amplify local correlations, which usually contain more relevant information for natural language tasks. Thanks to the Ptolemy’s theorem, our attention can be exactly decomposed into a linear form. We perform extensive experiments on both autoregressive language models and bidirectional models on five public benchmarks, including WikiText-103 (Merity et al., 2017), GLUE (Wang et al., 2018), IMDB (Maas et al., 2011), AMAZON (Ni et al., 2019) and Long-Range Arena benchmark (Tay et al., 2020b). Our model shows much better inference speed and smaller memory footprint, while achieving on par performance with the vanilla transformer. It is noteworthy that our method ranks $1 ^ { \mathrm { s t } }$ on the Long-Range Arena benchmark, showing favorable performance than other competitors, which well demonstrates its strong capacity in modeling long sequence inputs.
|
| 27 |
+
|
| 28 |
+
# 2 OUR METHOD
|
| 29 |
+
|
| 30 |
+
In this section, we provide technique details of our linear transformer called COSFORMER . The key insight of the COSFORMER is to replace the non-decomposable non-linear softmax operation by a linear operation with decomposable non-linear re-weighting mechanism. Our model is applicable
|
| 31 |
+
|
| 32 |
+
to both casual and cross attentions with a linear time and space complexity with regard to the input sequence length, thus exhibiting strong capacity in modeling long-range dependencies.
|
| 33 |
+
|
| 34 |
+
# 2.1 THE GENERAL FORM OF TRANSFORMER
|
| 35 |
+
|
| 36 |
+
Given an input sequence $x$ with length of $N$ , we first represent it in the embedding space $\boldsymbol { x } \in \mathbb { R } ^ { N \times d }$ with feature dimension of $d$ . A transformer block $\mathcal { T } : \dot { \mathbb { R } } ^ { N \times d } \mathbb { R } ^ { N \times d }$ with input $x$ is defined as:
|
| 37 |
+
|
| 38 |
+
$$
|
| 39 |
+
\mathcal { T } ( \boldsymbol { x } ) = \mathcal { F } ( \boldsymbol { A } ( \boldsymbol { x } ) + \boldsymbol { x } ) ,
|
| 40 |
+
$$
|
| 41 |
+
|
| 42 |
+
where $\mathcal { F }$ is a feedforward network that contains a residual connection; $\mathcal { A }$ is the self-attention function that computes the attention matrix $A$ , which has quadratic space and time complexity with respect to $N$ , thus becoming the computation bottleneck of $\tau$ on long inputs.
|
| 43 |
+
|
| 44 |
+
There are three key components in $\mathcal { A }$ , namely, query $( Q )$ , key $( K )$ , value $( V )$ computed through three learnable linear matrices WQ, WK , WV : $Q = x W _ { Q } , K = x W _ { K } , V = x W _ { V }$ . We use $M _ { i }$ to represent the i-th row of a matrix $M$ , then the output $\mathcal { O } \in \mathbb { R } ^ { N \times d }$ of $\mathcal { A } ( x )$ can be computed as:
|
| 45 |
+
|
| 46 |
+
$$
|
| 47 |
+
\boldsymbol { \mathcal { O } } = \boldsymbol { A } ( \boldsymbol { x } ) = \left[ \boldsymbol { \mathcal { O } } _ { 1 } , \ldots , \boldsymbol { \mathcal { O } } _ { N } \right] ^ { T } , \quad \boldsymbol { \mathcal { O } } _ { i } = \sum _ { j } \frac { \boldsymbol { \mathcal { S } } ( \boldsymbol { Q } _ { i } , K _ { j } ) } { \sum _ { j } \boldsymbol { \mathcal { S } } ( \boldsymbol { Q } _ { i } , K _ { j } ) } V _ { j } ,
|
| 48 |
+
$$
|
| 49 |
+
|
| 50 |
+
where $\boldsymbol { \mathcal { S } } ( \cdot )$ measures the similarity between queries. If $\begin{array} { r } { { \cal S } ( Q , K ) = \exp ( Q K ^ { T } ) } \end{array}$ , the Eq. 2 becomes the dot-product attention with softmax normalization. In this case, the space and time complexity to compute one row of the output $\mathcal { O } _ { i }$ is $O ( N )$ . Therefore, the total space and time complexity for computing $\mathcal { O }$ grows quadratically with respect to the input length.
|
| 51 |
+
|
| 52 |
+
# 2.2 LINEARIZATION OF SELF-ATTENTION
|
| 53 |
+
|
| 54 |
+
According to Eq. 2, we can select any similarity functions to compute the attention matrix. In order to maintain a linear computation budget, one solution is to adopt a decomposable similarity function such that:
|
| 55 |
+
|
| 56 |
+
$$
|
| 57 |
+
\begin{array} { r } { S ( Q _ { i } , K _ { j } ) = \phi ( Q _ { i } ) \phi ( K _ { j } ) ^ { T } , } \end{array}
|
| 58 |
+
$$
|
| 59 |
+
|
| 60 |
+
where $\phi$ is a kernel function that maps the queries and keys to their hidden representations. Then one can rewrite Eq. 2 in the form of kernel functions as:
|
| 61 |
+
|
| 62 |
+
$$
|
| 63 |
+
\begin{array} { r } { O _ { i } = \frac { \sum _ { j = 1 } ^ { N } ( \phi ( Q _ { i } ) \phi ( K _ { j } ) ^ { T } ) V _ { j } } { \sum _ { j = 1 } ^ { N } ( \phi ( Q _ { i } ) \phi ( K _ { j } ) ^ { T } ) } . , } \end{array}
|
| 64 |
+
$$
|
| 65 |
+
|
| 66 |
+
After that, attention operation in linear complexity is achieved via the matrix product property:
|
| 67 |
+
|
| 68 |
+
$$
|
| 69 |
+
( \phi ( Q ) \phi ( K ) ^ { T } ) V = \phi ( Q ) ( \phi ( K ) ^ { T } V ) .
|
| 70 |
+
$$
|
| 71 |
+
|
| 72 |
+
In this form (Eq. 5), instead of explicitly computing the attention matrix $A = Q K ^ { T } \in \mathbb { R } ^ { N \times N }$ , we calculate the $\phi ( \mathbf { \bar { K } } ) ^ { T } V \in \mathbb { R } ^ { d \times d }$ first, and then multiplying $\phi ( Q ) \in \mathbb { R } ^ { N \times d }$ . By using this trick, we only incurs a computation complexity of $O ( N d ^ { 2 } )$ . Note that in typical natural language tasks, the feature dimension of one head $d$ is always much smaller than the input sequence length $N \left( d \ll N \right)$ , so we can safely omit $d$ and achieve computation complexity of $O ( N )$ , as illustrated in Figure 2.
|
| 73 |
+
|
| 74 |
+
Previous Solutions As aforementioned, the key to the linear attentions is to find a decomposable similarity function $\boldsymbol { \mathcal { S } } ( \cdot )$ that generalizes well to different tasks. Most existing linear transformers are trying to find an unbiased estimation of the softmax attention. For example, RFA (Peng et al., 2020) approximates the softmax operation with random feature maps using theorem of random fourier features (Rahimi & Recht, 2008) and the Performer (Choromanski et al., 2020) utilizes positive random features to approximate it. However, we empirically find that these methods are sensitive to the selection of sampling rate and becomes unstable if the sampling rate gets too high. Also, to accommodate recency bias, gating mechanisms are employed to better exploit more recent context.
|
| 75 |
+
|
| 76 |
+
Another group of works attempt to directly replace the softmax with a linear operation. For example, the linear transformer (Katharopoulos et al., 2020) model replaces the softmax similarity function with a pure dot product $\boldsymbol { \mathcal { S } } = \dot { Q } \boldsymbol { K } ^ { T }$ , and use a non-linear activation function $\phi ( \cdot ) = \mathrm { e l u \bar { ( \cdot ) } + 1 }$ to model the pairwise relation between features. However, our controlled experiments show that their solution does not necessarily generalize well on many downstream tasks (Tab. 2) or the Long-Range Arena benchmark (Tab. 4). In this paper, we propose a new replacement of softmax that not only achieves comparable or better performance than the softmax attention in a wide range of tasks, but also enjoys linear space and time complexity.
|
| 77 |
+
|
| 78 |
+

|
| 79 |
+
Figure 2: Illustration of the computations for vanilla self attention (left) and linearized attention (right). The input length is $N$ and feature dimension is $d$ , with $d \ll N$ . Tensors in the same box are associated for computation. The linearized formulation allows $O ( N )$ time and space complexity.
|
| 80 |
+
|
| 81 |
+
# 2.3 ANALYSIS OF SOFTMAX ATTENTION
|
| 82 |
+
|
| 83 |
+
In the vanilla transformer architecture, when $\begin{array} { r } { { \cal S } ( Q , K ) = \exp ( Q K ^ { T } ) . } \end{array}$ , the softmax operation is applied to obtain row-wise normalization on the attention matrix $\overset { \cdot } { A } \in \mathbb { R } ^ { N \times N }$ as shown in the Eq. 2. In other words, we normalize the relations of each element in the input sequence to all other elements in order to obtain a weighted aggregation of contextual information. However, apart from the good empirical performance of softmax attention, what are the crucial and necessary characteristics of it remain only loosely determined in the original transformer paper and follow-up works.
|
| 84 |
+
|
| 85 |
+
In this work, we empirically identify two key properties of the softmax operation that may play important roles for its performance: 1) it ensures all values in the attention matrix $A$ to be non-negative; 2) it provides a non-linear reweighting mechanism to concentrates the distribution of attention connections and stabilizes the training(Titsias, 2016; Gao & Pavel, 2017; Jang et al., 2016).
|
| 86 |
+
|
| 87 |
+
To validate these assumptions, we design the following preliminary studies as shown in Table 1. First, to validate the importance of nonnegativity, we compare three instantiations of
|
| 88 |
+
|
| 89 |
+
Table 1: Analysis of the softmax properties. All attention variants are implemented in the RoBERTa (Liu et al., 2019) architecture and are pre-trained on the WikiText-103 (Merity et al., 2017) dataset. The Loss represents the validation loss. We then fine-tune these variants on each downstream datasets and show the accuracy (the higher the better).
|
| 90 |
+
|
| 91 |
+
<table><tr><td></td><td>Loss</td><td>QQP</td><td>SST-2</td><td>MNLI</td></tr><tr><td>1</td><td>2.343</td><td>84.23</td><td>76.26</td><td>58.27</td></tr><tr><td>ΦLeakyReLU</td><td>2.246</td><td>84.46</td><td>78.21</td><td>74.26</td></tr><tr><td>ReLU</td><td>1.993</td><td>88.86</td><td>89.90</td><td>77.86</td></tr><tr><td>softmax</td><td>1.915</td><td>88.41</td><td>92.31</td><td>79.15</td></tr></table>
|
| 92 |
+
|
| 93 |
+
the function $\phi$ in equation 3: an identify mapping $\phi _ { \mathbf { I } } = \mathbf { I }$ that does not preserve the non-negativity, and the other variant $\phi _ { \mathrm { R e L U ( \cdot ) } } = \mathrm { R e L U ( \cdot ) }$ that retains only positive input values while replacing negative values to zeros. We also add the $\phi _ { \mathrm { L e a k y R e L U ( \cdot ) } } = \mathrm { L e a k y R e L U ( \cdot ) }$ variant as it does not have the non-negativity as well but have the same non-linearly as the ReLU one. Second, to demonstrate the effect of non-linear re-weighting, we compare the models using only $\phi _ { \mathrm { R e L U ( \cdot ) } }$ without any re-weighting and those with softmax operations. From Table 1, the superior results of $\phi _ { \mathrm { R e L U } }$ over $\phi _ { \mathbf { I } }$ and $\phi _ { \mathrm { L e a k y R e L U } }$ demonstrate the benefit of retaining non-negative values. Our conjecture is that by retaining only positive values in the similarity matrices, the model ignores features with negative correlations, thus effectively avoiding aggregating irrelevant contextual information. By comparing the results of $\phi _ { \mathrm { R e L U } }$ with the softmax, we observe that models with softmax re-weighting converge faster and generalize better to downstream tasks. This might be explained as softmax normalization amplifies the correlated pairs, which might be useful to identify useful patterns.
|
| 94 |
+
|
| 95 |
+
# 2.4 COSFORMER
|
| 96 |
+
|
| 97 |
+
Based on the observations above, we propose our model COSFORMER , which discards entirely the softmax normalization while still features the non-negativity and re-weighting mechanism. Our COSFORMER consists two main components: a linear projection kernel $\phi _ { \mathrm { l i n e a r } }$ and a cos-Based Reweighting mechanism. Below we describe details of each components:
|
| 98 |
+
|
| 99 |
+
Linear projection kernel $\phi _ { \mathrm { l i n e a r } }$ Recall the general form of the attention in Eq. 2, let us define a linear similarity as:
|
| 100 |
+
|
| 101 |
+
$$
|
| 102 |
+
\begin{array} { r } { S ( Q , K ) = \operatorname { s } ( \phi _ { \mathrm { l i n e a r } } ( Q ) , \phi _ { \mathrm { l i n e a r } } ( K ) ) = \operatorname { s } ( Q ^ { ' } , K ^ { ' } ) } \end{array}
|
| 103 |
+
$$
|
| 104 |
+
|
| 105 |
+
where $\phi _ { \mathrm { l i n e a r } }$ is the transformation function that map queries $Q$ and keys $K$ to our desired representations $Q ^ { ' }$ and $K ^ { ' }$ , and s is a function that can be linearly decomposed to measure the similarity between $Q ^ { ' }$ and $K ^ { ' }$ . Specifically, in order to ensure a full positive attention matrix $A$ and avoid
|
| 106 |
+
|
| 107 |
+

|
| 108 |
+
Figure 3: (1): Attention matrix of vanilla transformer.(2):Attention matrix of COSFORMER .(3): Attention matrix of COSFORMER without re-weighting. (4): Visualization of the cos-based distance matrix. After reweighting, we can see a smoother attention distribution along the diagonal region of attention matrix, exhibiting a similar pattern to the vanilla transformer, which assists to stabilize the training.
|
| 109 |
+
|
| 110 |
+
aggregating negatively-correlated information, we adopt $\mathrm { R e L U } ( \cdot )$ as the transformation functions and therefore effectively eliminate negative values:
|
| 111 |
+
|
| 112 |
+
$$
|
| 113 |
+
\phi _ { \mathrm { l i n e a r } } ( x ) = \mathrm { R e L U } ( x )
|
| 114 |
+
$$
|
| 115 |
+
|
| 116 |
+
As $Q ^ { ' }$ and $K ^ { ' }$ contain only non-negative values, we directly take their dot-product $s ( x , y ) \ =$ $\boldsymbol { x } \boldsymbol { y } ^ { T } , \boldsymbol { x } , \boldsymbol { y } \in \mathbb { R } ^ { 1 \times d }$ followed by a row-wise normalization to compute attention matrices:
|
| 117 |
+
|
| 118 |
+
$$
|
| 119 |
+
\begin{array} { r } { \mathcal { O } _ { i } = \frac { \sum _ { j = 1 } ^ { N } f ( \phi _ { \mathrm { l i n e a r } } ( Q _ { i } ) , \phi _ { \mathrm { l i n e a r } } ( K _ { j } ) ) V _ { j } } { \sum _ { j = 1 } ^ { N } f ( \phi _ { \mathrm { l i n e a r } } ( Q _ { i } ) , \phi _ { \mathrm { l i n e a r } } ( K _ { j } ) ) } = \frac { \sum _ { j = 1 } ^ { N } ( \mathrm { R e L U } ( Q _ { i } ) \mathrm { R e L U } ( K _ { j } ) ^ { T } ) V _ { j } } { \sum _ { j = 1 } ^ { N } ( \mathrm { R e L U } ( Q _ { i } ) \mathrm { R e L U } ( K _ { j } ) ^ { T } ) } } \end{array}
|
| 120 |
+
$$
|
| 121 |
+
|
| 122 |
+
Based on Eq. 4, we rearrange the order of dot-product and obtain the formulation of the proposed attention in linear complexity as:
|
| 123 |
+
|
| 124 |
+
$$
|
| 125 |
+
\begin{array} { r } { \mathcal { O } _ { i } = \frac { \mathrm { R e L U } ( Q _ { i } ) \sum _ { j = 1 } ^ { N } \mathrm { R e L U } ( K _ { j } ) ^ { T } V _ { j } } { \mathrm { R e L U } ( Q _ { i } ) \sum _ { j = 1 } ^ { N } \mathrm { R e L U } ( K _ { j } ) ^ { T } } } \end{array}
|
| 126 |
+
$$
|
| 127 |
+
|
| 128 |
+
cos-Based Re-weighting Mechanism The non-linear re-weighting mechanism introduced by the softmax attention can concentrate the distribution of the attention weights and therefore stabilize the training process (Titsias, 2016; Gao & Pavel, 2017; Jang et al., 2016). We also empirically find that it can punish far-away connections and enforce locality in some cases. In fact, such locality bias, i.e., a large portion of contextual dependencies are from neighboring tokens, is commonly observed on downstream NLP tasks (Clark et al., 2019; Kovaleva et al., 2019), as shown in Figure 3 (1).
|
| 129 |
+
|
| 130 |
+
Based on the assumption above, what we need to fulfill the second property of softmax may be a decomposable re-weighting mechanism that can introduce recency bias to the attention matrix. Here, we propose a cos-based re-weighting mechanism as it perfectly fit our purpose: 1). the Ptolemy’s theorem ensures the cos weights can be decomposed into two summations; 2). as shown in Figure 3 (4), the cos will put more weights on the neighbouring tokens and therefore enforces locality. Also, by comparing the attention matrices in Figure 3 (2) and (3), the COSFORMER enforces more locality than the one without the re-weighting mechanism.
|
| 131 |
+
|
| 132 |
+
Specifically, by combining with Eq 6, the model with cosine re-weighting is defined as:
|
| 133 |
+
|
| 134 |
+
$$
|
| 135 |
+
\begin{array} { r } { s ( Q _ { i } ^ { ' } , K _ { j } ^ { ' } ) = Q _ { i } ^ { ' } K _ { j } ^ { ' T } \cos \left( \frac { \pi } { 2 } \times \frac { i - j } { M } \right) } \end{array}
|
| 136 |
+
$$
|
| 137 |
+
|
| 138 |
+
By leveraging the Ptolemy’s theorem, we decompose this formulation as:
|
| 139 |
+
|
| 140 |
+
$$
|
| 141 |
+
\begin{array} { r l } & { Q _ { i } ^ { ' } K _ { j } ^ { ' T } \cos \left( \frac { \pi } { 2 } \times \frac { i - j } { M } \right) = Q _ { i } ^ { ' } K _ { j } ^ { ' T } \left( \cos \left( \frac { \pi i } { 2 M } \right) \cos \left( \frac { \pi j } { 2 M } \right) + \sin \left( \frac { \pi i } { 2 M } \right) \sin \left( \frac { \pi j } { 2 M } \right) \right) } \\ & { \phantom { = } = \left( Q _ { i } ^ { ' } \cos \left( \frac { \pi i } { 2 M } \right) \right) \left( K _ { j } ^ { ' } \cos \left( \frac { \pi j } { 2 M } \right) \right) ^ { T } + \left( Q _ { i } ^ { ' } \sin \left( \frac { \pi i } { 2 M } \right) \right) \left( K _ { j } ^ { ' } \sin \left( \frac { \pi j } { 2 M } \right) \right) ^ { T } } \end{array}
|
| 142 |
+
$$
|
| 143 |
+
|
| 144 |
+
where $i , j = 1 , . . . , N , M \geq N$ , and $Q ^ { ' } = \mathrm { R e L U } ( Q ) , K ^ { ' } = \mathrm { R e L U } ( K )$ . Let $\begin{array} { r } { Q _ { i } ^ { \mathrm { c o s } } = Q _ { i } ^ { ' } \mathrm { c o s } \left( \frac { \pi i } { 2 M } \right) } \end{array}$ $\begin{array} { r } { Q _ { i } ^ { \mathrm { s i n } } = Q _ { i } ^ { ' } \sin { \left( \frac { \pi i } { 2 M } \right) } } \end{array}$ , $\begin{array} { r } { K _ { j } ^ { \mathrm { c o s } } = K _ { j } ^ { ' } \cos \left( \frac { \pi j } { 2 M } \right) } \end{array}$ , $\begin{array} { r } { K _ { j } ^ { \mathrm { s i n } } = K _ { j } ^ { ' } \sin \left( \frac { \pi j } { 2 M } \right) } \end{array}$ , the output of the proposed attention module can be expressed as:
|
| 145 |
+
|
| 146 |
+
$$
|
| 147 |
+
\begin{array} { r } { { \cal O } _ { i } = \frac { \sum _ { j = 1 } ^ { N } f ( Q _ { i } ^ { ' } , K _ { j } ^ { ' } ) V _ { j } } { \sum _ { j = 1 } ^ { N } f ( Q _ { i } ^ { ' } , K _ { j } ^ { ' } ) } = \frac { \sum _ { j = 1 } ^ { N } Q _ { i } ^ { \mathrm { c o s } } \left( \left( K _ { j } ^ { \mathrm { c o s } } \right) ^ { T } V _ { j } \right) + \sum _ { j = 1 } ^ { N } Q _ { i } ^ { \mathrm { s i n } } \left( \left( K _ { j } ^ { \mathrm { s i n } } \right) ^ { T } V _ { j } \right) } { \sum _ { j = 1 } ^ { N } Q _ { i } ^ { \mathrm { c o s } } \left( K _ { j } ^ { \mathrm { c o s } } \right) ^ { T } + \sum _ { j = 1 } ^ { N } Q _ { i } ^ { \mathrm { s i n } } \left( K _ { j } ^ { \mathrm { s i n } } \right) ^ { T } } , } \end{array}
|
| 148 |
+
$$
|
| 149 |
+
|
| 150 |
+

|
| 151 |
+
Figure 4: Training loss (left) and validation loss (right) of the bidirectional language modeling pre-train. In both training and validation, the proposed COSFORMER has a faster converge speed than vanilla transformer.
|
| 152 |
+
|
| 153 |
+
where $O _ { i }$ is the output at the $i ^ { t h }$ position of the sequence from the attention module. Detailed derivation are included in the Appendix. Without losing the generality, our method achieves a linear complexity as:
|
| 154 |
+
|
| 155 |
+
$$
|
| 156 |
+
\mathcal { O } = \mathcal { S } ( Q , K ) V = ( Q ^ { \mathrm { c o s } } K ^ { \mathrm { c o s } } + Q ^ { \mathrm { s i n } } K ^ { \mathrm { s i n } } ) V = Q ^ { \mathrm { c o s } } ( K ^ { \mathrm { c o s } } V ) + Q ^ { \mathrm { s i n } } ( K ^ { \mathrm { s i n } } V )
|
| 157 |
+
$$
|
| 158 |
+
|
| 159 |
+
Relation to positional encoding. COSFORMER can be seen as a new way of introducing the relative positional bias to the efficient transformer. Compared with the Rotary Position Embedding (Su et al., 2021), they use a more complex position embedding strategy and did not enforce the nonnegativity to the similarity scores as ours. Also, since they only change the position embedding on the numerator while keeping the denominator unchanged, the summation of their attention scores is not equal to 1. For Stochastic Positional Encoding (Liutkus et al., 2021), they use a sampling strategy to approximate the softmax, and introduce relative positional encoding to linear transformers.
|
| 160 |
+
|
| 161 |
+
# 3 EXPERIMENTS
|
| 162 |
+
|
| 163 |
+
In this section, we experimentally validate the effectiveness of the proposed method in multiple settings. The purposes of the experiments are three-fold. First, we validate the capacity of COSFORMER in language modeling through autoregressive (Sec. 3.1) and bidirectional (Sec. 3.2) setups using WikiText-103 (Merity et al., 2017). In this way, we validate the effectiveness of the proposed linear attention module in both causal and non-causal cases. Second, we investigate the generalization ability of COSFORMER on downstream tasks by comparisons with other existing transformer variants. This is achieved by performing comparative finetuning experiments on five datasets, including GLUE (QQP, SST-2, MNLI) (Wang et al., 2018), IMDB (Maas et al., 2011) and AMAZON (Ni et al., 2019) (Sec. 3.3). We further compare COSFORMER with other transformer variants on the long-range-arena benchmark (Tay et al., 2020b) to understand its ability in modeling long-range dependencies (Sec. 3.4) and show comparative analysis into model efficiency (Sec. 3.5). Third, we conduct ablation studies to understand each component in COSFORMER (Sec. 3.6).
|
| 164 |
+
|
| 165 |
+
# 3.1 AUTOREGRESSIVE LANGUAGE MODELING
|
| 166 |
+
|
| 167 |
+
In autoregressive or left-to-right language modeling, we estimate the probability distribution of a token given its previous tokens. We use (Baevski & Auli, 2018) as our baseline model. Specifically, we adopt their large model which has 16 cascaded layers with a projected dimensions of 1024, and replace the self-attention module with our proposed linear attention module. We train our model on 8 Nvidia Tesla A100 GPUs with a sequence length of 512 for 150K updates on the WikiText-103 (Merity et al., 2017) and report perplexity on the validation and test splits in Table 2.
|
| 168 |
+
|
| 169 |
+
We observe that although the baseline model is a powerful standard transformer which requires quadratic computation complexity, COSFORMER outperforms it with a clear margin in linear computation complexity. Besides, we achieve comparable perplexity to other methods on the validation set, and significantly outperform all competing methods on the test set by a clear gap, which further demonstrates the effectiveness of COSFORMER .
|
| 170 |
+
|
| 171 |
+
Table 2: Perplexity (lower is better) results of language modeling pre-training task on validation set and test set of the WikiText-103 (Merity et al., 2017) dataset.
|
| 172 |
+
|
| 173 |
+
<table><tr><td></td><td>ppl(val)↓</td><td>ppl(test)↓</td></tr><tr><td>VanillaTransformer</td><td>24.5</td><td>26.2</td></tr><tr><td>LinearTransformer</td><td>28.7</td><td>30.2</td></tr><tr><td>RFA-Gaussian</td><td>25.8</td><td>27.5</td></tr><tr><td>RFA-across</td><td>26.4</td><td>28.1</td></tr><tr><td>RFA-Gate-across</td><td>24.8</td><td>26.3</td></tr><tr><td>RFA-Gate-Gaussian</td><td>23.2</td><td>25.0</td></tr><tr><td>COSFORMER</td><td>23.5</td><td>23.1</td></tr></table>
|
| 174 |
+
|
| 175 |
+
Table 3: Results on fine-tuned downstream tasks based on pre-trained bidirectional model. Best result is in boldface and second best is underlined. The proposed COSFORMER achieves superb performances over competing efficient transformers and is approaching vanilla transformer.
|
| 176 |
+
|
| 177 |
+
<table><tr><td></td><td>QQP个</td><td>SST-2个</td><td>MNLI↑</td><td>IMDB ↑</td><td>AMAZON↑</td><td>Avg↑</td></tr><tr><td>Vanilla Transformer (Liu et al.,2019)</td><td>88.41</td><td>92.31</td><td>79.15</td><td>92.86</td><td>75.79</td><td>85.70</td></tr><tr><td>Performer (Choromanski et al.,2020)</td><td>69.92</td><td>50.91</td><td>35.37</td><td>60.36</td><td>64.84</td><td>56.28</td></tr><tr><td>Reformer (Kitaev et al.,2019)</td><td>63.18</td><td>50.92</td><td>35.47</td><td>50.01</td><td>64.28</td><td>52.77</td></tr><tr><td>Linear Trans. (Katharopoulos et al.,2020)</td><td>74.85</td><td>84.63</td><td>66.56</td><td>91.48</td><td>72.50</td><td>78.00</td></tr><tr><td>Longformer (Beltagy et al.,2020)</td><td>85.51</td><td>88.65</td><td>77.22</td><td>91.14</td><td>73.34</td><td>83.17</td></tr><tr><td>RFA (Peng et al.,2020)</td><td>75.28</td><td>76.49</td><td>57.6</td><td>78.98</td><td>68.15</td><td>71.30</td></tr><tr><td>COSFORMER</td><td>89.26</td><td>91.05</td><td>76.70</td><td>92.95</td><td>76.30</td><td>85.25</td></tr></table>
|
| 178 |
+
|
| 179 |
+
# 3.2 BIDIRECTIONAL LANGUAGE MODEL
|
| 180 |
+
|
| 181 |
+
For bidirectional language modeling, we adopt RoBERTa (Liu et al., 2019) as the baseline model. Similarly, we replace the self-attention module in the RoBERTa by the proposed linear attention module, and keep other structures unchanged. We train this bidirectional task on 2 Nvidia Tesla A100 GPUs for 50K iterations with a input sequence length 512. As shown in Figure 4, COSFORMER converges faster than vanilla transformer on both training and validation sets with a comparable or smaller loss values, despite it only consumes linear space and time computation complexity. In addition, the COSFORMER variant with re-weighting mechanism has both notably better converge speed and final results over the counterpart without re-weighting, which further validates the effectiveness of our cos-based distance matrix and also demonstrates the effectiveness of recency bias on natural language data.
|
| 182 |
+
|
| 183 |
+
# 3.3 DOWNSTREAM FINE-TUNING TASKS
|
| 184 |
+
|
| 185 |
+
In this section, we fine-tune the pre-trained model on downstream tasks to demonstrate the generalization ability of COSFORMER on downstream tasks. We use the pre-trained bidirectional model and fine-tune it on three downstream text classification tasks: GLUE (QQP, SST-2, MNLi) (Wang et al., 2018), IMDB (Maas et al., 2011) and AMAZON (Ni et al., 2019). For fair comparison, we first pre-train all the competing efficient transformer variants for the same 50K iterations on WikiText103 (Merity et al., 2017) under the same setting, then we follow the same fine-tuning protocol as RoBERTa (Liu et al., 2019) to fine-tune these methods on the downstream tasks. From Table 3, we can see that COSFORMER outperforms baseline (Liu et al., 2019) on three out of five datasets, and achieves either best or secondary place on all five downstream datasets compared to competing efficient transformers. It is worth noting that despite Longformer (Beltagy et al., 2020) achieves better results on MNLI than COSFORMER , it requires a computation complexity of $O ( N w )$ , where $w$ is window size. As shown in Figure 1, Longformer is slower and requires more memory overhead than COSFORMER . Other competing methods(Peng et al., 2020; Choromanski et al., 2020; Kitaev et al., 2019) are all based on kernel functions and have substantial performance gaps compared with our model. This validates the effectiveness of the proposed COSFORMER model compared with other efficient transformer variants.
|
| 186 |
+
|
| 187 |
+
# 3.4 RESULTS ON LONG-RANGE-ARENA BENCHMARK
|
| 188 |
+
|
| 189 |
+
To further evaluate the generalization ability of the proposed method, we train our model from scratch on Long-range-arena benchmark 2020b. Long-range-arena (Tay et al., 2020b) is a benchmark specifically designed for efficient transformers with long input sequences, thus serving as a suitable testbed to assess the quality of efficient transformer variants comparatively. To ensure fair comparison, we first implement our method on Jax (Bradbury et al., 2018), then carefully follow their preprocessing, data split, model structure and training protocol. We evaluate our method on a variety of tasks including Long sequence ListOps (Nangia & Bowman, 2018), Byte-level text classification (Maas et al., 2011), document retrieval using the ACL Anthology Network (Radev et al., 2013), image classification on sequence of pixels on CIFAR-10 (Krizhevsky & Hinton, 2009), and Pathfinder (Linsley et al., 2018). As shown in Table 4, COSFORMER overall achieves competitive results across all the tasks while achieving best performance on ListOps and Document Retrieval. For the Pathfinder task, since the distance between the two points can be very far from each other, our introduced locality bias would have negative impact to this task and show a bit lags to other SOTA methods, despite that the performance gap between our method and the vanilla transformer is small It is worth mentioning that COSFORMER achieves the best overall scores on Long-range-arena benchmark, being one of the only two models that surpass vanilla transformer architecture.
|
| 190 |
+
|
| 191 |
+
Table 4: Results on Long-range-arena benchmark. Best result is in boldface and second best is underlined. COSFORMER achieves the best average score across 5 different tasks.
|
| 192 |
+
|
| 193 |
+
<table><tr><td>Model</td><td>ListOps ↑</td><td>Text↑</td><td>Retrieval↑</td><td>Image↑</td><td>Pathfinder↑</td><td>Avg↑</td></tr><tr><td>Local Attention (Tay etal.,2020b)</td><td>15.82</td><td>52.98</td><td>53.39</td><td>41.46</td><td>66.63</td><td>46.06</td></tr><tr><td>Linear Trans. (Katharopoulos et al.,2020)</td><td>16.13</td><td>65.9</td><td>53.09</td><td>42.34</td><td>75.3</td><td>50.55</td></tr><tr><td>Reformer (Kitaev et al.,2019)</td><td>37.27</td><td>56.1</td><td>53.4</td><td>38.07</td><td>68.5</td><td>50.67</td></tr><tr><td>Sparse Trans.(Child et al.,2019)</td><td>17.07</td><td>63.58</td><td>59.59</td><td>44.24</td><td>71.71</td><td>51.24</td></tr><tr><td>Sinkhorn Trans.(Tay et al.,2020a)</td><td>33.67</td><td>61.2</td><td>53.83</td><td>41.23</td><td>67.45</td><td>51.29</td></tr><tr><td>Linformer(Wang et al., 2020)</td><td>35.7</td><td>53.94</td><td>52.27</td><td>38.56</td><td>76.34</td><td>51.36</td></tr><tr><td>Performer(Choromanski et al.,2020)</td><td>18.01</td><td>65.4</td><td>53.82</td><td>42.77</td><td>77.05</td><td>51.41</td></tr><tr><td>Synthesizer (Tay et al.,2021)</td><td>36.99</td><td>61.68</td><td>54.67</td><td>41.61</td><td>69.45</td><td>52.88</td></tr><tr><td>Longformer(Beltagy et al.,2020)</td><td>35.63</td><td>62.85</td><td>56.89</td><td>42.22</td><td>69.71</td><td>53.46</td></tr><tr><td>Transformer (Vaswani et al.,2017)</td><td>36.37</td><td>64.27</td><td>57.46</td><td>42.44</td><td>71.4</td><td>54.39</td></tr><tr><td>BigBird (Zaheer et al.,2020)</td><td>36.05</td><td>64.02</td><td>59.29</td><td>40.83</td><td>74.87</td><td>55.01</td></tr><tr><td>COSFORMER</td><td>37.9</td><td>63.41</td><td>61.36</td><td>43.17</td><td>70.33</td><td>55.23</td></tr></table>
|
| 194 |
+
|
| 195 |
+
Table 5: Speed comparison on the long-range-arena benchmark in both training and inference varying sequence lengths (1-4k). We mark it with a cross if a method runs out of memory. The higher, the better.
|
| 196 |
+
|
| 197 |
+
<table><tr><td></td><td colspan="4">Inference Speed(steps per second)↑</td><td colspan="4">Train Speed(steps per second)↑</td></tr><tr><td>model</td><td>1K</td><td>2K</td><td>3K</td><td>4k</td><td>1K</td><td>2K</td><td>3K</td><td>4K</td></tr><tr><td>Transformer(Vaswani et al.,2017)</td><td>25.37</td><td>7.83</td><td>X</td><td>X</td><td>6.95</td><td>2.23</td><td>X</td><td>X</td></tr><tr><td>Local Attention(Tay et al.,2020b)</td><td>57.73</td><td>33.19</td><td>23.36</td><td>17.79</td><td>13.45</td><td>6.71</td><td>4.32</td><td>3.09</td></tr><tr><td>Linformer(Wang et al., 2020)</td><td>70.09</td><td>39.1</td><td>27.05</td><td>20.62</td><td>14.75</td><td>7.09</td><td>4.52</td><td>3.21</td></tr><tr><td>Reformer(Kitaev et al., 2019)</td><td>44.21</td><td>21.58</td><td>12.74</td><td>8.37</td><td>11.58</td><td>4.98</td><td>2.94</td><td>1.95</td></tr><tr><td>Sinkhorn Trans.(Tay et al.,2020a)</td><td>43.29</td><td>23.58</td><td>16.53</td><td>12.7</td><td>11.09</td><td>5.57</td><td>3.68</td><td>2.68</td></tr><tr><td>Synthesizer (Tay et al.,2021)</td><td>20.89</td><td>6.24</td><td>X</td><td>X</td><td>6.36</td><td>2.01</td><td>X</td><td>X</td></tr><tr><td>BirBird (Zaheer et al., 2020)</td><td>20.96</td><td>11.5</td><td>8.12</td><td>6.15</td><td>6.46</td><td>3.2</td><td>2.13</td><td>1.53</td></tr><tr><td>Linear Trans. (Katharopoulos et al., 2020)</td><td>67.85</td><td>38.24</td><td>26.28</td><td>19.98</td><td>11.86</td><td>5.54</td><td>3.53</td><td>2.56</td></tr><tr><td>Performer (Choromanski et al.,2020)</td><td>74.15</td><td>42.31</td><td>29.5</td><td>22.44</td><td>14</td><td>6.49</td><td>4.1</td><td>2.94</td></tr><tr><td>Longformer (Beltagy et al.,2020)</td><td>22.99</td><td>6.72</td><td>X</td><td>X</td><td>4.4</td><td>1.3</td><td>×</td><td>X</td></tr><tr><td>Sparse Trans. Child et al. (2019)</td><td>24.87</td><td>7.5</td><td>X</td><td>×</td><td>6.77</td><td>2.2</td><td>X</td><td>×</td></tr><tr><td>COSFORMER</td><td>58.82</td><td>33.45</td><td>22.77</td><td>17.42</td><td>12.27</td><td>5.72</td><td>3.62</td><td>2.64</td></tr></table>
|
| 198 |
+
|
| 199 |
+
# 3.5 EFFICIENCY COMPARISON
|
| 200 |
+
|
| 201 |
+
In this section, we compare the efficiency of COSFORMER with other models, with a focus on long sequences as inputs. With the proposed linear attention module, we expect that COSFORMER scales comparably with other linear variants while significantly surpassing the vanilla transformer architecture. For a fair and comprehensive comparison, we implement our method and competing methods on Jax (Bradbury et al., 2018). We use the byte-level text classification benchmark and report runtime speed during both training and inference under different sequence lengths (1k-4k). We conduct experiments on one Nvidia A6000 GPU and also report the corresponding inferencetime memory foot prints as shown in Figure 1. As shown in Table 5 and Figure 1, most pattern based methods (Beltagy et al., 2020; Zaheer et al., 2020; Tay et al., 2020a; 2021) and vanilla transformer (Vaswani et al., 2017) are much slower and require greater memory than COSFORMER prevents them from extending to longer sequence. Further, the kernel based methods like (Narang et al., 2021; Choromanski et al., 2020; Tay et al., 2020a) have comparable speed and memory overheads, but their performances are less satisfactory compared to COSFORMER across above metrics. In summary, our model COSFORMER achieves overall better efficiency than other linear variants while maintain superior modeling and generalization ability.
|
| 202 |
+
|
| 203 |
+
# 3.6 ABLATION: cos-BASED RE-WEIGHTING
|
| 204 |
+
|
| 205 |
+
By introducing cos-based re-weighting, we provide a non-linear mechanism to concentrate the distribution of attention connections and stabilizes the training. In this way, we encourage the model to better take into account the locality inductive biases commonly observed on many natural language tasks. In particular, we investi
|
| 206 |
+
|
| 207 |
+
Table 6: Performance comparison of COSFORMER with and without cos-based re-weighting $( \phi _ { \mathrm { R e L U } } )$ . We evaluate on two compositive metrics. Bidirectional finetune $_ \mathrm { a v g }$ : average score across 5 datasets reported in Table 3. $\mathbf { L R A } _ { \mathrm { a v g } }$ : average score across 5 tasks reported in Table 4.
|
| 208 |
+
|
| 209 |
+
<table><tr><td>Model</td><td>Bidirectional finetuneavg 个</td><td>LRAavg↑</td></tr><tr><td>ReLU</td><td>85.12</td><td>54.20</td></tr><tr><td>COSFORMER</td><td>85.25</td><td>55.23</td></tr></table>
|
| 210 |
+
|
| 211 |
+
gate the effect of the cos-based re-weighting in two aspects. First, as shown in Figure 4, by adding
|
| 212 |
+
|
| 213 |
+
cos-based re-weighting, we obtain both notably better converge speed and final results in autoregressive language modeling. Further, in Table 6, we present a comparison between COSFORMER models with and without re-weighting mechanism. We use two composite metrics which comprehensively include 10 different datasets from bidirectional downstream fine-tuning tasks and long-range-arena (Tay et al., 2020b). COSFORMER achieves overall better results over the counterpart without reweighting, improving the average scores on bidirectional finetuning and long-range-arena by a clear margin. This verifies that the proposed re-weighting effectively incorporates the locality inductive biases for natural language tasks.
|
| 214 |
+
|
| 215 |
+
# 4 RELATED WORK
|
| 216 |
+
|
| 217 |
+
This section will introduce the existing works on improving the efficiency of Transformers, they can be broadly divided into two categories, Pattern based methods and Kernel based methods.
|
| 218 |
+
|
| 219 |
+
Pattern based method Pattern based methods sparsify the attention matrix with handcrafted or learnable patterns. As an early approach, Lee et al. (2019) leverages the inducing points from the sparse Gaussian process to reduce the quadratic complexities of a transformer. Child et al. (2019) reduces the complexity by applying combination of strided pattern and local pattern to the vanilla attention matrix. Longformer (Beltagy et al., 2020) designs fixed diagonal sliding windows combined with global window, and the sliding window pattern can also be extended with dilation to enlarge the receptive field. Zaheer et al. (2020) presents a more powerful and expressive sparse attention mechanism, which combines multiple types of attention patterns and gives a thorough study of sparse attention mechanism. Instead of fixed patterns, Kitaev et al. (2019) and Daras et al. (2020) group the attention computation process into buckets by local sensitive hashing, while Roy et al. (2020) uses mini-batch spherical $k$ -means. Nevertheless, Pattern based methods can only cope with sequences up to a certain length, and the computational complexity still grows rapidly when the input sequence becomes longer.
|
| 220 |
+
|
| 221 |
+
Kernel based method When faced with longer input sequences, it is more efficient to directly reduce the complexity of the theoretical calculation method. Kernel based methods speed up selfattention by reducing the computation complexity of self-attention from quadratic to linear. Vyas et al. (2020) approximate the full attention with a fixed number of cluster attention groups by assuming neighbouring queries in Euclidean space should have similar attention distributions. Peng et al. (2020) chooses to use the production of Gaussian kernel functions to approximate Softmax, changing the order of scale dot product calculation, thus reducing the theoretical time to linear complexity and Choromanski et al. (2020) uses Haar measurement based kernel instead. Wang et al. (2020) imports the low-rank prior for attention matrix and approximate softmax with SVD decomposition manner. Xiong et al. (2021) utilizes the Nystrom method with segment-means to generate a low- ¨ rank approximation of the Softmax matrix. Katharopoulos et al. (2020) formalizes the transformer layer as a recurrent neural network. In this paper, we demonstrate that the approximation to Softmax is unneccessary for Linearization of self-attention module. We instead propose a new method to replace Softmax with a linear operation with a re-weighting mechanism, which reduces both time complexity and space complexity to $O ( N )$ while maintaining the accuracy.
|
| 222 |
+
|
| 223 |
+
# 5 CONCLUSION
|
| 224 |
+
|
| 225 |
+
We presented COSFORMER , a new efficient transformer that has linear time and space complexity. Our COSFORMER is based on two key properties of the original softmax attention: (i) every element in the attention matrix are non-negative, such that negatively-correlated information are not included for contextual information aggregation; (ii) the non-linear re-weighting scheme concentrates the distribution of the attention matrix, in order to better exploit the locality inductive biases on sequence modeling. To fulfill these properties in our COSFORMER , we utilized the RuLU function as our linear operation to ensure the non-negative property; a new cos-based re-weighting mechanism was proposed to enforce the locality bias in the original softmax attention. Since our COSFORMER is naturally decomposable, it does not suffer the accumulated approximation error that usually happens in previous linear transformers. On causal pre-training, bidirectional pre-training, and multiple downstream text understanding tasks, COSFORMER achieves comparable or even better performances than the vanilla transformer. On long sequence benchmark, COSFORMER achieved state-of-the-art performance over five different tasks. Further, COSFORMER obtains a significant overall advantage in terms of time and memory efficiency over all existing efficient transformers, facilitating the transformers to easily scale to longer input sequence.
|
| 226 |
+
|
| 227 |
+
# REFERENCES
|
| 228 |
+
|
| 229 |
+
Abien Fred Agarap. Deep learning using rectified linear units (relu). arXiv preprint arXiv:1803.08375, 2018.
|
| 230 |
+
|
| 231 |
+
Alexei Baevski and Michael Auli. Adaptive input representations for neural language modeling. In International Conference on Learning Representations, 2018.
|
| 232 |
+
|
| 233 |
+
Alexei Baevski, Yuhao Zhou, Abdelrahman Mohamed, and Michael Auli. wav2vec 2.0: A framework for self-supervised learning of speech representations. Advances in Neural Information Processing Systems, 33, 2020.
|
| 234 |
+
|
| 235 |
+
Iz Beltagy, Matthew E Peters, and Arman Cohan. Longformer: The long-document transformer. arXiv preprint arXiv:2004.05150, 2020.
|
| 236 |
+
|
| 237 |
+
James Bradbury, Roy Frostig, Peter Hawkins, Matthew James Johnson, Chris Leary, Dougal Maclaurin, and Skye Wanderman-Milne. Jax: composable transformations of python $^ +$ numpy programs. Version 0.1, 55, 2018.
|
| 238 |
+
|
| 239 |
+
Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. arXiv, 2020.
|
| 240 |
+
|
| 241 |
+
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, pp. 213–229. Springer, 2020.
|
| 242 |
+
|
| 243 |
+
Rewon Child, Scott Gray, Alec Radford, and Ilya Sutskever. Generating long sequences with sparse transformers. arXiv preprint arXiv:1904.10509, 2019.
|
| 244 |
+
|
| 245 |
+
Krzysztof Choromanski, Valerii Likhosherstov, David Dohan, Xingyou Song, Andreea Gane, Tamas Sarlos, Peter Hawkins, Jared Davis, Afroz Mohiuddin, Lukasz Kaiser, et al. Rethinking attention with performers. arXiv preprint arXiv:2009.14794, 2020.
|
| 246 |
+
|
| 247 |
+
Kevin Clark, Urvashi Khandelwal, Omer Levy, and Christopher D Manning. 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, pp. 276–286, 2019.
|
| 248 |
+
|
| 249 |
+
Djork-Arne Clevert, Thomas Unterthiner, and Sepp Hochreiter. Fast and accurate deep network ´ learning by exponential linear units (elus). In Yoshua Bengio and Yann LeCun (eds.), 4th International Conference on Learning Representations, ICLR, San Juan, Puerto Rico, 2016.
|
| 250 |
+
|
| 251 |
+
Giannis Daras, Nikita Kitaev, Augustus Odena, and Alexandros G Dimakis. Smyrf - efficient attention using asymmetric clustering. In H. Larochelle, M. Ranzato, R. Hadsell, M. F. Balcan, and H. Lin (eds.), NeurIPS, volume 33, pp. 6476–6489. Curran Associates, Inc., 2020.
|
| 252 |
+
|
| 253 |
+
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 4171–4186, 2019.
|
| 254 |
+
|
| 255 |
+
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, 2020.
|
| 256 |
+
|
| 257 |
+
Bolin Gao and Lacra Pavel. On the properties of the softmax function with application in game theory and reinforcement learning. arXiv preprint arXiv:1704.00805, 2017.
|
| 258 |
+
|
| 259 |
+
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.
|
| 260 |
+
|
| 261 |
+
Sepp Hochreiter and Jurgen Schmidhuber. Long short-term memory. ¨ Neural computation, 9(8): 1735–1780, 1997.
|
| 262 |
+
|
| 263 |
+
Eric Jang, Shixiang Gu, and Ben Poole. Categorical reparameterization with gumbel-softmax. arXiv preprint arXiv:1611.01144, 2016.
|
| 264 |
+
|
| 265 |
+
Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, and Franc¸ois Fleuret. Transformers are rnns: Fast autoregressive transformers with linear attention. In International Conference on Machine Learning, pp. 5156–5165. PMLR, 2020.
|
| 266 |
+
|
| 267 |
+
Nikita Kitaev, Lukasz Kaiser, and Anselm Levskaya. Reformer: The efficient transformer. In International Conference on Learning Representations, 2019.
|
| 268 |
+
|
| 269 |
+
Olga Kovaleva, Alexey Romanov, Anna Rogers, and Anna Rumshisky. Revealing the dark secrets of bert. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLPIJCNLP), pp. 4365–4374, 2019.
|
| 270 |
+
|
| 271 |
+
A. Krizhevsky and G. Hinton. Learning multiple layers of features from tiny images. Master’s thesis, Department of Computer Science, University of Toronto, 2009.
|
| 272 |
+
|
| 273 |
+
Juho Lee, Yoonho Lee, Jungtaek Kim, Adam Kosiorek, Seungjin Choi, and Yee Whye Teh. Set transformer: A framework for attention-based permutation-invariant neural networks. In ICML, pp. 3744–3753, 2019.
|
| 274 |
+
|
| 275 |
+
Drew Linsley, Junkyung Kim, Vijay Veerabadran, Charlie Windolf, and Thomas Serre. Learning long-range spatial dependencies with horizontal gated recurrent units. In Proceedings of the 32nd International Conference on Neural Information Processing Systems, pp. 152–164, 2018.
|
| 276 |
+
|
| 277 |
+
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.
|
| 278 |
+
|
| 279 |
+
Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. arXiv preprint arXiv:2103.14030, 2021.
|
| 280 |
+
|
| 281 |
+
Antoine Liutkus, Ondˇrej C´ıfka, Shih-Lun Wu, Umut S¸ ims¸ekli, Yi-Hsuan Yang, and Gael Richard. ¨ Relative positional encoding for Transformers with linear complexity. 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. 7067–7079. PMLR, 18–24 Jul 2021.
|
| 282 |
+
|
| 283 |
+
Andrew Maas, Raymond E Daly, Peter T Pham, Dan Huang, Andrew Y Ng, and Christopher Potts. Learning word vectors for sentiment analysis. In Proceedings of the 49th annual meeting of the association for computational linguistics: Human language technologies, pp. 142–150, 2011.
|
| 284 |
+
|
| 285 |
+
Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. Pointer sentinel mixture models. 5th International Conference on Learning Representations, ICLR, Toulon, France, 2017.
|
| 286 |
+
|
| 287 |
+
Nikita Nangia and Samuel Bowman. Listops: A diagnostic dataset for latent tree learning. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Student Research Workshop, pp. 92–99, 2018.
|
| 288 |
+
|
| 289 |
+
Sharan Narang, Hyung Won Chung, Yi Tay, William Fedus, Thibault Fevry, Michael Matena, Karishma Malkan, Noah Fiedel, Noam Shazeer, Zhenzhong Lan, et al. Do transformer modifications transfer across implementations and applications? arXiv preprint arXiv:2102.11972, 2021.
|
| 290 |
+
|
| 291 |
+
Jianmo Ni, Jiacheng Li, and Julian McAuley. Justifying recommendations using distantly-labeled reviews and fine-grained aspects. 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. 188–197, 2019.
|
| 292 |
+
|
| 293 |
+
Hao Peng, Nikolaos Pappas, Dani Yogatama, Roy Schwartz, Noah Smith, and Lingpeng Kong. Random feature attention. In International Conference on Learning Representations, 2020.
|
| 294 |
+
|
| 295 |
+
Dragomir R Radev, Pradeep Muthukrishnan, Vahed Qazvinian, and Amjad Abu-Jbara. The acl anthology network corpus. Language Resources and Evaluation, 47(4):919–944, 2013.
|
| 296 |
+
|
| 297 |
+
Ali Rahimi and Benjamin Recht. Random features for large-scale kernel machines. In J. Platt, D. Koller, Y. Singer, and S. Roweis (eds.), Advances in Neural Information Processing Systems, volume 20. Curran Associates, Inc., 2008.
|
| 298 |
+
|
| 299 |
+
Aurko Roy, Mohammad Taghi Saffar, David Grangier, and Ashish Vaswani. Efficient content-based sparse attention with routing transformers. In TACL, 2020.
|
| 300 |
+
|
| 301 |
+
Steffen Schneider, Alexei Baevski, Ronan Collobert, and Michael Auli. wav2vec: Unsupervised pre-training for speech recognition. In INTERSPEECH, 2019.
|
| 302 |
+
|
| 303 |
+
Jianlin Su, Yu Lu, Shengfeng Pan, Bo Wen, and Yunfeng Liu. Roformer: Enhanced transformer with rotary position embedding. In arXiv, 2021.
|
| 304 |
+
|
| 305 |
+
Yi Tay, Dara Bahri, Liu Yang, Donald Metzler, and Da-Cheng Juan. Sparse sinkhorn attention. In International Conference on Machine Learning, pp. 9438–9447. PMLR, 2020a.
|
| 306 |
+
|
| 307 |
+
Yi Tay, Mostafa Dehghani, Samira Abnar, Yikang Shen, Dara Bahri, Philip Pham, Jinfeng Rao, Liu Yang, Sebastian Ruder, and Donald Metzler. Long range arena: A benchmark for efficient transformers. In International Conference on Learning Representations, 2020b.
|
| 308 |
+
|
| 309 |
+
Yi Tay, Dara Bahri, Donald Metzler, Da-Cheng Juan, Zhe Zhao, and Che Zheng. Synthesizer: Rethinking self-attention for transformer models. In International Conference on Machine Learning, pp. 10183–10192. PMLR, 2021.
|
| 310 |
+
|
| 311 |
+
Michalis K Titsias. One-vs-each approximation to softmax for scalable estimation of probabilities. arXiv preprint arXiv:1609.07410, 2016.
|
| 312 |
+
|
| 313 |
+
Yao-Hung Hubert Tsai, Shaojie Bai, Makoto Yamada, Louis-Philippe Morency, and Ruslan Salakhutdinov. Transformer dissection: An unified understanding for transformer’s attention via the lens of kernel. In EMNLP, 2019.
|
| 314 |
+
|
| 315 |
+
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.
|
| 316 |
+
|
| 317 |
+
A. Vyas, A. Katharopoulos, and F. Fleuret. Fast transformers with clustered attention. In NeurIPS, 2020.
|
| 318 |
+
|
| 319 |
+
Alex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel Bowman. Glue: A multi-task benchmark and analysis platform for natural language understanding. In Proceedings of the 2018 EMNLP Workshop BlackboxNLP: Analyzing and Interpreting Neural Networks for NLP, pp. 353–355, 2018.
|
| 320 |
+
|
| 321 |
+
Sinong Wang, Belinda Z Li, Madian Khabsa, Han Fang, and Hao Ma. Linformer: Self-attention with linear complexity. arXiv preprint arXiv:2006.04768, 2020.
|
| 322 |
+
|
| 323 |
+
Yunyang Xiong, Zhanpeng Zeng, Rudrasis Chakraborty, Mingxing Tan, Glenn Fung, Yin Li, and Vikas Singh. Nystromformer: A nystr ¨ om-based algorithm for approximating self-attention. In ¨ AAAI, 2021.
|
| 324 |
+
|
| 325 |
+
Manzil Zaheer, Guru Guruganesh, Kumar Avinava Dubey, Joshua Ainslie, Chris Alberti, Santiago Ontanon, Philip Pham, Anirudh Ravula, Qifan Wang, Li Yang, et al. Big bird: Transformers for longer sequences. In NeurIPS, 2020.
|
| 326 |
+
|
| 327 |
+
# A APPENDIX
|
| 328 |
+
|
| 329 |
+
A.1 MATHEMATICAL DERIVATION OF cos-BASED RE-WEIGHTING
|
| 330 |
+
|
| 331 |
+
Following Equation 11, we give a detailed deviation of how to obtain output at position $i ^ { t h }$ position:
|
| 332 |
+
|
| 333 |
+
$$
|
| 334 |
+
\begin{array} { r l } & { \mathcal { O } _ { 4 } = \frac { \sum _ { j = 1 } ^ { N } f \left( Q _ { j } ^ { \star } , K _ { j } ^ { \star \star } \right) ^ { T } V _ { j } } { \sum _ { j = 1 } ^ { N } f \left( Q _ { j } ^ { \star } , K _ { j } ^ { \star \star } \right) ^ { T } } } \\ & { = \frac { \sum _ { i = 1 } ^ { N } \left( \bar { Q } _ { i } ^ { \star \star \star } \left( \bar { K } _ { i } ^ { \star \star \star } \right) ^ { T } + \bar { Q } _ { i } ^ { \star \star \star } \left( \bar { K } _ { i } ^ { \star \star \star } \right) ^ { T } \right) V _ { j } } { \sum _ { i = 1 } ^ { N } \left( \bar { Q } _ { i } ^ { \star \star \star } \left( \bar { K } _ { i } ^ { \star \star \star } \right) ^ { T } + \bar { Q } _ { i } ^ { \star \star \star } \left( \bar { K } _ { i } ^ { \star \star \star } \right) ^ { T } \right) } } \\ & { = \frac { \sum _ { j = 1 } ^ { N } \bar { Q } _ { i } ^ { \star \star \star } \left( \bar { K } _ { j } ^ { \star \star \star } \right) ^ { T } V _ { j } + \sum _ { j = 1 } ^ { N } \bar { Q } _ { i } ^ { \star \star \star } \left( \bar { K } _ { j } ^ { \star \star \star } \right) ^ { T } V _ { j } } { \sum _ { j = 1 } ^ { N } \bar { Q } _ { i } ^ { \star \star \star } \left( \bar { K } _ { j } ^ { \star \star } \right) ^ { T } + \sum _ { j = 1 } ^ { N } \bar { Q } _ { i } ^ { \star \star \star } \left( \bar { K } _ { j } ^ { \star \star } \right) ^ { T } } } \\ & = \frac { \sum _ { j = 1 } ^ { N } \bar { Q } _ { i } ^ { \star \star } \left( \left( \bar { K } _ { j } ^ { \star \star \star } \right) ^ { T } V _ { j } \right) + \sum _ { j = 1 } ^ { N } \bar { Q } _ { i } ^ { \star \star } \left( \bar { K } _ { j } ^ { \star \star } \right) ^ { T } V _ { j } } { \sum _ { j = 1 } ^ { N } \bar { Q } _ { i } ^ { \star \star } \left( \bar { K } _ { j } ^ { \star \star } \right) ^ { T } V _ { j } } \end{array}
|
| 335 |
+
$$
|
| 336 |
+
|
| 337 |
+
where $i , j = 1 , . . . , N , M \geq N ,$ , and $Q ^ { ' } = \mathrm { R e L U } ( Q ) , K ^ { ' } = \mathrm { R e L U } ( K )$ . Let $\begin{array} { r } { Q _ { i } ^ { \mathrm { c o s } } = Q _ { i } ^ { ' } \cos \left( \frac { \pi i } { 2 M } \right) } \end{array}$ , $\begin{array} { r } { Q _ { i } ^ { \mathrm { c o s } } = Q _ { i } ^ { ' } \cos { \left( \frac { \pi i } { 2 M } \right) } , K _ { j } ^ { \mathrm { c o s } } = K _ { j } ^ { ' } \cos { \left( \frac { \pi j } { 2 M } \right) } , K _ { j } ^ { \mathrm { s i n } } = K _ { j } ^ { ' } \sin { \left( \frac { \pi j } { 2 M } \right) } . } \end{array}$ It presents that the output of the proposed COSFORMER attention can be obtained in a linear manner.
|
| 338 |
+
|
| 339 |
+
# A.2 PSEUDO CODE OF COSFORMER
|
| 340 |
+
|
| 341 |
+
Algorithm 1 describe the way to compute COSFORMER attention
|
| 342 |
+
|
| 343 |
+
<table><tr><td>Algorithm1 COsFoRMER attention</td></tr><tr><td>Input: Q ∈ RNxd1,K ∈RMxd1,V ∈RM×d2;</td></tr><tr><td>Output: O ∈ RN×d2;</td></tr><tr><td>Use Mi to represent the i-th row of matrix M;</td></tr><tr><td></td></tr><tr><td>Initialize Scos[i][j]=0,Ssin[i][j] =0,Tcos[i]=0,Tsin[i]=0,i=1,.,d1,j =1,.,d;</td></tr><tr><td>for i in 1,..., M do: Kcos=Kicos (),Kn =Ksin();</td></tr><tr><td>Scos += (Kcos)T Vi;</td></tr><tr><td>Ssin += (Ksin)T</td></tr><tr><td>Vi;</td></tr><tr><td>Tcos+= Kcos. 2</td></tr><tr><td>Tsin += Ksin; i ,</td></tr><tr><td>end for</td></tr><tr><td>for i in 1,...,N do:</td></tr><tr><td>Qcos = Qicos ( (),Qn = Qisin();</td></tr><tr><td>Qcos gcos +Qn Ssin O=</td></tr><tr><td></td></tr></table>
|
| 344 |
+
|
| 345 |
+
# A.3 ALGORITHM TO VISUALIZE ATTENTION MATRIX
|
| 346 |
+
|
| 347 |
+
Algorithm 2 describe the way to visualize attention matrix as Figure 3
|
| 348 |
+
|
| 349 |
+
# Algorithm 2 Algorithm to visualize attention matrix
|
| 350 |
+
|
| 351 |
+
Input: $M _ { k } \in \mathbb R _ { ~ . ~ . ~ . ~ . ~ , h } ^ { d \times d } { \mathrm { { \ell } } } = 1 , \ldots , n ; t h r e s h o l d \in [ 0 , 1 ] ;$
|
| 352 |
+
Output: $M \in \mathbb { R } ^ { d \times d }$ ;
|
| 353 |
+
Initialize $M [ i ] [ j ] = 0 , i \in { 1 , \dots , d , j } \in { 1 , \dots , d }$ ;
|
| 354 |
+
for $k$ in $1 , \ldots , n$ do: for $i$ in $1 , \ldots , d$ do: index $= \mathrm { a r g s o r t } ( M _ { k } [ i ] )$ (in descending order) $p = 0$ for $j$ in $1 , \ldots , d$ do: $l = \operatorname { i n d e x } [ j ]$ $p + = M _ { k } [ i ] [ l ]$ $M [ i ] [ l ] + = \bar { 1 }$ if $p >$ threshold then: break end if end for end for
|
| 355 |
+
end for
|
| 356 |
+
$M \ / = n$ ;
|
| 357 |
+
Use heatmap to visualize M;
|
| 358 |
+
|
| 359 |
+
# A.4 INTRODUCTION OF DATASET
|
| 360 |
+
|
| 361 |
+
We train both models on autoregressive language modeling and bidirectional modeling by Wikitext103 dataset, it is split by tokens and its statistics as Table 7.Then we fine-tune the pre-trained bidirectional modeling on several text classification tasks.
|
| 362 |
+
|
| 363 |
+
QQP dataset contain thousands of sentence pair from community question-answering website Quora.Network need to determine pairs of question are semantically equivalent. SST-2 and IMDB are collections of movie reviews. The task is to determine whether a review is positive or not. AMAZON dataset contains millions of product reviews from Amazon.The requirement of this task is to infer the scoring of the product from the review text.MNLI is a crow-source collections of sentence pairs. The network must distinguish which of the three categories entailment, contradiction and neutral the given sentences belong to.
|
| 364 |
+
|
| 365 |
+
The long-range-aren benchmark contains 5 different datasets.ListOps contains some designed clever mathematical problem to clarify the parsing ability of neural models. IMDB is also used in this benchmark to examine the text classification ability of neural models. CIFAR-10 is a image collection of various of object, this task require models capture 2D spatial relations between flatten pixels.In pathfinder task, models need to determine the connection of two points in the picture, so as to examine the model’s ability to acquire 2D spatial relationships.AAN dataset is used to evaluate the ability for models to encode and store compressed representations for retrieving.
|
| 366 |
+
|
| 367 |
+
<table><tr><td>Data</td><td>Train</td><td>Valid</td><td>Test</td></tr><tr><td>WikiText-103</td><td>103M</td><td>218K</td><td>246K</td></tr><tr><td>QQP</td><td>364K</td><td>-</td><td>391K</td></tr><tr><td>SST-2</td><td>67K</td><td>-</td><td>1.8K</td></tr><tr><td>MNLI</td><td>393K</td><td>-</td><td>20K</td></tr><tr><td>IMDB</td><td>25K</td><td>-</td><td>25K</td></tr><tr><td>AMAZON</td><td>3M</td><td>168K</td><td>168K</td></tr><tr><td>ListOps</td><td>90K</td><td>1</td><td>10K</td></tr><tr><td>AAN</td><td>147K</td><td>18K</td><td>17K</td></tr><tr><td>CIFAR-10</td><td>50K</td><td></td><td>10K</td></tr><tr><td>Pathfinder</td><td>160K</td><td>■</td><td>20K</td></tr></table>
|
| 368 |
+
|
| 369 |
+
Table 7: Statistics for the datasets.A subset of ”Small” amazon subset on electronics category is used for experiment
|
| 370 |
+
|
| 371 |
+
# A.5 QUALITATIVE RESULTS OF LRA
|
| 372 |
+
|
| 373 |
+
We provide our qualitative results of the ListOps and Document Retrieval tasks on Long-RangeArena benchmark (Tay et al., 2020b) with a comparison to the vanilla transformer.
|
| 374 |
+
|
| 375 |
+
ListOps is a ten-way classification task which aims to prediction the results of a sequence with a hierarchical structure and operators MAX, MEAN, MEDIAN and SUM MOD that are enclosed by delimiters (brackets). The network needs to access all tokens and model the logical structure of the inputs in order to make a prediction.
|
| 376 |
+
|
| 377 |
+
Document Retrieval task is to decide whether the two input long documents are similar or not with a binary label. This task evaluates a model’s ability to encode and store compressed representations that are useful for matching and retrieval. Since the samples in LRA are too long, We substantially shorten some selected samples and display them as below:
|
| 378 |
+
|
| 379 |
+
# Listops:
|
| 380 |
+
|
| 381 |
+
1 Input: ( ( ( [MED 7 ) 9 ) 3 ) 1 ..... 5 ) 6 ) 8 ) ] ) ) 2 ) 8 ) 9 ) 5 ) 0 ) ] ) ) 8 ) 5 ) 1 ) 2 ) ] ) Our Output: 0, Transformer output: 9, Ground-truth: 0
|
| 382 |
+
23 Input: ( ( ( ( ( ( ( ( ( [SM 5 ) 6 ) 0 ) 7 ) 1 ) ( ( ( ( ( (...... ( ( ( Input: ( ( [MIN 5 ) 8 ) 1 ) 0 ) (( [MED ( ( ( 8 ) 7 ) 2 ) 8 ) 1 ) 8 ) ] ) ) 7 ) ] )] ) Our output: 9, Transformer output: 3, Ground-truth: 9
|
| 383 |
+
45 Input: ( ( ( ( ( ( ( ( ( [MAX 7 ) 4 ) 8 ) ( ( ( ( ( ( ( ( ( ( ( [MAX 5 ) 2 ) ( ( ( ( ( ( [SM 3 ) 6 ) 9 ) ( ( ( ...... ) ) 1 ) 6 ) 4 ) 2 ) ] ) ) ] ) Our output: 9, Transformer output: 5, Ground-truth: 9
|
| 384 |
+
|
| 385 |
+
# Listing 1: Examples of LisOps
|
| 386 |
+
|
| 387 |
+
# Byte-level document retrieval:
|
| 388 |
+
|
| 389 |
+
1 Text1: b’1 Introduction Recent advances in Statistical Machine Translation (SMT) are widely centred around two concepts: (a) hierarchical translation processes, frequently employing Synchronous Context Free Grammars (SCFGs) and (b) transduction or synchronous rewrite processes over a linguistic ......
|
| 390 |
+
23 Text2: b’1 Introduction Automatic Grammatical Error Correction (GEC) for non-native English language learners has attracted more and more attention with the development of natural language processing , machine learning and big-data techniques. ?The CoNLL2013 shared task focuses on the problem of GEC in five different error types including determiner, preposition, noun number....
|
| 391 |
+
45 Our output: False, Transformer output: True, Ground-truth: False
|
| 392 |
+
|
| 393 |
+
Listing 2: Examples of Document Retrieval
|
md/dev/Bq2-WN5csW/Bq2-WN5csW.md
ADDED
|
@@ -0,0 +1,423 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Loss Landscape Dependent Self-Adjusting Learning Rates in Decentralized Stochastic Gradient Descent
|
| 2 |
+
|
| 3 |
+
Anonymous Author(s)
|
| 4 |
+
Affiliation
|
| 5 |
+
Address
|
| 6 |
+
email
|
| 7 |
+
Abstract
|
| 8 |
+
|
| 9 |
+
1 Distributed Deep Learning (DDL) is essential for large-scale Deep Learning (DL)
|
| 10 |
+
2 training. Synchronous Stochastic Gradient Descent (SSGD) 1 is the de facto DDL
|
| 11 |
+
3 optimization method. Using a sufficiently large batch size is critical to achieving
|
| 12 |
+
4 DDL runtime speedup. In a large batch setting, the learning rate must be increased
|
| 13 |
+
5 to compensate for the reduced number of parameter updates. However, a large
|
| 14 |
+
6 learning rate may harm convergence in SSGD and training can easily diverge.
|
| 15 |
+
7 Recently, Decentralized Parallel SGD (DPSGD) has been proposed to improve
|
| 16 |
+
8 distributed training speed. In this paper, we find that DPSGD not only has a runtime
|
| 17 |
+
9 benefit, but also a significant convergence benefit over SSGD in the large batch
|
| 18 |
+
10 setting. Based on a detailed analysis of DPSGD learning dynamics, we find that
|
| 19 |
+
11 DPSGD introduces additional landscape-dependent noise that automatically adjusts
|
| 20 |
+
12 the effective learning rate to improve convergence. In addition, we theoretically
|
| 21 |
+
13 show that this noise smooths the loss landscape, hence allowing a larger learning
|
| 22 |
+
14 rate. This result also implies that DPSGD can greatly simplify learning rate tuning
|
| 23 |
+
15 for tasks that require careful learning rate warmup (e.g, Attention-Based Language
|
| 24 |
+
16 Modeling). We conduct extensive studies over 18 state-of-the-art DL models/tasks
|
| 25 |
+
17 and demonstrate that DPSGD often converges in cases where SSGD diverges when
|
| 26 |
+
18 training is sensitive to large learning rates. Our findings are consistent across three
|
| 27 |
+
19 different application domains: Computer Vision (CIFAR10 and ImageNet-1K),
|
| 28 |
+
20 Automatic Speech Recognition (SWB300 and SWB2000) and Natural Language
|
| 29 |
+
21 Processing (Wikitext-103); three different types of neural network models: Convo
|
| 30 |
+
22 lutional Neural Networks, Long Short-Term Memory Recurrent Neural Networks
|
| 31 |
+
23 and Attention-based Transformer Models; and two optimizers: SGD and Adam.
|
| 32 |
+
|
| 33 |
+
# 24 1 Introduction
|
| 34 |
+
|
| 35 |
+
25 Deep Learning (DL) has revolutionized AI across application domains: Computer Vision (CV)
|
| 36 |
+
26 [29, 14], Natural Language Processing (NLP) [50], and Automatic Speech Recognition (ASR) [15].
|
| 37 |
+
27 Stochastic Gradient Descent (SGD) is the fundamental optimization method used in DL training.
|
| 38 |
+
28 Due to massive computational requirements, Distributed Deep Learning (DDL) is the preferred
|
| 39 |
+
29 mechanism to train large scale Deep Learning (DL) tasks.
|
| 40 |
+
|
| 41 |
+
The degree of parallelism in a DDL system is dictated by batch size: the larger the batch size, the more parallelism and higher speedup can be expected. However, large batches require a larger learning rate and overall they may negatively affect model accuracy because (1) large batch training usually converges to sharp minima which do not generalize well [24], and (2) large learning rates may violate the conditions (i.e., the learning rate should be less than the reciprocal of the smoothness parameter) required for convergence in nonconvex optimization theory [11]. Although training longer with large batches can lead to better generalization [18], doing so gives up some or all of the speedup we seek.
|
| 42 |
+
|
| 43 |
+

|
| 44 |
+
Figure 1: SSGD (red) does not converge when the learning rate needs to be large (e.g., large batch setting or a short warmup period). Figure 1a shows model accuracy (higher is better), while Figure 1b and Figure 1c show heldout loss (lower is better). Injecting Gaussian noise (blue) does not enable SSGD to escape poor local minima. In contrast, DPSGD (green) converges using the same hyperparameter setup. The detailed task descriptions and training recipes are given in Sections 4.3 and 4.5. BS denotes Batch-Size.
|
| 45 |
+
|
| 46 |
+
37 Through meticulous hyper-parameter design (e.g., learning rate schedules) tailored to each specific
|
| 47 |
+
38 task, SSGD-based DDL systems have enabled large batch training and shortened training time for
|
| 48 |
+
39 some challenging CV tasks [12, 54] and NLP tasks [55] from weeks to hours or less. However, it is
|
| 49 |
+
40 observed that SSGD with large batch size leads to large training loss and inferior model quality for
|
| 50 |
+
41 ASR tasks [58], as illustrated in Figure 1b (red curve). Here, we found for other types of tasks (e.g.
|
| 51 |
+
42 CV and NLP) and DL models, large batch SSGD has the same problem (Figures 1a and 1c).
|
| 52 |
+
43 Several SSGD variants have been proposed to address large batch training problems: (1) local
|
| 53 |
+
44 SGD, i.e., SGD-based algorithms with periodic averaging, where learners conduct global averaging
|
| 54 |
+
45 after multiple steps of gradient-based updates [13, 36, 64]; (2) SSGD based algorithm with second
|
| 55 |
+
46 order statistics, including adaptive gradient algorithms [55, 54] and algorithms for exploring the
|
| 56 |
+
47 information from the gradient covariance matrix [51]; and (3) SSGD-based algorithms on a smoothed
|
| 57 |
+
48 landscape [35, 9], in which specifically designed loss landscape smoothing algorithms are used. All
|
| 58 |
+
49 of these approaches require global synchronization and/or global statistics collection, which makes
|
| 59 |
+
50 them vulnerable to stragglers.
|
| 60 |
+
51 Decentralized algorithms, such as Decentralized Parallel Stochastic Gradient Descent (DPSGD) [33],
|
| 61 |
+
52 are surrogates for SSGD in machine learning. Unlike SSGD, where each learner updates its weights
|
| 62 |
+
53 by taking a global average of all learners’ weights, DPSGD updates each learner’s weights by taking
|
| 63 |
+
54 a partial average (i.e., across a subset of neighboring learners). In contrast to the existing variants
|
| 64 |
+
55 of SSGD, DPSGD requires no additional calculation and no global synchronization. Traditionally
|
| 65 |
+
56 DPSGD is a second-choice to SSGD, and is used only when the underlying computational resources
|
| 66 |
+
57 are less homogeneous (i.e., a high latency network or computational devices running at different
|
| 67 |
+
58 speeds). Little thought has been given to the question of whether there are any convergence benefits
|
| 68 |
+
59 for DPSGD, especially in the large batch setting.
|
| 69 |
+
60 In this paper, we find that DPSGD [33] greatly improves large batch training performance, as
|
| 70 |
+
61 illustrated by the green curves in Figure 1. Since DPSGD only uses a partial average of neighboring
|
| 71 |
+
62 learners’ weights, each learner’s weights differ from the weights of other learners. The differing
|
| 72 |
+
63 weights between learners are an additional source of noise in DPSGD training. The key difference
|
| 73 |
+
64 between SSGD, SSGD with Gaussian noise (denoted as $" \mathrm { S } \mathrm { S } \mathrm { G } \mathrm { D } ^ { \ast \prime \prime }$ in this paper) and DPSGD is the
|
| 74 |
+
65 source of noise during the update, and this noise directly affects performance in deep learning. This
|
| 75 |
+
66 naturally motivates us to ask Why does decentralized training outperform synchronous training in the
|
| 76 |
+
67 large batch setting? More specifically, we try to understand whether these performance differences
|
| 77 |
+
68 are caused by differences in noise. We answer this question from both theoretical and empirical
|
| 78 |
+
69 perspectives. Our contributions are:
|
| 79 |
+
|
| 80 |
+
• We analyze the dynamics of DDL algorithms, including both SSGD and DPSGD. We show, both theoretically and empirically, that the intrinsic noise in DPSGD automatically adjusts the effective learning rate when the batch size is large to help convergence. Note that the intrinsic noise comes completely for free in the DPSGD algorithm, and we show that it has
|
| 81 |
+
|
| 82 |
+
74 a loss-landscape smoothing effect. Guided by our theoretical results, we also investigate
|
| 83 |
+
75 training tasks where careful learning rate warmup schemes are required (e.g., Transformer
|
| 84 |
+
76 models) [56, 42, 52] and find that DPSGD can work with a much shorter learning rate
|
| 85 |
+
77 warmup period thus simplifying hyper-parameter tuning.
|
| 86 |
+
|
| 87 |
+
We conduct extensive empirical studies of 18 CV, ASR, and NLP tasks with state-of-the-art CNN, LSTM, and Transformer models. Our experimental results demonstrate that DPSGD consistently outperforms SSGD, across application domains and Neural Network (NN) architectures in the large batch setting, without any hyper-parameter tuning. To the best of our knowledge, DPSGD is the only generic algorithm that can improve SSGD large batch training and shorten learning rate warmup period for this many models/tasks. Furthermore, unlike other solutions, DPSGD does not require global synchronization.
|
| 88 |
+
|
| 89 |
+
85 The remainder of this paper is organized as follows. Section 2 details the problem formulation
|
| 90 |
+
86 and learning dynamics analysis of SSGD, ${ \bf S } { \bf S } { \bf G } { \bf D } ^ { * }$ , and DPSGD; Section 3 and Section 4 detail the
|
| 91 |
+
87 empirical results; Section 5 discusses related work; and Section 6 concludes the paper.
|
| 92 |
+
|
| 93 |
+
# 88 2 Analysis of stochastic learning dynamics in SSGD and DPSGD
|
| 94 |
+
|
| 95 |
+
89 We first formulate the dynamics of an SGD based learning algorithm with multiple $( n > 1 )$ ) learners
|
| 96 |
+
90 indexed by $j = 1 , 2 , 3 , . . . n$ following the same theoretical framework established for a single
|
| 97 |
+
91 learner [3]. At time (iteration) $t$ , each learner has its own weight vector $\vec { w } _ { j } ( t )$ , and the average
|
| 98 |
+
92 weight vector $\vec { w } _ { a } ( t )$ is defined as: $\begin{array} { r } { \vec { w } _ { a } ( t ) \equiv n ^ { - 1 } \sum _ { j = 1 } ^ { n } \vec { w } _ { j } ( t ) } \end{array}$ . Each learner $j$ updates its weight vector
|
| 99 |
+
93 according to the cross-entropy loss function $L ^ { \mu _ { j } ( t ) } ( \vec { w } )$ for minibatch $\mu _ { j } ( t )$ that is assigned to it at
|
| 100 |
+
94 time $t$ . The size of the local minibatch is $B$ , and the overall batch size for all learners is $n B$ . Two
|
| 101 |
+
95 multi-learner algorithms, SSGD and DPSGD, are described below.
|
| 102 |
+
|
| 103 |
+
(1) Synchronous Stochastic Gradient Descent (SSGD): In the synchronous algorithm, each learner $j \in [ 1 , n ]$ starts from the average weight vector $\vec { w } _ { a }$ and moves along the gradient of its local loss function $L ^ { \mu _ { j } ( t ) }$ evaluated at the average weight $\vec { w } _ { a }$ :
|
| 104 |
+
|
| 105 |
+
$$
|
| 106 |
+
\vec { w } _ { j } ( t + 1 ) = \vec { w } _ { a } ( t ) - \alpha \nabla L ^ { \mu _ { j } ( t ) } ( \vec { w } _ { a } ( t ) ) ,
|
| 107 |
+
$$
|
| 108 |
+
|
| 109 |
+
99 where $\alpha$ is the learning rate.
|
| 110 |
+
|
| 111 |
+
00 (2) Decentralized Parallel SGD (DPSGD): In the DPSGD algorithm [33], each learner $j$ computes
|
| 112 |
+
101 the gradient at its own local weight $\vec { w } _ { j } ( t )$ . The learning dynamics follows:
|
| 113 |
+
|
| 114 |
+
$$
|
| 115 |
+
\vec { w } _ { j } ( t + 1 ) = \vec { w } _ { s , j } ( t ) - \alpha \nabla L ^ { \mu _ { j } ( t ) } ( \vec { w } _ { j } ( t ) ) .
|
| 116 |
+
$$
|
| 117 |
+
|
| 118 |
+
where $\vec { w } _ { s , j } ( t )$ is the starting weight set to be the average weight of a subset of “neighboring" learners of learner- $j$ , which corresponds to the non-zero entries in the mixing matrix 2 defined in [33] (note that $\vec { w } _ { s , j } = \vec { w } _ { a }$ if all learners are included as neighbors).
|
| 119 |
+
|
| 120 |
+
05 By averaging over all learners, the learning dynamics for the average weight $\vec { w } _ { a }$ for both SSGD and
|
| 121 |
+
106 DPSGD can be written formally the same way as:
|
| 122 |
+
|
| 123 |
+
$$
|
| 124 |
+
\vec { w } _ { a } ( t + 1 ) = \vec { w } _ { a } ( t ) - \alpha \vec { g } _ { a } ,
|
| 125 |
+
$$
|
| 126 |
+
|
| 127 |
+
107 where $\begin{array} { r } { \vec { g } _ { a } = n ^ { - 1 } \sum _ { j = 1 } ^ { n } \vec { g } _ { j } } \end{array}$ is the average gradient and $\vec { g } _ { j }$ is the gradient from learner- $j$ . The difference
|
| 128 |
+
108 between SSGD and DPSGD is the weight at which $\vec { g } _ { j }$ is computed: $\vec { g } _ { j } \equiv \nabla L ^ { \mu _ { j } ( t ) } ( \vec { w } _ { a } ( t ) )$ is
|
| 129 |
+
109 computed at $\vec { w } _ { a }$ for SSGD; $\vec { g } _ { j } \equiv \nabla L ^ { \mu _ { j } ( t ) } ( \vec { w } _ { j } ( t ) )$ is computed at $\vec { w } _ { j }$ for DPSGD. The deviation of
|
| 130 |
+
110 the weight for learner- $j$ from the average weight is defined as $\delta \vec { w } _ { j } \equiv \vec { w } _ { j } - \vec { w } _ { a }$ . It is easy to see that
|
| 131 |
+
111 $\delta \vec { w } _ { j } ( t + 1 ) = \vec { w } _ { s , j } ( t ) - \vec { w } _ { a } ( t ) - \alpha [ \vec { g } _ { j } ( \bar { t } ) - \vec { g } _ { a } ( t ) ]$ , which depends on gradients at different points on
|
| 132 |
+
112 the loss landscape.
|
| 133 |
+
|
| 134 |
+
# 113 2.1 Understanding DPSGD from the Optimization Perspective
|
| 135 |
+
|
| 136 |
+
The main difference between DPSGD and SSGD is that the stochastic gradients are calculated at different weights in DPSGD, while SSGD’s stochastic gradient is calculated at the same weight. Intuitively, DPSGD explores more space than SSGD, which may help explain the empirical success of DPSGD. We formalize this intuition into the following theorem, which shows that DPSGD is optimizing a smoother landscape than SSGD.
|
| 137 |
+
|
| 138 |
+
119 Theorem 1. Denote $\mathcal { F } _ { t }$ by the filtration generated by all the random variables until the t-th iteration. Suppose n is large enough that120 $\begin{array} { r } { \left\| \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \nabla L ^ { \mu _ { i } ( t ) } ( \vec { w _ { i } } ( t ) ) - \frac { 1 } { n - 1 } \sum _ { i = 1 } ^ { n - 1 } \nabla L ^ { \mu _ { i } ( t ) } ( \vec { w _ { i } } ( t ) ) \right\| \leq \epsilon } \end{array}$
|
| 139 |
+
|
| 140 |
+
121 almost surely, and assume $\delta \vec { w } _ { i } ( t ) | \mathcal { F } _ { t - 1 } \stackrel { i . i . d . } { \sim } \mathcal { N } ( 0 , \sigma _ { w } ^ { 2 } I )$ with $i = 1 , \ldots , n - 1$ . Then from the
|
| 141 |
+
122 $( t - 1 )$ -th iteration to $t$ -th iteration, SSGD and DPSGD are doing one step of stochastic gradient
|
| 142 |
+
123 descent on two different functions $L ( w )$ and $\tilde { L } ( \vec { w } ) \equiv \mathbb { E } _ { \delta \vec { w } _ { i } ( t ) } \left[ L ( \vec { w } + \delta \vec { w } _ { i } ( t ) ) | \mathcal { F } _ { t - 1 } \right] ,$ , respectively.
|
| 143 |
+
124 The DPSGD loss $\tilde { L } ( w )$ is smoother than the SSGD loss $L ( \vec { w } ) i f L ( \vec { w } )$ is Lipschitz continuous.
|
| 144 |
+
125 Remark: The proof of Theorem 1 can be found in Appendix A. Here, we briefly mention its
|
| 145 |
+
126 implications. A function $f$ is defined as $l _ { s }$ -smooth if $\| \nabla \bar { f } ( x ) - \nabla f ( y ) \| \leq l _ { s } \| x - y \|$ for any $x , y$
|
| 146 |
+
127 where $l _ { s }$ is the smoothness parameter of $f$ . The landscape of the function $f$ is smoother when $l _ { s }$
|
| 147 |
+
128 is smaller. Assume $L ( w )$ is $G$ -Lipschitz continuous, i.e., $| L ( \vec { w } ) - L ( \vec { v } ) | \leq G \| \vec { w } - \vec { v } \|$ , then by
|
| 148 |
+
129 using Lemma 2 of [39], we know that the DPSGD landscape $\tilde { L } ( w )$ is $\frac { 2 G } { \sigma _ { w } }$ -smooth. According to the
|
| 149 |
+
130 convergence theory of SGD and DPSGD for nonconvex functions [11, 33, 12], the largest learning
|
| 150 |
+
131 rate one can choose to guarantee convergence is $\frac { 1 } { l _ { s } }$ . For SSGD with the original loss landscape $L , l _ { s }$
|
| 151 |
+
132 can be very large (even close to $+ \infty$ due to the nonsmooth nature of the ReLU activation) while $l _ { s }$ of
|
| 152 |
+
133 the smoothed loss function $\tilde { L }$ for DPSGD is much smaller. This explains why we can use a larger
|
| 153 |
+
134 learning rate in DPSGD as the landscape DPSGD sees has a smaller gradient-Lipschitz constant $l _ { s }$
|
| 154 |
+
135 than that in SSGD.
|
| 155 |
+
136 It is important to note that $l _ { s }$ of the smoothed loss function $\tilde { L }$ in DPSGD depends on the standard
|
| 156 |
+
137 deviation $\sigma _ { w }$ of weights from different learners. Since $\sigma _ { w }$ depends on the loss landscape and changes
|
| 157 |
+
138 with time (see Fig. 2(b)), the smoothing effect in DPSGD is self-adjusting – it is strong in the
|
| 158 |
+
139 initial stage of training when the loss landscape is rough and becomes weaker as training progresses
|
| 159 |
+
140 when the loss landscape becomes smoother. Our theoretical result suggests that this self-adjusting
|
| 160 |
+
141 smoothing effect is responsible for DPSGD’s convergence with a large learning rate in the large batch
|
| 161 |
+
142 size setting. Next, we elaborate on this insight and verify it in a simple network for classification
|
| 162 |
+
143 using the MNIST dataset.
|
| 163 |
+
144 Note that the Theorem 1 is only a one-step analysis. People may be interested in extending the
|
| 164 |
+
145 analysis to trajectory-based analysis. We provide a sketch here. If we consider the perturbed objective
|
| 165 |
+
146 $\tilde { L } ( w ) = \mathbb { E } _ { \delta } \left[ \bar { L } ( w + \delta ) \right]$ , where $\delta$ comes from the intrinsic noise of DPSGD, then we can utilize the
|
| 166 |
+
147 descent lemma as shown in [11] to prove that DPSGD can converge to a stationary point of $\tilde { L } ( w )$ in
|
| 167 |
+
148 polynomial time. However, without the inherent noise of DPSGD, the landscape is rough and that is
|
| 168 |
+
149 the reason why SSGD diverges. SSGD may not be able to converge to the stationary point of $L ( w )$
|
| 169 |
+
150 (since the large learning rate in large batch setting makes the descent lemma not applicable in this
|
| 170 |
+
151 case) or $\tilde { L } ( w )$ (since there is no noise and landscape-smoothing effect in SSGD, so SSGD does not
|
| 171 |
+
152 optimize the smoothed landscape). This is also consistent with our empirical evidence.
|
| 172 |
+
|
| 173 |
+
# 2.2 DPSGD Introduces a Landscape-Dependent Self-Adjusting Learning Rate that Helps Convergence
|
| 174 |
+
|
| 175 |
+
155 To understand the implication of the smoothing effect in DPSGD (Theorem 1) for learning dynamics,
|
| 176 |
+
156 we define an effective learning rate $\alpha _ { e } \equiv \alpha \vec { g } _ { a } \cdot \vec { g } / | | \vec { g } | | ^ { 2 }$ by projecting the weight displacement vector
|
| 177 |
+
157 $\Delta \vec { w } _ { a } \equiv \alpha \vec { g } _ { a }$ onto the direction of the gradient $\vec { g } \equiv \nabla L ( \vec { w } _ { a } )$ of the original loss function $L$ at $\vec { w } _ { a }$ .
|
| 178 |
+
158 The learning dynamics, Eq. 3, can be rewritten as:
|
| 179 |
+
|
| 180 |
+
$$
|
| 181 |
+
\vec { w } _ { a } ( t + 1 ) = \vec { w } _ { a } ( t ) - \alpha _ { e } \vec { g } + \vec { \eta } _ { \perp } ,
|
| 182 |
+
$$
|
| 183 |
+
|
| 184 |
+
159 where the “noise” term $\vec { \eta } _ { \perp } \equiv - \alpha \vec { g } _ { a } + \alpha _ { e } \vec { g }$ describes the random weight dynamics in directions
|
| 185 |
+
160 orthogonal to $\vec { g }$ . The noise term has zero mean $\langle \vec { \eta } _ { \perp } \rangle _ { \mu } = 0$ and the noise strength is characterized by
|
| 186 |
+
161 its variance $\Delta ( t ) \equiv | | \vec { \eta } _ { \perp } | | ^ { 2 }$ .
|
| 187 |
+
162 The effective learning rate $\alpha _ { e }$ is related to the noise strength: $\alpha _ { e } ^ { 2 } = ( \alpha ^ { 2 } | | \vec { g } _ { a } | | ^ { 2 } - \Delta ) / | | \vec { g } | | _ { - } ^ { 2 }$ , which
|
| 188 |
+
163 indicates that a higher noise strength $\Delta$ leads to a lower effective learning rate $\alpha _ { e }$ . The DPSGD noise
|
| 189 |
+
164 $\Delta _ { D P }$ is larger than the SSGD noise $\Delta _ { S }$ by an additional noise term $\Delta ^ { ( 2 ) } ( > 0 )$ that originates from
|
| 190 |
+
165 the difference of local weights $( \vec { w } _ { j } )$ from their mean $( \vec { w } _ { a } ) \colon \Delta _ { D P } = \Delta _ { S } + \Delta ^ { ( 2 ) }$ , see Appendix B for
|
| 191 |
+
|
| 192 |
+
details. By expanding 166 $\Delta ^ { ( 2 ) }$ w.r.t. $\delta \vec { w } _ { j }$ , we obtain the average $\Delta ^ { ( 2 ) }$ over minibatch ensemble $\{ \mu \}$ :
|
| 193 |
+
|
| 194 |
+
$$
|
| 195 |
+
\begin{array} { l } { { \displaystyle \langle \Delta ^ { ( 2 ) } \rangle _ { \mu } \equiv \alpha ^ { 2 } \langle | | n ^ { - 1 } \sum _ { j = 1 } ^ { n } [ \nabla L ^ { \mu _ { j } } ( \vec { w } _ { j } ) - \nabla L ^ { \mu _ { j } } ( \vec { w } _ { a } ) ] | | ^ { 2 } \rangle _ { \mu } } } \\ { { \displaystyle \approx \alpha ^ { 2 } \sum _ { k , l , l ^ { \prime } } H _ { k l } H _ { k l ^ { \prime } } C _ { l l ^ { \prime } } } , } \end{array}
|
| 196 |
+
$$
|
| 197 |
+
|
| 198 |
+
167 where $H _ { k l } = \nabla _ { k l } ^ { 2 } L$ is the Hessian matrix of the loss function and $\begin{array} { r } { C _ { l l ^ { \prime } } = n ^ { - 2 } \sum _ { j = 1 } ^ { n } \delta w _ { j , l } \delta w _ { j , l ^ { \prime } } } \end{array}$ is
|
| 199 |
+
168 the weight covariance matrix. From Eq. 5 and the dependence of on $\Delta$ , it is clear that the effective
|
| 200 |
+
169 learning rate in DPSGD depends directly on the loss landscape $( H )$ and indirectly via the weight
|
| 201 |
+
170 variance, $\sigma _ { w } ^ { 2 } = T r ( C )$ , which decreases as the loss landscape becomes smooth (see Fig. 2(b)).
|
| 202 |
+
171 It is important to stress that the noise $\vec { \eta } _ { \perp }$ in Eq.4 is not an artificially added noise. It is intrinsic to
|
| 203 |
+
172 the use of minibatches (random subsampling) in all SGD-based algorithms (including SSGD and
|
| 204 |
+
173 DPSGD). The noise is increased in DPSGD due to the weight difference among different learners
|
| 205 |
+
174 $( \delta \vec { w } _ { j } )$ . The noise strength $\Delta$ varies in weight space via its dependence on the loss landscape, as
|
| 206 |
+
175 explicitly shown in Eq. 5. However, besides its landscape dependence, SGD noise scales inversely
|
| 207 |
+
176 with the minibatch size $B$ [3]. With $n$ synchronized learners, the noise in SSGD scales as $1 / ( n B )$ ,
|
| 208 |
+
177 which is too small to be effective for a large batch size $n B$ . A main finding of our paper is that the
|
| 209 |
+
178 additional landscape-dependent noise $\Delta ^ { ( 2 ) }$ in DPSGD can make up for the small SSGD noise when
|
| 210 |
+
179 $n B$ is large and help enhance convergence in the large batch setting.
|
| 211 |
+
180 The landscape dependent smoothing effect in DPSGD (shown in Sec. 2.1) indicates that $\alpha _ { e }$ in DPSGD
|
| 212 |
+
181 is reduced at the beginning of training when the landscape is rough. To demonstrate effects of the
|
| 213 |
+
182 landscape-dependent self-adjusting learning rates, we did detailed analysis in numerical experiments
|
| 214 |
+
183 using the MNIST dataset. In this experiment, we used $n = 5$ learners with each learner a fully
|
| 215 |
+
184 connected network with two hidden layers (50 units per layer) and we used $\vec { w } _ { s , j } = \vec { w } _ { a }$ for DPSGD.
|
| 216 |
+
185 We focused on the large batch setting using $n B = 2 0 0 0$ and a large learning rate $\alpha = 1$ . As shown
|
| 217 |
+
186 in Fig. 2(a), DPSGD converges to a solution with a low loss $2 . { \bar { 1 } } \%$ test error), but SSGD fails to
|
| 218 |
+
187 converge.
|
| 219 |
+
188 To understand the convergence in DPSGD, we computed the effective learning rate $( \alpha _ { e } )$ and the
|
| 220 |
+
189 weight variance $( \sigma _ { w } ^ { 2 } )$ during training. As shown in Fig. 2(b) (upper panel), the effective learning rate
|
| 221 |
+
190 $\alpha _ { e }$ is reduced in DPSGD during early training $0 \leq t \leq 7 0 0 )$ ). This reduction of $\alpha _ { e }$ is caused by the
|
| 222 |
+
191 stronger noise $\Delta ^ { ( 2 ) }$ in DPSGD (see Fig. 4 in Appendix B), which is essential for convergence when
|
| 223 |
+
192 gradients are large in the beginning of the training process. In the later stage of the training process
|
| 224 |
+
193 when gradients are smaller, the landscape-dependent DPSGD noise decreases and $\alpha _ { e }$ automatically
|
| 225 |
+
194 increases back to be $\approx \alpha$ to allow fast convergence. From Eq. 5, the landscape-dependent noise in
|
| 226 |
+
|
| 227 |
+

|
| 228 |
+
Figure 2: (a) Comparison of different multi-learner algorithms, DPSGD (green), SSGD (red), and ${ \bf S } { \bf S } { \bf G } { \bf D } ^ { * }$ (blue) for a large learning rate $\alpha = 1$ . The adaptive learning rate allows DPSGD to converge while SSGD fails to converge. A fine-tuned ${ \bf S } { \bf S } { \bf G } { \bf D } ^ { * }$ also converges but to an inferior solution. (b) The effective learning rate for DPSGD $\alpha _ { e } ( D P S G D )$ is self-adaptive to the landscape – it is reduced in the beginning of training when gradients are large and recovers to $\sim \alpha$ when the gradients are small. The weight variance $\sigma _ { w } ^ { 2 } \overline { { ( t ) } }$ has the opposite landscape-dependence as $\alpha _ { e }$ and decreases with training time.
|
| 229 |
+
|
| 230 |
+
<table><tr><td colspan="2"></td><td>AlexNet</td><td>VGG</td><td>VGG-BN</td></tr><tr><td>bs=256 lr=1x</td><td>Baseline</td><td>56.31/79.05 lr=0.01</td><td>69.02/88.66</td><td>70.65/89.92 lr=0.1</td></tr><tr><td>bs=2048 lr=8x</td><td>SSGD DPSGD</td><td>54.29/77.43 53.71/76.91</td><td>67.67/87.91 67.28/87.58</td><td>70.36/89.58 69.76/89.31</td></tr><tr><td>bs=4096 lr=16x</td><td>SSGD DPSGD</td><td>0.10/0.50 52.53/76.01</td><td>0.10/0.50 66.44/87.20</td><td>65.39/86.51 68.86/88.82</td></tr><tr><td>bs=8192 lr=32x</td><td>SSGD DPSGD</td><td>0.10/0.50 49.01/73.00</td><td>0.10/0.50 65.00/86.11</td><td>0.10/0.50 63.55/85.43</td></tr></table>
|
| 231 |
+
|
| 232 |
+
Table 1: ImageNet-1K Top-1/Top-5 model accuracy $( \% )$ comparison for batch size 2048, 4096 and 8192. All experiments are conducted on 16 GPUs (learners), with batch size per GPU 128, 256 and 512 respectively. Bold text represents the best model accuracy achieved given the specific batch size and learning rate. The batch size 256 baseline is presented for reference. bs stands for batch-size, lr stands for learning rate. Baseline lr is set to 0.01 for AlexNet and VGG11, 0.1 for the other models. In the large batch setting, we use learning rate warmup and linear scaling as prescribed in [12]. For rough loss landscape like AlexNet and VGG, SSGD diverges when batch size is large whereas DPSGD converges.
|
| 233 |
+
|
| 234 |
+
195 DPSGD depends on the weight variance. As shown in Fig. 2(b) (lower panel), the weight variance
|
| 235 |
+
196 $\sigma _ { w } ^ { 2 }$ has a time-dependent trend that is opposite to $\alpha _ { e } \colon \sigma _ { w } ^ { 2 }$ is large in the beginning of training when
|
| 236 |
+
197 the landscape is rough and decreases as training progresses and the landscape becomes smoother.
|
| 237 |
+
198 To show the importance of the landscape-dependent weight variance, we used ${ \bf S } { \bf S } { \bf G } { \bf D } ^ { * }$ , which injects
|
| 238 |
+
199 a Gaussian noise with a constant variance to weights in SSGD, i.e., by setting $\delta \vec { w } _ { j } \stackrel { i . i . d . } { \sim } \mathcal { N } ( 0 , \sigma _ { 0 } ^ { 2 } I )$
|
| 239 |
+
200 with a constant $\sigma _ { 0 } ^ { 2 }$ . We found that ${ \bf S } { \bf S } { \bf G } { \bf D } ^ { * }$ fails to converge for most choices of noise strength $\sigma _ { 0 } ^ { 2 }$ .
|
| 240 |
+
201 Only by fine tuning $\sigma _ { 0 } ^ { 2 }$ can ${ \bf S } { \bf S } { \bf G } { \bf D } ^ { * }$ converge, but to an inferior solution with much higher loss and
|
| 241 |
+
202 test error $( 5 . 7 \% )$ as shown in Fig. 2(a).
|
| 242 |
+
203 Finally, in addition to helping convergence, we found that the landscape-dependent noise in DPSGD
|
| 243 |
+
204 can also help find flat minima with better generalization in the large batch setting (see Appendix C
|
| 244 |
+
205 for details).
|
| 245 |
+
|
| 246 |
+
# 206 3 Experimental Methodology
|
| 247 |
+
|
| 248 |
+
207 We implemented SSGD and DPSGD using PyTorch, OpenMPI, and NVidia NCCL. We ran exper
|
| 249 |
+
208 iments on a cluster of two 8-V100-GPU $\mathbf { \boldsymbol { x } } 8 6$ servers. For CV tasks, we evaluated on CIFAR-10
|
| 250 |
+
209 (50,000 training samples, 178MB) and ImageNet-1K (1.2 million training samples, 140GB). For
|
| 251 |
+
210 ASR tasks, we evaluated on SWB-300 (300 hours training data, 4,000,000 samples, 30GB) and
|
| 252 |
+
211 SWB-2000 (2000 hours training data, 30,000,000 samples, 216GB). For the NLP task, we evaluated
|
| 253 |
+
212 on Wikitext-103(103 million tokens, 180MB). In all, we evaluate 18 state-of-the-art NN models: 15
|
| 254 |
+
213 CNN models, 2 6-layer bi-directional LSTM models, and 1 16-layer GPT-2 transformer model. We
|
| 255 |
+
214 summarize the model sizes and training times in Table 6 of Appendix D. Also refer to Appendix D for
|
| 256 |
+
215 hardware configuration, software implementation, dataset and Neural Network (NN) model details.
|
| 257 |
+
|
| 258 |
+
# 216 4 Experimental Results
|
| 259 |
+
|
| 260 |
+
217 All the large batch experiments are conducted on 16 GPUs (learners). Batches are evenly distributed
|
| 261 |
+
218 among learners, e.g., with sixteen learners, each learner uses a local batch size that is one sixteenth
|
| 262 |
+
219 the overall batch size. A learner randomly picks a neighbor with which to exchange weights in each
|
| 263 |
+
220 DPSGD iteration [59].
|
| 264 |
+
|
| 265 |
+
# 4.1 SSGD and DPSGD Comparison on CV Tasks (CIFAR-10 and ImageNet-1K)
|
| 266 |
+
|
| 267 |
+
2 On ImageNet-1K we test 6 CNN models – AlexNet, VGG11, VGG11-BN, ResNet-50, ResNext-50
|
| 268 |
+
3 and DenseNet-161. Among them, AlexNet and VGG have rougher loss landscapes and can only
|
| 269 |
+
work with smaller learning rates, while VGG11-BN, ResNet-50, ResNext-50, and DenseNet-161
|
| 270 |
+
25 have smoother loss landscapes thanks to the use of BatchNorm or Residual Connections, and thus
|
| 271 |
+
6 can work with larger learning rates. We use the same baseline training recipe prescribed in [4]:
|
| 272 |
+
227 batch size 256, initial learning rate 0.01 for AlexNet and VGG-11 and 0.1 for the other 4 models,
|
| 273 |
+
228 learning rate anneals by 0.1 every 30 epochs, 100 epochs in total. To study the model performance
|
| 274 |
+
229 in the large batch setting, we follow the large batch size learning rate schedule prescribed in [12]:
|
| 275 |
+
230 learning rate warmup for the first 5 epochs and then learning rate linear scaling w.r.t batch size.
|
| 276 |
+
231 For example, in the AlexNet batch-size 8192 experiment, the learning rate is gradually warmed-up
|
| 277 |
+
232 from 0.01 to 0.32 in the first 5 epochs, annealed to 0.032 from epoch 31 to epoch 60, annealed to
|
| 278 |
+
233 0.0032 from epoch 61 to epoch 90, and annealed to 0.00032 from epoch 91 to epoch 100. SSGD and
|
| 279 |
+
234 DPSGD achieve comparable model accuracy in the large batch setting (see Table 10 in Appendix E.6).
|
| 280 |
+
235 Most noticeably, when batch-size increases to 8192, SSGD diverges with AlexNet, VGG11, and
|
| 281 |
+
236 VGG11-BN whereas DPSGD converges as shown in Table 1. Figure 9 in Appendix E.6 details the
|
| 282 |
+
237 model accuracy progression versus epochs in each setting. Please see our detailed analysis of DPSGD
|
| 283 |
+
238 vs SSGD on CIFAR-10 tasks throughout Appendix E.1 to Appendix E.5 where we document the
|
| 284 |
+
239 DPSGD and SSGD comparison and loss landscape visualization (contour 2D projection and Hessian
|
| 285 |
+
240 2D projection), which show that DPSGD usually leads to much flatter optima than SSGD, and thus
|
| 286 |
+
241 better generalization in the large batch setting.
|
| 287 |
+
|
| 288 |
+
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=3>SWB-300</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>bs2048</td><td rowspan=1 colspan=1>bs4096</td><td rowspan=1 colspan=1>bs8192</td></tr><tr><td rowspan=1 colspan=1>SSGD</td><td rowspan=1 colspan=1>1.58</td><td rowspan=1 colspan=1>10.37</td><td rowspan=1 colspan=1>10.37</td></tr><tr><td rowspan=1 colspan=1>DPSGD</td><td rowspan=1 colspan=1>1.59</td><td rowspan=1 colspan=1>1.60</td><td rowspan=1 colspan=1>1.66</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=2>SWB-2000</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>bs2048</td><td rowspan=1 colspan=1>bs4096</td><td rowspan=1 colspan=1>bs8192</td></tr><tr><td rowspan=1 colspan=1>SSGD</td><td rowspan=1 colspan=1>1.46</td><td rowspan=1 colspan=1>1.46</td><td rowspan=1 colspan=1>10.37</td></tr><tr><td rowspan=1 colspan=1>DPSGD</td><td rowspan=1 colspan=1>1.45</td><td rowspan=1 colspan=1>1.47</td><td rowspan=1 colspan=1>1.47</td></tr></table>
|
| 289 |
+
|
| 290 |
+
Table 2: Heldout loss comparison for SSGD and DPSGD, evaluated on SWB-300 and SWB-2000. There are 32000 classes in this task, a held-out loss 10.37 (i.e. $l n ^ { 3 2 0 0 0 }$ ) indicates a complete divergence. bs stands for batch size.
|
| 291 |
+
|
| 292 |
+

|
| 293 |
+
Figure 3: SSGD diverges when the learning rate warmup period is 75 iterations while DPSGD converges with a warmup period as short as 25 iterations. (Wikitext103, GPT-2)
|
| 294 |
+
|
| 295 |
+
Summary For rough loss landscapes like AlexNet and VGG, DPSGD converges whereas SSGD diverges in the large batch setting.
|
| 296 |
+
|
| 297 |
+
# 4.2 SSGD and DPSGD Comparison on ASR tasks
|
| 298 |
+
|
| 299 |
+
Unlike CV tasks where CNNs and their residual connection variants are the dominant models, ASR tasks overwhelmingly adopt RNN/LSTM models that capture sequence features. Furthermore, BatchNorm is known not to work well in RNN/LSTM tasks [31]. Finally, there are over 32,000 different classes with wildy uneven distribution in our ASR tasks due to the Zipfian characteristics of natural language. All in all, ASR tasks present a much more challenging loss landscape than CV tasks to optimize over.
|
| 300 |
+
|
| 301 |
+
For the SWB-300 and SWB-2000 tasks, we follow the same learning rate schedule proposed in [57]: we use learning rate 0.1 for baseline batch size 256, and linearly warmup the learning rate w.r.t the baseline batch size for the first 10 epochs before annealing the learning rate by $\scriptstyle { \frac { 1 } { \sqrt { 2 } } }$ for the remaining 10 epochs. For example, when using a batch size 2048, we linearly warmup the learning rate to 0.8 by the end of the 10th epoch before annealing. Table 2 illustrates heldout loss for SWB-300 and SWB-2000. In the SWB-300 task, SSGD diverges beyond batch size 2048 and DPSGD converges well until batch size 8192. In the SWB-2000 task, SSGD diverges beyond batch size 4096 and DPSGD converges well until batch size 8192. Figure 10 in Appendix E.7 details the heldout loss progression versus epochs.
|
| 302 |
+
|
| 303 |
+
Summary For ASR tasks, SSGD diverges whereas DPSGD converges to baseline model accuracy in the large batch setting.
|
| 304 |
+
|
| 305 |
+
# 4.3 Noise-injection and Learning Rate Tuning
|
| 306 |
+
|
| 307 |
+
263 In 6 out of 17 studied CV and ASR tasks, a large batch setting leads to a complete divergence in
|
| 308 |
+
64 SSGD: EfficientNet-B0, AlexNet, VGG11, VGG11-BN, SWB-300 and SWB-2000. As discussed in
|
| 309 |
+
265 Section 2, the intrinsic landscape-dependent noise in DPSGD effectively helps escape early traps (e.g.,
|
| 310 |
+
266 saddle points) and improves training by automatically adjusting the learning rate. In this section, we
|
| 311 |
+
267 demonstrate these facts by systematically adding Gaussian noise (the same as the $S S G D ^ { * }$ algorithm
|
| 312 |
+
268 in Section 2) and decreasing the learning rate. We find that SSGD might escape early traps but still
|
| 313 |
+
269 results in a much inferior model compared to DPSGD.
|
| 314 |
+
270 Noise-injection In Figure 1, we systematically explore Gaussian noise injection with mean 0 and
|
| 315 |
+
271 standard deviation (std) ranging from 10 to 0.00001 via binary search (i.e. roughly 20 configurations
|
| 316 |
+
272 for each task). We found in the vast majority of the setups, noise-injection cannot escape early
|
| 317 |
+
273 traps. In EfficientNet-B0, only when std is set to 0.04, does the model start to converge, but to a
|
| 318 |
+
274 very low accuracy (test accuracy $2 2 . 1 5 \%$ in SSGD vs $9 1 . 1 3 \%$ in DPSGD). In the SWB-300 case,
|
| 319 |
+
275 when std is 0.01, SSGD shows an early sign of converging for the first 3 epochs before it starts to
|
| 320 |
+
276 diverge. In the AlexNet, VGG11, VGG11-BN, and SWB-2000 cases, we didn’t find any configuration
|
| 321 |
+
277 that can escape early traps. Figure 1 characterizes our best-effort Gaussian noise tuning and its
|
| 322 |
+
278 comparison against SSGD and DPSGD. A plausible explanation is that Gaussian noise injection
|
| 323 |
+
279 escapes saddle points very slowly, since Gaussian noise is isotropic and the complexity for finding
|
| 324 |
+
280 local minima is dimension-dependent [10]. Deep Neural Networks are usually over-parameterized
|
| 325 |
+
281 (i.e., high-dimensional), so it may take a long time to escape local traps. In contrast, the heightened
|
| 326 |
+
282 landscape-dependent noise in DPSGD is anisotropic [3, 8] and can drive the system to escape in the
|
| 327 |
+
283 right directions.
|
| 328 |
+
284 Learning Rate Tuning To make otherwise-divergent SSGD training converge in the large batch
|
| 329 |
+
285 setting, we systematically tune down the learning rates. Table 3 and Table 4 compare the model quality
|
| 330 |
+
286 trained by SSGD and DPSGD using smaller learning rates in the large batch setting, for ImageNet and
|
| 331 |
+
|
| 332 |
+
Table 3: ImageNet-1K learning rate tuning for AlexNet VGG11, VGG11-BN with batch-size 8192. Bold text in each column indicates the best top-1/top-5 accuracy achieved across different learning rate and optimization method configurations for the corresponding batch size. DPSGD consistently delivers the most accurate models. \*The learning rate 1x used here corresponds to batch size 256 baseline learning rate, and we still adopt the same learning rate warmup, scaling and annealing schedule. Thus $3 2 \mathrm { x }$ refers to linear learning rate scaling when batch size is 8192. By reducing learning rate to 16x, ${ 8 } \mathbf { x }$ and $_ { 4 \mathrm { X } }$ , SSGD can escape early traps but still lags behind compared to DPSGD in most cases.
|
| 333 |
+
|
| 334 |
+
<table><tr><td colspan="3">AlexNet</td><td>VGG11</td><td>VGG11-BN</td></tr><tr><td rowspan="2">lr*=32x</td><td>SSGD</td><td>0.10/0.50</td><td>0.10/0.50</td><td>0.10/0.50</td></tr><tr><td>DPSGD</td><td>49.010/73.00</td><td>65.004/86.11</td><td>63.546/85.43</td></tr><tr><td rowspan="2">lr=16x</td><td>SSGD</td><td>0.10/0.50</td><td>0.10/0.50</td><td>70.11/89.47</td></tr><tr><td>DPSGD</td><td>49.26/73.14</td><td>62.046/83.98</td><td>69.108/89.07</td></tr><tr><td rowspan="2">lr=8x</td><td>SSGD</td><td>46.40/70.25</td><td>45.32/70.61</td><td>69.54/89.22</td></tr><tr><td>DPSGD</td><td>47.78/71.89</td><td>56.52/79.92</td><td>68.98/88.78</td></tr><tr><td rowspan="2">lr=4x</td><td>SSGD</td><td>41.77/66.44</td><td>50.20/74.83</td><td>68.61/88.57</td></tr><tr><td>DPSGD</td><td>42.18/66.96</td><td>48.52/73.33</td><td>67.98/88.22</td></tr></table>
|
| 335 |
+
|
| 336 |
+
Table 4: Decreasing learning rate for SWB-300 and SWB-2000 (bs stands for batch-size). Bold text in each column indicates the best held-out loss achieved across different learning rate and optimization method configurations for the corresponding batch size. DPSGD consistently delivers the most accurate models. \*learning rate 1.6 is used for bs4096 and learning rate 3.2 is used for bs8192. We still adopt the same learning rate warmup, scaling and annealing schedule (baseline learning rate is 0.1 for batch size 256).
|
| 337 |
+
|
| 338 |
+
<table><tr><td colspan="2"></td><td>SWB-300 (bs4096)</td><td>SWB-300 (bs8192)</td><td>SWB-2000 (bs 8192)</td></tr><tr><td rowspan="2">lr*=1.6/3.2</td><td>SSGD</td><td>10.37</td><td>10.37</td><td>10.37</td></tr><tr><td>DPSGD</td><td>1.60</td><td>1.66</td><td>1.47</td></tr><tr><td rowspan="2">lr=0.8/1.6</td><td>SSGD</td><td>10.37</td><td>10.37</td><td>10.37</td></tr><tr><td>DPSGD</td><td>1.65</td><td>1.73</td><td>1.48</td></tr><tr><td rowspan="2">lr=0.4/0.8</td><td>SSGD</td><td>1.76</td><td>10.37</td><td>1.51</td></tr><tr><td>DPSGD</td><td>1.77</td><td>1.80</td><td>1.52</td></tr><tr><td rowspan="2">lr=0.2/0.4</td><td>SSGD</td><td>1.92</td><td>2.05</td><td>1.58</td></tr><tr><td>DPSGD</td><td>1.94</td><td>2.00</td><td>1.59</td></tr></table>
|
| 339 |
+
|
| 340 |
+
ASR tasks. Table 9 in Appendix E.3 illustrates the similar learning rate tuning effort for CIFAR-10 tasks. As we can see, by using a smaller learning rate, SSGD can escape early traps and converge, however it consistently lags behind DPSGD in the large batch setting. Morever, DPSGD does not depend on such an exhaustive learning rate tuning to achieve convergence. DPSGD can simply follow the learning rate warm-up and linear scaling rules [12] whereas SSGD requires much more stringent learning rate tuning. This implies DPSGD practitioners enjoy a much larger degree of freedom when it comes to hyper-parameter tuning in the large batch setting than the SSGD practitioners.
|
| 341 |
+
|
| 342 |
+
Summary By systematically introducing landscape-independent noise and reducing the learning rate, SSGD could escape early traps (e.g., saddle points), but results in much inferior models compared to DPSGD in the large batch setting.
|
| 343 |
+
|
| 344 |
+
# 4.4 DPSGD and SSGD Runtime Comparison
|
| 345 |
+
|
| 346 |
+
In Appendix F, we detail runtime comparison between DPSGD and SSGD and demonstrate DPSGD consistently runs faster than SSGD. We also compare DPSGD with LAMB[55], a state-of-the-art optimizer specifically designed for synchronous large-batch training, demonstrating that DPSGD can avoid straggler problems in distributed training.
|
| 347 |
+
|
| 348 |
+
# 4.5 SSGD and DPSGD Comparison on NLP tasks (Wikitext-103)
|
| 349 |
+
|
| 350 |
+
For NLP tasks such as Masked Language Modeling (MLM) [6, 50], a careful learning rate warmup scheme needs to be designed so that learning rate grows from 0 to a desired learning rate gradually. Too short a warmup period often leads to divergence and practitioners need to restart training, which wastes huge computational resources[42, 52, 56]. We test our theory by finding the shortest viable learning rate warmup period for SSGD and DPSGD. We use the hyper-parameter settings prescribed in [52], warmup learning rate 0 to $2 . 5 \times 1 0 ^ { - 4 }$ in the first 64000 samples (i.e., 250 iterations of batch size 256) and then cosine-annealing to zero on top of an Adam optimizer. We then shorten the learning rate warmup period and check convergence. Figure 3 and Table 5 show that SSGD diverges when the learning rate warmup period is shorter than 100 iterations, while DPSGD converges with a warmup period as short as 25 iterations. Figure 1c shows that injecting independent random noise into SSGD (in the same fashion as Section 4.3) does not help SSGD escape early training traps. These experiments corroborate our theory that DPSGD can leverage loss landscape noise to self-adjust the learning rate.
|
| 351 |
+
|
| 352 |
+
<table><tr><td>Warmup(iters)</td><td>250</td><td>100</td><td>75</td><td>50</td><td>25</td><td>15</td></tr><tr><td>SYNC</td><td>3.09</td><td>3.07</td><td>7.26</td><td>7.26</td><td>7.26</td><td>7.26</td></tr><tr><td>DPSGD</td><td>3.08</td><td>3.053</td><td>3.06</td><td>3.08</td><td>3.09</td><td>7.26</td></tr></table>
|
| 353 |
+
|
| 354 |
+
Table 5: Validation loss comparison when shortening the learning rate warmup period. DPSGD can converge with a much shorter warmup. All experiments are conducted on 16 GPUs (learners). Wikitext-103, GPT-2 model, 200 epochs training in total.
|
| 355 |
+
|
| 356 |
+
# 5 Related Works
|
| 357 |
+
|
| 358 |
+
Please see Appendix G
|
| 359 |
+
|
| 360 |
+
# 6 Conclusion
|
| 361 |
+
|
| 362 |
+
In this paper, we find that in the large-batch and large-learning-rate setting, DPSGD yields comparable model accuracy when SSGD converges; moreover, DPSGD converges when SSGD diverges. We then investigate why DPSGD outperforms SSGD for large batch training. Through detailed analysis on small-scale tasks and an extensive empirical study of a diverse set of modern DL tasks, we conclude that the landscape-dependent noise, which is strengthened in the DPSGD system, self-adjusts the effective learning rate according to the loss landscape, helping convergence. This self-adjusting learning rate effect is a mere by-product of the inherent loss-landscape-dependent-noise of the DPSGD training algorithm and requires no additional computation, no additional communication and no additional hyper-parameter tuning. The theory was originally developed to understand why DPSGD outperforms SSGD in the large batch setting for CV and ASR tasks. The same theory can be also verified in NLP tasks where when a carefully designed learning rate warmup scheme is required.
|
| 363 |
+
|
| 364 |
+
References [1] Carlo Baldassi, Christian Borgs, Jennifer T. Chayes, Alessandro Ingrosso, Carlo Lucibello, Luca Saglietti, and Riccardo Zecchina. Unreasonable effectiveness of learning neural networks: From accessible states and robust ensembles to basic algorithmic schemes. Proceedings of the National Academy of Sciences, 113(48):E7655–E7662, 2016. [2] Pratik Chaudhari, Anna Choromanska, Stefano Soatto, Yann LeCun, Carlo Baldassi, Christian Borgs, Jennifer Chayes, Levent Sagun, and Riccardo Zecchina. Entropy-sgd: Biasing gradient descent into wide valleys, 2016. [3] Pratik Chaudhari and Stefano Soatto. Stochastic gradient descent performs variational inference, converges to limit cycles for deep networks. 2018 Information Theory and Applications Workshop (ITA), Feb 2018.
|
| 365 |
+
[4] Soumith Chintala. PyTorch ImageNet Examples, 2020. Available at https://github.com/pytorch/ examples/tree/master/imagenet. [5] J. Deng, W. Dong, R. Socher, L. Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE Conference on Computer Vision and Pattern Recognition, pages 248–255, 2009. [6] 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.
|
| 366 |
+
[7] Gintare Karolina Dziugaite and Daniel M Roy. Computing nonvacuous generalization bounds for deep (stochastic) neural networks with many more parameters than training data. arXiv preprint arXiv:1703.11008, 2017. [8] Yu Feng and Yuhai Tu. The inverse variance–flatness relation in stochastic gradient descent is critical for finding flat minima. Proceedings of the National Academy of Sciences, 118(9), 2021. [9] Pierre Foret, Ariel Kleiner, Hossein Mobahi, and Behnam Neyshabur. Sharpness-aware minimization for efficiently improving generalization. ICLR, 2021.
|
| 367 |
+
[10] Rong Ge, Furong Huang, Chi Jin, and Yang Yuan. Escaping from saddle points—online stochastic gradient for tensor decomposition. In Conference on Learning Theory, pages 797– 842, 2015.
|
| 368 |
+
[11] Saeed Ghadimi and Guanghui Lan. Stochastic first-and zeroth-order methods for nonconvex stochastic programming. SIAM Journal on Optimization, 23(4):2341–2368, 2013.
|
| 369 |
+
[12] Priya Goyal, Piotr Dollár, Ross B. Girshick, Pieter Noordhuis, Lukasz Wesolowski, Aapo Kyrola, Andrew Tulloch, Yangqing Jia, and Kaiming He. Accurate, large minibatch SGD: training imagenet in 1 hour. CoRR, abs/1706.02677, 2017.
|
| 370 |
+
[13] Vipul Gupta, Santiago Akle Serrano, and Dennis DeCoste. Stochastic weight averaging in parallel: Large-batch training that generalizes well. ICLR, 2020.
|
| 371 |
+
[14] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. CVPR, 2015.
|
| 372 |
+
[15] Geoffrey Hinton, Li Deng, Dong Yu, George Dahl, Abdel rahman Mohamed, Navdeep Jaitly, Andrew Senior, Vincent Vanhoucke, Patrick Nguyen, Tara Sainath, and Brian Kingsbury. Deep neural networks for acoustic modeling in speech recognition. Signal Processing Magazine, 2012.
|
| 373 |
+
[16] Geoffrey E. Hinton and Drew van Camp. Keeping the neural networks simple by minimizing the description length of the weights. In Proceedings of the Sixth Annual Conference on Computational Learning Theory, COLT ’93, pages 5–13, New York, NY, USA, 1993. ACM.
|
| 374 |
+
[17] Sepp Hochreiter and Jürgen Schmidhuber. Flat minima. Neural Computation, 9(1):1–42, 1997.
|
| 375 |
+
[18] Elad Hoffer, Itay Hubara, and Daniel Soudry. Train longer, generalize better: closing the generalization gap in large batch training of neural networks. In Advances in Neural Information Processing Systems, pages 1731–1741, 2017. [19] Andrew G. Howard, Menglong Zhu, Bo Chen, Dmitry Kalenichenko, Weijun Wang, Tobias Weyand, Marco Andreetto, and Hartwig Adam. Mobilenets: Efficient convolutional neural networks for mobile vision applications. CoRR, abs/1704.04861, 2017. [20] G. Huang, Z. Liu, L. Van Der Maaten, and K. Q. Weinberger. Densely connected convolutional networks. In 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 2261–2269, 2017.
|
| 376 |
+
387 [21] Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. ICML, 2015. [22] Stanisław Jastrz˛ebski, Zachary Kenton, Devansh Arpit, Nicolas Ballas, Asja Fischer, Yoshua Bengio, and Amos Storkey. Three factors influencing minima in sgd. arXiv preprint arXiv:1711.04623, 2017. [23] Stanislaw Jastrzebski, Zachary Kenton, Devansh Arpit, Nicolas Ballas, Asja Fischer, Yoshua Bengio, and Amos J Storkey. Finding flatter minima with sgd. In ICLR (Workshop), 2018. [24] Nitish Shirish Keskar, Dheevatsa Mudigere, Jorge Nocedal, Mikhail Smelyanskiy, and Ping Tak Peter Tang. On large-batch training for deep learning: Generalization gap and sharp minima. arXiv preprint arXiv:1609.04836, 2016. [25] D. P. Kingma and J. L. Ba. ADAM: a method for stochastic optimization. In International Conference on Learning Representations (ICLR), 2015. [26] Robert Kleinberg, Yuanzhi Li, and Yang Yuan. An alternative view: When does sgd escape local minima? arXiv preprint arXiv:1802.06175, 2018. [27] Anastasia Koloskova, Sebastian Stich, and Martin Jaggi. Decentralized stochastic optimization and gossip algorithms with compressed communication. In International Conference on Machine Learning, pages 3478–3487. PMLR, 2019. [28] Alex Krizhevsky and Geoffrey Hinton. Learning multiple layers of features from tiny images. Computer Science Department, University of Toronto, Tech. Rep, 1(4):7, 2009. [29] Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. In Advances in neural information processing systems, pages 1097–1105, 2012. [30] Sameer Kumar, Victor Bitorff, Dehao Chen, Chiachen Chou, Blake Hechtman, HyoukJoong Lee, Naveen Kumar, Peter Mattson, Shibo Wang, Tao Wang, Yuanzhong Xu, and Zongwei Zhou. Scale MLPerf-0.6 models on Google TPU-v3 Pods. arXiv e-prints, page arXiv:1909.09756, September 2019. [31] César Laurent, Gabriel Pereyra, Philémon Brakel, Ying Zhang, and Yoshua Bengio. Batch normalized recurrent neural networks, 2016. [32] Hao Li, Zheng Xu, Gavin Taylor, Christoph Studer, and Tom Goldstein. Visualizing the loss landscape of neural nets. In S. Bengio, H. Wallach, H. Larochelle, K. Grauman, N. CesaBianchi, and R. Garnett, editors, Advances in Neural Information Processing Systems 31, pages 6389–6399. Curran Associates, Inc., 2018. [33] Xiangru Lian, Ce Zhang, Huan Zhang, Cho-Jui Hsieh, Wei Zhang, and Ji Liu. Can decentralized algorithms outperform centralized algorithms? a case study for decentralized parallel stochastic gradient descent. In Advances in Neural Information Processing Systems, pages 5330–5340, 2017. [34] Xiangru Lian, Wei Zhang, Ce Zhang, and Ji Liu. Asynchronous decentralized parallel stochastic gradient descent. In ICML, 2018. [35] Tao Lin, Lingjing Kong, Sebastian Stich, and Martin Jaggi. Extrapolation for large-batch training in deep learning. In Hal Daumé III and Aarti Singh, editors, Proceedings of the 37th International Conference on Machine Learning, volume 119 of Proceedings of Machine Learning Research, pages 6094–6104. PMLR, 13–18 Jul 2020.
|
| 377 |
+
429 [36] Tao Lin, Sebastian U. Stich, and Martin Jaggi. Don’t use large mini-batches, use local SGD. ICLR, 2020. [37] Kang Liu. Train CIFAR10 with PyTorch, 2020. Available at https://github.com/kuangliu/pytorchcifar.
|
| 378 |
+
433 [38] Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. Pointer sentinel mixture models. ICLR, 2017. [39] Yurii Nesterov and Vladimir Spokoiny. Random gradient-free minimization of convex functions. Foundations of Computational Mathematics, 17(2):527–566, 2017.
|
| 379 |
+
437 [40] Behnam Neyshabur, Srinadh Bhojanapalli, David McAllester, and Nati Srebro. Exploring generalization in deep learning. In Advances in Neural Information Processing Systems, pages 5947–5956, 2017. [41] Behnam Neyshabur, Srinadh Bhojanapalli, and Nathan Srebro. A pac-bayesian approach to spectrally-normalized margin bounds for neural networks. arXiv preprint arXiv:1707.09564, 2017. [42] Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving language understanding by generative pre-training. 2018. [43] Alec Radford, Jeff Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. 2019. [44] Sashank J. Reddi, Satyen Kale, and Sanjiv Kumar. On the convergence of adam and beyond. In International Conference on Learning Representations, 2018. [45] Mark Sandler, Andrew G. Howard, Menglong Zhu, Andrey Zhmoginov, and Liang-Chieh Chen. Inverted residuals and linear bottlenecks: Mobile networks for classification, detection and segmentation. CVPR, abs/1801.04381, 2018. [46] K. Simonyan and A. Zisserman. Very deep convolutional networks for large-scale image recognition. International Conference on Learning Representations, 2015. [47] Samuel L Smith and Quoc V Le. A bayesian perspective on generalization and stochastic gradient descent. arXiv preprint arXiv:1710.06451, 2017. [48] Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott E. Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. CoRR, abs/1409.4842, 2014. [49] Mingxing Tan and Quoc V. Le. Efficientnet: Rethinking model scaling for convolutional neural networks. ICML, abs/1905.11946, 2019. [50] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Ł ukasz Kaiser, and Illia Polosukhin. Attention is all you need. In I. Guyon, U. V. Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett, editors, Advances in Neural Information Processing Systems 30, pages 5998–6008. Curran Associates, Inc., 2017. [51] Yeming Wen, Kevin Luk, Maxime Gazeau, Guodong Zhang, Harris Chan, and Jimmy Ba. An empirical study of stochastic gradient descent with structured covariance noise. In Silvia Chiappa and Roberto Calandra, editors, Proceedings of the Twenty Third International Conference on Artificial Intelligence and Statistics, volume 108 of Proceedings of Machine Learning Research, pages 3621–3631. PMLR, 26–28 Aug 2020. [52] Thomas Wolf. Transfer Learning in Natural Language Processing, 2019. Available at https: //github.com/huggingface/naacl_transfer_learning_tutorial. [53] Saining Xie, Ross B. Girshick, Piotr Dollár, Zhuowen Tu, and Kaiming He. Aggregated residual transformations for deep neural networks. CVPR, abs/1611.05431, 2017. [54] Yang You, Igor Gitman, and Boris Ginsburg. Scaling SGD batch size to 32k for imagenet training. CoRR, abs/1708.03888, 2017. [55] Yang You, Jing Li, Jonathan Hseu, Xiaodan Song, James Demmel, and Cho-Jui Hsieh. Reducing BERT pre-training time from 3 days to 76 minutes. CoRR, abs/1904.00962, 2019. [56] Susan Zhang, Stephen Roller, Naman Goyal, Mikel Artetxe, Moya Chen, Shuohui Chen, Christopher Dewan, Mona Diab, Xian Li, Xi Victoria Lin, Todor Mihaylov, Myle Ott, Sam Shleifer, Kurt Shuster, Daniel Simig, Punit Singh Koura, Anjali Sridhar, Tianlu Wang, and Luke Zettlemoyer. Opt: Open pre-trained transformer language models, 2022. [57] Wei Zhang, Xiaodong Cui, Ulrich Finkler, Brian Kingsbury, George Saon, David Kung, and Michael Picheny. Distributed deep learning strategies for automatic speech recognition. In ICASSP’2019, May 2019.
|
| 380 |
+
[58] Wei Zhang, Xiaodong Cui, Ulrich Finkler, George Saon, Abdullah Kayi, Alper Buyuktosunoglu, Brian Kingsbury, David Kung, and Michael Picheny. A highly efficient distributed deep learning system for automatic speech recognition. In INTERSPEECH’2019, Sept 2019.
|
| 381 |
+
[59] Wei Zhang, Xiaodong Cui, Abdullah Kayi, Mingrui Liu, Ulrich Finkler, Brian Kingsbury, George Saon, Youssef Mroueh, Alper Buyuktosunoglu, Payel Das, David Kung, and Michael Picheny. Improving efficiency in large-scale decentralized distributed training. In ICASSP’2020, May 2020.
|
| 382 |
+
[60] Wei Zhang, Suyog Gupta, Xiangru Lian, and Ji Liu. Staleness-aware async-sgd for distributed deep learning. In Proceedings of the Twenty-Fifth International Joint Conference on Artificial Intelligence, IJCAI 2016, New York, NY, USA, 9-15 July 2016, pages 2350–2356, 2016.
|
| 383 |
+
[61] Wei Zhang, Suyog Gupta, and Fei Wang. Model accuracy and runtime tradeoff in distributed deep learning: A systematic study. In IEEE International Conference on Data Mining, 2016.
|
| 384 |
+
[62] Xiangyu Zhang, Xinyu Zhou, Mengxiao Lin, and Jian Sun. Shufflenet: An extremely efficient convolutional neural network for mobile devices. CVPR, abs/1707.01083, 2018.
|
| 385 |
+
[63] Yao Zhang, Andrew M. Saxe, Madhu S. Advani, and Alpha A. Lee. Energy–entropy competition and the effectiveness of stochastic gradient descent in machine learning. Molecular Physics, 116(21-22):3214–3223, Jun 2018.
|
| 386 |
+
[64] Fan Zhou and Guojing Cong. On the convergence properties of a k-step averaging stochastic gradient descent algorithm for nonconvex optimization. In IJCAI-18, pages 3219–3227, 7 2018.
|
| 387 |
+
|
| 388 |
+
# Checklist
|
| 389 |
+
|
| 390 |
+
1. For all authors...
|
| 391 |
+
|
| 392 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
|
| 393 |
+
(b) Did you describe the limitations of your work? [Yes]
|
| 394 |
+
(c) Did you discuss any potential negative societal impacts of your work? [N/A]
|
| 395 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 396 |
+
|
| 397 |
+
2. If you are including theoretical results...
|
| 398 |
+
|
| 399 |
+
(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]
|
| 400 |
+
|
| 401 |
+
3. If you ran experiments...
|
| 402 |
+
|
| 403 |
+
(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] Not code(proprietary), but enough instructions to reproduce the results.
|
| 404 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
|
| 405 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No]
|
| 406 |
+
(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]
|
| 407 |
+
|
| 408 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 409 |
+
|
| 410 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes]
|
| 411 |
+
(b) Did you mention the license of the assets? [N/A]
|
| 412 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [No]
|
| 413 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
|
| 414 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
|
| 415 |
+
|
| 416 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 417 |
+
|
| 418 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 419 |
+
|
| 420 |
+
536 (b) Did you describe any potential participant risks, with links to Institutional Review
|
| 421 |
+
537 Board (IRB) approvals, if applicable? [N/A]
|
| 422 |
+
538 (c) Did you include the estimated hourly wage paid to participants and the total amount
|
| 423 |
+
539 spent on participant compensation? [N/A]
|
md/dev/FjqBs4XKe87/FjqBs4XKe87.md
ADDED
|
@@ -0,0 +1,359 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Prompt Injection: Parameterization of Fixed Inputs
|
| 2 |
+
|
| 3 |
+
Anonymous Author(s)
|
| 4 |
+
Affiliation
|
| 5 |
+
Address
|
| 6 |
+
email
|
| 7 |
+
|
| 8 |
+
# Abstract
|
| 9 |
+
|
| 10 |
+
1 Recent works have shown that attaching prompts to the input is effective at con
|
| 11 |
+
2 ditioning Language Models (LM) to perform specific tasks. However, prompts
|
| 12 |
+
3 are always included in the input text during inference, thus incurring substantial
|
| 13 |
+
4 computational and memory overhead. Also, there is currently no straightforward
|
| 14 |
+
5 method of utilizing prompts that are longer than the maximum input length of
|
| 15 |
+
6 the LMs without incurring additional costs during inference. We propose Prompt
|
| 16 |
+
7 Injection (PI), a novel formulation of injecting the prompt into the parameters of an
|
| 17 |
+
8 LM to be an efficient alternative to attaching fixed prompts to the input. We show
|
| 18 |
+
9 that in scenarios with long fixed prompts, PI can be up to 280 times more efficient in
|
| 19 |
+
10 terms of total FLOPs than previous approaches. We further explore methodologies
|
| 20 |
+
11 for PI and show promising results in persona-dependent conversation, semantic
|
| 21 |
+
12 parsing, and zero-shot learning with task instructions. Through these explorations,
|
| 22 |
+
13 we show that PI can be a promising direction for conditioning language models,
|
| 23 |
+
14 especially in scenarios with long and fixed prompts1.
|
| 24 |
+
|
| 25 |
+
# 15 1 Introduction
|
| 26 |
+
|
| 27 |
+
16 Contemporary works with large Language Models (LMs) [3, 32, 23, 5, 28] have shown that attaching
|
| 28 |
+
17 prompts (also referred to as prefixes) to the input is effective at conditioning LMs to perform specific
|
| 29 |
+
18 tasks. During training, LMs are trained to condition on the given prompts in hopes of generalizing
|
| 30 |
+
19 to unseen prompts during inference. Unseen prompts can be a persona for persona-dependent
|
| 31 |
+
20 conversation [39], database schema for semantic parsing [10], and task instruction for zero-shot
|
| 32 |
+
21 learning with task instructions [23]. In these tasks, a new prompt is fixed to the input at every
|
| 33 |
+
22 inference. For instance, in persona-dependent conversation [39, 18, 33], a persona description is
|
| 34 |
+
23 appended to the dialogue history, so that the LM can always be conditioned on the persona. For
|
| 35 |
+
24 another example, in semantic parsing, the LM is conditioned on the database schema as well as
|
| 36 |
+
25 natural language questions to generalize to a new database [37, 10, 36]. Lastly, zero-shot learning
|
| 37 |
+
26 with task instructions [32, 23] involves adding natural language instructions to the inputs for adapting
|
| 38 |
+
27 LMs to novel tasks.
|
| 39 |
+
|
| 40 |
+
However, concatenating prompts to input sequences for prompt-dependent inference has two major limitations. (1) During inference, prompts are always included in the input text and thus incur computational and memory overhead [16]. (2) It is challenging to fit a long text such as the detailed description of a persona as a prompt into Transformer-based models whose input lengths are often fixed [27]. For instance, in persona-dependent conversation, the model constantly refers to the persona description along with the dialogue history [35, 22], as shown in the left side of Figure 1. Moreover, in real world scenarios, a persona may consist of a long detailed text description of a character or person, not just a few profile sentences. Naively concatenating long prompts to the input sequences is challenging due to the quadratic cost in time and memory of Transformer-based architectures with
|
| 41 |
+
|
| 42 |
+

|
| 43 |
+
Figure 1: Prompt Injection example on a persona-dependent conversation. The left side presents an inference procedure of a previous approach where the persona (prompt) is concatenated to every input. The right side describes Prompt Injection, where the persona is injected into the model in advance, so that the model is able to generate responses without constantly referring to the persona description. Thus, Prompt Injection approach takes less time to generate responses than the previous method.
|
| 44 |
+
|
| 45 |
+
37 regard to the input sequence length. Other approaches specialized for long inputs [1, 13], such as
|
| 46 |
+
38 Fusion-in-Decoder [12], or those that augment the LM with a retrieval mechanism [9] may be used
|
| 47 |
+
39 but still come with increased overall memory and computations, ultimately leading to a delay in
|
| 48 |
+
40 generating responses. This problem becomes critical in situations where the LMs are deployed, and
|
| 49 |
+
41 fast inference speed is required.
|
| 50 |
+
42 In this work, we formulate a novel problem called Prompt Injection (PI), where we attempt to inject a
|
| 51 |
+
43 given prompt into the parameters of an LM to address the two limitations mentioned above. With
|
| 52 |
+
44 PI, LMs can produce prompt-dependent outputs without the computational overhead of appending
|
| 53 |
+
45 fixed prompts at inference time (the right side of Figure 1), and it also enables the injection of longer
|
| 54 |
+
46 prompts in a wholistic way. More specifically, we first show that PI is much more efficient (up to
|
| 55 |
+
47 280 times) in terms of total FLOPs compared to previous approaches that may be used for handling
|
| 56 |
+
48 long prompts such as Fusion-in-Decoder [12] or Linear Transformer [13]. Next, we explore different
|
| 57 |
+
49 methodologies as baselines for PI, including the continued pre-training approach on the prompt as
|
| 58 |
+
50 well as a novel distillation approach called Pseudo-INput Generation (PING), in order to analyze
|
| 59 |
+
51 what components are effective for successful PI. We apply these PI methods to three different tasks
|
| 60 |
+
52 with fixed prompts: persona-dependent conversation, semantic parsing, and zero-shot learning with
|
| 61 |
+
53 instructions. We compare the methods against LMs with explicit prompts as the upper bound (i.e.,
|
| 62 |
+
54 unconstrained) as well as the LM without both the prompt and PI as the lower bound. Experimental
|
| 63 |
+
55 results show meaningful improvements with respect to the lower bound, but also exhibit a non-trivial
|
| 64 |
+
56 gap with the upper bound. Despite the performance gap, we still believe that PI is a direction worth
|
| 65 |
+
57 exploring considering the computational benefit of the injection, especially since inference speed is
|
| 66 |
+
58 critical in real world applications.
|
| 67 |
+
|
| 68 |
+
59 In sum, our main contributions are three folds:
|
| 69 |
+
|
| 70 |
+
• We formally define the Prompt Injection (PI) formulation and demonstrate its necessity in terms of computation and memory efficiency, especially in scenarios with long prompts.
|
| 71 |
+
• We explore baseline approaches for PI, showing that performance can approach the upper bound (unconstrained) performance in some cases.
|
| 72 |
+
• We show that the injection of long prompts (e.g., detailed description of persona) can be achieved through PI and show its efficiency in comparison with previous methods, being up to 280 times more efficient during inference.
|
| 73 |
+
|
| 74 |
+
67 Through this work, we hope the community explores PI as an efficient alternative for performing
|
| 75 |
+
68 prompt-dependent tasks.
|
| 76 |
+
|
| 77 |
+
# 69 2 Related Work
|
| 78 |
+
|
| 79 |
+
70 Prompting Prompting is an emerging paradigm for modeling LMs, especially for few-shot and
|
| 80 |
+
71 zero-shot learning [20, 3, 21, 24, 32, 23]. With the help of appropriate prompts, one can exploit
|
| 81 |
+
72 knowledge learned by a pre-trained LM and manipulate the LM’s behavior. The benefit of prompting
|
| 82 |
+
73 is that the pre-trained LM can adapt to new scenarios with few or no labeled training data. However,
|
| 83 |
+
74 for the in-context learning scenario, processing prompts that involve many training examples for each
|
| 84 |
+
75 inference incurs substantial computational and memory overhead [16]. Given training data, Liu et al.
|
| 85 |
+
76 [16] replace in-context learning with fine-tuning a small set of parameters for tackling the above
|
| 86 |
+
77 issue. Prompt Injection also tackles the same issue but assumes a stricter scenario where there are no
|
| 87 |
+
78 training data for the given prompt.
|
| 88 |
+
79 Efficient Transformers for Long Inputs One can consider using efficient Transformer-based [29]
|
| 89 |
+
80 architectures for handling long input sequences [27]. The main challenge of using a vanilla Trans
|
| 90 |
+
81 former architecture is the quadratic cost in time and memory with regard to the input sequence
|
| 91 |
+
82 length due to the self-attention operation. There has been a surge of recent works addressing this
|
| 92 |
+
83 problem [6, 38, 1, 13, 40, 8]. They are primarily dedicated to improving either the efficiency of the
|
| 93 |
+
84 self-attention mechanism or the general efficiency of the Transformer architecture through sparse mod
|
| 94 |
+
85 els. Our Prompt Injection approach tackles the efficiency problem of performing prompt-dependent
|
| 95 |
+
86 tasks by keeping the input sequences short (without prompts), bounding the time and memory
|
| 96 |
+
87 complexity to a constant invariant of the length of the prompt.
|
| 97 |
+
88 Persona-dependent Conversation Endowing a chabot with a persona [39, 18, 33] is challenging,
|
| 98 |
+
89 but it enables the chatbot to deliver more personal, specific, consistent, and engaging conversa
|
| 99 |
+
90 tions [39] and gain user trust [17, 25, 19]. To achieve this, previous works have attached a persona to
|
| 100 |
+
91 the dialog history at every inference time, so that the model can always be conditioned on the persona.
|
| 101 |
+
92 However, given a long persona description, this approach brings the critical problem of increased
|
| 102 |
+
93 overall memory and computations, resulting in delayed response generation. An LM augmented
|
| 103 |
+
94 with a retrieval mechanism [9] may be used but still comes with non-trivial computational overhead.
|
| 104 |
+
95 Prompt Injection allows a dialogue agent to generate responses without a persona description as the
|
| 105 |
+
96 explicit input once the persona is injected.
|
| 106 |
+
97 Semantic Parsing Semantic parsing is the task of mapping a natural language query into a SQL
|
| 107 |
+
98 query executable on a database. Recently, the community has focused more on cross-domain (cross
|
| 108 |
+
99 database) semantic parsing, where models are trained and tested on different domains (databases) [37].
|
| 109 |
+
100 The domain-adaptation setup introduces many generalization challenges, such as non-explicit column
|
| 110 |
+
101 names and domain-specific phrases [10], and recent works concatenate the natural language query
|
| 111 |
+
102 with the serialized database schema as the input to address the problem [26, 7, 36]. With Prompt
|
| 112 |
+
103 Injection, the model is adapted to a new database schema in advance, so that it can map natural
|
| 113 |
+
104 language queries to SQL queries on the new database without explicitly referring to the schema
|
| 114 |
+
105 during inference.
|
| 115 |
+
106 Zero-shot Learning with Task Instructions Recent works [23, 32] have addressed zero-shot
|
| 116 |
+
107 generalization to new tasks [3, 14] by multi-task prompted training. With multi-task prompted
|
| 117 |
+
108 training, the models learn to use task instructions as prompts to generalize to unseen tasks. It is
|
| 118 |
+
109 demonstrated that this approach improves generalization ability to novel tasks and offers an effective
|
| 119 |
+
110 substitute for unsupervised language model pre-training. Through Prompt Injection, the LM can be
|
| 120 |
+
111 aware of a novel task instruction before performing the task and thus does not require the instruction,
|
| 121 |
+
112 which can be lengthy, to make predictions.
|
| 122 |
+
|
| 123 |
+
# 113 3 Prompt Injection
|
| 124 |
+
|
| 125 |
+
114 In this section, we formally define Prompt Injection (PI) as a task and describe the benefits of the
|
| 126 |
+
115 formulation. Prompt-dependent generation is a task of generating an output sequence $\textbf { { y } }$ that is a
|
| 127 |
+
116 proper response to the input sequence $_ { \textbf { \em x } }$ and coherent to the prompt $_ z$ . Utilizing the prompt during
|
| 128 |
+
117 inference, the generated sentence is obtained by ${ \pmb y } = f ( \tilde { z , \pmb x } )$ where $f$ denotes an LM such as
|
| 129 |
+
118 T5 and GPT-2. Prompt Injection (PI), i.e., parameterization of prompts, allows LMs to perform
|
| 130 |
+
119 prompt-dependent generation without using prompts during inference. To achieve this, we need to
|
| 131 |
+
120 design a PI method $H$ to inject a prompt $_ z$ into an LM $f$ . The process of PI can be represented as
|
| 132 |
+
|
| 133 |
+
$$
|
| 134 |
+
f _ { z } = H ( z , f )
|
| 135 |
+
$$
|
| 136 |
+
|
| 137 |
+
121 where $f _ { z }$ denotes an LM injected with the prompt. Then the prompt-dependent output sequence can
|
| 138 |
+
122 be obtained by ${ \pmb y } = f _ { z } ( { \pmb x } )$ .
|
| 139 |
+
123 PI can also be applied for long prompts whose length exceeds the LM’s input sequence length. Given
|
| 140 |
+
124 a long prompt $_ z$ , we decompose it into multiple sub-prompts $\left\{ z _ { i } \right\}$ each of which fits the LM’s input
|
| 141 |
+
125 length, i.e., $\boldsymbol { z } = \boldsymbol { z } _ { 1 : n } = [ z _ { 1 } ; z _ { 2 } ; . . . ; z _ { n } ]$ . Then the $\mathrm { P I }$ process can be executed iteratively, injecting
|
| 142 |
+
126 each sub-prompt sequentially while the LM is aware of the previous sub-prompts:
|
| 143 |
+
|
| 144 |
+
$$
|
| 145 |
+
\begin{array} { c } { f _ { z _ { 1 } } = H ( z _ { 1 } , f ) } \\ { f _ { z _ { 1 : 2 } } = H ( z _ { 2 } , f _ { z _ { 1 } } ) } \\ { \cdot \cdot \cdot } \\ { f _ { z _ { 1 : n } } = H ( z _ { n } , f _ { z _ { 1 : n - 1 } } ) } \end{array}
|
| 146 |
+
$$
|
| 147 |
+
|
| 148 |
+
127 The above formulation can be seen as a high-level abstraction of iterative PI that we aim to ap
|
| 149 |
+
128 proximate. In practice, in order to fully inject $z _ { 1 : n }$ , we repeat (2)-(4) multiple times (i.e., multiple
|
| 150 |
+
129 epochs).
|
| 151 |
+
130 Why is Prompt Injection necessary? Prompt Injection brings definite advantages when applied to
|
| 152 |
+
131 prompt-dependent tasks. The previous approach of appending prompts to the input sequences has
|
| 153 |
+
132 the drawback of the model repeatedly referring to the prompt at each inference time. This becomes
|
| 154 |
+
133 critical in scenarios requiring long prompts, as Transformer architecture has quadratic computational
|
| 155 |
+
134 and memory costs due to the limitation of the self-attention operation. We propose PI as a solution
|
| 156 |
+
135 to this computation bottleneck. Once a prompt is injected into the LM in advance, the LM no
|
| 157 |
+
136 longer needs to refer to the prompt during inference. As a result, the model’s input length remains
|
| 158 |
+
137 independent of the length of prompts and is able to utilize prompts of any length efficiently. We
|
| 159 |
+
138 discuss the efficiency gain of PI in Section 6.1.
|
| 160 |
+
139 Evaluation Metric for Prompt Injection PI can be evaluated by the evaluation metric of the
|
| 161 |
+
140 fixed prompt-dependent task at hand. We also introduce a metric called the Prompt Injection
|
| 162 |
+
141 score (PI score) to measure the degree of injection. The metric is agnostic of the target task by
|
| 163 |
+
142 comparing the results with that of an LM given actual prompts during inference. Let $X _ { w / }$ prompt
|
| 164 |
+
143 denote the LM’s task score with the prompt as an additional input (upper bound) and $X _ { w / o }$ prompt
|
| 165 |
+
144 denote the LM’s task score without the prompt (lower bound). We define PI score as the min
|
| 166 |
+
145 max scaling score of $X _ { P I }$ , where $X _ { P I }$ represents the score of the LM on the target task after PI,
|
| 167 |
+
146 $i . e . , \mathbf { P I } \ s \mathbf { c o r e } = \operatorname* { m a x } ( 0 , X _ { P I } - X _ { w / o \ p r o m p t } ) / \left( X _ { w / \ p r o m p t } - X _ { w / o \ p r o m p t } \right)$ . We limit using PI
|
| 168 |
+
147 only in situations where $X _ { w / p r o m p t } > X _ { w / c }$ prompt because there is no reason to inject a prompt
|
| 169 |
+
148 if task performance degrades when using the prompt. Even if the range of individual task scores
|
| 170 |
+
149 may vary from task to task, PI score represents the overall injection effectiveness of the PI methods,
|
| 171 |
+
150 agnostic of the individual task score range.
|
| 172 |
+
|
| 173 |
+
# 151 4 Methods for Prompt Injection
|
| 174 |
+
|
| 175 |
+
152 In this section, we explore methods of Prompt Injection (PI) that can address prompt-dependent tasks
|
| 176 |
+
153 without accessing the prompt during inference. To achieve this, the model should be trained to store
|
| 177 |
+
154 the prompt in its parameters. This can be seen as parameterizing the prompt into the model instead of
|
| 178 |
+
155 feeding the prompt explicitly to the model. This is challenging as the prompt is unseen to the model
|
| 179 |
+
156 and has no corresponding training data. In Section 4.1, a baseline method by continued pre-training
|
| 180 |
+
157 is introduced, followed by a method for improving the baseline with curriculum learning. Section 4.2
|
| 181 |
+
158 presents a novel distillation-based method called Pseudo-INput Generation (PING) that learns to
|
| 182 |
+
159 generate pseudo-inputs to inject novel prompts.
|
| 183 |
+
|
| 184 |
+

|
| 185 |
+
Phase 2: Distillation
|
| 186 |
+
|
| 187 |
+
Phase 1: Generator Training
|
| 188 |
+
|
| 189 |
+
Figure 2: Illustration of the Pseudo-INput Generation (PING). During Phase 1, an input generator is trained with the task-specific training data. The inputs are prompts of a task, and the outputs are task inputs corresponding to the prompt. Input and output examples applied to semantic parsing are shown. During Phase 2, the input generator generates pseudo-inputs from the given target prompt, which are used to distill knowledge from the teacher to the student. Blue square boxes indicate frozen parameters; yellow rounded boxes indicate unfrozen parameters.
|
| 190 |
+
|
| 191 |
+
# 160 4.1 Continued Pre-training
|
| 192 |
+
|
| 193 |
+
161 We establish the Continued Pre-training method as a straightforward baseline for PI. This method
|
| 194 |
+
162 injects prompts into the parameters of an LM by continuing with the pre-training objective of the
|
| 195 |
+
163 LM on the target prompt. The pre-training objective is a straightforward option as it works in an
|
| 196 |
+
164 unsupervised manner. In our experiments, we leverage the pre-trained T5 model [21] and thus use
|
| 197 |
+
165 the masked language modeling objective which is the pre-training objective of T5. Following Raffel
|
| 198 |
+
166 et al. [21], we randomly replace $15 \%$ of a given prompt with special mask tokens; then, the model is
|
| 199 |
+
167 trained to predict the sequence of masked tokens. In this process, the model learns about the prompt
|
| 200 |
+
168 the same way the model learns knowledge during the pre-training stage.
|
| 201 |
+
169 Curriculum learning We further investigate the baseline method by leveraging curricula [2, 4]
|
| 202 |
+
170 during continued pre-training. We set the mask ratio as the difficulty criteria [34] and gradually
|
| 203 |
+
171 increase the ratio throughout the Continued Pre-training. As the mask ratio increases, the model
|
| 204 |
+
172 should predict more masked tokens given less context. With curriculum learning, we expect the LM to
|
| 205 |
+
173 gradually better adapt to the prompt, improving its prompt-dependent task performance. Throughout
|
| 206 |
+
174 the experiments, we increase the mask ratio linearly from $15 \%$ to $30 \%$ , $50 \%$ , and $70 \%$ and report the
|
| 207 |
+
175 best score.
|
| 208 |
+
|
| 209 |
+
# 176 4.2 Pseudo-INput Generation (PING)
|
| 210 |
+
|
| 211 |
+
177 The purpose of PI is to inject a prompt into the parameters of an LM which can also be done indirectly
|
| 212 |
+
178 through distillation. In this subsection, we propose a novel distillation-based method called Pseudo
|
| 213 |
+
179 INput Generation (PING) that distills a novel prompt into a student LM that does not have access
|
| 214 |
+
180 to the prompt through a teacher LM that does have access to the prompt. In order for distillation,
|
| 215 |
+
181 pseudo-inputs are needed since we assume a scenario where the prompt to be injected has never been
|
| 216 |
+
182 seen during training and does not have separate training data. An overview of PING is illustrated in
|
| 217 |
+
183 Figure 2. As shown in the figure, during Phase 1, an input generator is trained with the task-specific
|
| 218 |
+
184 training data. When given a prompt of the task as the input, the generator is expected to generate the
|
| 219 |
+
185 task inputs that correspond to the prompt. During Phase 2, the input generator is frozen and is used to
|
| 220 |
+
186 generate pseudo-inputs from the unseen prompt, which are then given to the teacher together with the
|
| 221 |
+
187 prompt, while only the pseudo-inputs are given to the student. This way, the student learns to follow
|
| 222 |
+
188 the teacher and is able to learn about the prompt indirectly. We believe that this is the first work that
|
| 223 |
+
189 aims to distill knowledge with different inputs for the teacher and the student.
|
| 224 |
+
|
| 225 |
+
# 190 5 Experimental Setup
|
| 226 |
+
|
| 227 |
+
In this section, we explain the experimental setups in detail. All experiments are performed with the T5-base [21] (220M parameters) model unless noted otherwise.
|
| 228 |
+
|
| 229 |
+
# 5.1 Prompt-dependent tasks
|
| 230 |
+
|
| 231 |
+
In order to evaluate the effectiveness of Prompt Injection (PI) methods, we select three promptdependent tasks—persona-dependent conversation, semantic parsing, and zero-shot learning with task instructions; all these tasks require fixed prompts during inference. Fixed prompts come in the form of a persona in persona-dependent conversation [39], database schema in semantic parsing [10], and task instruction in zero-shot learning with task instructions [23]. As described in the introduction and Section 3, when PI is applied for these tasks, there would be apparent benefits in real world scenarios. For instance, PI eliminates the need to repeatedly include persona descriptions in the input during inference when serving a conversational model of a specific personality. With these tasks, not only the performance of the baseline PI methods is evaluated, but also the significance of PI is emphasized by comparison with the (unconstrained) previous approaches that concatenate prompts to the input.
|
| 232 |
+
|
| 233 |
+
# 5.2 Datasets
|
| 234 |
+
|
| 235 |
+
Following datasets of prompt-dependent tasks mentioned in Section 5.1 are utilized to evaluate Prompt Injection (PI).
|
| 236 |
+
|
| 237 |
+
PERSONA-CHAT PERSONA-CHAT [39] is a crowd-sourced dataset intended for training agents to perform engaging and personal chit-chat by comprising the dialogues to be grounded on specific personas. They crowdsourced 1,155 unique personas, each with five profile sentences and 162,064 utterances over 10,907 dialogues. For each dialogue, two speakers have a 6-8 turn conversation conditioned on a given persona. The task is measured via perplexity (PPL). We randomly select 100 dialogues from the validation set as persona-dependent conversation benchmark for testing PI. The persona descriptions are 60 tokens long on average.
|
| 238 |
+
|
| 239 |
+
215 Spider Spider [37] is a large cross-domain semantic parsing and text-to-SQL dataset for developing
|
| 240 |
+
216 natural language interfaces to cross-domain databases. It includes 10,181 questions, 5,693 unique
|
| 241 |
+
217 SQL queries, and 200 database schemas covering 138 different domains. Models must generalize to
|
| 242 |
+
218 new database schemas as well as new queries to perform well on it. Evaluation metrics include Exact
|
| 243 |
+
219 Matching (EM) and Execution Accuracy (EA). We utilize the dev set containing 20 databases with
|
| 244 |
+
220 about 50 questions per database as a semantic parsing benchmark for PI. The database schemas range
|
| 245 |
+
221 in length from 55 to 430 token lengths.
|
| 246 |
+
|
| 247 |
+
WSC / RTE / COPA For the task of zero-shot task generalization, Raffel et al. [21] have trained the LM on a diverse set of tasks and evaluated on a held-out group of tasks to evaluate generalization performance. We choose coreference resolution, natural language inference, and sentence completion tasks, three out of their four held-out tasks, and test PI on WSC (Winograd Schema Challenge), RTE (Recognizing Textual Entailment), and COPA (Choice of Plausible Alternatives) datasets [30]. All of these tasks are binary classification tasks. We utilize task instructions (prompts) of WSC, RTE, and COPA provided from Raffel et al. [21] and report average task scores of using task instructions. The task instructions are comprised of about 20-30 tokens.
|
| 248 |
+
|
| 249 |
+
# 5.3 Implementation Details
|
| 250 |
+
|
| 251 |
+
For the Continued Pre-training method (Section 4.1), we use the Adam optimizer [15] with a constant learning rate 1e-4 and batch size 8. We perform 5-20 steps of injection. For PING (Section 4.2), input generators are trained on each tasks for 1-2 epochs. We use KL-divergence for distilling the last layer’s output of the decoder and perform 10-40 steps of injection. Diverse pseudo-inputs are generated by sampling each token from the output probability distribution of the decoder. For all of the experiments except for zero-shot generalization, we use a single 16GB T4 GPU. For zero-shot generalization, we use 4 32GB V100 GPUs.
|
| 252 |
+
|
| 253 |
+
Table 1: Inference efficiency of different models that can be used for performing prompt-dependent inference. We depict how many times PI is efficient in comparison with the other approaches inside the parenthesis. When there is out-of-memory (OOM) using the 16GB T4 GPU, we estimate the FLOPs in italics assuming a linear correlation between prompt length and FLOPs.
|
| 254 |
+
|
| 255 |
+
<table><tr><td>Model</td><td>Prompt Length</td><td>FLOPs (G)</td><td>Latency (s)</td></tr><tr><td>T5 W/ PI</td><td>*</td><td>0.7k</td><td>0.58</td></tr><tr><td>T5</td><td>512</td><td>7.2k (×10.3)</td><td>1.09 (x1.9)</td></tr><tr><td rowspan="6">T5 W/ FID</td><td>512 ×2</td><td>14.6k (×21.0)</td><td>2.38 (×4.1)</td></tr><tr><td>512×4</td><td>OOM</td><td>=</td></tr><tr><td>512</td><td>7.2k (×10.3)</td><td>1.09 (×1.9)</td></tr><tr><td>512×2</td><td>14.0k (×20.2)</td><td>1.54 (×2.6)</td></tr><tr><td>512 ×4</td><td>27.6k(×39.8)</td><td>2.87 (×4.9)</td></tr><tr><td>512 ×8</td><td>54.9k(×79.2)</td><td>5.87 (×10.0)</td></tr><tr><td>LINEAR-</td><td>512 ×28</td><td>00M(×280)</td><td>-</td></tr><tr><td rowspan="4">TRANSFORMER</td><td>512</td><td>9.5k (×13.8)</td><td>1.58 (×2.7)</td></tr><tr><td>512×2</td><td>16.1k(×23.2)</td><td>2.62 (x4.5)</td></tr><tr><td>512 × 4</td><td>29.2k(×42.2)</td><td>4.74 (×8.1)</td></tr><tr><td>512×8 512 × 28</td><td>55.6k(×80.1) 0OM(×280)</td><td>9.11 (×15.6) -</td></tr></table>
|
| 256 |
+
|
| 257 |
+
238 In order for injection and comparison with upper-bound and lower-bound performance, we first
|
| 258 |
+
239 need two different versions of the LM adapted to the given task. For the task of persona-dependent
|
| 259 |
+
240 conversation and semantic parsing, one (upper bound) is fine-tuned together with prompts since
|
| 260 |
+
241 prompts are explicitly used during inference, while the other (lower bound) is fine-tuned on the task
|
| 261 |
+
242 without being given the prompt. We perform PI on the lower-bound LM since we also assume having
|
| 262 |
+
243 no access to prompts during inference.
|
| 263 |
+
244 For the zero-shot learning task, we modify the prompts developed by Raffel et al. [21]
|
| 264 |
+
245 in the form of a fixed prompt. Their prompts have placeholders such as Premise, and
|
| 265 |
+
246 Hypothesis. We replace the placeholders with fixed words such as "Premise" and "Hypoth
|
| 266 |
+
247 esis", then append the actual content to the prompt in a key-value format. For example,
|
| 267 |
+
248 if the original is If {Premise} is true, is it also true that {Hypothesis}?, then
|
| 268 |
+
249 the converted prompt is If "Premise" is true, is it also true that "Hypothesis"?
|
| 269 |
+
250 Premise:{Premise} Hypothesis:{Hypothesis}. This ensures that the prompt is fixed, which
|
| 270 |
+
251 can be injected with PI. We use the T0-3B LM checkpoint for the zero-shot generalization.
|
| 271 |
+
|
| 272 |
+
# 252 6 Experimental Results
|
| 273 |
+
|
| 274 |
+
In this section, we first explore the inference efficiency of models performing prompt-dependent tasks and show that Prompt Injection (PI) leads to meaningful computational efficiency. Then the baseline and proposed methods are tested and compared on datasets discussed in Section 5.2. The results indicate that the Pseudo-INput Generation (PING) method achieves the best performance among PI methods, sometimes even outperforming the unconstrained upper bound, which uses explicit prompts during inference. In Section 6.3, we provide a concrete instance of injecting a real persona description into a conversational model, demonstrating the feasibility of long prompt injection.
|
| 275 |
+
|
| 276 |
+
# 6.1 Inference Efficiency
|
| 277 |
+
|
| 278 |
+
The comparison of inference efficiency of a model with PI, a baseline model that naively concatenates prompts to the input, Fusion-in-Decoder (FiD) [12], and Linear Transformer [13] are shown in Table 1. We consider FiD as one of the options for processing long inputs because it processes long input sequences by encoding chunks of input sequences separately, reducing the quadratic complexity to linear. Linear Transformer also reduces the complexity to linear by linearizing the
|
| 279 |
+
|
| 280 |
+
Table 2: Prompt Injection performance on three prompt-dependent tasks. W/ PROMPT stands for the upper bound (unconstrained) method, which uses the prompt during inference by appending it to the input. W/O PROMPT depicts the lower bound method of not utilizing the prompts at all. Lastly, we show three W/ PI methods: CP and CP W/ CURR stand for the Continued Pre-training (baseline) and the Continued Pre-training with curricular, respectively, as explained in Section 4.1; PING depicts our novel proposed method utilizing distillation.
|
| 281 |
+
|
| 282 |
+
<table><tr><td></td><td colspan="2">Dialogue</td><td colspan="3">Semantic Parsing</td><td colspan="6">Task Generalization</td></tr><tr><td></td><td colspan="2">PERSONA-CHAT</td><td colspan="2">Spider</td><td colspan="2"></td><td colspan="2">RTE</td><td colspan="2">COPA</td></tr><tr><td></td><td>PPL (↓)</td><td>PI Score</td><td>EM</td><td>EA PI Score</td><td></td><td>ACC PI Score ACC PI Score </td><td></td><td></td><td></td><td>ACC PI Score</td></tr><tr><td>W/PROMPT</td><td>8.83</td><td></td><td>57.9 61.3</td><td></td><td>=</td><td>63.6</td><td>1</td><td>67.9</td><td>、</td><td>67.3</td></tr><tr><td>W/O PROMPT</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>W/O PI</td><td>11.01</td><td></td><td>14.5 15.1</td><td></td><td>=</td><td>44.0</td><td>64.2 =</td><td></td><td>60.0</td><td></td></tr><tr><td>W/PI</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>CP</td><td>10.85</td><td>0.073</td><td>16.9 17.5</td><td></td><td>0.054</td><td>54.5</td><td>0.536 67.7</td><td>0.946</td><td>64.8</td><td>0.658</td></tr><tr><td>CP W/ CURR</td><td>10.61</td><td>0.183</td><td>17.7 18.4</td><td></td><td>0.072</td><td>50.8</td><td>0.347 68.2</td><td>1.08</td><td>64.1</td><td>0.562</td></tr><tr><td>PING</td><td>9.82</td><td>0.546</td><td>36.6 41.7</td><td></td><td>0.507</td><td>63.7</td><td>1.005</td><td>64.2 0</td><td>60.6</td><td>0.082</td></tr></table>
|
| 283 |
+
|
| 284 |
+
266 attention mechanism. We measure FLOPs and forward propagation latency via DeepSpeed Flops profiler 2267 using a single 16GB T4 GPU.
|
| 285 |
+
|
| 286 |
+
As shown in Table 1, T5 W/ PI is much more efficient than other models, especially as we assume a longer prompt length. This is because the efficiency of PI remains the same independent of the prompt length while the costs of others increase linearly. Specifically, when the prompt length is 8 times the model’s max input sequence length, one can achieve $8 0 \times$ computational efficiency in terms of FLOPs by applying PI. Furthermore, in a scenario where the prompt length is $2 8 \times$ the model’s max input sequence length (shown in Section 6.3 when trying to utilize a long persona that is over 13,000 token length long), previous approaches show an out-of-memory (OOM) issue using the 16GB T4 GPU, and it is impossible to utilize them. PI is estimated to be $2 8 0 \times$ more efficient in terms of total FLOPs if there is no OOM issue.
|
| 287 |
+
|
| 288 |
+
# 77 6.2 Task Performance
|
| 289 |
+
|
| 290 |
+
In Table 2, we report the task performance obtained by applying different PI methods on three prompt-dependent tasks. PI scores are also obtained as introduced in Section 3. For all of W/ PI methods, we observe an overall increase in performance compared to W/O PROMPT, indicating successful injection of prompts into the parameters of the model through PI methods.
|
| 291 |
+
|
| 292 |
+
For the results, while CP gives modest performance improvement over W/O PROMPT, the results of CP W/ CURR show that leveraging curricula during continued pre-training is effective in some cases. CP W/ CURR performs better compared to CP in PERSONA-CHAT, Spider, and RTE; it even outperforms W/ PROMPT in RTE. On the other hand, PING significantly improves performance from CP in PERSONA-CHAT, Spider, and WSC, outperforming W/ PROMPT in WSC. This sheds light on the possibility that PI may be able to reach the upper bound (unconstrained) performance. However, the results show at the same time that there is still a gap between the performance of PI methods and the upper bound W/ PROMPT that needs to be bridged in future work.
|
| 293 |
+
|
| 294 |
+
We find that the performance of different methods depends on the complexity of the input sequence structure. We believe that PING achieves a good performance in PERSONA-CHAT, Spider, and WSC because those datasets have relatively simple input sequences (short utterances; simple query; a sentence and two words, respectively). In datasets with many components or multiple complex sentences (e.g., COPA and RTE), the low quality of generated pseudo-inputs degrades the performance of PING. On the other hand, CP and CP W/ CURR perform better in datasets with complex structure. These findings encourage the community to explore a more integral PI method that can cover different datasets.
|
| 295 |
+
|
| 296 |
+

|
| 297 |
+
some of the most important questions humaniFigure 3: A real world example of Prompt Injection with a long prompt. (Left) The process of injecting a Wikipedia article describing a person (Elon Musk) into a model with PI. The article is more than 13,000 tokens long. (Right) Actual conversation between the persona injected model and a human that is hand-picked.
|
| 298 |
+
|
| 299 |
+
# 298 6.3 Long Prompts Injection
|
| 300 |
+
|
| 301 |
+
To demonstrate the effectiveness of PI on injection of long prompts into LMs, we show how the method works with a real world example. We pick a Wikipedia page (Elon Musk), considering it as a long persona description, and inject the entire article (over 13,000 tokens) into an LM trained with PERSONA-CHAT. Here, we use T5-large as a base model and apply PING.
|
| 302 |
+
|
| 303 |
+
Figure 3 shows an actual instance of interactions with the LM that underwent PI through PING. The responses show the LM successfully reflecting the description of the person on the Wikipedia page without having the description appended to the input. Moreover, the inference of PI is $2 8 0 \times$ more computationally efficient in terms of FLOPs than the baseline, as shown in Section 6.1. Lastly, we provide a live demo to allow interactions with an LM injected with the persona of Elon Musk.
|
| 304 |
+
|
| 305 |
+
# 308 7 Conclusion
|
| 306 |
+
|
| 307 |
+
09 Limitations and Future Work While Prompt Injection (PI) enables performing prompt-dependent
|
| 308 |
+
0 tasks efficiently, there are limitations that needs to be addressed in future work. In particular, the
|
| 309 |
+
current PI methods cause task performance degradation. Moreover, the computational costs needed
|
| 310 |
+
12 for the injection of prompts into the model parameters have not been extensively considered. For
|
| 311 |
+
13 example, when considering previous conversation history as prompts to be injected in a multi-turn
|
| 312 |
+
14 conversation setting, fast injection may also be a requirement for real-world application. Updating or
|
| 313 |
+
15 adding a relatively small number of parameters [11, 31] may be a potential avenue for addressing the
|
| 314 |
+
16 problems.
|
| 315 |
+
317 In this paper, we propose Prompt Injection (PI), a novel formulation of injecting the prompt into the
|
| 316 |
+
318 parameters of an LM, as an efficient alternative to attaching fixed prompts to the inputs for prompt
|
| 317 |
+
319 dependent tasks. Through experiments, we show that PI is much more computationally efficient (up
|
| 318 |
+
320 to 280 times) in terms of total FLOPs for handling long prompts compared to the previous alternatives.
|
| 319 |
+
321 We further explore baseline methodologies for PI and find that Pseudo-INput Generation (PING), a
|
| 320 |
+
322 distillation-based approach, shows promising results in persona-dependent conversation, semantic
|
| 321 |
+
323 parsing, and zero-shot learning with task instructions. Through the explorations, we show that PI
|
| 322 |
+
324 can be a promising direction for conditioning language models with prompts, especially in scenarios
|
| 323 |
+
325 with long and fixed prompts. To this end, we hope the community explores PI for achieving both
|
| 324 |
+
326 performance and efficiency on prompt-dependent tasks.
|
| 325 |
+
|
| 326 |
+
# References
|
| 327 |
+
|
| 328 |
+
[1] Iz Beltagy, Matthew E. Peters, and Arman Cohan. Longformer: The long-document transformer. ArXiv, abs/2004.05150, 2020.
|
| 329 |
+
|
| 330 |
+
[2] Yoshua Bengio, Jérôme Louradour, Ronan Collobert, and Jason Weston. Curriculum learning. In ICML ’09, 2009. [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. ArXiv, abs/2005.14165, 2020. [4] Daniel Fernando Campos. Curriculum learning for language modeling. ArXiv, abs/2108.02170, 2021. [5] 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 Baindoor Rao, Parker Barnes, Yi Tay, Noam M. Shazeer, Vinodkumar Prabhakaran, Emily Reif, Nan Du, Benton C. 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 García, 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 Oliveira Moreira, Rewon Child, Oleksandr Polozov, Katherine Lee, Zongwei Zhou, Xuezhi Wang, Brennan Saeta, Mark Diaz, Orhan Firat, Michele Catasta, Jason Wei, Kathleen S. Meier-Hellstern, Douglas Eck, Jeff Dean, Slav Petrov, and Noah Fiedel. Palm: Scaling language modeling with pathways. ArXiv, abs/2204.02311, 2022. [6] Zihang Dai, Zhilin Yang, Yiming Yang, Jaime G. Carbonell, Quoc V. Le, and Ruslan Salakhutdinov. Transformer-xl: Attentive language models beyond a fixed-length context. In ACL, 2019. [7] Xiang Deng, Ahmed Hassan Awadallah, Christopher Meek, Oleksandr Polozov, Huan Sun, and Matthew Richardson. Structure-grounded pretraining for text-to-sql. ArXiv, abs/2010.12773, 2021. [8] Mandy Guo, Joshua Ainslie, David C. Uthus, Santiago Ontañón, Jianmo Ni, Yun-Hsuan Sung, and Yinfei Yang. Longt5: Efficient text-to-text transformer for long sequences. ArXiv, abs/2112.07916, 2021. [9] Seungju Han, Beomsu Kim, Jin Yong Yoo, Seokjun Seo, Sangbum Kim, Enkhbayar Erdenee, and Buru Chang. Meet your favorite character: Open-domain chatbot mimicking fictional characters with only a few utterances. arXiv preprint arXiv:2204.10825, 2022. [10] Moshe Hazoom, Vibhor Malik, and Ben Bogin. Text-to-sql in the wild: A naturally-occurring dataset based on stack exchange data. ArXiv, abs/2106.05006, 2021. [11] Edward J. Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, and Weizhu Chen. Lora: Low-rank adaptation of large language models. ArXiv, abs/2106.09685, 2021. [12] Gautier Izacard and Edouard Grave. Leveraging passage retrieval with generative models for open domain question answering. In EACL, 2021. [13] Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, and Franccois Fleuret. Transformers are rnns: Fast autoregressive transformers with linear attention. ArXiv, abs/2006.16236, 2020. [14] Boseop Kim, Hyoungseok Kim, Sang-Woo Lee, Gichang Lee, Donghyun Kwak, Dong Hyeon Jeon, Sunghyun Park, Sung ju Kim, Seonhoon Kim, Dong Hyung Seo, Heungsub Lee, Minyoung Jeong, Sungjae Lee, Minsub Kim, SukHyun Ko, Seokhun Kim, Taeyong Park, Jinuk Kim,
|
| 331 |
+
78 Soyoung Kang, Na-Hyeon Ryu, Kang Min Yoo, Minsuk Chang, Soobin Suh, Sookyo In,
|
| 332 |
+
79 Jinseong Park, Kyungduk Kim, Hiun Kim, Jisu Jeong, Yong Goo Yeo, Dong hyun Ham, Do
|
| 333 |
+
80 Hyoung Park, Min Young Lee, Jaewoo Kang, Inho Kang, Jung-Woo Ha, Woo Chul Park, and Nako Sung. What changes can large-scale language models bring? intensive study on hyperclova: Billions-scale korean generative pretrained transformers. ArXiv, abs/2109.04650, 2021.
|
| 334 |
+
[15] Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. CoRR, abs/1412.6980, 2015.
|
| 335 |
+
[16] Haokun Liu, Derek Tam, Mohammed Muqeeth, Jay Mohta, Tenghao Huang, Mohit Bansal, and Colin Raffel. Few-shot parameter-efficient fine-tuning is better and cheaper than in-context learning. 2022.
|
| 336 |
+
[17] Qian Liu, Yihong Chen, B. Chen, Jian-Guang Lou, Zixuan Chen, Bin Zhou, and Dongmei Zhang. You impress me: Dialogue generation via mutual persona perception. ArXiv, abs/2004.05388, 2020.
|
| 337 |
+
[18] Pierre-Emmanuel Mazaré, Samuel Humeau, Martin Raison, and Antoine Bordes. Training millions of personalized dialogue agents. In EMNLP, 2018.
|
| 338 |
+
[19] Qiao Qian, Minlie Huang, Haizhou Zhao, Jingfang Xu, and Xiaoyan Zhu. Assigning personality/profile to a chatting machine for coherent conversation generation. In IJCAI, 2018.
|
| 339 |
+
[20] Alec Radford, Jeff Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. 2019.
|
| 340 |
+
[21] Colin Raffel, Noam M. 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, abs/1910.10683, 2020.
|
| 341 |
+
[22] Stephen Roller, Emily Dinan, Naman Goyal, Da Ju, Mary Williamson, Yinhan Liu, Jing Xu, Myle Ott, Kurt Shuster, Eric Michael Smith, Y.-Lan Boureau, and Jason Weston. Recipes for building an open-domain chatbot. In EACL, 2021.
|
| 342 |
+
[23] Victor Sanh, Albert Webson, Colin Raffel, Stephen H. Bach, Lintang A. Sutawika, Zaid Alyafeai, Antoine Chaffin, Arnaud Stiegler, Teven Le Scao, Arun Raja, Manan Dey, M SAIFUL BARI, Canwen Xu, Urmish Thakker, Shanya Sharma, Eliza Szczechla, Taewoon Kim, Gunjan Chhablani, Nihal V. 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 Févry, Jason Alan Fries, Ryan Teehan, Stella Rose Biderman, Leo Gao, T. G. Owe Bers, Thomas Wolf, and Alexander M. Rush. Multitask prompted training enables zero-shot task generalization. ArXiv, abs/2110.08207, 2021.
|
| 343 |
+
[24] Timo Schick and Hinrich Schütze. It’s not just size that matters: Small language models are also few-shot learners. ArXiv, abs/2009.07118, 2021.
|
| 344 |
+
[25] Haoyu Song, Weinan Zhang, Yiming Cui, Dong Wang, and Ting Liu. Exploiting persona information for diverse generation of conversational responses. In IJCAI, 2019.
|
| 345 |
+
[26] Alane Suhr, Ming-Wei Chang, Peter Shaw, and Kenton Lee. Exploring unexplored generalization challenges for cross-database semantic parsing. In ACL, 2020.
|
| 346 |
+
[27] Yi Tay, Mostafa Dehghani, Dara Bahri, and Donald Metzler. Efficient transformers: A survey. ACM Computing Surveys (CSUR), 2022.
|
| 347 |
+
[28] Romal Thoppilan, Daniel De Freitas, Jamie Hall, Noam M. Shazeer, Apoorv Kulshreshtha, Heng-Tze Cheng, Alicia Jin, Taylor Bos, Leslie Baker, Yu Du, Yaguang Li, Hongrae Lee, Huaixiu Zheng, Amin Ghafouri, Marcelo Menegali, Yanping Huang, Maxim Krikun, Dmitry Lepikhin, James Qin, Dehao Chen, Yuanzhong Xu, Zhifeng Chen, Adam Roberts, Maarten Bosma, Yanqi Zhou, Chung-Ching Chang, I. A. Krivokon, Willard James Rusch, Marc Pickett, Kathleen S. Meier-Hellstern, Meredith Ringel Morris, Tulsee Doshi, Renelito Delos Santos, Toju Duke, Johnny Hartz Søraker, Ben Zevenbergen, Vinodkumar Prabhakaran, Mark Diaz, Ben Hutchinson, Kristen Olson, Alejandra Molina, Erin Hoffman-John, Josh Lee, Lora Aroyo, Ravindran Rajakumar, Alena Butryna, Matthew Lamm, V. O. Kuzmina, Joseph Fenton, Aaron Cohen, Rachel Bernstein, Ray Kurzweil, Blaise Aguera-Arcas, Claire Cui, Marian Croak, Ed Chi, and Quoc Le. Lamda: Language models for dialog applications. ArXiv, abs/2201.08239, 2022.
|
| 348 |
+
[29] Ashish Vaswani, Noam M. Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. ArXiv, abs/1706.03762, 2017.
|
| 349 |
+
[30] Alex Wang, Yada Pruksachatkun, Nikita Nangia, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R. Bowman. Superglue: A stickier benchmark for general-purpose language understanding systems. In NeurIPS, 2019.
|
| 350 |
+
[31] Ruize Wang, Duyu Tang, Nan Duan, Zhongyu Wei, Xuanjing Huang, Jianshu Ji, Guihong Cao, Daxin Jiang, and Ming Zhou. K-adapter: Infusing knowledge into pre-trained models with adapters. In FINDINGS, 2021.
|
| 351 |
+
[32] Jason Wei, Maarten Bosma, Vincent 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, abs/2109.01652, 2021.
|
| 352 |
+
[33] Sean Welleck, Jason Weston, Arthur D. Szlam, and Kyunghyun Cho. Dialogue natural language inference. In ACL, 2019.
|
| 353 |
+
[34] Alexander Wettig, Tianyu Gao, Zexuan Zhong, and Danqi Chen. Should you mask $15 \%$ in masked language modeling? arXiv preprint arXiv:2202.08005, 2022.
|
| 354 |
+
[35] Thomas Wolf, Victor Sanh, Julien Chaumond, and Clement Delangue. Transfertransfo: A transfer learning approach for neural network based conversational agents. ArXiv, abs/1901.08149, 2019.
|
| 355 |
+
[36] Tianbao Xie, Chen Henry Wu, Peng Shi, Ruiqi Zhong, Torsten Scholak, Michihiro Yasunaga, Chien-Sheng Wu, Ming Zhong, Pengcheng Yin, Sida I. Wang, Victor Zhong, Bailin Wang, Chengzu Li, Connor Boyle, Ansong Ni, Ziyu Yao, Dragomir Radev, Caiming Xiong, Lingpeng Kong, Rui Zhang, Noah A. Smith, Luke Zettlemoyer, and Tao Yu. Unifiedskg: Unifying and multi-tasking structured knowledge grounding with text-to-text language models. ArXiv, abs/2201.05966, 2022.
|
| 356 |
+
[37] Tao Yu, Rui Zhang, Kai-Chou Yang, Michihiro Yasunaga, Dongxu Wang, Zifan Li, James Ma, Irene Z Li, Qingning Yao, Shanelle Roman, Zilin Zhang, and Dragomir R. Radev. Spider: A large-scale human-labeled dataset for complex and cross-domain semantic parsing and text-to-sql task. In EMNLP, 2018.
|
| 357 |
+
[38] Manzil Zaheer, Guru Guruganesh, Kumar Avinava Dubey, Joshua Ainslie, Chris Alberti, Santiago Ontañón, Philip Pham, Anirudh Ravula, Qifan Wang, Li Yang, and Amr Ahmed. Big bird: Transformers for longer sequences. ArXiv, abs/2007.14062, 2020.
|
| 358 |
+
[39] Saizheng Zhang, Emily Dinan, Jack Urbanek, Arthur D. Szlam, Douwe Kiela, and Jason Weston. Personalizing dialogue agents: I have a dog, do you have pets too? In ACL, 2018.
|
| 359 |
+
[40] Chen Zhu, Wei Ping, Chaowei Xiao, Mohammad Shoeybi, Tom Goldstein, Anima Anandkumar, and Bryan Catanzaro. Long-short transformer: Efficient transformers for language and vision. ArXiv, abs/2107.02192, 2021.
|
md/dev/H4DqfPSibmx/H4DqfPSibmx.md
ADDED
|
@@ -0,0 +1,444 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# FLASHATTENTION: Fast and Memory-Efficient Exact Attention with IO-Awareness
|
| 2 |
+
|
| 3 |
+
Tri Dao†, Daniel Y. Fu †, Stefano Ermon †, Atri Rudra ‡, Christopher Ré † † Department of Computer Science, Stanford University ‡ Department of Computer Science and Engineering, University at Buffalo, SUNY {trid,danfu}@stanford.edu, ermon@stanford.edu, atri@buffalo.edu, chrismre@cs.stanford.edu
|
| 4 |
+
|
| 5 |
+
# Abstract
|
| 6 |
+
|
| 7 |
+
Transformers are slow and memory-hungry on long sequences, since the time and memory complexity of self-attention are quadratic in sequence length. Approximate attention methods have attempted to address this problem by trading off model quality to reduce the compute complexity, but often do not achieve wall-clock speedup. We argue that a missing principle is making attention algorithms $I O$ -aware— accounting for reads and writes between levels of GPU memory. We propose FLASHATTENTION, an IO-aware exact attention algorithm that uses tiling to reduce the number of memory reads/writes between GPU high bandwidth memory (HBM) and GPU on-chip SRAM. We analyze the IO complexity of FLASHATTENTION, showing that it requires fewer HBM accesses than standard attention, and is optimal for a range of SRAM sizes. We also extend FLASHATTENTION to block-sparse attention, yielding an approximate attention algorithm that is faster than any existing approximate attention method. FLASHATTENTION trains Transformers faster than existing baselines: $15 \%$ end-to-end wall-clock speedup on BERT-large (seq. length 512) compared to the MLPerf 1.1 training speed record, $3 \times$ speedup on GPT-2 (seq. length 1K), and $2 . 4 \times$ speedup on long-range arena (seq. length 1K-4K). FLASHATTENTION and block-sparse FLASHATTENTION enable longer context in Transformers, yielding higher quality models (0.7 better perplexity on GPT-2 and 6.4 points of lift on long-document classification) and entirely new capabilities: the first Transformers to achieve better-than-chance performance on the Path-X challenge (seq. length 16K, $6 1 . 4 \%$ accuracy) and Path-256 (seq. length 64K, $6 3 . 1 \%$ accuracy).
|
| 8 |
+
|
| 9 |
+
# 1 Introduction
|
| 10 |
+
|
| 11 |
+
Transformer models [86] have emerged as the most widely used architecture in applications such as natural language processing and image classification. Transformers have grown larger [5] and deeper [87], but equipping them with longer context remains difficult [83], since the self-attention module at their heart has time and memory complexity quadratic in sequence length. An important question is whether making attention faster and more memory-efficient can help Transformer models address their runtime and memory challenges for long sequences.
|
| 12 |
+
|
| 13 |
+
Many approximate attention methods have aimed to reduce the compute and memory requirements of attention. These methods range from sparse-approximation [53, 77] to low-rank approximation [13, 52, 88], and their combinations [3, 9, 96]. Although these methods reduce the compute requirements to linear or near-linear in sequence length, many of them do not display wall-clock speedup against standard attention and have not gained wide adoption. One main reason is that they focus on FLOP reduction (which may not correlate with wall-clock speed) and tend to ignore overheads from memory access (IO).
|
| 14 |
+
|
| 15 |
+
In this paper, we argue that a missing principle is making attention algorithms IO-aware [1]—that is, carefully accounting for reads and writes to different levels of fast and slow memory (e.g., between fast GPU on-chip SRAM and relatively slow GPU high bandwidth memory, or HBM [47], Figure 1 left). On modern GPUs, compute speed has out-paced memory speed [64–66], and most operations in Transformers are bottlenecked by memory accesses [45]. IO-aware algorithms have been critical for similar memory-bound operations, when reading and writing data can account for a large portion of the runtime—such as database joins [74], image processing [73], numerical linear algebra [4], and more [42, 89]. However, common Python interfaces to deep learning such as PyTorch and Tensorflow do not allow fine-grained control of memory access.
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
Figure 1: Left: FLASHATTENTION uses tiling to prevent materialization of the large $N { \times } N$ attention matrix (dotted box) on (relatively) slow GPU HBM. In the outer loop (red arrows), FLASHATTENTION loops through blocks of the $\mathbf { K }$ and $\mathbf { V }$ matrices and loads them to fast on-chip SRAM. In each block, FLASHATTENTION loops over blocks of Q matrix (blue arrows), loading them to SRAM, and writing the output of the attention computation back to HBM. Right: Speedup over the PyTorch implementation of attention on GPT-2. FLASHATTENTION does not read and write the large $N { \times } N$ attention matrix to HBM, resulting in an $7 . 6 \times$ speedup on the attention computation.
|
| 19 |
+
|
| 20 |
+
We propose FLASHATTENTION, a new attention algorithm that computes exact attention with far fewer memory accesses. Our main goal is to avoid reading and writing the attention matrix to and from HBM. This requires (i) computing the softmax reduction without access to the whole input (ii) not storing the large intermediate attention matrix for the backward pass. We apply two well-established techniques to address these challenges. (i) We restructure the attention computation to split the input into blocks and make several passes over input blocks, thus incrementally performing the softmax reduction (also known as tiling). (ii) We store the softmax normalization factor from the forward pass to quickly recompute attention on-chip in the backward pass, which is faster than the standard approach of reading the intermediate attention matrix from HBM. We implement FLASHATTENTION in CUDA to achieve fine-grained control over memory access and fuse all the attention operations into one GPU kernel. Even with the increased FLOPs due to recomputation, our algorithm both runs faster (up to $7 . 6 \mathrm { x }$ on GPT-2 [70], Figure 1 right) and uses less memory—linear in sequence length—than standard attention, thanks to the massively reduced amount of HBM access.
|
| 21 |
+
|
| 22 |
+
We analyze the IO complexity [1] of FLASHATTENTION, proving that it requires $O ( N ^ { 2 } d ^ { 2 } M ^ { - 1 } )$ HBM accesses where $d$ is the head dimension and $M$ is the size of SRAM, as compared to $\Omega ( N d + N ^ { 2 } )$ of standard attention. For typical values of $d$ and $M$ , FLASHATTENTION requires many times fewer HBM accesses compared to standard attention (up to $9 \times$ fewer, as shown in Fig. 2). Moreover, we provide a lower bound, showing that no exact attention algorithm can asymptotically improve on the number of HBM accesses over all SRAM sizes.
|
| 23 |
+
|
| 24 |
+
We also show that FLASHATTENTION can serve as a useful primitive for realizing the potential of approximate attention algorithms by overcoming their issues with memory access overhead. As a proof of concept, we implement block-sparse FLASHATTENTION, a sparse attention algorithm that is $2 { - } 4 \times$ faster than even FLASHATTENTION, scaling up to sequence length of $6 4 \mathrm { k }$ . We prove that block-sparse FLASHATTENTION has better IO complexity than FLASHATTENTION by a factor proportional to the sparsity ratio. We discuss further extensions to other operations (attention on multi-GPU, kernel regression, block-sparse matrix multiply) in Section 5. We open-source FLASHATTENTION to make it easier to build on this primitive1.
|
| 25 |
+
|
| 26 |
+
We empirically validate that FLASHATTENTION speeds up model training and improves model quality by modeling longer context. We also benchmark the runtime and memory footprint of FLASHATTENTION and block-sparse FLASHATTENTION compared to prior attention implementations.
|
| 27 |
+
|
| 28 |
+
• Faster Model Training. FLASHATTENTION trains Transformer models faster in wall-clock time. We train BERT-large (seq. length 512) $15 \%$ faster than the training speed record in MLPerf 1.1 [60], GPT2 (seq. length 1K) $3 \times$ faster than baseline implementations from HuggingFace [91] and Megatron-LM [80], and long-range arena (seq. length 1K-4K) $2 . 4 \times$ faster than baselines.
|
| 29 |
+
|
| 30 |
+
• Higher Quality Models. FLASHATTENTION scales Transformers to longer sequences, which improves their quality and enables new capabilities. We observe a 0.7 improvement in perplexity on GPT-2 and 6.4 points of lift from modeling longer sequences on long-document classification [14]. FLASHATTENTION enables the first Transformer that can achieve better-than-chance performance on the Path-X [83] challenge, solely from using a longer sequence length (16K). Block-sparse FLASHATTENTION enables a Transformer to scale to even longer sequences (64K), resulting in the first model that can achieve better-than-chance performance on Path-256.
|
| 31 |
+
|
| 32 |
+
• Benchmarking Attention. FLASHATTENTION is up to $3 \times$ faster than the standard attention implementation across common sequence lengths from 128 to 2K and scales up to 64K. Up to sequence length of 512, FLASHATTENTION is both faster and more memory-efficient than any existing attention method, whereas for sequence length beyond 1K, some approximate attention methods (e.g., Linformer) start to become faster. On the other hand, block-sparse FLASHATTENTION is faster than all existing approximate attention methods that we know of.
|
| 33 |
+
|
| 34 |
+
# 2 Background
|
| 35 |
+
|
| 36 |
+
We provide some background on the performance characteristics of common deep learning operations on modern hardware (GPUs). We also describe the standard implementation of attention.
|
| 37 |
+
|
| 38 |
+
# 2.1 Hardware Performance
|
| 39 |
+
|
| 40 |
+
We focus here on GPUs. Performance on other hardware accelerators are similar [48, 50].
|
| 41 |
+
|
| 42 |
+
GPU Memory Hierarchy. The GPU memory hierarchy (Fig. 1 left) comprises multiple forms of memory of different sizes and speeds, with smaller memory being faster. As an example, the A100 GPU has 40-80GB of high bandwidth memory (HBM) with bandwidth $1 . 5 { - } 2 . 0 \mathrm { T B } / \mathrm { s }$ and 192KB of on-chip SRAM per each of 108 streaming multiprocessors with bandwidth estimated around 19TB/s [46, 47]. The on-chip SRAM is an order of magnitude faster than HBM but many orders of magnitude smaller in size. As compute has gotten faster relative to memory speed [64–66], operations are increasingly bottlenecked by memory (HBM) accesses. Thus exploiting fast SRAM becomes more important.
|
| 43 |
+
|
| 44 |
+
Execution Model. GPUs have a massive number of threads to execute an operation (called a kernel).
|
| 45 |
+
Each kernel loads inputs from HBM to registers and SRAM, computes, then writes outputs to HBM.
|
| 46 |
+
|
| 47 |
+
Performance characteristics. Depending on the balance of computation and memory accesses, operations can be classified as either compute-bound or memory-bound. This is commonly measured by the arithmetic intensity [89], which is the number of arithmetic operations per byte of memory access.
|
| 48 |
+
|
| 49 |
+
1. Compute-bound: the time taken by the operation is determined by how many arithmetic operations there are, while time accessing HBM is much smaller. Typical examples are matrix multiply with large inner dimension, and convolution with large number of channels.
|
| 50 |
+
2. Memory-bound: the time taken by the operation is determined by the number of memory accesses, while time spent in computation is much smaller. Examples include most other operations: elementwise (e.g., activation, dropout), and reduction (e.g., sum, softmax, batch norm, layer norm).
|
| 51 |
+
|
| 52 |
+
Kernel fusion. The most common approach to accelerate memory-bound operations is kernel fusion: if there are multiple operations applied to the same input, the input can be loaded once from HBM, instead of multiple times for each operation. Compilers can automatically fuse many elementwise operations [55, 68, 78]. However, in the context of model training, the intermediate values still need to be written to HBM to save for the backward pass, reducing the effectiveness of naive kernel fusion.
|
| 53 |
+
|
| 54 |
+
# 2.2 Standard Attention Implementation
|
| 55 |
+
|
| 56 |
+
Given input sequences $\mathbf { Q } , \mathbf { K } , \mathbf { V } \in \mathbb { R } ^ { N \times d }$ where $N$ is the sequence length and $d$ is the head dimension, we want to compute the attention output O ∈ R?? ×??:
|
| 57 |
+
|
| 58 |
+
$$
|
| 59 |
+
\begin{array} { r } { \mathbf { S } = \mathbf { Q } \mathbf { K } ^ { \top } \in \mathbb { R } ^ { N \times N } , \quad \mathbf { P } = \operatorname { s o f t m a x } ( \mathbf { S } ) \in \mathbb { R } ^ { N \times N } , \quad \mathbf { O } = \mathbf { P } \mathbf { V } \in \mathbb { R } ^ { N \times d } , } \end{array}
|
| 60 |
+
$$
|
| 61 |
+
|
| 62 |
+
where softmax is applied row-wise.
|
| 63 |
+
|
| 64 |
+
Standard attention implementations materialize the matrices S and $\mathbf { P }$ to HBM, which takes $O ( N ^ { 2 } )$ memory. Often $N \gg d$ (e.g., for GPT2, $N = 1 0 2 4$ and $d = 6 4$ ). We describe the standard attention implementation in Algorithm 0. As some or most of the operations are memory-bound (e.g., softmax), the large number of memory accesses translates to slow wall-clock time.
|
| 65 |
+
|
| 66 |
+
This problem is exacerbated by other elementwise operations applied to the attention matrix, such as masking applied to S or dropout applied to $\mathbf { P }$ . As a result, there have been many attempts to fuse several elementwise operations, such as fusing masking with softmax [80].
|
| 67 |
+
|
| 68 |
+
In Section 3.2, we will show that the standard attention implementation performs HBM accesses quadratic in the sequence length $N$ . We also compare the number of FLOPs and number of HBM accesses of standard attention and of our method (FLASHATTENTION).
|
| 69 |
+
|
| 70 |
+
Algorithm 0 Standard Attention Implementation
|
| 71 |
+
|
| 72 |
+
Require: Matrices $\mathbf { Q } , \mathbf { K } , \mathbf { V } \in \mathbb { R } ^ { N \times d }$ in HBM.
|
| 73 |
+
|
| 74 |
+
1: Load Q,K by blocks from HBM, compute $\mathbf { S } { = } \mathbf { Q } \mathbf { K } ^ { \top }$ , write S to HBM.
|
| 75 |
+
2: Read S from HBM, compute $\mathbf { P } =$ softmax(S), write $\mathbf { P }$ to HBM.
|
| 76 |
+
3: Load P and $\mathbf { V }$ by blocks from HBM, compute $\mathbf { O } { = } \mathbf { P } \mathbf { V }$ , write $\mathbf { o }$ to HBM.
|
| 77 |
+
4: Return O.
|
| 78 |
+
|
| 79 |
+
# 3 FLASHATTENTION: Algorithm, Analysis, and Extensions
|
| 80 |
+
|
| 81 |
+
We show how to compute exact attention with fewer HBM reads/writes and without storing large intermediate matrices for the backward pass. This yields an attention algorithm that is both memory efficient and faster in wall-clock time. We analyze its IO complexity, showing that our method requires much fewer HBM accesses compared to standard attention. We further show that FLASHATTENTION can serve as a useful primitive by extending it to handle block-sparse attention.
|
| 82 |
+
|
| 83 |
+
We focus here on the forward pass for ease of exposition; Appendix B contains details for the backward.
|
| 84 |
+
|
| 85 |
+
# 3.1 An Efficient Attention Algorithm With Tiling and Recomputation
|
| 86 |
+
|
| 87 |
+
Given the inputs ${ \bf Q } , { \bf K } , { \bf V } \in \mathbb { R } ^ { N \times d }$ in HBM, we aim to compute the attention output $\mathbf { O } \in \mathbb { R } ^ { N \times d }$ and write it to HBM. Our goal is to reduce the amount of HBM accesses (to sub-quadratic in $N$ ).
|
| 88 |
+
|
| 89 |
+
We apply two established techniques (tiling, recomputation) to overcome the technical challenge of computing exact attention in sub-quadratic HBM accesses. We describe this in Algorithm 1. The main idea is that we split the inputs Q,K,V into blocks, load them from slow HBM to fast SRAM, then compute the attention output with respect to those blocks. By scaling the output of each block by the right normalization factor before adding them up, we get the correct result at the end.
|
| 90 |
+
|
| 91 |
+
Tiling. We compute attention by blocks. Softmax couples columns of $\mathbf { K }$ , so we decompose the large softmax with scaling [53, 62, 69]. For numerical stability, the softmax of vector $\boldsymbol { x } \in \mathbb { R } ^ { \dot { B } }$ is computed:
|
| 92 |
+
|
| 93 |
+
$$
|
| 94 |
+
m ( x ) : = \operatorname* { m a x } _ { i } \ x _ { i } , \quad f ( x ) : = \left[ e ^ { x _ { 1 } - m ( x ) } \quad \ldots \quad e ^ { x _ { B } - m ( x ) } \right] , \quad \ell ( x ) : = \sum _ { i } f ( x ) _ { i } , \quad \mathrm { s o f t m a x } ( x ) : = \frac { f ( x ) } { \ell ( x ) } .
|
| 95 |
+
$$
|
| 96 |
+
|
| 97 |
+
For vectors $\boldsymbol { x } ^ { ( 1 ) } , \boldsymbol { x } ^ { ( 2 ) } \in \mathbb { R } ^ { B }$ , we can decompose the softmax of the concatenated $\boldsymbol { x } = \left[ \boldsymbol { x } ^ { ( 1 ) } ~ \boldsymbol { x } ^ { ( 2 ) } \right] \in \mathbb { R } ^ { 2 B }$ as: $\eta \left( x \right) = m \left( \left[ x ^ { \left( 1 \right) } ~ x ^ { \left( 2 \right) } \right] \right) = \operatorname* { m a x } ( m \left( x ^ { \left( 1 \right) } \right) , m \left( x ^ { \left( 2 \right) } \right) ) , \quad f \left( x \right) = \left[ e ^ { m \left( x ^ { \left( 1 \right) } \right) - m \left( x \right) } f \left( x ^ { \left( 1 \right) } \right) \quad \stackrel { \star } { e ^ { m \left( x ^ { \left( 2 \right) } \right) - m \left( x \right) } } f \left( x ^ { \left( 2 \right) } \right) \right]$
|
| 98 |
+
|
| 99 |
+
$$
|
| 100 |
+
\ell ( x ) = \ell ( \left[ x ^ { ( 1 ) } ~ x ^ { ( 2 ) } \right] ) = e ^ { m ( x ^ { ( 1 ) } ) - m ( x ) } \ell ( x ^ { ( 1 ) } ) + e ^ { m ( x ^ { ( 2 ) } ) - m ( x ) } \ell ( x ^ { ( 2 ) } ) , \quad \mathrm { s o f t m a x } ( x ) = \frac { f ( x ) } { \ell ( x ) } .
|
| 101 |
+
$$
|
| 102 |
+
|
| 103 |
+
Therefore if we keep track of some extra statistics $( m ( x ) , \ell ( x ) )$ , we can compute softmax one block at a time.2 We thus split the inputs $\mathbf { Q } , \mathbf { K } , \mathbf { V }$ into blocks (Algorithm 1 line 1), compute the softmax values along with extra statistics (Algorithm 1 line 1), and combine the results (Algorithm 1 line 1).
|
| 104 |
+
|
| 105 |
+
Recomputation. One of our goals is to not store $O ( N ^ { 2 } )$ intermediate values for the backward pass. The backward pass typically requires the matrices $\mathbf { S } , \mathbf { \dot { P } } \in \mathrm { \mathbb { R } } ^ { N \times N }$ to compute the gradients with respect to Q,K,V. However, by storing the output $\mathbf { o }$ and the softmax normalization statistics $( m , \ell )$ , we can recompute the attention matrix $\mathbf { s }$ and $\mathbf { P }$ easily in the backward pass from blocks of $\mathbf { Q } , \mathbf { K } , \mathbf { V }$ in SRAM. This can be seen as a form of selective gradient checkpointing [10, 36]. While gradient checkpointing has been suggested to reduce the maximum amount of memory required [69], all implementations (that we know off) have to trade speed for memory. In contrast, even with more FLOPs, our recomputation speeds up the backward pass due to reduced HBM accesses (Fig. 2). The full backward pass description is in Appendix B.
|
| 106 |
+
|
| 107 |
+
Implementation details: Kernel fusion. Tiling enables us to implement our algorithm in one CUDA kernel, loading input from HBM, performing all the computation steps (matrix multiply, softmax, optionally masking and dropout, matrix multiply), then write the result back to HBM (masking and dropout in Appendix B). This avoids repeatedly reading and writing of inputs and outputs from and to HBM.
|
| 108 |
+
|
| 109 |
+
# Algorithm 1 FLASHATTENTION
|
| 110 |
+
|
| 111 |
+
Require: Matrices $\mathbf { Q } , \mathbf { K } , \mathbf { V } \in \mathbb { R } ^ { N \times d }$ in HBM, on-chip SRAM of size $M$ .
|
| 112 |
+
1: Set block sizes $\begin{array} { r } { B _ { c } = \lceil \frac { M } { 4 d } \rceil , B _ { r } = \operatorname* { m i n } ( \lceil \frac { M } { 4 d } \rceil , d ) } \end{array}$ .
|
| 113 |
+
2: Initialize ${ \bf O } = ( 0 ) _ { N \times d } \in { \mathbb R } ^ { N \times d }$ , $\mathcal { \ell } = ( 0 ) _ { N } \in \mathbb { R } ^ { N } , m = ( - \infty ) _ { N } \in \mathbb { R } ^ { N }$ in HBM.
|
| 114 |
+
3: Divide $\mathbf { Q }$ into $\begin{array} { r } { T _ { r } = \left\lceil \frac { N } { B _ { r } } \right\rceil } \end{array}$ blocks $\mathbf { Q } _ { 1 } , . . . , \mathbf { Q } _ { T _ { r } }$ of size $B _ { r } \times d$ each, and divide $\mathbf { K } , \mathbf { V }$ in to $\begin{array} { r } { T _ { c } = \left\lceil \frac { N } { B _ { c } } \right\rceil } \end{array}$
|
| 115 |
+
blocks ${ \bf K } _ { 1 } , . . . , { \bf K } _ { T _ { c } }$ and $\dot { \mathbf { V } } _ { 1 } , . . . , \mathbf { V } _ { T _ { c } }$ , of size $B _ { c } { \times } d$ each.
|
| 116 |
+
4: Divide $\mathbf { o }$ into $T _ { r }$ blocks $\mathbf { 0 } _ { i } , . . . , \mathbf { 0 } _ { T _ { r } }$ of size $B _ { r } { \times } d$ each, divide $\ell$ into $T _ { r }$ blocks $\ell _ { i } , . . . , \ell _ { T _ { r } }$ of size
|
| 117 |
+
$B _ { r }$ each, divide $m$ into $T _ { r }$ blocks $m _ { 1 } , . . . , m _ { T _ { r } }$ of size $B _ { r }$ each.
|
| 118 |
+
5: for $1 \leq j \leq T _ { c }$ do
|
| 119 |
+
6: Load $\mathbf { K } _ { j } , \mathbf { V } _ { j }$ from HBM to on-chip SRAM.
|
| 120 |
+
7: for $1 \leq i \leq T _ { r }$ do
|
| 121 |
+
8: Load $\mathbf { Q } _ { i } , \mathbf { O } _ { i } , \ell _ { i } , m _ { i }$ from HBM to on-chip SRAM.
|
| 122 |
+
9: On chip, compute $\mathbf { S } _ { i j } = \mathbf { Q } _ { i } \mathbf { K } _ { j } ^ { T } \in \mathbb { R } ^ { B _ { r } \times B _ { c } }$ .
|
| 123 |
+
10: On chip, compute $\tilde { m } _ { i j } = \mathrm { r o w m a x } ( \mathbf { S } _ { i j } ) \in \mathbb { R } ^ { B _ { r } }$ , $\tilde { \mathbf { P } } _ { i j } = \exp ( \mathbf { S } _ { i j } - \tilde { m } _ { i j } ) \in \mathbb { R } ^ { B _ { r } \times B _ { c } }$ (pointwise),
|
| 124 |
+
$\widetilde { \ell } _ { i j } = \mathrm { r o w s u m } ( \tilde { \mathbf { P } } _ { i j } ) \in \mathbb { R } ^ { \tilde { B } _ { r } }$ .
|
| 125 |
+
11: On chip, compute $m _ { i } ^ { \mathrm { n e w } } { = } \operatorname* { m a x } ( m _ { i } , \tilde { m } _ { i j } ) \in { \mathbb R } ^ { B _ { r } }$ , $\ell _ { i } ^ { \mathrm { n e w } } = e ^ { m _ { i } - m _ { i } ^ { \mathrm { n e w } } } \ell _ { i } + e ^ { \tilde { m } _ { i j } - m _ { i } ^ { \mathrm { n e w } } } \tilde { \ell } _ { i j } \in \mathbb { R } ^ { B _ { r } } .$
|
| 126 |
+
12: Write $\mathbf O _ { i } \gets \mathrm { d i a g } ( \ell _ { i } ^ { \mathrm { n e w } } ) ^ { - 1 } ( \mathrm { d i a g } ( \ell _ { i } ) e ^ { m _ { i } - m _ { i } ^ { \mathrm { n e w } } } \mathbf O _ { i } + e ^ { \tilde { m } _ { i j } - m _ { i } ^ { \mathrm { n e w } } } \tilde { \mathbf P } _ { i j } \mathbf V _ { j } )$ to HBM.
|
| 127 |
+
13: Write $\ell _ { i } \gets \ell _ { i } ^ { \mathrm { n e w } }$ , $m _ { i } \gets m _ { i } ^ { \mathrm { n e w } }$ to HBM.
|
| 128 |
+
14: end for
|
| 129 |
+
15: end for
|
| 130 |
+
16: Return O.
|
| 131 |
+
|
| 132 |
+
We show FLASHATTENTION’s correctness, runtime, and memory requirement (proof in Appendix C).
|
| 133 |
+
|
| 134 |
+
Theorem 1. Algorithm 1 returns ${ \bf O } = \mathrm { s o f t m a x } ( { \bf Q } { \bf K } ^ { \top } ) { \bf V }$ with $O ( N ^ { 2 } d )$ FLOPs and requires $O ( N )$ additional memory beyond inputs and output.
|
| 135 |
+
|
| 136 |
+
# 3.2 Analysis: IO Complexity of FLASHATTENTION
|
| 137 |
+
|
| 138 |
+
We analyze the IO complexity of FLASHATTENTION, showing significant reduction in HBM accesses compared to standard attention. We also provide a lower bound, proving that no exact attention algorithm can asymptotically improve on HBM accesses over all SRAM sizes. Proofs are in Appendix C.
|
| 139 |
+
|
| 140 |
+
Theorem 2. Let $N$ be the sequence length, ?? be the head dimension, and ?? be size of SRAM with $d \leq M \leq N d$ . Standard attention (Algorithm 0) requires $\Theta ( N d + N ^ { 2 } )$ HBM accesses, while FLASHATTENTION (Algorithm $^ { l }$ ) requires $\breve { \Theta } ( N ^ { 2 } d ^ { 2 } M ^ { - 1 } )$ HBM accesses.
|
| 141 |
+
|
| 142 |
+
For typical values of $d$ (64-128) and $M$ (around 100KB), $d ^ { 2 }$ is many times smaller than $M$ , and thus FLASHATTENTION requires many times fewer HBM accesses than standard implementation. This leads to both faster execution and lower memory footprint, which we validate in Section 4.3.
|
| 143 |
+
|
| 144 |
+
The main idea of the proof is that given the SRAM size of $M$ , we can load blocks of $\mathbf { K } , \mathbf { V }$ of size $\Theta ( M )$ each (Algorithm 1 line 1). For each block of $\mathbf { K }$ and $\mathbf { V }$ , we iterate over all blocks of $\mathbf { Q }$ (Algorithm 1 line 1) to compute the intermediate values, resulting in $\Theta ( N d M ^ { - 1 } )$ passes over Q. Each pass loads $\Theta ( N d )$ elements, which amounts to $\Theta ( \dot { N } ^ { 2 } d ^ { 2 } M ^ { - 1 } )$ HBM accesses. We similarly prove that the backward pass of standard attention requires $\Theta ( N d + N ^ { 2 } )$ HBM accesses while the backward pass of FLASHATTENTION requires $\Theta ( N ^ { 2 } d ^ { 2 } M ^ { - 1 } )$ HBM accesses (Appendix B).
|
| 145 |
+
|
| 146 |
+
We prove a lower-bound: one cannot asymptotically improve on the number of HBM accesses for all values of $M$ (the SRAM size) when computing exact attention.
|
| 147 |
+
|
| 148 |
+

|
| 149 |
+
Figure 2: Left: Forward $^ +$ backward runtime of standard attention and FLASHATTENTION for seq. length 1024, head dim. 64, 16 heads, batch size 64, key-padding mask and no dropout on A100 GPU. HBM access is one of the primary factors affecting runtime. Middle: Forward runtime of FLASHATTENTION (seq. length 1024, head dim. 64, 16 heads, batch size 64) on A100 GPU. Fewer HBM accesses result in faster runtime, up to a point. Right: The runtime (for seq. length 4K) of block-sparse FLASHATTENTION is faster than FLASHATTENTION by a factor proportional to the sparsity.
|
| 150 |
+
|
| 151 |
+
Proposition 3. Let ?? be the sequence length, ?? be the head dimension, and $M$ be size of SRAM with $d \leq \bar { M } \leq N d$ . There does not exist an algorithm to compute exact attention with $o ( N ^ { 2 } d ^ { 2 } M ^ { - 1 } ) ,$ ) HBM accesses for all ?? in the range [??,?? ??].
|
| 152 |
+
|
| 153 |
+
The proof relies on the fact that for $M = \Theta ( N d )$ any algorithm must perform $\Omega ( N ^ { 2 } d ^ { 2 } M ^ { - 1 } ) = \Omega ( N d )$ HBM accesses. This type of lower bound over a subrange of $M$ is common in the streaming algorithms literature [92]. We leave proving parameterized complexity [29] lower bounds in terms of $M$ as exciting future work.
|
| 154 |
+
|
| 155 |
+
We validate that the number of HBM accesses is the main determining factor of attention run-time. In Fig. 2 (left), we see that even though FLASHATTENTION has higher FLOP count compared to standard attention (due to recomputation in the backward pass), it has much fewer HBM accesses, resulting in much faster runtime. In Fig. 2 (middle), we vary the block size $B _ { c }$ of FLASHATTENTION, which results in different amounts of HBM accesses, and measure the runtime of the forward pass. As block size increases, the number of HBM accesses decreases (as we make fewer passes over the input), and runtime decreases. For large enough block size (beyond 256), the runtime is then bottlenecked by other factors (e.g., arithmetic operations). Moreover, larger block size will not fit into the small SRAM size.
|
| 156 |
+
|
| 157 |
+
# 3.3 Extension: Block-Sparse FLASHATTENTION
|
| 158 |
+
|
| 159 |
+
We extend FLASHATTENTION to approximate attention: we propose block-sparse FLASHATTENTION, whose IO complexity is smaller than FLASHATTENTION by a factor proportional to the sparsity.
|
| 160 |
+
|
| 161 |
+
iven inputs ${ \mathbf { Q } } , { \mathbf { K } } , { \mathbf { V } } \in \mathbb { R } ^ { N \times d }$ and a mask matrix $\tilde { \mathbf { M } } \in \{ 0 , 1 \} ^ { N \times N }$ , we want to compute:
|
| 162 |
+
|
| 163 |
+
where $( \mathbf { S } \odot \mathbb { 1 } _ { \tilde { \mathbf { M } } } ) _ { k l } = \mathbf { S } _ { k l }$ if $\tilde { \mathbf { M } } _ { k l } = 1$ and $- \infty$ if ${ \bf M } _ { k l } = 0$ . We require $\tilde { \textbf { M } }$ to have block form: for some block sizes $B _ { r } , B _ { c }$ , for all $^ { k , l }$ , $\tilde { \mathbf { M } } _ { k , l } = \mathbf { M } _ { i j }$ with $i = \lfloor k / B _ { r } \rfloor , j = \lfloor l / B _ { c } \rfloor$ for some $\mathbf { M } \in \{ 0 , 1 \} ^ { N / B _ { r } \times N / B _ { c } }$
|
| 164 |
+
|
| 165 |
+
Given a predefined block sparsity mask $\mathbf { M } \in \{ 0 , 1 \} ^ { N / B _ { r } \times N / B _ { c } }$ we can easily adapt Algorithm 1 to only compute the nonzero blocks of the attention matrix. The algorithm is identical to Algorithm 1, except we skip zero blocks. We reproduce the algorithm description in Algorithm 5 in Appendix B.
|
| 166 |
+
|
| 167 |
+
We also analyze the IO complexity of block-sparse FLASHATTENTION.
|
| 168 |
+
|
| 169 |
+
Proposition 4. Let ?? be the sequence length, ?? be the head dimension, and ?? be size of SRAM with $d \leq M \leq N d$ . Block-sparse FLASHATTENTION (Algorithm 5) requires $\Theta ( N d + N ^ { 2 } d ^ { 2 } \mathbf { \tilde { \mathit { M } } } ^ { - 1 } s )$ HBM accesses where ?? is the fraction of nonzero blocks in the block-sparsity mask.
|
| 170 |
+
|
| 171 |
+
We see that applying block-sparsity yields a direct improvement by the sparsity to the larger term in the IO complexity. For large sequence lengths √ $N$ , $s$ is often set to $\dot { N } ^ { - 1 / 2 }$ [12] or $N ^ { - 1 } \mathrm { l o g } N$ [3, 18, 96], resulting in $\Theta ( N \sqrt { N } )$ or $\Theta ( N \mathrm { l o g } N )$ IO complexity. For downstream experiments, we use the fixed butterfly sparsity pattern [18], which has been shown to be able to approximate arbitrary sparsity [17].
|
| 172 |
+
|
| 173 |
+
In Fig. 2 (right), we validate that as the sparsity increases, the runtime of block-sparse FLASHATTENTION improves proportionally. On the LRA benchmark, block-sparse FLASHATTENTION achieves $2 . 8 \times$ speedup, while performing on par with standard attention (Section 4).
|
| 174 |
+
|
| 175 |
+
# 4 Experiments
|
| 176 |
+
|
| 177 |
+
We evaluate the impact of using FLASHATTENTION to train Transformer models. We validate two claims about training time and model accuracy, and report attention runtime and memory benchmarks.
|
| 178 |
+
|
| 179 |
+
• Training Speed. FLASHATTENTION outperforms the MLPerf 1.1 [60] speed record for BERT by $15 \%$ , and speeds up GPT-2 up to $3 \times$ over HuggingFace [91] and $1 . 8 \times$ over Megatron [80] over standard Transformers. FLASHATTENTION speeds up the long-range arena (LRA) benchmark $2 . 4 \times$ . Quality. FLASHATTENTION scales Transformers to longer sequences, yielding higher quality. FLASHATTENTION trains GPT-2 with context length 4K faster than Megatron trains GPT-2 with context length 1K, while achieving 0.7 better perplexity. Modeling longer sequences yields 6.4 points of lift on two long-document classification tasks. Finally, FLASHATTENTION yields the first Transformer that can achieve better-than-random performance on the challenging Path-X task (sequence length 16K), and block-sparse FLASHATTENTION yields the first sequence model that we know of that can achieve better-than-random performance on Path-256 (sequence length 64K). Benchmarking Attention. We measure the runtime and memory performance of FLASHATTENTION and block-sparse FLASHATTENTION based on sequence length. We confirm that the memory footprint of FLASHATTENTION scales linearly with seq. length and is up to $3 \times$ faster than standard attention for common seq. lengths (up to 2K). We confirm that runtime of block-sparse FLASHATTENTION scales linearly in seq. length and is faster than all existing approximate attention baselines.
|
| 180 |
+
|
| 181 |
+
Additional experiment details are in Appendix E.
|
| 182 |
+
|
| 183 |
+
# 4.1 Faster Models with FLASHATTENTION
|
| 184 |
+
|
| 185 |
+
BERT. FLASHATTENTION yields the fastest single-node BERT training speed that we know of. We train a BERT-large [24] model with FLASHATTENTION on Wikipedia. Table 1 compares our training time to the implementation from Nvidia that set the training speed record for MLPerf 1.1 [60, 63]. Our implementation is $15 \%$ faster.
|
| 186 |
+
|
| 187 |
+
Table 1: Training time of BERT-large, starting from the same initialization provided by the MLPerf benchmark, to reach the target accuracy of $7 2 . 0 \%$ on masked language modeling. Averaged over 10 runs on $8 \times \mathrm { A 1 0 0 }$ GPUs.
|
| 188 |
+
|
| 189 |
+
<table><tr><td>BERTImplementation</td><td>Training time (minutes)</td></tr><tr><td>NvidiaMLPerf1.1[63]</td><td>20.0± 1.5</td></tr><tr><td>FLASHATTENTION (Ours)</td><td>17.4 ± 1.4</td></tr></table>
|
| 190 |
+
|
| 191 |
+
GPT-2. FLASHATTENTION yields faster training times for GPT-2 [70] on the large OpenWebtext dataset [34] than the widely used HuggingFace [91] and Megatron-LM [80] implementations. Table 2 shows up to $3 \times$ end-to-end speedup compared to Huggingface and $1 . 7 \times$ speedup compared to Megatron-LM. FLASHATTENTION achieves the same perplexity as the other two implementations, as we do not change the model definition. Appendix E includes plots of the validation perplexity throughout training, confirming that FLASHATTENTION is as numerically stable as the baselines and produces the same training / validation curves.
|
| 192 |
+
|
| 193 |
+
Table 2: GPT-2 small and medium using FLASHATTENTION achieve up to $3 \times$ speed up compared to Huggingface implementation and up to $1 . 7 \times$ compared to Megatron-LM. Training time reported on $8 \mathrm { { \times A l 0 0 s } }$ GPUs.
|
| 194 |
+
|
| 195 |
+
<table><tr><td>Model implementations</td><td>Open WebText (ppl)</td><td>Training time (speedup)</td></tr><tr><td rowspan="3">GPT-2 small - Huggingface [91] GPT-2 small - Megatron-LM[80] GPT-2 small - FLASHATTENTION</td><td>18.2</td><td>9.5 days (1.0x)</td></tr><tr><td>18.2</td><td>4.7 days (2.0x)</td></tr><tr><td>18.2</td><td>2.7 days (3.5x)</td></tr><tr><td rowspan="2">GPT-2 medium- Huggingface [91] GPT-2 medium-Megatron-LM[80]</td><td>14.2</td><td>21.0 days (1.0x)</td></tr><tr><td>14.2</td><td>11.5 days (1.8×)</td></tr><tr><td>GPT-2 medium-FLASHATTENTION</td><td>14.2</td><td>6.9 days (3.0x)</td></tr></table>
|
| 196 |
+
|
| 197 |
+
Long-range Arena. We compare vanilla Transformer (with either standard implementation or FLASHATTENTION) on the long-range arena (LRA [83]) benchmark. We measure accuracy, throughput, and training time of all models. Each task has a different sequence length varying between 1024 and 4096. We follow the implementation and experimental setting in Tay et al. [83]and Xiong et al. [94].3 Table 3 shows that FLASHATTENTION achieves up $2 . 4 \times$ speed-up compared to standard attention. Block-sparse FLASHATTENTION is faster than all of the approximate attention methods that we have tested.
|
| 198 |
+
|
| 199 |
+
# 4.2 Better Models with Longer Sequences
|
| 200 |
+
|
| 201 |
+
Language Modeling with Long Context. The runtime and memory-efficiency of FLASHATTENTION allow us to increase the context length of GPT-2 by $4 \times$ while still running faster than the optimized implementation from Megatron-LM. Table 4 shows that that GPT-2 with
|
| 202 |
+
|
| 203 |
+
Table 3: The performance of standard attention, FLASHATTENTION, block-sparse FLASHATTENTION, and approximate attention baselines on the Long-Range-Arena benchmarks.
|
| 204 |
+
|
| 205 |
+
<table><tr><td>Models</td><td>ListOps</td><td>Text</td><td>Retrieval</td><td>Image</td><td>Pathfinder</td><td>Avg</td><td>Speedup</td></tr><tr><td>Transformer</td><td>36.0</td><td>63.6</td><td>81.6</td><td>42.3</td><td>72.7</td><td>59.3</td><td>=</td></tr><tr><td>FLASHATTENTION</td><td>37.6</td><td>63.9</td><td>81.4</td><td>43.5</td><td>72.7</td><td>59.8</td><td>2.4×</td></tr><tr><td>Block-sparse FLASHATTENTION</td><td>37.0</td><td>63.0</td><td>81.3</td><td>43.6</td><td>73.3</td><td>59.6</td><td>2.8×</td></tr><tr><td>Linformer [88]</td><td>35.6</td><td>55.9</td><td>77.7</td><td>37.8</td><td>67.6</td><td>54.9</td><td>2.5×</td></tr><tr><td>Linear Attention [52]</td><td>38.8</td><td>63.2</td><td>80.7</td><td>42.6</td><td>72.5</td><td>59.6</td><td>2.3×</td></tr><tr><td>Performer [13]</td><td>36.8</td><td>63.6</td><td>82.2</td><td>42.1</td><td>69.9</td><td>58.9</td><td>1.8×</td></tr><tr><td>Local Attention [83]</td><td>36.1</td><td>60.2</td><td>76.7</td><td>40.6</td><td>66.6</td><td>56.0</td><td>1.7×</td></tr><tr><td>Reformer[53]</td><td>36.5</td><td>63.8</td><td>78.5</td><td>39.6</td><td>69.4</td><td>57.6</td><td>1.3×</td></tr><tr><td>Smyrf [20]</td><td>36.1</td><td>64.1</td><td>79.0</td><td>39.6</td><td>70.5</td><td>57.9</td><td>1.7×</td></tr></table>
|
| 206 |
+
|
| 207 |
+
FLASHATTENTION and context length 4K is still $30 \%$ faster than GPT-2 from Megatron with context length 1K, while achieving 0.7 better perplexity.
|
| 208 |
+
|
| 209 |
+
Table 4: GPT-2 small with FLASHATTENTION, with $4 \times$ larger context length compared to Megatron-LM, is still $30 \%$ faster while achieving 0.7 better perplexity. Training time on $8 \times \mathrm { A 1 0 0 }$ GPUs is reported.
|
| 210 |
+
|
| 211 |
+
<table><tr><td>Model implementations</td><td>Context length</td><td>OpenWebText (ppl)</td><td>Training time (speedup)</td></tr><tr><td>GPT-2small-Megatron-LM</td><td>1k</td><td>18.2</td><td>4.7 days (1.0x)</td></tr><tr><td>GPT-2 small-FLASHATTENTION</td><td>1k</td><td>18.2</td><td>2.7 days (1.7×)</td></tr><tr><td>GPT-2 small -FLASHATTENTION</td><td>2k</td><td>17.7</td><td>3.0 days (1.6x)</td></tr><tr><td>GPT-2 small-FLASHATTENTION</td><td>4k</td><td>17.2</td><td>3.6 days (1.3x)</td></tr></table>
|
| 212 |
+
|
| 213 |
+
Long Document Classification. Training Transformers with longer sequences with FLASHATTENTION improves performance on the MIMIC-III [49] and ECtHR [6, 7] datasets. MIMIC-III contains intensive care unit patient discharge summaries, each annotated with multiple labels. ECtHR contains legal cases from the European Court of Human Rights, each of which is mapped to articles of the Convention of Human Rights that were allegedly violaged. Both of these datasets contain very long text documents; the average number of tokens in MIMIC is 2,395 tokens, and the longest document contains 14,562 tokens, while the average and longest numbers in ECtHR are 2,197 and 49,392, respectively. We evaluate lift from increasing the sequence length of a pretrained RoBERTa model [58] (we repeat the positional embeddings, as in Beltagy et al. [3]).
|
| 214 |
+
|
| 215 |
+
Table 5 shows that sequence length 16K outperforms length 512 by 4.3 points on MIMIC, and that length 8K outperforms length 512 by 8.5 points on ECtHR. The discrepancies may be due to subtle distribution shifts: MIMIC-III contains specialized medical text and thus may be more susceptible to a distribution shift in the document length, whereas ECtHR contains general language.
|
| 216 |
+
|
| 217 |
+
Table 5: Long Document performance (micro $F _ { 1 }$ ) at different sequence lengths using FLASHATTENTION.
|
| 218 |
+
|
| 219 |
+
<table><tr><td></td><td>512</td><td>1024</td><td>2048</td><td>4096</td><td>8192</td><td>16384</td></tr><tr><td>MIMIC-III [49]</td><td>52.8</td><td>50.7</td><td>51.7</td><td>54.6</td><td>56.4</td><td>57.1</td></tr><tr><td>ECtHR[6]</td><td>72.2</td><td>74.3</td><td>77.1</td><td>78.6</td><td>80.7</td><td>79.2</td></tr></table>
|
| 220 |
+
|
| 221 |
+
Table 6: We report the first Transformer model that can achieve non-random performance on Path- $\mathbf { \delta X }$ and Path-256.
|
| 222 |
+
|
| 223 |
+
<table><tr><td>Model</td><td>Path-X</td><td>Path-256</td></tr><tr><td>Transformer</td><td>X</td><td>X</td></tr><tr><td>Linformer[88]</td><td>X</td><td>X</td></tr><tr><td>Linear Attention [52]</td><td>X</td><td>X</td></tr><tr><td>Performer[13]</td><td>X</td><td>X</td></tr><tr><td>Local Attention [83]</td><td>X</td><td>X</td></tr><tr><td>Reformer[53]</td><td>X</td><td>X</td></tr><tr><td>SMYRF[20]</td><td>X</td><td>X</td></tr><tr><td>FLASHATTENTION</td><td>61.4</td><td>X</td></tr><tr><td>Block-sparse FLASHATTENTION</td><td>56.0</td><td>63.1</td></tr></table>
|
| 224 |
+
|
| 225 |
+
Path-X and Path-256. The Path-X and Path-256 benchmarks are challenging tasks from the long-range arena benchmark designed to test long context. The task is to classify whether two points in a black and white $1 2 8 \times 1 2 8$ (or $2 5 6 \times 2 5 6$ ) image have a path connecting them, and the images are fed to the transformer one pixel at a time. In prior work, all transformer models have either run out of memory, or only achieved random performance [83]. There has been a search for alternative architectures that can model such long context [39]. We present here the first result of Transformer models being able to solve Path-X and Path-256 (Table 6). We pretrain a transformer on Path-64, and then transfer to Path-X by spatially interpolating the positional embeddings. FLASHATTENTION achieves 61.4 accuracy on Path-X. Additionally, block-sparse FLASHATTENTION enables the Transformers to scale to sequence length 64K, achieving 63.1 accuracy4 on Path-256.
|
| 226 |
+
|
| 227 |
+

|
| 228 |
+
Figure 3: Left: runtime of forward pass $^ +$ backward pass. Right: attention memory usage.
|
| 229 |
+
|
| 230 |
+
# 4.3 Benchmarking Attention
|
| 231 |
+
|
| 232 |
+
We vary sequence length and measure runtime and memory usage of FLASHATTENTION and block-sparse FLASHATTENTION against various attention baselines on one A100 GPU with $4 0 \mathrm { G B }$ HBM, with dropout and a padding mask. We compare against reference implementations for exact attention, approximate attention, and sparse attention. We report a subset of baselines in the main body; Appendix E contains more baselines and full details.
|
| 233 |
+
|
| 234 |
+
Runtime. Figure 3 (left) reports the runtime in milliseconds of the forward $^ +$ backward pass of FLASHATTENTION and block-sparse FLASHATTENTION compared to the baselines in exact, approximate, and sparse attention (exact numbers in Appendix E). Runtime grows quadratically with sequence length, but FLASHATTENTION runs significantly faster than exact attention baselines, up to $3 \times$ faster than the PyTorch implementation. The runtimes of many approximate/sparse attention mechanisms grow linearly with sequence length, but FLASHATTENTION still runs faster than approximate and sparse attention for short sequences due to fewer memory accesses. The approximate attention runtimes begin to cross over with FLASHATTENTION at sequences between 512 and 1024. On the other hand, block-sparse FLASHATTENTION is faster than all implementations of exact, sparse, and approximate attention that we know of, across all sequence lengths.
|
| 235 |
+
|
| 236 |
+
Memory Footprint. Figure 3 (right) shows the memory footprint of FLASHATTENTION and block-sparse FLASHATTENTION compared to various exact, approximate, and sparse attention baselines. FLASHATTENTION and block-sparse FLASHATTENTION have the same memory footprint, which grows linearly with sequence length. FLASHATTENTION is up to $2 0 \times$ more memory efficient than exact attention baselines, and is more memory-efficient than the approximate attention baselines. All other algorithms except for Linformer run out of memory on an A100 GPU before 64K, and FLASHATTENTION is still $2 \times$ more efficient than Linformer.
|
| 237 |
+
|
| 238 |
+
# 5 Limitations and Future Directions
|
| 239 |
+
|
| 240 |
+
We discuss limitations of our approach and future directions. Related work is given in Appendix A.
|
| 241 |
+
|
| 242 |
+
Compiling to CUDA. Our current approach to building IO-aware implementations of attention requires writing a new CUDA kernel for each new attention implementation. This requires writing the attention algorithm in a considerably lower-level language than PyTorch, and requires significant engineering effort. Implementations may also not be transferrable across GPU architectures. These limitations suggest the need for a method that supports writing attention algorithms in a high-level language (e.g., PyTorch), and compiling to IO-aware implementations in CUDA—similar to efforts such as Halide in image processing [73].
|
| 243 |
+
|
| 244 |
+
IO-Aware Deep Learning. We believe that the IO-aware approach can extend beyond attention. Attention is the most memory-intensive computation in Transformers, but every layer in a deep network touches GPU HBM. We hope our work inspires IO-aware implementations of additional modules. We discuss these potential extensions in Appendix D.
|
| 245 |
+
|
| 246 |
+
Multi-GPU IO-Aware Methods. Our IO-aware implementation of attention is optimal within constants for computing attention on a single GPU. However, the attention computation may be parallelizable across multiple GPUs [75]. Using multiple GPUs adds an additional layer to IO analysis— accounting for data transfer between GPUs. We hope our work inspires future work in this direction.
|
| 247 |
+
|
| 248 |
+
Societal Impacts. As Transformer-based foundation models grow in size and data, our work seeks to understand how to train these large models more efficiently. This may allow a general community with limited access to computational resources to train and understand those foundation models. Our method is applicable to all Transformer-based models, which have a variety of applications, both positive and negative. For example, language modeling may make it easier to spread misinformation, while image classification models may make automatic surveillance easier. Alleviating these risks requires addressing application-specific issues such as privacy, bias, and discrimination.
|
| 249 |
+
|
| 250 |
+
# Acknowledgments
|
| 251 |
+
|
| 252 |
+
Our implementation uses Apex’s FMHA code (https://github.com/NVIDIA/apex/tree/ master/apex/contrib/csrc/fmha) as a starting point. We thank Young-Jun Ko for the in-depth explanation of his FMHA implementation and for his thoughtful answers to our questions about CUDA. We thank Sabri Eyuboglu, Megan Leszczynski, Laurel Orr, Yuhuai Wu, Beidi Chen, and Xun Huang for their constructive feedback and suggestions on early drafts of the paper. We thank Markus Rabe and Charles Staats for helpful discussion of their attention algorithm.
|
| 253 |
+
|
| 254 |
+
We gratefully acknowledge the support of NIH under No. U54EB020405 (Mobilize), NSF under Nos. CCF1763315 (Beyond Sparsity), CCF1563078 (Volume to Velocity), and 1937301 (RTML); ARL under No. W911NF-21-2-0251 (Interactive Human-AI Teaming); ONR under No. N000141712266 (Unifying Weak Supervision); ONR N00014-20-1-2480: Understanding and Applying Non-Euclidean Geometry in Machine Learning; N000142012275 (NEPTUNE); NXP, Xilinx, LETI-CEA, Intel, IBM, Microsoft, NEC, Toshiba, TSMC, ARM, Hitachi, BASF, Accenture, Ericsson, Qualcomm, Analog Devices, Google Cloud, Salesforce, Total, the HAI-GCP & HAI-Azure Cloud Credits for Research program, the Stanford Data Science Initiative (SDSI), Department of Defense (DoD) through the National Defense Science and Engineering Graduate Fellowship (NDSEG) Program, and members of the Stanford DAWN project: Facebook, Google, and VMWare. The U.S. Government is authorized to reproduce and distribute reprints for Governmental purposes notwithstanding any copyright notation thereon. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views, policies, or endorsements, either expressed or implied, of NIH, ONR, or the U.S. Government. Atri Rudra’s research is supported by NSF grant CCF-1763481.
|
| 255 |
+
|
| 256 |
+
# References
|
| 257 |
+
|
| 258 |
+
[1] Alok Aggarwal and S Vitter, Jeffrey. The input/output complexity of sorting and related problems. Communications of the ACM, 31(9):1116–1127, 1988.
|
| 259 |
+
[2] Irwan Bello. LambdaNetworks: Modeling long-range interactions without attention. arXiv preprint arXiv:2102.08602, 2021.
|
| 260 |
+
[3] Iz Beltagy, Matthew E Peters, and Arman Cohan. Longformer: The long-document transformer. arXiv preprint arXiv:2004.05150, 2020.
|
| 261 |
+
[4] L Susan Blackford, Antoine Petitet, Roldan Pozo, Karin Remington, R Clint Whaley, James Demmel, Jack Dongarra, Iain Duff, Sven Hammarling, Greg Henry, et al. An updated set of basic linear algebra subprograms (blas). ACM Transactions on Mathematical Software, 28(2): 135–151, 2002.
|
| 262 |
+
[5] 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.
|
| 263 |
+
[6] Ilias Chalkidis, Ion Androutsopoulos, and Nikolaos Aletras. Neural legal judgment prediction in English. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 4317–4323, Florence, Italy, 2019. Association for Computational Linguistics. doi: 10.18653/v1/P19-1424. URL https://www.aclweb.org/anthology/P19-1424.
|
| 264 |
+
[7] Ilias Chalkidis, Manos Fergadiotis, Dimitrios Tsarapatsanis, Nikolaos Aletras, Ion Androutsopoulos, and Prodromos Malakasiotis. Paragraph-level rationale extraction through regularization: A case study on european court of human rights cases. In Proceedings of
|
| 265 |
+
|
| 266 |
+
the Annual Conference of the North American Chapter of the Association for Computational Linguistics, Mexico City, Mexico, 2021. Association for Computational Linguistics.
|
| 267 |
+
|
| 268 |
+
[8] Benjamin Charlier, Jean Feydy, Joan Alexis Glaunès, François-David Collin, and Ghislain Durif. Kernel operations on the gpu, with autodiff, without memory overflows. Journal of Machine Learning Research, 22(74):1–6, 2021. URL http://jmlr.org/papers/v22/20-275.html.
|
| 269 |
+
|
| 270 |
+
[9] Beidi Chen, Tri Dao, Eric Winsor, Zhao Song, Atri Rudra, and Christopher Ré. Scatterbrain: Unifying sparse and low-rank attention. In Advances in Neural Information Processing Systems (NeurIPS), 2021.
|
| 271 |
+
|
| 272 |
+
[10] Tianqi Chen, Bing Xu, Chiyuan Zhang, and Carlos Guestrin. Training deep nets with sublinear memory cost. arXiv preprint arXiv:1604.06174, 2016.
|
| 273 |
+
|
| 274 |
+
[11] Tianqi Chen, Thierry Moreau, Ziheng Jiang, Lianmin Zheng, Eddie Yan, Haichen Shen, Meghan Cowan, Leyuan Wang, Yuwei Hu, Luis Ceze, et al. $\{ \mathrm { T V M } \}$ : An automated {End-to-End} optimizing compiler for deep learning. In 13th USENIX Symposium on Operating Systems Design and Implementation (OSDI 18), pages 578–594, 2018.
|
| 275 |
+
|
| 276 |
+
[12] Rewon Child, Scott Gray, Alec Radford, and Ilya Sutskever. Generating long sequences with sparse transformers. arXiv preprint arXiv:1904.10509, 2019.
|
| 277 |
+
|
| 278 |
+
[13] Krzysztof Marcin Choromanski, Valerii Likhosherstov, David Dohan, Xingyou Song, Andreea Gane, Tamas Sarlos, Peter Hawkins, Jared Quincy Davis, Afroz Mohiuddin, Lukasz Kaiser, et al. Rethinking attention with performers. In International Conference on Learning Representations (ICLR), 2020.
|
| 279 |
+
|
| 280 |
+
[14] Xiang Dai, Ilias Chalkidis, Sune Darkner, and Desmond Elliott. Revisiting transformer-based models for long document classification. arXiv preprint arXiv:2204.06683, 2022.
|
| 281 |
+
|
| 282 |
+
[15] Zihang Dai, Zhilin Yang, Yiming Yang, Jaime G Carbonell, Quoc Le, and Ruslan Salakhutdinov. Transformer-XL: Attentive language models beyond a fixed-length context. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 2978–2988, 2019.
|
| 283 |
+
|
| 284 |
+
[16] Tri Dao, Albert Gu, Matthew Eichhorn, Atri Rudra, and Christopher Ré. Learning fast algorithms for linear transforms using butterfly factorizations. In International Conference on Machine Learning (ICML), 2019.
|
| 285 |
+
|
| 286 |
+
[17] Tri Dao, Nimit Sohoni, Albert Gu, Matthew Eichhorn, Amit Blonder, Megan Leszczynski, Atri Rudra, and Christopher Ré. Kaleidoscope: An efficient, learnable representation for all structured linear maps. In International Conference on Learning Representations (ICLR), 2020.
|
| 287 |
+
|
| 288 |
+
[18] Tri Dao, Beidi Chen, Kaizhao Liang, Jiaming Yang, Zhao Song, Atri Rudra, and Christopher Ré. Pixelated butterfly: Simple and efficient sparse training for neural network models. In International Conference on Learning Representations (ICLR), 2022.
|
| 289 |
+
|
| 290 |
+
[19] Tri Dao, Beidi Chen, Nimit Sohoni, Arjun Desai, Michael Poli, Jessica Grogan, Alexander Liu, Aniruddh Rao, Atri Rudra, and Christopher Ré. Monarch: Expressive structured matrices for efficient and accurate training. In International Conference on Machine Learning (ICML), 2022.
|
| 291 |
+
|
| 292 |
+
[20] Giannis Daras, Nikita Kitaev, Augustus Odena, and Alexandros G Dimakis. Smyrf-efficient attention using asymmetric clustering. Advances in Neural Information Processing Systems, 33:6476–6489, 2020.
|
| 293 |
+
|
| 294 |
+
[21] Christopher De Sa, Albert Gu, Rohan Puttagunta, Christopher Ré, and Atri Rudra. A twopronged progress in structured dense matrix vector multiplication. In Proceedings of the TwentyNinth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 1060–1079. SIAM, 2018.
|
| 295 |
+
|
| 296 |
+
[22] 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, pages 248–255. Ieee, 2009.
|
| 297 |
+
|
| 298 |
+
[23] Peter J Denning. The working set model for program behavior. Communications of the ACM, 11(5):323–333, 1968.
|
| 299 |
+
|
| 300 |
+
[24] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. 2019.
|
| 301 |
+
[25] Xin Dong, Shangyu Chen, and Sinno Jialin Pan. Learning to prune deep neural networks via layer-wise optimal brain surgeon. arXiv preprint arXiv:1705.07565, 2017.
|
| 302 |
+
[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 International Conference on Learning Representations, 2020.
|
| 303 |
+
[27] Y Eidelman and I Gohberg. On a new class of structured matrices. Integral Equations and Operator Theory, 34(3):293–324, 1999.
|
| 304 |
+
[28] Jean Feydy, Joan Glaunès, Benjamin Charlier, and Michael Bronstein. Fast geometric learning with symbolic matrices. Advances in Neural Information Processing Systems, 33, 2020.
|
| 305 |
+
[29] Jörg Flum and Martin Grohe. Parameterized Complexity Theory. Springer, 2006.
|
| 306 |
+
[30] Jonathan Frankle and Michael Carbin. The lottery ticket hypothesis: Finding sparse, trainable neural networks. In International Conference on Learning Representations, 2018.
|
| 307 |
+
[31] Jonathan Frankle, Gintare Karolina Dziugaite, Daniel M Roy, and Michael Carbin. Stabilizing the lottery ticket hypothesis. arXiv preprint arXiv:1903.01611, 2019.
|
| 308 |
+
[32] Jonathan Frankle, Gintare Karolina Dziugaite, Daniel Roy, and Michael Carbin. Linear mode connectivity and the lottery ticket hypothesis. In International Conference on Machine Learning, pages 3259–3269. PMLR, 2020.
|
| 309 |
+
[33] Karan Goel, Albert Gu, Chris Donahue, and Christopher Ré. It’s raw! audio generation with state-space models. In International Conference on Machine Learning (ICML), 2022.
|
| 310 |
+
[34] Aaron Gokaslan, Vanya Cohen, Pavlick Ellie, and Stefanie Tellex. Openwebtext corpus, 2019.
|
| 311 |
+
[35] Jim Gray, Surajit Chaudhuri, Adam Bosworth, Andrew Layman, Don Reichart, Murali Venkatrao, Frank Pellow, and Hamid Pirahesh. Data cube: A relational aggregation operator generalizing group-by, cross-tab, and sub-totals. Data mining and knowledge discovery, 1(1):29–53, 1997.
|
| 312 |
+
[36] Andreas Griewank and Andrea Walther. Evaluating derivatives: principles and techniques of algorithmic differentiation. SIAM, 2008.
|
| 313 |
+
[37] Albert Gu, Tri Dao, Stefano Ermon, Atri Rudra, and Christopher Ré. Hippo: Recurrent memory with optimal polynomial projections. In Advances in neural information processing systems (NeurIPS), 2020.
|
| 314 |
+
[38] Albert Gu, Isys Johnson, Karan Goel, Khaled Saab, Tri Dao, Atri Rudra, and Christopher Ré. Combining recurrent, convolutional, and continuous-time models with linear state space layers. Advances in Neural Information Processing Systems, 34, 2021.
|
| 315 |
+
[39] Albert Gu, Karan Goel, and Christopher Ré. Efficiently modeling long sequences with structured state spaces. In The International Conference on Learning Representations (ICLR), 2022.
|
| 316 |
+
[40] Song Han, Jeff Pool, John Tran, and William J Dally. Learning both weights and connections for efficient neural networks. arXiv preprint arXiv:1506.02626, 2015.
|
| 317 |
+
[41] Song Han, Huizi Mao, and William J Dally. Deep compression: Compressing deep neural networks with pruning, trained quantization and huffman coding. In International Conference on Learning Representations, 2016.
|
| 318 |
+
[42] John Hennessy and David Patterson. Memory hierarchy design. Computer Architecture: A Quantitative Approach, pages 390–525, 2003.
|
| 319 |
+
[43] Sara Hooker. The hardware lottery. arXiv preprint arXiv:2009.06489, 2020.
|
| 320 |
+
[44] Weizhe Hua, Zihang Dai, Hanxiao Liu, and Quoc V Le. Transformer quality in linear time. arXiv preprint arXiv:2202.10447, 2022.
|
| 321 |
+
[45] Andrei Ivanov, Nikoli Dryden, Tal Ben-Nun, Shigang Li, and Torsten Hoefler. Data movement is all you need: A case study on optimizing transformers. Proceedings of Machine Learning and Systems, 3:711–732, 2021.
|
| 322 |
+
[46] Zhe Jia and Peter Van Sandt. Dissecting the Ampere GPU architecture via microbenchmarking. GPU Technology Conference, 2021.
|
| 323 |
+
[47] Zhe Jia, Marco Maggioni, Benjamin Staiger, and Daniele P Scarpazza. Dissecting the nvidia Volta GPU architecture via microbenchmarking. arXiv preprint arXiv:1804.06826, 2018.
|
| 324 |
+
[48] Zhe Jia, Blake Tillman, Marco Maggioni, and Daniele Paolo Scarpazza. Dissecting the graphcore IPU architecture via microbenchmarking. arXiv preprint arXiv:1912.03413, 2019.
|
| 325 |
+
[49] Alistair EW Johnson, Tom J Pollard, Lu Shen, Li-wei H Lehman, Mengling Feng, Mohammad Ghassemi, Benjamin Moody, Peter Szolovits, Leo Anthony Celi, and Roger G Mark. Mimic-iii, a freely accessible critical care database. Scientific data, 3(1):1–9, 2016.
|
| 326 |
+
[50] Norman P Jouppi, Cliff Young, Nishant Patil, David Patterson, Gaurav Agrawal, Raminder Bajwa, Sarah Bates, Suresh Bhatia, Nan Boden, Al Borchers, et al. In-datacenter performance analysis of a tensor processing unit. In Proceedings of the 44th annual international symposium on computer architecture, pages 1–12, 2017.
|
| 327 |
+
[51] Thomas Kailath, Sun-Yuan Kung, and Martin Morf. Displacement ranks of matrices and linear equations. Journal of Mathematical Analysis and Applications, 68(2):395–407, 1979.
|
| 328 |
+
[52] Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, and François Fleuret. Transformers are RNNs: Fast autoregressive transformers with linear attention. In International Conference on Machine Learning, pages 5156–5165. PMLR, 2020.
|
| 329 |
+
[53] Nikita Kitaev, Łukasz Kaiser, and Anselm Levskaya. Reformer: The efficient transformer. In The International Conference on Machine Learning (ICML), 2020.
|
| 330 |
+
[54] Zhenzhong Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel, Piyush Sharma, and Radu Soricut. Albert: A lite BEDRT for self-supervised learning of language representations. In The International Conference on Learning Representations (ICLR), 2020.
|
| 331 |
+
[55] Mingzhen Li, Yi Liu, Xiaoyan Liu, Qingxiao Sun, Xin You, Hailong Yang, Zhongzhi Luan, Lin Gan, Guangwen Yang, and Depei Qian. The deep learning compiler: A comprehensive survey. IEEE Transactions on Parallel and Distributed Systems, 32(3):708–727, 2020.
|
| 332 |
+
[56] Valerii Likhosherstov, Krzysztof Choromanski, Jared Davis, Xingyou Song, and Adrian Weller. Sub-linear memory: How to make performers slim. arXiv preprint arXiv:2012.11346, 2020.
|
| 333 |
+
[57] Ji Lin, Yongming Rao, Jiwen Lu, and Jie Zhou. Runtime neural pruning. In I. Guyon, U. V. Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett, editors, Advances in Neural Information Processing Systems, volume 30. Curran Associates, Inc., 2017.
|
| 334 |
+
[58] 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.
|
| 335 |
+
[59] Xuezhe Ma, Xiang Kong, Sinong Wang, Chunting Zhou, Jonathan May, Hao Ma, and Luke Zettlemoyer. Luna: Linear unified nested attention. Advances in Neural Information Processing Systems, 34, 2021.
|
| 336 |
+
[60] Peter Mattson, Christine Cheng, Gregory Diamos, Cody Coleman, Paulius Micikevicius, David Patterson, Hanlin Tang, Gu-Yeon Wei, Peter Bailis, Victor Bittorf, et al. Mlperf training benchmark. Proceedings of Machine Learning and Systems, 2:336–349, 2020.
|
| 337 |
+
[61] Frank McSherry, Michael Isard, and Derek G Murray. Scalability! but at what {COST}? In 15th Workshop on Hot Topics in Operating Systems (HotOS XV), 2015.
|
| 338 |
+
[62] Maxim Milakov and Natalia Gimelshein. Online normalizer calculation for softmax. arXiv preprint arXiv:1805.02867, 2018.
|
| 339 |
+
|
| 340 |
+
[63] MLCommons. Mlperf 1.1 training results, 2021. URL https://mlcommons.org/en/ training-normal-11/.
|
| 341 |
+
|
| 342 |
+
[64] NVIDIA. Nvidia Tesla V100 GPU architecture, 2017.
|
| 343 |
+
|
| 344 |
+
[65] NVIDIA. Nvidia A100 tensor core GPU architecture, 2020.
|
| 345 |
+
|
| 346 |
+
[66] NVIDIA. Nvidia H100 tensor core GPU architecture, 2022.
|
| 347 |
+
|
| 348 |
+
[67] D Stott Parker. Random butterfly transformations with applications in computational linear algebra. 1995.
|
| 349 |
+
|
| 350 |
+
[68] 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.
|
| 351 |
+
|
| 352 |
+
[69] Markus N Rabe and Charles Staats. Self-attention does not need $O ( n ^ { 2 } )$ memory. arXiv preprint arXiv:2112.05682, 2021.
|
| 353 |
+
|
| 354 |
+
[70] 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.
|
| 355 |
+
|
| 356 |
+
[71] Jack Rae and Ali Razavi. Do transformers need deep long-range memory? In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, Online, July 2020. Association for Computational Linguistics. URL https://www.aclweb.org/anthology/2020.acl-main.672.
|
| 357 |
+
|
| 358 |
+
[72] Jack W Rae, Anna Potapenko, Siddhant M Jayakumar, and Timothy P Lillicrap. Compressive transformers for long-range sequence modelling. In The International Conference on Learning Representations (ICLR), 2020.
|
| 359 |
+
|
| 360 |
+
[73] Jonathan Ragan-Kelley, Connelly Barnes, Andrew Adams, Sylvain Paris, Frédo Durand, and Saman Amarasinghe. Halide: a language and compiler for optimizing parallelism, locality, and recomputation in image processing pipelines. Acm Sigplan Notices, 48(6):519–530, 2013.
|
| 361 |
+
|
| 362 |
+
[74] Raghu Ramakrishnan, Johannes Gehrke, and Johannes Gehrke. Database management systems, volume 3. McGraw-Hill New York, 2003.
|
| 363 |
+
|
| 364 |
+
[75] Benjamin Recht and Christopher Ré. Parallel stochastic gradient algorithms for large-scale matrix completion. Mathematical Programming Computation, 5(2):201–226, 2013.
|
| 365 |
+
|
| 366 |
+
[76] Hongyu Ren, Hanjun Dai, Zihang Dai, Mengjiao Yang, Jure Leskovec, Dale Schuurmans, and Bo Dai. Combiner: Full attention transformer with sparse computation cost. Advances in Neural Information Processing Systems, 34, 2021.
|
| 367 |
+
|
| 368 |
+
[77] Aurko Roy, Mohammad Saffar, Ashish Vaswani, and David Grangier. Efficient content-based sparse attention with routing transformers. Transactions of the Association for Computational Linguistics, 9:53–68, 2021.
|
| 369 |
+
|
| 370 |
+
[78] Amit Sabne. XLA: Compiling machine learning for peak performance. 2020.
|
| 371 |
+
|
| 372 |
+
[79] Victor Sanh, Thomas Wolf, and Alexander M Rush. Movement pruning: Adaptive sparsity by fine-tuning. arXiv preprint arXiv:2005.07683, 2020.
|
| 373 |
+
|
| 374 |
+
[80] 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 preprint arXiv:1909.08053, 2019.
|
| 375 |
+
|
| 376 |
+
[81] Vikas Sindhwani, Tara Sainath, and Sanjiv Kumar. Structured transforms for small-footprint deep learning. In Advances in Neural Information Processing Systems, pages 3088–3096, 2015.
|
| 377 |
+
|
| 378 |
+
[82] Sainbayar Sukhbaatar, Edouard Grave, Piotr Bojanowski, and Armand Joulin. Adaptive attention span in transformers. In Proceedings of the Annual Meeting of the Association for Computational Linguistics, 2019.
|
| 379 |
+
|
| 380 |
+
[83] Yi Tay, Mostafa Dehghani, Samira Abnar, Yikang Shen, Dara Bahri, Philip Pham, Jinfeng Rao, Liu Yang, Sebastian Ruder, and Donald Metzler. Long range arena: A benchmark for efficient transformers. In International Conference on Learning Representations, 2020.
|
| 381 |
+
|
| 382 |
+
[84] Yi Tay, Mostafa Dehghani, Dara Bahri, and Donald Metzler. Efficient transformers: A survey. arXiv preprint arXiv:2009.06732, 2020.
|
| 383 |
+
|
| 384 |
+
[85] 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, pages 10347–10357. PMLR, 2021.
|
| 385 |
+
|
| 386 |
+
[86] 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.
|
| 387 |
+
|
| 388 |
+
[87] Hongyu Wang, Shuming Ma, Li Dong, Shaohan Huang, Dongdong Zhang, and Furu Wei. Deepnet: Scaling transformers to 1,000 layers. arXiv preprint arXiv:2203.00555, 2022.
|
| 389 |
+
|
| 390 |
+
[88] Sinong Wang, Belinda Z Li, Madian Khabsa, Han Fang, and Hao Ma. Linformer: Self-attention with linear complexity. arXiv preprint arXiv:2006.04768, 2020.
|
| 391 |
+
|
| 392 |
+
[89] Samuel Williams, Andrew Waterman, and David Patterson. Roofline: an insightful visual performance model for multicore architectures. Communications of the ACM, 52(4):65–76, 2009.
|
| 393 |
+
|
| 394 |
+
[90] Michael E Wolf and Monica S Lam. A data locality optimizing algorithm. In Proceedings of the ACM SIGPLAN 1991 conference on Programming language design and implementation, pages 30–44, 1991.
|
| 395 |
+
|
| 396 |
+
[91] Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Rémi Louf, Morgan Funtowicz, Joe Davison, Sam Shleifer, Patrick von Platen, Clara Ma, Yacine Jernite, Julien Plu, Canwen Xu, Teven Le Scao, Sylvain Gugger, Mariama Drame, Quentin Lhoest, and Alexander M. Rush. Transformers: State-of-the-art natural language processing. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pages 38–45, Online, October 2020. Association for Computational Linguistics. URL https://www.aclweb.org/anthology/2020.emnlp-demos.6.
|
| 397 |
+
|
| 398 |
+
[92] David P Woodruff. Optimal space lower bounds for all frequency moments. In SODA, volume 4, pages 167–175. Citeseer, 2004.
|
| 399 |
+
|
| 400 |
+
[93] Felix Wu, Angela Fan, Alexei Baevski, Yann N Dauphin, and Michael Auli. Pay less attention with lightweight and dynamic convolutions. In The International Conference on Learning Representations (ICLR), 2019.
|
| 401 |
+
|
| 402 |
+
[94] Yunyang Xiong, Zhanpeng Zeng, Rudrasis Chakraborty, Mingxing Tan, Glenn Fung, Yin Li, and Vikas Singh. Nyströmformer: A nystöm-based algorithm for approximating self-attention. In Proceedings of the AAAI Conference on Artificial Intelligence. AAAI Conference on Artificial Intelligence, volume 35, page 14138, 2021.
|
| 403 |
+
|
| 404 |
+
[95] Li Yuan, Yunpeng Chen, Tao Wang, Weihao Yu, Yujun Shi, Zi-Hang Jiang, Francis EH Tay, Jiashi Feng, and Shuicheng Yan. Tokens-to-token vit: Training vision transformers from scratch on imagenet. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 558–567, 2021.
|
| 405 |
+
|
| 406 |
+
[96] Manzil Zaheer, Guru Guruganesh, Kumar Avinava Dubey, Joshua Ainslie, Chris Alberti, Santiago Ontanon, Philip Pham, Anirudh Ravula, Qifan Wang, Li Yang, et al. Big bird: Transformers for longer sequences. Advances in Neural Information Processing Systems, 33, 2020.
|
| 407 |
+
|
| 408 |
+
[97] Shuangfei Zhai, Walter Talbott, Nitish Srivastava, Chen Huang, Hanlin Goh, Ruixiang Zhang, and Josh Susskind. An attention free transformer. arXiv preprint arXiv:2105.14103, 2021.
|
| 409 |
+
|
| 410 |
+
[98] Chen Zhu, Wei Ping, Chaowei Xiao, Mohammad Shoeybi, Tom Goldstein, Anima Anandkumar, and Bryan Catanzaro. Long-short transformer: Efficient transformers for language and vision. Advances in Neural Information Processing Systems, 34, 2021.
|
| 411 |
+
|
| 412 |
+
# Checklist
|
| 413 |
+
|
| 414 |
+
1. For all authors...
|
| 415 |
+
|
| 416 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
|
| 417 |
+
(b) Did you describe the limitations of your work? [Yes] See Section 5
|
| 418 |
+
(c) Did you discuss any potential negative societal impacts of your work? [Yes] See Section 5
|
| 419 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 420 |
+
|
| 421 |
+
2. If you are including theoretical results...
|
| 422 |
+
|
| 423 |
+
(a) Did you state the full set of assumptions of all theoretical results? [Yes] See Section 3.2 (b) Did you include complete proofs of all theoretical results? [Yes] See Appendix C
|
| 424 |
+
|
| 425 |
+
3. If you ran experiments...
|
| 426 |
+
|
| 427 |
+
(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 Appendix E
|
| 428 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Appendix E
|
| 429 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] See Section 4
|
| 430 |
+
(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
|
| 431 |
+
|
| 432 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 433 |
+
|
| 434 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes] See Section 4 and Appendix E
|
| 435 |
+
(b) Did you mention the license of the assets? [Yes] See Appendix E
|
| 436 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [No]
|
| 437 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
|
| 438 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
|
| 439 |
+
|
| 440 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 441 |
+
|
| 442 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 443 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 444 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
md/dev/HtoA0oT30jC/HtoA0oT30jC.md
ADDED
|
@@ -0,0 +1,525 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# NOVEL VIEW SYNTHESIS WITH DIFFUSION MODELS
|
| 2 |
+
|
| 3 |
+
Daniel Watson Google Research, Brain
|
| 4 |
+
|
| 5 |
+
William Chan Google Research, Brain
|
| 6 |
+
|
| 7 |
+
Ricardo Martin-Brualla Google Research
|
| 8 |
+
|
| 9 |
+
Jonathan Ho Google Research, Brain
|
| 10 |
+
|
| 11 |
+
Andrea Tagliasacchi Google Research, Brain
|
| 12 |
+
|
| 13 |
+
Mohammad Norouzi Google Research, Brain
|
| 14 |
+
|
| 15 |
+
# ABSTRACT
|
| 16 |
+
|
| 17 |
+
We present 3DiM, a diffusion model for 3D novel view synthesis, which is able to translate a single input view into consistent and sharp completions across many views. The core component of 3DiM is a pose-conditional image-to-image diffusion model, which is trained to take a source view and its pose as inputs, and generates a novel view for a target pose as output. 3DiM can then generate multiple views that are approximately 3D consistent using a novel technique called stochastic conditioning. At inference time, the output views are generated autoregressively. When generating each novel view, one selects a random conditioning view from the set of previously generated views at each denoising step. We demonstrate that stochastic conditioning significantly improves 3D consistency compared to a na¨ıve sampler for an image-to-image diffusion model, which involves conditioning on a single fixed view. We compare 3DiM to prior work on the SRN ShapeNet dataset, demonstrating that 3DiM’s generated completions from a single view achieve much higher fidelity, while being approximately 3D consistent. We also introduce a new evaluation methodology, 3D consistency scoring, to quantify the 3D consistency of a generated object by training a neural field on the model’s output views. 3DiM is geometry free, does not rely on hyper-networks or test-time optimization for novel view synthesis, and allows a single model to easily scale to a large number of scenes.
|
| 18 |
+
|
| 19 |
+

|
| 20 |
+
Figure 1: Given a single input image on the left, 3DiM performs novel view synthesis and generates the four views on the right. We trained a single ${ \sim } 4 7 1 \mathrm { M }$ parameter 3DiM on all of ShapeNet (without classconditioning) and sample frames with 256 steps (512 score function evaluations with classifier-free guidance). See the Supplementary Website (https://3d-diffusion.github.io/) for video outputs.
|
| 21 |
+
|
| 22 |
+
# 1 INTRODUCTION
|
| 23 |
+
|
| 24 |
+
Diffusion Probabilistic Models (DPMs) (Sohl-Dickstein et al., 2015; Song & Ermon, 2019; Ho et al., 2020), also known as simply diffusion models, have recently emerged as a powerful family of generative models, achieving state-of-the-art performance on audio and image synthesis (Chen et al., 2020; Dhariwal & Nichol, 2021), while admitting better training stability over adversarial approaches (Goodfellow et al., 2014), as well as likelihood computation, which enables further applications such as compression and density estimation (Song et al., 2021; Kingma et al., 2021). Diffusion models have achieved impressive empirical results in a variety of image-to-image translation tasks not limited to text-to-image, super-resolution, inpainting, colorization, uncropping, and artifact removal (Song et al., 2020; Saharia et al., 2021a; Ramesh et al., 2022; Saharia et al., 2022).
|
| 25 |
+
|
| 26 |
+
One particular image-to-image translation problem where diffusion models have not been investigated is novel view synthesis, where, given a set of images of a given 3D scene, the task is to infer how the scene looks from novel viewpoints. Before the recent emergence of Scene Representation Networks (SRN) (Sitzmann et al., 2019) and Neural Radiance Fields (NeRF) (Mildenhall et al., 2020), state-of-the-art approaches to novel view synthesis were typically built on generative models (Sun et al., 2018) or more classical techniques on interpolation or disparity estimation (Park et al., 2017; Zhou et al., 2018). Today, these models have been outperformed by NeRF-class models (Yu et al., 2021; Niemeyer et al., 2021; Jang & Agapito, 2021), where 3D consistency is guaranteed by construction, as images are generated by volume rendering of a single underlying 3D representation (a.k.a. “geometry-aware” models).
|
| 27 |
+
|
| 28 |
+
Still, these approaches feature different limitations. Heavily regularized NeRFs for novel view synthesis with few images such as RegNeRF (Niemeyer et al., 2021) produce undesired artifacts when given very few images, and fail to leverage knowledge from multiple scenes (recall NeRFs are trained on a single scene, i.e., one model per scene), and given one or very few views of a novel scene, a reasonable model must extrapolate to complete the occluded parts of the scene. PixelNeRF (Yu et al., 2021) and VisionNeRF (Lin et al., 2022) address this by training NeRF-like models conditioned on feature maps that encode the novel input view(s). However, these approaches are regressive rather than generative, and as a result, they cannot yield different plausible modes and are prone to blurriness. This type of failure has also been previously observed in regression-based models (Saharia et al., 2021b). Other works such as CodeNeRF (Jang & Agapito, 2021) and LoLNeRF (Rebain et al., 2021) instead employ test-time optimization to handle novel scenes, but still have issues with sample quality.
|
| 29 |
+
|
| 30 |
+
In recent literature, geometry-free approaches (i.e., methods without explicit geometric inductive biases like those introduced by volume rendering) such as Light Field Networks (LFN) (Sitzmann et al., 2021) and Scene Representation Transformers (SRT) (Sajjadi et al., 2021) have achieved results competitive with 3D-aware methods in the “few-shot” setting, where the number of conditioning views is limited (i.e., 1-10 images vs. dozens of images as in the usual NeRF setting). Similarly to our approach, EG3D (Chan et al., 2022) provides approximate 3D consistency by leveraging generative models. EG3D employs a StyleGAN (Karras et al., 2019) with volumetric rendering, followed by generative super-resolution (the latter being responsible for the approximation). In comparison to this complex setup, we do not only provide a significantly simpler architecture, but also a simpler hyper-parameter tuning experience compared GANs, which are well-known to be notoriously difficult to tune (Mescheder et al., 2018).
|
| 31 |
+
|
| 32 |
+
Motivated by these observations and the success of diffusion models in image-to-image tasks, we introduce 3D Diffusion Models (3DiMs). 3DiMs are image-to-image diffusion models trained on pairs of images of the same scene, where we assume the poses of the two images are known. Drawing inspiration from Scene Representation Transformers (Sajjadi et al., 2021), 3DiMs are trained to build a conditional generative model of one view given another view and their poses. Our key discovery is that we can turn this image-to-image model into a model that can produce an entire set of 3D-consistent frames through autoregressive generation, which we enable with our novel stochastic conditioning sampling algorithm. We cover stochastic conditioning in more detail in Section 2.2 and provide an illustration in Figure 3. Compared to prior work, 3DiMs are generative (vs. regressive) geometry free models, they allow training to scale to a large number of scenes, and offer a simple end-to-end approach.
|
| 33 |
+
|
| 34 |
+
We now summarize our core contributions:
|
| 35 |
+
|
| 36 |
+
1. We introduce 3DiM, a geometry-free image-to-image diffusion model for novel view synthesis.
|
| 37 |
+
2. We introduce the stochastic conditioning sampling algorithm, which encourages 3DiM to generate 3D-consistent outputs.
|
| 38 |
+
3. We introduce $X$ -UNet, a new UNet architecture (Ronneberger et al., 2015) variant for 3D novel view synthesis, demonstrating that changes in architecture are critical for high fidelity results.
|
| 39 |
+
4. We introduce an evaluation scheme for geometry-free view synthesis models, $3 D$ consistency scoring, that can numerically capture 3D consistency by training neural fields on model outputs.
|
| 40 |
+
|
| 41 |
+

|
| 42 |
+
Figure 2: Pose-conditional image-to-image training – Example training inputs and outputs for pose-conditional image-to-image diffusion models, presented in Section 2.1. Given two frames from a common scene and their poses $( R , t )$ , the training task is to undo the noise added to one of the two frames. $( ^ { * } )$ In practice, our neural network is trained to predict the Gaussian noise $\epsilon$ used to corrupt the original view – the predicted view is still just a linear combination of the noisy input and the predicted $\epsilon$ .
|
| 43 |
+
|
| 44 |
+
# 2 POSE-CONDITIONAL DIFFUSION MODELS
|
| 45 |
+
|
| 46 |
+
To motivate 3DiMs, let us consider the problem of novel view synthesis given few images from a probabilistic perspective. Given a complete description of a 3D scene $s$ , for any pose $\pmb { p }$ , the view $\scriptstyle { \pmb { x } } ^ { ( { \pmb { p } } ) }$ at pose $\pmb { p }$ is fully determined from $s$ , i.e., views are conditionally independent given $s$ . However, we are interested in modeling distributions of the form $q ( \pmb { x } _ { 1 } , . . . , \pmb { x } _ { m } | \pmb { x } _ { m + 1 } , . . . , \pmb { x } _ { n } )$ without $s$ , where views are no longer conditionally independent. A concrete example is the following: given the back of a person’s head, there are multiple plausible views for the front. An image-to-image model sampling front views given only the back should indeed yield different outputs for each front view – with no guarantees that they will be consistent with each other – especially if it learns the data distribution perfectly. Similarly, given a single view of an object that appears small, there is ambiguity on the pose itself: is it small and close, or simply far away? Thus, given the inherent ambiguity in the few-shot setting, we need a sampling scheme where generated views can depend on each other in order to achieve 3D consistency. This contrasts NeRF approaches, where query rays are conditionally independent given a 3D representation $s$ – an even stronger condition than imposing conditional independence among frames. Such approaches try to learn the richest possible representation for a single scene $s$ , while 3DiM avoids the difficulty of learning a generative model for $s$ altogether.
|
| 47 |
+
|
| 48 |
+
# 2.1 IMAGE-TO-IMAGE DIFFUSION MODELS WITH POSE CONDITIONING
|
| 49 |
+
|
| 50 |
+
Given a data distribution $q ( \pmb { x } _ { 1 } , \pmb { x } _ { 2 } )$ of pairs of views from a common scene at poses $p _ { 1 } , p _ { 2 } \in \mathrm { S E } ( 3 )$ , we define an isotropic Gaussian process that adds increasing amounts of noise to data samples as the signal-to-noise-ratio $\lambda$ decreases, following Salimans & Ho (2022):
|
| 51 |
+
|
| 52 |
+
$$
|
| 53 |
+
q ( z _ { k } ^ { ( \lambda ) } | \pmb { x } _ { k } ) : = \mathcal { N } ( z _ { k } ^ { ( \lambda ) } ; \sigma ( \lambda ) ^ { \frac { 1 } { 2 } } \pmb { x } _ { k } , \sigma ( - \lambda ) \mathbf { I } )
|
| 54 |
+
$$
|
| 55 |
+
|
| 56 |
+
where $\sigma ( \cdot )$ is the sigmoid function. We can apply the reparametrization trick (Kingma & Welling, 2013) and sample from these marginal distributions via
|
| 57 |
+
|
| 58 |
+
$$
|
| 59 |
+
z _ { k } ^ { ( \lambda ) } = \sigma ( \lambda ) ^ { \frac { 1 } { 2 } } x _ { k } + \sigma ( - \lambda ) ^ { \frac { 1 } { 2 } } \epsilon , \quad \epsilon \sim \mathcal { N } ( \mathbf { 0 } , \mathbf { I } )
|
| 60 |
+
$$
|
| 61 |
+
|
| 62 |
+
Then, given a pair of views, we learn to reverse this process in one of the two frames by minimizing the objective proposed by $\mathrm { H o }$ et al. (2020), which has been shown to yield much better sample quality than maximizing the true evidence lower bound (ELBO):
|
| 63 |
+
|
| 64 |
+
$$
|
| 65 |
+
L ( \theta ) = \mathbb { E } _ { q ( \pmb { x } _ { 1 } , \pmb { x } _ { 2 } ) } ~ \mathbb { E } _ { \lambda , \epsilon } ~ \| \epsilon _ { \theta } ( z _ { 2 } ^ { ( \lambda ) } , \pmb { x } _ { 1 } , \lambda , \pmb { p } _ { 1 } , \pmb { p } _ { 2 } ) - \epsilon \| _ { 2 } ^ { 2 }
|
| 66 |
+
$$
|
| 67 |
+
|
| 68 |
+
where θ is a neural network whose task is to denoise the frame z(λ)2 given a different (clean) frame $\scriptstyle { \mathbf { { \mathscr { x } } } } _ { 1 }$ , and $\lambda$ is the log signal-to-noise-ratio. To make our notation more legible, we slightly abuse notation and from now on we will simply write $\epsilon _ { \theta } ( z _ { 2 } ^ { ( \lambda ) } , x _ { 1 } )$ . We illustrate training in Figure 2.
|
| 69 |
+
|
| 70 |
+

|
| 71 |
+
Figure 3: Stochastic conditioning sampler – We illustrate our proposed inference procedure for 3DiM, outlined in Section 2.2. There are two main components to our sampling procedure: (1) the autoregressive generation of multiple frames (illustrated vertically as “step $1 ^ { \circ }$ , “step $2 ^ { \circ }$ , etc.), and (2) the denoising process to generate each individual frame (illustrated horizontally). When generating a new frame, we select a previous frame as the conditioning frame randomly at each denoising step (illustrated with the dice). Note that this is not part of 3DiM training; also, we omit the pose inputs in the diagram to avoid overloading the figure.
|
| 72 |
+
|
| 73 |
+
# 2.2 3D CONSISTENCY VIA STOCHASTIC CONDITIONING
|
| 74 |
+
|
| 75 |
+
Motivation. We begin this section by motivating the need of our stochastic conditioning sampler. In the ideal situation, we would model our 3D scene frames using the chain rule decomposition:
|
| 76 |
+
|
| 77 |
+
$$
|
| 78 |
+
p ( \pmb { x } ) = \prod _ { i } p ( \pmb { x } _ { i } | \pmb { x } _ { < i } )
|
| 79 |
+
$$
|
| 80 |
+
|
| 81 |
+
This factorization is ideal, as it models the distribution exactly without making any conditional independence assumptions. Each frame is generated autoregressively, conditioned on all the previous frames. However, we found this solution to perform poorly. Due to memory limitations, we can only condition on a limited number of frames in practice, (i.e., a $k$ -Markovian model). We also find that, as we increase the maximum number of input frames $k$ , the worse the sample quality becomes. In order to achieve the best possible sample quality, we thus opt for the bare minimum of $k = 2$ (i.e., an image-to-image model). Our key discovery is that, with $k = 2$ , we can still achieve approximate 3D consistency. Instead of using a sampler that is Markovian over frames, we leverage the iterative nature of diffusion sampling by varying the conditioning frame at each denoising step.
|
| 82 |
+
|
| 83 |
+
Stochastic Conditioning. We now detail our novel stochastic conditioning sampling procedure that allows us to generate 3D-consistent samples from a 3DiM. We start with a set of conditioning views $\mathcal { X } = \{ \pmb { x } _ { 1 } , . . . , \pmb { x } _ { k } \}$ of a static scene, where typically $k = 1$ or is very small. We then generate a new frame by running a modified version of the standard denoising diffusion reverse process for steps $\lambda _ { \operatorname* { m i n } } = \lambda _ { T } < \lambda _ { T - 1 } < . . . < \lambda _ { 0 } = \lambda _ { \operatorname* { m a x } }$ :
|
| 84 |
+
|
| 85 |
+
$$
|
| 86 |
+
\begin{array} { r c l } { { \hat { \pmb x } _ { k + 1 } } } & { { = } } & { { \displaystyle \frac { 1 } { \sigma ( \lambda _ { k } ) ^ { \frac { 1 } { 2 } } } \left( \pmb z _ { k + 1 } ^ { ( \lambda _ { t } ) } - \sigma ( - \lambda _ { t } ) ^ { \frac { 1 } { 2 } } \pmb \epsilon _ { \theta } ( \pmb z _ { k + 1 } ^ { ( \lambda _ { t } ) } , \pmb x _ { i } ) \right) } } \\ { { \pmb z _ { k + 1 } ^ { ( \lambda _ { t - 1 } ) } } } & { { \sim } } & { { q \left( \pmb z _ { k + 1 } ^ { ( \lambda _ { t - 1 } ) } | \pmb z _ { k + 1 } ^ { ( \lambda _ { t } ) } , \hat { \pmb x } _ { k + 1 } \right) } } \end{array}
|
| 87 |
+
$$
|
| 88 |
+
|
| 89 |
+
where, crucially, $i \sim \operatorname { U n i f o r m } ( \{ 1 , . . . , k \} )$ is re-sampled at each denoising step. In other words, each individual denoising step is conditioned on a different random view from $\mathcal { X }$ (the set that contains the input view(s) and the previously generated samples). Once we finish running this sampling chain and produce a final $\mathbf { \boldsymbol { x } } _ { k + 1 }$ , we simply add it to $\mathcal { X }$ and repeat this procedure if we want to sample more frames. Given sufficient denoising steps, stochastic conditioning allows each generated frame to be guided by all previous frames. See Figure 3 for an illustration. In practice, we use 256 denoising steps, which we find to be sufficient to achieve both high sample quality and approximate 3D consistency. As usual in the literature, the first (noisiest sample) is just a Gaussian, i.e., $z _ { i } ^ { ( \lambda _ { T } ) } \sim$ $\mathcal { N } ( \mathbf { 0 } , \mathbf { I } )$ , and at the last step $\lambda _ { 0 }$ , we sample noiselessly.
|
| 90 |
+
|
| 91 |
+
We can interpret stochastic conditioning as a na¨ıve approximation to true autoregressive sampling that works well in practice. True autoregressive sampling would require a score model of the form $\nabla _ { z _ { k + 1 } ^ { ( \lambda ) } } \log q ( z _ { k + 1 } ^ { ( \lambda ) } | \pmb { x } _ { 1 } , . . . , \pmb { x } _ { k } )$ , but this would strictly require multi-view training data, while we are ultimately interested in enabling novel view synthesis with as few as two training views per scene.
|
| 92 |
+
|
| 93 |
+

|
| 94 |
+
Figure 4: X-UNet Architecture – We modify the typical UNet architecture used by recent work on diffusion models to accomodate 3D novel view synthesis. We share the same UNet weights among the two input frames, the clean conditioning view and the denoising target view. We add cross attention layers to mix information between the input and output view, illustrated in yellow.
|
| 95 |
+
|
| 96 |
+
# 2.3 X-UNET
|
| 97 |
+
|
| 98 |
+
The 3DiM model needs a neural network architecture that takes both the conditioning frame and the noisy frame as inputs. One natural way to do this is simply to concatenate the two images along the channel dimensions, and use the standard UNet architecture (Ronneberger et al., 2015; Ho et al., 2020). This “Concat-UNet” has found significant success in prior work of image-to-image diffusion models (Saharia et al., 2021b;a). However, in our early experiments, we found that the Concat-UNet yields very poor results – there were severe 3D inconsistencies and lack of alignment to the conditioning image. We hypothesize that, given limited model capacity and training data, it is difficult to learn complex, nonlinear image transformations that only rely on self-attention. We thus introduce our $X$ -UNet, whose core changes are (1) sharing parameters to process each of the two views, and (2) using cross attention between the two views. We find our X-UNet architecture to be very effective for 3D novel view synthesis.
|
| 99 |
+
|
| 100 |
+
We now describe X-UNet in detail. We follow Ho et al. (2020); Song et al. (2020), and use the UNet (Ronneberger et al., 2015) with residual blocks and self-attention.We also take inspiration from Video Diffusion Models (Ho et al., 2022) by sharing weights over the two input frames for all the convolutional and self-attention layers, but with several key differences:
|
| 101 |
+
|
| 102 |
+
1. We let each frame have its own noise level (recall that the inputs to a DDPM residual block are feature maps as well as a positional encoding for the noise level). We use a positional encoding of $\lambda _ { \mathrm { m a x } }$ for the clean frame. Ho et al. (2022) conversely denoise multiple frames simultaneously, each at the same noise level. 2. Alike Ho et al. (2020), we modulate each UNet block via FiLM (Dumoulin et al., 2018), but we use the sum of pose and noise-level positional encodings, as opposed to the noise-level embedding alone. Our pose encoding additionally differs in that they are of the same dimensionality as frames– they are camera rays, identical to those used by Sajjadi et al. (2021). 3. Instead of attending over “time” after each self-attention layer like Ho et al. (2022), which in our case would entail only two attention weights, we define a cross-attention layer and let each frame’s feature maps call this layer to query the other frame’s feature maps.
|
| 103 |
+
|
| 104 |
+
For more details on our proposed architecture, we refer the reader to the Supplementary Material (Sec.6). We also provide a comparison to the “Concat-UNet” architecture in Section 3.2.
|
| 105 |
+
|
| 106 |
+

|
| 107 |
+
Figure 5: State-of-the-art comparisons – Example input and output views of a 3DiM trained on the SRN cars dataset at the 128x128 resolution, compared to existing geometry-aware methods. Results are best appreciated in the Supplementary Website (https://3d-diffusion.github.io/).
|
| 108 |
+
|
| 109 |
+
Table 2: State-of-the-art comparisons – Results on the SRN ShapeNet benchmark comparing 3DiMs to prior work on novel view synthesis from a single image. $( ^ { * } )$ SSIM scores may not necessarily be computed with a Gaussian kernel following Wang et al. (2004) – in practice we observe this can lead to differences of up to 0.02. We report these marked numbers directly from prior work.
|
| 110 |
+
|
| 111 |
+
<table><tr><td rowspan="2"></td><td colspan="3">SRN cars</td><td colspan="3">SRN chairs</td></tr><tr><td>PSNR (↑)</td><td>SSIM (↑)</td><td>FID (↓)</td><td>PSNR (↑)</td><td>SSIM (↑)</td><td>FID (↓)</td></tr><tr><td>Geometry-aware</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>SRN</td><td>22.25</td><td>0.88</td><td>41.21</td><td>22.89</td><td>0.89</td><td>26.51</td></tr><tr><td>PixelNeRF</td><td>23.17</td><td>0.89</td><td>59.24</td><td>23.72</td><td>0.90</td><td>38.49</td></tr><tr><td>VisionNeRF</td><td>22.88</td><td>0.90</td><td>21.31</td><td>24.48</td><td>0.92</td><td>10.05</td></tr><tr><td>CodeNeRF</td><td>23.80</td><td>*0.91</td><td></td><td>23.66</td><td>*0.90</td><td>1</td></tr><tr><td>Geometry-free</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>LFN</td><td>22.42</td><td>*0.89</td><td></td><td>22.26</td><td>*0.90</td><td></td></tr><tr><td>ENR</td><td>22.26</td><td></td><td></td><td>22.83</td><td>1</td><td></td></tr><tr><td>3DiM (ours)</td><td>21.01</td><td>0.57</td><td>8.99</td><td>17.05</td><td>0.53</td><td>6.57</td></tr></table>
|
| 112 |
+
|
| 113 |
+
# 3 EXPERIMENTS
|
| 114 |
+
|
| 115 |
+
We benchmark 3DiMs on the SRN ShapeNet dataset (Sitzmann et al., 2019) to allow comparisons with prior work on novel view synthesis from a single image. This dataset consists of views and poses of car and chair ShapeNet (Chang et al., 2015) assets, rendered at the $1 2 8 \mathrm { x } 1 2 8$ resolution.
|
| 116 |
+
|
| 117 |
+
We compare 3DiMs with Light Field Networks (LFN) (Sitzmann et al., 2021) and Equivariant Neural Rendering (ENR) (Dupont et al., 2020), two competitive geometry-free approaches, as well as geometry-aware approaches including Scene Representation Networks (SRN) (Sitzmann et al., 2019), PixelNeRF (Yu et al., 2021), CodeNeRF (Jang & Agapito, 2021) and the recent VisionNeRF (Lin et al., 2022). We include standard metrics in the literature: peak signal-to-noiseratio (PSNR), structural similarity (SSIM) (Wang et al., 2004), and the Frechet Inception Distance ´ (FID) (Heusel et al., 2017). To remain consistent with prior work, we evaluate over all scenes in the held-out dataset (each has 251 views), conditioning our models on a single view (view #64) to produce all other 250 views via a single call to our sampler outlined in Section 2.2, and then report the average PSNR and SSIM. Importantly, FID scores were computed with this same number of views, comparing the set of all generated views against the set of all the ground truth views. Because prior work did not include FID scores, we acquire the evaluation image outputs of SRN, PixelNeRF and VisionNeRF and compute the scores ourselves. We reproduce PSNR scores, and carefully note that some of the models do not follow Wang et al. (2004) on their SSIM computation (they use a uniform rather than Gaussian kernel), so we also recompute SSIM scores following (Wang et al., 2004). For more details, including hyperparameter choices, see Supplementary Material (Sec.7).
|
| 118 |
+
|
| 119 |
+
Out-of-distribution poses on SRN chairs. We note that the test split of the SRN ShapeNet chairs was unintentionally released with out-of-distribution poses compared to the train split: most test views are at a much larger distance to the object than those in the training dataset; we confirmed this via correspondence with the authors of Sitzmann et al. (2019). Because 3DiMs are geometry-free, we (unsurprisingly) observe that they do not perform well on this out-of-distribution evaluation task, as all the poses used at test-time are of scale never seen during training. However, simply merging, shuffling, and re-splitting the dataset completely fixes the issue. To maintain comparability with prior work, results on SRN chairs in Table 2 are those on the original dataset, and we denote the re-split dataset as “SRN chairs\*” (note the \*) in all subsequent tables to avoid confusion.
|
| 120 |
+
|
| 121 |
+

|
| 122 |
+
Figure 6: 3DiM samples on OOD synthetic images – We qualitatively demonstrate the text-to-3D capabilities of 3DiM by synthethizing an input view with Imagen, a text-to-image model, and then create more views with 3DiM.
|
| 123 |
+
|
| 124 |
+
State-of-the-art comparisons. While 3DiM does not necessarily achieve superior reconstruction errors (PSNR and SSIM, see Table 2), qualitatively, we find that the fidelity of our generated videos can be strikingly better. We include an example in Figure 5. The use of diffusion models allows us to produce sharp samples, as opposed to regression models that are well-known to be prone to blurriness (Saharia et al., 2021b) in spite of high PSNR and SSIM scores. This is why we introduce and evaluate FID scores. In fact, we do not expect to achieve very low reconstruction errors due to the inherent ambiguity of novel view synthesis with a single image: constructing a consistent object with the given frame(s) is acceptable, but will still be punished by said reconstruction metrics if it differs from the ground truth views (even if achieving consistency). We additionally refer the reader to Section 3.1, where we include simple ablations demonstrating how worse models can improve the different standardized metrics in the literature. E.g., we show that with regression models, similarly to the baseline samples, PSNR and SSIM do not capture sharp modes well – they scores these models as much better despite the samples looking significantly more blurry (with PixelNeRF, which qualitatively seems the blurriest, achieving the best scores).
|
| 125 |
+
|
| 126 |
+
Results on out-of-distribution images.. We additionally show qualitative results attempting to lift single images in the wild (without known poses) into 3D. To this end, we train a 471M parameter 3DiM on all of ShapeNet (except for 10 objects per class which we leave out for testing). This model has identical parameters to the 3DiM used for SRN cars. However, it differs in that we poses with relative camera extrinsics (i.e., the camera position and rotation corresponding to the noisy input frame is always the same) as we do not know the poses of images in the wild. Our qualitative results on single-image-to-3D generation include:
|
| 127 |
+
|
| 128 |
+
1. ShapeNet objects held out from the training data
|
| 129 |
+
2. Images in the wild we directly took from the internet (with a white background, minimal shadow, and corresponding to any ShapeNet class)
|
| 130 |
+
3. Images synthesized by Imagen (Saharia et al., 2022), a text-to-image diffusion model
|
| 131 |
+
|
| 132 |
+
In order to make Imagen synthesize objects with white backgrounds and minimal shadows at the $1 2 8 \mathrm { x } 1 2 8$ resolution, in addition to natural language prompting, we inpaint a 5px white border at each denoising step when generating a $6 4 \mathrm { x } 6 4$ image, and then upsample it using the second model on the Imagen cascade, i.e., a text-conditional super-resolution model. We find that this strategy is much more reliable than only relying on prompt engineering to create images with white backgrounds: this leads the text-to-image model to make the rest of background consistent with the fully white border, so the generated image results in an out-of-distribution object while maintaining an in-distribution background. We present example novel views given a ShapeNet test object in Figure 1, and given a synthetic image from Imagen in Figure 6. We include several video samples for all the cases described above in the Supplementary Website (https://3d-diffusion.github.io/).
|
| 133 |
+
|
| 134 |
+
SRN cars
|
| 135 |
+
SRN chairs\*
|
| 136 |
+
|
| 137 |
+
<table><tr><td></td><td>PSNR (↑)</td><td>SSIM (↑)</td><td>FID (↓)</td><td>PSNR (↑)</td><td>SSIM (↑)</td><td>FID (↓)</td></tr><tr><td>3DiM</td><td>21.01</td><td>0.57</td><td>8.99</td><td>14.29</td><td>0.48</td><td>3.30</td></tr><tr><td>+ no stochastic conditioning</td><td>23.82</td><td>0.59</td><td>1.87</td><td>15.73</td><td>0.51</td><td>1.05</td></tr><tr><td>+regression</td><td>22.55</td><td>0.85</td><td>17.45</td><td>16.85</td><td>0.76</td><td>20.70</td></tr></table>
|
| 138 |
+
|
| 139 |
+
Table 3: Ablation – study removing stochastic conditioning and diffusion altogether from 3DiM.
|
| 140 |
+
Results are included for novel view synthesis from a single image on the SRN ShapeNet benchmark.
|
| 141 |
+
$( ^ { * } )$ Re-split chairs dataset as detailed in Section 3 – not comparable to numbers in Table 2.
|
| 142 |
+
|
| 143 |
+

|
| 144 |
+
Figure 7: Ablations – Example input and output views of 3DiM ablations on the SRN chairs dataset at the $1 2 8 \mathrm { x } 1 2 8$ resolution. The second “Image-to-Image” column corresponds to removing our stochastic conditioning sampler from Section 2.2. The third “Concat-UNet” column corresponds to removing our proposed architecture in Section 2.3, resorting to a UNet that concatenates both images along the channel axis instead of weight sharing over frames. The fourth “Regression” column is one-step diffusion model trained from scratch.
|
| 145 |
+
|
| 146 |
+
We now present some ablation studies on 3DiM. First, we remove our proposed sampler and use a na¨ıve image-to-image model as discussed at the start of Section 2.2. We additionally remove the use of a diffusion process altogether, i.e., a regression model that generates samples via a single denoising step. Naturally, the regression models are trained separately, but we can still use an identical architecture, always feeding white noise for one frame, along with its corresponding noise level $\lambda _ { \operatorname* { m i n } }$ . Results are included in Table 3 and samples are included in Figure 7.
|
| 147 |
+
|
| 148 |
+
Unsurprisingly, we find that both of these components are crucial to achieve good results. The use of many diffusion steps allows sampling sharp images that achieve much better (lower) FID scores than both prior work and the regression models, where in both cases, reconstructions appear blurry. Notably, the regression models achieve better PSNR and SSIM scores than 3DiM despite the severe blurriness, suggesting that these standardized metrics fail to meaningfully capture sample quality for geometry-free models, at least when comparing them to geometry-aware or non-stochastic reconstruction approaches. Similarly, FID also has a failure mode: na¨ıve image-to-image sampling improves (decreases) FID scores significantly, but severely worsens shape and texture inconsistencies between sampled frames. These findings suggest that none of these standardized metrics are sufficient to effectively evaluate geometry-free models for view synthesis; nevertheless, we observe that said metrics do correlate well with sample quality across 3DiMs and can still be useful indicators for hyperparameter tuning despite their individual failures.
|
| 149 |
+
|
| 150 |
+
Table 5: Architecture comparison – study comparing the X-UNet and Concat-UNet neural architectures. Results are included for novel view synthesis from a single image on the SRN ShapeNet benchmark, with the re-split chairs as detailed in Section 3. $( ^ { * } )$ Re-split chairs dataset as detailed in Section 3 – these numbers are not comparable to those in Table 2.
|
| 151 |
+
|
| 152 |
+
<table><tr><td rowspan="2"></td><td rowspan="2">PSNR (↑) SSIM (↑)</td><td rowspan="2">cars</td><td colspan="4">chairs*</td></tr><tr><td>FID (↓)</td><td>PSNR (↑)</td><td>SSIM (↑)</td><td>FID (↓)</td></tr><tr><td>Concat-UNet</td><td>17.21</td><td>0.52</td><td>21.54</td><td>12.36</td><td>0.44</td><td>5.15</td></tr><tr><td>X-UNet</td><td>21.01</td><td>0.57</td><td>8.99</td><td>14.29</td><td>0.48</td><td>3.30</td></tr></table>
|
| 153 |
+
|
| 154 |
+
# 3.2 UNET ARCHITECTURE COMPARISONS
|
| 155 |
+
|
| 156 |
+
In order to demonstrate the benefit of our proposed modifications, we additionally compare our proposed X-UNet architecture from Section 2.3 to the simpler UNet architecture following Saharia et al. (2021b;a) (which we simply call “Concat-UNet”). The Concat-UNet architecture, unlike ours, does not share weights across frames; instead, it simply concatenates the conditioning image to the noisy input image along the channel axis. To do this comparison, we train 3DiMs on the ConcatUNet architecture with the same number of hidden channels, and keep all other hyperparameters identical. Because our architecture has the additional cross-attention layer at the coarse-resolution blocks, our architecture has a slightly larger number of parameters than the Concat-UNet ${ \sim } 4 7 1 \mathrm { M }$ v.s. ${ \sim } 4 2 1 \mathrm { M }$ ). Results are included in Table 5 and Figure 7.
|
| 157 |
+
|
| 158 |
+
While the Concat-UNet architecture is able to sample frames that resemble the data distribution, we find that 3DiMs trained with our proposed X-UNet architecture suffer much less from 3D inconsistency and alignment to the conditioning frame. Moreover, while the metrics should be taken with a grain of salt as previously discussed, we find that all the metrics significantly worsen with the Concat-UNet. We hypothesize that our X-UNet architecture better exploits symmetries between frames and poses due to our proposed weight-sharing mechanism, and that the cross-attention helps significantly to align with the content of the conditioning view.
|
| 159 |
+
|
| 160 |
+
# 4 EVALUATING 3D CONSISTENCY IN GEOMETRY-FREE VIEW SYNTHESIS
|
| 161 |
+
|
| 162 |
+
As we demonstrate in Sections 3.1 and 3.2, the standardized metrics in the literature have failure modes when specifically applied to geometry-free novel view synthesis models, e.g., their inability to successfully measure 3D consistency, and the possibility of improving them with worse models. Leveraging the fact that volumetric rendering of colored density fields are 3D-consistent by design, we thus propose an additional evaluation scheme called “3D consistency scoring”. Our metrics should satisfy the following desiderata:
|
| 163 |
+
|
| 164 |
+
1. The metric must penalize outputs that are not 3D consistent.
|
| 165 |
+
2. The metric must not penalize outputs that are 3D consistent but deviate from the ground truth.
|
| 166 |
+
3. The metric must penalize outputs that do not align with the conditioning view(s).
|
| 167 |
+
|
| 168 |
+
In order to satisfy the second requirement, we cannot compare output renders to ground-truth views. Thus, one straightforward way to satisfy all desiderata is to sample many views from the geometryfree model given a single view, train a NeRF-like neural field (Mildenhall et al., 2020) on a fraction of these views, and compute a set of metrics that compare neural field renders on the remaining views. This way, if the geometry-free model outputs inconsistent views, the training of neural field will be hindered and classical image evaluation metrics should clearly reflect this. Additionally, to enforce the third requirement, we simply include the conditioning view(s) that were used to generate the rest as part of the training data. We report PSNR, SSIM and FID on the held-out views, although one could use other metrics under our proposed evaluation scheme.
|
| 169 |
+
|
| 170 |
+
We evaluate 3DiMs on the SRN benchmark, and for comparison, we additionally include metrics for models trained on (1) the real test views and (2) on image-to-image samples from the 3DiMs, i.e., without our proposed sampler like we reported in Section 3. To maintain comparability, we sample the same number of views from the different 3DiMs we evaluate in this section, all at the same poses and conditioned on the same single views. We leave out $10 \%$ of the test views (25 out of 251) from neural field training, picking 25 random indices once and maintaining this choice of indices for all
|
| 171 |
+
|
| 172 |
+
<table><tr><td rowspan="2">Training view source</td><td colspan="3">SRN cars</td><td colspan="3">SRN chairs*</td></tr><tr><td>PSNR (↑)</td><td>SSIM (↑)</td><td>FID (↓)</td><td>PSNR (↑)</td><td>SSIM (↑)</td><td>FID (↓)</td></tr><tr><td>Original data (3D consistent)</td><td>28.21</td><td>0.96</td><td>10.57</td><td>24.87</td><td>0.93</td><td>17.05</td></tr><tr><td>3DiM(~1.3B params)</td><td>28.48</td><td>0.96</td><td>29.55</td><td>22.90</td><td>0.86</td><td>58.61</td></tr><tr><td>3DiM(~471M params)</td><td>28.53</td><td>0.96</td><td>22.09</td><td>18.84</td><td>0.79</td><td>98.78</td></tr><tr><td>+ no stochastic conditioning</td><td>25.78</td><td>0.94</td><td>30.51</td><td>17.61</td><td>0.75</td><td>116.16</td></tr></table>
|
| 173 |
+
|
| 174 |
+
Table 6: 3D consistency scores – For neural fields trained with different view sources, we compare renders to held-out views from the same sources.
|
| 175 |
+
|
| 176 |
+
subsequent evaluations. We also train models with more parameters $( \sim 1 . 3 \mathrm { B } )$ in order to investigate whether increasing model capacity can further improve 3D consistency. See Supplementary Material (Sec.7) for more details on the neural fields we chose and their hyperparameters.
|
| 177 |
+
|
| 178 |
+
We find that our proposed evaluation scheme clearly punishes 3D inconsistency as desired – the neural fields trained on image-to-image 3DiM samples have worse scores across all metrics compared to neural fields trained on 3DiM outputs sampled via our stochastic conditioning. This helps quantify the value of our proposed sampler, and also prevents the metrics from punishing reasonable outputs that are coherent with the input view(s) but do not match the target views – a desirable property due to the stochasticity of generative models. Moreover, we qualitatively find that the smaller model reported in the rest of the paper is comparable in quality to the ${ \sim } 1 . 3 \mathrm { B }$ parameter model on cars, though on chairs, we do observe a significant improvement on 3D consistency in our samples. Importantly, 3D consistency scoring agrees with our qualitative observations.
|
| 179 |
+
|
| 180 |
+
# 5 CONCLUSION AND FUTURE WORK
|
| 181 |
+
|
| 182 |
+
We propose 3DiM, a diffusion model for 3D novel view synthesis. Combining improvements in our X-UNet neural architecture (Section 2.3), with our novel stochastic conditioning sampling strategy that enables autoregressive generation over frames (Section 2.2), we show that from as few as a single image we can generate approximately 3D consistent views with very sharp sample quality. We additionally introduce 3D consistency scoring to evaluate the 3D consistency of geometry-free generative models by training neural fields on model output views, as their performance will be hindered increasingly with inconsistent training data (Section 4). We thus show, both quantitatively and visually, that 3DiMs with stochastic conditioning can achieve approximate 3D consistency and high sample quality simultaneously, and how classical metrics fail to capture both sharp modes and 3D inconsistency.
|
| 183 |
+
|
| 184 |
+
A noteworthy limitation of 3DiM is that, due to the geometry-free setup, it can only handle distributions of poses that it is exposed to durining training. In particular, further study is required where more variations to the poses are introduced. For example, varying focal lengths, sensor widths, making the camera not look exactly at the objects, and varying the distances from the camera to the objects more aggressively. Our use of stochastic conditioning might also exacerbate the need for many denoising steps. While we believe that finding effective architectures that allow conditioning on sets of images remains an important open problem, stochastic conditioning unlocks the ability to train on examples that only have two views and helps overcome memory-intensive neural architectures. Similar approaches using randomized, sparse conditioning are already being explored in follow-up work on video generation (Davtyan et al., 2022) in order to enable efficient training when modeling the joint distribution is computationally prohibitive.
|
| 185 |
+
|
| 186 |
+
We are most excited about the possibility of applying 3DiM, which can model entire datasets with a single model, to the largest 3D datasets from the real world – though more research is required to handle noisy poses (due to the need for pose estimation) and other challenges present in this context. Developing end-to-end approaches for high-quality generation that are 3D consistent by design like more recent work (Muller et al., 2022) and that also yield high-quality 3D meshes remain important ¨ research problems. Another potentially significant application of 3DiM is its use as a prior in order to achieve 3D consistent generation via approaches that operate exclusively at sampling time (Poole et al., 2022; Zhou & Tulsiani, 2022; Xu et al., 2022) in order to enable wide adoption of similar, disruptive technologies on the 3D design industry.
|
| 187 |
+
|
| 188 |
+
# REFERENCES
|
| 189 |
+
|
| 190 |
+
Jonathan T. Barron, Ben Mildenhall, Dor Verbin, Pratul P. Srinivasan, and Peter Hedman. Mip-nerf 360: Unbounded anti-aliased neural radiance fields. CVPR, 2022.
|
| 191 |
+
|
| 192 |
+
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.
|
| 193 |
+
|
| 194 |
+
Eric R Chan, Connor Z Lin, Matthew A Chan, Koki Nagano, Boxiao Pan, Shalini De Mello, Orazio Gallo, Leonidas J Guibas, Jonathan Tremblay, Sameh Khamis, et al. Efficient geometry-aware 3d generative adversarial networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 16123–16133, 2022.
|
| 195 |
+
|
| 196 |
+
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 preprint arXiv:1512.03012, 2015.
|
| 197 |
+
|
| 198 |
+
Nanxin Chen, Yu Zhang, Heiga Zen, Ron J Weiss, Mohammad Norouzi, and William Chan. Wavegrad: Estimating gradients for waveform generation. arXiv preprint arXiv:2009.00713, 2020.
|
| 199 |
+
|
| 200 |
+
Aram Davtyan, Sepehr Sameni, and Paolo Favaro. Randomized conditional flow matching for video prediction. arXiv preprint arXiv:2211.14575, 2022.
|
| 201 |
+
|
| 202 |
+
Prafulla Dhariwal and Alexander Nichol. Diffusion models beat gans on image synthesis. Advances in Neural Information Processing Systems, 34, 2021.
|
| 203 |
+
|
| 204 |
+
Vincent Dumoulin, Ethan Perez, Nathan Schucher, Florian Strub, Harm de Vries, Aaron Courville, and Yoshua Bengio. Feature-wise transformations. Distill, 3(7):e11, 2018.
|
| 205 |
+
|
| 206 |
+
Emilien Dupont, Miguel Bautista Martin, Alex Colburn, Aditya Sankar, Josh Susskind, and Qi Shan. Equivariant neural rendering. In International Conference on Machine Learning, pp. 2761–2770. PMLR, 2020.
|
| 207 |
+
|
| 208 |
+
Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. Advances in neural information processing systems, 27, 2014.
|
| 209 |
+
|
| 210 |
+
Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and Sepp Hochreiter. Gans trained by a two time-scale update rule converge to a local nash equilibrium. Advances in neural information processing systems, 30, 2017.
|
| 211 |
+
|
| 212 |
+
Jonathan Ho and Tim Salimans. Classifier-free diffusion guidance. In NeurIPS 2021 Workshop on Deep Generative Models and Downstream Applications, 2021.
|
| 213 |
+
|
| 214 |
+
Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33:6840–6851, 2020.
|
| 215 |
+
|
| 216 |
+
Jonathan Ho, Tim Salimans, Alexey Gritsenko, William Chan, Mohammad Norouzi, and David J Fleet. Video diffusion models. arXiv preprint arXiv:2204.03458, 2022.
|
| 217 |
+
|
| 218 |
+
Wonbong Jang and Lourdes Agapito. Codenerf: Disentangled neural radiance fields for object categories. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 12949–12958, 2021.
|
| 219 |
+
|
| 220 |
+
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, pp. 4401–4410, 2019.
|
| 221 |
+
|
| 222 |
+
Tero Karras, Miika Aittala, Timo Aila, and Samuli Laine. Elucidating the design space of diffusionbased generative models. arXiv preprint arXiv:2206.00364, 2022.
|
| 223 |
+
|
| 224 |
+
Diederik Kingma, Tim Salimans, Ben Poole, and Jonathan Ho. Variational diffusion models. Advances in neural information processing systems, 34:21696–21707, 2021.
|
| 225 |
+
|
| 226 |
+
Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
|
| 227 |
+
|
| 228 |
+
Diederik P Kingma and Max Welling. Auto-encoding variational bayes. arXiv preprint arXiv:1312.6114, 2013.
|
| 229 |
+
|
| 230 |
+
Kai-En Lin, Lin Yen-Chen, Wei-Sheng Lai, Tsung-Yi Lin, Yi-Chang Shih, and Ravi Ramamoorthi. Vision transformer for nerf-based view synthesis from a single input image. arXiv preprint arXiv:2207.05736, 2022.
|
| 231 |
+
|
| 232 |
+
Lars Mescheder, Andreas Geiger, and Sebastian Nowozin. Which training methods for gans do actually converge? In International conference on machine learning, pp. 3481–3490. PMLR, 2018.
|
| 233 |
+
|
| 234 |
+
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 European conference on computer vision, pp. 405–421. Springer, 2020.
|
| 235 |
+
|
| 236 |
+
Norman Muller, Yawar Siddiqui, Lorenzo Porzi, Samuel Rota Bul ¨ o, Peter Kontschieder, and \` Matthias Nießner. Diffrf: Rendering-guided 3d radiance field diffusion. arXiv preprint arXiv:2212.01206, 2022.
|
| 237 |
+
|
| 238 |
+
Thomas Muller, Alex Evans, Christoph Schied, and Alexander Keller. Instant neural graphics prim- ¨ itives with a multiresolution hash encoding. ACM Trans. Graph., 41(4):102:1–102:15, July 2022. doi: 10.1145/3528223.3530127. URL https://doi.org/10.1145/3528223. 3530127.
|
| 239 |
+
|
| 240 |
+
Michael Niemeyer, Jonathan T Barron, Ben Mildenhall, Mehdi SM Sajjadi, Andreas Geiger, and Noha Radwan. Regnerf: Regularizing neural radiance fields for view synthesis from sparse inputs. arXiv preprint arXiv:2112.00724, 2021.
|
| 241 |
+
|
| 242 |
+
Eunbyung Park, Jimei Yang, Ersin Yumer, Duygu Ceylan, and Alexander C Berg. Transformationgrounded image generation network for novel 3d view synthesis. In Proceedings of the ieee conference on computer vision and pattern recognition, pp. 3500–3509, 2017.
|
| 243 |
+
|
| 244 |
+
Ben Poole, Ajay Jain, Jonathan T Barron, and Ben Mildenhall. Dreamfusion: Text-to-3d using 2d diffusion. arXiv preprint arXiv:2209.14988, 2022.
|
| 245 |
+
|
| 246 |
+
Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical textconditional image generation with clip latents. arXiv preprint arXiv:2204.06125, 2022.
|
| 247 |
+
|
| 248 |
+
Daniel Rebain, Mark Matthews, Kwang Moo Yi, Dmitry Lagun, and Andrea Tagliasacchi. Lolnerf: Learn from one look, 2021.
|
| 249 |
+
|
| 250 |
+
Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networks for biomedical image segmentation. In International Conference on Medical image computing and computerassisted intervention, pp. 234–241. Springer, 2015.
|
| 251 |
+
|
| 252 |
+
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, 2021a.
|
| 253 |
+
|
| 254 |
+
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, 2021b.
|
| 255 |
+
|
| 256 |
+
Chitwan Saharia, William Chan, Saurabh Saxena, Lala Li, Jay Whang, Emily Denton, Seyed Kamyar Seyed Ghasemipour, Burcu Karagol Ayan, S Sara Mahdavi, Rapha Gontijo Lopes, et al. Photorealistic text-to-image diffusion models with deep language understanding. arXiv preprint arXiv:2205.11487, 2022.
|
| 257 |
+
|
| 258 |
+
Mehdi SM Sajjadi, Henning Meyer, Etienne Pot, Urs Bergmann, Klaus Greff, Noha Radwan, Suhani Vora, Mario Lucic, Daniel Duckworth, Alexey Dosovitskiy, et al. Scene representation transformer: Geometry-free novel view synthesis through set-latent scene representations. arXiv preprint arXiv:2111.13152, 2021.
|
| 259 |
+
|
| 260 |
+
Tim Salimans and Jonathan Ho. Progressive distillation for fast sampling of diffusion models. arXiv preprint arXiv:2202.00512, 2022.
|
| 261 |
+
|
| 262 |
+
Vincent Sitzmann, Michael Zollhofer, and Gordon Wetzstein. Scene representation networks: Con- ¨ tinuous 3d-structure-aware neural scene representations. Advances in Neural Information Processing Systems, 32, 2019.
|
| 263 |
+
|
| 264 |
+
Vincent Sitzmann, Semon Rezchikov, Bill Freeman, Josh Tenenbaum, and Fredo Durand. Light field networks: Neural scene representations with single-evaluation rendering. Advances in Neural Information Processing Systems, 34, 2021.
|
| 265 |
+
|
| 266 |
+
Jascha Sohl-Dickstein, Eric Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. In International Conference on Machine Learning, pp. 2256–2265. PMLR, 2015.
|
| 267 |
+
|
| 268 |
+
Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. Advances in Neural Information Processing Systems, 32, 2019.
|
| 269 |
+
|
| 270 |
+
Yang Song, Jascha Sohl-Dickstein, Diederik P Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. arXiv preprint arXiv:2011.13456, 2020.
|
| 271 |
+
|
| 272 |
+
Yang Song, Conor Durkan, Iain Murray, and Stefano Ermon. Maximum likelihood training of scorebased diffusion models. Advances in Neural Information Processing Systems, 34:1415–1428, 2021.
|
| 273 |
+
|
| 274 |
+
Shao-Hua Sun, Minyoung Huh, Yuan-Hong Liao, Ning Zhang, and Joseph J Lim. Multi-view to novel view: Synthesizing novel views with self-learned confidence. In Proceedings of the European Conference on Computer Vision (ECCV), pp. 155–171, 2018.
|
| 275 |
+
|
| 276 |
+
Dor Verbin, Peter Hedman, Ben Mildenhall, Todd Zickler, Jonathan T. Barron, and Pratul P. Srinivasan. Ref-NeRF: Structured view-dependent appearance for neural radiance fields. CVPR, 2022.
|
| 277 |
+
|
| 278 |
+
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.
|
| 279 |
+
|
| 280 |
+
Dejia Xu, Yifan Jiang, Peihao Wang, Zhiwen Fan, Yi Wang, and Zhangyang Wang. Neurallift-360: Lifting an in-the-wild 2d photo to a 3d object with $3 6 0 ^ { \circ }$ views. arXiv e-prints, pp. arXiv–2211, 2022.
|
| 281 |
+
|
| 282 |
+
Alex Yu, Vickie Ye, Matthew Tancik, and Angjoo Kanazawa. pixelnerf: Neural radiance fields from one or few images. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 4578–4587, 2021.
|
| 283 |
+
|
| 284 |
+
Tinghui Zhou, Richard Tucker, John Flynn, Graham Fyffe, and Noah Snavely. Stereo magnification: Learning view synthesis using multiplane images. arXiv preprint arXiv:1805.09817, 2018.
|
| 285 |
+
|
| 286 |
+
Zhizhuo Zhou and Shubham Tulsiani. Sparsefusion: Distilling view-conditioned diffusion for 3d reconstruction. arXiv preprint arXiv:2212.00792, 2022.
|
| 287 |
+
|
| 288 |
+
# Novel View Synthesis with Diffusion Models
|
| 289 |
+
|
| 290 |
+
Supplementary Material
|
| 291 |
+
|
| 292 |
+
# 6 ARCHITECTURE DETAILS
|
| 293 |
+
|
| 294 |
+
In order to maximize the reproducibility of our results, we provide code in JAX (Bradbury et al., 2018) for our proposed X-UNet neural architecture from Section 2.3. Assuming we have an input batch with elements each containing
|
| 295 |
+
|
| 296 |
+
{ "z", # noisy input image (HxWx3 tensor) "x", # conditioning view (HxWx3 tensor) "logsnr", # log signal-to-noise ratio of noisy image (scalar) "t", # camera positions (two 3d vectors) "R", # camera rotations (two 3x3 matrices) "K", # camera intrinsics (a.k.a. calibration matrix) (3x3 matrix)
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
our neural network module is as follows:
|
| 300 |
+
|
| 301 |
+
from typing import Optional import flax.linen as nn import jax.numpy as jnp import numpy as onp import visu3d as v3d
|
| 302 |
+
|
| 303 |
+
nonlinearity $=$ nn.swish
|
| 304 |
+
|
| 305 |
+
def out_init_scale(): """Zeros initializer.""" return nn.initializers.variance_scaling(0.0, 'fan_in', 'truncated_normal')
|
| 306 |
+
|
| 307 |
+
def nearest_neighbor_upsample(h: jnp.ndarray): """Nearest neighbor upsampling for multiple frames.""" B, F, H, W, ${ \mathrm { ~ \small ~ \mathscr ~ { ~ C ~ } ~ } } = { \mathrm { ~ \small ~ h ~ } }$ .shape h $=$ h.reshape(B, F, H, 1, W, 1, C) h = jnp.broadcast_to(h, (B, F, H, 2, W, 2, C)) return h.reshape(B, F, H $\star$ 2, W $\star$ 2, C)
|
| 308 |
+
|
| 309 |
+
def avgpool_downsample(h: jnp.ndarray, k: int $= 2$ ): """Average pooling downsampling for multiple frames.""" return nn.avg_pool(h, (1, k, k), (1, k, k))
|
| 310 |
+
|
| 311 |
+
def posenc_ddpm(timesteps: jnp.ndarray, emb_ch: int, max_time: int $=$ 1000.0): """Positional encodings for noise levels, following DDPM.""" # 1000 is the magic number from DDPM. With different timesteps, we # normalize by the number of steps but still multiply by 1000. timesteps \*= 1000.0 / max_time half_dim $=$ emb_ch // 2 # 10000 is the magic number from transformers. emb $=$ onp.log(10000) / (half_dim - 1)
|
| 312 |
+
|
| 313 |
+
emb $=$ jnp.exp(jnp.arange(half_dim, dtype $=$ timesteps.dtype) $\star$ -emb)
|
| 314 |
+
emb $=$ emb.reshape( $\star$ ([1] $^ { \star }$ (timesteps.ndim - 1)), emb.shape[-1])
|
| 315 |
+
emb $=$ timesteps[..., None] $\star$ emb
|
| 316 |
+
emb $=$ jnp.concatenate([jnp.sin(emb), jnp.cos(emb)], axis $= - 1$ )
|
| 317 |
+
return emb
|
| 318 |
+
|
| 319 |
+
def posenc_nerf(x: jnp.ndarray, min_deg: int $\qquad = \quad 0$ , max_deg: int $= ~ \perp 5$ ): """Concatenate x and its positional encodings, following NeRF."""
|
| 320 |
+
|
| 321 |
+
if min_deg $= =$ max_deg: return x
|
| 322 |
+
scales $=$ jnp.array([2\*\*i for i in range(min_deg, max_deg)])
|
| 323 |
+
xb $=$ jnp.reshape( (x[..., None, :] $^ { \star }$ scales[:, None]), list(x.shape[:-1]) + [-1]
|
| 324 |
+
)
|
| 325 |
+
emb $=$ jnp.sin(jnp.concatenate([xb, xb $^ +$ onp.pi / 2.0], axis $: = - 1$ ))
|
| 326 |
+
return jnp.concatenate([x, emb], axis $= - 1$ )
|
| 327 |
+
|
| 328 |
+
class GroupNorm(nn.Module): """Group normalization, applied over frames."""
|
| 329 |
+
|
| 330 |
+
@nn.compact
|
| 331 |
+
|
| 332 |
+
def __call__(self, h: jnp.ndarray):B, _, H, W, ${ \mathrm { ~ \small ~ \mathscr ~ { ~ C ~ } ~ } } = { \mathrm { ~ \small ~ h ~ } }$ .shapeh $=$ nn.GroupNorm(num_groups $= 3 2$ )(h.reshape(B $\star$ 2, 2, H, W, C))return h.reshape(B, 2, H, W, C)
|
| 333 |
+
|
| 334 |
+
class FiLM(nn.Module): """Feature-wise linear modulation."""
|
| 335 |
+
|
| 336 |
+
features: int @nn.compact
|
| 337 |
+
|
| 338 |
+
def __call__(self, h: jnp.ndarray, emb: jnp.ndarray): emb $=$ nn.Dense(2 \* self.features)(nonlinearity(emb)) scale, shift $=$ jnp.split(emb, $^ 2$ , axis $= - 1$ ) return h $^ { \star }$ (1.0 $^ +$ scale) $^ +$ shift
|
| 339 |
+
|
| 340 |
+
class ResnetBlock(nn.Module): """BigGAN-style residual block, applied over frames."""
|
| 341 |
+
|
| 342 |
+
features: Optional[int] $=$ None dropout: float $= ~ 0 . 0$ resample: Optional[str] $=$ None
|
| 343 |
+
|
| 344 |
+
# @nn.compact
|
| 345 |
+
|
| 346 |
+
def __call__(self, h_in: jnp.ndarray, emb: jnp.ndarray, \*, train: bool): _, _, _, _, C $=$ h_in.shape features $=$ C if self.features is None else self.features
|
| 347 |
+
|
| 348 |
+
$\mathrm { ~ \textbar ~ { ~ h ~ } ~ } =$ nonlinearity(GroupNorm()(h_in))
|
| 349 |
+
if self.resample is not None: updown $= \quad \left\{ \begin{array} { r l r l } \end{array} \right.$ 'up': nearest_neighbor_upsample, 'down': avgpool_downsample, }[self.resample]
|
| 350 |
+
|
| 351 |
+
$\mathrm { ~ \textit ~ { ~ h ~ } ~ } =$ updown(h) h_in $=$ updown(h_in)
|
| 352 |
+
|
| 353 |
+
$\mathrm { ~ \textbar ~ { ~ h ~ } ~ } =$ nn.Conv(features, kernel_size $=$ (1, 3, 3), strides $=$ (1, 1, 1))(h)
|
| 354 |
+
$\mathrm { ~ \textbar ~ { ~ h ~ } ~ } =$ FiLM(features $=$ features)(GroupNorm()(h), emb)
|
| 355 |
+
h $=$ nonlinearity(h)
|
| 356 |
+
h $=$ nn.Dropout(rate $=$ self.dropout)(h, deterministic $: =$ not train)
|
| 357 |
+
$\mathrm { ~ \textbar ~ { ~ h ~ } ~ } =$ nn.Conv( features, kernel_size $=$ (1, 3, 3), strides $=$ (1, 1, 1), kernel_init $=$ out_init_scale(),
|
| 358 |
+
|
| 359 |
+
)(h)
|
| 360 |
+
|
| 361 |
+
if C $! =$ features: h_in $=$ nn.Dense(features)(h_in) return (h $^ +$ h_in) / onp.sqrt(2)
|
| 362 |
+
|
| 363 |
+
class AttnLayer(nn.Module):
|
| 364 |
+
|
| 365 |
+
"""Attention layer usable for self and cross attention."""
|
| 366 |
+
|
| 367 |
+
attn_heads: int $\qquad = \quad 4$
|
| 368 |
+
|
| 369 |
+
# @nn.compact
|
| 370 |
+
|
| 371 |
+
def _call__(self, \*, q: jnp.ndarray, kv: jnp.ndarray): $\mathrm { ~ C ~ } = \mathrm { ~ q ~ }$ .shape[-1] head_dim $\begin{array} { r l } { \mathbf { \Sigma } } & { { } = \mathbf { \Sigma } \subset \mathbf { \Sigma } } \end{array}$ // self.attn_heads q $=$ nn.DenseGeneral((self.attn_heads, head_dim))(q) k $=$ nn.DenseGeneral((self.attn_heads, head_dim))(kv) $\begin{array} { r l } { \mathsf { v } } & { { } = } \end{array}$ nn.DenseGeneral((self.attn_heads, head_dim))(kv) return nn.dot_product_attention(q, k, v)
|
| 372 |
+
|
| 373 |
+
class AttnBlock(nn.Module): """Attention block with skip connection."""
|
| 374 |
+
|
| 375 |
+
attn_type: str attn_heads: int $\qquad = \quad 4$
|
| 376 |
+
|
| 377 |
+
# @nn.compact
|
| 378 |
+
|
| 379 |
+
def __call__(self, h_in: jnp.ndarray): B, _, H, W, C $=$ h_in.shape
|
| 380 |
+
|
| 381 |
+
h $=$ GroupNorm()(h_in) h0 = h[:, 0].reshape(B, H \* W, C) h1 = h[:, 1].reshape(B, H $\star$ W, C) attn_layer $=$ AttnLayer(attn_heads $=$ self.attn_heads)
|
| 382 |
+
|
| 383 |
+
if self.attn_type $= =$ 'self': $\mathrm { ~ \textit ~ { ~ h ~ O ~ } ~ } =$ attn_layer( $\mathtt { q } \mathrm { = h 0 }$ , $\mathtt { k v } { = } \mathtt { h } 0$ ) $\begin{array} { r l } { \operatorname { h } 1 } & { { } = } \end{array}$ attn_layer( $\mathtt { q } \mathrm { = h 1 }$ , $\mathrm { k v } { = } \mathrm { h } 1$ )
|
| 384 |
+
elif self.attn_type $= =$ 'cross': $\mathrm { ~ \textit ~ { ~ h ~ O ~ } ~ } =$ attn_layer( $\mathtt { q } \mathrm { = h 0 }$ , $\mathrm { k v } { = } \mathrm { h } 1$ ) h1 $=$ attn_layer( $\mathtt { q } \mathrm { = h 1 }$ , $\mathtt { k v } { = } \mathtt { h } 0$ )
|
| 385 |
+
else: raise NotImplementedError(self.attn_type)
|
| 386 |
+
|
| 387 |
+
h = jnp.stack([h0, h1], axis $^ { = 1 }$ )
|
| 388 |
+
|
| 389 |
+
$\mathrm { ~ \textbar ~ { ~ h ~ } ~ } =$ h.reshape(B, 2, H, W, $^ { - 1 }$ )
|
| 390 |
+
$\mathrm { ~ \textbar ~ { ~ h ~ } ~ } =$ nn.DenseGeneral(C, axis $ \mathfrak { s } = ( - 2$ , -1), kernel_init $=$ out_init_scale())(h)
|
| 391 |
+
return (h $^ +$ h_in) / onp.sqrt(2)
|
| 392 |
+
|
| 393 |
+
class XUNetBlock(nn.Module): """X-UNet block."""
|
| 394 |
+
|
| 395 |
+
features: int use_attn: bool $=$ False attn_heads: int $\qquad = \quad 4$ dropout: float $= ~ 0 . 0$
|
| 396 |
+
|
| 397 |
+
# @nn.compact
|
| 398 |
+
|
| 399 |
+
def call (self, x: jnp.ndarray, emb: jnp.ndarray, $\star$ , train: bool): h $=$ ResnetBlock(features $=$ self.features, dropout $=$ self.dropout)( x, emb, train $=$ train )
|
| 400 |
+
|
| 401 |
+
if self.use_attn: h $=$ AttnBlock(attn_type $=$ 'self', attn_heads $=$ self.attn_heads)(h) h $=$ AttnBlock(attn_type $= ^ { \parallel }$ cross', attn_heads $=$ self.attn_heads)(h)
|
| 402 |
+
|
| 403 |
+
return h
|
| 404 |
+
|
| 405 |
+
class ConditioningProcessor(nn.Module): """Process conditioning inputs into embeddings."""
|
| 406 |
+
|
| 407 |
+
emb_ch: int num_resolutions: int use_pos_emb: bool $=$ True use_ref_pose_emb: bool $=$ True
|
| 408 |
+
|
| 409 |
+
@nn.compact
|
| 410 |
+
def __call__(self, batch: dict[str, jnp.ndarray], cond_mask: jnp.ndarray): B, H, W, _ $=$ batch['x'].shape # Log signal-to-noise-ratio embedding.
|
| 411 |
+
logsnr $=$ jnp.clip(batch['logsnr'], -20.0, 20.0)
|
| 412 |
+
logsnr $= \ 2 . 0 \times$ jnp.arctan(jnp.exp(-logsnr / 2.0)) / onp.pi
|
| 413 |
+
logsnr_emb $=$ posenc_ddpm(logsnr, emb_ch ${ \underline { { \mathbf { \Pi } } } } =$ self.emb_ch, max_time $^ { - 1 }$ .0) logsnr_emb $=$ nn.Dense(self.emb_ch)(logsnr_emb)
|
| 414 |
+
logsnr_emb $=$ nn.Dense(self.emb_ch)(nonlinearity(logsnr_emb))
|
| 415 |
+
|
| 416 |
+
# Pose embeddings.
|
| 417 |
+
|
| 418 |
+
world_from_cam $=$ v3d.Transform( $\mathrm { R = }$ batch['R'], t $=$ batch['t']) cam_spec $=$ v3d.PinholeCamera(resolution ${ } = { }$ (H, W), $\mathrm { K } =$ batch['K']) rays $=$ v3d.Camera(spec $=$ cam_spec, world_from_cam $\cdot ^ { = }$ world_from_cam).rays()
|
| 419 |
+
|
| 420 |
+
pose_emb_pos $=$ posenc_nerf(rays.pos, min_deg $= 0$ , max_deg $= \beth 5$ ) pose_emb_dir $=$ posenc_nerf(rays.dir, min_deg ${ \bf \bar { \theta } } = 0$ , max_deg ${ } = 8 { }$ ) pose_emb $=$ jnp.concatenate([pose_emb_pos, pose_emb_dir], axi $S { = } { - } 1$ )
|
| 421 |
+
|
| 422 |
+
# Enable classifier-free guidance over poses.
|
| 423 |
+
|
| 424 |
+
D $=$ pose_emb.shape[-1]
|
| 425 |
+
assert cond_mask.shape $= =$ (B,)
|
| 426 |
+
cond_mask $=$ cond_mask[:, None, None, None, None]
|
| 427 |
+
pose_emb $=$ jnp.where(cond_mask, pose_emb, jnp.zeros_like(pose_emb))
|
| 428 |
+
|
| 429 |
+
# Learnable position embeddings over (H, W) of frames (optional).
|
| 430 |
+
|
| 431 |
+
if self.use_pos_emb: pos_emb $=$ self.param( 'pos_emb', nn.initializers.normal(stddev $\ l = 1$ .0 / onp.sqrt(D)), (H, W, D), pose_emb.dtype, ) pose_emb $+ =$ pos_emb[None, None]
|
| 432 |
+
|
| 433 |
+
# Binary embedding to let the model distinguish frames (optional)
|
| 434 |
+
|
| 435 |
+
if self.use_ref_pose_emb: first_emb $=$ self.param( 'ref_pose_emb_first', nn.initializers.normal(stddev $^ { \cdot = 1 }$ .0 / onp.sqrt(D)), (D,), pose_emb.dtype, )[None, None, None, None] other_emb $=$ self.param( 'ref_pose_emb_other', nn.initializers.normal(stddev $\ l = 1$ .0 / onp.sqrt(D)), (D,), pose_emb.dtype, )[None, None, None, None] pose_emb $+ =$ jnp.concatenate([first_emb, other_emb], axis $^ { = 1 }$
|
| 436 |
+
|
| 437 |
+
# Downsample ray embeddings for each UNet resolution.
|
| 438 |
+
pose_embs $=$ []
|
| 439 |
+
for i_level in range(self.num_resolutions): pose_embs.append( nn.Conv( features $=$ self.emb_ch, kernel_size $=$ (1, 3, 3), strides $=$ (1, $2 \star \star$ i_level, 2\*\*i_level), )(pose_emb) )
|
| 440 |
+
|
| 441 |
+
return logsnr_emb, pose_embs class XUNet(nn.Module): """Our proposed XUNet architecture."""
|
| 442 |
+
|
| 443 |
+
ch: int $= \ 2 5 6$
|
| 444 |
+
ch_mult: tuple[int] $=$ (1, 2, 2, 4)
|
| 445 |
+
emb_ch: int $= ~ 1 0 2 4$
|
| 446 |
+
num_res_blocks: int $= 3$
|
| 447 |
+
attn_resolutions: tuple[int] $=$ (8, 16, 32)
|
| 448 |
+
attn_heads: int $\qquad = \quad 4$
|
| 449 |
+
dropout: float $= ~ 0 . 1$
|
| 450 |
+
use_pos_emb: bool $=$ True
|
| 451 |
+
use_ref_pose_emb: bool $=$ True
|
| 452 |
+
|
| 453 |
+
@nn.compact def __call__( self,
|
| 454 |
+
|
| 455 |
+
batch: dict[str, jnp.ndarray], \*, cond_mask: jnp.ndarray, train: bool, ): _, _, _, ${ \mathrm { ~ \small ~ \mathscr ~ { ~ C ~ } ~ } } =$ batch['x'].shape num_resolutions $=$ len(self.ch_mult) logsnr_emb, pose_embs $=$ ConditioningProcessor( emb_ch $=$ self.emb_ch, num_resolutions $=$ num_resolutions, use_pos_emb $=$ self.use_pos_emb, use_ref_pose_emb $=$ self.use_ref_pose_emb, )(batch, cond_mask) del cond_mask
|
| 456 |
+
|
| 457 |
+
h $=$ jnp.stack([batch['x'], batch $[ { \mathrm { ~ ~ \cdot ~ } } _ { Z } { \mathrm { ~ ~ \cdot ~ } } ] ]$ , axis $: = 1$ ) h $=$ nn.Conv(self.ch, kernel_size $=$ (1, 3, 3), strides $=$ (1, 1, 1))(h)
|
| 458 |
+
|
| 459 |
+
# Downsampling.
|
| 460 |
+
|
| 461 |
+
hs $=$ [h]
|
| 462 |
+
for i_level in self.ch_mult: emb $=$ logsnr_emb[..., None, None, :] $^ +$ pose_embs[i_level]
|
| 463 |
+
|
| 464 |
+
for in range(self.num_res_blocks): use_attn $=$ h.shape[2] in self.attn_resolutions h $=$ XUNetBlock( features $=$ self.ch $\star$ self.ch_mult[i_level], dropout $=$ self.dropout, attn_heads $=$ self.attn_heads, use_attn ${ \bf \Phi } = { \bf \Phi }$ use_attn, )(h, emb, train $=$ train) hs.append(h)
|
| 465 |
+
|
| 466 |
+
if i_level $\downarrow =$ num_resolutions - 1: emb $=$ logsnr_emb[..., None, None, :] $^ +$ pose_embs[i_level + 1] h $=$ ResnetBlock(dropout $=$ self.dropout, resample $= 1$ down')( h, emb, train ${ \bf \Phi } = { \bf \Phi }$ train ) hs.append(h)
|
| 467 |
+
|
| 468 |
+
# # Middle.
|
| 469 |
+
|
| 470 |
+
emb $=$ logsnr_emb[..., None, None, :] $^ +$ pose_embs[-1]
|
| 471 |
+
use_attn $=$ h.shape[2] in self.attn_resolutions
|
| 472 |
+
h $=$ XUNetBlock( features $=$ self.ch $\star$ self.ch_mult[i_level], dropout $=$ self.dropout, attn_heads $=$ self.attn_heads, use_attn $=$ use_attn,
|
| 473 |
+
)(h, emb, train $=$ train)
|
| 474 |
+
|
| 475 |
+
$\#$ Upsampling.
|
| 476 |
+
|
| 477 |
+
for i_level in reversed(range(num_resolutions)): emb $=$ logsnr_emb[..., None, None, :] $^ +$ pose_embs[i_level] for _ in range(self.num_res_blocks + 1): use_attn $=$ hs[-1].shape[2] in self.attn_resolutions h $=$ jnp.concatenate([h, hs.pop()], axis $= - 1$ ) h $=$ XUNetBlock(
|
| 478 |
+
|
| 479 |
+
features $=$ self.ch $\star$ self.ch_mult[i_level], dropout $=$ self.dropout, attn_heads $=$ self.attn_heads, use_attn ${ \bf \Phi } = { \bf \Phi }$ use_attn, )(h, emb, train $=$ train)
|
| 480 |
+
|
| 481 |
+
if i_level $\ : \ 0$ : emb $=$ logsnr_emb[..., None, None, :] $^ +$ pose_embs[i_level] $\mathrm { ~ \textbar ~ { ~ h ~ } ~ } =$ ResnetBlock(dropout $=$ self.dropout, resample $= ^ { \parallel }$ up')( h, emb, train ${ \bf \Phi } = { \bf \Phi }$ train )
|
| 482 |
+
|
| 483 |
+
# End.
|
| 484 |
+
assert not hs
|
| 485 |
+
$\mathrm { ~ \textbar ~ { ~ h ~ } ~ } =$ nonlinearity(GroupNorm()(h))
|
| 486 |
+
return nn.Conv( C, kernel_size $=$ (1, 3, 3), strides $; =$ (1, 1, 1), kernel_init $=$ out_init_scale(),
|
| 487 |
+
)(h)[:, 1]
|
| 488 |
+
|
| 489 |
+
# 7 HYPERPARAMETERS
|
| 490 |
+
|
| 491 |
+
We now detail hyperparameter choices across our experiments. These include choices specific to the neural architecture, the training procedure, and also choices only relevant during inference.
|
| 492 |
+
|
| 493 |
+
# 7.1 NEURAL ARCHITECTURE
|
| 494 |
+
|
| 495 |
+
For our neural architecture, our main experiments use $_ { \mathrm { C h } = 2 5 6 }$ ( ${ \sim } 4 7 1 \mathrm { M }$ params), and we also experiment with $\cosh { = } 4 4 8$ $( \sim 1 . 3 \mathrm { B }$ params) in Section 4. One of our early findings that we kept throughout all experiments in the paper is that $\mathtt { c h \_ m u l t } = ( \mathtt { l } , \mathtt { \xi } _ { 2 } , \mathtt { \xi } _ { 2 } , \mathtt { \xi } _ { 4 } )$ (i.e., setting the lowest UNet resolution to 8x8) was sufficient to achieve good sample quality, wheras most prior work includes UNet resolutions up to $4 \mathbf { x } 4$ . We sweeped over the rest of the hyperparameters with the input and target views downsampled from their original $1 2 8 \mathrm { x } 1 2 8$ resolution to the $3 2 \mathrm { x } 3 2 $ , selecting values that led to the best qualitative improvements. These values are the default values present in the code we provide for the XUNet module in Section 6. We generally find that the best hyperparameter choices at low-resolution experiments transfer well when applied to the higher resolutions, and thus recommend this strategy for cheaper and more practical hyperparameter tuning.
|
| 496 |
+
|
| 497 |
+
For the ${ \sim } 1 . 3 \mathrm { B }$ parameter models, we tried increasing the number of parameters of our proposed UNet architecture through several different ways: increasing the number of blocks per resolution, the number of attention heads, the number of cross-attention layers per block, and the base number of hidden channels. Among all of these, we only found the last to provide noticeably better sample quality. We thus run 3D consistency scoring for models scaled this way, with channel sizes per UNet resolution of $4 4 8 \times [ 1 , 2 , 2 , 4 ]$ instead of $2 5 6 \times [ 1 , 2 , 2 , 4 ]$ (we could not fit $_ { \mathrm { c h } = 5 1 2 }$ in TPUv4 memory without model parallelism). On cars, we find that the smaller model reported in the rest of the paper is comparable in quality to the ${ \sim } 1 . 3 \mathrm { B }$ parameter model, though on chairs, we do observe a significant improvement on 3D consistency, both visually and quantitatively (see Table 6).
|
| 498 |
+
|
| 499 |
+
# 7.2 TRAINING
|
| 500 |
+
|
| 501 |
+
Following Equation 3 in the paper, our neural network attempts to model the noise $\epsilon$ added to a real image in order to undo it given the noisy image. Other parameterizations are possible, e.g., predicting $_ { \textbf { \em x } }$ directly rather than predicting $\epsilon$ , though we did not sweep over these choices. For our noise schedule, we use a cosine-shaped log signal to noise ratio that monotonically decreases from 20 to -20. It can be implemented in JAX as follows:
|
| 502 |
+
|
| 503 |
+
def logsnr_schedule_cosine(t, $\star$ , logsnr_min $= - 2 0$ ., logsnr_max $: = 2 0$ .): $\textrm { b } =$ onp.arctan(onp.exp(-.5 \* logsnr_max)) $\begin{array} { r l } { \exists } & { { } = } \end{array}$ onp.arctan(onp.exp(-.5 $\star$ logsnr_min)) - b return $^ { - 2 }$ . \* jnp.log(jnp.tan( $ { \sf a } \mathrm { ~ ~ \star ~ } \sf t + \mathrm { ~ ~ b ~ } )$ )
|
| 504 |
+
|
| 505 |
+
Additionally:
|
| 506 |
+
|
| 507 |
+
• We use a learning rate with peak value 0.0001, using linear warmup for the first 10 million examples (where one batch has batch_size examples), following Karras et al. (2022).
|
| 508 |
+
• We use a global batch size of 128.
|
| 509 |
+
• We train each batch element as an unconditional example $10 \%$ of the time to enable classifier-free guidance. This is done by overriding the conditioning frame to be at the maximum noise level. We note other options are possible (e.g., zeroing-out the conditioning frame), but we chose the option which is most compatible with our neural architecture.
|
| 510 |
+
• We use the Adam optimizer (Kingma & Ba, 2014) with $\beta _ { 1 } = 0 . 9$ and $\beta _ { 2 } = 0 . 9 9$ .
|
| 511 |
+
• We use EMA decay for the model parameters, with a half life of 500K examples (where one batch has batch_size examples) following Karras et al. (2022).
|
| 512 |
+
|
| 513 |
+
# 7.3 SAMPLING
|
| 514 |
+
|
| 515 |
+
While Ho et al. (2020) note that their ancestral sampler can be used with any variances between $\tilde { \beta } _ { t }$ (variances of $q ( \boldsymbol { z } _ { s } | \boldsymbol { z } _ { t } , \boldsymbol { x } ) )$ and $\beta _ { t }$ (variances of the underlying SDE), we simply use the former as those correspond to their ancestral sampler. We do not observe this choice to have a significant effect sample quality. All our samples are generated with 256 denoising steps. As is standard in the literature, we also clip each predicted $_ { \textbf { \em x } }$ at each denoising step to the normalized range of the images $[ - 1 , 1 ]$ .
|
| 516 |
+
|
| 517 |
+
Classifier-free guidance. Our models use classifier-free guidance (Ho & Salimans, 2021), as we find that small guidance weights help encourage 3D consistency further. All our models were trained unconditionally with a probability of $10 \%$ for each minibatch element. For unconditional examples, we zero out the (positionally encoded) pose and replace the clean frame with standard Gaussian noise (leveraging our weight-sharing architecture, see Section 2.3). We swept over various guidance weights, and simply picked those where 3D inconsistency was qualitatively least apparent on sampled videos. For SRN cars, we use a guidance weight of 3.0, while for SRN chairs we use a weight of 2.0.
|
| 518 |
+
|
| 519 |
+
# 7.4 3D CONSISTENCY SCORING
|
| 520 |
+
|
| 521 |
+
Note that traditional NeRFs (Mildenhall et al., 2020) can be 3D inconsistent as the model allows for view-dependent radiance. We thus employ a simpler and faster to train version based on instantNGP (Muller et al., 2022) without view dependent components, and with additional distortion and ¨ orientation loss terms for improved convergence (Barron et al., 2022; Verbin et al., 2022). Note that the specific implementation details of the neural field method chosen will affect the metrics considerably, so it is of utmost importance to apply the same method and hyperparameters for the neural fields to make 3D consistency scores comparable across models.
|
| 522 |
+
|
| 523 |
+
We design the neural fields as simple Multi-Layer Perceptrons (MLPs) of hidden size 64 and no skip connections. The density MLP has one hidden layer, while the MLP that predicts the color components uses 2 hidden layers. We use a learning rate of 0.01 linearly decayed to 0.001 for the first 100 steps. We use the Adam optimizer with weight decay set to 0.1 and clip gradients of norm exceeding 1.0. We only apply 1000 training steps for each scene and do not optimize camera poses. On each training step, we simply optimize over all available pixels, rather than sampling a random subset of pixels from all the training views.
|
| 524 |
+
|
| 525 |
+
To render the neural fields after training, we set near and far bounds to $\begin{array} { r } { t _ { n } = \frac { 3 r _ { \mathrm { m i n } } } { 8 } , t _ { f } = \frac { 3 r _ { \mathrm { m a x } } } { 2 } . } \end{array}$ where $r _ { \operatorname* { m i n } } , r _ { \operatorname* { m a x } }$ are the minimum and maximum distances from the camera positions to the origin (center of each object) in the corresponding dataset. All renders post-training are also performed with differentiable volume rendering.
|
md/dev/IDwN6xjHnK8/IDwN6xjHnK8.md
ADDED
|
@@ -0,0 +1,545 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# TRANSFORMER-BASED TRANSFORM CODING
|
| 2 |
+
|
| 3 |
+
Yinhao Zhu∗ Yang Yang∗ Taco Cohen Qualcomm AI Research† {yinhaoz, yyangy, tacos}@qti.qualcomm.com
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
Neural data compression based on nonlinear transform coding has made great progress over the last few years, mainly due to improvements in prior models, quantization methods and nonlinear transforms. A general trend in many recent works pushing the limit of rate-distortion performance is to use ever more expensive prior models that can lead to prohibitively slow decoding. Instead, we focus on more expressive transforms that result in a better rate-distortioncomputation trade-off. Specifically, we show that nonlinear transforms built on Swin-transformers can achieve better compression efficiency than transforms built on convolutional neural networks (ConvNets), while requiring fewer parameters and shorter decoding time. Paired with a compute-efficient Channel-wise AutoRegressive Model prior, our SwinT-ChARM model outperforms VTM-12.1 by $3 . 6 8 \%$ in BD-rate on Kodak with comparable decoding speed. In P-frame video compression setting, we are able to outperform the popular ConvNet-based scalespace-flow model by $1 2 . 3 5 \%$ in BD-rate on UVG. We provide model scaling studies to verify the computational efficiency of the proposed solutions and conduct several analyses to reveal the source of coding gain of transformers over ConvNets, including better spatial decorrelation, flexible effective receptive field, and more localized response of latent pixels during progressive decoding.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Transform coding (Goyal, 2001) is the dominant paradigm for compression of multi-media signals, and serves as the technical foundation for many successful coding standards such as JPEG, AAC, and HEVC/VVC. Codecs based on transform coding divide the task of lossy compression into three modularized components: transform, quantization, and entropy coding. All three components can be enhanced by deep neural networks: autoencoder networks are adopted as flexible nonlinear transforms, deep generative models are used as powerful learnable entropy models, and various differentiable quantization schemes are proposed to aid end-to-end training. Thanks to these advancements, we have seen rapid progress in the domain of image and video compression. Particularly, the hyperprior line of work (Balle et al., 2018; Minnen et al., 2018; Lee et al., 2019; Agustsson et al., 2020; ´ Minnen & Singh, 2020) has led to steady progress of neural compression performance over the past two years, reaching or even surpassing state-of-the-art traditional codecs. For example, in image compression, BPG444 was surpassed by a neural codec in 2018 (Minnen et al., 2018), and (Cheng et al., 2020; Xie et al., 2021; Ma et al., 2021; Guo et al., 2021; Wu et al., 2020) have claimed on-par or better performance than VTM (a test model of the state-of-the-art non-learned VVC standard).
|
| 12 |
+
|
| 13 |
+
One general trend in the advancement of neural image compression schemes is to develop ever more expressive yet expensive prior models based on spatial context. However, the rate-distortion improvement from context based prior modeling often comes with a hefty price $\mathrm { { t a g } ^ { 1 } }$ in terms of decoding complexity. Noteably, all existing works that claimed on-par or better performance than VTM (Cheng et al., 2020; Xie et al., 2021; Ma et al., 2021; Guo et al., 2021; Wu et al., 2020) rely on slow and expensive spatial context based prior models.
|
| 14 |
+
|
| 15 |
+
The development of nonlinear transforms, on the other hand, are largely overlooked. This leads us to the following questions: can we achieve the same performance as that of expensive prior models by designing a more expressive transform together with simple prior models? And if so, how much more complexity in the transform is required?
|
| 16 |
+
|
| 17 |
+
Interestingly, we show that by leveraging and adapting the recent development of vision transformers, not only can we build neural codecs with simple prior models that can outperform ones built on expensive spatial autoregressive priors, but do so with smaller transform complexity compared to its convolutional counterparts, attaining a strictly better ratedistortion-complexity trade-off. As can be seen in Figure 1, our proposed neural image codec SwinT-ChARM can outperform VTM-12.1 at comparable decoding time, which, to the best of our knowledge, is a first in the neural compression literature.
|
| 18 |
+
|
| 19 |
+

|
| 20 |
+
Figure 1: BD-rate (smaller is better) vs decoding time. Our Swin transformer based image compression models land in a favorable region of rate-distortion-computation trade-off that has never been achieved before. See Section 4.2 for more results and evaluation setup.
|
| 21 |
+
|
| 22 |
+
As main contributions, we 1) extend SwinTransformer (Liu et al., 2021) to a decoder setting and build Swin-transformer based neural image codecs that attain better rate-distortion performance with lower complexity compared with existing solutions, 2) verify its effectiveness in video compression by enhancing scalespace-flow, a popular neural P-frame codec,
|
| 23 |
+
|
| 24 |
+
and 3) conduct extensive analysis and ablation study to explore differences between convolution and transformers, and investigate potential source of coding gain.
|
| 25 |
+
|
| 26 |
+
# 2 BACKGROUND & RELATED WORK
|
| 27 |
+
|
| 28 |
+
Conv-Hyperprior The seminal hyperprior architecture (Balle et al., 2018; Minnen et al., 2018) is ´ a two-level hierarchical variational autoencoder, consisting of a pair of encoder/decoder $g _ { a } , g _ { s }$ , and a pair of hyper-encoder/hyper-decoder $h _ { a } , h _ { s }$ . Given an input image $\mathbf { x }$ , a pair of latent ${ \bf y } = g _ { a } ( { \bf x } )$ and hyper-latent ${ \bf z } = h _ { a } ( { \bf y } )$ is computed. The quantized hyper-latent ${ \hat { \mathbf { z } } } = Q ( \mathbf { z } )$ is modeled and entropycoded with a learned factorized prior. The latent $\mathbf { y }$ is modeled with a factorized Gaussian distribution $p ( \mathbf { y } | \hat { \mathbf { z } } ) = \mathcal { N } ( \mu , \mathrm { d i a g } ( { \pmb \sigma } ) )$ whose parameter is given by the hyper-decoder $( \pmb { \mu } , \pmb { \sigma } ) = h _ { s } ( \hat { \bf z } )$ . The quantized version of the latent $\hat { \mathbf { y } } = \bar { Q } ( \mathbf { y } - \pmb { \mu } ) + \bar { \pmb { \mu } }$ is then entropy coded and passed through decoder $g _ { s }$ to derive reconstructed image $\hat { \mathbf { x } } = g _ { s } ( \hat { \mathbf { y } } )$ . The tranforms $g _ { a } , g _ { s } , h _ { a } , h _ { s }$ are all parameterized as ConvNets (for details, see Appendix A.1).
|
| 29 |
+
|
| 30 |
+
Conv-ChARM (Minnen & Singh, 2020) extends the baseline hyperprior architecture with a channel-wise auto-regressive model $( { \mathrm { C h A R M } } ) ^ { 2 }$ , in which latent $\mathbf { y }$ is split along channel dimension into $S$ groups (denoted as $\mathbf { y } _ { 1 } , \ldots , \mathbf { y } _ { S } )$ , and the Gaussian prior $p ( \mathbf { y } _ { s } | \hat { \mathbf { z } } , \hat { \mathbf { y } } _ { < s } )$ is made autoregressive across groups where the mean/scale of ${ \bf y } _ { s }$ depends on quantized latent in the previous groups $\hat { \mathbf { y } } _ { < s }$ . In practice, $S = 1 0$ provides a good balance of performance and complexity and is adopted here.
|
| 31 |
+
|
| 32 |
+
Spatial AR models Most of recent performance advancements of neural image compression is driven by the use of spatial auto-regressive/context models. Variants include causal global prediction (Guo et al., 2021), 3D context (Ma et al., 2021), block-level context (Wu et al., 2020), nonlocal context (Li et al., 2020; Qian et al., 2021). One common issue with these designs is that decoding cannot be parallelized along spatial dimensions, leading to impractical3decoding latency, especially for large resolution images.
|
| 33 |
+
|
| 34 |
+
ConvNet-based transforms While the design space of prior models is extensively explored, nonlinear transforms, as an important component, have received less attention. A standard convolution encoder-decoder with GDN (Balle et al., 2016; 2017) as activation is widely adopted in the literature. ´ Later works introduce new transform designs, such as residual blocks with smaller kernels (Cheng et al., 2020), nonlocal (sigmoid gating) layers (Zhou et al., 2019; Chen et al., 2021), invertible neural networks (Xie et al., 2021), and PReLU as an efficient replacement of GDN (Egilmez et al., 2021).
|
| 35 |
+
|
| 36 |
+
Vision transformers Although many transform networks are proposed, they are still mainly based on ConvNets. Recently transformers (Vaswani et al., 2017) have been introduced to the vision domain and have shown performance competitive with ConvNets in many tasks, e.g. object detection (Carion et al., 2020), classification (Dosovitskiy et al., 2021), image enhancement (Chen et al., 2020), and semantic segmentation (Zheng et al., 2021). Inspired by their success, in this work we explore how vision transformers work as nonlinear transforms for image and video compression.
|
| 37 |
+
|
| 38 |
+
# 3 SWIN-TRANSFORMER BASED TRANSFORM CODING
|
| 39 |
+
|
| 40 |
+
Among the large number of vision transformer variants, we choose Swin Transformer (Liu et al., 2021) (hereafter referred to as SwinT) to build the nonlinear transforms, mainly because of 1) its linear complexity w.r.t. input resolution due to local window attention, and 2) its flexibility in handling varying input resolutions at test time, enabled by relative position bias and hierarchical architecture.
|
| 41 |
+
|
| 42 |
+

|
| 43 |
+
Figure 2: Network architecture of our proposed SwinT-ChARM model4. In the SwinT-Hyperprior model, the ChARM component is removed and instead $\pmb { \mu }$ and $\sigma$ are directly output by the hyperdecoder $h _ { s }$ (For details see Figure 13 in Appendix A.1).
|
| 44 |
+
|
| 45 |
+
# 3.1 SWINT ENCODER AND DECODER
|
| 46 |
+
|
| 47 |
+
The original SwinT is proposed as a vision backbone, i.e. an encoder transform with downsampling. As shown in Figure 2, the SwinT encoder $g _ { a }$ contains SwinT blocks interleaved with Patch Merge blocks. The Patch Merge block contains Space-to-Depth (for downsampling), LayerNorm, and Linear layers sequentially. SwinT block performs local self-attention within each non-overlapping window of the feature maps and preserves feature size. Consecutive SwinT blocks at the same feature size shift the window partitioning with respect to the previous block to promote information propagation across nearby windows in the previous block.
|
| 48 |
+
|
| 49 |
+
We adopt SwinT encoder as the encoder transform $g _ { a }$ in our model, and extend it to SwinT decoder $g _ { s }$ by reversing the order of blocks in $g _ { a }$ , and replacing the Patch Merge block with a Patch Split block, which contains Linear, LayerNorm, Depth-to-Space (for upsampling) layers in sequence. The architectures for hyper transforms $h _ { a } , h _ { s }$ are similar to $g _ { a } , g _ { s }$ with different configurations.
|
| 50 |
+
|
| 51 |
+
With these four SwinT transforms, we propose two image compression models, SwinT-Hyperprior and SwinT-ChARM, whose prior and hyper prior models are respectively the same as in ConvHyperprior and Conv-ChARM introduced in Section 2. The full model architectures are shown in Figure 2 and Figure 13.
|
| 52 |
+
|
| 53 |
+
# 3.2 EXTENSION TO P-FRAME COMPRESSION
|
| 54 |
+
|
| 55 |
+
To investigate the effectiveness of SwinT transforms for video compression, we study one popular P-frame compression model called Scale-Space Flow (SSF) (Agustsson et al., 2020). There are three instances of Conv-Hyperprior in SSF, which are respectively for compressing I-frames, scale-space flow and residual. We propose a SwinT variant, referred to as SwinT-SSF, which is obtained by replacing Conv transforms $g _ { a } , g _ { s }$ in the flow codec and residual codec of SSF with SwinT tranforms. To stabilize training of flow codec in SwinT-SSF, we need to remove all LayerNorm layers and reduce the window size (e.g. from 8 to 4). The baseline SSF model will be referred as Conv-SSF. Even though we build our solution on top of SSF, we believe this general extension can be applied to other ConvNet-based video compression models (Rippel et al., 2021; Hu et al., 2021) as well.
|
| 56 |
+
|
| 57 |
+
# 4 EXPERIMENTS AND ANALYSIS
|
| 58 |
+
|
| 59 |
+
# 4.1 EXPERIMENT SETUP
|
| 60 |
+
|
| 61 |
+
Training All image compression models are trained on the CLIC2020 training set. ConvHyperprior and SwinT-Hyperprior are trained with 2M batches. Conv-ChARM and SwinT-ChARM are trained with 3.5M and 3.1M steps. Each batch contains 8 random $2 5 6 \times 2 5 6$ crops from training images. Training loss $L = D + \beta R$ is a weighted combination of distortion $D$ and bitrate $R$ , with $\beta$ being the Lagrangian multiplier steering rate-distortion trade-off. Distortion $D$ is MSE in RGB color space. To cover a wide range of rate and distortion, for each solution, we train 5 models with $\beta \in \{ \bar { 0 . } 0 0 3 , 0 . 0 0 1 , 0 . 0 0 0 3 , 0 . 0 0 0 \bar { 1 } , 0 . 0 0 0 0 3 \}$ . The detailed training schedule is in Appendix B.1.
|
| 62 |
+
|
| 63 |
+
For P-frame compression models, we follow the training setup of SSF. Both Conv-SSF and SwinTSSF are trained on Vimeo-90k Dataset (Xue et al., 2019) for 1M steps with learning rate $1 0 ^ { - 4 }$ , batch size of 8, crop size of $2 5 6 \times 2 5 6$ , followed by 50K steps of training with learning rate $1 0 ^ { - 5 }$ and crop size $3 8 4 \times 2 5 6$ . The models are trained with 8 $\beta$ values $2 ^ { \gamma } \times 1 0 ^ { - \bar { 4 } } : \gamma \in \{ 0 , 1 , \bar { . . . , 7 } \}$ . We adopt one critical trick to stablize the training from (Jaegle et al., 2021; Meister et al., 2018), i.e. to forward each video sequence twice during one optimization step (mini-batch), once in the original frame order, once in the reversed frame order. Finally we add flow $\mathrm { l o s s } ^ { 5 }$ only between 0 and 200K steps, which we found not critical for stable training but improves the RD.
|
| 64 |
+
|
| 65 |
+
Evaluation We evaluate image compression models on 4 datasets: Kodak (Kodak, 1999), CLIC2021 testset (CLIC, 2021), Tecnick testset (Asuni & Giachetti, 2014), and JPEG-AI testset (JPEG-AI, 2020). We use BPG and VTM-12.1 to code the images in YUV444 mode, and then calculate PSNR in RGB. For a fair comparison all images are cropped to multiples of 256 to avoid padding for neural codecs.
|
| 66 |
+
|
| 67 |
+
We evaluated P-frame models on UVG (Mercat et al., 2020) 6 and MCL-JCV (Wang et al., 2016), and compare them with the test model implementation of HEVC, referred to as HEVC (HM), and open source library implementation of HEVC, refered to as HEVC $\left( \mathrm { x } 2 6 5 \right)$ . To align configuration, all video codecs are evaluated in low-delay-P model with a fixed GOP size of 12.
|
| 68 |
+
|
| 69 |
+
Besides rate-distortion curves, we also evaluate different models using BD-rate (Tan et al., 2016), which represents the average bitrate savings for the same reconstruction quality. For image codecs, BD-rate is computed for each image and then averaged across all images; for video codecs, BD-rate is computed for each video and then averaged across all videos. More details on testset preprocessing, and traditional codecs configurations can be found in Appendix B.2.
|
| 70 |
+
|
| 71 |
+

|
| 72 |
+
Figure 3: Comparison of compression efficiency on Kodak8. Note that the encoding time of VTM12.1 is much longer than all neural codecs, as shown in Table 4 and Table 7 in the Appendix.
|
| 73 |
+
|
| 74 |
+
# 4.2 RESULTS
|
| 75 |
+
|
| 76 |
+
RD and BD-rate for image codecs The RD curves for all compared image codecs evaluated on Kodak are shown in Figure 3a, and the relative rate reduction of each codec compared to VTM-12.1 at a range of PSNR levels is shown in Figure 3b 7.
|
| 77 |
+
|
| 78 |
+
As can be seen from Figure 3, SwinT transform consistently outperforms its convolutional counterpart; the RD-performance of SwinT-Hyperprior is on-par with Conv-ChARM, despite the simpler prior; SwinT-ChARM outperforms VTM-12.1 across a wide PSNR range. In the Appendix (Figure 28 and Figure 30), we further incorporate the results from existing literature known to us for a complete comparison. Particularly, our Conv-Hyperprior is much better than the results reported in (Minnen et al., 2018) (no context), and Conv-ChARM is on par with (Minnen & Singh, 2020).
|
| 79 |
+
|
| 80 |
+
Table 1: BD-rate of image codecs relative to VTM-12.1 (smaller is better).
|
| 81 |
+
|
| 82 |
+
<table><tr><td>Image Codec</td><td>Kodak</td><td>CLIC2021</td><td>Tecnick</td><td>JPEG-AI</td></tr><tr><td>BPG444</td><td>20.87%</td><td>28.45%</td><td>27.74%</td><td>27.14%</td></tr><tr><td>Conv-Hyperprior</td><td>11.65%</td><td>12.23%</td><td>12.49%</td><td>20.98%</td></tr><tr><td>Conv-ChARM</td><td>3.44%</td><td>4.14%</td><td>3.50%</td><td>9.59%</td></tr><tr><td>SwinT-Hyperprior</td><td>1.69%</td><td>0.83%</td><td>-0.15%</td><td>6.86%</td></tr><tr><td>SwinT-ChARM</td><td>-3.68%</td><td>-5.46%</td><td>-7.10%</td><td>0.69%</td></tr></table>
|
| 83 |
+
|
| 84 |
+
In Table 1, we summarize the BD-rate of image codecs across all four dataset with VTM-12.1 as anchor. On average SwinT-ChARM is able to achieve $3 . 8 \%$ rate reduction compared to VTM12.1. The relative gain from Conv-Hyperprior to SwinT-Hyperprior is on-average $12 \%$ and that from Conv-ChARM to SwinT-ChARM is on-average $9 \%$ . Further gain over VTM-12.1 can be obtained by test-time latent optimization (Campos et al., 2019) or full model instance adaptation (van Rozendaal et al., 2021), which are out of the scope of this work.
|
| 85 |
+
|
| 86 |
+

|
| 87 |
+
Figure 4: PSNR vs bitrate curves of P-frame codecs on UVG and MCL-JCV datasets.
|
| 88 |
+
|
| 89 |
+
RD and BD-rate for video codecs For P-frame compression, we evaluated SwinT-SSF on UVG and MCL-JCV, with RD comparison shown in Figure 4. Again, SwinT transform leads to consistently better RD. Table 2 summarizes BD-rate with our reproduced Conv-SSF model as anchor. We can see that SwinT-SSF achieves an average of $11 \%$ rate saving over Conv-SSF. Additionally, we show that if SwinT transform is only applied to residual-autoencoder (labeled as SwinT-SSF-Res), it can only get about $4 . 6 \%$ gain, which indicates
|
| 90 |
+
|
| 91 |
+
Table 2: BD-rate of video codecs, with ConvSSF (reproduced) as anchor.
|
| 92 |
+
|
| 93 |
+
<table><tr><td>Video Codec</td><td>UVG</td><td>MCL-JCV</td></tr><tr><td>HEVC (x265)</td><td>25.97%</td><td>25.83%</td></tr><tr><td>HEVC (HM)</td><td>-15.80%</td><td>-24.96%</td></tr><tr><td>SwinT-SSF</td><td>-12.35%</td><td>-10.03%</td></tr><tr><td>SwinT-SSF-Res</td><td>-5.08%</td><td>-4.16%</td></tr></table>
|
| 94 |
+
|
| 95 |
+
that both flow and residual compression benefit from SwinT as encoder and decoder transforms. Note that SwinT-SSF still lags behind HM, suggesting lots of room for improvement in neural video compression. For per-video breakdown of BD-rate, see Figure 18 and Figure 17 in the Appendix.
|
| 96 |
+
|
| 97 |
+
Table 3: Decoding complexity. All models are trained with $\beta = 0 . 0 0 1$ , evaluated on $7 6 8 \times 5 1 2$ images (average $0 . 7 \ \mathrm { b p p }$ ). Decoding time is broken down into inference time of hyper-decoder $h _ { s }$ and decoder $g _ { s }$ , entropy decoding time of hyper-code $\hat { \mathbf { z } }$ and code $\hat { \mathbf { y } }$ (including inference time of the prior model if it is ChARM).
|
| 98 |
+
|
| 99 |
+
<table><tr><td rowspan="2">Codec</td><td colspan="5">Time (ms)</td><td rowspan="2">GMACs</td><td rowspan="2">Peak memory</td><td rowspan="2">Model params</td></tr><tr><td>Z</td><td>hs</td><td>y</td><td>9s</td><td>total</td></tr><tr><td>Conv-Hyperprior</td><td>5.5</td><td>4.0</td><td>38.2</td><td>168.9</td><td>219.3</td><td>350</td><td>0.50GB</td><td>21.4M</td></tr><tr><td>Conv-ChARM</td><td>5.3</td><td>4.1</td><td>82.9</td><td>168.5</td><td>264.0</td><td>362</td><td>0.53GB</td><td>29.3M</td></tr><tr><td>SwinT-Hyperprior</td><td>6.0</td><td>4.8</td><td>38.1</td><td>59.6</td><td>114.0</td><td>99</td><td>1.44GB</td><td>24.7M</td></tr><tr><td>SwinT-ChARM</td><td>5.9</td><td>4.8</td><td>90.7</td><td>60.1</td><td>167.3</td><td>111</td><td>1.47GB</td><td>32.6M</td></tr></table>
|
| 100 |
+
|
| 101 |
+
Decoding complexity We evaluate the decoding complexity of 4 image codecs on 100 images of size $7 6 8 \times 5 1 2$ and show the metrics in Table 3, including decoding time, GMACs and GPU peak memory during decoding and total model parameters. The models run with PyTorch 1.9.0 on a workstation with one RTX 2080 Ti GPU. From the table, the inference time of SwinT decoder is less than that of Conv decoder. The entropy decoding time of ChARM prior is about twice than the factorized prior. The total decoding time of SwinT-based models is less than Conv-based models. In ablation study A5, we show a smaller SwinT-Hyperprior with 20.6M parameters has almost the same RD as the SwinT-Hyperprior profiled here. For details on encoding complexity, profiling setup, scaling to image resolution, please refer to Table 4 and Section D.3 in the Appendix.
|
| 102 |
+
|
| 103 |
+
Scaling behavior To see how the BD-rate varies with model size, we scale SwinTHyperprior and Conv-Hyperprior to be twice or half of the size of the base models (i.e. medium size)9. The result is shown in Figure 5. For both types of models, as we reduce the base model size, there is a sharp drop in performance, while doubling model size only leads to marginal gain. Noticeably, SwinT-Hyperpriorsmall is on-par with Conv-Hyperprior-medium even with half of the parameters, and SwinT transforms in general incur fewer MACs per parameter.
|
| 104 |
+
|
| 105 |
+
In Figure 1, we further consolidate the decoding latency and scaling behavior study into a single plot and show that SwinT-ChARM runs at comparable speed as VTM-12.1 while achiev
|
| 106 |
+
|
| 107 |
+

|
| 108 |
+
Figure 5: Model size scaling.
|
| 109 |
+
|
| 110 |
+
ing better performance,10 as opposed to state-of-the-art neural codecs with spatial autoregressive prior that decodes orders of magnitude slower.
|
| 111 |
+
|
| 112 |
+
# 4.3 ANALYSIS
|
| 113 |
+
|
| 114 |
+
Latent correlation One of the motivating principles of transform coding is that simple coding can be made more effective in the transform domain than in the original signal space (Goyal, 2001; Balle et al., 2021). A desirable transform would decorrelate the source signal so that simple scalar ´ quantization and factorized entropy model can be applied without constraining coding performance. In most mature neural compression solutions, uniform scalar quantization is adopted together with a learned factorized or conditionally factorized Gaussian prior distribution. It is critical, then, to effectively factorize and Gaussianize the source distribution so that coding overhead can be minimized.
|
| 115 |
+
|
| 116 |
+

|
| 117 |
+
Figure 6: Spatial correlation11of $( \mathbf { y } - \pmb { \mu } ) / \pmb { \sigma }$ with models trained at $\beta = 0 . 0 0 1$ . SwinT-Hyperprior (right) achieves uniformly smaller correlation than Conv-Hyperprior (left).
|
| 118 |
+
|
| 119 |
+
Specifically, in hyperprior based models (Balle et al., 2018),´ ${ \bar { \mathbf { y } } } \triangleq ( \mathbf { y } - { \pmb { \mu } } ) / \sigma$ is modeled as a standard spherical normal vector. The effectiveness of the analysis transform $g _ { a }$ can then be evaluated by measuring how much correlation there is among different elements in $\bar { \mathbf { y } }$ . We are particularly interested in measuring the correlation between nearby spatial positions, which are heavily correlated in the source domain for natural images. In Figure 6, we visualize the normalized spatial correlation of $\bar { \mathbf { y } }$ averaged over all latent channels, and compare Conv-Hyperprior with SwinT-Hyperprior at $\beta = 0 . 0 0 1$ . It can be observed that while both lead to small cross-correlations, Swin-Transformer does a much better job with uniformly smaller correlation values, and the observation is consistent with other $\beta$ values, which are provided in Figure 20 in the Appendix. This suggests that transformer based transforms incur less redundancy across different spatial latent locations compared with convolutional ones, leading to an overall better rate-distortion trade-off. The larger spatial correlation (and thus redundancy) in Conv-Hyperprior also explains why a compute-heavy spatial auto-regressive model is often needed to improve RD with convolutional based transforms (Minnen et al., 2018; Lee et al., 2019; Ma et al., 2021; Guo et al., 2021; Wu et al., 2020). Figure 6 also reveals that most of the correlation of a latent comes from the four elements surrounding it. This suggests that a checkerboard-based conditional prior model (He et al., 2021) may yield further coding gain.
|
| 120 |
+
|
| 121 |
+

|
| 122 |
+
Figure 7: Comparison of effective receptive field (ERF) of the encoders $g _ { a }$ , which is visualized as absolution gradients of the center pixel in the latent (i.e. $d \mathbf { y } / d \mathbf { x } )$ with respect to the input image. The plot shows the close up of the gradient maps averaged over all channels in each input of test images/videos. Check Figure 21 for the ERF of the composed encoding transform $h _ { a } \circ g _ { a }$ .
|
| 123 |
+
|
| 124 |
+
Effective receptive field Intra prediction in HEVC or AV1 only rely on left and top boarders of the current coding block (Sullivan et al., 2012; Chen et al., 2018), except for intra block copy for screen content $\mathrm { { X u } }$ et al., 2016). We would like to see how large the effective receptive field (ERF) (Luo et al., 2017) of SwinT encoders compared to Conv encoders. The theoretical receptive field of the encoders $( g _ { a } , h _ { a } \circ g _ { a } )$ in SwinT-based codecs is much larger than that of Conv-based codecs. However comparing Figure $\mathrm { 7 a }$ with 7e and Figure 7b with 7f, the ERF of SwinT encoders after training is even smaller than Conv encoders. When we examine the ERF of the released Swin transformers for classification, detection and segmentation tasks, they are all spanning the whole input image. This contrast suggests that (natural) image compression with rate-distortion objective is a local task, even with transformer-based nonlinear transforms. We further look into P-frame compression models, particularly the ERF of two types of transforms in flow codec and residual codec, as shown in Figure 7d & 7h, and Figure 7c & $7 \mathrm { g }$ . Clearly for flow codec, SwinT transform has much larger ERF than the convolution counterpart. For residual codec, the ERF of SwinT transforms is similar to image (I-frame) compression case. This shows of flexibility of SwinT encoders to attend to longer or shorter range depending on the tasks. To get a better picture of the behavior of attention layers in SwinT transforms, we also show the attention distance in each layer in Figure 22.
|
| 125 |
+
|
| 126 |
+
Progressive decoding The ERF in the previous section shows the behavior of the encoder transforms, here we further investigate the decoder transforms through the lens of progressive decoding (Rippel et al., 2014; Minnen & Singh, 2020; Lu et al., 2021). Initialized with the prior mean, the input to the decoder is progressively updated with the dequantized latent $\hat { \mathbf { y } }$ in terms of coding units, leading to gradually improved reconstruction quality. For the latent with shape $( C , H , W )$ , we consider three types of coding units, i.e. per channel $( 1 , H , W )$ , per pixel $( C , 1 , 1 )$ , per element $( 1 , 1 , 1 )$ . The coding units are ordered by the sum of prior std of all elements within each unit. The RD curves of progressive decoding for SwinT-Hyperprior and Conv-Hyperprior are shown in Figure 8a, which closely follow each other when ordered by channel or element, but significantly apart when ordered by pixel (spatial dim). Particularly, we show an extreme case when the half pixels in the latent (masked by checkerboard pattern) are updated with dequantized values, corresponding to the two scatter points in Figure 8a. One visual example (CLIC2021 test) is shown in Figure 8b under this setup, where we can clearly see SwinT decoder achieves better reconstruction quality than the Conv decoder, mainly in terms of more localized response to a single latent pixel. This is potentially useful for region-of-interest decompression. More visual examples are shown in Figure 26.
|
| 127 |
+
|
| 128 |
+

|
| 129 |
+
Figure 8: (Left) Progressive decoding according to the order of the sum of prior std of all elements within each latent coding unit, which can be one latent channel, pixel or element. SwinT-Hyperprior archives about 2dB better reconstruction at the same bitrate than Conv-Hyperprior for per-pixel progressive decoding. (Right) The reconstructions with SwinT-Hyperprior (top) and Conv-Hyperprior (bottom) for the latent masked with checkerboard pattern corresponding to the two plus markers on the left subfigure. The SwinT decoder has more localized reconstruction to a single latent pixel.
|
| 130 |
+
|
| 131 |
+
# 4.4 ABLATION STUDY
|
| 132 |
+
|
| 133 |
+
Relative position bias There are two sources of positional information in SwinT transforms, namely the Space-to-Depth modules and the additive relative position bias (RPB). Even when the RPB is removed, SwinT-Hyperprior still outperforms Conv-Hyperprior across all bitrates, which indicates image compression may not require accurate relative position.
|
| 134 |
+
|
| 135 |
+
Shifted window The original motivation of shifted window design is to promotes the inter-layer feature propagation across nonoverlapping windows. Image compression performance drops slightly when there is no shifted window at all. This further suggests image compression requires local information.
|
| 136 |
+
|
| 137 |
+
The details of ablations A3-A5 in Figure 9 can be found in Section F of the appendix.
|
| 138 |
+
|
| 139 |
+

|
| 140 |
+
Figure 9: Ablation study
|
| 141 |
+
|
| 142 |
+
# 5 CONCLUSION
|
| 143 |
+
|
| 144 |
+
In this work we propose Swin transformer based transforms for image and video compression. In the image compression setting, SwinT transform consistently outperforms its convolutional counterpart. Particularly, the proposed SwinT-ChARM model outperforms VTM-12.1 at comparable decoding speed, which, to the best of our knowledge, is the first in learning-based methods. We also show the effectiveness of SwinT transforms when extended to the P-frame compression setting. Compared with convolution transforms, SwinT transforms can spatially decorrelate the latent better, have more flexible receptive field to adapt to tasks that requires either short-range (image) and long-range (motion) information, and better progressive decoding of latent pixels. While pushing the neural image compression to a new level in terms of rate-distortion-computation trade-off, we believe it is only the starting point for developing more efficient transformer-based image and video codecs.
|
| 145 |
+
|
| 146 |
+
# ACKNOWLEDGMENTS
|
| 147 |
+
|
| 148 |
+
We would like to thank Amir Said for developing entropy coding and great advice on data compression in general. We would also appreciate the helpful discussions from Reza Pourreza and Hoang Le, and draft reviews from Auke Wiggers and Johann Brehmer.
|
| 149 |
+
|
| 150 |
+
# REFERENCES
|
| 151 |
+
|
| 152 |
+
Eirikur Agustsson, David Minnen, Nick Johnston, Johannes Balle, Sung Jin Hwang, and George Toderici. Scale-space flow for end-to-end optimized video compression. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 8503–8512, 2020.
|
| 153 |
+
|
| 154 |
+
Nicola Asuni and Andrea Giachetti. Testimages: a large-scale archive for testing visual devices and basic image processing algorithms. In STAG, pp. 63–70, 2014.
|
| 155 |
+
|
| 156 |
+
Johannes Balle, Valero Laparra, and Eero P. Simoncelli. Density modeling of images using a gener- ´ alized normalization transformation. In Yoshua Bengio and Yann LeCun (eds.), 4th International Conference on Learning Representations, ICLR 2016, San Juan, Puerto Rico, May 2-4, 2016, Conference Track Proceedings, 2016. URL http://arxiv.org/abs/1511.06281.
|
| 157 |
+
|
| 158 |
+
Johannes Balle, Valero Laparra, and Eero P. Simoncelli. End-to-end optimized image compres- ´ sion. In 5th International Conference on Learning Representations, ICLR 2017, Toulon, France, April 24-26, 2017, Conference Track Proceedings. OpenReview.net, 2017. URL https: //openreview.net/forum?id $=$ rJxdQ3jeg.
|
| 159 |
+
|
| 160 |
+
Johannes Balle, David Minnen, Saurabh Singh, Sung Jin Hwang, and Nick Johnston. Variational Im- ´ age Compression with a Scale Hyperprior. In 6th International Conference on Learning Representations, ICLR 2018, Vancouver, BC, Canada, April 30 - May 3, 2018, Conference Track Proceedings. OpenReview.net, 2018. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ rkcQFMZRb.
|
| 161 |
+
|
| 162 |
+
Johannes Balle, Philip A. Chou, David Minnen, Saurabh Singh, Nick Johnston, Eirikur Agusts- ´ son, Sung Jin Hwang, and George Toderici. Nonlinear transform coding. IEEE J. Sel. Top. Signal Process., 15(2):339–353, 2021. doi: 10.1109/JSTSP.2020.3034501. URL https: //doi.org/10.1109/JSTSP.2020.3034501.
|
| 163 |
+
|
| 164 |
+
Joaquim Campos, Simon Meierhans, Abdelaziz Djelouah, and Christopher Schroers. Content Adaptive Optimization for Neural Image Compression. In IEEE Conference on Computer Vision and Pattern Recognition Workshops, CVPR Workshops 2019, Long Beach, CA, USA, June 16-20, 2019, pp. 0. Computer Vision Foundation / IEEE, 2019. URL http://openaccess.thecvf.com/content_CVPRW_2019/html/CLIC_ 2019/Campos_Content_Adaptive_Optimization_for_Neural_Image_ Compression_CVPRW_2019_paper.html.
|
| 165 |
+
|
| 166 |
+
Nicolas Carion, Francisco Massa, Gabriel Synnaeve, Nicolas Usunier, Alexander Kirillov, and Sergey Zagoruyko. End-to-end object detection with transformers. In Andrea Vedaldi, Horst Bischof, Thomas Brox, and Jan-Michael Frahm (eds.), Computer Vision - ECCV 2020 - 16th European Conference, Glasgow, UK, August 23-28, 2020, Proceedings, Part I, volume 12346 of Lecture Notes in Computer Science, pp. 213–229. Springer, 2020. doi: 10.1007/978-3-030-58452-8\ 13. URL https://doi.org/10.1007/978-3-030-58452-8_13.
|
| 167 |
+
|
| 168 |
+
Hanting Chen, Yunhe Wang, Tianyu Guo, Chang Xu, Yiping Deng, Zhenhua Liu, Siwei Ma, Chunjing Xu, Chao Xu, and Wen Gao. Pre-trained image processing transformer. CoRR, abs/2012.00364, 2020. URL https://arxiv.org/abs/2012.00364.
|
| 169 |
+
|
| 170 |
+
Tong Chen, Haojie Liu, Zhan Ma, Qiu Shen, Xun Cao, and Yao Wang. End-to-end learnt image compression via non-local attention optimization and improved context modeling. IEEE Trans. Image Process., 30:3179–3191, 2021. doi: 10.1109/TIP.2021.3058615. URL https://doi. org/10.1109/TIP.2021.3058615.
|
| 171 |
+
|
| 172 |
+
Yue Chen, Debargha Murherjee, Jingning Han, Adrian Grange, Yaowu Xu, Zoe Liu, Sarah Parker, Cheng Chen, Hui Su, Urvang Joshi, Ching-Han Chiang, Yunqing Wang, Paul Wilkins, Jim Bankoski, Luc Trudeau, Nathan Egge, Jean-Marc Valin, Thomas Davies, Steinar Midtskogen, Andrey Norkin, and Peter de Rivaz. An overview of core coding tools in the av1 video codec. In 2018 Picture Coding Symposium (PCS), pp. 41–45, 2018. doi: 10.1109/PCS.2018.8456249.
|
| 173 |
+
|
| 174 |
+
Zhengxue Cheng, Heming Sun, Masaru Takeuchi, and Jiro Katto. Learned image compression with discretized gaussian mixture likelihoods and attention modules. In 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition, CVPR 2020, Seattle, WA, USA, June 13-19, 2020, pp. 7936–7945. IEEE, 2020. doi: 10.1109/CVPR42600.2020.00796. URL https://doi. org/10.1109/CVPR42600.2020.00796.
|
| 175 |
+
|
| 176 |
+
CLIC. Clic2021 challenge on learned image compression, 2021. URL http://compression. cc/tasks/.
|
| 177 |
+
|
| 178 |
+
Yihe Dong, Jean-Baptiste Cordonnier, and Andreas Loukas. Attention is not all you need: pure attention loses rank doubly exponentially with depth. In Marina Meila and Tong Zhang (eds.), Proceedings of the 38th International Conference on Machine Learning, ICML 2021, 18-24 July 2021, Virtual Event, volume 139 of Proceedings of Machine Learning Research, pp. 2793–2803. PMLR, 2021. URL http://proceedings.mlr.press/v139/dong21a.html.
|
| 179 |
+
|
| 180 |
+
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 9th International Conference on Learning Representations, ICLR 2021, Virtual Event, Austria, May 3-7, 2021. OpenReview.net, 2021. URL https://openreview.net/forum? id ${ . } = { }$ YicbFdNTTy.
|
| 181 |
+
|
| 182 |
+
Hilmi E. Egilmez, Ankitesh K. Singh, Muhammed Z. Coban, Marta Karczewicz, Yinhao Zhu, Yang Yang, Amir Said, and Taco S. Cohen. Transform network architectures for deep learning based end-to-end image/video coding in subsampled color spaces. CoRR, abs/2103.01760, 2021. URL https://arxiv.org/abs/2103.01760.
|
| 183 |
+
|
| 184 |
+
Alaaeldin El-Nouby, Hugo Touvron, Mathilde Caron, Piotr Bojanowski, Matthijs Douze, Armand Joulin, Ivan Laptev, Natalia Neverova, Gabriel Synnaeve, Jakob Verbeek, and Herve J ´ egou. Xcit: ´ Cross-covariance image transformers. CoRR, abs/2106.09681, 2021. URL https://arxiv. org/abs/2106.09681.
|
| 185 |
+
|
| 186 |
+
V.K. Goyal. Theoretical foundations of transform coding. IEEE Signal Processing Magazine, 18 (5):9–21, 2001. doi: 10.1109/79.952802.
|
| 187 |
+
|
| 188 |
+
Zongyu Guo, Zhizheng Zhang, Runsen Feng, and Zhibo Chen. Causal contextual prediction for learned image compression. IEEE Transactions on Circuits and Systems for Video Technology, pp. 1–1, 2021. doi: 10.1109/TCSVT.2021.3089491.
|
| 189 |
+
|
| 190 |
+
Qi Han, Zejia Fan, Qi Dai, Lei Sun, Ming-Ming Cheng, Jiaying Liu, and Jingdong Wang. Demystifying local vision transformer: Sparse connectivity, weight sharing, and dynamic weight. CoRR, abs/2106.04263, 2021. URL https://arxiv.org/abs/2106.04263.
|
| 191 |
+
|
| 192 |
+
Dailan He, Yaoyan Zheng, Baocheng Sun, Yan Wang, and Hongwei Qin. Checkerboard context model for efficient learned image compression. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 14771–14780, 2021.
|
| 193 |
+
|
| 194 |
+
Zhihao Hu, Guo Lu, and Dong Xu. FVC: A New Framework towards Deep Video Compression in Feature Space. arXiv preprint arXiv:2105.09600, 2021.
|
| 195 |
+
|
| 196 |
+
Andrew Jaegle, Sebastian Borgeaud, Jean-Baptiste Alayrac, Carl Doersch, Catalin Ionescu, David Ding, Skanda Koppula, Daniel Zoran, Andrew Brock, Evan Shelhamer, Olivier J. Henaff,´ Matthew M. Botvinick, Andrew Zisserman, Oriol Vinyals, and Joao Carreira. Perceiver IO: ˜ A General Architecture for Structured Inputs & Outputs. CoRR, abs/2107.14795, 2021. URL https://arxiv.org/abs/2107.14795.
|
| 197 |
+
|
| 198 |
+
JPEG-AI. JPEG-AI Test Images. https://jpegai.github.io/test_images/, 2020.
|
| 199 |
+
|
| 200 |
+
Ilyes Khemakhem, Diederik Kingma, Ricardo Monti, and Aapo Hyvarinen. Variational autoencoders and nonlinear ica: A unifying framework. In International Conference on Artificial Intelligence and Statistics, pp. 2207–2217. PMLR, 2020.
|
| 201 |
+
|
| 202 |
+
Kodak. Kodak Test Images. http://r0k.us/graphics/kodak/, 1999.
|
| 203 |
+
|
| 204 |
+
Simon Kornblith, Mohammad Norouzi, Honglak Lee, and Geoffrey Hinton. Similarity of neural network representations revisited. In International Conference on Machine Learning, pp. 3519– 3529. PMLR, 2019.
|
| 205 |
+
|
| 206 |
+
Jooyoung Lee, Seunghyun Cho, and Seung-Kwon Beack. Context-adaptive entropy model for endto-end optimized image compression. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id $=$ HyxKIiAqYQ.
|
| 207 |
+
|
| 208 |
+
Mu Li, Kai Zhang, Wangmeng Zuo, Radu Timofte, and David Zhang. Learning context-based nonlocal entropy modeling for image compression. CoRR, abs/2005.04661, 2020. URL https: //arxiv.org/abs/2005.04661.
|
| 209 |
+
|
| 210 |
+
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. CoRR, abs/2103.14030, 2021. URL https://arxiv.org/abs/2103.14030.
|
| 211 |
+
|
| 212 |
+
Yadong Lu, Yinhao Zhu, Yang Yang, Amir Said, and Taco S Cohen. Progressive neural image compression with nested quantization and latent ordering. In 2021 IEEE International Conference on Image Processing (ICIP), pp. 539–543, 2021. doi: 10.1109/ICIP42928.2021.9506026.
|
| 213 |
+
|
| 214 |
+
Wenjie Luo, Yujia Li, Raquel Urtasun, and Richard S. Zemel. Understanding the Effective Receptive Field in Deep Convolutional Neural Networks. CoRR, abs/1701.04128, 2017. URL http: //arxiv.org/abs/1701.04128.
|
| 215 |
+
|
| 216 |
+
Changyue Ma, Zhao Wang, Ru-Ling Liao, and Yan Ye. A cross channel context model for latents in deep image compression. CoRR, abs/2103.02884, 2021. URL https://arxiv.org/abs/ 2103.02884.
|
| 217 |
+
|
| 218 |
+
Simon Meister, Junhwa Hur, and Stefan Roth. Unflow: Unsupervised learning of optical flow with a bidirectional census loss. In Sheila A. McIlraith and Kilian Q. Weinberger (eds.), Proceedings of the Thirty-Second AAAI Conference on Artificial Intelligence, (AAAI-18), the 30th innovative Applications of Artificial Intelligence (IAAI-18), and the 8th AAAI Symposium on Educational Advances in Artificial Intelligence (EAAI-18), New Orleans, Louisiana, USA, February 2-7, 2018, pp. 7251–7259. AAAI Press, 2018. URL https://www.aaai.org/ocs/index.php/ AAAI/AAAI18/paper/view/16502.
|
| 219 |
+
|
| 220 |
+
Alexandre Mercat, Marko Viitanen, and Jarno Vanne. Uvg dataset: 50/120fps 4k sequences for video codec analysis and development. In Proceedings of the 11th ACM Multimedia Systems Conference, MMSys ’20, pp. 297–302, New York, NY, USA, 2020. Association for Computing Machinery. ISBN 9781450368452. doi: 10.1145/3339825.3394937. URL https://doi. org/10.1145/3339825.3394937.
|
| 221 |
+
|
| 222 |
+
David Minnen and Saurabh Singh. Channel-Wise Autoregressive Entropy Models for Learned Image Compression. In IEEE International Conference on Image Processing, ICIP 2020, Abu Dhabi, United Arab Emirates, October 25-28, 2020, pp. 3339–3343. IEEE, 2020. doi: 10. 1109/ICIP40778.2020.9190935. URL https://doi.org/10.1109/ICIP40778.2020. 9190935.
|
| 223 |
+
|
| 224 |
+
David Minnen, Johannes Balle, and George Toderici. Joint autoregressive and hierarchi- ´ cal priors for learned image compression. In Samy Bengio, Hanna M. Wallach, Hugo Larochelle, Kristen Grauman, Nicolo Cesa-Bianchi, and Roman Garnett (eds.), \` Advances in Neural Information Processing Systems 31: Annual Conference on Neural Information Processing Systems 2018, NeurIPS 2018, December 3-8, 2018, Montreal, Canada ´ , pp. 10794–10803, 2018. URL https://proceedings.neurips.cc/paper/2018/ hash/53edebc543333dfbf7c5933af792c9c4-Abstract.html.
|
| 225 |
+
|
| 226 |
+
Yichen Qian, Zhiyu Tan, Xiuyu Sun, Ming Lin, Dongyang Li, Zhenhong Sun, Hao Li, and Rong Jin. Learning accurate entropy model with global reference for image compression. In 9th International Conference on Learning Representations, ICLR 2021, Virtual Event, Austria, May 3-7, 2021. OpenReview.net, 2021. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ cTbIjyrUVwJ.
|
| 227 |
+
|
| 228 |
+
Maithra Raghu, Ben Poole, Jon Kleinberg, Surya Ganguli, and Jascha Sohl-Dickstein. On the expressive power of deep neural networks. In international conference on machine learning, pp. 2847–2854. PMLR, 2017.
|
| 229 |
+
|
| 230 |
+
Oren Rippel, Michael A. Gelbart, and Ryan P. Adams. Learning ordered representations with nested dropout. In Proceedings of the 31th International Conference on Machine Learning, ICML 2014, Beijing, China, 21-26 June 2014, volume 32 of JMLR Workshop and Conference Proceedings, pp. 1746–1754. JMLR.org, 2014. URL http://proceedings.mlr.press/v32/ rippel14.html.
|
| 231 |
+
|
| 232 |
+
Oren Rippel, Alexander G. Anderson, Kedar Tatwawadi, Sanjay Nair, Craig Lytle, and Lubomir D. Bourdev. ELF-VC: efficient learned flexible-rate video coding. CoRR, abs/2104.14335, 2021. URL https://arxiv.org/abs/2104.14335.
|
| 233 |
+
|
| 234 |
+
Gary J Sullivan, Jens-Rainer Ohm, Woo-Jin Han, and Thomas Wiegand. Overview of the high efficiency video coding (hevc) standard. IEEE Transactions on circuits and systems for video technology, 22(12):1649–1668, 2012.
|
| 235 |
+
|
| 236 |
+
Thiow Keng Tan, Rajitha Weerakkody, Marta Mrak, Naeem Ramzan, Vittorio Baroncini, JensRainer Ohm, and Gary J. Sullivan. Video quality evaluation methodology and verification testing of hevc compression performance. IEEE Transactions on Circuits and Systems for Video Technology, 26(1):76–90, 2016. doi: 10.1109/TCSVT.2015.2477916.
|
| 237 |
+
|
| 238 |
+
Ties van Rozendaal, Iris A. M. Huijben, and Taco Cohen. Overfitting for Fun and Profit: InstanceAdaptive Data Compression. In 9th International Conference on Learning Representations, ICLR 2021, Virtual Event, Austria, May 3-7, 2021. OpenReview.net, 2021. URL https: //openreview.net/forum?id $=$ oFp8Mx_V5FL.
|
| 239 |
+
|
| 240 |
+
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Isabelle Guyon, Ulrike von Luxburg, Samy Bengio, Hanna M. Wallach, Rob Fergus, S. V. N. Vishwanathan, and Roman Garnett (eds.), Advances in Neural Information Processing Systems 30: Annual Conference on Neural Information Processing Systems 2017, December 4-9, 2017, Long Beach, CA, USA, pp. 5998–6008, 2017. URL https://proceedings.neurips.cc/paper/2017/hash/ 3f5ee243547dee91fbd053c1c4a845aa-Abstract.html.
|
| 241 |
+
|
| 242 |
+
Haiqiang Wang, Weihao Gan, Sudeng Hu, Joe Yuchieh Lin, Lina Jin, Longguang Song, Ping Wang, Ioannis Katsavounidis, Anne Aaron, and C-C Jay Kuo. MCL-JCV: a JND-based H. 264/AVC video quality assessment dataset. In 2016 IEEE International Conference on Image Processing (ICIP), pp. 1509–1513. IEEE, 2016.
|
| 243 |
+
|
| 244 |
+
Yaojun Wu, Xin Li, Zhizheng Zhang, Xin Jin, and Zhibo Chen. Learned block-based hybrid image compression. arXiv preprint arXiv:2012.09550, 2020.
|
| 245 |
+
|
| 246 |
+
Yueqi Xie, Ka Leong Cheng, and Qifeng Chen. Enhanced invertible encoding for learned image compression. August 2021.
|
| 247 |
+
|
| 248 |
+
Xiaozhong Xu, Shan Liu, Tzu-Der Chuang, Yu-Wen Huang, Shaw-Min Lei, Krishnakanth Rapaka, Chao Pang, Vadim Seregin, Ye-Kui Wang, and Marta Karczewicz. Intra block copy in hevc screen content coding extensions. IEEE Journal on Emerging and Selected Topics in Circuits and Systems, 6(4):409–419, 2016. doi: 10.1109/JETCAS.2016.2597645.
|
| 249 |
+
|
| 250 |
+
Tianfan Xue, Baian Chen, Jiajun Wu, Donglai Wei, and William T Freeman. Video Enhancement with Task-Oriented Flow. International Journal of Computer Vision (IJCV), 127(8):1106–1125, 2019.
|
| 251 |
+
|
| 252 |
+
Sixiao Zheng, Jiachen Lu, Hengshuang Zhao, Xiatian Zhu, Zekun Luo, Yabiao Wang, Yanwei Fu, Jianfeng Feng, Tao Xiang, Philip H. S. Torr, and Li Zhang. Rethinking semantic segmentation from a sequence-to-sequence perspective with transformers. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2021, virtual, June 19-25, 2021, pp. 6881–6890. Computer Vision Foundation / IEEE, 2021. URL https://openaccess.thecvf.com/content/CVPR2021/html/Zheng_ Rethinking_Semantic_Segmentation_From_a_Sequence-to-Sequence_ Perspective_With_Transformers_CVPR_2021_paper.html.
|
| 253 |
+
|
| 254 |
+
Lei Zhou, Zhenhong Sun, Xiangji Wu, and Junmin Wu. End-to-end optimized image compression with attention mechanism. In CVPR workshops, pp. 0, 2019.
|
| 255 |
+
|
| 256 |
+
# Appendix
|
| 257 |
+
|
| 258 |
+
# Table of Contents
|
| 259 |
+
|
| 260 |
+
# A Models 15
|
| 261 |
+
|
| 262 |
+
A.1 Convolution baselines . 15
|
| 263 |
+
A.2 Swin-Transformer based compression models . 15
|
| 264 |
+
A.3 Model configurations for model size scaling study 16
|
| 265 |
+
|
| 266 |
+
# B Training and Evaluation
|
| 267 |
+
|
| 268 |
+
# 17
|
| 269 |
+
|
| 270 |
+
B.1 Training 17
|
| 271 |
+
B.2 Traditional codec evaluation 19
|
| 272 |
+
|
| 273 |
+
# C BD rate computation 19
|
| 274 |
+
|
| 275 |
+
C.1 BD rate for image codec . 20
|
| 276 |
+
C.2 BD rate for video codec 20
|
| 277 |
+
|
| 278 |
+
# D More Results 21
|
| 279 |
+
|
| 280 |
+
D.1 Image compression 21
|
| 281 |
+
D.2 Video Compression 22
|
| 282 |
+
D.3 Coding complexity 22
|
| 283 |
+
|
| 284 |
+
# E Analysis 24
|
| 285 |
+
|
| 286 |
+
E.1 Spatial correlation of latent 24
|
| 287 |
+
E.2 Effective Receptive Field 25
|
| 288 |
+
E.3 Rate distribution across latent channels 25
|
| 289 |
+
E.4 Centered kernel alignment . 25
|
| 290 |
+
E.5 Progressive decoding 25
|
| 291 |
+
|
| 292 |
+
# F More ablation studies 26
|
| 293 |
+
|
| 294 |
+
# A MODELS
|
| 295 |
+
|
| 296 |
+
# A.1 CONVOLUTION BASELINES
|
| 297 |
+
|
| 298 |
+
Conv-Hyperprior and Conv-ChARM The architecture of Conv-Hyperprior and ConvChARM are shown in Figure 10 and Figure 11. For both architecture, our base model (i.e. medium size) has the following hyperparameters: $\begin{array} { r l } { ( C _ { 1 } , C _ { 2 } , C _ { 3 } , C _ { 4 } , C _ { 5 } , C _ { 6 } , C _ { 7 } ) } & { { } = } \end{array}$ (320, 320, 320, 320, 192, 192, 192).
|
| 299 |
+
|
| 300 |
+
# A.2 SWIN-TRANSFORMER BASED COMPRESSION MODELS
|
| 301 |
+
|
| 302 |
+
SwinT-Hyperprior, SwinT-ChARM For both SwinT-Hyperprior and SwinT-ChARM, we use the same configurations: $( w _ { g } , w _ { h } ) = ( 8 , 4 )$ , $( C _ { 1 } , C _ { 2 } , C _ { 3 } , C _ { 4 } , \bar { C _ { 5 } } , \bar { C _ { 6 } } ) = ( 1 2 8 , 1 9 2 , 2 5 6 , 3 2 0 , 1 9 2 , 1 9 2 ) _ { \mathrm { { t } } }$ , $( d _ { 1 } , d _ { 2 } , d _ { 3 } , d _ { 4 } , d _ { 5 } , d _ { 6 } ) \stackrel { } { = } ( 2 , 2 , 6 , 2 , 5 , 1 )$ where $C , d .$ , and $w$ are defined in Figure 13 and Figure 2. The head dim is 32 for all attention layers in SwinT-based models.
|
| 303 |
+
|
| 304 |
+
SwinT-SSF For SwinT transforms used in SSF variant, the first Patch Merge block is with downsample rate of 4 and two other Patch Merge blocks with downsampling rate of 2. Thus the downsampling rate for the encoder is still 16, the same as the image compression models. There are only 3 transformer stages with depths 2, 4, 2. The embedding dim is 96. The number of latent and hyper latent channels are all 192. The window size is 4 for flow codec and 8 for residual codec.
|
| 305 |
+
|
| 306 |
+

|
| 307 |
+
Figure 10: Conv-Hyperprior
|
| 308 |
+
|
| 309 |
+

|
| 310 |
+
Figure 11: Conv-ChARM
|
| 311 |
+
|
| 312 |
+
SwinT-SSF-Res This is a variant where only residual autoencoder uses SwinT transforms. Same architecture as the residual autoencoder in SwinT-SSF.
|
| 313 |
+
|
| 314 |
+
A.3 MODEL CONFIGURATIONS FOR MODEL SIZE SCALING STUDY
|
| 315 |
+
|
| 316 |
+
# A.3.1 SWINT-HYPERPRIOR
|
| 317 |
+
|
| 318 |
+
Set of model hyperparameters that are common to all experiments: $( d _ { 1 } , d _ { 2 } , d _ { 3 } , d _ { 4 } , d _ { 5 } , d _ { 6 } ) \ =$ $( 2 , 2 , 6 , 2 , 5 , 1 )$ $( w _ { g } , w _ { h } ) = ( 8 , 4 )$
|
| 319 |
+
|
| 320 |
+
$$
|
| 321 |
+
( C _ { 1 } , C _ { 2 } , C _ { 3 } , C _ { 4 } , C _ { 5 } , C _ { 6 } ) = ( 9 6 , 1 2 8 , 1 6 0 , 1 9 2 , 9 6 , 1 2 8 )
|
| 322 |
+
$$
|
| 323 |
+
|
| 324 |
+
SwinT-Hyperprior (medium) $( C _ { 1 } , C _ { 2 } , C _ { 3 } , C _ { 4 } , C _ { 5 } , C _ { 6 } ) = ( 1 2 8 , 1 9 2 , 2 5 6 , 3 2 0 , 1 9 2 , 1 9 2 )$
|
| 325 |
+
|
| 326 |
+
SwinT-Hyperprior (large) $( C _ { 1 } , C _ { 2 } , C _ { 3 } , C _ { 4 } , C _ { 5 } , C _ { 6 } ) = ( 1 6 0 , 2 5 6 , 3 5 2 , 4 4 8 , 1 9 2 , 2 5 6 )$
|
| 327 |
+
|
| 328 |
+
A.3.2 CONV-HYPERPRIOR
|
| 329 |
+
|
| 330 |
+
Conv-Hyperprior (small) $( C _ { 1 } , C _ { 2 } , C _ { 3 } , C _ { 4 } , C _ { 5 } , C _ { 6 } , C _ { 7 } ) = ( 1 9 2 , 1 9 2 , 1 9 2 , 1 9 2 , 1 2 8 , 1 2 8 , 1 2 8 )$
|
| 331 |
+
|
| 332 |
+
Conv-Hyperprior (medium) $( C _ { 1 } , C _ { 2 } , C _ { 3 } , C _ { 4 } , C _ { 5 } , C _ { 6 } , C _ { 7 } ) = ( 3 2 0 , 3 2 0 , 3 2 0 , 3 2 0 , 1 9 2 , 1 9 2 , 1 9 2 )$
|
| 333 |
+
|
| 334 |
+

|
| 335 |
+
Figure 12: ChARM architecture. Since $y _ { i }$ can only be decoded after $\mu _ { i }$ and $\sigma _ { i }$ is obtained, the $S$ ChARM-blocks are executed sequentially. We use $S = 1 0$ in all our experiments, which is consistent with (Minnen & Singh, 2020).
|
| 336 |
+
|
| 337 |
+

|
| 338 |
+
Figure 13: SwinT-Hyperprior
|
| 339 |
+
|
| 340 |
+
$$
|
| 341 |
+
( C _ { 1 } , C _ { 2 } , C _ { 3 } , C _ { 4 } , C _ { 5 } , C _ { 6 } , C _ { 7 } ) = ( 4 4 8 , 4 4 8 , 4 4 8 , 4 4 8 , 2 5 6 , 2 5 6 , 2 5 6 )
|
| 342 |
+
$$
|
| 343 |
+
|
| 344 |
+
# B TRAINING AND EVALUATION
|
| 345 |
+
|
| 346 |
+
# B.1 TRAINING
|
| 347 |
+
|
| 348 |
+
All image compression models are trained on CLIC2020 training set, which contains both professional and mobile training sets, in total 1,633 high resolution natural images. Conv-Hyperprior and SwinT-Hyperprior are trained with 2M batches. Each batch contains 8 patches of size $2 5 6 \times 2 5 6$ randomly cropped from the training images. Learning rate starts at $1 0 ^ { - 4 }$ and is reduced to $1 0 ^ { - 5 }$ at 1.8M step.
|
| 349 |
+
|
| 350 |
+
For Conv-ChARM, we first train a model Conv-ChARM at $\beta = 0 . 0 0 0 1$ from scratch for 2M steps, with it as the starting point, we continue to train other beta values Conv-ChARM- $\beta$ , $\beta \in B$ for $1 . 5 \mathbf { M }$ steps. For SwinT-ChARM- $\beta$ , we load the transform weights from the checkpoint at 2M step of the pretrained SwinT-Hyperprior- $\beta$ , then finetune the transforms together with the random initialized ChARM prior for 1.1M steps. Learning rate starts at $1 0 ^ { - 4 }$ and is reduced to $1 0 ^ { - 5 }$ for the last 100K steps.
|
| 351 |
+
|
| 352 |
+
Training loss $L = D + \beta R$ is a weighted combination of distortion $D$ and bitrate $R$ , with $\beta$ being the Lagrangian multiplier steering rate-distortion trade-off. Distortion $D$ is MSE in RGB color space. To cover a wide range of rate and distortion, for each solution, we train 5 models with $\bar { \beta } \in B = \{ 0 . 0 0 3 , 0 . 0 0 1 , 0 . 0 0 \bar { 0 } 3 , 0 . 0 0 0 1 , 0 . 0 0 0 0 3 \}$ .
|
| 353 |
+
|
| 354 |
+
Usually we need to train longer for the model with larger bitrates (i.e. smaller $\beta$ ) to converge. Particularly for the results presented in this paper, We train SwinT-Hyperprior-0.00003 for $2 . 5 \mathbf { M }$ steps instead of 2M steps for the other 4 lower bitrates.
|
| 355 |
+
|
| 356 |
+
For P-frame compression models, we follow the training setup of SSF. Both Conv-SSF and SwinTSSF are trained on Vimeo-90k Dataset (Xue et al., 2019) for 1M steps with learning rate $1 0 ^ { - 4 }$ , batch size of 8, crop size of $2 5 6 \times 2 5 6$ , followed by 50K steps of training with learning rate $1 0 ^ { - 5 }$ and crop size12 $3 8 4 \times 2 5 6$ . The models are trained with 8 $\beta$ values $2 ^ { \gamma } \times 1 0 ^ { - 4 } : \gamma \in \{ 0 , 1 , . . . , 7 \}$ . We adopt one critical trick to stablize the training from (Jaegle et al., 2021; Meister et al., 2018), i.e. to forward each video sequence twice during one optimization step (mini-batch), once in the original frame order, once in the reversed frame order. When this trick is used, we set the batch size to be 4 instead of 8. Finally we add flow loss only between 0 and 200K steps, which we found not critical for stable training but helps improve the RD.
|
| 357 |
+
|
| 358 |
+
For all model training, Adam optimizer is used without weighted decay. Training for 2M steps takes about 10 days and 14 days respectively for Conv-Hyperprior and SwinT-Hyperprior on a single Nvidia V100 GPU. Total training time is about 7.5 days on a single Nvidia V100 GPU.
|
| 359 |
+
|
| 360 |
+
For all models, we use mixed quantization during training (Minnen & Singh, 2020), i.e. adding uniform noise to the continuous latent before passing to the prior model, subtracting prior mean from the continuous latent followed by rounding before passing to the decoder transform.
|
| 361 |
+
|
| 362 |
+
# B.2 TRADITIONAL CODEC EVALUATION
|
| 363 |
+
|
| 364 |
+
In this section, we provide evaluation script used to generate results for traditional codecs.
|
| 365 |
+
|
| 366 |
+
# B.2.1 IMAGE CODECS
|
| 367 |
+
|
| 368 |
+
VTM-12.1: VTM-12.1 software is built from https://vcgit.hhi.fraunhofer.de/ jvet/VVCSoftware_VTM/-/tags/VTM-12.1 and we use the script from CompressAI (https://github.com/InterDigitalInc/CompressAI/tree/efc69ea24) for dataset evaluation. Specifically, the following command is issued to gather VTM-12.1 image compression evaluation results:
|
| 369 |
+
|
| 370 |
+
python -m compressai.utils.bench vtm [path to image folder] -c [path to VVCSoftware_VTM folder]/cfg/encoder_intra_vtm.cfg -b [path to VVCSoftware_VTM folder]/bin -q 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40
|
| 371 |
+
|
| 372 |
+
BPG: BPG software is obtained from https://bellard.org/bpg/ and the following commands are used for encoding and decoding.
|
| 373 |
+
|
| 374 |
+
bpgenc -e x265 -q [0 to 51] -f 444 -o [encoded heic file] [original png file] bpgdec $- \bigcirc$ [decoded png file] [encoded heic file]
|
| 375 |
+
|
| 376 |
+
# B.2.2 VIDEO CODECS
|
| 377 |
+
|
| 378 |
+
# HEVC (x265)
|
| 379 |
+
|
| 380 |
+
ffmpeg -y -pix_fmt yuv420p -s [resolution] -r [frame-rate] -i [input yuv420 raw video] -c:v libx265 -preset medium -crf [9, 12, 15, 18, 21, 24, 27, 30] -tune zerolatency -x265-params "keyint=12:min-keyint=12:verbose $^ { = 1 }$ " [output mkv file path]
|
| 381 |
+
|
| 382 |
+
# AVC (x264)
|
| 383 |
+
|
| 384 |
+
ffmpeg -y -pix_fmt yuv420p -s [resolution] -r [frame-rate] -i [input yuv420 raw video] -c:v libx264 -preset medium -crf [9, 12, 15, 18, 21, 24, 27, 30] -tune zerolatency -x264-params "keyint $= 1 2$ :min-keyint $= 1 2$ :verbose $^ { = 1 }$ " [output mkv file path]
|
| 385 |
+
|
| 386 |
+
# HEVC (HM)
|
| 387 |
+
|
| 388 |
+
[Path to HM folder]/bin/TAppEncoderStatic -c [Path to HM folder]/cfg/encoder_lowdelay_P_main.cfg -i [input yuv raw video] --InputBitDepth $^ { \underline { { { \boldsymbol { \ b } } } } } = 8$ -wdt [width] -hgt [height] -fr [frame-rate] -f [number of frames] -o [output yuv video] -b [encoded bitstream bin file] -ip 12 -q [12, 17, 22, 27, 32, 37, 42]
|
| 389 |
+
|
| 390 |
+
# C BD RATE COMPUTATION
|
| 391 |
+
|
| 392 |
+
def Bjontegaard_Delta_Rate( # rate and psnr in ascending order rate_ref, psnr_ref, # reference rate_new, psnr_new, # new result ): min_psnr $=$ max(psnr_ref[0], psnr_new[0], 30)
|
| 393 |
+
|
| 394 |
+
max_psnr $=$ min(psnr_ref[-1], psnr_new[-1], 44)
|
| 395 |
+
log_rate_ref $=$ log(rate_ref)
|
| 396 |
+
log_rate_new $=$ log(rate_new)
|
| 397 |
+
spline_ref $=$ scipy.interpolate.CubicSpline( psnr_ref, log_rate_ref, bc_type $= ^ { \prime }$ not-a-knot’, extrapolate $=$ True,
|
| 398 |
+
)
|
| 399 |
+
spline_new $=$ scipy.interpolate.CubicSpline( psnr_new, log_rate_new, bc_type $= ^ { \prime }$ not-a-knot’, extrapolate $=$ True,
|
| 400 |
+
)
|
| 401 |
+
delta_log_rate $=$ ( spline_new.integrate(min_psnr, max_psnr) - spline_ref.integrate(min_psnr, max_psnr)
|
| 402 |
+
)
|
| 403 |
+
delta_rate $=$ exp(delta_log_rate / (max_psnr - min_psnr))
|
| 404 |
+
return 100 $\star$ (delta_rate - 1)
|
| 405 |
+
|
| 406 |
+
# C.1 BD RATE FOR IMAGE CODEC
|
| 407 |
+
|
| 408 |
+
# Evaluate BD-rate on an image dataset
|
| 409 |
+
bd_rates $=$ list()
|
| 410 |
+
for image in image_dataset: # evaluate rate and psnr on reference and new codec # for this image with different qualities rate_ref, psnr_ref $=$ ReferenceCodec(image, $\mathrm { { q } } \mathrm { { p } } \mathrm { { = } } [ \ \dots \ ]$ ) rate_new, psnr_new $=$ NewImageCodec(image, bet $\mathsf { a } = [ \hdots ]$ ) bd_rates.append( Bjontegaard_Delta_Rate( rate_ref, psnr_ref, rate_new, psnr_new, ) )
|
| 411 |
+
# BD is computed per image and then averaged
|
| 412 |
+
bd_rate $=$ bd_rates.mean()
|
| 413 |
+
|
| 414 |
+
# C.2 BD RATE FOR VIDEO CODEC
|
| 415 |
+
|
| 416 |
+
# Evaluate BD-rate on a video dataset
|
| 417 |
+
bd_rates $=$ list()
|
| 418 |
+
for video in video_dataset: # evaluate rate and psnr on reference and new codec # for this video with different qualities rate_ref, psnr_ref $=$ ReferenceCodec(video, $\mathrm { { q } } \mathrm { { p } } \mathrm { { = } } [ \ \dots \ ]$ ) rate_new, psnr_new $=$ NewVideoCodec(video, bet $\mathsf { a } = [ \hdots ]$ ) bd_rates.append( Bjontegaard_Delta_Rate( rate_ref, psnr_ref, rate_new, psnr_new, ) )
|
| 419 |
+
# BD is computed per video and then averaged
|
| 420 |
+
bd_rate $=$ bd_rates.mean()
|
| 421 |
+
|
| 422 |
+
# D MORE RESULTS
|
| 423 |
+
|
| 424 |
+
# D.1 IMAGE COMPRESSION
|
| 425 |
+
|
| 426 |
+
Additional rate-distortion results on CLIC2021, Tecnick, and JPEG-AI are provided in Figure 14, Figure 15, and Figure 16.
|
| 427 |
+
|
| 428 |
+
For a complete comparison of results from existing literatures, we provide a summary RD plot of all neural image codec solutions known to us in Figure 28 on Kodak. In Figure 29 and Figure 30, we plot the percentage rate saving with BPG444 and VTM-12.1 as reference, respectively.
|
| 429 |
+
|
| 430 |
+

|
| 431 |
+
Figure 14: Comparison of compression efficiency on CLIC Test 2021.
|
| 432 |
+
|
| 433 |
+

|
| 434 |
+
Figure 15: Comparison of compression efficiency on Tecnick Test.
|
| 435 |
+
|
| 436 |
+

|
| 437 |
+
Figure 16: Comparison of compression efficiency on JPEG AI Test.
|
| 438 |
+
|
| 439 |
+
# D.2 VIDEO COMPRESSION
|
| 440 |
+
|
| 441 |
+
In Figure 17 and Figure 18, we provide performance comparison of Conv-SSF, SwinT-SSF, HEVC $\left( \mathbf { \boldsymbol { x } } 2 6 5 \right)$ , and AVC $\left( \mathrm { x } 2 6 4 \right)$ with per-video breakdown.
|
| 442 |
+
|
| 443 |
+

|
| 444 |
+
Figure 17: Rate savings for each video in the MCL-JCV dataset. Values represent the file size relative to H.264 as estimated by BD rate. [18, 20, 24, 25] are animated sequences.
|
| 445 |
+
|
| 446 |
+

|
| 447 |
+
Figure 18: Rate savings for each video in the UVG dataset. Values represent the file size relative to H.264 as estimated by BD rate.
|
| 448 |
+
|
| 449 |
+
# D.3 CODING COMPLEXITY
|
| 450 |
+
|
| 451 |
+
We evaluate the decoding complexity of all neural image codecs in terms of the time for network inference and entropy coding, peak GPU memory, model size, etc. We select 100 high resolution images from CLIC testset and center crop them to three resolutions $( 7 6 8 \times 5 1 2 , 1 2 8 0 \times 7 6 8 , 1 7 9 2 \times$
|
| 452 |
+
|
| 453 |
+
1024) to see how those metrics scale with image size. Batch size is one for all model inference. We run the experiment on a local workstation with one RTX 2080 Ti GPU, with PyTorch 1.9.0 and Cuda toolkit 11.1. For bit-exact entropy coding, we need to use deterministic13 convolution. The neural networks run on the single GPU and entropy coding runs on CPU with 8 threads. We follow the standard protocols to measure the inference time and peak memory of neural nets, such as GPU warm up and synchronization. File open/close is excluded from coding time measurement. MACs, GPU peak memory, and model parameter count are profiled using get model profile function of deepspeed profiler14.
|
| 454 |
+
|
| 455 |
+
We show more details on the coding complexity of neural image codecs in Figure 19, particularly the linear scaling to image resolution of both SwinT-based and Conv-based models. The break-down of encoding complexity is shown in Table 4.
|
| 456 |
+
|
| 457 |
+

|
| 458 |
+
Figure 19: Detailed profiling on a single RTX 2080 Ti with deterministic conv. Note that while Conv encoder and Conv decoder are of symmetric architectures, Conv decoder takes more time than Conv encoder mainly because Transposed Conv layers in the decoder take much longer than Conv layers in the encoder.
|
| 459 |
+
|
| 460 |
+
For completeness, we also report the profiling for CPU coding time in Table 5 and Table 6. The evaluation setup is the same as the GPU profiling case, except models are run on the CPU instead (same host machine with Intel(R) Xeon(R) W-2123 CPU $\textcircled { a } 3 . 6 0 \mathrm { G H z }$ ).
|
| 461 |
+
|
| 462 |
+
Table 7 reports encoding and decoding time of VTM-12.1 under different quantization parameters (QPs), evaluated on an Intel Core i9-9940 CPU $@$ $) ~ 3 . 3 0 \mathrm { G H z }$ , averaged over 24 Kodak images. As can be seen from the table, decoding time of VTM-12.1 is a function of reconstruction quality, where longer decoding time is observed for higher quality reconstruction. In Figure 1, the reported VTM12.1 decoding speed corresponds to a QP value of 28, where the bpp value is similar to that obtained by models trained with $\beta = 0 . 0 0 1$ . It is worth pointing out that VTM-12.1 encoding process is much slower, ranging anywhere from 1 to 5 minutes per image, whereas neural codec runs much faster.
|
| 463 |
+
|
| 464 |
+
Table 4: GPU encoding complexity. All models are trained with $\beta ~ = ~ 0 . 0 0 1$ , evaluated on the resolution $7 6 8 \times 5 1 2$ (the average bitrate is around $0 . 7 \ \mathsf { b p p }$ ). For the encoding time, we show the network inference time for the encoder $g _ { a }$ , the hyper encoder $h _ { a }$ , the hyper decoder $h _ { s }$ , the entropy encoding time for the hyper latent $\hat { \mathbf { z } }$ and the latent $\hat { \mathbf { y } }$ (including network inference time for the prior model if it is ChARM). GMACs and GPU peak memory during encoding and the parameter count of the entire model are also listed.
|
| 465 |
+
|
| 466 |
+
<table><tr><td rowspan="2">Codec</td><td colspan="6">Time (ms)</td><td rowspan="2">GMACs</td><td rowspan="2">Memory (GB)</td><td rowspan="2">Params (M)</td></tr><tr><td>ga</td><td>ha</td><td>Z</td><td>hs</td><td>y</td><td>total</td></tr><tr><td>Conv-Hyperprior</td><td>22.7</td><td>2.3</td><td>2.8</td><td>4.0</td><td>29.8</td><td>62.0</td><td>102</td><td>0.62</td><td>21.4</td></tr><tr><td>SwinT-Hyperprior</td><td>57.5</td><td>1.2</td><td>2.4</td><td>4.8</td><td>34.3</td><td>100.5</td><td>100</td><td>1.47</td><td>24.7</td></tr><tr><td>Conv-ChARM</td><td>22.9</td><td>2.4</td><td>2.6</td><td>4.1</td><td>63.4</td><td>95.7</td><td>114</td><td>0.66</td><td>29.3</td></tr><tr><td>SwinT-ChARM</td><td>57.8</td><td>1.3</td><td>2.4</td><td>4.8</td><td>68.7</td><td>135.3</td><td>112</td><td>1.51</td><td>32.6</td></tr></table>
|
| 467 |
+
|
| 468 |
+
Table 5: CPU decoding complexity. All models are trained with $\beta = 0 . 0 0 1$ , evaluated on $7 6 8 \times 5 1 2$ images (average $0 . 7 \ \mathrm { b p p }$ ). Decoding time is broken down into inference time of hyper-decoder $h _ { s }$ and decoder $g _ { s }$ , entropy decoding time of hyper-code $\hat { \mathbf { z } }$ and code $\hat { \mathbf { y } }$ (including inference time of the prior model if it is ChARM).
|
| 469 |
+
|
| 470 |
+
<table><tr><td rowspan="2">Codec</td><td colspan="5">CPU decoding ' Time (ms)</td><td rowspan="2">GMACs</td></tr><tr><td>Z</td><td>hs</td><td>y</td><td>9s</td><td>total</td></tr><tr><td>Conv-Hyperprior</td><td>5.1</td><td>20.9</td><td>30.5</td><td>1636.2</td><td>1703.3</td><td>350</td></tr><tr><td>SwinT-Hyperprior</td><td>5.7</td><td>18.3</td><td>30.3</td><td>1912.8</td><td>1979.5</td><td>99</td></tr><tr><td>Conv-ChARM</td><td>4.7</td><td>20.9</td><td>154.6</td><td>1634.3</td><td>1825.6</td><td>362</td></tr><tr><td>SwinT-ChARM</td><td>5.8</td><td>18.2</td><td>141.1</td><td>1877.3</td><td>2054.7</td><td>111</td></tr></table>
|
| 471 |
+
|
| 472 |
+
Table 6: CPU encoding complexity. All models are trained with $\beta ~ = ~ 0 . 0 0 1$ , evaluated on the resolution $7 6 8 \times 5 1 2$ (the average bitrate is around $0 . 7 \ \mathsf { b p p }$ ). For the encoding time, we show the network inference time for the encoder $g _ { a }$ , the hyper encoder $h _ { a }$ , the hyper decoder $h _ { s }$ , the entropy encoding time for the hyper latent $\hat { \mathbf { z } }$ and the latent $\hat { \mathbf { y } }$ (including network inference time for the prior model if it is ChARM).
|
| 473 |
+
|
| 474 |
+
<table><tr><td rowspan="2">Codec</td><td colspan="6">CPU encoding Time (ms)</td><td rowspan="2">GMACs</td></tr><tr><td>ga</td><td>ha</td><td>Z</td><td>hs</td><td>y</td><td>total</td></tr><tr><td>Conv-Hyperprior</td><td>896.0</td><td>8.9</td><td>2.7</td><td>20.9</td><td>31.1</td><td>960.9</td><td>102</td></tr><tr><td>SwinT-Hyperprior</td><td>1781.6</td><td>14.5</td><td>2.6</td><td>18.3</td><td>29.7</td><td>1847.9</td><td>100</td></tr><tr><td>Conv-ChARM</td><td>895.7</td><td>8.9</td><td>2.5</td><td>20.9</td><td>146.3</td><td>1075.5</td><td>114</td></tr><tr><td>SwinT-ChARM</td><td>1697.1</td><td>14.5</td><td>2.6</td><td>18.2</td><td>133.5</td><td>1867.1</td><td>112</td></tr></table>
|
| 475 |
+
|
| 476 |
+
Table 7: Decoding and encoding time of VTM-12.1 averaged over 24 Kodak images.
|
| 477 |
+
|
| 478 |
+
<table><tr><td>QP</td><td>bits per pixel</td><td>PSNR (dB)</td><td>Decoding time(s)</td><td>Encoding time (s)</td></tr><tr><td>16</td><td>2.5441</td><td>44.09</td><td>0.284</td><td>300.47</td></tr><tr><td>28</td><td>0.7844</td><td>36.76</td><td>0.249</td><td>118.85</td></tr><tr><td>40</td><td>0.1557</td><td>29.51</td><td>0.149</td><td>71.10</td></tr></table>
|
| 479 |
+
|
| 480 |
+
# E ANALYSIS
|
| 481 |
+
|
| 482 |
+
# E.1 SPATIAL CORRELATION OF LATENT
|
| 483 |
+
|
| 484 |
+
We visualize the spatial correlation map for Conv-Hyperprior and SwinT-Hyperprior at different $\beta$ in Figure 20.
|
| 485 |
+
|
| 486 |
+
# E.2 EFFECTIVE RECEPTIVE FIELD
|
| 487 |
+
|
| 488 |
+
See Figure 21 for the effective receptive field for the composed encoding tranforms $h _ { a } \circ g _ { a }$ and Figure 22 for the mean attention distance visualization of each head within each transformer layer.
|
| 489 |
+
|
| 490 |
+
# E.3 RATE DISTRIBUTION ACROSS LATENT CHANNELS
|
| 491 |
+
|
| 492 |
+
It is generally believed that ConvNets learn to extract various features and store them in each channel of the activations. Here we look into the features in the latent channels which are to be quantized and entropy coded to bitstreams. Particularly we order the total bitrate of each channel averaged over Kodak dataset $2 4 7 6 8 \times 2 5 6$ images). The result is shown in Figure 23. We find an interesting phenomenon across models under different bitrates: there is a cutoff point of the bitrate-vs-channel curve where the bitrate suddenly drops to zero, which manifest the rate constraint in the loss function. As expected, the cutoff index decreases for the model trained for smaller bitrate (larger $\beta$ ).
|
| 493 |
+
|
| 494 |
+
# E.4 CENTERED KERNEL ALIGNMENT
|
| 495 |
+
|
| 496 |
+
To investigate the difference or similarity between latent features of Conv-based and SwinT-based models, we resort to a commonly used tool in representation learning called centered kernel alignment (CKA) (Kornblith et al., 2019). We evaluate CKA between each of the Conv latent channel and SwinT latent channel (both models are trained under the same $\beta$ ) over the 24 Kodak images. There are 320 channels for both Conv latent and SwinT latent, resulting a $3 2 0 \times 3 2 0$ CKA matrix. The result is shown in Figure 24. The latent channel is ordered by the averaged bitrate of each channel over Kodak images (same as in Section E.3). The CKA matrix has clear block structure, where high similarity region corresponds to the latent channels before the bitrate cutoff in the rate distribution curve (Figure 23).
|
| 497 |
+
|
| 498 |
+
Identification of SwinT and Conv latent channels with CKA Within the block of high similarity (from the CKA matrix), we identify the ‘less’ similar SwinT latent channels with lowest CKA values between this SwinT channel and all other Conv latent channels. For each of the identified SwinT channel, we find the Conv latent channel with the largest CKA value between the two. This way, we are able to identify latent channels of two different models with high similarity. We show the identified top 8 channels in Figure 25. The channels are indeed highly similar, up to a sign flip, even through the two model architectures are quite different. This empirical result is relevant to the literature on the identifiability of generative models (Khemakhem et al., 2020).
|
| 499 |
+
|
| 500 |
+
# E.5 PROGRESSIVE DECODING
|
| 501 |
+
|
| 502 |
+
More visual examples of reconstructions of checkerboard (spatially) masked latent are provided in Figure 26.
|
| 503 |
+
|
| 504 |
+
Channel-wise progressive decoding Here we visualize the behavior of channel-wise progressive decoding of Conv and SwinT models. For both models, we order the latent channels with a heuristic importance metric: the reduction of distortion over the increase of rate if one channel is included for decoding. We start with the order of bitrate per channel, we pass the leading channels of bitrate order (zero out all rest channels) to the decoder to obtain reconstruction and calculate distortion. We plot the top 8 channels following this importance order. For each channel, we show 6 maps from top to bottom: latent values, mean prediction from the hyper decoder, standard deviation prediction from the hyper decoder, the bitmap, the reconstruction with only current channel, the reconstruction with up to current channel (all leading channels). The result is shown in Figure 27. For Conv models, usually the top 3 important channels are responsible for lightness, and two color components (blueyellow, red-green), similar to the LAB colorspace. The rest of the latent channels are responsible for adding details like texture and edges. For the Swint models, at low bitrate, there is one significantly different channel (the first column in Figure 27b), which is in a coarse scale (with smooth blocks) and responsible for the reconstruction of a nearly constant image with value close to 120 (the mean value of natural image dataset). This latent channel costs extremely small bitrate but reaches PSNR of 13dB. We tried remove this first channel, the progressive reconstruction with the rest leading 7 channels only leads to PSNR around 16dB, instead of 26dB shown in the figure.
|
| 505 |
+
|
| 506 |
+
# F MORE ABLATION STUDIES
|
| 507 |
+
|
| 508 |
+
Local self-attention To see if local self-attention is the most important component in transformers, we replace it by depthwise separable convolution block15 (Han et al., 2021; El-Nouby et al., 2021), which performs similar spatial feature aggregation as self-attention, while keeping all other components the same as in the SwinT. We found this change only leads to minor degradation in RD. This suggests other components in transformers such as MLPs and skip connections may also play a big role, other than just self-attention, for the leading performance in our work and many other tasks (Dong et al., 2021).
|
| 509 |
+
|
| 510 |
+
Small depths Upon investigating the mean attention distance as shown in Figure 22, we find the last block in each of the last two encoder stages has about half of its attention heads degenerate to attending to fixed nearly pixels. This suggests redundant transformer blocks at that stage, so we remove those two blocks, i.e. from depths [2, 2, 6, 2] to [2, 2, 5, 1]. The resulting SwinT-Hyperprior has even less parameters (20.6M) than Conv-Hyperprior (21.4M) while with almost no RD loss compared to the larger model. We expect more hyperparameter search will identify models with better RD-complexity trade-off than we currently show in this work.
|
| 511 |
+
|
| 512 |
+
Deeper Conv encoder Deeper models are usually more expressive (Raghu et al., 2017) and the state-of-the-art Conv-based compression models typically use much deeper layers than the encoder in the original Hyperprior model (Balle et al., 2018). As a sanity check on whether deeper con- ´ volutional transforms can outperform SwinT-based encoder transforms with 12 blocks, we take an existing design (Chen et al., 2021) with residual blocks and attention (sigmoid gating) layers, which has over 50 conv layers in either encoder or decoder, and more parameters than conv baseline. It indeed improves the RD in lower bitrate, but still worse than SwinT-Hyperprior, and gets much worse in higher bitrate. This is probably the reason that compression models based on this type of transforms did not report results at higher bitrates.
|
| 513 |
+
|
| 514 |
+

|
| 515 |
+
Figure 20: Spatial correlation of $( \mathbf y - \pmb \mu ( \hat { \mathbf z } ) ) / \pmb \sigma ( \hat { \mathbf z } )$ , averaged across all latent elements of all images on Kodak. The value with index $( i , j )$ corresponds to the normalized cross-correlation of latents at spatial location $( w , h )$ and $( w + i , h + j )$ . Left column corresponds to Conv-Hyperprior and right columns corresponds to SwinT-Hyperprior. Each row shows a pair of models trained at the same $\beta$ , where the $\beta$ values from top to bottom are 0.0001, 0.0003, 0.001, 0.003. A consistent observation across all these models is that SwinT-Hyperprior achieves uniformly smaller correlation than its convolutional counterpart. As $\beta$ gets smaller (rate becomes lower), the correlation in both models increase, with SwinT-Hyperprior increasing much slower than Conv-Hyperprior.
|
| 516 |
+
|
| 517 |
+

|
| 518 |
+
Figure 21: Comparison of effective receptive field (ERF) of the composed encoders $h _ { a } \circ g _ { a }$ . The ERF is visualized as the absolution gradients of the center pixel in the hyper latent (i.e. $d z / d x )$ with respect to the input images/videos, specifically 24 Kodak images cropped to $5 1 2 \times 5 1 2$ for image codecs (the left four models, all with $\beta = 0 . 0 0 3$ ), and 24 randomly selected batches from UVG video dataset cropped to $7 6 8 \times 7 6 8$ for P-frame codecs (the right four models, all with $\beta = 0 . 0 0 0 8 )$ .
|
| 519 |
+
|
| 520 |
+

|
| 521 |
+
Figure 22: Mean attention distance of SwinT-Hyperprior models evaluated on Kodak. It is calculated as the average relative distance between each query and key weighted by the attention weight for each query, in each head of each layer. Each vertical color bar in the figure shows the mean and 1-std for the mean attention distance of one head, dashed black bar separates heads from different transformer stages (feature resolutions). The order of input to output is from left to right within each figure. Lower bitrate models have smaller attention distance.
|
| 522 |
+
|
| 523 |
+

|
| 524 |
+
Figure 23: Rate distribution of latent channels. Five lines with the same colormap from bright to dark corresponds to the model trained under five $\beta$ values from small to large (i.e. overall bitrate from large to small). The cutoff index decreases as the total rate goes down.
|
| 525 |
+
|
| 526 |
+

|
| 527 |
+
Figure 24: Centered Kernel Alignment between 320 SwinT latent channels and 320 Conv latent channels. Blocks with high similarity correspond to latent channels before the cutoff in Figure 23.
|
| 528 |
+
|
| 529 |
+

|
| 530 |
+
Figure 25: Identification of latent features from SwinT and Conv models with CKA (on 23rd image in Kodak). For each subfigure, top row shows 8 channels of SwinT latents with the smallest mean CKA values between this channel and all Conv latent channels (before the rate cutoff in Figure 23). The corresponding image on the bottom shows the Conv latent channel with the largest CKA with the top SwinT channel. The identified channels are highly similar, up to sign flip.
|
| 531 |
+
|
| 532 |
+

|
| 533 |
+
Figure 26: More examples of reconstructions with SwinT-Hyperprior (top row) and ConvHyperprior (bottom row) for the latent masked with checkerboard pattern where half of the latent dequantized values are replaced with the corresponding prior mean before passing to the decoder $g _ { s }$ . The example image shown in Figure 8b is andy-kelly-0E vhMVqL9g-unsplash from CLIC2021 test, same as the two images shown here.
|
| 534 |
+
|
| 535 |
+

|
| 536 |
+
Figure 27: Channel-wise progressive decoding. The 3 leading latent channels following an importance order are responsible for grayscale, and two color components of the reconstruction (second to the last row). For SwinT models, we find a coarse-scale latent channel (the left most channel) which costs negligible bits but is important for reconstruction (without it, the 7 other leading channels can only decode to a reconstruction with PSNR around 16dB). For each subfigure, from top to bottom: latent, prior mean, prior std, bitmap, reconstruction with current channel, reconstruction with leading channels (up to current channel).
|
| 537 |
+
|
| 538 |
+

|
| 539 |
+
Figure 28: Rate-distortion performance on Kodak, comparing with existing works (Cheng et al., 2020; Xie et al., 2021; Ma et al., 2021; Guo et al., 2021; Balle et al., 2018; Minnen & Singh, 2020; ´ Lee et al., 2019; Wu et al., 2020; Minnen et al., 2018). Dashed line-style indicates the use of spatial autoregressive model (block-wise or pixel-wise) as prior model.
|
| 540 |
+
|
| 541 |
+

|
| 542 |
+
Figure 29: Percentage of rate-saving over BPG444 evaluated on Kodak (extended version of Figure 3b), comparing with existing works (Cheng et al., 2020; Xie et al., 2021; Ma et al., 2021; Guo et al., 2021; Balle et al., 2018; Minnen & Singh, 2020; Lee et al., 2019; Wu et al., 2020; Minnen ´ et al., 2018). Dashed line-style indicates the use of spatial autoregressive model (block-wise or pixel-wise) as prior model.
|
| 543 |
+
|
| 544 |
+

|
| 545 |
+
Figure 30: Percentage of rate-saving over VTM-12.1 evaluated on Kodak (extended version of Figure 3b), comparing with existing works (Cheng et al., 2020; Xie et al., 2021; Ma et al., 2021; Guo et al., 2021; Balle et al., 2018; Minnen & Singh, 2020; Lee et al., 2019; Wu et al., 2020; Minnen ´ et al., 2018). Dashed line-style indicates the use of spatial autoregressive model (block-wise or pixel-wise) as prior model.
|
md/dev/JTmO2V9Xpz/JTmO2V9Xpz.md
ADDED
|
@@ -0,0 +1,340 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# MEGABYTE: Modeling Million-byte Sequences with Multiscale Transformers
|
| 2 |
+
|
| 3 |
+
Lili Yu∗ Dániel Simig∗ Colin Flaherty∗ Armen Aghajanyan
|
| 4 |
+
|
| 5 |
+
Luke Zettlemoyer Mike Lewis
|
| 6 |
+
|
| 7 |
+
Meta AI
|
| 8 |
+
|
| 9 |
+
# Abstract
|
| 10 |
+
|
| 11 |
+
Autoregressive transformers are spectacular models for short sequences but scale poorly to long sequences such as high-resolution images, podcasts, code, or books. We propose MEGABYTE, a multi-scale decoder architecture that enables end-to-ModModelModelModel end differentiable modeling of sequences of over one million bytes. MEGABYTE segments sequences into patches and uses a local submodel within patches and a_ m e g _ b y t _ ' ' t r _ n global model between patches. This enables sub-quadratic self-attention, much larger feedforward layers for the same compute, and improved parallelism during decoding—unlocking better performance at reduced cost for both training and gen-Global Model eration. Extensive experiments show that MEGABYTE allows byte-level models to perform competitively with subword models on long context language modeling, achieve state-of-the-art density estimation on ImageNet, and model audio from raw files. Together, these results establish the viability of tokenization-free autoregressive sequence modeling at scale.
|
| 12 |
+
|
| 13 |
+
# 1 Introduction
|
| 14 |
+
|
| 15 |
+
Sequences of millions of bytes are ubiquitous; for example, music, image, or video files typically consist of multiple megabytes. However, large transformer decoders (LLMs) typically only use several thousand tokens of context (Brown et al., 2020; Zhang et al., 2022a)—both because of the quadratic cost of self-attention but also, more importantly, the cost of large feedforward networks per-position. This severely limits the set of tasks where LLMs can be applied.
|
| 16 |
+
|
| 17 |
+
We introduce MEGABYTE, a new approach to modeling long byte sequences. First, byte sequences are segmented into fixed-sized patches, loosely analogous to tokens. Our model then consists of three parts: (1) a patch embedder, which simply encodes a patch by losslessly concatenating embeddings of each byte, (2) a global module, a large autoregressive transformer that inputs and outputs patch representations and (3) a local module, a small autoregressive model
|
| 18 |
+
|
| 19 |
+

|
| 20 |
+
Figure 1: Overview of MEGABYTE with patch size $P =$ 4. A small local model autoregressively predicts each patch byte-by-byte, using the output of a larger global model to condition on previous patches. Global and Local inputs are padded by $P$ and 1 token respectively to avoid leaking information about future tokens.
|
| 21 |
+
|
| 22 |
+
that predicts bytes within a patch. Crucially, we observe that for many tasks, most byte predictions
|
| 23 |
+
|
| 24 |
+
$$
|
| 25 |
+
\begin{array} { r l r } { \iota _ { t } ^ { \mathrm { c o b i s c d } } } & { = E _ { x _ { t } } ^ { \mathrm { i o b o l . } \mathrm { c o n b e d } } + E _ { t } ^ { \mathrm { i o s } } } & { t \in [ 0 . . T ) , E ^ { \mathrm { g l o b a i c m e d } } \ \in \mathbb { R } ^ { N \times D G } , } \\ & { } & { E ^ { \mathrm { p o s } } \in \mathbb { R } ^ { T \times N \times D G } , \ k ^ { \mathrm { c o b d . } } \in \mathbb { R } ^ { T \times N \times D _ { G } } } \\ & { } & { E ^ { \mathrm { p l o b a i s i n } } } \\ & { \iota _ { k } ^ { \mathrm { g l o b a i s a l } } } & { = \left\{ \begin{array} { l l } { E ^ { \mathrm { g l o b a l . } \mathrm { p o s d . } } } & { \mathrm { i f } \ k = 0 , } \\ { h _ { t } ^ { \mathrm { i o s } } ( \mathrm { p . e } - 1 ) \cdot p \cdot ( k \cdot p ) } & { k \in [ 1 , \ldots , K ) , } \\ { w _ { 0 } \times \mathrm { c o n . } \mathrm { c o n } } & { 1 } \end{array} \right. } \\ & { } & { \mathrm { p l o b . ~ } } \\ { \iota _ { t , k } ^ { \mathrm { p o t a i n } } } & { = \mathrm { t r a s i o n ~ c l o b a i ~ } \left( b _ { 0 , k } ^ { \mathrm { g l o b a i . } } \right) } \\ & { } & { \mathrm { i f ~ } \mu _ { k , p } ^ { \mathrm { c o s i s a l } } + \frac { \mu _ { k } ^ { \mathrm { i n d . } } \mu _ { k } ^ { \mathrm { f l o c a l . } } } { \mu _ { k , p } ^ { \mathrm { i n d . } } } } \end{array}
|
| 26 |
+
$$
|
| 27 |
+
|
| 28 |
+
are relatively easy (for example, completing a word given the first few characters), meaning that large networks per-byte are unnecessary, and a much smaller model can be used for intra-patch modelling.
|
| 29 |
+
|
| 30 |
+
MEGABYTE has three main advantages over Transformers for long sequence modeling:
|
| 31 |
+
|
| 32 |
+
1. Sub-quadratic self-attention Most work on long sequence models has focused on mitigating the quadratic cost of self-attention. MEGABYTE decomposes long sequences into two shorter sequences, and optimal patch sizes reduces the self-attention cost to $O ( N ^ { \frac { 4 } { 3 } } )$ , which remains tractable for even long sequences.
|
| 33 |
+
|
| 34 |
+
2. Per-patch feedforward layers In GPT3-size models, more than $9 8 \%$ of FLOPS are used in computing position-wise feedforward layers. MEGABYTE uses large feedforward layers per-patch rather than per-position, enabling much larger and more expressive models for the same cost. With patch size $P$ , where a baseline transformer would use the same feedforward layer with $m$ parameters $P$ times, MEGABYTE can use a layer with $m P$ parameters once for the same cost.
|
| 35 |
+
|
| 36 |
+
3. Parallelism in Decoding Transformers must perform all computations serially during generation because the input to each timestep is the output from the previous timestep. By reusing the global representation over multiple time steps during local model decoding, MEGABYTE allows greater parallelism during generation. For example, a MEGABYTE model with 1.5B parameters can generate sequences $40 \%$ faster than a standard 350M Transformer, whilst also improving perplexity when trained with the same compute.
|
| 37 |
+
|
| 38 |
+
Together, these improvements allow us to train much larger and better-performing models for the same compute budget, scale to very long sequences, and improve generation speed during deployment.
|
| 39 |
+
|
| 40 |
+
MEGABYTE also provides a strong contrast to existing autoregressive models that typically use some form of tokenization, where sequences of bytes are mapped to larger discrete tokens (Sennrich et al., 2015; Ramesh et al., 2021; Hsu et al., 2021). Tokenization complicates pre-processing, multi-modal modelling, and transfer to new domains, while hiding useful structure from the model. It also means that most state-of-the-art models are not truly end to end. The most widely used approaches to tokenization require language-specific heuristics (Radford et al., 2019) or lose information (Ramesh et al., 2021). Replacing tokenization with efficient and performant byte models would therefore have many advantages.
|
| 41 |
+
|
| 42 |
+
We conduct extensive experiments for both MEGABYTE and strong baselines. We use a fixed compute and data budget across all models to focus our comparisons solely on the model architecture rather than training resources, which are known to benefit all models. We find that MEGABYTE allows byte-level models to perform competitively with subword models on long context language modeling, achieve state-of-the-art perplexities for density estimation on ImageNet, and allow audio modelling from raw audio files. Together, these results establish the viability of tokenization-free autoregressive sequence modeling at scale.
|
| 43 |
+
|
| 44 |
+
# 2 MEGABYTE Transformer
|
| 45 |
+
|
| 46 |
+
# 2.1 Overview
|
| 47 |
+
|
| 48 |
+
MEGABYTE is an autoregressive model for efficiently modeling long input sequences. MEGABYTE is comprised of 3 components: (1) a patch embedder that inputs a discrete sequence, embeds each element, and chunks it into patches of length $P$ (2) a large global Transformer that contextualizes patch representations by performing self-attention over previous patches, and (3) a smaller local Transformer that inputs a contextualized patch representation from the global model, and autoregressively predict the next patch.
|
| 49 |
+
|
| 50 |
+
# 2.2 Components
|
| 51 |
+
|
| 52 |
+
Patch Embedder with patch size of $P$ maps a byte sequence $x _ { 0 . . T }$ to a sequence of patch embeddings of length $\begin{array} { r } { K = { \frac { T } { P } } } \end{array}$ and dimension $P \cdot D _ { G }$ .
|
| 53 |
+
|
| 54 |
+
First, each byte is embedded with a lookup table $E$ global-embed $\in \mathbb { R } ^ { V \times D _ { G } }$ to an embedding of size $D _ { G }$ and positional embeddings are added.
|
| 55 |
+
|
| 56 |
+
$$
|
| 57 |
+
h _ { t } ^ { \mathrm { e m b e d } } = E _ { x _ { t } } ^ { \mathrm { g l o b a l - e m b e d } } + E _ { t } ^ { \mathrm { p o s } } \qquad t \in [ 0 . . T ]
|
| 58 |
+
$$
|
| 59 |
+
|
| 60 |
+
Then, byte embeddings are reshaped into a sequence of $K$ patch embeddings with dimension $P \cdot D _ { G }$ . To allow autoregressive modelling, the patch sequence is padded to start with a trainable patch-sized padding embedding $( E ^ { \mathrm { g l o b a l - p a d } } \ \in \ \mathbb { R } ^ { P \times D _ { G } } )$ ), and the last patch is removed from the input. This sequence is the input to the global model, and is denoted hglobal-in ∈ RK×(P ·DG).
|
| 61 |
+
|
| 62 |
+
$$
|
| 63 |
+
\begin{array} { r } { h _ { k } ^ { \mathrm { g l o b a l - i n } } = \left\{ \begin{array} { l l } { E ^ { \mathrm { g l o b a l - p a d } } , } & { \mathrm { i f } k = 0 , } \\ { h _ { ( ( k - 1 ) \cdot P ) : ( k \cdot P ) } ^ { \mathrm { e m b e d } } , } & { k \in [ 1 , . . , K ) , } \end{array} \right. } \end{array}
|
| 64 |
+
$$
|
| 65 |
+
|
| 66 |
+
Global Model is a decoder-only Transformer with dimension $P \cdot D _ { G }$ that operates on a sequence of
|
| 67 |
+
$K$ tween patchpresentation uts a sequence of by performing se patch representations attention over previous , and outputs an updated. $K$ $h _ { 0 : K } ^ { \mathrm { g l o b a l - i n } }$ $h _ { 0 : K } ^ { \mathrm { g l o b a l - o u t } }$
|
| 68 |
+
|
| 69 |
+
$$
|
| 70 |
+
h _ { 0 ; K } ^ { \mathrm { g l o b a l - o u t } } = \mathrm { t r a n s f o r m e r } ^ { \mathrm { g l o b a l } } ( h _ { 0 : K } ^ { \mathrm { g l o b a l - i n } } )
|
| 71 |
+
$$
|
| 72 |
+
|
| 73 |
+
The output of the final global layer $h _ { 0 : K } ^ { \mathrm { g l o b a l } }$ contains $K$ patc epresentations imension $P \cdot D _ { G }$ .
|
| 74 |
+
For each of these, we reshape them into sequences of length $P$ $D _ { G }$ , where position $p$
|
| 75 |
+
uses dimensions $p \cdot D _ { G }$ to $( p + 1 ) \cdot D _ { G }$ . Each position is then projected to the dimension of the local
|
| 76 |
+
model with a matrix these with byte embe $w ^ { \mathrm { G L } } \in \mathbb { R } ^ { D _ { G } \times D _ { L } }$ where for th $D _ { L }$ is the local model dikens in the next patch combineocal byte $D _ { L }$ $E _ { x _ { ( k \cdot P + p - 1 ) } } ^ { \mathrm { l o c a l - e m b e d } }$ $( E ^ { \mathrm { l o c a l - p a d } } \in \mathbb { R } ^ { D _ { L } } )$
|
| 77 |
+
autoregressive modelling within a patch. This results in a tensor hlocal-in ∈ RK×P ×DL .
|
| 78 |
+
|
| 79 |
+
$$
|
| 80 |
+
h _ { k , p } ^ { \mathrm { l o c a l - i n } } = w ^ { \mathrm { G L } } h _ { k , ( p \cdot D _ { G } ) : ( ( p + 1 ) \cdot D _ { G } ) } ^ { \mathrm { g l o b a l - o u t } } + E _ { x _ { ( k \cdot P + p - 1 ) } } ^ { \mathrm { l o c a l - e m b e d } }
|
| 81 |
+
$$
|
| 82 |
+
|
| 83 |
+
Local Model is a smaller decoder-only Transformer of dimension $D _ { L }$ that operates on a single patch $k$ containing $P$ elements, each of which is the sum of an output from the global model and an embedding of the previous byte in the sequence. $K$ copies of the local models are run on each patch independently (and in parallel during training), computing a representation $h ^ { \mathrm { l o c a l - o u t } } \in \mathbb { R } ^ { K \times P \cdot \hat { D } _ { L } }$ .
|
| 84 |
+
|
| 85 |
+
$$
|
| 86 |
+
h _ { k , 0 : P } ^ { \mathrm { l o c a l - o u t } } = \mathrm { t r a n s f o r m e r } ^ { \mathrm { l o c a l } } ( h _ { k , 0 : P } ^ { \mathrm { l o c a l - i n } } )
|
| 87 |
+
$$
|
| 88 |
+
|
| 89 |
+
Finally, we can compute the probability distribution over the vocabulary at each position. The $p$ th element of the $k$ th patch corresponds to element $t$ of the complete sequence, where $t = k \cdot P + p$ :
|
| 90 |
+
|
| 91 |
+
$$
|
| 92 |
+
p ( x _ { t } | x _ { 0 : t } ) = \mathrm { s o f t m a x } \big ( E ^ { \mathrm { l o c a l - e m b e d } } h _ { k , p } ^ { \mathrm { l o c a l - o u t } } \big ) _ { x _ { t } }
|
| 93 |
+
$$
|
| 94 |
+
|
| 95 |
+
# 2.3 Variations and Extensions
|
| 96 |
+
|
| 97 |
+
Convolutional Patch Encoder: One limitation of patchifying sequences is that it is not translation invariant, and byte sequences may receive a different representation depending on their position in the patch. This may mean, for example, that a model has to relearn the meaning of a word at different offsets. To mitigate this issue, we experimented with augmenting the Patch Embedder with causal convolutional layers, which allow translation-invariant contextual representations of the bytes before they are chunked into patches. We use a stack of convolutional layers, with filter sizes of 3, 5 and 7.
|
| 98 |
+
|
| 99 |
+
Cross-patch Attention: The Local model uses short sequences for efficiency, and relies on the Global model for long-range information. However, we can increase the context of the Local model with little overhead by allowing it to condition on $r$ elements from the previous patch. This approach allows the Global model to focus on a longer-range context. Specifically, when computing selfattention in each layer, we concatenate the keys and values with the last $r$ keys and queries from the previous patch. We use rotary embeddings (Su et al., 2021) to model relative positions between elements in the sequence. This approach is reminiscent of TransformerXL (Dai et al., 2019) but differs by being fully differentiable.
|
| 100 |
+
|
| 101 |
+
Strided Inference: We observed empirically that the per-token loss within each patch increases towards the end of the patch, as the prediction relies more on the weaker Local model. To alleviate this issue, we propose strided inference, in which we predict the sequence with two forward passes of the full model, whose inputs are offset by $p / 2$ positions from each other. We then combine the first $p / 2$ positions in each patch for our predictions to predict the complete sequence. Similarly to sliding window methods (Press et al., 2020), this approach doubles the cost of inference but improves results.
|
| 102 |
+
|
| 103 |
+
# 3 Efficiency Analysis
|
| 104 |
+
|
| 105 |
+
# 3.1 Training Efficiency
|
| 106 |
+
|
| 107 |
+
Attention The cost of attention in a transformer architecture for a sequence of length $T$ has $O ( T ^ { 2 } )$ complexity. Much work has been explored reducing this; for example, Sparse Transformers (Child et al., 2019) and Routing Transformers (Roy et al., 2020) show strong results with a complexity $O ( T ^ { \frac { 3 } { 2 } } )$ . Many linear attention mechanisms have also been proposed (Katharopoulos et al., 2020; Choromanski et al., 2020), although we are not aware of competitive results on large scale language modeling tasks. As a function of sequence length $T$ and patch size $P$ , the Global model has a sequence of length $\textstyle { \frac { P } { T } }$ so uses $\scriptstyle O ( { \frac { T ^ { 2 } } { P ^ { 2 } } } )$ operations, and the Local model uses $\textstyle { \frac { P } { T } }$ sequences of length $P$ so uses $\begin{array} { r } { O ( \frac { T P ^ { 2 } } { P } ) = O ( P T ) } \end{array}$ operations. The overall cost of MEGABYTE is therefore in $\begin{array} { r } { O ( \frac { T ^ { 2 } } { P ^ { 2 } } + T P ) } \end{array}$ . $P$ is a hyperparameter that is chosen to create an architecture for sequences of size $T$ . By setting $P = T ^ { \frac { 1 } { 3 } }$ the complexity is in $O ( T ^ { \frac { 4 } { 3 } } )$ . Using much shorter patches of $P = T ^ { \frac { 1 } { 5 } }$ would give a complexity of $O ( T ^ { \frac { 8 } { 5 } } )$ . The cost is less than the transformer for all non-trivial values of $P$ such that $1 < P < T$ .
|
| 108 |
+
|
| 109 |
+
Feedforward Layers However, attention is not the main cost in large transformers. Instead of increasing the sequence length, transformers are more commonly scaled by increasing the dimension of their latent state $d$ , and the feedforward network cost dominates the model’s overall cost (Kaplan et al., 2020). For example, in the GPT3 architecture, the quadratic self-attention computation accounts for only $1 . 4 \%$ of FLOPS. Following the approximation of (Kaplan et al., 2020), a forward pass with a large transformer with $m$ non-embedding parameters on a sequence of length $T$ uses roughly $2 m T$ FLOPS. MEGABYTE contains two transformers: the Global model uses $m _ { g }$ parameters on a sequence of length $\textstyle { \frac { T } { P } }$ , and a Local model with $m _ { l }$ parameters that sees $\textstyle { \frac { T } { P } }$ sequences of length $P$ giving an estimate of $2 T ( \frac { m _ { g } } { P } + m _ { l } )$ FLOPS. When $m _ { g } \gg m _ { l }$ , the FLOPS used by MEGABYTE is approximately $\frac { 2 T m _ { g } } { P }$ , allowing a model $P$ times larger than a transformer with equivalent FLOPS. This analysis holds irrespective of any efficient attention mechanisms used in the transformer.
|
| 110 |
+
|
| 111 |
+
Combined Analysis To understand efficiency at different sequence lengths and model sizes, we calculate the total FLOPS used by transformers, Linear Transformers and MEGABYTE. For each operation, we use FLOP estimates from (Kaplan et al., 2020), except for attention in Linear Transformers, which we estimate as $9 D$ FLOPS/token1, where $D$ is the model embedding dimension. Figure 3 shows that for models of size 660M to 173B and sequence lengths of up to 1M tokens,
|
| 112 |
+
|
| 113 |
+
MEGABYTE with $P = 8$ uses less FLOPS than either transformers or Linear Transformers. Baseline model architectures are based on GPT3, and Megabyte global/local model sizes are 452M/151M, 5.8B/604M, 170B/3.2B respectively.
|
| 114 |
+
|
| 115 |
+
# 3.2 Generation Efficiency
|
| 116 |
+
|
| 117 |
+
Generating long sequences with transformers is slow, because the input to each timestep is the output from the previous timestep, meaning each layer must be computed for each token serially. As running a layer on a single token typically does not saturate the amount of parallelism available within a GPU, for analysis, we model each layer as a constant cost independently of size. Consider a MEGABYTE model with $L _ { \mathrm { g l o b a l } }$ layers in the Global model and $L _ { \mathrm { l o c a l } }$ layers in the Local model and patch size $P$ , compared with a Transformer architecture with $L _ { \mathrm { l o c a l } } + L _ { \mathrm { g l o b a l } }$ layers. Generating each patch with MEGABYTE requires a sequence of $O ( L _ { \mathrm { g l o b a l } } + P \cdot L _ { \mathrm { l o c a l } } )$ serial operations, whereas the Transformer requires $\bar { O } ( P \cdot L _ { \mathrm { g l o b a l } } + P \cdot L _ { \mathrm { l o c a l } } )$ serial operations. When $L _ { \mathrm { g l o b a l } } \gg L _ { \mathrm { l o c a l } }$ (i.e. the Global model has many more layers than the Local model), MEGABYTE can reduce inference costs by a factor close to $P$ .
|
| 118 |
+
|
| 119 |
+

|
| 120 |
+
Figure 3: Computational cost (FLOPS/token) for different model architectures at different scales. MEGABYTE architectures (here with $P = 8$ ) use less FLOPS than equivalently sized Transformers and Linear Transformers (Katharopoulos et al., 2020) across a wide range of model sizes and sequence lengths, allowing larger models to be used for the same computational cost.
|
| 121 |
+
|
| 122 |
+
# 4 Experimental setup
|
| 123 |
+
|
| 124 |
+
Controlling for Compute and Data Models show consistent improvements when increasing both data and compute Kaplan et al. (2020); Hoffmann et al. (2022), meaning that one model can outperform another because of an increased training budget instead of an improved architecture. However, in practice, both compute and data are typically limited. We conduct experiments using a fixed compute and data budget across all models to focus comparisons solely on the model architecture rather than training resources. To achieve this, we adjust model hyperparameters (mainly, number of layers) within each architecture so that the forward pass time taken per byte is matched, and then train all models for the same number of bytes.
|
| 125 |
+
|
| 126 |
+
Comparison Systems We compare MEGABYTE with both a standard decoder-only Transformer and PerceiverAR (Hawthorne et al., 2022). PerceiverAR extends the original transformer with a single cross-attention layer over a much longer context sequence, and is the best performing general purpose autoregressive model we are aware of and achieves state-of-the-art results across several modalities. We implemented both models in the same codebase, and all models share a similar data loader, preprocessing step, and trainer to avoid any artifacts in our compute-controlled experiments.
|
| 127 |
+
|
| 128 |
+
Training Procedure All models were trained using the Metaseq2 code base Zhang et al. (2022b). The training used the PyTorch framework Paszke et al. (2019), with fairscale to improve memory efficiency through fully sharded model and optimizer states Baines et al. (2021). Mixed precision training was used to improve training efficiency at scale Micikevicius et al. (2017). More training details and various model parameters can be found in Section A.1 in the Appendix. To validate our implementation of PerceiverAR, we reproduced their experiments on downsized ImageNet at 64 pixels. By carefully matching hyperparameters, we achieved a bits per byte (bpb) score of 3.53, compared to the reported 3.54 in the original paper.
|
| 129 |
+
|
| 130 |
+
Inference Methods Several techniques have been proposed for trading off speed for performance during inference with language models, including sliding windows Press et al. (2020) and our strided inference. We only use these methods when comparing with prior published work (Tables 2 and 3).
|
| 131 |
+
|
| 132 |
+
<table><tr><td>Dataset</td><td>Total Bytes</td><td>bytes/doc</td><td>Transformer</td><td>PerceiverAR</td><td>MEGABYTE</td></tr><tr><td>PG-19</td><td>10.1GB</td><td>411,404</td><td>1.057</td><td>1.104</td><td>1.000</td></tr><tr><td>Stories</td><td>21.3GB</td><td>35,265</td><td>1.064</td><td>1.070</td><td>0.978</td></tr><tr><td>Books</td><td>79.7GB</td><td>509,526</td><td>1.097</td><td>1.104</td><td>1.007</td></tr><tr><td>arXiv</td><td>91.5GB</td><td>58,518</td><td>0.816</td><td>0.791</td><td>0.678</td></tr><tr><td>Code</td><td>353.7GB</td><td>7,461</td><td>0.575</td><td>0.546</td><td>0.411</td></tr></table>
|
| 133 |
+
|
| 134 |
+
Table 1: Text dataset sizes and mean document lengths. We also report bpb of various models (Transformer, PerceiverAR, and MEGABYTE) trained with the same compute.
|
| 135 |
+
|
| 136 |
+
<table><tr><td></td><td>Tokenizer</td><td>Vocab</td><td>Context Length</td><td>Validation</td><td>Test</td></tr><tr><td>TransformerXL Rae et al. (2019a)</td><td>SentPiece</td><td>32k</td><td>512+1024</td><td>45.5</td><td>36.3</td></tr><tr><td>CompressiveTransformer Rae et al. (2019a)</td><td>SentPiece</td><td>32k</td><td>512+512+2x512</td><td>43.4</td><td>33.6</td></tr><tr><td>PerceiverAR Hawthorne et al. (2022)</td><td>SentPiece</td><td>32k</td><td>2048</td><td>45.9</td><td>28.9</td></tr><tr><td>BlockRecurrent Hutchins et al. (2022)</td><td>SentPiece</td><td>32k</td><td>1024+recurrence</td><td>-</td><td>26.5</td></tr><tr><td>Transformer byte-level (ours)</td><td>Bytes</td><td>256</td><td>2048</td><td>81.6</td><td>69.4</td></tr><tr><td>PerceiverAR byte-level (ours)</td><td>Bytes</td><td>256</td><td>8192</td><td>119.1</td><td>88.8</td></tr><tr><td>MEGABYTE</td><td>Bytes</td><td>256</td><td>8192</td><td>42.8</td><td>36.4</td></tr></table>
|
| 137 |
+
|
| 138 |
+
Table 2: Larger scale experiments on PG19, converting bits-per-byte to word-level perplexities for comparison with prior work. Results below the line are compute-matched. MEGABYTE outperforms other byte models by a wide margin, and gives results competitive with state-of-the-art models trained on subwords.
|
| 139 |
+
|
| 140 |
+
# 5 Language Modeling
|
| 141 |
+
|
| 142 |
+
We evaluated the performance of MEGABYTE on language modeling on a set of 5 diverse datasets emphasizing long-range dependencies: Project Gutenberg (PG-19), Books, Stories, arXiv, and Code.
|
| 143 |
+
|
| 144 |
+
Datasets We experiment on a range of long form text datasets. The PG-19 dataset Rae et al. (2019b) consists of English-language books written before 1919 and is extracted from the Project Gutenberg online library. The Stories dataset Trinh & Le (2018) is a subset of CommonCrawl data meant to emulate Winograd schemas. Books Gao et al. (2020) is another collection of English-language books. The arXiv dataset contains technical publications written in $\mathrm { I A T _ { E } X }$ from the arXiv online archive. Finally, the Code dataset is a large publicly available dataset of open source code, under Apache, BSD or MIT licenses. More details on dataset sizes and document lengths are shared in Table 1.
|
| 145 |
+
|
| 146 |
+
Controlled Experiments Table 1 lists bpb on each dataset. Each model is trained for 80 billion bytes, and models are scaled to use the same compute budget. We carefully tune hyperparameters for all architectures to best utilize the available compute budget. MEGABYTE consistently outperforms both transformers and PerceiverAR across all datasets. We use the same sets of parameters on all dataset. In all experiments presented in Table 1, transformer has size of 320M with context length of 1024, PerceiverAR has size of 248M with context size of 8192 and latent size of 1024, and MEGABYTE global/local model sizes are 758M/262M with context length of 8192 and patch size of 8.
|
| 147 |
+
|
| 148 |
+
Scaling Experiment We scale up our training data on PG-19 (Table 2), and compare MEGABYTE with byte baselines, as well as converting all results to word-level perplexities to benchmark with stateof-art token based models. We train a byte-level Transformer, PerceiverAR and MEGABYTE models for 400B bytes and the same compute budget using same model parameters as in the controlled experiments. We find that MEGABYTE outperforms other byte-level models by a wide margin at this scale.3 We also compare with the best previously reported numbers for sub-word models. These results may be confounded by differing amounts of compute and tuning used, but show that MEGABYTE gives results competitive with state-of-the-art models trained on subwords. These results suggest that MEGABYTE may allow future large language models to be tokenization-free.
|
| 149 |
+
|
| 150 |
+
# 6 Image Modeling
|
| 151 |
+
|
| 152 |
+
Sequence Modeling on ImageNet We test MEGABYTE on variants of the autoregressive image generation task on ImageNet (Oord et al., 2016), to measure its ability to efficiently use long context. We test on three different resolutions of images, ranging from $6 4 { \times } 6 4$ to $6 4 0 { \times } 6 4 0$ pixels – the latter requiring the effective modeling of sequences with over 1.2M tokens. This generation task becomes increasingly challenging as the image’s resolution grows: doing well on this task requires the modeling of local patterns (textures, lines, etc.) and long-range context that provides information about the high level structure of the image. Inspired by recent works in Vision Transformers (Dosovitskiy et al., 2020), we model image data patch by patch (more details can be found in Appendix D.1).
|
| 153 |
+
|
| 154 |
+
Comparison with State of the Art We train a large MEGABYTE model on ImageNet 64x64 with Global and Local models sized 2.7B and 350M parameters, respectively, for 1.4T tokens. We estimate that training this model consumed less than half the GPU hours we would have needed to reproduce the best PerceiverAR model described by (Hawthorne et al., 2022). As shown in Table 2, MEGABYTE matches the state-of-the-art performance of PerceiverAR whilst using only half the compute.
|
| 155 |
+
|
| 156 |
+
<table><tr><td>ImageNet64</td><td>bpb</td></tr><tr><td>Routing Transformer (Roy et al.,2020)</td><td>3.43</td></tr><tr><td>Combiner (Ren et al., 2021)</td><td>3.42</td></tr><tr><td>Perceiver AR (Hawthorne et al.,2022)</td><td>3.40</td></tr><tr><td>MEGABYTE</td><td>3.40</td></tr></table>
|
| 157 |
+
|
| 158 |
+
Table 3: Bits per byte (bpb) on ImageNet $6 4 { \times } 6 4$ . MEGABYTE matches the current state-of-the-art while only using half the amount of GPU hours to train.
|
| 159 |
+
|
| 160 |
+
<table><tr><td></td><td>Context</td><td>Image64</td><td>Image256</td><td>Image640</td></tr><tr><td>Total len</td><td></td><td>12288</td><td>196608</td><td>1228800</td></tr><tr><td>Transformer</td><td>1024</td><td>3.62</td><td>3.801</td><td>2.847</td></tr><tr><td>Perceiver AR</td><td>12000</td><td>3.55</td><td>3.373</td><td>2.345</td></tr><tr><td>MEGABYTE</td><td>Full</td><td>3.52</td><td>3.158</td><td>2.282</td></tr></table>
|
| 161 |
+
|
| 162 |
+
Table 4: Bits per byte (bpb) on ImageNet with different resolutions. All models use the same compute and data. MEGABYTE scales well to sequences of over 1M tokens.
|
| 163 |
+
|
| 164 |
+
Scaling to higher resolutions We compare three transformer variants (vanilla, PerceiverAR, MEGABYTE) to test scalability to long sequences on increasingly large image resolutions. We use our own implementations of these in the same framework and budget the same amount of GPU hours and data to train each of these model variants.
|
| 165 |
+
|
| 166 |
+
MEGABYTE is able to handle all sequence lengths with a single forward pass of up to 1.2M tokens. We found neither the standard Transformer nor PerceiverAR could model such long sequences at a reasonable model size, so instead we split images into segments of size 1024 and 12000 respectively. For Megabyte, we set patch size as 12 for Image64 and patch size as 192 for Image256 and Image640 datasets. Model sizes are adjusted to match overall training speeds across models and we do not use any form of sliding window evaluation in this experiment. As seen in Table 4, MEGABYTE outperforms baselines across all resolutions in this compute-controlled setting. The precise settings used for each of the baseline models such as context length and number of latents are summarized in Table 12. Results show that MEGABYTE outperforms the other systems at all resolutions, demonstrating an effective model of sequences of over 1M bytes.
|
| 167 |
+
|
| 168 |
+
# 7 Audio Modeling
|
| 169 |
+
|
| 170 |
+
Audio has aspects of both the sequential structure of text and the continuous nature of images, so is an interesting application for MEGABYTE.
|
| 171 |
+
|
| 172 |
+
Raw audio is typically stored as a sequence of 16-bit integer values (one per timestep); a softmax layer would need to output 65,536 probabilities per timestep to model all possible values. To address this issue, various techniques have been developed to reduce the memory and computational requirements of the softmax layer. For instance, van den Oord et al. (2016) apply $\mu$ -law companding transformation and quantizes the input into 256 possible values. Alternatively, van den Oord et al. (2017) model the samples using the discretized mixture of logistics distribution introduced by Salimans et al. (2017). Finally, Kalchbrenner et al. (2018) use a dual softmax technique to produce 8 coarse and 8 fine bits. In our approach, we simplify the audio modeling process by directly reading the bytes (256 possible values) from the audio file and conducting an autoregressive language model on top of that. This greatly streamlines the modeling process, making it easier and more efficient.
|
| 173 |
+
|
| 174 |
+
Our audio modeling approach focuses on $1 6 \ \mathrm { k H z }$ , 16-bit audio, which equates to 32k bytes per one-second clip. We use an extensive audio dataset consisting of 2 terabytes (roughly 18,000 hours) of audio. We use a sequence length of 524,288, a patch size of 32, and a batch size of 32 to facilitate model training. By utilizing these settings, we can effectively train our model on large volumes of audio data, helping to improve its accuracy and efficacy. Our model obtains bpb of 3.477, much lower than the results with perceiverAR (3.543) and vanilla transformer model (3.567). More ablation results are presented in Table 6.
|
| 175 |
+
|
| 176 |
+
<table><tr><td></td><td>Global Size</td><td>(Local) Size</td><td>bpb</td><td>Generation Time (s)</td></tr><tr><td>Transformer</td><td>1</td><td>350M</td><td>1.064</td><td>132</td></tr><tr><td>MEGABYTE</td><td>1.3B</td><td>218M</td><td>0.991</td><td>93</td></tr></table>
|
| 177 |
+
|
| 178 |
+
Table 5: Comparison of bits per byte (bpb) and generation speed of 8192 bytes of transformer model (with context length 1024) and MEGABYTE with context length 8192 and patch size 8.
|
| 179 |
+
|
| 180 |
+
# 8 Analysis
|
| 181 |
+
|
| 182 |
+
We study different behaviors of MEGABYTE. All experiments in the same group use the same compute.
|
| 183 |
+
|
| 184 |
+
Generation speed We also compare the text generation speed between MEGABYTE and a transformer. We compare a 350M parameter baseline transfomer and a MEGABYTE model with a 1.3B parameter Global model and a 218M parameter local model, trained on PG19 with equal compute. As shown in Table 5, the MEGABYTE model achieves much lower perplexity as expected. However, MEGABYTE also generates a sequence of 8192 tokens $40 \%$ faster than transformer, despite having over 4 times the parameters. This speed up is due to the bulk of the parameters being in the Global model, which only needs to be computed once for every 8 tokens, whereas all the parameters in the baseline model are used on every token.
|
| 185 |
+
|
| 186 |
+
Model Components In Table 6, we analyze the significance of different components in the MEGABYTE architecture by studying arXiv, Librilight-L and ImageNet256 datasets. Removing Local (w/o local model) or global (w/o global model) model, we observe a substantial increase in bpb on all datasets, showing that both parts are crucial. The performance of the model without the cross-patch local model (w/o cross-patch local model) is competitive, indicating that the architecture is robust to this modification. We observe slight improvement on the Librilight-L and ImageNet256 datasets by augmenting the MEGABYTE model with a CNN encoder (w/ CNN encoder). This suggests that the MEGABYTE architecture can benefit from integrating alternative encoding mechanisms.
|
| 187 |
+
|
| 188 |
+
Effective Use of Context Long-context models often struggle to benefit from the full context (Sun et al., 2021). Figure 7 shows that later tokens within each context window have a higher likelihood, indicating that MEGABYTE can effectively use at least 8k bytes of context on the PG19 dataset.
|
| 189 |
+
|
| 190 |
+
<table><tr><td></td><td>Arxiv</td><td>Audio</td><td>Image256</td></tr><tr><td>MEGABYTE</td><td>0.6871</td><td>3.477</td><td>3.158</td></tr><tr><td>w/o local model</td><td>1.263</td><td>5.955</td><td>4.768</td></tr><tr><td>w/o global model</td><td>1.373</td><td>3.659</td><td>3.181</td></tr><tr><td>w/o cross-patch attention</td><td>0.6781</td><td>3.481</td><td>3.259</td></tr><tr><td>w/ CNN encoder</td><td>0.6871</td><td>3.475</td><td>3.155</td></tr></table>
|
| 191 |
+
|
| 192 |
+
Table 6: Ablation of MEGABYTE model components. Models with the same dataset are trained using the same compute. The hyperparameters are listed in Table 12.
|
| 193 |
+
|
| 194 |
+

|
| 195 |
+
Table 7: Average log probability assigned to different positions within the context length by MEGABYTE and by a vanilla transformer model on PG19 test set.
|
| 196 |
+
|
| 197 |
+

|
| 198 |
+
Table 8: An illustration of strided inference with patch size 8. Blue and yellow represents two inferences that are shifted by half patch size. Solid line indicates final probablity being taking during strided inference.
|
| 199 |
+
|
| 200 |
+
<table><tr><td>Method</td><td>Inference Cost</td><td>bpb</td></tr><tr><td>Basic Inference</td><td>1X</td><td>0.9079</td></tr><tr><td>w/ Sliding Window</td><td>2X</td><td>0.8918</td></tr><tr><td>w/ Strided Inference</td><td>2X</td><td>0.8926</td></tr><tr><td>w/ Sliding& Strided</td><td>4X</td><td>0.8751</td></tr></table>
|
| 201 |
+
|
| 202 |
+
Table 9: Performance of various inference techniques on the PG19 test set using our best MEGABYTE model.
|
| 203 |
+
|
| 204 |
+
Strided Inference We find that within a single patch, on average, the MEGABYTE performs worse on later tokens within a patch (see Figure 8). Section 2.3 proposes strided inference as a solution, where two forward passes are performed offset by $\textstyle { \frac { P } { 2 } }$ tokens, and results from the first half of each patch are combined. Table 9 shows performance improvements from strided inference, which are additive with the standard sliding window.
|
| 205 |
+
|
| 206 |
+
Patch Size. We experimented with various patch sizes on Image256 dataset and found a wide range of values where MEGABYTE performs similarly. We found similar robustness to patch size choices across all modalities, although the optimal patch size itself can be different across modalities.
|
| 207 |
+
|
| 208 |
+
Local to Global model Size Ratio. We experimented with different Local/Global model size ratios on PG19 dataset. By grouping bytes into patches, MEGABYTE effectively uses $P$ times less tokens for the Global model as on the Local model—enabling us to increase the size of the Global model with reduced cost. We find that a given compute budget is spent optimally when the Global model is larger than the Local model, consistently across all modalities and various patch sizes.
|
| 209 |
+
|
| 210 |
+
<table><tr><td>Patch</td><td>Global Size</td><td>Local Size</td><td>bpb</td></tr><tr><td>48</td><td>125M</td><td>114M (L=11)</td><td>3.178</td></tr><tr><td>192</td><td>125M</td><td>125M (L=12)</td><td>3.158</td></tr><tr><td>768</td><td>125M</td><td>83M(L=8)</td><td>3.186</td></tr></table>
|
| 211 |
+
|
| 212 |
+
Table 10: Effects of patch size on performance on the Image256 dataset. All versions use the same amount of GPU hours and data.
|
| 213 |
+
|
| 214 |
+
<table><tr><td>Global Size</td><td>Local Size</td><td>bpb</td></tr><tr><td>350M (D=1024,L=24)</td><td>290M (D=1024,L=20)</td><td>1.014</td></tr><tr><td>760M (D=1536,L=24)</td><td>262M (D=1024,L=18)</td><td>1.002</td></tr><tr><td>1.3B (D=2048,L=24)</td><td>218M (D=1024,L=15)</td><td>0.991</td></tr></table>
|
| 215 |
+
|
| 216 |
+
Table 11: Effects of Local / Global model size on the PG19 dataset. Increasing the capacity of global model improves performance. Models are compute and data matched.
|
| 217 |
+
|
| 218 |
+
# 9 Related Work
|
| 219 |
+
|
| 220 |
+
Prior research has explored the possibility of improving the efficiency of Transformers on long sequences, primarily motivated by mitigating the quadratic cost of self-attention.
|
| 221 |
+
|
| 222 |
+
Efficient Encoder Models Several related techniques to ours have been developed for transformer encoder architectures but cannot be straightforwardly applied to decoders. In particular, patchifying operations have previously been used in image encoder models such as ViT (Dosovitskiy et al., 2020), and down- and up-sampling operations have been used for text encoders (Clark et al., 2022), but such methods cannot be naively applied to decoder-only models without leaking information to future bytes in the same patch. MEGABYTE generalizes these approaches to an efficient decoder model by using a intra-patch transformer to predict each sequence element’s likelihood, and offseting the inputs to the two models to avoid leaking information. Jaegle et al. (2021) use self-attention on a shorter latent sequence also resembles patchification, but this technique cannot easily be applied to decoder architectures without leaking information to future timesteps.
|
| 223 |
+
|
| 224 |
+
Efficient Decoder models Improving the efficiency of decoder models is harder because of the need to make one prediction per timestep, and not leak information to future timesteps. The most popular approaches can be categorized as (1) chunking sequences into smaller blocks, and propagating information from previous blocks with either recurrence (Dai et al., 2019; Hutchins et al., 2022) or cross-attention (Hawthorne et al., 2022), (2) linear alternatives to attention, which typically involve forms of token-level recurrence (Katharopoulos et al., 2020) or state space models (Gu et al., 2021; Smith et al., 2022; Ma et al., 2022), or (3) sparse approximations of attention (Kitaev et al., 2020; Beltagy et al., 2020; Child et al., 2019; Wu et al., 2022). However, the performance of dense attention means it is typically still chosen for large scale decoders (Touvron et al., 2023; Chowdhery et al., 2022). MEGABYTE takes the alternative approach of decomposing the complete sequence into two shorter sequences, giving sub-quadratic attention. We also note that feedforward networks are the dominant cost in large decoders, not self-attention. Our approach to compressing sequences allows much larger models than would be possible when using large feedforward networks at every timestep.
|
| 225 |
+
|
| 226 |
+
Tokenization The most common approach to shortening sequence lengths in Transformer decoders is to pre-process the input with a form of tokenization, in which multiple bytes are mapped to a single discrete token from a fixed vocabulary. For text, this can be done losslessly using methods such as BPE (Sennrich et al., 2015) and SentencePiece (Kudo & Richardson, 2018), but these approaches can require language-specific heuristics (Radford et al., 2019), limit out-of-domain performance (Sharami et al., 2023), and can affect prompting and truncated sampling in unpredictable ways.4 The amount of high-frequency information in images and audio means that tokenization cannot be performed losslessly, and instead clustering (Hsu et al., 2021) or discrete auto-encoders (Ramesh et al., 2021) are used to compress the inputs, which lose information and likely limit generative model performance. Our patches are analogous to traditional lossless tokens, and the Local model performs the role of mapping a hidden state to a distribution over possible patches.
|
| 227 |
+
|
| 228 |
+
# 10 Conclusion
|
| 229 |
+
|
| 230 |
+
We introduced MEGABYTE, a scaleable architecture for modeling long sequences. MEGABYTE outperforms existing byte-level models across a range of tasks and modalities, allowing large models of sequences of over 1 million tokens. It also gives competitive language modeling results with subword models, which may allow byte-level models to replace tokenization. However, the scale of experiments here is far below those of state-of-the-art language models (Brown et al., 2020), and future work should explore scaling MEGABYTE to much larger models and datasets.
|
| 231 |
+
|
| 232 |
+
# References
|
| 233 |
+
|
| 234 |
+
Baines, M., Bhosale, S., Caggiano, V., Goyal, N., Goyal, S., Ott, M., Lefaudeux, B., Liptchinsky, V., Rabbat, M., Sheiffer, S., Sridhar, A., and Xu, M. FairScale: A general purpose modular PyTorch library for high performance and large scale training. https://github.com/ facebookresearch/fairscale, 2021.
|
| 235 |
+
Beltagy, I., Peters, M. E., and Cohan, A. Longformer: The long-document transformer. arXiv preprint arXiv:2004.05150, 2020.
|
| 236 |
+
Brown, T., Mann, B., Ryder, N., Subbiah, M., Kaplan, J. D., Dhariwal, P., Neelakantan, A., Shyam, P., Sastry, G., Askell, A., et al. Language models are few-shot learners. Advances in neural information processing systems, 33:1877–1901, 2020.
|
| 237 |
+
Child, R., Gray, S., Radford, A., and Sutskever, I. Generating long sequences with sparse transformers. arXiv preprint arXiv:1904.10509, 2019.
|
| 238 |
+
Choromanski, K., Likhosherstov, V., Dohan, D., Song, X., Gane, A., Sarlos, T., Hawkins, P., Davis, J., Mohiuddin, A., Kaiser, L., et al. Rethinking attention with performers. arXiv preprint arXiv:2009.14794, 2020.
|
| 239 |
+
Chowdhery, A., Narang, S., Devlin, J., Bosma, M., Mishra, G., Roberts, A., Barham, P., Chung, H. W., Sutton, C., Gehrmann, S., et al. Palm: Scaling language modeling with pathways. arXiv preprint arXiv:2204.02311, 2022.
|
| 240 |
+
Clark, J. H., Garrette, D., Turc, I., and Wieting, J. Canine: Pre-training an efficient tokenization-free encoder for language representation. Transactions of the Association for Computational Linguistics, 10:73–91, 2022.
|
| 241 |
+
Dai, Z., Yang, Z., Yang, Y., Carbonell, J., Le, Q. V., and Salakhutdinov, R. Transformer-xl: Attentive language models beyond a fixed-length context, 2019. URL https://arxiv.org/abs/1901. 02860.
|
| 242 |
+
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.
|
| 243 |
+
Gao, L., Biderman, S., Black, S., Golding, L., Hoppe, T., Foster, C., Phang, J., He, H., Thite, A., Nabeshima, N., Presser, S., and Leahy, C. The pile: An 800gb dataset of diverse text for language modeling, 2020.
|
| 244 |
+
Gu, A., Goel, K., and Ré, C. Efficiently modeling long sequences with structured state spaces. arXiv preprint arXiv:2111.00396, 2021.
|
| 245 |
+
Hawthorne, C., Jaegle, A., Cangea, C., Borgeaud, S., Nash, C., Malinowski, M., Dieleman, S., Vinyals, O., Botvinick, M., Simon, I., et al. General-purpose, long-context autoregressive modeling with perceiver ar. In International Conference on Machine Learning, pp. 8535–8558. PMLR, 2022.
|
| 246 |
+
Hoffmann, J., Borgeaud, S., Mensch, A., Buchatskaya, E., Cai, T., Rutherford, E., Casas, D. d. L., Hendricks, L. A., Welbl, J., Clark, A., et al. Training compute-optimal large language models. arXiv preprint arXiv:2203.15556, 2022.
|
| 247 |
+
Hsu, W.-N., Bolte, B., Tsai, Y.-H. H., Lakhotia, K., Salakhutdinov, R., and Mohamed, A. Hubert: Self-supervised speech representation learning by masked prediction of hidden units. IEEE/ACM Transactions on Audio, Speech, and Language Processing, 29:3451–3460, 2021.
|
| 248 |
+
Hutchins, D., Schlag, I., Wu, Y., Dyer, E., and Neyshabur, B. Block-recurrent transformers. arXiv preprint arXiv:2203.07852, 2022.
|
| 249 |
+
Jaegle, A., Gimeno, F., Brock, A., Vinyals, O., Zisserman, A., and Carreira, J. Perceiver: General perception with iterative attention. In International conference on machine learning, pp. 4651–4664. PMLR, 2021.
|
| 250 |
+
Kalchbrenner, N., Elsen, E., Simonyan, K., Noury, S., Casagrande, N., Lockhart, E., Stimberg, F., van den Oord, A., Dieleman, S., and Kavukcuoglu, K. Efficient neural audio synthesis. CoRR, abs/1802.08435, 2018. URL http://arxiv.org/abs/1802.08435.
|
| 251 |
+
Kaplan, J., McCandlish, S., Henighan, T., Brown, T. B., Chess, B., Child, R., Gray, S., Radford, A., Wu, J., and Amodei, D. Scaling laws for neural language models. arXiv preprint arXiv:2001.08361, 2020.
|
| 252 |
+
Katharopoulos, A., Vyas, A., Pappas, N., and Fleuret, F. Transformers are rnns: Fast autoregressive transformers with linear attention. In International Conference on Machine Learning, pp. 5156– 5165. PMLR, 2020.
|
| 253 |
+
Kingma, D. P. and Ba, J. Adam: A method for stochastic optimization. In ICLR, 2015.
|
| 254 |
+
Kitaev, N., Kaiser, Ł., and Levskaya, A. Reformer: The efficient transformer. arXiv preprint arXiv:2001.04451, 2020.
|
| 255 |
+
Kudo, T. and Richardson, J. Sentencepiece: A simple and language independent subword tokenizer and detokenizer for neural text processing. arXiv preprint arXiv:1808.06226, 2018.
|
| 256 |
+
Ma, X., Zhou, C., Kong, X., He, J., Gui, L., Neubig, G., May, J., and Zettlemoyer, L. Mega: moving average equipped gated attention. arXiv preprint arXiv:2209.10655, 2022.
|
| 257 |
+
Micikevicius, P., Narang, S., Alben, J., Diamos, G., Elsen, E., Garcia, D., Ginsburg, B., Houston, M., Kuchaiev, O., Venkatesh, G., et al. Mixed precision training. arXiv preprint arXiv:1710.03740, 2017.
|
| 258 |
+
Oord, A. v. d., Kalchbrenner, N., and Kavukcuoglu, K. Pixel Recurrent Neural Networks. ICML, 4:2611–2620, 1 2016. doi: 10.48550/arxiv.1601.06759. URL https://arxiv.org/abs/1601. 06759v3.
|
| 259 |
+
Paszke, A., Gross, S., Massa, F., Lerer, A., Bradbury, J., Chanan, G., Killeen, T., Lin, Z., Gimelshein, N., Antiga, L., et al. PyTorch: An imperative style, high-performance deep learning library. In NeurIPS, 2019.
|
| 260 |
+
Press, O., Smith, N. A., and Lewis, M. Shortformer: Better language modeling using shorter inputs. arXiv preprint arXiv:2012.15832, 2020.
|
| 261 |
+
Radford, A., Wu, J., Child, R., Luan, D., Amodei, D., and Sutskever, I. Language models are unsupervised multitask learners. 2019.
|
| 262 |
+
Rae, J. W., Potapenko, A., Jayakumar, S. M., and Lillicrap, T. P. Compressive transformers for long-range sequence modelling. arXiv preprint arXiv:1911.05507, 2019a.
|
| 263 |
+
Rae, J. W., Potapenko, A., Jayakumar, S. M., and Lillicrap, T. P. Compressive transformers for long-range sequence modelling. arXiv preprint arXiv:1911.05507, 2019b.
|
| 264 |
+
Ramesh, A., Pavlov, M., Goh, G., Gray, S., Voss, C., Radford, A., Chen, M., and Sutskever, I. Zeroshot text-to-image generation. In International Conference on Machine Learning, pp. 8821–8831. PMLR, 2021.
|
| 265 |
+
Ren, H., Dai, H., Dai, Z., Yang, M., Leskovec, J., Schuurmans, D., and Dai, B. Combiner: Full attention transformer with sparse computation cost, 2021. URL https://arxiv.org/abs/2107. 05768.
|
| 266 |
+
Roy, A., Saffar, M., Vaswani, A., and Grangier, D. Efficient content-based sparse attention with routing transformers, 2020. URL https://arxiv.org/abs/2003.05997.
|
| 267 |
+
Salimans, T., Karpathy, A., Chen, X., and Kingma, D. P. Pixelcnn $^ { + + }$ : Improving the pixelcnn with discretized logistic mixture likelihood and other modifications. CoRR, abs/1701.05517, 2017. URL http://arxiv.org/abs/1701.05517.
|
| 268 |
+
Sennrich, R., Haddow, B., and Birch, A. Neural machine translation of rare words with subword units. arXiv preprint arXiv:1508.07909, 2015.
|
| 269 |
+
Sharami, J., Shterionov, D., and Spronck, P. A systematic analysis of vocabulary and bpe settings for optimal fine-tuning of nmt: A case study of in-domain translation. arXiv preprint arXiv:2303.00722, 2023.
|
| 270 |
+
Smith, J. T., Warrington, A., and Linderman, S. W. Simplified state space layers for sequence modeling. arXiv preprint arXiv:2208.04933, 2022.
|
| 271 |
+
Su, J., Lu, Y., Pan, S., Murtadha, A., Wen, B., and Liu, Y. Roformer: Enhanced transformer with rotary position embedding. arXiv preprint arXiv:2104.09864, 2021.
|
| 272 |
+
Sun, S., Krishna, K., Mattarella-Micke, A., and Iyyer, M. Do long-range language models actually use long-range context? arXiv preprint arXiv:2109.09115, 2021.
|
| 273 |
+
Touvron, H., Lavril, T., Izacard, G., Martinet, X., Lachaux, M.-A., Lacroix, T., Rozière, B., Goyal, N., Hambro, E., Azhar, F., et al. Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971, 2023.
|
| 274 |
+
Trinh, T. H. and Le, Q. V. A simple method for commonsense reasoning. arXiv preprint arXiv:1806.02847, 2018.
|
| 275 |
+
van den Oord, A., Dieleman, S., Zen, H., Simonyan, K., Vinyals, O., Graves, A., Kalchbrenner, N., Senior, A. W., and Kavukcuoglu, K. Wavenet: A generative model for raw audio. CoRR, abs/1609.03499, 2016. URL http://arxiv.org/abs/1609.03499.
|
| 276 |
+
van den Oord, A., Li, Y., Babuschkin, I., Simonyan, K., Vinyals, O., Kavukcuoglu, K., van den Driessche, G., Lockhart, E., Cobo, L. C., Stimberg, F., Casagrande, N., Grewe, D., Noury, S., Dieleman, S., Elsen, E., Kalchbrenner, N., Zen, H., Graves, A., King, H., Walters, T., Belov, D., and Hassabis, D. Parallel wavenet: Fast high-fidelity speech synthesis. CoRR, abs/1711.10433, 2017. URL http://arxiv.org/abs/1711.10433.
|
| 277 |
+
Wu, Y., Rabe, M. N., Hutchins, D., and Szegedy, C. Memorizing transformers. arXiv preprint arXiv:2203.08913, 2022.
|
| 278 |
+
Zhang, S., Roller, S., Goyal, N., Artetxe, M., Chen, M., Chen, S., Dewan, C., Diab, M., Li, X., Lin, V., Mihaylov, T., Ott, M., Shleifer, S., Shuster, K., Simig, D., Koura, S., Sridhar, A., Wang, T., Zettlemoyer, L., and Ai, M. OPT: Open Pre-trained Transformer Language Models. 5 2022a. doi: 10.48550/arxiv.2205.01068. URL https://arxiv.org/abs/2205.01068v4.
|
| 279 |
+
Zhang, S., Roller, S., Goyal, N., Artetxe, M., Chen, M., Chen, S., Dewan, C., Diab, M., Li, X., Lin, X. V., et al. Opt: Open pre-trained transformer language models. arXiv preprint arXiv:2205.01068, 2022b.
|
| 280 |
+
|
| 281 |
+
# A Supplementary Material
|
| 282 |
+
|
| 283 |
+
# A.1 Training Details
|
| 284 |
+
|
| 285 |
+
To ensure stable training, we applied gradient clipping with a maximum norm of 1.0 and used the Adam optimizer with $\beta _ { 1 } = 0 . 9$ , $\beta _ { 2 } = 0 . 9 8$ Kingma & Ba (2015). We used the built-in polynomial decay learning rate scheduler in MetaSeq with 500 warmup updates and the end learning rate set to 0. All models are trained with pre-norm and using ReLU activation. We apply a dropout of 0.1 throughout, but we do not apply any dropout to embeddings. We also use weight decay of 0.1. To initialize the weights, we use a variant based on Megatron-LM codebase, which involves using a normal distribution with a mean of zero and a standard deviation of 0.006. We truncate this normal distribution within two standard deviations and observed substantial gain in both training stability and performance.
|
| 286 |
+
|
| 287 |
+
# A.2 Motivation
|
| 288 |
+
|
| 289 |
+
Why is the local model needed? Many of the efficiency advantages of the MEGABYTE design could be realized with the Global model alone, which would resemble a decoder version of ViT (Dosovitskiy et al., 2020). However, the joint distribution over the patch $p ( x _ { t + 1 } , . . , x _ { t + P } | x _ { 0 . . t } )$ has an output space of size $2 5 6 ^ { P }$ so direct modeling is only tractable for very small patches. We could instead factor the joint distribution into conditionally independent distributions $p ( x _ { t + 1 } | x _ { 0 . . t } ) . . p ( x _ { t + P } | x _ { 0 . . t } )$ , but this would greatly limit the model’s expressive power. For example, it would be unable to express a patch distribution such as $50 \%$ cat and $50 \%$ dog, and would instead have to assign probability mass to strings such as cag and dot. Instead, our autoregressive Local model conditions on previous characters within the patch, allowing it to only assign probability to the desired strings.
|
| 290 |
+
|
| 291 |
+
Increasing Parameters for Fixed Compute Transformer models have shown consistent improvements with parameter counts (Kaplan et al., 2020). However, the size of models is limited by their increasing computational cost. MEGABYTE allows larger models for the same cost, both by making self attention sub-quadratic, and by using large feedforward layers across patches rather than individual tokens.
|
| 292 |
+
|
| 293 |
+
Re-use of Established Components MEGABYTE consists of two transformer models interleaved with shifting, reshaping and a linear projection. This re-use increases the likelihood that the architecture will inherit the desirable scaling properties of transformers.
|
| 294 |
+
|
| 295 |
+
# A.3 Model Details
|
| 296 |
+
|
| 297 |
+
As discussed in Section 4, we conduct experiments using a fixed compute and data budget across all models to focus our comparisons solely on the model architecture rather than training resources. To achieve this, we adjust model hyperparameters within each architecture so that the time taken for a single update is matched and then train all models for the same number of updates. We list all of model details in Table 12 and Table 13.
|
| 298 |
+
|
| 299 |
+
<table><tr><td></td><td>Model</td><td>#L</td><td>dmodel</td><td>#H</td><td>dhead</td></tr><tr><td>S1</td><td>125M</td><td>12</td><td>768</td><td>12</td><td>64</td></tr><tr><td>S2</td><td>350M</td><td>24</td><td>1024</td><td>16</td><td>64</td></tr><tr><td>S3</td><td>760M</td><td>24</td><td>1536</td><td>16</td><td>96</td></tr><tr><td>S4</td><td>1.3B</td><td>24</td><td>2048</td><td>32</td><td>64</td></tr><tr><td>S5</td><td>2.7B</td><td>32</td><td>2560</td><td>32</td><td>80</td></tr><tr><td>S6</td><td>6.7B</td><td>32</td><td>4096</td><td>32</td><td>128</td></tr></table>
|
| 300 |
+
|
| 301 |
+
Listing 1: Pseudocode of Megabyte model
|
| 302 |
+
|
| 303 |
+
<table><tr><td>Model</td><td>(Global) Size</td><td>Local Size</td><td>BS</td><td>LR</td><td>Context Length (in bytes)</td></tr><tr><td colspan="6">arXiv</td></tr><tr><td>Transformer</td><td>320M (D=1024,L=22)</td><td>N/A</td><td></td><td>2.00E-04</td><td>1,024</td></tr><tr><td>Perceiver AR</td><td>248M(D=1024,L=17)</td><td>N/A</td><td></td><td>2.00E-04</td><td>8,192 (1024 latents)</td></tr><tr><td>MEGABYTE</td><td>758M(D=2048,L=14)</td><td>262M (D=1024,L=18)</td><td>27248</td><td>2.00E-04</td><td>8,192 (patch size 8)</td></tr><tr><td>w/o Local model</td><td>2.3B (D=2560,L=20)</td><td>N/A</td><td>48</td><td>1.50E-04</td><td>8,192 (patch size 4)</td></tr><tr><td>w/o global model</td><td>N/A</td><td>350M (D=1024,L=24)</td><td>192</td><td>2.00E-04</td><td>8,192 (patch size 8)</td></tr><tr><td>w/o cross-patch Local model</td><td>921M (D=2048,L=17)</td><td>350M(D=1024,L=24)</td><td>48</td><td>2.00E-04</td><td>8,192 (patch size 8)</td></tr><tr><td>w/ CNN encoder</td><td>704M (D=2048,L=13)</td><td>262M (D=1024,L=18)</td><td>48</td><td>2.00E-04</td><td>8,192 (patch size 8)</td></tr><tr><td colspan="6">Image task 64 (Table 2)</td></tr><tr><td>MEGABYTE</td><td>2.7B (D=2560,L=32)</td><td>350M (D=1024,L=24)</td><td>2</td><td>2.00E-04</td><td>12,288 (patch size 12)</td></tr><tr><td colspan="6">Image task 64 (Table 4)</td></tr><tr><td>Transformer</td><td>760M (D=1536,L=24)</td><td>N/A</td><td>512</td><td>3.00E-04</td><td>2.048</td></tr><tr><td>Perceiver AR</td><td>227M(D=1024,L=16)</td><td>N/A</td><td>512</td><td>3.00E-04</td><td>12,288 (1024 latents)</td></tr><tr><td>MEGABYTE</td><td>1.3B (D=2048,L=24)</td><td>1.3B (D=2048,L=24)</td><td>256</td><td>3.00E-04</td><td>12,288 (patch size 12)</td></tr><tr><td colspan="6">Image task 256</td></tr><tr><td>Transformer</td><td>62M (D=768,L=6)</td><td>N/A</td><td>1536</td><td>2.00E-04</td><td>1,024</td></tr><tr><td>Perceiver AR</td><td>62M (D=768,L=6)</td><td>N/A</td><td>256</td><td>2.00E-04</td><td>8,192 (768 latents)</td></tr><tr><td>MEGABYTE</td><td>125M (D=768,L=12)</td><td>125M (D=768,L=12)</td><td>16</td><td>2.00E-04</td><td>196,608 (patch size 192)</td></tr><tr><td>w/o local model</td><td>2.7B (D=4096,L=32)</td><td>N/A</td><td>16</td><td>2.00E-04</td><td>196,608 (patch size 48)</td></tr><tr><td>w/o global model</td><td>125M (D=768,L=12)</td><td>125M (D=768,L=12)</td><td>16</td><td>2.00E-04</td><td>196,608(patch size 192)</td></tr><tr><td>w/o cross-patch Local model</td><td>250M</td><td>156M (D=768,L=15)</td><td>16</td><td>2.00E-04</td><td>196,608 (patch size 192)</td></tr><tr><td>w/ CNN encoder</td><td>125M (D=768,L=12)</td><td>125M (D=768,L=12)</td><td>16</td><td>2.00E-04</td><td>196,608 (patch size 192)</td></tr><tr><td colspan="6">Image task 640</td></tr><tr><td>Transformer</td><td>83M (D=768,L=8)</td><td>N/A</td><td></td><td>3.00E-04</td><td>1,024</td></tr><tr><td>Perceiver AR</td><td>62M (D=768,L=6)</td><td>N/A</td><td>4800 2048</td><td>3.00E-04</td><td>4,096 (1024 latents)</td></tr><tr><td>MEGABYTE</td><td>125M (D=768,L=12)</td><td>83M (D=768,L=8)</td><td>32</td><td>3.00E-04</td><td>1,228,800 (192 patch size)</td></tr><tr><td colspan="6">audio</td></tr><tr><td>Transformer</td><td>135M(D=768,L=13)</td><td>N/A</td><td>2048</td><td>2.00E-04</td><td>1024</td></tr><tr><td>Perceiver AR</td><td>62M(D=768,L=6)</td><td>N/A</td><td>384</td><td>2.00E-04</td><td>8,192 (1024 latents)</td></tr><tr><td>MEGABYTE</td><td>350M(D=1024,L=24)</td><td>125M (D=768,L=12)</td><td>256</td><td>2.00E-04</td><td>524,288 (32 patch size)</td></tr><tr><td>w/o local model</td><td>2.7B (D=4096,L=32)</td><td>125M (D=768,L=12)</td><td>256</td><td>2.00E-04</td><td>524,288(32 patch size)</td></tr><tr><td>w/o global model</td><td>350M(D=1024,L=24)</td><td>125M(D=768,L=12)</td><td>256</td><td>2.00E-04</td><td>524,288 (32 patch size)</td></tr><tr><td>w/o cross-patch Local model</td><td>350M(D=1024,L=24)</td><td>146M(D=768,L=14)</td><td>256</td><td>2.00E-04</td><td>524,288 (32 patch size)</td></tr><tr><td>w/ CNN encoder</td><td>350M (D=1024,L=24)</td><td>125M (D=768,L=12)</td><td>256</td><td>2.00E-04</td><td>524,288 (32 patch size)</td></tr></table>
|
| 304 |
+
|
| 305 |
+
Table 13: Model architecture details. We report the model size, the embedding size (D), number of layaers(L), total batch size (BS), learning rate(LR), and context length. When we vary the number of model layers from the standard amount for the given size (Table 12), we note this accordingly. For PerceiverAR models, we note the number of latents used, and for MEGABYTE models we note the patch sizes.
|
| 306 |
+
|
| 307 |
+
# B Pseudocode
|
| 308 |
+
|
| 309 |
+
class MegaByteDecoder : def _init_ self , global_args , local_args , patch_size , ) : self . pad $\qquad = \quad 0$ self . patch_size $=$ patch_size self . globalmodel $=$ TransformerDecoder ( global_args ) self . localmodel $=$ TransformerDecoder ( local_args ) def forward ( self , bytes , ) : bytes_global , bytes_local $=$ self . prepare_input ( bytes )
|
| 310 |
+
|
| 311 |
+
global_bytes_embedded $=$ self . globalmodel . embed ( bytes_global ) global_in $=$ rearrange ( global_bytes_embedded , "b (t p) e -> b t (p e)", $\mathtt { p } =$ self . patch_size , ) global_output $=$ self . globalmodel ( global_in ) global_output_reshaped $=$ rearrange ( global_output , "b t (p e) -> (b t) p e", p = self . patch_size , ) local_bytes_embedded $=$ self . localmodel . embed ( bytes_local ) local_in $=$ local_bytes_embedded $^ +$ global_output_reshaped local_output $=$ self . localmodel ( local_in ) batch_size $=$ bytes_global . shape [0] x $=$ rearrange ( local_output , "(b t) l v -> b (t l) v", b = batch_size ) return x def prepare_input ( self , bytes ) : padding_global $=$ bytes . new ( bytes . shape [0] , self . patch_size ) . fill_ ( self . pad ) bytes_global $=$ torch . cat (( padding_global , bytes [: , : - self . patch_size ]) , -1) bytes_input $=$ rearrange ( bytes , "b (t p) -> (b t) p", $\mathtt { p } = \mathtt { s e l f }$ . patch_size ) padding_local $=$ bytes_input . new ( bytes_input . shape [0] , 1) . fill_ ( self . pad ) bytes_local $=$ torch . cat (( padding_local , bytes_input [: , : -1]) , -1) return bytes_global , bytes_local
|
| 312 |
+
|
| 313 |
+
# C PerceiverAR Implementation
|
| 314 |
+
|
| 315 |
+
To reproduce PerceiverAR in a compute-controlled setting we extended the standard transformer implementation in metaseq with an additonal cross attention layer to compute the latents and match the architecture of PerceiverAR. We trained the model by sampling random spans from each text, matching the procedure used in the PerceiverAR codebase. To be consistent with the original work, we use sliding window evaluation with a stride of num_latents/2 unless otherwise noted. In several cases we used the standard metaseq implementation as opposed to specific techniques reported in the original paper: 1) we used standard attention dropout instead of cross-attention dropout 2) We did not implement chunked attention. We verified our implementation by reproducing the "Standard Ordering" experiments in Table 5 of the Perceiver AR paper. After carefully matching context size, number of latents, the amount of data and training steps used and learning rate, we achieved $3 . 5 3 \mathrm { b p b }$ vs 3.54 reported in the original paper.
|
| 316 |
+
|
| 317 |
+
# D More results
|
| 318 |
+
|
| 319 |
+
# D.1 Patch scan Implementation
|
| 320 |
+
|
| 321 |
+
Images have a natural structure, containing a grid of $n \times n$ pixels each composed of 3 bytes (corresponding to color channels). We explore two ways of converting images to sequences for modeling (see Figure 4). Firstly, raster scan where the pixels are linearized into 3 bytes and concatenated row-by-row. Secondly, patch scan where we create patches of shape $p \times p \times 3$ bytes where $p = { \sqrt { \frac { P } { 3 } } }$ , and then use a raster scan both within and between patches. Unless otherwise specified, MEGABYTE models use patch scan for image data.
|
| 322 |
+
|
| 323 |
+

|
| 324 |
+
Figure 4: Two ways to model 2D data sequentially. Left, raster scan, by taking bytes row by row and left to right; right, patch scan, where we first split an image into patches, and do raster scan across patches and within a patch. $( \mathrm { T } { = } 3 6 , \mathrm { K } { = } 9 , \mathrm { P } { = } 4 )$ .
|
| 325 |
+
|
| 326 |
+
# D.2 Patch scan vs Raster scan
|
| 327 |
+
|
| 328 |
+
The patch scan method is inspired by recent works in Vision Transformers (Dosovitskiy et al., 2020), and it is more effective than raster scan for modeling image sequencing. We found it improves both MEGABYTE and Perceiver AR.
|
| 329 |
+
|
| 330 |
+
<table><tr><td></td><td>(Global) Size</td><td>Local Size</td><td>context</td><td>bpb</td></tr><tr><td>MEGABYTE (patch scan)</td><td>62M (D=768,L=6)</td><td>N/A</td><td>8,192 (768 latents)</td><td>3.158</td></tr><tr><td>MEGABYTE (raster scan)</td><td>62M (D=768,L=6)</td><td>N/A</td><td>8,192 (768 latents)</td><td>3.428</td></tr><tr><td>Perceiver AR (patch scan)</td><td>125M (D=768,L=12)</td><td>125M (D=768,L=12)</td><td>196,608 (patch size 192)</td><td>3.373</td></tr><tr><td>Perceiver AR (raster scan)</td><td>125M (D=768,L=12)</td><td>125M (D=768,L=12)</td><td>196,608 (patch size 192)</td><td>3.552</td></tr></table>
|
| 331 |
+
|
| 332 |
+
Table 14: ImageNet256 performance with patch scan vs raster scan for MEGABYTE and Perceiver AR.
|
| 333 |
+
|
| 334 |
+
# D.3 Longer sequence modeling
|
| 335 |
+
|
| 336 |
+
For our $\mathsf { p g l 9 }$ scaling experiment, we also use longer context length for MEGABYTE. The results are shown in Table 15. With longer sequence, we didn’t observer further improvement, consistent with findings in Hawthorne et al. (2022). We think we will benefit more from longer sequence when we futher scale up the model size and data.
|
| 337 |
+
|
| 338 |
+
<table><tr><td></td><td>context</td><td>bpb</td></tr><tr><td>MEGABYTE</td><td>8,192 (patch size 8)</td><td>0.8751</td></tr><tr><td>MEGABYTE</td><td>16,384 (patch size 8)</td><td>0.8787</td></tr></table>
|
| 339 |
+
|
| 340 |
+
Table 15: Longer sequence for PG19 dataset. For both experiments, we set global model as 1.3b, local model as $3 5 0 \mathrm { m }$ , and MEGABYTE patch size as 8.
|
md/dev/K0E_F0gFDgA/K0E_F0gFDgA.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/Ms6QZafNv01/Ms6QZafNv01.md
ADDED
|
@@ -0,0 +1,493 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Optimal algorithms for group distributionally robust optimization and beyond
|
| 2 |
+
|
| 3 |
+
Anonymous Author(s)
|
| 4 |
+
Affiliation
|
| 5 |
+
Address
|
| 6 |
+
email
|
| 7 |
+
|
| 8 |
+
# Abstract
|
| 9 |
+
|
| 10 |
+
1 Distributionally robust optimization (DRO) can improve the robustness and fairness
|
| 11 |
+
2 of learning methods. In this paper, we devise stochastic algorithms for a class
|
| 12 |
+
3 of DRO problems including group DRO, subpopulation fairness, and empirical
|
| 13 |
+
4 conditional value at risk (CVaR) optimization. Our new algorithms achieve faster
|
| 14 |
+
5 convergence rates than existing algorithms for multiple DRO settings. We also
|
| 15 |
+
6 provide a new information-theoretic lower bound that implies our bounds are tight
|
| 16 |
+
7 for group DRO. Empirically, too, our algorithms outperform known methods.
|
| 17 |
+
|
| 18 |
+
# 8 1 Introduction
|
| 19 |
+
|
| 20 |
+
9 Commonly, machine learning models are trained to optimize the average performance. However,
|
| 21 |
+
10 such models may not perform equally well among all demographic subgroups due to a hidden bias in
|
| 22 |
+
11 the training set or distribution shift in training and test phases [Hovy and Søgaard, 2015; Hashimoto
|
| 23 |
+
12 et al., 2018; Martinez et al., 2021; Duchi and Namkoong, 2021]. Biases in datasets are also directly
|
| 24 |
+
13 related to fairness concerns in machine learning [Buolamwini and Gebru, 2018; Jurgens et al., 2017].
|
| 25 |
+
14 Recently, various algorithms based on distributionally robust optimization (DRO) have been proposed
|
| 26 |
+
15 to address these problems [Hovy and Søgaard, 2015; Hashimoto et al., 2018; Hu et al., 2018; Oren et
|
| 27 |
+
16 al., 2019; Williamson and Menon, 2019; Sagawa et al., 2020; Curi et al., 2020; Zhang et al., 2021;
|
| 28 |
+
17 Martinez et al., 2021; Duchi and Namkoong, 2021]. However, these algorithms are often highly
|
| 29 |
+
18 tailored to each specific DRO formulation. Furthermore, it is often unclear whether these proposed
|
| 30 |
+
19 algorithms are optimal in terms of the convergence rate. Are there a unified algorithmic methodology
|
| 31 |
+
20 and a lower bound for these problems?
|
| 32 |
+
21 Contributions. In this paper, we study a general class of DRO problems, which includes group
|
| 33 |
+
22 DRO [Hu et al., 2018; Oren et al., 2019; Sagawa et al., 2020], subpopulation fairness [Martinez et
|
| 34 |
+
23 al., 2021], conditional value at risk (CVaR) optimization [Curi et al., 2020], and many others. Let
|
| 35 |
+
24 $\boldsymbol \Theta \subseteq \mathbb { R } ^ { n }$ be a convex set of model parameters and $\ell ( \theta ; z ) : \Theta \to \mathbb { R } _ { + }$ be a convex loss of the model
|
| 36 |
+
25 with parameter $\theta$ with respect to data point $z$ . The data point $z$ may be drawn from one out of $m$
|
| 37 |
+
26 distributions $P _ { 1 } , \ldots , P _ { m }$ which are accessible via a stochastic oracle that returns an i.i.d. sample
|
| 38 |
+
27 $z \sim P _ { i }$ . Let $Q$ be a convex subset of the probability simplex in $\mathbb { R } ^ { m }$ that contains the uniform vector,
|
| 39 |
+
28 i.e., $( 1 / m , \ldots , 1 / m ) \in Q$ . Our DRO formulation is as follows:
|
| 40 |
+
|
| 41 |
+
$$
|
| 42 |
+
\operatorname* { m i n } _ { \theta \in \Theta } \operatorname* { m a x } _ { q \in Q } \sum _ { i = 1 } ^ { m } q _ { i } \operatorname* { \bf { E } } _ { z \sim P _ { i } } [ \ell ( \theta ; z ) ] .
|
| 43 |
+
$$
|
| 44 |
+
|
| 45 |
+
29 If $Q$ are the probability simplex and scaled $k$ -set polytope, we can recover group DRO [Sagawa et
|
| 46 |
+
30 al., 2020] and subpopulation fairness [Martinez et al., 2021], respectively. Moreover, we formulate
|
| 47 |
+
31 a new, more general fairness concept based on weighted rankings with $Q$ being a permutahedron,
|
| 48 |
+
32 which includes these special cases; see Section 2 for details.
|
| 49 |
+
|
| 50 |
+
Submitted to 36th Conference on Neural Information Processing Systems (NeurIPS 2022). Do not distribute.
|
| 51 |
+
|
| 52 |
+
Table 1: Summary of convergence results for group DRO. Here, $m$ denotes the number of groups, $n$ the dimension of $\theta$ , $G$ the Lipschitz constant of loss function $\ell$ , $D$ the diameter of feasible set $\Theta$ , $M$ the range of loss function $\ell$ , and $T$ the number of calls to stochastic oracle.
|
| 53 |
+
|
| 54 |
+
<table><tr><td>reference</td><td>convergence rate E[εr]</td><td>iteration complexity</td><td>lower bound</td><td></td></tr><tr><td>[Sagawa et al., 2020]</td><td>0(m</td><td>G2 D²+M2 log m T</td><td>O(m + n) + proj. onto Θ</td><td rowspan="3">( G²D²+M2m T (Theorem 5)</td></tr><tr><td>Ours (Theorem 2)</td><td></td><td>T</td><td>O(m + n) + proj. onto Θ</td></tr><tr><td>Ours (Theorem 3)</td><td>0(√</td><td>G²D²+M²m) T</td><td>O(m + n) + proj. onto Θ + solving scalar equation</td></tr></table>
|
| 55 |
+
|
| 56 |
+
33 For our general DRO, we devise an efficient stochastic gradient algorithm. Furthermore, we show that
|
| 57 |
+
34 it achieves the information-theoretic optimal convergence rate for group DRO. Our main technical
|
| 58 |
+
35 contributions are as follows;
|
| 59 |
+
|
| 60 |
+
• We provide a generic stochastic gradient algorithm for our general DRO. By specializing it in the group DRO setting, we provide two algorithms (GDRO-EXP3 and GDRO-TINF)√ that improve the rate of Sagawa et al. [2020] by a factor of $\Omega ( { \sqrt { m } } )$ with the almost same complexity per iteration; see Table 1. Furthermore, our generic algorithm can be specialized to improve the convergence rate of Curi et al. [2020] for subpopulation fairness (a.k.a. empirical CVaR optimization). Finally, we show that our algorithm runs efficiently if $Q$ is a permutahedron, which includes all aforementioned subclasses.
|
| 61 |
+
• We prove a matching information-theoretic lower bound for the convergence rate of group DRO. This implies that no algorithm can improve the convergence rate of GDRO-TINF (up to a constant factor). To the best of our knowledge, this is the first information-theoretic lower bound for group DRO.
|
| 62 |
+
• Our experiments on real-world and synthetic datasets show that our algorithms also empirically outperform the known algorithm, supporting our theoretical analysis.
|
| 63 |
+
|
| 64 |
+
# 49 1.1 Our techniques
|
| 65 |
+
|
| 66 |
+
50 Algorithms. The core idea of our algorithms is stochastic no-regret dynamics [Hazan, 2016]. We
|
| 67 |
+
51 regard DRO (1) as a two-player zero-sum game between a player who picks $\theta \in \Theta$ and another player
|
| 68 |
+
52 who picks $q \in Q$ . The two players iteratively update their solution using online learning algorithms;
|
| 69 |
+
53 in particular, we will use online gradient descent (OGD) [Zinkevich, 2003] and online mirror descent
|
| 70 |
+
54 (OMD) [Cesa-Bianchi and Lugosi, 2006] for the $\theta$ -player and $q$ -player, respectively. In addition, we
|
| 71 |
+
55 need to estimate gradients for both players, since the objective function of our DRO is stochastic and
|
| 72 |
+
56 we cannot obtain exact gradients.
|
| 73 |
+
57 The convergence rate of stochastic no-regret dynamics depends on the expected regret of OGD and
|
| 74 |
+
58 OMD. To obtain the optimal convergence rate, we must carefully choose the regularizer in OMD as
|
| 75 |
+
59 well as gradient estimators, exploiting the structure of our DRO. In particular, we need to balance
|
| 76 |
+
60 the variance of gradient estimators and the diameter terms in both OGD and OMD. This is the most
|
| 77 |
+
61 challenging part of the algorithm design. Inspired by adversarial multi-armed bandit algorithms,
|
| 78 |
+
62 we design gradient estimators for no-regret dynamics of OGD and OMD in our DRO. Indeed, our
|
| 79 |
+
63 algorithms for group DRO (GDRO-EXP3 and GDRO-TINF) are based on adversarial multi-armed
|
| 80 |
+
64 bandit algorithms, EXP3 [Auer et al., 2003] and Tsallis-INF [Zimmert and Seldin, 2021], respectively,
|
| 81 |
+
65 hence the name. Although each building block (OGD, OMD, and gradient estimators) is fairly known
|
| 82 |
+
66 in the literature, we need to put them together in the right combination to obtain the optimal rate.
|
| 83 |
+
67 Lower bound. For the lower bound, we carefully design a family of group DRO instances for which
|
| 84 |
+
68 any algorithm requires a certain number of queries to achieve a good objective value. To bound
|
| 85 |
+
69 the number of queries, we use information-theoretic tools such as Le Cam’s lemma and bound the
|
| 86 |
+
70 Kullback-Leibler divergence between Bernoulli distributions. Such tools are also used at the heart of
|
| 87 |
+
71 lower bounds for stochastic convex optimization [Agarwal et al., 2012] and adversarial multi-armed
|
| 88 |
+
72 bandits [Auer et al., 2003], but the connection to those settings is much more subtle here, and our
|
| 89 |
+
73 construction is specifically designed for group DRO-type problems.
|
| 90 |
+
75 DRO is a wide field ranging from robust optimization to machine learning and statistics [Goh and Sim,
|
| 91 |
+
76 2010; Bertsimas et al., 2018], whose original idea dates back to Scarf [1958]. Popular choices of the
|
| 92 |
+
77 uncertainty set in DRO include balls around an empirical distribution in Wasserstein distance [Esfahani
|
| 93 |
+
78 and Kuhn, 2018; Blanchet et al., 2019], $f$ -divergence [Namkoong and Duchi, 2016; Duchi and
|
| 94 |
+
79 Namkoong, 2021], $\chi ^ { 2 }$ -divergence [Staib et al., 2019], and maximum mean discrepancy [Staib and
|
| 95 |
+
80 Jegelka, 2019; Kirschner et al., 2020].
|
| 96 |
+
81 DRO algorithms have been mainly studied for the offline setting, i.e., algorithms can access all data
|
| 97 |
+
82 points of the empirical distribution. Note that our DRO is not offline because the group distributions
|
| 98 |
+
83 are given by the stochastic oracles. Namkoong and Duchi [2016] proposed stochastic gradient
|
| 99 |
+
84 algorithms for offline DRO with $f$ -divergence uncertainty sets. Curi et al. [2020] used no-regret
|
| 100 |
+
85 dynamics for empirical CVaR minimization. Their algorithm invokes sampling from $k$ -DPP in each
|
| 101 |
+
86 iteration, which is more computationally demanding than our algorithm. Furthermore, our algorithm
|
| 102 |
+
87 gets rid of an $O ( \log m )$ factor in the convergence rate using the Tsallis entropy regularizer; see
|
| 103 |
+
88 Theorem 4. Qi et al. [2021]; Jin et al. [2021] devised stochastic gradient algorithms for several DRO
|
| 104 |
+
89 with non-convex losses.
|
| 105 |
+
90 Agarwal et al. [2012] gave a lower bound for stochastic convex optimization, which is a special case
|
| 106 |
+
91 of our DRO with only one distribution. Recently, Carmon et al. [2021] showed a lower bound for
|
| 107 |
+
92 minimax problem $\begin{array} { r } { \operatorname* { m i n } _ { x } \operatorname* { m a x } _ { i = 1 } ^ { m } f _ { i } ( x ) } \end{array}$ for non-stochastic Lipschitz convex $f _ { i }$ . Our lower bound deals
|
| 108 |
+
93 with the stochastic functions, so this result does not apply.
|
| 109 |
+
94 In this paper, we assume that the group information is given in advance. However, the group
|
| 110 |
+
95 information might not be easy to define in practice. Bao et al. [2021] propose a simple method to
|
| 111 |
+
96 define groups for classification problems based on mistakes of models in the training phase. Their
|
| 112 |
+
97 method often generates group DRO instances with large $m$ . Our algorithms are more efficient for
|
| 113 |
+
98 such group DRO thanks to the better dependence on $m$ in the convergence rate.
|
| 114 |
+
99 No-regret dynamics is a well-studied method for solving two-player zero-sum games [Cesa-Bianchi
|
| 115 |
+
100 and Lugosi, 2006]. For non-stochastic convex-concave games, one can achieve $O ( 1 / T )$ convergence
|
| 116 |
+
101 via predictable sequences [Rakhlin and Sridharan, 2013]. This result does not apply to our setting
|
| 117 |
+
102 because our DRO is a stochastic game.
|
| 118 |
+
103 Notations. Throughout the paper, $m$ denotes the number of distributions (groups) and $n$ denotes
|
| 119 |
+
104 the dimension of a variable $\theta$ . For a positive integer $m$ , we write $[ m ] : = \{ 1 , \ldots , m \}$ . The orthogonal
|
| 120 |
+
105 projection onto set $\Theta$ is denoted by $\mathrm { p r o j } _ { \Theta }$ . The ith standard unit vector is denoted by $\mathbf { e } _ { i }$ and the
|
| 121 |
+
106 all-one vector is denoted by 1. The probability simplex in $\mathbb { R } ^ { m }$ is denoted by $\Delta _ { m }$ .
|
| 122 |
+
|
| 123 |
+
# 107 2 Examples contained in our general DRO
|
| 124 |
+
|
| 125 |
+
108 In this section, we show how several DRO formulations in the literature can be phrased in our general
|
| 126 |
+
109 DRO formulation (1). In addition, we propose a novel fairness constraint based on weighted rankings
|
| 127 |
+
110 using our general DRO.
|
| 128 |
+
111 Group DRO. When $Q$ equals the probablility simplex, we obtain group DRO [Hu et al., 2018;
|
| 129 |
+
112 Oren et al., 2019; Sagawa et al., 2020]:
|
| 130 |
+
|
| 131 |
+
$$
|
| 132 |
+
\operatorname* { m i n } _ { \theta \in \Theta } \operatorname* { m a x } _ { i = 1 } ^ { m } \ \underset { z \sim P _ { i } } { \mathbf { E } } [ \ell ( \theta ; z ) ] .
|
| 133 |
+
$$
|
| 134 |
+
|
| 135 |
+
113 That is, group DRO aims to minimize the expected loss in the worst group, thereby ensuring better
|
| 136 |
+
114 performance across all groups.
|
| 137 |
+
115 Empirical CVaR, Subpopulation fairness, Average top- $k$ worst group loss. Group DRO may
|
| 138 |
+
116 yield overly pessimistic solutions. For instance, the groups might be automatically generated by other
|
| 139 |
+
117 algorithms (such as one in Bao et al. [2021]) and there might exist a few “outlier” groups that make
|
| 140 |
+
118 the group DRO objective trivial.
|
| 141 |
+
|
| 142 |
+
119 For such a case, we can restrict $Q$ to a small subset of the probability simplex so that the solution cannot put large weights on a few outlier groups. Especially, let 120 $Q = \left\{ q \in \Delta _ { m } : 0 \leq q _ { i } \leq { \frac { 1 } { p m } } \right\}$ for
|
| 143 |
+
|
| 144 |
+
121 some parameter $p \in ( 0 , 1 )$ , i.e., $Q$ is a scaled $k$ -set polytope. The intuition behind the choice of $Q$
|
| 145 |
+
122 is that, by limiting the largest entry of $q$ to $1 / p m$ , DRO would optimize the expected loss over the
|
| 146 |
+
123 worst $p$ -fraction subgroups of $m$ groups. Therefore, if the fraction of outlier groups is sufficiently
|
| 147 |
+
124 small compared to $p$ , then $p$ -fraction subgroups must contain “inlier” groups as well. Therefore, it is
|
| 148 |
+
125 likely that DRO with $Q$ finds solutions more robust than group DRO.
|
| 149 |
+
126 When $P _ { i }$ is the Dirac measure of data $z _ { i }$ , then the resulting DRO is empirical CVaR optimization [Curi
|
| 150 |
+
127 et al., 2020]. In the fairness context, the same problem is called subpopulation fairness [Williamson
|
| 151 |
+
128 and Menon, 2019; Martinez et al., 2021; Duchi and Namkoong, 2021].
|
| 152 |
+
129 If $p \ = \ m / k$ for some positive integer $k$ , the resulting DRO is the average top- $k$ worst group
|
| 153 |
+
130 loss [Zhang et al., 2021]:
|
| 154 |
+
|
| 155 |
+
$$
|
| 156 |
+
\operatorname* { m i n } _ { \theta \in \Theta } \frac { 1 } { k } \sum _ { i = 1 } ^ { k } L _ { i } ^ { \downarrow } ( \theta ) ,
|
| 157 |
+
$$
|
| 158 |
+
|
| 159 |
+
where 131 $L _ { i } ^ { \downarrow } ( \theta )$ denotes the the $i$ th largest population group loss of $\theta$ . More precisely, let $L _ { i } ( \theta ) =$ 132 $\mathbf { E } _ { z \sim P _ { i } } [ \ell ( \theta ; z ) ]$ for $i \in [ m ]$ and sort them in the non-increasing order: $L _ { 1 } ^ { \downarrow } ( \theta ) \ge \cdots \ge L _ { m } ^ { \downarrow } ( \theta )$ .
|
| 160 |
+
|
| 161 |
+
133 Weighted ranking of group losses. The aforementioned DRO formulations are special cases of the
|
| 162 |
+
134 following DRO, which we call the weighted ranking of group losses. Let $\alpha \in \Delta ^ { m }$ be a fixed vector
|
| 163 |
+
135 with non-increasing entries. Let $Q$ be the permutahedron of $\alpha$ , the convex hull of $( \alpha _ { \sigma ( 1 ) } , \ldots , \alpha _ { \sigma ( m ) } )$
|
| 164 |
+
136 for all permutations $\sigma$ of $[ m ]$ . Then, the resulting DRO is
|
| 165 |
+
|
| 166 |
+
$$
|
| 167 |
+
\operatorname* { m i n } _ { \theta \in \Theta } \sum _ { i = 1 } ^ { m } \alpha _ { i } L _ { i } ^ { \downarrow } ( \theta ) .
|
| 168 |
+
$$
|
| 169 |
+
|
| 170 |
+
137 Group DRO corresponds to $\alpha = ( 1 , 0 , \ldots , 0 )$ and the average top- $k$ worst group losses corresponds 138 to $\alpha \overset { \cdot } { = } ( 1 / k , \ldots , \bar { 1 ^ { \prime } } k , 0 , \ldots , 0 )$ . Another example that is contained in none of the above examples is {zk times
|
| 171 |
+
|
| 172 |
+
139 lexicographic minimax fairness [Diana et al., 2021]. The goal of lexicographical minimax fairness
|
| 173 |
+
140 is to find $\theta \in \Theta$ such that the sequence $( L _ { 1 } ^ { \downarrow } ( \theta ) , \dots , L _ { m } ^ { \downarrow } ( \theta ) )$ is lexicographically minimum. This
|
| 174 |
+
141 corresponds to $\alpha$ with sufficiently varied entries, i.e., $\alpha _ { 1 } \gg \alpha _ { 2 } \gg \cdot \cdot \cdot \gg \alpha _ { m }$ .
|
| 175 |
+
|
| 176 |
+
# 142 3 Algorithms
|
| 177 |
+
|
| 178 |
+
143 In this section, we describe our algorithms. First, we present a generic algorithm for our general
|
| 179 |
+
144 DRO (1) and provide a unified convergence analysis in Section 3.1. Then, we specialize it into two
|
| 180 |
+
145 concrete algorithms for group DRO (2) in Section 3.2. We sketch algorithms for the average of top- $k$
|
| 181 |
+
146 group losses and weighted ranking of group loss in Section 3.3.
|
| 182 |
+
|
| 183 |
+
# 7 3.1 Algorithm for the general case
|
| 184 |
+
|
| 185 |
+
148 We present our algorithm for geranal DRO (1). At a high level, our algorithm can be regarded as
|
| 186 |
+
149 stochastic no-regret dynamics. Let us denote $\begin{array} { r } { L ( \boldsymbol { \theta } , \boldsymbol { q } ) : = \sum _ { i = 1 } ^ { m } q _ { i } \mathbf { E } _ { z \sim P _ { i } } [ \ell ( \boldsymbol { \theta } ; z ) ] } \end{array}$ . Imagine that the
|
| 187 |
+
150 $\theta$ -player and $q$ -player run online algorithms $\scriptstyle A _ { \theta }$ and $A _ { q }$ , respectively, to solve the minimax problem
|
| 188 |
+
151 $\begin{array} { r } { \operatorname* { m i n } _ { \theta \in \Theta } \operatorname* { m a x } _ { q \in Q } L ( \theta , q ) } \end{array}$ . That is, for $t = 1 , \dots , T$ ,
|
| 189 |
+
|
| 190 |
+
• $\theta _ { t } \in \Theta$ and $q _ { t } \in Q$ are determined by $\scriptstyle A _ { \theta }$ and $A _ { q }$ , respectively.
|
| 191 |
+
• Both players feed gradient estimators $\hat { \nabla } _ { \theta , t }$ and $\hat { \nabla } _ { \boldsymbol { q } , t }$ to $\scriptstyle A _ { \theta }$ and $A _ { q }$ , respectively. Here, $\mathbf { E } [ \hat { \nabla } _ { \boldsymbol { \theta } , t } ] = \nabla _ { \boldsymbol { \theta } } L ( \theta _ { t } , q _ { t } )$ and $\mathbf { E } [ \hat { \nabla } _ { q , t } ] = \nabla _ { q } L ( \theta _ { t } , q _ { t } )$ .
|
| 192 |
+
|
| 193 |
+
155 Let
|
| 194 |
+
|
| 195 |
+
$$
|
| 196 |
+
\varepsilon _ { T } : = \operatorname* { m a x } _ { q \in Q } L ( \bar { \theta } _ { 1 : T } , q ) - \operatorname* { m i n } _ { \theta \in \Theta } \operatorname* { m a x } _ { q \in Q } L ( \theta , q )
|
| 197 |
+
$$
|
| 198 |
+
|
| 199 |
+
be the optimality156 convergence rate of the averavia regrets iterand $\begin{array} { r } { \bar { \theta } _ { 1 : T } = \frac { 1 } { T } \sum _ { t = 1 } ^ { T } \theta _ { t } } \end{array}$ . We can bound the eorithms (see Appendix ectedfor a $\mathbf { E } [ \varepsilon _ { T } ]$ $R _ { \theta }$ $R _ { q }$ $\mathbf { A }$ 158 formal definition), i.e.,
|
| 200 |
+
|
| 201 |
+
$$
|
| 202 |
+
\mathbf { E } [ \varepsilon _ { T } ] \leq \frac { \mathbf { E } [ R _ { \theta } ( T ) ] + \mathbf { E } [ R _ { q } ( T ) ] } { T } .
|
| 203 |
+
$$
|
| 204 |
+
|
| 205 |
+
159 We can obtain hence the convergence rate of the above algorithms by investigating the expected regret
|
| 206 |
+
160 bounds of these online algorithms.
|
| 207 |
+
161 To get a concrete algorithm, we must specify the online algorithms $A _ { \theta } , A _ { q }$ as well as the gradient
|
| 208 |
+
162 estimators $\hat { \nabla } _ { \boldsymbol { \theta } , t } , \hat { \nabla } _ { \boldsymbol { q } , t }$ . We use OGD and OMD as $\scriptstyle A _ { \theta }$ and $A _ { q }$ , respectively. We construct the gradient
|
| 209 |
+
163 estimators by sampling $i _ { t } \sim q _ { t }$ and $z \sim P _ { i _ { t } }$ and setting $\hat { \nabla } _ { \boldsymbol { \theta } , t } = \nabla _ { \boldsymbol { \theta } } \ell ( \theta _ { t } ; z )$ and $\begin{array} { r } { \hat { \nabla } _ { q , t } = \frac { \ell ( \theta _ { t } ; z ) } { q _ { t , i _ { t } } } \mathbf { e } _ { i _ { t } } } \end{array}$
|
| 210 |
+
164 This leads to Algorithm 1. There, $\Psi : Q \mathbb { R }$ denotes the regularizer of OMD and $\eta _ { \theta , t }$ and $\eta _ { q }$
|
| 211 |
+
165 denote the step sizes of OGD and OMD, respectively. 1 It turns out that this combination of online
|
| 212 |
+
166 algorithms and gradient estimators yields the best convergence rate (for group DRO) because the
|
| 213 |
+
167 expected regrets of both players are optimal.
|
| 214 |
+
|
| 215 |
+
# Algorithm 1 Algorithm for general DRO (1)
|
| 216 |
+
|
| 217 |
+
Require: initial solution $\theta _ { 1 } \in \Theta$ , number of iterations $T$ , step sizes $\eta _ { \theta , t } > 0 ( t \in [ T ] ) , \eta _ { q } > 0$ , and a strictly convex function $\Psi : Q \mathbb { R }$ .
|
| 218 |
+
1: Let $q _ { 1 } \dot { = } ( 1 / m , \dots , 1 / m )$ .
|
| 219 |
+
2: for $t = 1 , \dots , T$ do
|
| 220 |
+
3: Sample $i _ { t } \sim q _ { t }$ .
|
| 221 |
+
4: Call the stochastic oracle to obtain $z \sim P _ { i _ { t } }$ .
|
| 222 |
+
5: $\theta _ { t + 1 } \mathrm { p r o j } _ { \Theta } ( \theta _ { t } - \eta _ { \theta , t } \nabla _ { \theta } \ell ( \theta _ { t } ; z ) )$
|
| 223 |
+
6: $\begin{array} { r l r } { \nabla \Psi ( \widetilde { q } _ { t + 1 } ) } & { { } } & { \nabla \Psi ( q _ { t } ) \ - \ \frac { \eta _ { q } } { q _ { t , i _ { t } } } \ell ( \theta _ { t } ; z ) \mathbf { e } _ { i _ { t } } } \end{array}$ ; $\begin{array} { r l r } { q _ { t + 1 } } & { { } } & { \arg \operatorname* { m i n } _ { q \in Q } D _ { \Psi } ( q , \tilde { q } _ { t + 1 } ) } \end{array}$ , where $D _ { \Psi } ( x , y ) = \Psi ( x ) - \Psi ( y ) - \nabla \Psi ( x ) ^ { \top } ( y - x )$ is the Bregman divergence with respect to $\Psi$ .
|
| 224 |
+
7: return $\textstyle { \frac { 1 } { T } } \sum _ { t = 1 } ^ { T } \theta _ { t }$ .
|
| 225 |
+
|
| 226 |
+
168 We now analyze the convergence rate of Algorithm 1. We make the following standard assumptions.
|
| 227 |
+
|
| 228 |
+
69 Assumption 1. The loss function $\ell ( \theta ; z )$ is continuously differentiable and $G$ -Lipchitz in $\theta$ , and has
|
| 229 |
+
170 range $[ 0 , M ]$ for all $z$ . The Euclidean diameter of the feasible region $\Theta$ is at most $D$ .
|
| 230 |
+
|
| 231 |
+
The following theorem follows from plugging regret bounds of OGD and OGD, and the construction 2 of the gradient estimators into (3).
|
| 232 |
+
|
| 233 |
+
73 Theorem 1. If $\eta _ { \theta , t }$ is nonincreasing, Algorithm 1 achieves the expected convergence rate
|
| 234 |
+
|
| 235 |
+
$$
|
| 236 |
+
\Im [ \varepsilon _ { T } ] \leq \frac { 1 } { T } \left( \frac { G ^ { 2 } } { 2 } \sum _ { t = 1 } ^ { T } \eta _ { \theta , t } + \frac { D ^ { 2 } } { 2 \eta _ { \theta , T } } + \frac { M ^ { 2 } } { 2 } \eta _ { \theta } \sum _ { t = 1 } ^ { T } \frac { \mathbf { F } } { i _ { t } } \left[ \frac { ( \nabla ^ { 2 } \Psi ( q _ { t } ) ) _ { i _ { t } , i _ { t } } ^ { - 1 } } { q _ { t , i _ { t } } ^ { 2 } } \right] + \frac { \operatorname* { m a x } _ { q ^ { * } \in Q } D _ { \Psi } ( q ^ { * } , \mathbf { 1 } / m ) } { \eta _ { q } } \right) .
|
| 237 |
+
$$
|
| 238 |
+
|
| 239 |
+
174 A formal proof can be found in Appendix B. We will see how specific choices of the regularizer $\Psi$
|
| 240 |
+
175 yield various algorithms and convergence rates for group DRO and others in the next subsections. A
|
| 241 |
+
176 few remarks on the regularizers, step sizes, and projection step are in order.
|
| 242 |
+
177 Regularizer. Although Algorithm 1 works with general $\Psi$ , we can choose a specific regularizer for
|
| 243 |
+
178 $Q$ appearing in applications, e.g, the probability simplex, scaled $k$ -set polytope, or a permutahedron.
|
| 244 |
+
179 In the next subsections, we show that the entropy regularizer $\begin{array} { r } { \Psi ( x ) = \bar { \sum _ { i } } ( x _ { i } \log x _ { i } - \bar { \operatorname { x } _ { i } } ) } \end{array}$ and Tsallis
|
| 245 |
+
180 entropy regularizer $\begin{array} { r } { \Psi ( x ) = 2 ( 1 - \sum _ { i } \sqrt { x _ { i } } ) } \end{array}$ yield efficient algorithms with improved convergence
|
| 246 |
+
181 rates for these cases.
|
| 247 |
+
182 Step sizes. The theorem includes decreasing step sizes such as $\begin{array} { r } { \eta _ { \theta , t } = \frac { D } { m G \sqrt { t } } } \end{array}$ in addition to fixed
|
| 248 |
+
183 step sizes. Decreasing step sizes have the advantage that we do not require the knowledge of $T$
|
| 249 |
+
184 at the beginning of the algorithm but come at the cost of an extra constant factor in the expected
|
| 250 |
+
185 convergence rate. Since both step size policies give the asymptotically same convergence rate, we
|
| 251 |
+
186 describe only fixed step sizes in the theorems in the next subsections. In practice, decreasing step
|
| 252 |
+
187 sizes stabilize the algorithm and often outperform fixed step sizes.
|
| 253 |
+
|
| 254 |
+
Projection step. In general, the Bregman projection argminq∈Q $\mathrm { a r g m i n } _ { q \in Q } D _ { \Psi } ( q , \tilde { q } _ { t + 1 } )$ is convex, but may be costly to compute. For the applications described in Section 2, $\tilde { Q }$ is a permutahedron. In this case,
|
| 255 |
+
|
| 256 |
+
# Algorithm 2 GDRO-EXP3
|
| 257 |
+
|
| 258 |
+
Require: initial solution $\theta _ { 1 } \in \Theta$ , number of iterations $T$ , and step sizes $\eta _ { \theta , t } > 0 \left( t \in [ T ] \right)$ , $\eta _ { q } > 0$ .
|
| 259 |
+
1: Let $q _ { t } = ( 1 / m , \dots , 1 / m )$ .
|
| 260 |
+
2: for $t = 1 , \dots , T$ do
|
| 261 |
+
3: Sample $i _ { t } \sim q _ { t }$ .
|
| 262 |
+
4: Call the stochastic oracle to obtain $z \sim P _ { i _ { t } }$ 5: θt+1 ← projΘ(θt − ηθ,t∇θ\`(θt; z))
|
| 263 |
+
6: q˜t+1 ← qt exp ηq\`(θt;z)eitqt,i
|
| 264 |
+
7: qt+1 ← Pq˜t+1q˜t+1,i .
|
| 265 |
+
8: return 1T PTt=1 θt.
|
| 266 |
+
|
| 267 |
+
# Algorithm 3 GDRO-TINF
|
| 268 |
+
|
| 269 |
+
Require: initial solution $\theta _ { 1 } \in \Theta$ , number of iterations $T$ , and step sizes $\eta _ { \theta , t } > 0 \left( t \in [ T ] \right)$ , $\eta _ { q } > 0$ .
|
| 270 |
+
1: Let $q _ { t } = ( 1 / m , \dots , 1 / m )$ .
|
| 271 |
+
2: for $t = 1 , \dots , T$ do
|
| 272 |
+
3: Sample $i _ { t } \sim q _ { t }$ . 4: Call the stochastic oracle to obtain $z \sim P _ { i _ { t } }$ .
|
| 273 |
+
5: $\begin{array} { r l } & { \theta _ { t + 1 } \gets \mathrm { p r o j } _ { \Theta } ( \theta _ { t } - \eta _ { \theta , t } \nabla _ { \theta } \ell ( \theta _ { t } ; z ) ) } \\ & { \widetilde { q } _ { t + 1 } \gets q _ { t } \left( \mathbf { 1 } - \frac { \eta _ { q } \sqrt { q _ { t } } } { q _ { t , i _ { t } } } \ell ( \theta _ { t } ; z ) \mathbf { e } _ { i _ { t } } \right) ^ { - 2 } } \\ & { \mathrm { C o m p u t e ~ } \quad \alpha \qquad \in \qquad \mathbb { R } \quad \mathrm { s u c h } } \\ & { \sum _ { i = 1 } ^ { m } \left( \sqrt { \widetilde { q } _ { t + 1 , i } } - \alpha \right) ^ { - 2 } = 1 . } \\ & { q _ { t + 1 } \gets \left( \sqrt { \widetilde { q } _ { t + 1 } } - \alpha \mathbf { 1 } \right) ^ { - 2 } } \\ & { \mathrm { t u r n ~ } \frac { 1 } { T } \sum _ { t = 1 } ^ { T } \theta _ { t } . } \end{array}$
|
| 274 |
+
6: 7: that
|
| 275 |
+
8:
|
| 276 |
+
9: return 1T PTt=1 θt.
|
| 277 |
+
|
| 278 |
+
190 it is known that the Bregman projection with respect to the entropy and Tsallis entropy regularizers
|
| 279 |
+
191 can be done in $O ( m \log m )$ time [Lim and Wright, 2016]. If $Q$ is the probability simplex, we even
|
| 280 |
+
192 have a closed form for the Bregman projection.
|
| 281 |
+
|
| 282 |
+
# 3.2 Algorithms for Group DRO
|
| 283 |
+
|
| 284 |
+
As applications of our generic algorithm, we now describe two concrete algorithms for group DRO (2) and their convergence rates.
|
| 285 |
+
|
| 286 |
+
GDRO-EXP3. Let $\Psi$ be the entropy regularizer, which corresponds to the EXP3 algorithm for 7 the $q$ -player. The resulting algorithm, GDRO-EXP3, is shown in Algorithm 2. The update is in a 8 closed formula and its complexity is $O ( m + n )$ time. The convergence rate follows from Theorem 1.
|
| 287 |
+
|
| 288 |
+
99 Theorem 2. If $\eta _ { \theta , t }$ is nonincreasing, GDRO-EXP3 (Algorithm 2) achieves the expected convergence
|
| 289 |
+
00 rate
|
| 290 |
+
|
| 291 |
+
$$
|
| 292 |
+
\mathbf { E } [ \varepsilon _ { T } ] \leq { \frac { 1 } { T } } \left( { \frac { G ^ { 2 } } { 2 } } \sum _ { t = 1 } ^ { T } \eta _ { \theta , t } + { \frac { D ^ { 2 } } { 2 \eta _ { \theta , T } } } + { \frac { m M ^ { 2 } } { 2 } } \eta _ { q } T + { \frac { \log m } { \eta _ { q } } } \right) .
|
| 293 |
+
$$
|
| 294 |
+
|
| 295 |
+
For 201 $\begin{array} { r } { \eta _ { \theta , t } = \frac { D } { G \sqrt { T } } } \end{array}$ and ηq = $\begin{array} { r } { \eta _ { q } = \sqrt { \frac { 2 \log m } { m M ^ { 2 } T } } } \end{array}$ , we obtain
|
| 296 |
+
|
| 297 |
+
$$
|
| 298 |
+
\mathbf { E } [ \varepsilon _ { T } ] \leq { \sqrt { 2 } } { \frac { { \sqrt { G ^ { 2 } D ^ { 2 } + 2 M ^ { 2 } m \log m } } } { \sqrt { T } } } .
|
| 299 |
+
$$
|
| 300 |
+
|
| 301 |
+
202 GRDO-TINF. We can further improve the convergence rate using the Tsallis entropy regularizer
|
| 302 |
+
203 at the cost of a slightly higher iteration complexity. The update of $q _ { t }$ is then
|
| 303 |
+
|
| 304 |
+
$$
|
| 305 |
+
\tilde { q } _ { t + 1 } = q _ { t } \left( \mathbf { 1 } - \frac { \eta _ { q } \sqrt { q _ { t } } } { q _ { t , i _ { t } } } \ell ( \theta _ { t } ; z ) \mathbf { e } _ { i _ { t } } \right) ^ { - 2 } , \quad q _ { t + 1 } : = \left( \sqrt { \tilde { q } _ { t + 1 } } - \alpha \mathbf { 1 } \right) ^ { - 2 } ,
|
| 306 |
+
$$
|
| 307 |
+
|
| 308 |
+
204 where the multiplication, square-root, and power operations are entry-wise and $\alpha \in \mathbb { R }$ is the unique
|
| 309 |
+
205 solution of equation $\begin{array} { r } { \sum _ { i = 1 } ^ { m } \overline { { \left( \sqrt { \tilde { q } _ { t + 1 , i } } - \alpha \right) ^ { - 2 } } } = 1 } \end{array}$ . The solution $\alpha$ can be computed via the Newton
|
| 310 |
+
206 method. Practically, one can use $\alpha$ in the previous iteration to warm start the Newton method. In
|
| 311 |
+
207 each iteration, the algorithm performs a single orthogonal projection onto $\Theta$ , the Newton method for
|
| 312 |
+
208 finding $\alpha$ , and $O ( m + n )$ operations to update $\theta _ { t } , q _ { t }$ . The pseudocode is given in Algorithm 3. From
|
| 313 |
+
209 Theorem 1, we obtain the following convergence rate.
|
| 314 |
+
210 Theorem 3. If $\eta _ { \theta , t }$ is nonincreasing, GDRO-TINF (Algorithm 3) achieves the expected convergence
|
| 315 |
+
211 rate
|
| 316 |
+
|
| 317 |
+
$$
|
| 318 |
+
\mathbf { E } [ \varepsilon _ { T } ] \leq { \frac { 1 } { T } } \left( { \frac { G ^ { 2 } } { 2 } } \sum _ { t = 1 } ^ { T } \eta _ { \theta , t } + { \frac { D ^ { 2 } } { 2 \eta _ { \theta , T } } } + { \sqrt { m } } M ^ { 2 } \eta _ { q } T + { \frac { \sqrt { m } } { \eta _ { q } } } \right) .
|
| 319 |
+
$$
|
| 320 |
+
|
| 321 |
+
For 212 $\begin{array} { r } { \eta _ { \theta , t } = \frac { D } { G \sqrt { T } } } \end{array}$ and $\begin{array} { r } { \eta _ { q } = \frac { 1 } { M \sqrt { T } } } \end{array}$ , we obtain
|
| 322 |
+
|
| 323 |
+
$$
|
| 324 |
+
\mathbf { E } [ \varepsilon _ { T } ] \leq \sqrt { 2 } \frac { \sqrt { G ^ { 2 } D ^ { 2 } + 4 M ^ { 2 } m } } { \sqrt { T } } .
|
| 325 |
+
$$
|
| 326 |
+
|
| 327 |
+
213 Comparison to Sagawa et al. [2020]. Our algorithms improve the convergence rate of Sagawa et√
|
| 328 |
+
214 al. [2020] by a factor of $O ( \sqrt { m } )$ ; see Table 1. The reason lies in the choice of gradient estimator. All
|
| 329 |
+
215 algorithms are stochastic no-regret dynamics. As outlined above, their convergence hence can be
|
| 330 |
+
216 bounded by the regrets of the players, which depend on the variance of the local norm of the gradient
|
| 331 |
+
217 estimators. Their strategy is based on uniform sampling that yields a variance of √ $O ( m )$ for both
|
| 332 |
+
218 players, whereas our bound is $O ( { \sqrt { m } } )$ thanks to the gradient estimators tailored to the regularizer of
|
| 333 |
+
219 OMD. More details may be found in Appendix D.
|
| 334 |
+
|
| 335 |
+
# 3.3 Algorithm for weighted ranking of group losses
|
| 336 |
+
|
| 337 |
+
We now consider a more general case that $Q$ is a permutahedron. Applying Algorithm 1 with the Tsallis entropy regularizer, we obtain the following result.
|
| 338 |
+
|
| 339 |
+
Theorem 4. If $\eta _ { \theta , t }$ is nonincreasing and $Q$ is a permutahedron, Algorithm 1 with the Tsallis entropy regularizer achieves the same expected convergence rate as Theorem 3. Furthermore, the iteration complexity is $O ( m \log m + n )$ .
|
| 340 |
+
|
| 341 |
+
This implies a convergence rate of G2D2+M2mT ) for empirical CVaR optimization, which improves q G2D2+M2m log mT ) convergence by Curi et al. [2020]. Furthermore, their iteration complexity is $O ( m ^ { 3 } )$ due to the $k$ -DPP sampling step, so our algorithm is even faster in terms of iteration complexity.
|
| 342 |
+
|
| 343 |
+
# 4 Lower bound
|
| 344 |
+
|
| 345 |
+
Theorem 3 states that we can find an $\varepsilon$ -optimal solution for group DRO in $ { \mathcal { O } } ( \frac { G ^ { 2 } D ^ { 2 } + M ^ { 2 } m } { \varepsilon ^ { 2 } } )$ calls to stochastic oracles. Next, we show that this query complexity is information-theoretically optimal.
|
| 346 |
+
|
| 347 |
+
33 Let $\mathcal { L }$ be a class of convex $G$ -Lipschitz loss functions $\ell : \Theta \to [ 0 , M ]$ . Given a loss function $\ell \in { \mathcal { L } }$ ,
|
| 348 |
+
34 and an $m$ -set $\mathcal { P } = \{ P _ { 1 } , \ldots , P _ { m } \}$ of distributions, denote the optimality gap of $\theta \in \Theta$ by
|
| 349 |
+
|
| 350 |
+
$$
|
| 351 |
+
R ( \theta , \ell , \mathcal { P } ) = \operatorname* { m a x } _ { P \in \mathcal { P } } \mathbf { \Xi } _ { z \sim P } ^ { \mathbf { E } } [ \ell ( \theta ; z ) ] - \operatorname* { m i n } _ { \theta ^ { * } \in \Theta } \operatorname* { m a x } _ { P \in \mathcal { P } } \mathbf { \Xi } _ { z \sim P } ^ { \mathbf { E } } [ \ell ( \theta ^ { * } ; z ) ] .
|
| 352 |
+
$$
|
| 353 |
+
|
| 354 |
+
Let 235 $\boldsymbol { \mathcal { A } } _ { T }$ be the set of algorithms that outputs $\hat { \theta } \in \Theta$ making $T$ queries to the stochastic oracle.
|
| 355 |
+
|
| 356 |
+
Theorem 5 (Lower Bound).
|
| 357 |
+
|
| 358 |
+
$$
|
| 359 |
+
\operatorname* { i n f } _ { \boldsymbol { \hat { \theta } } \in A _ { T } } \operatorname* { s u p } _ { \boldsymbol { \ell } \in \mathcal { L } , \boldsymbol { \Theta } , \mathcal { P } } \mathbf { E } [ R ( \boldsymbol { \hat { \theta } } , \boldsymbol { \ell } , \mathcal { P } ) ] \geq \Omega \left( \operatorname* { m a x } \left\{ \frac { G D } { \sqrt { T } } , M \sqrt { \frac { m } { T } } \right\} \right) ,
|
| 360 |
+
$$
|
| 361 |
+
|
| 362 |
+
236 where $\Theta$ runs over convex sets with diameter $D$ and $\mathcal { P }$ over $m$ -sets of distributions, and $\mathbf { E } _ { \mathcal { P } }$ denotes
|
| 363 |
+
237 the expectation over outcomes of the stochastic oracle in $\mathcal { P }$ .
|
| 364 |
+
|
| 365 |
+
As ${ \sqrt { x + y } } \leq { \sqrt { x } } + { \sqrt { y } } \leq { \sqrt { 2 ( x + y ) } }$ for $x , y \geq 0$ , this theorem immediately implies that the minimax convergence rate is $\Omega \left( { \sqrt { \frac { G ^ { 2 } D ^ { 2 } + M ^ { 2 } m } { T } } } \right)$ , which equals the convergence rate achieved by Algorithm 3 up to a constant factor.
|
| 366 |
+
|
| 367 |
+
241 Proof Sketch. It suffices to show two lower bounds $\textstyle { \frac { G D } { \sqrt { T } } }$ and $M _ { \sqrt { T } }$ independently. The former is
|
| 368 |
+
242 a well-known lower bound for stochastic convex optimization [Agarwal et al., 2012]. To illustrate the
|
| 369 |
+
243 latter, we take an algorithmic dependent point of view via the Le cam’s method. For any algorithm
|
| 370 |
+
244 in $\boldsymbol { \mathcal { A } } _ { T }$ , we need to construct instances $\mathcal { P } _ { 0 } , \mathcal { P } _ { 1 }$ such that the total variation distance between the
|
| 371 |
+
245 distributions over the query outcomes (they depend on both the behavior of the algorithm and the
|
| 372 |
+
246 instance) with respect to $\mathcal { P } _ { 0 }$ and $\mathcal { P } _ { 1 }$ is small. On the other hand, the objective function of the two
|
| 373 |
+
247 instances must be well-separated, i.e., any fixed $\theta$ is $\delta$ sub-optimal for either $\mathcal { P } _ { 0 }$ or $\mathcal { P } _ { 1 }$ . So, any
|
| 374 |
+
248 algorithm that solves group DRO up to error $\delta$ needs to distinguish two instances $\mathcal { P } _ { 0 }$ and $\mathcal { P } _ { 1 }$ . This
|
| 375 |
+
249 implies a query lower bound because the total variation distance of the outcome distributions of
|
| 376 |
+
250 these instances is small. The challenge is how to construct such instances for the regime of small
|
| 377 |
+
251 dimensions of $\theta$ , e.g, $n = 1$ . To this end, we carefully construct linear functions for $m$ groups using
|
| 378 |
+
252 opposite slopes. Then, based on the behavior of the algorithm, we tweak the noise bias in one of the
|
| 379 |
+
253 groups with a positive slope, in a way that any fixed $\theta$ is $\Theta ( \delta )$ sub-optimal for one of these instances.
|
| 380 |
+
254 For the detailed proof, see Appendix C.
|
| 381 |
+
|
| 382 |
+

|
| 383 |
+
Figure 1: Results on Adult dataset
|
| 384 |
+
|
| 385 |
+

|
| 386 |
+
Figure 2: Results on synthetic dataset
|
| 387 |
+
|
| 388 |
+
# 5 Experiments
|
| 389 |
+
|
| 390 |
+
In this section, we compare our algorithms with the known algorithm using real-world and synthetic datasets. We follow the setup in [Namkoong and Duchi, 2016].
|
| 391 |
+
|
| 392 |
+
Adult dataset. For the real-world dataset, we use Adult dataset [Dua and Graff, 2017]. The dataset consists of age, gender, race, educational background, and many other attributes of 48, 842 individuals from the US census. The task is to predict whether the person’s income is greater than 50, 000 USD or not. We set up 6 groups based on the race and gender attributes: each group corresponds to a combination of {black, white, others} $\times \left\{ \begin{array} { r l } \end{array} \right.$ {female, male}. Converting the categorical features to dummy variables, we obtain a 101-dimensional feature vector $a \in \mathbb { R } ^ { n }$ ( $n = 1 0 1$ ) for each individual. We train the linear model with the logistic loss and hinge loss functions. The group-DRO objective is the worst empirical loss over the 6 groups:
|
| 393 |
+
|
| 394 |
+
$$
|
| 395 |
+
\operatorname* { m a x } _ { i = 1 } ^ { 6 } { \frac { 1 } { | I _ { i } | } } \sum _ { ( a , b ) \in I _ { i } } \ell ( \theta ; a , b ) ,
|
| 396 |
+
$$
|
| 397 |
+
|
| 398 |
+
where 266 $I _ { i }$ is the set of data points in the ith group. The feasible region is set to the Euclidean ball of 267 radius $D = 1 0$ .
|
| 399 |
+
|
| 400 |
+
268 Synthetic dataset. To observe the performance of the algorithms over the regime of high-dimension
|
| 401 |
+
269 model parameters and the larger number of groups, we also conducted experiments using the following
|
| 402 |
+
270 synthetic instances. First, we set $n = 5 0 0$ and varied $m \in \{ 1 0 , 5 0 , 1 0 0 \}$ . For each group $i \in [ m ]$ , we
|
| 403 |
+
271 generated the true classifier $\theta _ { i } ^ { * } \in \mathbb { R } ^ { n }$ from the uniform distribution over the unit sphere in $\mathbb { R } ^ { n }$ . The ith
|
| 404 |
+
272 group distribution $P _ { i }$ was the empirical distribution of 1,000 data points, where each data point $( a , b )$
|
| 405 |
+
273 was drawn as $a \sim N ( 0 , I _ { n } )$ and $b = \mathrm { s i g n } ( a ^ { \top } \theta _ { i } ^ { * } )$ with probability 0.9 and $b = - \mathrm { s i g n } ( a ^ { \top } \theta _ { i } ^ { * } )$ with
|
| 406 |
+
274 probability 0.1. We trained the linear model with the hinge loss function. Finally, the group-DRO
|
| 407 |
+
275 objective is
|
| 408 |
+
|
| 409 |
+
$$
|
| 410 |
+
\underset { i = 1 } { \operatorname* { m a x } } \ \underset { ( a , b ) \sim P _ { i } } { \mathbf { E } } [ \ell ( \theta ; a , b ) ] .
|
| 411 |
+
$$
|
| 412 |
+
|
| 413 |
+
276 The feasible region is set to the Euclidean ball of radius $D = 1 0$ .
|
| 414 |
+
|
| 415 |
+
# 5.1 Algorithms
|
| 416 |
+
|
| 417 |
+
We implemented GDRO-EXP3, GDRO-TINF, and the algorithm in [Sagawa et al., 2020] in Python.
|
| 418 |
+
We ran our algorithms for $T = 2 , 0 0 0 , 0 0 0$ iterations.
|
| 419 |
+
|
| 420 |
+
Inner online algorithms. It is known that EXP3 has a variance as large as $O ( T ^ { 2 } )$ [Lattimore and Szepesvári, 2020]. Therefore, vanilla EXP3 often fails to achieve a sublinear regret even though it achieves $O ( \sqrt { T } )$ regret in expectation. This large variance makes it difficult to reliably evaluate the performance of the algorithms. To stabilize the algorithms, we replaced EXP3 with its variation,√ EXP3P [Auer et al., 2003], which achieves $O ( \sqrt { T } )$ regret with high probability. Note that this change does not harm our expected convergence bounds.
|
| 421 |
+
|
| 422 |
+
Step sizes. The choice of step sizes is crucial to the practical performance of first-order methods. We found that the decreasing step size $\eta _ { \theta , t } \sim 1 / \sqrt { t }$ for $\theta _ { t }$ and the fixed step size $\eta _ { q } \sim 1 / \sqrt { T }$ for $q _ { t }$ gave the best results. More precisely, we set $\begin{array} { r } { \eta _ { \theta , t } = \frac { C _ { \theta } D } { \sqrt { t } } } \end{array}$ $( t \in [ T ] )$ and $\begin{array} { r } { \eta _ { q } = C _ { q } \sqrt { \frac { \log m } { m T } } } \end{array}$ , where $C _ { \theta } \in [ 0 . 1 , 5 . 0 ]$ and $C _ { q } \in [ 0 . 1 , 3 . 0 ]$ are hyper-parameters tuned for each algorithm. We used the best hyper-parameter found by Optuna [Akiba et al., 2019] for the shown results.
|
| 423 |
+
|
| 424 |
+
Mini-batch. The use of mini-batch often improves the stability of stochastic gradient algorithms. In our experiments, we used mini-batches of size 10 to evaluate stochastic gradients. Neither the objective values of outputs nor the stability was improved with larger mini-batch sizes. The group DRO objective is evaluated using the entire dataset.
|
| 425 |
+
|
| 426 |
+
Initialization. For both datasets, we initialized the algorithms with $\theta _ { 1 } = \mathbf { 0 }$ .
|
| 427 |
+
|
| 428 |
+
# 5.2 Results
|
| 429 |
+
|
| 430 |
+
We show the results of our experiment in Figures 1 and 2.
|
| 431 |
+
|
| 432 |
+
Adult dataset. In Figure 1, we plot the optimality gap of the averaged iterate $\textstyle { \frac { 1 } { T } } \sum _ { t = 1 } ^ { T } \theta _ { t }$ against the number of iteration . We observe that all the algorithms converge with a rate roughly $T ^ { - 0 . 5 }$ for both loss functions, consistent with our convergence bound. Furthermore, our algorithms (GDRO-EXP3 and GDRO-TINF) achieve faster convergence compared to the algorithm by Sagawa et al. [2020]. Interestingly, GDRO-TINF achieves a $1 \overline { { 0 } } ^ { - 4 }$ optimality gap in $T = 1 0 ^ { 6 }$ iterations, which is faster than the theoretical $T ^ { - 0 . 5 }$ rate in Theorem 3.
|
| 433 |
+
|
| 434 |
+
Synthetic dataset. In Figure 2, we plot the objective values of the averaged iterate against the number of iterations. For all the values of $m$ , our algorithms (especially GDRO-EXP3) consistently achieve smaller loss values faster than the known algorithm. The performance gap between our algorithms and the known algorithm increased as $m$ grows, which verifies that our algorithms have better dependence on $m$ in the convergence rate.
|
| 435 |
+
|
| 436 |
+
09 References
|
| 437 |
+
10 Alekh Agarwal, Peter L. Bartlett, Pradeep Ravikumar, and Martin J. Wainwright. Informationtheoretic lower bounds on the oracle complexity of stochastic convex optimization. IEEE Transactions on Information Theory, pages 3235–3249, 2012.
|
| 438 |
+
13 Takuya Akiba, Shotaro Sano, Toshihiko Yanase, Takeru Ohta, and Masanori Koyama. Optuna: A next-generation hyperparameter optimization framework. In Proceedings of the 25rd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, 2019.
|
| 439 |
+
316 Peter Auer, Nicolò Cesa-Bianchi, Yoav Freund, and Robert E. Schapire. The nonstochastic multiarmed bandit problem. SIAM Journal on Computing, 32(1):48–77, 2003.
|
| 440 |
+
18 Yujia Bao, Shiyu Chang, and Regina Barzilay. Predict then interpolate: A simple algorithm to learn stable classifiers. In Proceedings of the 38th International Conference on Machine Learning, volume 139, pages 640–650, 2021. Dimitris Bertsimas, Vishal Gupta, and Nathan Kallus. Data-driven robust optimization. Mathematical Programming, 167(2):235–292, 2018. Jose Blanchet, Yang Kang, and Karthyek Murthy. Robust wasserstein profile inference and applications to machine learning. Journal of Applied Probability, 56(3):830–857, 2019.
|
| 441 |
+
25 Joy Buolamwini and Timnit Gebru. Gender shades: Intersectional accuracy disparities in commercial gender classification. In Proceedings of the 1st Conference on Fairness, Accountability and Transparency, pages 77–91, 2018. Yair Carmon, Arun Jambulapati, Yujia Jin, and Aaron Sidford. Thinking inside the ball: Near-optimal minimization of the maximal loss. In Proceedings of 34th Conference on Learning Theory, volume
|
| 442 |
+
134 of Proceedings of Machine Learning Research, pages 866–882, 2021.
|
| 443 |
+
31 Nicolo Cesa-Bianchi and Gabor Lugosi. Prediction, Learning, and Games. Cambridge University Press, 2006.
|
| 444 |
+
33 Sebastian Curi, Kfir Y. Levy, Stefanie Jegelka, and Andreas Krause. Adaptive sampling for stochastic risk-averse learning. In Advances in Neural Information Processing Systems, pages 1036–1047,
|
| 445 |
+
2020.
|
| 446 |
+
36 Emily Diana, Wesley Gill, Ira Globus-Harris, Michael Kearns, Aaron Roth, and Saeed SharifiMalvajerdi. Lexicographically fair learning: Algorithms and generalization. In Proceedings of the
|
| 447 |
+
2nd Symposium on Foundations of Responsible Computing, pages 6:1–6:23, 2021.
|
| 448 |
+
39 Dheeru Dua and Casey Graff. UCI machine learning repository, 2017.
|
| 449 |
+
40 John C. Duchi and Hongseok Namkoong. Learning models with uniform performance via distributionally robust optimization. The Annals of Statistics, 49(3):1378 – 1406, 2021.
|
| 450 |
+
42 Peyman Mohajerin Esfahani and Daniel Kuhn. Data-driven distributionally robust optimization using the wasserstein metric: Performance guarantees and tractable reformulations. Mathematical Programming, 171(1):115–166, 2018.
|
| 451 |
+
45 Joel Goh and Melvyn Sim. Distributionally robust optimization and its tractable approximations. Operations Research, 58(4-part-1):902–917, 2010.
|
| 452 |
+
47 Tatsunori Hashimoto, Megha Srivastava, Hongseok Namkoong, and Percy Liang. Fairness without demographics in repeated loss minimization. In Proceedings of the 35th International Conference on Machine Learning, pages 1929–1938, 2018.
|
| 453 |
+
50 Elad Hazan. Introduction to Online Convex Optimization. 2016.
|
| 454 |
+
51 Dirk Hovy and Anders Søgaard. Tagging performance correlates with author age. In Proceedings of the 53rd Annual Meeting of the Association for Computational Linguistics and the 7th International Joint Conference on Natural Language Processing, pages 483–488, 2015.
|
| 455 |
+
|
| 456 |
+
354 Weihua Hu, Gang Niu, Issei Sato, and Masashi Sugiyama. Does distributionally robust supervised learning give robust classifiers? In Proceedings of the 35th International Conference on Machine Learning, pages 2029–2037, 2018. Jikai Jin, Bohang Zhang, Haiyang Wang, and Liwei Wang. Non-convex distributionally robust optimization: Non-asymptotic analysis. In Advances in Neural Information Processing Systems, volume 34, pages 2771–2782, 2021. David Jurgens, Yulia Tsvetkov, and Dan Jurafsky. Incorporating dialectal variability for socially equitable language identification. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics, pages 51–57, 2017. Johannes Kirschner, Ilija Bogunovic, Stefanie Jegelka, and Andreas Krause. Distributionally robust bayesian optimization. In Proceedings of the 33rd International Conference on Artificial Intelligence and Statistics, pages 2174–2184, 2020. Tor Lattimore and Csaba Szepesvári. Bandit algorithms. Cambridge University Press, 2020. Cong Han Lim and Stephen J. Wright. Efficient bregman projections onto the permutahedron and related polytopes. In Proceedings of the 19th International Conference on Artificial Intelligence and Statistics, pages 1205–1213, 2016. Natalia L Martinez, Martin A Bertran, Afroditi Papadaki, Miguel Rodrigues, and Guillermo Sapiro. Blind pareto fairness and subgroup robustness. In Proceedings of the 38th International Conference on Machine Learning, pages 7492–7501, 2021. Hongseok Namkoong and John C Duchi. Stochastic gradient methods for distributionally robust optimization with $f$ -divergences. In Advances in Neural Information Processing Systems, 2016. Yonatan Oren, Shiori Sagawa, Tatsunori Hashimoto, and Percy Liang. Distributionally robust language modeling. In Proceedings of the Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLPIJCNLP), pages 4227–4237, 2019. Qi Qi, Zhishuai Guo, Yi Xu, Rong Jin, and Tianbao Yang. An online method for a class of distributionally robust optimization with non-convex objectives. In Advances in Neural Information Processing Systems, volume 34, pages 10067–10080, 2021. Alexander Rakhlin and Karthik Sridharan. Optimization, learning, and games with predictable sequences. In Advances in Neural Information Processing Systems, 2013. Shiori Sagawa, Pang Wei Koh, Tatsunori B. Hashimoto, and Percy Liang. Distributionally robust neural networks for group shifts: On the importance of regularization for worst-case generalization. In The 8th International Conference on Learning Representations, 2020. Herbert Scarf. A min-max solution of an inventory problem. Studies in the mathematical theory of inventory and production, 1958. Matthew Staib and Stefanie Jegelka. Distributionally robust optimization and generalization in kernel methods. In Advances in Neural Information Processing Systems, 2019. Matthew Staib, Bryan Wilder, and Stefanie Jegelka. Distributionally robust submodular maximization. In Proceedings of the 22nd International Conference on Artificial Intelligence and Statistics, pages 506–516, 2019. Robert Williamson and Aditya Menon. Fairness risk measures. In Proceedings of the 36th International Conference on Machine Learning, pages 6786–6797, 2019. Jingzhao Zhang, Aditya Krishna Menon, Andreas Veit, Srinadh Bhojanapalli, Sanjiv Kumar, and Suvrit Sra. Coping with label shift via distributionally robust optimisation. In The 9th International Conference on Learning Representations, 2021. Julian Zimmert and Yevgeny Seldin. Tsallis-inf: An optimal algorithm for stochastic and adversarial bandits. Journal of Machine Learning Research, 22(28):1–49, 2021.
|
| 457 |
+
|
| 458 |
+
Martin Zinkevich. Online convex programming and generalized infinitesimal gradient ascent. In Proceedings of the 20th International Conference on International Conference on Machine Learning, pages 928–935, 2003.
|
| 459 |
+
|
| 460 |
+
# 404 Checklist
|
| 461 |
+
|
| 462 |
+
1. For all authors...
|
| 463 |
+
|
| 464 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
|
| 465 |
+
(b) Did you describe the limitations of your work? [No]
|
| 466 |
+
(c) Did you discuss any potential negative societal impacts of your work? [No] This paper is a theoretical paper.
|
| 467 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 468 |
+
|
| 469 |
+
2. If you are including theoretical results...
|
| 470 |
+
|
| 471 |
+
(a) Did you state the full set of assumptions of all theoretical results? [Yes] See Assumption 1.
|
| 472 |
+
(b) Did you include complete proofs of all theoretical results? [Yes] Ommited Proof can be found in the supplemental material.
|
| 473 |
+
|
| 474 |
+
3. If you ran experiments...
|
| 475 |
+
|
| 476 |
+
(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 experiment code can be found in the supplemental material.
|
| 477 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Section 5.
|
| 478 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No]
|
| 479 |
+
(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]
|
| 480 |
+
|
| 481 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 482 |
+
|
| 483 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes]
|
| 484 |
+
(b) Did you mention the license of the assets? [Yes]
|
| 485 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [No]
|
| 486 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [No] We used a public dataset.
|
| 487 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No]
|
| 488 |
+
|
| 489 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 490 |
+
|
| 491 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [No] Not applicable
|
| 492 |
+
(b) DidNo describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [No]
|
| 493 |
+
(c) DidNo include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [No]
|
md/dev/NPJznfA7ZC/NPJznfA7ZC.md
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Demystifying Prompts in Language Models via Perplexity Estimation
|
| 2 |
+
|
| 3 |
+
Hila Gonen1,2 Srini Iyer2 Terra Blevins1 Noah A. Smith1,3 Luke Zettlemoyer1,
|
| 4 |
+
|
| 5 |
+
1Paul G. Allen School of Computer Science & Engineering, University of Washington 2Meta AI Research 3Allen Institute for Artificial Intelligence hilagnn@gmail.com sviyer@meta.com {blvns,nasmith,lsz}@cs.washington.edu
|
| 6 |
+
|
| 7 |
+
# Abstract
|
| 8 |
+
|
| 9 |
+
Language models can be prompted to perform a wide variety of tasks with zero- and few-shot incontext learning. However, performance varies significantly with the choice of prompt, and we do not yet understand why this happens. In this paper, we analyze the factors that contribute to this variance and establish a new empirical hypothesis: the performance of a prompt is predicted by the extent to which the model is familiar with the language it contains. Over a wide range of tasks, we show that the lower the perplexity of the prompt, the better it is able to perform the task, when considering reasonable prompts that are related to it. As part of our analysis, we also devise a method to automatically extend a small seed set of manually written prompts by paraphrasing with GPT3 and backtranslation. This larger set allows us to verify that perplexity is a strong predictor of the success of a prompt and we show that the lowest perplexity prompts are consistently effective.
|
| 10 |
+
|
| 11 |
+
# 1 Introduction
|
| 12 |
+
|
| 13 |
+
Language models can be prompted to perform a wide range of zero- and few-shot learning tasks (Brown et al., 2020; Schick and Schütze, 2020). However, there is significant variance in the performance of seemingly similar prompts (Chen et al., 2022): for AG News (Zhang et al., 2015), we find an over 30 point accuracy gap between different manually curated prompts (see Table 1) on OPT 175B (Zhang et al., 2022). Despite efforts to improve prompt engineering (Shin et al., 2020; Li and Liang, 2021; Gao et al., 2021), it is still challenging to develop high-quality prompts for new tasks, and little is known about why this phenomenon occurs.
|
| 14 |
+
|
| 15 |
+
We are interested in understanding what makes some prompts better than others, and using this understanding to create better prompts for given tasks and models. We hypothesize that the lower the perplexity of a prompt is, the better its performance on the task will be, when considering reasonable prompts that are related to the task. This is based on the intuition that the more frequently the prompt (or very similar phrases) appears in the training data, the more the model is familiar with it and is able to perform the described task. We refrain from using the training data directly as it is often unavailable, expensive to search due to its size, and hard to use for approximate matching of similar prompts. Instead, we focus on the perplexity of the prompt as a proxy for its occurrences in the data.
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
Figure 1: Accuracy vs. perplexity for the AG News dataset with OPT 175B. The $x$ axis is in log scale. Each point stands for a different prompt.
|
| 19 |
+
|
| 20 |
+
To enable more complete analysis, we automatically expand the set of manually created prompts for the task by paraphrasing, resulting in a much larger and diverse set of prompts. We focus on prompts in English that reasonably describe the task for two reasons: (a) our main motivation is to understand what lies under the variance of performance in this type of prompt; (b) we aim to devise a useful method for creating prompts that are consistently effective, that could be easily adopted and interpreted by future, potentially non-expert users.
|
| 21 |
+
|
| 22 |
+
We show empirically that our hypothesis holds across a diverse set of tasks (including classification and word prediction), models, and model sizes, providing us some insights about the underlying mechanism of prompting (see Figure 1). As a result, we devise a method, SPELL (Selecting Prompts by Estimating LM Likelihood), for creating prompts in an informed manner. We show that using SPELL to choose prompts results in less variability in performance as well as in accuracy gains (1.8 accuracy points with OPT and 2.3 accuracy points with Bloom on average). Importantly, our method does not require labels at all, only a small sample of inputs for the task.
|
| 23 |
+
|
| 24 |
+
Our contributions can be summarized as follows: (a) we formalize the notion that better familiarity of the model with the prompt correlates with better performance (Section 2); (b) we automatically elaborate a given set of seed prompts using paraphrasing (Section 3); (c) we establish experimentally the hypothesis that lower perplexity of the prompt correlates well with better performance (Section 5); (d) we devise a method to create a more consistent set of prompts, that also improve results even with no labels for the task (Section 7).
|
| 25 |
+
|
| 26 |
+
# 2 Why are prompts not all created equal?
|
| 27 |
+
|
| 28 |
+
Despite the popularity of prompting as a method for using language models (Shin et al., 2020; Li and Liang, 2021; Gao et al., 2021), the cause for the different behavior of various prompts remains unclear so far. Table 1 shows four example prompts for a news topic classification task (AG News) and their respective accuracies when used to prompt OPT 175B (Zhang et al., 2022). The accuracy gap between the different prompts is not trivial, and it is not possible to predict from the prompts alone.
|
| 29 |
+
|
| 30 |
+
Table 1: Example prompts for the task AG News (news classification) that vary considerably in accuracy.
|
| 31 |
+
|
| 32 |
+
<table><tr><td>Prompt</td><td>Accuracy</td></tr><tr><td>What is this piece of news regarding?</td><td>40.9</td></tr><tr><td>What is this article about?</td><td>52.4</td></tr><tr><td>What is the best way to describe this article?</td><td>68.2</td></tr><tr><td>What is the most accurate label for this news article?</td><td>71.2</td></tr></table>
|
| 33 |
+
|
| 34 |
+
We propose that the more frequently a prompt appears in some variation in the data, the better it works for the task. The intuition behind this is that a sequence that is more expected by the model is more likely to aid the model to extract the relevant information. However, this premise is hard to measure accurately: most language models use huge amounts of training data (e.g., OPT uses a corpus of roughly 180B tokens, and Bloom uses roughly 366B tokens), and in addition, this training data is not always publicly available (e.g., GPT3; Brown et al. 2020). Our initial attempts to estimate exact-match occurrences of prompts in the data resulted in very sparse counts, which led us to look for a softer formalization.1
|
| 35 |
+
|
| 36 |
+
Instead of considering the training data directly, we propose to focus on the perplexity of the prompt as a proxy for its occurrences in some form in the data – essentially indicating to what extent the model expects this prompt. This perplexity-based framing helps to avoid the challenge of exact match in the data, and takes into account variations of the prompt that the model is also exposed to and might be influenced by. In addition, it helps overcome the challenges mentioned above as it requires neither access to the pretraining data (which is not always publicly available for LMs) nor matching over huge amounts of text.
|
| 37 |
+
|
| 38 |
+
Hypothesis: lower perplexity correlates with better performance. We hypothesize that on average, lower-perplexity prompts perform better. We are interested in establishing this hypothesis by experimentally showing a significant negative correlation between the perplexity of the prompt and its performance on the task, across a diverse set of tasks and models.
|
| 39 |
+
|
| 40 |
+
We define the perplexity of the prompt as the perplexity of the full prompt sequence, including the input itself, and without the label, averaged over 1,000 examples (see Section 4 for details). The input is a part of the prompt in the case of the word prediction tasks by design (e.g., “The opposite of the word good is”). Inclusion of the task input as part of the prompt for classification tasks as well is intentional: we want to ground the prompt to the task (without the input, we are testing the hypothesis that lower perplexity prompts across all tasks work better on every task). The label is not considered a part of the prompt and is not taken into consideration when computing the prompt. In practice, this also results in a huge advantage of our method, SPELL (Section 7), which aims to find better prompts—it does not require any labels.
|
| 41 |
+
|
| 42 |
+
For performance measures, we use the loglikelihood score assigned by the model to the correct label given that prompt. We choose this metric over accuracy as it gives a more fine-grained distinction between prompts and because accuracy can be unstable, as explained in more detail in Section 4. For classification tasks, we also report correlation with accuracy, which is the main evaluation metric for this type of task.
|
| 43 |
+
|
| 44 |
+
# 3 Automatic Expansion of Seed Prompts
|
| 45 |
+
|
| 46 |
+
We are interested in expanding our pool of prompts in order to: (a) have a more diverse set of prompts, making it more likely to find a better prompt for our task, and (b) support better analysis to validate our prompt quality hypothesis. In this section, we describe our method for automatically expanding a seed set of manually created prompts using paraphrasing.
|
| 47 |
+
|
| 48 |
+
Step 0: Creating a seed set of manually-written prompts We first write/collect a small set of human written prompts that describe the task. For classification tasks we assume that the input appears before the prompt, with no choices appearing as part of the prompt (to help in smooth paraphrasing of the prompt itself).
|
| 49 |
+
|
| 50 |
+
Step 1: Paraphrasing with GPT3 We use the text-davinci-002 version of GPT3 (Brown et al., 2020) to generate paraphrases for each of the manual prompts in our seed set. We prompt it with a meta-prompt for paraphrasing to generate variations of one of our seed prompts. An example of such a meta-prompt is: Write a paraphrase for the following sentence: <seed prompt> Paraphrase:. The 7 meta-prompts used in this step are listed in Table 2.
|
| 51 |
+
|
| 52 |
+
We choose GPT3 as our paraphrasing model because of its well-documented generation abilities. This is also to ensure that there is a separation between the model we use to create the prompts and the models we use to rank them (OPT and Bloom, see Section 4 for details), to avoid confounding the experimental setup.
|
| 53 |
+
|
| 54 |
+
Step 2: Paraphrasing using backtranslation Our second step takes as input the paraphrases from GPT3 (in addition to the seed set of prompts) and translates them into different languages and back into English to get additional prompt paraphrases (Wieting et al., 2017). We use a set of 8 languages available in the NLLB translation model (Costajussà et al., 2022) that are relatively high resource and close to English,2 to reduce the risk of noise. Since we aim to get about 100 prompts per task, we add 8 additional languages3 in the case where the basic 8 languages yielded too few alternatives. For word prediction tasks, we use the sequence of the created prompt up to the index of the label, not including the label, for example: The word “dog” in French is “. Depending on the task, we enforce the existence of specific words (e.g., the name of the language, and the source word, in word-level translation) or enforce the prompt to be a question.
|
| 55 |
+
|
| 56 |
+
Examples and Statistics Table 4 lists all 4 manually created prompts we use for the AG News task (news classification), alongside a few sampled prompts created automatically using our method. As was typically the case, we are able to get prompts that are rather different in phrasing and structure from those included in the seed set.
|
| 57 |
+
|
| 58 |
+
The statistics of the prompts in the manually created seed set (Step 0) as well as the prompts after Step 1 and Step 2 for each task (see Section 4.1 for details about the tasks) are detailed in Table 3.
|
| 59 |
+
|
| 60 |
+
# 4 Experimental Setup
|
| 61 |
+
|
| 62 |
+
# 4.1 Models, Tasks and Datasets
|
| 63 |
+
|
| 64 |
+
We study four auto-regressive models: OPT (Zhang et al., 2022) of different sizes (1.3B, 30B, 175B parameters), all trained mainly on English,4 and Bloom (176B parameters; Luccioni et al. 2022), which is trained on 46 natural languages and 13 programming languages. We experiment with two types of tasks: word prediction tasks and classification tasks, as detailed below.
|
| 65 |
+
|
| 66 |
+
Word Prediction Tasks The first task in this category is word-level translation. Given a source word in English and a target language, we expect the model to predict the correct translation. For this task we use NorthEuraLex5 (Dellert et al., 2019), a lexical database providing translations of 1016 words into 107 languages. We experiment with 9 languages that use the Latin script. For Bloom, we use 5 additional languages that do not use the
|
| 67 |
+
|
| 68 |
+
Table 2: Meta prompts used in Step 1 of our method for paraphrasing using GPT3.
|
| 69 |
+
|
| 70 |
+
<table><tr><td>Meta prompts</td></tr><tr><td>Write a paraphrase for the following sentence: <seed-prompt> Paraphrase: <seed-prompt> Paraphrase:</td></tr><tr><td>Write a likely paraphrase of the text: <seed-prompt> Paraphrase:</td></tr><tr><td>Write a sentence similar to the following one: <seed-prompt> Paraphrase:</td></tr><tr><td>Paraphrase the following sentence: <seed-prompt> Paraphrase:</td></tr><tr><td>Write a variation of this sentence: <seed-prompt> How would you say the following sentence in a different way? <seed-prompt></td></tr></table>
|
| 71 |
+
|
| 72 |
+
Table 3: Number of prompts for the different tasks: prompts after step 0 (creating prompts manually), prompts after step 1 (GPT3 paraphrasing), and prompts after step 2 (backtranslation).
|
| 73 |
+
|
| 74 |
+
<table><tr><td>Task</td><td># Step 0</td><td># Step 1 # Step 2</td></tr><tr><td>Word-Level Translation</td><td>12 59</td><td>118</td></tr><tr><td>Antonyms</td><td>12 85</td><td>176</td></tr><tr><td>GLUE Cola</td><td>4 27</td><td>144</td></tr><tr><td>Newspop</td><td>13 43</td><td>119</td></tr><tr><td>AG News</td><td>4 23</td><td>108</td></tr><tr><td>IMDB</td><td>10 45</td><td>178</td></tr><tr><td>DBpedia</td><td>8 23</td><td>103</td></tr><tr><td>Emotion</td><td>4 14</td><td>94</td></tr><tr><td>Tweet Offensive</td><td>5 41</td><td>119</td></tr></table>
|
| 75 |
+
|
| 76 |
+
Latin script (since Bloom is multilingual). Note that only 5 of the languages we experiment with are officially covered by Bloom.6
|
| 77 |
+
|
| 78 |
+
We also consider antonym prediction where, given a word, the model is expected to predict its antonym. For this task, we use data from Kaggle,7 which is based on WordNet (Miller, 1995). We choose 1,000 word pairs at random.
|
| 79 |
+
|
| 80 |
+
Classification Tasks We choose classification tasks from Huggingface Datasets,8 with an attempt to have a set of diverse tasks that use relatively short inputs, with some prompts available in PromptSource (Bach et al., 2022):9 (a) GLUE Cola (grammaticality; Warstadt et al. 2018); (b) Newspop (news classification; Moniz and Torgo 2018); (c) AG News (news classification; Zhang et al. 2015); (d) IMDB (movie review classification; Maas et al. 2011); (e) DBpedia (topic classification; Lehmann et al. 2015); (f) Emotion (classification to emotions; Saravia et al. 2018); (g) Tweet Offensive (classification to offensive vs. not offensive tweets; Barbieri et al. 2020). We use 1,000 random examples from each dataset.
|
| 81 |
+
|
| 82 |
+
The full set of manual prompts is listed in Section A in the Appendix. In these tasks, the prompt follows the input, and at the end of each prompt we add the choices of classes (i.e., we provide the possible labels explicitly in the prompt by listing the possible answers as defined by the dataset itself.): “Choices: X, Y, Z. Answer:” as we find it helps in terms of accuracy. Defining the label space likely helps in our zero-shot setting because there are no previous demonstrations from which the model can learn the possible classes. Additionally, adding class options to the prompt helps to reduce the effect of the surface form competition (Holtzman et al., 2021). The option of generating the answer and comparing it with the gold label was not reasonable here, since we cannot expect the model to generate the exact label as the first choice often enough.
|
| 83 |
+
|
| 84 |
+
# 4.2 Implementation Details
|
| 85 |
+
|
| 86 |
+
In all experiments we evaluate zero-shot performance. To avoid noise when computing perplexity, we instantiate the prompts with 1,000 examples of the dataset, compute the perplexity of the prompt with each example, and calculate the average across all instantiated prompts.
|
| 87 |
+
|
| 88 |
+
To estimate the performance of the prompt, we look at two measures: (a) the language model score (log probability) of the correct label, averaged across 1,000 examples; (b) the accuracy on the task, computed over the 1,000 examples. To compute accuracy, for each example we score all classes and choose the highest ranking class as the prediction of the model. The score of a label of multiple tokens is defined by the sum of the token
|
| 89 |
+
|
| 90 |
+
Table 4: Prompts for the task AG News (news classification): the manually created prompts and a sample of automatically created prompts using our method.
|
| 91 |
+
|
| 92 |
+
<table><tr><td>All Manually Created Prompts</td><td>Examples of Similar Automatically Created Prompts</td></tr><tr><td>What label best describes this news article?</td><td>What's the most accurate label for this news article?</td></tr><tr><td>What is this piece of news regarding? Which newspaper section would this article likely appear in?</td><td>What does this piece of news concern?</td></tr><tr><td>What topic is this news article about?</td><td>In what section of the newspaper could this article be published? What category does this article fall into?</td></tr></table>
|
| 93 |
+
|
| 94 |
+
Table 5: Correlation results for the different tasks, with OPT (different sizes) and Bloom. Correlations with $p < 0 . 0 5$ are marked with \*. Correlations with $p < 0 . 0 0 6 2 5$ (according to Bonferroni correction for multiple hypotheses) are marked with $^ { * * }$ . Dark and light blue colored cells stand for negative correlations $< - 0 . 2$ and $> - 0 . 2$ , respectively. Dark and light orange colored cells stand for positive correlations $> 0 . 2$ and $< 0 . 2$ , respectively. Average accuracy across all prompts and average accuracy of best $50 \%$ prompts are also reported for reference (Avg Acc and Acc $50 \%$ , respectively).
|
| 95 |
+
|
| 96 |
+
<table><tr><td>Model</td><td>Task</td><td colspan="2">Perplexity-score corr. Pearson Spearman</td><td colspan="2">Perplexity-acc corr. Pearson Spearman</td><td rowspan="2"> Avg Acc</td><td rowspan="2"> Acc 50%</td></tr><tr><td rowspan="8">OPT175B</td><td>Antonyms</td><td>**-0.41</td><td>**-0.53</td><td></td><td></td></tr><tr><td>GLUE Cola</td><td>-0.15</td><td>-0.14</td><td>-0.04</td><td>1 -0.02</td><td>1 47.7</td><td>1 57.1</td></tr><tr><td>Newspop</td><td>*-0.24</td><td>**-0.26</td><td> *-0.20</td><td>-0.18</td><td>66.4</td><td>72.9</td></tr><tr><td>AG News</td><td>**-0.63</td><td> **-0.68</td><td> **-0.77</td><td>**-0.81</td><td>57.5</td><td>68.7</td></tr><tr><td>IMDB</td><td>**0.35</td><td>**0.40</td><td>0.14</td><td>*0.20</td><td>86.2</td><td>91.0</td></tr><tr><td>DBpedia</td><td> **-0.50</td><td>**-0.44</td><td> **-0.51</td><td>**-0.42</td><td>46.7</td><td>55.2</td></tr><tr><td>Emotion</td><td>-0.14</td><td>-0.19</td><td> **-0.30</td><td> **-0.32</td><td>16.4</td><td>23.0</td></tr><tr><td>Tweet Offensive</td><td>*-0.19</td><td>0.07</td><td>0.18</td><td>*0.23</td><td>51.3</td><td>55.8</td></tr><tr><td rowspan="8">Bloom 176B</td><td>Antonyms</td><td>**-0.37</td><td>**-0.23</td><td></td><td></td><td>1</td><td>1</td></tr><tr><td>GLUE Cola</td><td>0.07</td><td>0.11</td><td>**-0.25</td><td>**-0.26</td><td>55.5</td><td>65.6</td></tr><tr><td>Newspop</td><td>**-0.50</td><td>**-0.42</td><td> **-0.59</td><td> **-0.51</td><td>78.9</td><td>87.8</td></tr><tr><td>AG News</td><td>**-0.62</td><td> **-0.54</td><td>**-0.44</td><td>**-0.44</td><td>50.3</td><td>59.4</td></tr><tr><td>IMDB</td><td>0.04</td><td>0.09</td><td>-0.08</td><td>-0.14</td><td>89.3</td><td>92.2</td></tr><tr><td>DBpedia</td><td>**-0.47</td><td> *-0.27</td><td>**-0.35</td><td>*-0.21</td><td>27.2</td><td>33.4</td></tr><tr><td>Emotion</td><td>**-0.33</td><td> **-0.42</td><td>**-0.48</td><td>**-0.55</td><td>29.3</td><td>31.7</td></tr><tr><td>Tweet Offensive</td><td>0.14</td><td>*0.24</td><td> *-0.20</td><td>-0.03</td><td>41.6</td><td>46.2</td></tr><tr><td rowspan="8">OPT 30B</td><td> Antonyms</td><td> **-0.54</td><td>**-0.70</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>GLUE Cola</td><td>-0.05</td><td>0.03</td><td>-0.13</td><td>0.02</td><td>32.2</td><td>35.5</td></tr><tr><td>Newspop</td><td>*-0.23</td><td> *-0.25</td><td>*-0.18</td><td>-0.12</td><td>60.3</td><td>66.6</td></tr><tr><td>AG News</td><td>**-0.66</td><td> **-0.71</td><td> **-0.81</td><td>**-0.80</td><td>49.3</td><td>60.7</td></tr><tr><td>IMDB</td><td>-0.06</td><td>*0.17</td><td>0.04</td><td>**0.22</td><td>81.6</td><td>86.1</td></tr><tr><td>DBpedia</td><td> **-0.41</td><td> **-0.34</td><td>*-0.21</td><td>*-0.25</td><td>35.9</td><td>42.4</td></tr><tr><td>Emotion</td><td>0.00</td><td>-0.03</td><td>0.18</td><td>0.13</td><td>12.3</td><td>16.2</td></tr><tr><td>Tweet Offensive</td><td>**-0.44</td><td>**-0.39</td><td>-0.11</td><td>-0.05</td><td>54.6</td><td>60.2</td></tr><tr><td rowspan="8">OPT 1.3B</td><td>Antonyms</td><td> **-0.45</td><td>**-0.53</td><td></td><td></td><td>1</td><td></td></tr><tr><td>GLUE Cola</td><td> **-0.39</td><td> **-0.36</td><td>-0.09</td><td>*-0.19</td><td>60.3</td><td>1 65.9</td></tr><tr><td>Newspop</td><td>**0.33</td><td>*0.21</td><td>-0.07</td><td>-0.07</td><td>37.6</td><td>40.3</td></tr><tr><td>AG News</td><td>**-0.33</td><td>**-0.29</td><td> **-0.56</td><td> **-0.49</td><td>31.9</td><td>37.6</td></tr><tr><td>IMDB</td><td>-0.11</td><td>-0.07</td><td>**0.24</td><td>**0.22</td><td>86.0</td><td>89.1</td></tr><tr><td>DBpedia</td><td>-0.16</td><td>-0.14</td><td>-0.02</td><td>-0.01</td><td>8.7</td><td>9.2</td></tr><tr><td>Emotion</td><td>0.08</td><td>0.08</td><td>**-0.29</td><td>**-0.30</td><td>7.0</td><td>9.1</td></tr><tr><td>Tweet Offensive</td><td>**-0.42</td><td>**-0.35</td><td> **-0.50</td><td>**-0.38</td><td>58.6</td><td>62.6</td></tr></table>
|
| 97 |
+
|
| 98 |
+
scores.
|
| 99 |
+
|
| 100 |
+
For the word prediction tasks we only report scores, since accuracy in general is less stable, suffers more from the surface form competition (Holtzman et al., 2021), and is usually quite low for these tasks in our setting (the chances the model will generate an exact match of the label are low). Hence, the score of the correct label gives a better estimate of the actual performance of the model.
|
| 101 |
+
|
| 102 |
+
Table 6: Correlation results for word-level translation, with OPT 175B and Bloom 176B. All correlations are statistically significant also according to Bonferroni correction for multiple hypotheses for OPT $( p < 0 . 0 0 5 5 )$ . Same for Bloom $( p \textless 0 . 0 0 3 5 7 )$ , except for Catalan (Pearson) and Japanese (Spearman).
|
| 103 |
+
|
| 104 |
+
<table><tr><td rowspan="2">Lang</td><td colspan="2">OPT175B</td><td rowspan="2">Bloom 176B Pearson</td><td rowspan="2">Spear.</td></tr><tr><td>Pearson</td><td>Spear.</td></tr><tr><td>ita</td><td>-0.44</td><td>-0.57</td><td>-0.37</td><td>-0.63</td></tr><tr><td>spa</td><td>-0.47</td><td>-0.61</td><td>-0.51</td><td>-0.66</td></tr><tr><td>cat</td><td>-0.47</td><td>-0.58</td><td>-0.24</td><td>-0.31</td></tr><tr><td>fra</td><td>-0.48</td><td>-0.57</td><td>-0.48</td><td>-0.64</td></tr><tr><td>deu</td><td>-0.44</td><td>-0.60</td><td>-0.46</td><td>-0.65</td></tr><tr><td>fin</td><td>-0.44</td><td>-0.62</td><td>-0.34</td><td>-0.56</td></tr><tr><td>por</td><td>-0.45</td><td>-0.62</td><td>-0.46</td><td>-0.61</td></tr><tr><td>eus</td><td>-0.47</td><td>-0.61</td><td>-0.45</td><td>-0.61</td></tr><tr><td>tur</td><td>-0.44</td><td>-0.62</td><td>-0.33</td><td>-0.62</td></tr><tr><td>jpn</td><td></td><td></td><td>-0.33</td><td>-0.26</td></tr><tr><td>arb</td><td></td><td></td><td>-0.36</td><td>-0.47</td></tr><tr><td>rus</td><td>1</td><td></td><td>-0.54</td><td>-0.69</td></tr><tr><td>kor</td><td></td><td></td><td>-0.42</td><td>-0.58</td></tr><tr><td>ell</td><td></td><td></td><td>-0.40</td><td>-0.51</td></tr></table>
|
| 105 |
+
|
| 106 |
+
# 5 Results
|
| 107 |
+
|
| 108 |
+
Classification Tasks and Antonym Prediction Table 5 depicts the Pearson and Spearman correlation results on the classification tasks and the antonym task, with both OPT 175B and Bloom (two upper blocks). We see that most correlations are negative and statistically significant, as we expect. This validates our hypothesis and shows that in the majority of tasks we indeed get a strong correlation between low perplexity of the prompt and better performance on the task.10 For each task we also report the average accuracy.
|
| 109 |
+
|
| 110 |
+
Word-Level Translation The results of the wordlevel translation task are reported in Table 6. Here the correlations are extremely consistent across all languages and across models, with statistical significance for all languages except for Catalan and Japanese (in Bloom).
|
| 111 |
+
|
| 112 |
+
Results across Different Model Sizes We repeat the same experiment with the OPT models of sizes 1.3B and 30B, to investigate whether these correlations are also consistent across model sizes or whether this is a phenomenon we should expect only in large language models. Table 5 (two lower blocks) shows these results for all classification tasks and antonym prediction. We do see that in general the trend appears to be the same in the smaller models as well; however, the correlations seem to be slightly weaker. We hypothesize that this might be due to the overall lower performance of these smaller models, making the performance results we use for correlation less stable and reliable. For word-level translation, however, all correlations with the 30B and 1.3B models are similar to those with the 175B model, and are all statistically significant (also after Bonferroni correction for multiple hypotheses).
|
| 113 |
+
|
| 114 |
+
# 6 Analysis
|
| 115 |
+
|
| 116 |
+
Next, we further explore the observed relationship between model perplexity and prompt performance. Despite the consistently high correlation between these two factors, the structure of this relationship varies across tasks (Section 6.1). Additionally, we find that the automatically added prompts are highquality and not a significant source of noise (Section 6.2), and that the best prompts selected by our approach vary across models (Section 6.3).
|
| 117 |
+
|
| 118 |
+
# 6.1 Visualizing the Relationship between Perplexity and Performance
|
| 119 |
+
|
| 120 |
+
To visualize the correlations we get between the perplexity and the performance of the prompts across the different settings, we plot a few examples for different tasks and languages. Figures 1 and 2 show some of the results for selected tasks, as detailed in the captions. The negative trend of the correlation is clearly visible in all plots. Interestingly, the structure of the plots for word-level translation are very similar across all the language pairs, suggesting that prompts get consistent perplexity and performance across languages (possibly at different scales). Indeed, the intersection of the 10 lowest perplexity prompts between any two different languages is 8.6 and 8.4 on average (for OPT 175B and Bloom, respectively), which is extremely high. This is not very surprising since we know that the only differences between the prompts in the different languages are the names of the target languages (e.g., The word for “dog” in French is “). Additionally, the intersection of 10 prompts with the highest label score between any two different languages is 7 and 6.5 on average (for OPT 175B and Bloom, respectively).
|
| 121 |
+
|
| 122 |
+
A notable finding that appears in the word-level translation plots is the clear separation between prompts that include or do not include quotation marks for the label (usually aligns with whether the prompt uses quotation marks for the source word) – three example prompts appear on the plot. Prompts with quotation marks for the words tend to have both lower perplexity and better performance, consistently. We further analyze the results for OPT 175B within clusters (with/without quotations marks). In the cluster with quotation marks, we get negative correlations (in the range of $- 0 . 2 8$ to –0.38) that are statistically significant for almost all languages. The correlations within the other cluster are weaker and less significant (this is expected given the overall lower performance of that cluster).
|
| 123 |
+
|
| 124 |
+

|
| 125 |
+
Figure 2: Score of correct label vs. perplexity for the word-level translation task in French with OPT 175B. The $x$ axis is in log scale. The blue points stand for prompts with quotation marks for the words, while the yellow points are of prompts without quotation marks.
|
| 126 |
+
|
| 127 |
+
# 6.2 Effect of Noisy Prompts
|
| 128 |
+
|
| 129 |
+
We expect our automatic method for expanding the set of prompts to also introduce some noise. Though our focus is on the lower perplexity prompts, since we want to benefit from this analysis and be able to devise a method for creating better prompts, we do want to make sure that this potential noise is not the cause for the strong correlations we get. In other words, one might claim that some noisy prompts have particularly high perplexity and also perform badly, thus, supporting our hypothesis in an undesirable and uncontrolled manner.
|
| 130 |
+
|
| 131 |
+
We turn to inspect the $10 \%$ highest perplexity prompts in the different tasks and find subjectively that they are not noisy, and are usually valid prompts for the tasks. The 5 highest perplexity prompts for the GLUE Cola task are listed in Table 7 as an example.
|
| 132 |
+
|
| 133 |
+
Table 7: Example of the 5 highest perplexity prompts for GLUE Cola, using OPT 175B.
|
| 134 |
+
|
| 135 |
+
<table><tr><td>prompt</td><td>ppl</td></tr><tr><td>Is this example correct English usage?</td><td>25.79</td></tr><tr><td>Is this example using English correctly?</td><td>25.46</td></tr><tr><td>Is this example correct English?</td><td>25.33</td></tr><tr><td>Is this the example in correct English?</td><td>25.00</td></tr><tr><td>Is English in this example correct?</td><td>24.90</td></tr></table>
|
| 136 |
+
|
| 137 |
+
Table 8: Correlations before and after filtering out noisy prompts, with AG News and Word-Level Translation (WLT).
|
| 138 |
+
|
| 139 |
+
<table><tr><td rowspan="2">Task</td><td rowspan="2">Lang</td><td colspan="2">Before filtering</td><td colspan="2">After filtering</td></tr><tr><td>Pearson</td><td>Spearman</td><td>Pearson</td><td>Spearman</td></tr><tr><td>AG News</td><td>-</td><td>-0.63</td><td>-0.68</td><td>-0.62</td><td>-0.54</td></tr><tr><td rowspan="9">WLT</td><td>ita</td><td>-0.44</td><td>-0.58</td><td>-0.44</td><td>-0.57</td></tr><tr><td>spa</td><td>-0.47</td><td>-0.61</td><td>-0.47</td><td>-0.61</td></tr><tr><td>cat</td><td>-0.45</td><td>-0.57</td><td>-0.47</td><td>-0.58</td></tr><tr><td>fra</td><td>-0.47</td><td>-0.57</td><td>-0.48</td><td>-0.57</td></tr><tr><td>deu</td><td>-0.43</td><td>-0.60</td><td>-0.44</td><td>-0.60</td></tr><tr><td>fin</td><td>-0.41</td><td>-0.60</td><td>-0.44</td><td>-0.62</td></tr><tr><td>por</td><td>-0.43</td><td>-0.61</td><td>-0.45</td><td>-0.62</td></tr><tr><td>eus</td><td>-0.45</td><td>-0.60</td><td>-0.47</td><td>-0.61</td></tr><tr><td>tur</td><td>-0.43</td><td>-0.61</td><td>-0.44</td><td>-0.62</td></tr></table>
|
| 140 |
+
|
| 141 |
+
As a sanity check, we choose two tasks: wordlevel translation and AG News, manually filter out the noisy prompts, and compute the correlations again. The annotation is done by external annotators (NLP researchers) that were presented with the tasks and asked to label whether the prompt is reasonable to use for the task. The new correlations with OPT 175B are reported in Table 8. We find that all correlations remain strong and statistically significant when noise is manually removed from the analysis. We get the same trends with Bloom as well.
|
| 142 |
+
|
| 143 |
+
# 6.3 Best Performing Prompts
|
| 144 |
+
|
| 145 |
+
Table 9 lists the 5 lowest perplexity prompts for the task of antonym prediction, as an example. Similar lists for the rest of the tasks are listed in Section B in the Appendix.
|
| 146 |
+
|
| 147 |
+
A closer look at the lowest perplexity prompts reveals that the intersection of 10 lowest perplexity prompts between OPT 175B and Bloom is 7.1 on average, across the classification tasks. When looking at the 10 highest accuracy prompts across models we get an average intersection of 3.1 across the classification tasks.
|
| 148 |
+
|
| 149 |
+
Table 9: Lowest perplexity prompts for the antonym prediction task, using OPT 175B.
|
| 150 |
+
|
| 151 |
+
<table><tr><td>prompt</td><td>ppl</td></tr><tr><td>The following two words are antonyms:“good"and “</td><td>10.24</td></tr><tr><td>The antonym of the word“good’is“</td><td>10.32</td></tr><tr><td>The word that has the opposite meaning of the word “good"is “</td><td>10.43</td></tr><tr><td>The word“good’is the antithesis of the word “</td><td>10.85</td></tr><tr><td>The word “good"is the opposite of the word “</td><td>11.15</td></tr></table>
|
| 152 |
+
|
| 153 |
+
# 7 SPELL: Selecting Prompts by Estimating LM Likelihood
|
| 154 |
+
|
| 155 |
+
The primary contribution of this work is the analysis of the relationship between prompt perplexity and downstream task performance (Section 5). As one potential application of our findings, we also present a new method, SPELL, for generating and selecting consistently effective prompts.
|
| 156 |
+
|
| 157 |
+
Assuming a fixed computational budget for finding effective prompts for a given task, and that the search space might be quite large, we devise the following straightforward procedure:
|
| 158 |
+
|
| 159 |
+
1. Obtain a small set of manually created prompts for the task.
|
| 160 |
+
2. Expand the set of prompts with automatic paraphrasing using a LM (e.g., GPT3) and backtranslation (see Section 3).
|
| 161 |
+
3. Rank the list of prompts by perplexity (averaged on a representative sample of task inputs, e.g., 1,000).
|
| 162 |
+
4. Choose the $k$ (e.g., 3) lowest perplexity prompts.
|
| 163 |
+
|
| 164 |
+
Using this algorithm, we show empirically that it is best to prioritize experimenting with the lowest perplexity prompts, as they are more stable (exhibit less variation in performance) and perform better than manual prompts on average. This method also does not require any labels for the task, and is applicable to any task, also by non-experts, given example inputs only.
|
| 165 |
+
|
| 166 |
+
# 7.1 Empirical Validation of SPELL
|
| 167 |
+
|
| 168 |
+
To show the effectiveness of our method, we report the results we get using SPELL across the different tasks. In Table 10 we report the average accuracy with the manual prompts compared to the average accuracy with the 3 lowest-perplexity prompts, for both OPT 175B and Bloom. Indeed, in most cases, the average accuracy using the 3 lowest perplexity prompts outperforms the average accuracy of the manual prompts, with an average of 1.8 accuracy points across tasks with OPT and 2.3 accuracy points with Bloom, demonstrating the effectiveness of our method.
|
| 169 |
+
|
| 170 |
+
Table 10: The average accuracy with the manual prompts (manual) compared to the average accuracy with the 3 lowest-perplexity prompts (low-ppl), for both OPT 175B and Bloom, across tasks.
|
| 171 |
+
|
| 172 |
+
<table><tr><td></td><td colspan="3">OPT</td><td colspan="3">Bloom</td></tr><tr><td>Task</td><td>low-ppl</td><td>manual</td><td>△</td><td>low-ppl</td><td>manual</td><td>△</td></tr><tr><td>GLUE Cola</td><td>51.7</td><td>48.5</td><td>3.1</td><td>64.5</td><td>60.9</td><td>3.6</td></tr><tr><td>Newspop</td><td>80.6</td><td>70.4</td><td>10.2</td><td>90.0</td><td>80.0</td><td>10.0</td></tr><tr><td>AG News</td><td>68.4</td><td>61.9</td><td>6.5</td><td>51.0</td><td>63.5</td><td>-12.5</td></tr><tr><td>IMDB</td><td>90.4</td><td>88.9</td><td>1.4</td><td>91.3</td><td>88.8</td><td>2.5</td></tr><tr><td>DBpedia</td><td>46.0</td><td>51.7</td><td>-5.7</td><td>31.2</td><td>30.2</td><td>1.0</td></tr><tr><td>Emotion</td><td>21.6</td><td>22.6</td><td>-1.1</td><td>35.8</td><td>32.1</td><td>3.6</td></tr><tr><td>Tweet Offensive</td><td>48.4</td><td>50.6</td><td>-2.3</td><td>48.6</td><td>40.8</td><td>7.8</td></tr></table>
|
| 173 |
+
|
| 174 |
+
The variability in accuracy of the 3 lowest perplexity prompts is also much lower than that of the manually created prompts: with OPT 175B, the average standard deviation within the 3 lowest perplexity prompts (across tasks) is 5.07, vs. 6.86 for the manual prompts, and with Bloom the gap is much bigger, with an average of 2.6 for the 3 lowest perplexity prompts vs. 7.47 for the manual ones.11 This further shows that SPELL is more stable and reliable compared to using an arbitrary set of manually created prompts. SPELL sets the stage for further development in this direction, and serves as an initial indication of the benefits of involving perplexity estimation in the process of generating effective prompts.
|
| 175 |
+
|
| 176 |
+
# 8 Related Work
|
| 177 |
+
|
| 178 |
+
Relation between performance and training data Previous work looking directly into the relation between the training data and the performance is limited. Razeghi et al. (2022) study numeric deduction tasks, and examine the correlations between the model performance on specific test instances and the frequency of terms from those instances in the pretraining data. They find that the models are more accurate on instances whose terms are more prevalent in the training data. Additionally, Han and Tsvetkov (2022) propose a method to effectively identify a very small subset of pretraining data that directly supports the model in performing a specific task. Elazar et al. (2022) use causal inference to measure the effect of pretraining data statistics on factual knowledge performance, and
|
| 179 |
+
|
| 180 |
+
Kandpal et al. (2022) show correlational and causal relationships between accuracy and relevant document count (from training data) for QA datasets.
|
| 181 |
+
|
| 182 |
+
Prompt tuning and analysis There is a very rich line of work trying to find prompts automatically. Shin et al. (2020) present an automated method to create discrete prompts for a diverse set of tasks, based on a gradient-guided search, and they demonstrate their method on masked LMs. Other work also focuses on discrete prompts, aiming to improve zero-shot performance (Gao et al., 2021; Le Scao and Rush, 2021; Deng et al., 2022; Shi et al., 2022), or trains continuous prompts (Li and Liang, 2021; Lester et al., 2021; Qin and Eisner, 2021).
|
| 183 |
+
|
| 184 |
+
On top of works that suggest a variety of methods for creating better prompts, some work also analyzes those prompts to try and get some insights about them: Khashabi et al. (2022a) find that model performance is highly sensitive to small changes in wordings and Khashabi et al. (2022b) point to a surprising disconnect between continuous and discrete prompts.
|
| 185 |
+
|
| 186 |
+
# Limitations
|
| 187 |
+
|
| 188 |
+
Searching for human-readable prompts We limit our search space to human-readable prompts that are fluent and accurately describe the task at hand, as we are primarily motivated in understanding why some relevant prompts work better than others. We do this by using manually created prompts and their automatically created paraphrases. Our findings may not hold when the possible prompt space is expanded to include any token sequence; we leave this direction to future work.
|
| 189 |
+
|
| 190 |
+
Generality of our analysis and of the SPELL method We perform our analysis on and build our method around specific models, namely OPT and Bloom. Additionally, our study is limited to the specific tasks we experiment with and to English. It is possible that our analysis and SPELL method do not generalize to other pretrained models or tasks; however, we consider models of various sizes and from different sources, and a wide range of tasks to mitigate this risk.
|
| 191 |
+
|
| 192 |
+
# Acknowledgements
|
| 193 |
+
|
| 194 |
+
We thank Alisa Liu and Orevaoghene Ahia for their help in annotating noisy prompts. We also thank the reviewers for their valuable comments on the paper.
|
| 195 |
+
|
| 196 |
+
# 9 Conclusion
|
| 197 |
+
|
| 198 |
+
We investigate the phenomenon where some prompts perform better than others despite appearing similar to the human users of LMs. Specifically, we hypothesize that the perplexity of a prompt under a given LM is closely tied to its task performance. We test this theory on a large number of tasks and autoregressive LMs, and the resulting correlation study validates our hypothesis. Further analysis of this relationship demonstrates that the best prompts differ across models, highlighting the importance of model-specific analysis, and that the underlying structure of the relationship between perplexity and performance varies across tasks.
|
| 199 |
+
|
| 200 |
+
In light of these findings, we then propose a method, SPELL, to help users find wellperforming prompts for new tasks. Empirical validation of the proposed procedure shows that SPELL generates effective prompts with low variability in performance, and produces small gains of 1.8 (2.3) accuracy points with OPT (Bloom) over manual prompts. We therefore conclude that SPELL provides a general and interpretable approach for applying LMs to new tasks while requiring minimal human effort, and no labels.
|
| 201 |
+
|
| 202 |
+
# References
|
| 203 |
+
|
| 204 |
+
Stephen H. Bach, Victor Sanh, Zheng-Xin Yong, Albert Webson, Colin Raffel, Nihal V. Nayak, Abheesht Sharma, Taewoon Kim, M Saiful Bari, Thibault Fevry, Zaid Alyafeai, Manan Dey, Andrea Santilli, Zhiqing Sun, Srulik Ben-David, Canwen Xu, Gunjan Chhablani, Han Wang, Jason Alan Fries, Maged S. Al-shaibani, Shanya Sharma, Urmish Thakker, Khalid Almubarak, Xiangru Tang, Xiangru Tang, Mike Tian-Jian Jiang, and Alexander M. Rush. 2022. Promptsource: An integrated development environment and repository for natural language prompts.
|
| 205 |
+
|
| 206 |
+
Francesco Barbieri, Jose Camacho-Collados, Luis Espinosa-Anke, and Leonardo Neves. 2020. TweetEval:Unified Benchmark and Comparative Evaluation for Tweet Classification. In Proceedings of Findings of EMNLP.
|
| 207 |
+
|
| 208 |
+
Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. 2020. Language models are few-shot learners. Advances in neural information processing systems, 33:1877–1901.
|
| 209 |
+
|
| 210 |
+
Yanda Chen, Chen Zhao, Zhou Yu, Kathleen McKeown, and He He. 2022. On the relation between sensitivity and accuracy in in-context learning. arXiv e-prints, pages arXiv–2209.
|
| 211 |
+
|
| 212 |
+
Marta R Costa-jussà, James Cross, Onur Çelebi, Maha Elbayad, Kenneth Heafield, Kevin Heffernan, Elahe Kalbassi, Janice Lam, Daniel Licht, Jean Maillard, et al. 2022. No language left behind: Scaling human-centered machine translation. arXiv preprint arXiv:2207.04672.
|
| 213 |
+
|
| 214 |
+
Johannes Dellert, Thora Daneyko, Alla Münch, Alina Ladygina, Armin Buch, Natalie Clarius, Ilja Grigorjew, Mohamed Balabel, Hizniye Isabella Boga, Zalina Baysarova, et al. 2019. Northeuralex: a widecoverage lexical database of northern eurasia. Language Resources and Evaluation, pages 1–29.
|
| 215 |
+
|
| 216 |
+
Mingkai Deng, Jianyu Wang, Cheng-Ping Hsieh, Yihan Wang, Han Guo, Tianmin Shu, Meng Song, Eric P Xing, and Zhiting Hu. 2022. Rlprompt: Optimizing discrete text prompts with reinforcement learning. arXiv preprint arXiv:2205.12548.
|
| 217 |
+
|
| 218 |
+
Yanai Elazar, Nora Kassner, Shauli Ravfogel, Amir Feder, Abhilasha Ravichander, Marius Mosbach, Yonatan Belinkov, Hinrich Schütze, and Yoav Goldberg. 2022. Measuring causal effects of data statistics on language model’sfactual’predictions. arXiv preprint arXiv:2207.14251.
|
| 219 |
+
|
| 220 |
+
Tianyu Gao, Adam Fisch, and Danqi Chen. 2021. Making pre-trained language models better few-shot learners. 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 3816–3830.
|
| 221 |
+
|
| 222 |
+
Xiaochuang Han and Yulia Tsvetkov. 2022. Orca: Interpreting prompted language models via locating supporting data evidence in the ocean of pretraining data. arXiv preprint arXiv:2205.12600.
|
| 223 |
+
|
| 224 |
+
Ari Holtzman, Peter West, Vered Shwartz, Yejin Choi, and Luke Zettlemoyer. 2021. Surface form competition: Why the highest probability answer isn’t always right. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 7038–7051.
|
| 225 |
+
|
| 226 |
+
Nikhil Kandpal, Haikang Deng, Adam Roberts, Eric Wallace, and Colin Raffel. 2022. Large language models struggle to learn long-tail knowledge. arXiv preprint arXiv:2211.08411.
|
| 227 |
+
|
| 228 |
+
Daniel Khashabi, Chitta Baral, Yejin Choi, and Hannaneh Hajishirzi. 2022a. Reframing instructional prompts to gptk’s language. In Findings of the Association for Computational Linguistics: ACL 2022, pages 589–612.
|
| 229 |
+
|
| 230 |
+
Daniel Khashabi, Xinxi Lyu, Sewon Min, Lianhui Qin, Kyle Richardson, Sean Welleck, Hannaneh Hajishirzi, Tushar Khot, Ashish Sabharwal, Sameer
|
| 231 |
+
|
| 232 |
+
Singh, and Yejin Choi. 2022b. Prompt waywardness: The curious case of discretized interpretation of continuous prompts. In Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies.
|
| 233 |
+
|
| 234 |
+
Teven Le Scao and Alexander Rush. 2021. How many data points is a prompt worth? In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies. Association for Computational Linguistics.
|
| 235 |
+
|
| 236 |
+
Jens Lehmann, Robert Isele, Max Jakob, Anja Jentzsch, Dimitris Kontokostas, Pablo N Mendes, Sebastian Hellmann, Mohamed Morsey, Patrick Van Kleef, Sören Auer, et al. 2015. Dbpedia–a large-scale, multilingual knowledge base extracted from wikipedia. Semantic web, 6(2):167–195.
|
| 237 |
+
|
| 238 |
+
Brian Lester, Rami Al-Rfou, and Noah Constant. 2021. The power of scale for parameter-efficient prompt tuning. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 3045–3059.
|
| 239 |
+
|
| 240 |
+
Xiang Lisa Li and Percy Liang. 2021. Prefix-tuning: Optimizing continuous prompts for generation. 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 4582– 4597.
|
| 241 |
+
|
| 242 |
+
Alexandra Sasha Luccioni, Sylvain Viguier, and AnneLaure Ligozat. 2022. Estimating the carbon footprint of bloom, a 176b parameter language model. arXiv preprint arXiv:2211.02001.
|
| 243 |
+
|
| 244 |
+
Andrew L. Maas, Raymond E. Daly, Peter T. Pham, Dan Huang, Andrew Y. Ng, and Christopher Potts. 2011. Learning word vectors for sentiment analysis. In Proceedings of the 49th Annual Meeting of the Association for Computational Linguistics: Human Language Technologies, pages 142–150, Portland, Oregon, USA. Association for Computational Linguistics.
|
| 245 |
+
|
| 246 |
+
George A Miller. 1995. Wordnet: a lexical database for english. Communications of the ACM, 38(11):39–41.
|
| 247 |
+
|
| 248 |
+
N. Moniz and L. Torgo. 2018. Multi-source social feedback of online news feeds. ArXiv, abs/1801.07055.
|
| 249 |
+
|
| 250 |
+
Guanghui Qin and Jason Eisner. 2021. Learning how to ask: Querying lms with mixtures of soft prompts. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 5203–5212.
|
| 251 |
+
|
| 252 |
+
Yasaman Razeghi, Robert L Logan IV, Matt Gardner, and Sameer Singh. 2022. Impact of pretraining term frequencies on few-shot reasoning. arXiv preprint arXiv:2202.07206.
|
| 253 |
+
|
| 254 |
+
Elvis Saravia, Hsien-Chi Toby Liu, Yen-Hao Huang, Junlin Wu, and Yi-Shin Chen. 2018. CARER: Contextualized affect representations for emotion recognition. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pages 3687–3697, Brussels, Belgium. Association for Computational Linguistics.
|
| 255 |
+
|
| 256 |
+
Timo Schick and Hinrich Schütze. 2020. It’s not just size that matters: Small language models are also few-shot learners. arXiv preprint arXiv:2009.07118.
|
| 257 |
+
|
| 258 |
+
Weijia Shi, Xiaochuang Han, Hila Gonen, Ari Holtzman, Yulia Tsvetkov, and Luke Zettlemoyer. 2022. Toward human readable prompt tuning: Kubrick’s the shining is a good movie, and a good prompt too? arXiv preprint arXiv:2212.10539.
|
| 259 |
+
|
| 260 |
+
Taylor Shin, Yasaman Razeghi, Robert L Logan IV, Eric Wallace, and Sameer Singh. 2020. Autoprompt: Eliciting knowledge from language models with automatically generated prompts. arXiv preprint arXiv:2010.15980.
|
| 261 |
+
|
| 262 |
+
Alex Warstadt, Amanpreet Singh, and Samuel R Bowman. 2018. Neural network acceptability judgments. arXiv preprint arXiv:1805.12471.
|
| 263 |
+
|
| 264 |
+
John Wieting, Jonathan Mallinson, and Kevin Gimpel. 2017. Learning paraphrastic sentence embeddings from back-translated bitext. In Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing, pages 274–285.
|
| 265 |
+
|
| 266 |
+
Susan Zhang, Stephen Roller, Naman Goyal, Mikel Artetxe, Moya Chen, Shuohui Chen, Christopher Dewan, Mona Diab, Xian Li, Xi Victoria Lin, et al. 2022. Opt: Open pre-trained transformer language models. arXiv preprint arXiv:2205.01068.
|
| 267 |
+
|
| 268 |
+
Xiang Zhang, Junbo Jake Zhao, and Yann LeCun. 2015. Character-level convolutional networks for text classification. In NIPS.
|
| 269 |
+
|
| 270 |
+
# A Manually Created Prompts
|
| 271 |
+
|
| 272 |
+
Table 11 lists the manually created prompts we use for the different tasks. We manually add, remove and edit prompts for some of these tasks, to make them fit for our setting. For example, the following prompt for AG News, taken from Promptsource, does not fit our setting: Would you recommend the following article to a politician, an athlete, business executive, or a scientist?
|
| 273 |
+
|
| 274 |
+
# B Lowest Perplexity Prompts
|
| 275 |
+
|
| 276 |
+
Table 12 lists the 5 lowest perplexity prompts for each task, using OPT 175B.
|
| 277 |
+
|
| 278 |
+
Table 11: The set of manually created prompts for each task.
|
| 279 |
+
|
| 280 |
+
<table><tr><td>Task Manual Prompts</td><td></td></tr><tr><td>Antonyms</td><td>The antonym of the word “good”is“ The opposite meaning of the word “good”is “ “Good”is the opposite of“ “Good”is the negation of“ The following are opposites of each other:“good"and “ The word “good"contradicts the word “ The antonym of the word good is The opposite meaning of the word good is Good is the opposite of</td></tr><tr><td>GLUE Cola</td><td>The following are opposites of each other: good and The word good contradicts the word Does the this sentence make sense and use correct English? Is this example grammatically correct and sensible? Does this sentence make sense and is it grammatically correct?</td></tr><tr><td>Newspop</td><td>Does this example use correct English? What is the article about? What is this news about? What is the topic of this news piece? What does this article discuss? What is the topic of this sentence? What category does the article belong to? Pick one category forthis news piece. Pick the category that fits the text. The article refers to which category? What topic does the article belong to? What category fits this article? What topic does this news piece belong to? Choose the correct category for this article.</td></tr><tr><td>AG News</td><td>What label best describes this news article? What is this piece of news regarding? Which newspaper section would this article likely appear in? What topic is this news article about? This movie review expresses what sentiment? Did the reviewer find this movie good or bad?</td></tr><tr><td>IMDB</td><td>Is this review positive or negative? How does the viewer feel about the movie? What sentiment does the writer express for the movie? What sentiment is expressed for the movie? What is the sentiment expressed in this text? Did the reviewer enjoy the movie? What is the sentiment expressed by the reviewer for the movie? How does the reviewer feel about the movie? What category does the paragraph belong to? Pick one category for the text.</td></tr><tr><td>DBpedia</td><td>Pick the category that fits the text. The text refers to which category? What category does the title belong to? What category fits this text? What topic does this text belong to? Choose the correct category for the text. What is the emotion expressed in this message?</td></tr><tr><td>Emotion</td><td>What emotion does this message express? How will you feel about the message? What emotion does the writer express for the message? Is this tweet offensive? Can the tweet be removed for being offensive?</td></tr><tr><td>Tweet Offensive</td><td>Is the author's tweet offensive? Task: Identify if the tweetor text is offensive. Is this an offensive tweet? The translation of the word “dog"to French is“ The translation of the word dog to French is The word “dog”in French is“</td></tr><tr><td>Word-Level Translation</td><td>“dog”(In French: “ Translate the word dog into French: The translation of dog to French is “dog”(French: “ The word dog in French is Translate the word“dog”into French: “ dog (In French: dog (French: The translation of“dog”to French is “</td></tr></table>
|
| 281 |
+
|
| 282 |
+
Table 12: The 5 lowest perplexity prompts for each task, using OPT 175B.
|
| 283 |
+
|
| 284 |
+
<table><tr><td>Task</td><td>Lowest Perplexity Prompts</td><td>Perplexity</td></tr><tr><td rowspan="5">Antonyms</td><td>The following two words are antonyms:“good”and “</td><td>10.24</td></tr><tr><td>The antonym of the word“good"is“</td><td>10.32</td></tr><tr><td>The word that has the opposite meaning of the word “good" is “</td><td>10.43</td></tr><tr><td>The word“good”is the antithesis of the word“</td><td>10.85</td></tr><tr><td>The word “good” is the opposite of the word “</td><td>11.15</td></tr><tr><td rowspan="5">GLUE Cola</td><td>Is this an example of the proper use of the English language?</td><td>11.63</td></tr><tr><td>Does the sentence make sense and does it follow the rules of grammar?</td><td>11.76</td></tr><tr><td>Is this sentence an example of the correct use of the English language?</td><td>12.10</td></tr><tr><td>Does this sentence make sense and is it grammatically correct?</td><td>12.15</td></tr><tr><td>Is this sentence grammatically correct and does it make sense?</td><td>12.68</td></tr><tr><td rowspan="5">Newspop</td><td>What is the main subject of the article?</td><td>10.01</td></tr><tr><td>What is the main topic of the article?</td><td>10.01</td></tr><tr><td>What is the subject matter of the article?</td><td>10.17</td></tr><tr><td>What is the subject of the article?</td><td>10.21</td></tr><tr><td>What is the main idea of this article?</td><td>10.21</td></tr><tr><td rowspan="5">AG News</td><td>In what section of the newspaper would you expect to find this article?</td><td>7.51</td></tr><tr><td>In which section of the newspaper would you expect to find this article?</td><td>7.52</td></tr><tr><td>In which section of the newspaper would this article be most likely to appear?</td><td>7.60</td></tr><tr><td>In what section of the newspaper do you expect to find this article?</td><td>7.80</td></tr><tr><td>In what section of the newspaper would this article most likely appear?</td><td>7.87</td></tr><tr><td rowspan="5">IMDB</td><td>What is the opinion of the review? Is it positive or negative?</td><td>7.19</td></tr><tr><td>Is this a positive or negative review?</td><td>7.31</td></tr><tr><td>What do you think of the movie?</td><td>7.33</td></tr><tr><td>What do you think of the film?</td><td>7.35</td></tr><tr><td>Is that a positive or a negative?</td><td>7.35</td></tr><tr><td rowspan="5">DBpedia</td><td>What is the category to which the text refers?</td><td>8.99</td></tr><tr><td>What is the subject of the text?</td><td>9.15</td></tr><tr><td>What category does the title belong to?</td><td>9.18</td></tr><tr><td>Which category does the text refer to?</td><td>9.19</td></tr><tr><td>What is the subject of this text?</td><td>9.20</td></tr><tr><td rowspan="5">Emotion</td><td>How do you feel when you hear this message?</td><td>12.72</td></tr><tr><td>What is the writer's emotional reaction to this news?</td><td>13.18</td></tr><tr><td>What is the emotion expressed in this message?</td><td>13.20</td></tr><tr><td>How does this message make you feel?</td><td>13.32</td></tr><tr><td>How do you feel about this message?</td><td>13.50</td></tr><tr><td rowspan="5">Tweet Offensive</td><td>If someone said this to you, would you be offended?</td><td>13.00</td></tr><tr><td>If someone said that to you, would you be offended?</td><td>13.10</td></tr><tr><td>Would you be offended if someone said that to you?</td><td>13.73</td></tr><tr><td>Would it offend you if someone said that to you?</td><td>14.79</td></tr><tr><td>If someone told you that, would you be offended?</td><td>14.93</td></tr><tr><td rowspan="5">Word-Level Translation</td><td>The word for“dog"in French is“</td><td>7.73</td></tr><tr><td>The French word for“dog”is“</td><td>8.16</td></tr><tr><td>The French translation of the word“dog”is“</td><td>8.24</td></tr><tr><td>The translation of the word “dog”in French is “</td><td>8.35</td></tr><tr><td>The translation of the word “dog” into French is “</td><td>8.91</td></tr></table>
|
md/dev/OpC-9aBBVJe/OpC-9aBBVJe.md
ADDED
|
@@ -0,0 +1,390 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SAMPLE-EFFICIENT REINFORCEMENT LEARNING BY BREAKING THE REPLAY RATIO BARRIER
|
| 2 |
+
|
| 3 |
+
Pierluca D’Oro∗ Mila, Universite de Montr´ eal´
|
| 4 |
+
|
| 5 |
+
Max Schwarzer∗
|
| 6 |
+
Google Brain
|
| 7 |
+
Mila, Universite de Montr ´ eal ´
|
| 8 |
+
|
| 9 |
+
Evgenii Nikishin Mila, Universite de Montr ´ eal ´
|
| 10 |
+
|
| 11 |
+
Pierre-Luc Bacon Mila, Universite de Montr´ eal´
|
| 12 |
+
|
| 13 |
+
Marc G. Bellemare Google Brain, Mila
|
| 14 |
+
|
| 15 |
+
Aaron Courville Mila, Universite de Montr´ eal´
|
| 16 |
+
|
| 17 |
+
# ABSTRACT
|
| 18 |
+
|
| 19 |
+
Increasing the replay ratio, the number of updates of an agent’s parameters per environment interaction, is an appealing strategy for improving the sample efficiency of deep reinforcement learning algorithms. In this work, we show that fully or partially resetting the parameters of deep reinforcement learning agents causes better replay ratio scaling capabilities to emerge. We push the limits of the sample efficiency of carefully-modified algorithms by training them using an order of magnitude more updates than usual, significantly improving their performance in the Atari $1 0 0 \mathrm { k }$ and DeepMind Control Suite benchmarks. We then provide an analysis of the design choices required for favorable replay ratio scaling to be possible and discuss inherent limits and tradeoffs.
|
| 20 |
+
|
| 21 |
+
# 1 INTRODUCTION
|
| 22 |
+
|
| 23 |
+
In many real world scenarios, each interaction with the environment comes at a cost, and it is desirable for deep reinforcement learning (RL) algorithms to learn with a minimal amount of samples (Franc¸ois-Lavet et al., 2018). This can be naturally achieved if an algorithm is able to leverage more computational resources during training to improve its performance. Given the online nature of deep RL, there is a peculiar way to aim at having such behavior: to train the agent for longer, given a dataset of experiences, before interacting with the environment again.
|
| 24 |
+
|
| 25 |
+

|
| 26 |
+
Figure 1: Scaling behavior of SAC and SR-SAC in the DeepMind Control Suite (DMC15-500k) benchmark, and of SPR and SR-SPR in the Atari $1 0 0 \mathrm { k }$ benchmark (5 seeds for point for SAC and SR-SAC, at least 20 seeds for point for SPR and SR-SPR, $9 5 \%$ bootstrapped C.I.).
|
| 27 |
+
|
| 28 |
+
A method based on this idea can be said to be scaling the replay ratio, the number of updates of an agent’s parameters for each environment interaction. Despite generally providing limited benefit when applied to standard baselines (Fedus et al., 2020; Kumar et al., 2021), replay ratio scaling has been shown to bring performance improvements to well-tuned algorithms. Recent approaches were able to achieve better sample efficiency by increasing it to higher values, up to 8 for discrete control (Kielak, 2019) or 20 for continuous control (Chen et al., 2021; Smith et al., 2022).
|
| 29 |
+
|
| 30 |
+
In this paper, we show that it is possible, with minimal but careful modifications to model-free algorithms mostly based on parameter resets (Ash & Adams, 2020; Nikishin et al., 2022), to reach new levels of replay ratio scaling and push the sample efficiency limits of deep RL. Both in continuous control, with SAC in DeepMind Control Suite (Haarnoja et al., 2018; Tassa et al., 2018), and discrete control, with SPR in Atari 100k (Schwarzer et al., 2021a; Kaiser et al., 2020), we break the replay ratio barrier, unlocking a training regime in which orders of magnitude of additional agent updates can be used to increase the performance of an algorithm for a given budget of interactions with the environment. By doing so, we obtain better aggregated scores than strong baselines, with a general blueprint to improve sample efficiency of potentially any off-policy deep RL algorithm.
|
| 31 |
+
|
| 32 |
+
To understand how this can be feasible, it is useful to reflect on one of the most common patterns observed in the development of deep RL algorithms (Mnih et al., 2015b). With a few exceptions, researchers typically ground their methods on the well-established dynamic programming mathematical machinery, combining it with optimization strategies common in deep learning. However, the RL setting is inherently different from the one in which most deep learning architectures and optimization methods were developed. In deep RL, neural networks have to deal with dynamic datasets, whose composition changes over the course of training; their training actively determines the value of future inputs, but also the value of future targets. We argue that the recently identified tendency of neural networks to lose their ability to learn and generalize from new information during training (Chaudhry et al., 2018; Ash & Adams, 2020; Berariu et al., 2021; Igl et al., 2021; Dohare et al., 2022; Lyle et al., 2022a;b; Nikishin et al., 2022), against which most RL methods deploy no countermeasures, has been the main roadblock in achieving better sample efficiency through replay ratio scaling.
|
| 33 |
+
|
| 34 |
+
After presenting and evaluating our algorithmic solution leading to better replay ratio scaling, we discuss some of the aspects of thinking about deep RL algorithms under the lens of this paradigm. We show some examples of algorithm design decisions important, or not important, for effective replay ratio scaling to be possible, with particular attention to the role of online interaction. Then, we visualize in an explicit way the data-computations tradeoff implied by this approach and, after having shown the potential of replay ratio scaling, we discuss its inherent limits.
|
| 35 |
+
|
| 36 |
+
# 2 RELATED WORK
|
| 37 |
+
|
| 38 |
+
Loss of Ability to Learn and Generalize in Neural Networks A growing body of evidence suggests that artificial neural networks lose their ability to learn and generalize during training. The phenomenon is not clearly visible when learning with a static dataset on a fixed task, but it starts appearing when the data distribution changes. In the continual learning setting, an alleviation of the problem by partially resetting the network parameters already provides a consistent improvement (Ash & Adams, 2020). Berariu et al. (2021) provides an in-depth study of how this phenomenon happens, including how many training updates are required for the performance of a network on future tasks to be unrecoverably damaged. The phenomenon becomes even more prominent in deep RL, where it has been identified in multiple settings. In the context of on-policy algorithms, it has been investigated as a consequence of transient non-stationarity and mitigated via self-distillation (Igl et al., 2021); in off-policy RL, it has been studied under the name of capacity loss (Lyle et al., 2022a), counteracted by the use of auxiliary tasks; in the sparse reward setting, it has been mitigated by post-training policy distillation (Lyle et al., 2022b). To address what they call loss of plasticity, Dohare et al. (2022) proposes a variation of backpropagation compatible with continual learning, also applying it to the continual RL context. In this paper, we primarily leverage a periodic hard resetting method (Zhou et al., 2022), as investigated in Nikishin et al. (2022) to address the primacy bias phenomenon. Our work demonstrates that addressing this phenomenon allows for increased sample efficiency by scaling the replay ratio to much higher values than other model-free methods. We report in Appendix A a more precise summary and glossary of the different related definitions from previous work.
|
| 39 |
+
|
| 40 |
+
Scaling in Deep and Reinforcement Learning The topic of understanding and exploiting the scaling behavior of a deep learning algorithm’s performance with respect to the amount of resources used for training has recently gained attention. Hestness et al. (2017) pioneered the idea of empirically studying and predicting performance when increasing a model’s size, and subsequent work investigated scaling with respect to both model and dataset size, as well as training time (Kaplan et al., 2020; Bahri et al., 2021; Djolonga et al., 2021). Recent work in language modeling has also highlighted the importance of having high-quality data and the right training setup for efficient scaling to be possible (Hoffmann et al., 2022). In RL, scaling with respect to model size has been investigated in the offline setting for decision transformers (Lee et al., 2022) and with respect to planning-time in model-based RL (Hamrick et al., 2021). For what concerns replay ratio scaling, moderately increasing the replay ratio for standard baselines has been shown to be a competitive data-efficient baseline for both discrete and continuous control when compared to model-based RL methods (Holland et al., 2018; Van Hasselt et al., 2019; Kielak, 2019; D’Oro & Jaskowski, 2020), despite clear limitations (Kumar ´ et al., 2021). Recent approaches in continuous control leveraged high replay ratios as a strategy to improve sample efficiency through the use of ensembles of value functions (Chen et al., 2021; Hiraoka et al., 2022; Wu et al., 2022) or normalization strategies (Smith et al., 2022); we argue that explicitly alleviating the progressive loss of ability to learn and generalize pushes the replay ratio scaling capabilities much further than those techniques can achieve.
|
| 41 |
+
|
| 42 |
+
# 3 EFFECTIVE REPLAY RATIO SCALING WITH RESETS
|
| 43 |
+
|
| 44 |
+
Most off-policy deep RL algorithms make use of a replay buffer (Lin, 1992) for storing transitions encountered over (a window of) an agent’s lifespan. At a fixed frequency, such methods sample a batch of transitions from the buffer, update the parameters of the agent by following the gradient of some loss function, and let the agent interact again with the environment before adding new experience to the buffer. The number of agent updates per environment step is usually called replay ratio1 (Wang et al., 2016; Fedus et al., 2020), and most standard algorithms are trained with a value around 1 (Mnih et al., 2015a; Haarnoja et al., 2018). It is natural to view increasing the replay ratio beyond these values as a way to improve sample efficiency. For ease of discussion, we now explicitly state and give a name to this idea, which has been an object of interest in previous studies (Van Hasselt et al., 2019; Kumar et al., 2021).
|
| 45 |
+
|
| 46 |
+
# Replay Ratio Scaling
|
| 47 |
+
|
| 48 |
+
Change in an agent’s performance caused by doing more updates for a fixed number of environment interactions.
|
| 49 |
+
|
| 50 |
+
This definition does not have any positive connotation per se; any deep RL algorithm will have a certain replay ratio scaling behavior, and a desirable property for an algorithm is to have particularly favorable replay ratio scaling, so that its performance can improve by increasing the replay ratio.
|
| 51 |
+
|
| 52 |
+
In contrast to other performance scaling properties analyzed for deep learning algorithms (Kaplan et al., 2020), replay ratio scaling is intertwined with the online RL paradigm: if the agent has a significantly better data-collection policy due to more training, the next collected sample will be potentially different with respect to the one collected if doing less training before the interaction; by this virtue, also future learning will be directly impacted by the presence of different data in the replay buffer. In other words, this type of scaling can only be understood by considering the interaction of an agent with an environment: training more on a small dataset of interactions, without any further collection of data, will eventually lead to challenges associated to off-policy learning (Ostrovski et al., 2021); but training more while the data is collected can drastically change the stream of incoming data and the overall learning dynamics.
|
| 53 |
+
|
| 54 |
+
Given its appeal, what are the limiting factors to increasing the replay ratio? We argue that the main factor inhibiting effective replay ratio scaling in existing deep RL algorithms has been the progressive loss of the ability to learn and generalize in neural networks (Dohare et al., 2022; Lyle et al., 2022b; Nikishin et al., 2022). It has been shown that this property hinders a neural network’s performance under task switches (Ash & Adams, 2020; Berariu et al., 2021) and, from the perspective of a neural network employed by the agent, what is deep RL if not a long sequence of related but distinct tasks (Dabney et al., 2021)?
|
| 55 |
+
|
| 56 |
+

|
| 57 |
+
Figure $2 \&$ Table 1: Performance of SR-SAC and of standard baselines on the DMC15 benchmark. (5 seeds for SR-SAC, 20 for all other algorithms, $9 5 \%$ bootstrapped C.I.).
|
| 58 |
+
|
| 59 |
+
Recent studies showed that, even under smooth task changes, the more training has been done on a previous task, the worse the performance will eventually be in a new task (Ash & Adams, 2020; Berariu et al., 2021). Since higher replay ratio correspond to an increased amount of training, this gives a natural explanation to the limit in increasing it. The ability to learn and generalize can, however, be restored. For instance, Nikishin et al. (2022) periodically reset the network’s parameters, with a frequency that is fixed with respect to the number of environment steps. In this work, we argue that the key to surprisingly effective replay ratio scaling is a periodic restoration of the ability to learn and generalize of the network, via partial (Ash & Adams, 2020) or total (Nikishin et al., 2022) resets of its parameters, with a reset frequency that only depends on the number of updates and thus implicitly also on the replay ratio. This means the more an algorithm updates its neural networks, the more frequent the restoration of its ability to learn and generalize will be, leading to better performance, as we now show in practice.
|
| 60 |
+
|
| 61 |
+
# 4 REPLAY RATIO SCALING DRASTICALLY IMPROVES SAMPLE EFFICIENCY
|
| 62 |
+
|
| 63 |
+
We apply two different reset strategies to two standard continuous control and discrete control algorithms and study their replay ratio scaling behavior. We consider Soft Actor-Critic (SAC) (Haarnoja et al., 2018), which optimizes an actor and a critic by maximizing policy entropy alongside the environment’s reward, and SPR (Schwarzer et al., 2021a), a model-free DQN-based reinforcement learning algorithm that augments a sample-efficient variant of Rainbow (Van Hasselt et al., 2019) with a model-based latent dynamics prediction objective designed to improve representation learning in the low-data regime. The two curves in Figure 1 show that it is possible, with the same algorithm, to almost double the performance for the same number of environment steps, by just varying the replay ratio. We call the modified versions of these two algorithms Scaled-by-Resetting SAC (SR-SAC) and Scaled-by-Resetting SPR (SR-SPR). In the rest of this section, we are going to describe the precise the details of the reset strategies that we employ for the two algorithms, as well as the benchmarks to which they are applied, by describing our decisions first in continuous control and then in discrete control. For evaluation and comparisons, we follow the protocol suggested by Agarwal et al. (2021).
|
| 64 |
+
|
| 65 |
+
# 4.1 CONTINUOUS CONTROL
|
| 66 |
+
|
| 67 |
+
The DMC15 Benchmark To appropriately compare the performance of different algorithms, we consider a benchmark based on 15 environments from DeepMind Control Suite (Tassa et al., 2018). Our selection of tasks, reported in Table 6, is a set for which discussing sample efficiency is sensible (i.e., neither immediately solvable nor unsolvable by common deep RL algorithms). For ease of comparison, we specialize the benchmark to DMC15-500k, in which $5 \times 1 0 ^ { 5 }$ interactions with the environment are allowed, and DMC15-1M, in which $1 0 ^ { 6 }$ interactions are allowed.
|
| 68 |
+
|
| 69 |
+
Reset Strategy We adapt the approach of Nikishin et al. (2022), and completely reset all the agent parameters every $2 . 5 6 \times \mathrm { \bar { 1 0 } } ^ { 6 }$ of its updates. This lets us avoid individually specifying the moments at which resets should happen for different replay ratios. In terms of environment steps, resets will just occur more often at higher replay ratios. For instance, for replay ratio 128 ( $1 2 8 \mathrm { x }$ higher than what typically used by SAC), a reset occurs once every 20000 steps of interaction with the environment.
|
| 70 |
+
|
| 71 |
+
Results In Figure 2, we compare a version of SR-SAC that uses a replay ratio of 128 to standard deep RL baselines. This also includes the recently proposed REDQ (Chen et al., 2021), which obtained state-of-the-art sample efficiency by using a replay ratio of 20. At any budget of interactions with the environment, SR-SAC compares favorably with REDQ, despite being a simpler algorithm. SR-SAC establishes a new state-of-the-art result for model-free continuous control. Following (Agarwal et al., 2021) we focus on interquartile mean (IQM) performance, defined as the $2 5 \%$ trimmed mean performance over all runs on all considered tasks, and report $9 5 \%$ bootstrap confidence intervals.
|
| 72 |
+
|
| 73 |
+
# 4.2 ATARI 100K
|
| 74 |
+
|
| 75 |
+
Reset Strategy We follow Nikishin et al. (2022) in performing one reset every 40,000 updates; at replay ratio 16, the highest considered, this corresponds to a reset every 2,500 environment steps, or roughly once every three minutes of interaction. However, Nikishin et al. (2022) only reset a subset of the agent’s parameters when training on the ALE, leaving the agent’s convolutional encoder untouched by resets. While this leaves the encoder vulnerable to plasticity loss, fully resetting the encoder is impractical, as Nikishin et al. (2022) observe. As an intermediate solution, we apply soft resets, using a variant of Shrink and Perturb (Ash & Adams, 2020) in which encoder parameters are interpolated between their previous value and a random re-initialized parameter vector on each reset: $\theta ^ { t } = \stackrel { \cdot } { \alpha } \theta ^ { t - 1 } + ( 1 - \alpha ) \phi$ , $\phi \sim$ initializer. This formulation is different from that used by (Ash & Adams, 2020) but allows easy interpolation between completely resetting a layer and leaving it unchanged; we use $\alpha = 0 . 8$ by default. We examine the impact of this decision in Section 5.2.
|
| 76 |
+
|
| 77 |
+
Target Networks By default, SPR does not employ a separate target network, unlike traditional DQNs (Mnih et al., 2015a). However, we find that this leads replay ratio scaling to stop improving performance at relatively low replay ratios, which we hypothesize is due to fundamental variance in optimization limiting the accuracy to which the value function may be estimated. To alleviate it, we directly adopt the target strategy employed by SR-SAC, with an exponential moving average (EMA) target network with coefficient $\tau = 0 . 0 0 5$ , which we find allows beneficial replay ratio scaling out to at least replay ratio 16. Moreover, following (Ghavamzadeh et al., 2011), SR-SPR also uses its target network for action selection. We elaborate on this design decision in Section 5.2.
|
| 78 |
+
|
| 79 |
+
Results Figure 3 shows performance profiles of SR-SPR at various replay ratios, demonstrating that replay ratio scaling consistently improves performance up to at least replay ratio 16. We also compare a version of SR-SPR that uses replay ratio 16 to standard baselines (DrQ, DER, Kostrikov et al., 2022; Van Hasselt et al., 2019) and recent work (IRIS, Micheli et al., 2022) in table 2. SR-SPR establishes a new state-of-the-art for model-free control on Atari 100k, and rivals prior work that has aggressively pretrained on additional data (Liu & Abbeel, 2021; Schwarzer et al., 2021b). We present full results and per-game scores for SR-SPR in table 4, and show training curves in fig. 15. We report IQM performance, as well as plotting a performance profile (Agarwal et al., 2021), which visualizes the full distribution of performance across all runs2 and demonstrates that increasing SR-SPR’s replay ratio comprehensively improves performance.
|
| 80 |
+
|
| 81 |
+

|
| 82 |
+
Figure 3 & Table 2: Performance profiles (left, higher is better) of SR-SPR at various replay ratios, and $9 5 \%$ C.I.s of SR-SPR: 16 and of standard baselines on Atari 100k (right, 20 seeds for SR-SPR and SPR, 5 seeds for IRIS, 100 seeds for all other algorithms as taken from Agarwal et al. (2021))
|
| 83 |
+
|
| 84 |
+

|
| 85 |
+
Figure 4: Scaling behavior of SAC, SR-SAC and its tandem and iterated offline variations in the DMC15 benchmark. Each individual line shows performance at a given number of environment steps, denoted by color, across different numbers of agent updates. Each point in a line is obtained by measuring performance with a different replay ratio for that number of environment steps. Each line is computed over 5 seeds.
|
| 86 |
+
|
| 87 |
+
# 5 ALGORITHM DESIGN IN LIGHT OF REPLAY RATIO SCALING
|
| 88 |
+
|
| 89 |
+
# 5.1 ANALYZING THE IMPORTANCE OF ONLINE INTERACTION
|
| 90 |
+
|
| 91 |
+
When training with high replay ratios and short reset intervals, the training regime an agent is subjected to begins to resemble offline RL; the agent is primarily learning from data collected by policies unrelated to its own, with only a small amount of online data available to correct its policy. Given many classical analyses from offline RL (Levine et al., 2020), it is perhaps surprising that an agent trained in a pseudo-offline setting with no explicit regularization towards conservatism (e.g., Kumar et al., 2020) can learn successfully. What is then the role of the incoming stream of interactions? To gain some understanding, in this section we attack the problem from different angles and study the scaling behavior of variants of SR-SAC. We consider different data collection patterns and how interleaving them with agent optimization changes the training dynamics. The appendix also presents a comparisons with NFQI (Riedmiller, 2005) and with the online use of an offline RL algorithm.
|
| 92 |
+
|
| 93 |
+
# 5.1.1 ITERATED OFFLINE SETTING
|
| 94 |
+
|
| 95 |
+
Changing the replay ratio in a deep RL algorithm can be seen as a specific way of increasing the proportion of offline training an agent is subject to. Specifically, the agent’s parameters are updated a number of times exactly equal to the replay ratio before a new sample is collected. This implies a uniform distribution of the number of offline updates across time steps. Is this an important variable for determining the replay ratio scaling behavior of an algorithm?
|
| 96 |
+
|
| 97 |
+
To answer this question, we resort to what we call iterated offline RL (Matsushima et al., 2021; Riedmiller et al., 2021), which alternates between purely offline updates and data collection. In this setting, a certain value of replay ratio is not distributed uniformly during the course of the interactions with the environment. Instead, the agent is not updated during data collection, and an amount of updates equal to the one that would be due in that data collection time frame in virtue of the replay ratio is applied completely offline, right after each reset.
|
| 98 |
+
|
| 99 |
+
As visible in Figure 4, the iterated offline paradigm has a different replay ratio scaling behavior. Applying a very large number of updates with a fixed dataset, with an algorithm such as SAC, incurs serious risk of generating a degenerate policy, not able to outperform the previous one. As exemplified in Figure 6, in the absence of any mechanism for stopping this natural degeneration to happen, this circle is broken only when enough data is collected. Collecting enough data in this sense is possible for easy tasks such as hopper-stand and walker-run, with a cost in sample efficiency, or impossible on hard tasks such as humanoid-stand and quadruped-walk. This is unfortunate: the iterated offline RL paradigm can be quite useful in practical settings, in which the agent is allowed to only collected batches of data without any update (perhaps for safety reasons); however, current backbone algorithms (such as SAC) are not currently compatible with such a setting, that thus leads to favorable replay scaling only when closer to the online setting. This explains the sudden increase in the curve of Figure 4, when the number of agent updates, and consequently the reset frequency, becomes large enough. An interesting question, left for future work, is whether this behavior could change if combined with conservative algorithms created for the offline RL setting.
|
| 100 |
+
|
| 101 |
+

|
| 102 |
+
Figure 6: Examples of behaviors of SR-SAC and its tandem and iterated offline variations on four environments from DMC15. (5 runs, $\pm$ std).
|
| 103 |
+
|
| 104 |
+
# 5.1.2 TANDEM SETTING
|
| 105 |
+
|
| 106 |
+
With high replay ratios, an agent’s training begins to resemble offline RL: although the agent still has the possibility to interact with the environment, it is very infrequent relative to the amount of training. Thus, an agent after a reset has a small stream of interactions collected by the agent itself, while the vast majority of its data was collected by potentially unrelated agents. How important, then, is this small stream of online interaction? To answer this question, we leverage the tandem setting, as presented in Ostrovski et al. (2021). Two copies of the same agent, identical apart from the initialization, are created. With the same algorithm (SR-SAC in this case), they are trained on the replay buffer collected by the active agent. The passive agent thus never directly interacts with environment, and cannot collect data to correct its own misconceptions about the environment.
|
| 107 |
+
|
| 108 |
+
As shown in Figure 4, the behavior of Tandem SR-SAC offers an alternative perspective on the importance of online interactions: despite the performance of the algorithm being hurt, the overall replay ratio scaling capabilities remain similar. We can look at the performance of the passive agent to understand what the exact effect of online interactions is on training. As evident in the environments from Figure 6, especially in hopper-stand and quadruped-walk, there is a qualitative difference between the behavior of an active agent (blue curve) and a passive agent (green curve): right after a reset, with the initial high replay ratio training, the performance of both agents is greatly improved; after a few thousands steps, training remains stable for the active agent but causes performance collapse in the passive agent. This experiment thus demonstrates the power of having online interactions as an implicit regularization mechanism.
|
| 109 |
+
|
| 110 |
+
For the design of future replay ratio-scalable algorithms, one should keep in mind that it is indeed possible to scale an algorithm potentially affected by extreme off-policyness; however, online data collection slows down performance collapse when training aggressively, as shown in both the iterated offline and the tandem experiments.
|
| 111 |
+
|
| 112 |
+

|
| 113 |
+
Figure 5: Learning curves (top) and evaluation performance (bottom) at replay ratio 16 for SPR and SR-SPR with and without offline updates after each reset.
|
| 114 |
+
|
| 115 |
+
# 5.1.3 ALTERNATIVE COMBINATIONS OF OFFLINE AND ONLINE UPDATES
|
| 116 |
+
|
| 117 |
+
The iterated offline setting can be seen as the extreme in which all of the updates are done offline, compared to the even distribution used in the online setting. What if we use an intermediate strategy?
|
| 118 |
+
|
| 119 |
+
For SR-SPR, we find that directly mixing offline and online RL by performing half the updates allotted to each interval immediately after each reset can actually improve performance by some metrics, such as training return (see Figure 5 upper), by mitigating the performance drop otherwise experienced after each reset. Although we find that this has essentially no impact on final evaluation performance (Figure 5 lower), it may allow SR-SPR to be used when cumulative regret is important.
|
| 120 |
+
|
| 121 |
+
5.2 WHAT IS REQUIRED FOR REPLAY RATIO SCALING IN DISCRETE CONTROL?
|
| 122 |
+
|
| 123 |
+
Although replay ratio scaling is relatively straightforward for SR-SAC, achieving robust replay ratio scaling for SR-SPR requires more complex design decisions due to its shorter training period and more complex function approximation. As a result, unlike SR-SAC, SR-SPR contains additional modifications from the variant of SPR used by Nikishin et al. (2022). We study the impact of these design decisions on scaling behavior and report results in Figure 7.
|
| 124 |
+
|
| 125 |
+
Inspired by the findings of Berariu et al. (2021) that plasticity loss is concentrated in the final layers of the network but affects all layers, we apply Shrink and Perturb (SP) to the encoder; this is responsible for roughly a constant increase of $\mathrm { I Q M 0 . 0 4 }$ past replay ratio 4. We note however that applying Shrink and Perturb alone to all the parameters of the network is not sufficient to enable beneficial scaling; it is important that at least the network’s final layers be completely reset. We explain this using the observations from (Berariu et al., 2021) that the last layers are more responsible for the loss of plasticity.
|
| 126 |
+
|
| 127 |
+
That said, the most important factor in allowing SR-SPR to continue scaling well is its use of a target network. This effect is primarily due to better action selection through the target net
|
| 128 |
+
|
| 129 |
+

|
| 130 |
+
Figure 7: The replay ratio scaling behavior of SRSPR with various components ablated.
|
| 131 |
+
|
| 132 |
+
work; we found that the stabilizing effect on optimization was a less important factor. This is reminiscent of speedy Q-learning (Ghavamzadeh et al., 2011), where the use of an exponential moving average policy was shown to improve convergence speed, and can also be understood in relationship to the policy churn phenomenon (Schaul et al., 2022) (see Figure 10 in the appendix).
|
| 133 |
+
|
| 134 |
+
Meanwhile, removing both Shrink and Perturb and the target network is roughly equivalent to taking the method of Nikishin et al. (2022) but setting reset intervals as in SR-SPR. As Figure 7 suggests, this alone suffices to yield some replay ratio scaling but not as efficient compared to SR-SPR. However, maintaining a fixed reset interval (in terms of environment steps) when varying replay ratio, as done by Nikishin et al. (2022), leads to poor performance at replay ratios above 4.
|
| 135 |
+
|
| 136 |
+
Intriguingly, we note that these modifications are beneficial specifically for replay ratio scaling; at replay ratios 1 or 2 they do not improve performance (although for the most part they do not significantly harm performance either). We thus hypothesize that there may be other modifications to complex algorithms such as SPR that could be made to further improve replay ratio scaling properties, but that are today not in widespread use because they do not improve performance in standard low replay ratio settings.
|
| 137 |
+
|
| 138 |
+
# 5.3 VISUALIZING THE DATA/COMPUTE TRADEOFF
|
| 139 |
+
|
| 140 |
+
If an order of magnitude more of updates can be used for improving the performance of an algorithm, additional tradeoffs start to emerge. The type of computations that replay ratio scaling implies are fundamentally different than other concepts of scaling, (e.g., about larger models): scaling here is inherently sequential. Thus, obtaining more hardware does not help faster execution of the algorithm.
|
| 141 |
+
|
| 142 |
+
When collecting new transitions is not very expensive, the choice between collecting new samples in the environment and spending more time updating an agent could become nontrivial.
|
| 143 |
+
|
| 144 |
+
We visualize this tradeoff in Figure 8. The plot is obtained by combining runs of SR-SAC with doubling replay ratio from 0.25 to 128, and considering, for a fixed data budget (in terms of environment steps), the total computational budget (in terms of total number of agent updates at that point), as well as the achieved performance. There exists multiple ways to achieve the same level of performance, as denoted by the color. This plot shows that resets provide a knob on replay ratio scaling and allows to tradeoff data for computation. If, for a given problem, sample efficiency is more important than computational considerations, one can spend about two orders of magnitude of additional agent updates to obtain the same performance that can be obtained by waiting for 800000 additional samples to be collected from the environment. The peculiar feature of the approach we advocate for in this paper is that it allows to act on this tradeoff with an algorithm basically as simple as the employed backbone.
|
| 145 |
+
|
| 146 |
+

|
| 147 |
+
Figure 8: Performance of SR-SAC in DMC15 as a function of the number of interactions and of the number of agent updates, determined by the replay ratio.
|
| 148 |
+
|
| 149 |
+
# 6 THE LIMITS OF REPLAY RATIO SCALING
|
| 150 |
+
|
| 151 |
+
We have seen what becomes possible when higher level of replay ratio scaling are unlocked by resets. What are the limits of this paradigm? First of all, replay ratio scaling is always possible up to a finite value, at which there is simply not enough information left to be extracted from the existing dataset of experience. Current methods, including the one proposed in this paper, are not able to automatically identify when this limit is reached, and they are therefore still subject to performance collapse when increasing the replay ratio too much. Second, replay ratio scaling cannot go beyond the intrinsic limitations of the given deep RL algorithm: for example, if the task is simply impossible to solve because of hard credit assignment or exploration, then replay ratio scaling is only of limited help. Third, the strategy we proposed for replay ratio scaling is based on keeping the entire history of interactions with the environment in the replay buffer. While this is feasible for the kind of sampleefficiency benchmarks that we have used in this paper, it might also require special consideration to be applied to larger problems; for instance, it is possible to keep a large replay buffer on permanent storage, albeit at the cost of slower batch retrieval. Lastly, replay ratio scaling can inherently become time-consuming for a training agent, which can limit the applicability of methodologies like ours to settings requiring high-frequency interactions with an environment.
|
| 152 |
+
|
| 153 |
+
# 7 CONCLUSIONS
|
| 154 |
+
|
| 155 |
+
In this paper, we have shown that, by leveraging partial or full resets of an agent’s parameters, it is possible to unlock new levels of favorable replay ratio scaling and, consequently, of sampleefficiency for model-free deep RL algorithms. We demonstrated this by a careful evaluation on the DeepMind Control Suite and Atari 100k benchmarks, where our approach (SR-SAC and SRSPR) demonstrated far superior performance compared to strong baselines, with minimal amounts of additional algorithmic complexity. Then, we discussed which algorithmic design choices are important for achieving such levels of replay ratio scaling with a deep RL algorithm, as well as the tradeoffs implied by this paradigm. Through our empirical analysis, we showed the value of online data collection, offering a perspective on its relationship with offline RL (Levine et al., 2020).
|
| 156 |
+
|
| 157 |
+
More generally, this paper is about how to leverage a discovery for the design of future deep RL algorithms. We believe this work to be an example of how the development of effective deep RL methods should be achieved not only through extending existing algorithms or creating new ones, but also through the discovery of new phenomena related to deep RL systems, and of techniques for exploiting them to increase performance. It is natural to wonder whether deeper understanding or exploitation of surprising empirical properties (Ostrovski et al., 2021; Schaul et al., 2022) beyond the one behind this work could lead to the emergence of new capabilities in deep RL algorithms.
|
| 158 |
+
|
| 159 |
+
# ACKNOWLEDGMENTS
|
| 160 |
+
|
| 161 |
+
The authors thank Zhixuan Lin for adapting the REDQ baseline, Nathan U. Rahn, Rishabh Agarwal, David Yu-Tung Hui, Jesse Farebrother for insightful discussions and useful suggestions on the early draft, the Mila community for creating a stimulating research environment, Digital Research Alliance of Canada and Nvidia for computational resources. This work was partially supported by CIFAR, Samsung, Hitachi, Facebook AI Chair, Borealis, IVADO, and Gruppo Ermenegildo Zegna.
|
| 162 |
+
|
| 163 |
+
We acknowledge the Python community (Van Rossum & Drake Jr, 1995; Oliphant, 2007) for developing the core set of tools that enabled this work, including JAX (Bradbury et al., 2018; Babuschkin et al., 2020), Jupyter (Kluyver et al., 2016), Matplotlib (Hunter, 2007), numpy (Oliphant, 2006; Van Der Walt et al., 2011), pandas (McKinney, 2012), and SciPy (Jones et al., 2014).
|
| 164 |
+
|
| 165 |
+
# REFERENCES
|
| 166 |
+
|
| 167 |
+
Rishabh Agarwal, Max Schwarzer, Pablo Samuel Castro, Aaron Courville, and Marc G Bellemare. Deep reinforcement learning at the edge of the statistical precipice. In Thirty-Fifth Conference on Neural Information Processing Systems, 2021.
|
| 168 |
+
|
| 169 |
+
Jordan Ash and Ryan P Adams. On warm-starting neural network training. Advances in Neural Information Processing Systems, 33:3884–3894, 2020.
|
| 170 |
+
|
| 171 |
+
Igor Babuschkin, Kate Baumli, Alison Bell, Surya Bhupatiraju, Jake Bruce, Peter Buchlovsky, David Budden, Trevor Cai, Aidan Clark, Ivo Danihelka, Claudio Fantacci, Jonathan Godwin, Chris Jones, Tom Hennigan, Matteo Hessel, Steven Kapturowski, Thomas Keck, Iurii Kemaev, Michael King, Lena Martens, Vladimir Mikulik, Tamara Norman, John Quan, George Papamakarios, Roman Ring, Francisco Ruiz, Alvaro Sanchez, Rosalia Schneider, Eren Sezener, Stephen Spencer, Srivatsan Srinivasan, Wojciech Stokowiec, and Fabio Viola. The DeepMind JAX Ecosystem, 2020. URL http://github.com/deepmind.
|
| 172 |
+
|
| 173 |
+
Yasaman Bahri, Ethan Dyer, Jared Kaplan, Jaehoon Lee, and Utkarsh Sharma. Explaining neural scaling laws. arXiv preprint arXiv:2102.06701, 2021.
|
| 174 |
+
|
| 175 |
+
Tudor Berariu, Wojciech Czarnecki, Soham De, Jorg Bornschein, Samuel Smith, Razvan Pascanu, and Claudia Clopath. A study on the plasticity of neural networks. arXiv preprint arXiv:2106.00042, 2021.
|
| 176 |
+
|
| 177 |
+
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.
|
| 178 |
+
|
| 179 |
+
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.
|
| 180 |
+
|
| 181 |
+
Pablo Samuel Castro, Subhodeep Moitra, Carles Gelada, Saurabh Kumar, and Marc G. Bellemare. Dopamine: A research framework for deep reinforcement learning. CoRR, abs/1812.06110, 2018. URL http://arxiv.org/abs/1812.06110.
|
| 182 |
+
|
| 183 |
+
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, 2018.
|
| 184 |
+
|
| 185 |
+
Xinyue Chen, Che Wang, Zijian Zhou, and Keith Ross. Randomized ensembled double q-learning: Learning fast without a model. arXiv preprint arXiv:2101.05982, 2021.
|
| 186 |
+
|
| 187 |
+
Will Dabney, Andre Barreto, Mark Rowland, Robert Dadashi, John Quan, Marc G Bellemare, and ´ David Silver. The value-improvement path: Towards better representations for reinforcement learning. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pp. 7160– 7168, 2021.
|
| 188 |
+
|
| 189 |
+
Josip Djolonga, Jessica Yung, Michael Tschannen, Rob Romijnders, Lucas Beyer, Alexander Kolesnikov, Joan Puigcerver, Matthias Minderer, Alexander D’Amour, Dan Moldovan, et al. On robustness and transferability of convolutional neural networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 16458–16468, 2021.
|
| 190 |
+
|
| 191 |
+
Shibhansh Dohare, Richard S. Sutton, and A. Rupam Mahmood. Continual backprop: Stochastic gradient descent with persistent randomness, 2022. URL https://openreview.net/forum? id $= 8$ 6sEVRfeGYS.
|
| 192 |
+
|
| 193 |
+
Pierluca D’Oro and Wojciech Jaskowski. How to learn a useful critic? model-based action-gradient- ´ estimator policy optimization. Advances in Neural Information Processing Systems, 33:313–324, 2020.
|
| 194 |
+
|
| 195 |
+
William Fedus, Prajit Ramachandran, Rishabh Agarwal, Yoshua Bengio, Hugo Larochelle, Mark Rowland, and Will Dabney. Revisiting fundamentals of experience replay. In International Conference on Machine Learning, pp. 3061–3071. PMLR, 2020.
|
| 196 |
+
|
| 197 |
+
Vincent Franc¸ois-Lavet, Peter Henderson, Riashat Islam, Marc G Bellemare, Joelle Pineau, et al. An introduction to deep reinforcement learning. Foundations and Trends® in Machine Learning, 11 (3-4):219–354, 2018.
|
| 198 |
+
|
| 199 |
+
Justin Fu, Aviral Kumar, Ofir Nachum, George Tucker, and Sergey Levine. D4rl: Datasets for deep data-driven reinforcement learning. arXiv preprint arXiv:2004.07219, 2020.
|
| 200 |
+
|
| 201 |
+
Mohammad Ghavamzadeh, Hilbert Kappen, Mohammad Azar, and Remi Munos. Speedy ´ q-learning. 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/ ab1a4d0dd4d48a2ba1077c4494791306-Paper.pdf.
|
| 202 |
+
|
| 203 |
+
Tuomas Haarnoja, Aurick Zhou, P. Abbeel, and Sergey Levine. Soft actor-critic: Off-policy maximum entropy deep reinforcement learning with a stochastic actor. In ICML, 2018.
|
| 204 |
+
|
| 205 |
+
Jessica B Hamrick, Abram L. Friesen, Feryal Behbahani, Arthur Guez, Fabio Viola, Sims Witherspoon, Thomas Anthony, Lars Holger Buesing, Petar Velickovi ˇ c, and Theophane Weber. On the role ´ of planning in model-based deep reinforcement learning. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } = \dot { \mathbf { \Psi } }$ IrM64DGB21.
|
| 206 |
+
|
| 207 |
+
Joel Hestness, Sharan Narang, Newsha Ardalani, Gregory Diamos, Heewoo Jun, Hassan Kianinejad, Md Patwary, Mostofa Ali, Yang Yang, and Yanqi Zhou. Deep learning scaling is predictable, empirically. arXiv preprint arXiv:1712.00409, 2017.
|
| 208 |
+
|
| 209 |
+
Takuya Hiraoka, Takahisa Imagawa, Taisei Hashimoto, Takashi Onishi, and Yoshimasa Tsuruoka. Dropout q-functions for doubly efficient reinforcement learning. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ xCVJMsPv3RT.
|
| 210 |
+
|
| 211 |
+
Jordan Hoffmann, Sebastian Borgeaud, Arthur Mensch, Elena Buchatskaya, Trevor Cai, Eliza Rutherford, Diego de Las Casas, Lisa Anne Hendricks, Johannes Welbl, Aidan Clark, Tom Hennigan, Eric Noland, Katie Millican, George van den Driessche, Bogdan Damoc, Aurelia Guy, Simon Osindero, Karen Simonyan, Erich Elsen, Jack W. Rae, Oriol Vinyals, and L. Sifre. Training compute-optimal large language models. ArXiv, abs/2203.15556, 2022.
|
| 212 |
+
|
| 213 |
+
G Zacharias Holland, Erin J Talvitie, and Michael Bowling. The effect of planning shape on dyna-style planning in high-dimensional state spaces. arXiv preprint arXiv:1806.01825, 2018.
|
| 214 |
+
|
| 215 |
+
John D Hunter. Matplotlib: A 2d graphics environment. IEEE Annals of the History of Computing, 9 (03):90–95, 2007.
|
| 216 |
+
|
| 217 |
+
Maximilian Igl, Gregory Farquhar, Jelena Luketina, Wendelin Boehmer, and Shimon Whiteson. Transient non-stationarity and generalisation in deep reinforcement learning. In ICLR, 2021.
|
| 218 |
+
|
| 219 |
+
Eric Jones, Travis Oliphant, and Pearu Peterson. SciPy: Open source scientific tools for Python. 2014.
|
| 220 |
+
|
| 221 |
+
Lukasz Kaiser, Mohammad Babaeizadeh, Piotr Milos, Blazej Osinski, Roy H. Campbell, K. Czechowski, D. Erhan, Chelsea Finn, Piotr Kozakowski, Sergey Levine, Ryan Sepassi, G. Tucker, and Henryk Michalewski. Model-based reinforcement learning for atari. $A r X i \nu$ , abs/1903.00374, 2020.
|
| 222 |
+
|
| 223 |
+
Jared Kaplan, Sam McCandlish, T. J. Henighan, Tom B. Brown, Benjamin Chess, Rewon Child, Scott Gray, Alec Radford, Jeff Wu, and Dario Amodei. Scaling laws for neural language models. ArXiv, abs/2001.08361, 2020.
|
| 224 |
+
|
| 225 |
+
Kacper Piotr Kielak. Do recent advancements in model-based deep reinforcement learning really improve data efficiency? 2019.
|
| 226 |
+
|
| 227 |
+
Thomas Kluyver, Benjamin Ragan-Kelley, Fernando Perez, Brian E Granger, Matthias Bussonnier, ´ Jonathan Frederic, Kyle Kelley, Jessica B Hamrick, Jason Grout, Sylvain Corlay, et al. Jupyter Notebooks-a publishing format for reproducible computational workflows., volume 2016. 2016.
|
| 228 |
+
|
| 229 |
+
Ilya Kostrikov. JAXRL: Implementations of Reinforcement Learning algorithms in JAX, 10 2021. URL https://github.com/ikostrikov/jaxrl.
|
| 230 |
+
|
| 231 |
+
Ilya Kostrikov, Ashvin Nair, and Sergey Levine. Offline reinforcement learning with implicit q-learning. ArXiv, abs/2110.06169, 2022.
|
| 232 |
+
|
| 233 |
+
Aviral Kumar, Aurick Zhou, George Tucker, and Sergey Levine. Conservative q-learning for offline reinforcement learning. Advances in Neural Information Processing Systems, 33:1179–1191, 2020.
|
| 234 |
+
|
| 235 |
+
Aviral Kumar, Rishabh Agarwal, Dibya Ghosh, and Sergey Levine. Implicit under-parameterization inhibits data-efficient deep reinforcement learning. ArXiv, abs/2010.14498, 2021.
|
| 236 |
+
|
| 237 |
+
Kuang-Huei Lee, Ofir Nachum, Mengjiao Yang, L. Y. Lee, Daniel Freeman, Winnie Xu, Sergio Guadarrama, Ian S. Fischer, Eric Jang, Henryk Michalewski, and Igor Mordatch. Multi-game decision transformers. ArXiv, abs/2205.15241, 2022.
|
| 238 |
+
|
| 239 |
+
Sergey Levine, Aviral Kumar, George Tucker, and Justin Fu. Offline reinforcement learning: Tutorial, review, and perspectives on open problems, 2020. URL https://arxiv.org/abs/2005. 01643.
|
| 240 |
+
|
| 241 |
+
Long-Ji Lin. Reinforcement learning for robots using neural networks. Carnegie Mellon University, 1992.
|
| 242 |
+
|
| 243 |
+
Hao Liu and Pieter Abbeel. Aps: Active pretraining with successor features. In International Conference on Machine Learning, pp. 6736–6747. PMLR, 2021.
|
| 244 |
+
|
| 245 |
+
Clare Lyle, Mark Rowland, and Will Dabney. Understanding and preventing capacity loss in reinforcement learning. ArXiv, abs/2204.09560, 2022a.
|
| 246 |
+
|
| 247 |
+
Clare Lyle, Mark Rowland, Will Dabney, Marta Z. Kwiatkowska, and Yarin Gal. Learning dynamics and generalization in reinforcement learning. ArXiv, abs/2206.02126, 2022b.
|
| 248 |
+
|
| 249 |
+
Tatsuya Matsushima, Hiroki Furuta, Yutaka Matsuo, Ofir Nachum, and Shixiang Gu. Deploymentefficient reinforcement learning via model-based offline optimization. In International Conference on Learning Representations, 2021.
|
| 250 |
+
|
| 251 |
+
Wes McKinney. Python for data analysis: Data wrangling with Pandas, NumPy, and IPython. ” O’Reilly Media, Inc.”, 2012.
|
| 252 |
+
|
| 253 |
+
Vincent Micheli, Eloi Alonso, and Franc¸ois Fleuret. Transformers are sample efficient world models, 2022. URL https://arxiv.org/abs/2209.00588.
|
| 254 |
+
|
| 255 |
+
Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Andrei A Rusu, Joel Veness, Marc G Bellemare, Alex Graves, Martin Riedmiller, Andreas K Fidjeland, Georg Ostrovski, et al. Human-level control through deep reinforcement learning. nature, 518(7540):529–533, 2015a.
|
| 256 |
+
|
| 257 |
+
Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Andrei A. Rusu, Joel Veness, Marc G. Bellemare, Alex Graves, Martin A. Riedmiller, Andreas Fidjeland, Georg Ostrovski, Stig Petersen, Charlie Beattie, Amir Sadik, Ioannis Antonoglou, Helen King, Dharshan Kumaran, Daan Wierstra, Shane Legg, and Demis Hassabis. Human-level control through deep reinforcement learning. Nature, 518:529–533, 2015b.
|
| 258 |
+
|
| 259 |
+
Evgenii Nikishin, Max Schwarzer, Pierluca D’Oro, Pierre-Luc Bacon, and Aaron C. Courville. The primacy bias in deep reinforcement learning. In ICML, 2022.
|
| 260 |
+
|
| 261 |
+
Travis E Oliphant. A guide to NumPy, volume 1. Trelgol Publishing USA, 2006.
|
| 262 |
+
|
| 263 |
+
Travis E Oliphant. Python for scientific computing. Computing in Science & Engineering, 9(3): 10–20, 2007.
|
| 264 |
+
|
| 265 |
+
Georg Ostrovski, Pablo Samuel Castro, and Will Dabney. The difficulty of passive learning in deep reinforcement learning. Advances in Neural Information Processing Systems, 2021.
|
| 266 |
+
|
| 267 |
+
Martin Riedmiller. Neural fitted q iteration–first experiences with a data efficient neural reinforcement learning method. In European conference on machine learning, pp. 317–328. Springer, 2005.
|
| 268 |
+
|
| 269 |
+
Martin A. Riedmiller, Jost Tobias Springenberg, Roland Hafner, and Nicolas Manfred Otto Heess. Collect & infer - a fresh look at data-efficient reinforcement learning. In CoRL, 2021.
|
| 270 |
+
|
| 271 |
+
Tom Schaul, Andre Barreto, John Quan, and Georg Ostrovski. The phenomenon of policy churn. ´ arXiv preprint arXiv:2206.00730, 2022.
|
| 272 |
+
|
| 273 |
+
Max Schwarzer, Ankesh Anand, Rishab Goel, R. Devon Hjelm, Aaron C. Courville, and Philip Bachman. Data-efficient reinforcement learning with self-predictive representations. In ICLR, 2021a.
|
| 274 |
+
|
| 275 |
+
Max Schwarzer, Nitarshan Rajkumar, Michael Noukhovitch, Ankesh Anand, Laurent Charlin, R Devon Hjelm, Philip Bachman, and Aaron C Courville. Pretraining representations for data-efficient reinforcement learning. Advances in Neural Information Processing Systems, 34:12686–12699, 2021b.
|
| 276 |
+
|
| 277 |
+
Laura Smith, Ilya Kostrikov, and Sergey Levine. A walk in the park: Learning to walk in 20 minutes with model-free reinforcement learning. ArXiv, abs/2208.07860, 2022.
|
| 278 |
+
|
| 279 |
+
Yuval Tassa, Yotam Doron, Alistair Muldal, Tom Erez, Yazhe Li, Diego de Las Casas, David Budden, Abbas Abdolmaleki, Josh Merel, Andrew Lefrancq, Timothy P. Lillicrap, and Martin A. Riedmiller. Deepmind control suite. ArXiv, abs/1801.00690, 2018.
|
| 280 |
+
|
| 281 |
+
Stefan Van Der Walt, S Chris Colbert, and Gael Varoquaux. The numpy array: a structure for efficient numerical computation. Computing in science & engineering, 13(2):22–30, 2011.
|
| 282 |
+
|
| 283 |
+
Hado P Van Hasselt, Matteo Hessel, and John Aslanides. When to use parametric models in reinforcement learning? Advances in Neural Information Processing Systems, 32, 2019.
|
| 284 |
+
|
| 285 |
+
Guido Van Rossum and Fred L Drake Jr. Python tutorial, volume 620. Centrum voor Wiskunde en Informatica Amsterdam, 1995.
|
| 286 |
+
|
| 287 |
+
Ziyu Wang, Victor Bapst, Nicolas Heess, Volodymyr Mnih, Remi Munos, Koray Kavukcuoglu, and Nando de Freitas. Sample efficient actor-critic with experience replay. arXiv preprint arXiv:1611.01224, 2016.
|
| 288 |
+
|
| 289 |
+
Yanqiu Wu, Xinyue Chen, Che Wang, Yiming Zhang, Zijian Zhou, and Keith W. Ross. Aggressive qlearning with ensembles: Achieving both high sample efficiency and high asymptotic performance, 2022. URL https://openreview.net/forum?id $=$ NOApNZTiTNU.
|
| 290 |
+
|
| 291 |
+
Hattie Zhou, Ankit Vani, Hugo Larochelle, and Aaron Courville. Fortuitous forgetting in connectionist networks. In International Conference on Learning Representations, 2022. URL https:// openreview.net/forum?id=ei3SY1_zYsE.
|
| 292 |
+
|
| 293 |
+
<table><tr><td>Expression</td><td>Definition</td><td>Used In</td></tr><tr><td>Damage from Warm-Starting</td><td>[Phenomenon for which]“a warm-started network performs worse on test samples than a network trained on the same data but witha new random initialization”</td><td>Ash & Adams (2020)</td></tr><tr><td>Damage from Non-Stationarity</td><td>“A memory effect where these transient non-stationarities can permanently impact the latent representation and adversely affect generalisation performance"</td><td>Igl et al. (2021)</td></tr><tr><td>Capacity Loss</td><td>“Reduced ability to fit new targets in deep neural networks”</td><td>Lyle et al. (2022b), Lyle et al. (2022a) Berariuetal.</td></tr><tr><td></td><td>Loss of Plasticity“Loss of the ability of the model to keep learning"</td><td>(2021),Dohare et al. (2022)</td></tr><tr><td>Primacy Bias</td><td>“A tendency to overfit initial experiences that damages the rest of the learning process"</td><td>Nikishinetal. (2022)</td></tr></table>
|
| 294 |
+
|
| 295 |
+

|
| 296 |
+
Table 3: Definitions of coinciding and related phenomena from previous work justifying the effectiveness of our strategy for replay ratio scaling.
|
| 297 |
+
Figure 9: Sensitivity of the IQM to varying reset intervals (in terms of gradient updates) of SR-SAC on the DeepMind Control Suite (DMC15-500k) benchmark, and of SR-SPR on the Atari $1 0 0 \mathrm { k }$ benchmark. (10 seeds, $9 5 \%$ bootstrapped C.I.).
|
| 298 |
+
|
| 299 |
+
# A DEFINITIONS FROM RELATED WORKS
|
| 300 |
+
|
| 301 |
+
To further clarify our description of previous work from the related work section, we report in Table 3 definitions of the different terms used to refer to the loss of the ability to learn and generalize in neural networks. Each definition is directly taken from one of the papers corresponding to it. Note that, despite their overlap, they reflect slightly different perspectives on the nature of this phenomenon, and it can be worth for future investigations to pin down which one of these is more relevant for replay ratio scaling or reinforcement learning as a whole.
|
| 302 |
+
|
| 303 |
+
# B ADDITIONAL EXPERIMENTAL RESULTS
|
| 304 |
+
|
| 305 |
+
# B.1 ADDITIONAL STUDIES
|
| 306 |
+
|
| 307 |
+
Reset Interval An important hyperparameter for both SR-SAC and SR-SPR is the interval at which resets are performed, as denominated in terms of number of agent updates. In Figure 9, we study how performance is impacted by this choice, at different replay ratios. Overall, both SR-SAC and SR-SPR perform well for a vast range of reset intervals, with favorable replay ratio scaling and generally smooth performance degradation. Note that, for large intervals (e.g., the last point on the right for SR-SAC with $R R = 1 6$ , and last two points in the bottom right for SR-SPR), this is equivalent to actually performing no resets, just running the unmodified baseline algorithms. Thus, performance experiences non-smooth drops only in these easily avoidable cases.
|
| 308 |
+
|
| 309 |
+

|
| 310 |
+
Figure 10: Churn-related diagnostics (based on the policy churn definition from Schaul et al. (2022)) for the online and target networks. Different colors and RR denote different values of replay ratio.
|
| 311 |
+
|
| 312 |
+
Counteracting Policy Churn by Acting with the Target Network Schaul et al. (2022) defined the policy churn as the change in the agent’s policy due to optimization. It was shown that a certain amount of policy churn can be beneficial for exploration in the absence of external noise (e.g., coming from $\epsilon$ -greedy exploration); however, it is intuitive that excessive churn can actually hurt performance, for instance by breaking the the consistency of trajectories. We hypothesize that mitigating excessive policy churn is a major reason why SR-SPR performs better when actions are selected with the target network rather than the online network. Figure 10 shows that, if we measure churn before each interaction with the environment, increasing the replay ratio will naturally increase it, while acting with the target network will decrease it. When the replay ratio is too high, it is likely that the benefits coming from additional offline computations might be nullified by the inconsistency in the exploration data; acting with the target network reduces these inconsistencies without giving up on the more efficient optimization, at the cost of introducing minimal delays in the improvement of the data-collecting policy.
|
| 313 |
+
|
| 314 |
+
Using an offline RL algorithm online In Section 5.1, we conducted a set of experiments with the goal of highlighting the importance of online interactions, concluding that a consistent stream of online interaction data and neural networks able to learn and generalize from a dataset of experiences are key factors behind effective replay ratio scaling. Online RL algorithms such as SAC are naturally reliant on the online stream of interactions; but it is natural to ask whether algorithms created for offline RL setting, where no interaction with the environment is assumed to be possible during training, can make the most out of the computational budget granted through high replay ratios in the online setting. To test this hypothesis, we run the Implicit Q-learning (IQL) (Kostrikov et al., 2022) algorithm as an online RL algorithm on DMC15-500k with a replay ratio of 32. Results in Figure 11 show that, despite being by design more robust to more aggressive training, the conservative nature of offline RL algorithms makes them not amenable to effective online learning, regardless of the presence of resets. This shows the effectiveness of online interactions as a strong supervision mechanism, able, when supported by resets, to make online RL algorithms robust to high replay ratios without the need of overly conservative behaviors.
|
| 315 |
+
|
| 316 |
+

|
| 317 |
+
Figure 11: Performance on DMC15-500k of running IQL $\mathrm { R R } { = } 3 2$ ) online, with and without resets.
|
| 318 |
+
|
| 319 |
+

|
| 320 |
+
Figure 12: The performance of SR-SPR and SPR from scratch and when fine-tuning a pre-trained encoder on Atari $1 0 0 \mathrm { k }$ (10 seeds. $9 5 \%$ bootstrapped C.I.
|
| 321 |
+
|
| 322 |
+
# B.2 FINETUNING PRETRAINED REPRESENTATIONS
|
| 323 |
+
|
| 324 |
+
Finetuning pretrained representations has become increasing common in reinforcement learning and elsewhere (Schwarzer et al., 2021b; Liu & Abbeel, 2021; Bommasani et al., 2021). One obvious question to ask is whether or not replay scaling as demonstrated in the tabula rasa setting here can also be used to make this finetuning more sample efficient. In Figure 12 we answer this question in the affirmative. We initialize SPR and SR-SPR with pretrained encoders (taken for experimental convenience from SPR agents trained at replay ratio 1 for one million steps), and initialize all other parameters randomly. We then train at a range of replay ratios for $1 0 0 \mathrm { k }$ steps. For SR-SPR, we apply shrink and perturb towards the pretrained encoder weights rather than random parameters, but otherwise train as normal.
|
| 325 |
+
|
| 326 |
+
We find that while both SPR and SR-SPR benefit from the pretrained representations at low replay ratios, only SR-SPR is able to improve fine-tuning performance by replay scaling. Standard SPR with pretrained representations rapidly degrades in performance as the replay ratio is increased, while the performance of SR-SPR steadily increases at higher replay ratios. Although the gap between SR-SPR with and without pretraining closes somewhat at higher replay ratios, this is to be expected, as higher replay-ratio agents have more opportunities to improve their own representations even without pretraining.
|
| 327 |
+
|
| 328 |
+
# B.3 FINETUNING AFTER OFFLINE TRAINING
|
| 329 |
+
|
| 330 |
+
The efficiency of SR-SAC and SR-SPR makes the general approach behind their design potentially appealing for the setting of offline RL with an additional fine tuning phase. In Figure 13, we provide preliminary evidence that the paradigm we advocated for in this paper may indeed be particularly beneficial in this setting. We test IQL with the same pretraining scheme presented in Kostrikov et al. (2022), consisting in a million offline training steps followed by a million interactions with the environment for fine tuning. We implement SR-IQL by using a replay ratio of 10 and resetting, every two million updates, all of the parameters of its neural networks during the fine tuning phase. We compare SR-IQL to IQL on two tasks from the D4RL benchmark (Fu et al., 2020). As shown in Figure 13, SR-IQL is roughly on par with IQL in the antmaze-umaze-v0 task, but reaches superior performance during fine tuning in antmaze-umaze-diverse-v0. We believe this sets the stage to experimenting with our replay ratio scaling paradigm in this setting as a promising research direction for future work.
|
| 331 |
+
|
| 332 |
+

|
| 333 |
+
Figure 13: Performance of SR-IQL and IQL in two tasks from D4RL. Negative steps denotes the pretraining phase (10 seeds, $\pm$ std).
|
| 334 |
+
|
| 335 |
+

|
| 336 |
+
Figure 14: Pareto fronts for SR-SAC and Tandem SR-SAC on DMC15 (5 seeds).
|
| 337 |
+
|
| 338 |
+
# B.4 PARETO FRONTS COMPARISON
|
| 339 |
+
|
| 340 |
+
With the same approach used for studying the data/computation tradeoffs of SR-SAC, it also becomes possible to directly compare the performance of different replay ratio-scalable algorithms. As a simple example, we compare SR-SAC, its tandem version and SAC in Figure 14. The different lines are Pareto curves, obtained by retaining the points that are dominating the other ones in terms of either data or computational budget, to reach an IQM of at least 600. On this plot, SAC simply appears as a point because, not allowing for effective replay ratio scaling, it can only reach the prescribed performance by using more data and a relatively small amount of computational resources.
|
| 341 |
+
|
| 342 |
+
# B.5 COMPARISON WITH NEURAL FITTED Q-ITERATION
|
| 343 |
+
|
| 344 |
+
The approach we demonstrated for replay ratio scaling, for its relationship with offline RL and its use of resets, could resemble the classic NFQI algorithm (Riedmiller, 2005), which train from scratch, after each large batch of transitions, a Q-function. Our approach propagates information across resets mainly through the use of the replay buffer, having a fast target network updated alongside the regular agent training; NFQI instead propagates information primarily through a target network, which is updated once per reset. We implement an-friendly variant of NFQI on SR-SPR at replay ratio 16, performing one target network update upon each reset. However, we find that this leads to very poor performance (IQM 0.350), achieving barely half that of standard SR-SPR. Although we hypothesized that 2,500 environment steps (the standard reset interval for SR-SPR at replay ratio 16) might be too infrequent for target network updates, making this interval shorter did not improve performance. Although we cannot rule out the possibility that NFQI might be competitive at dramatically higher replay ratios, its inherent slowness in propagating information is likely to lead it to lag in data-efficient settings; any reset interval that is sufficiently long to allow for accurate estimation of the value function may lead to insufficiently rapid value propagation via target updates, and vice versa.
|
| 345 |
+
|
| 346 |
+
# C COMPUTATIONAL CONSIDERATIONS
|
| 347 |
+
|
| 348 |
+
For DMC, the running time depends on the individual environment, due to differences in dimensionality of the observation as well as physics simulation time. On an NVIDIA V100 GPU, at this highest replay ratio of $\mathrm { R R } { = } 1 2 8$ , our code takes about 10.5 hours on acrobot-swingup and about 15 hours on humanoid-run to complete $5 0 0 \mathrm { k }$ environment steps. For a replay ratio of $\mathrm { R R } = 3 2$ , which yields remarkable, even if not best, performance, the time goes down to just about 3 hours and about 4 hours respectively. which is well-below the typical demands of modern model-based RL methods. With careful seed parallelization, running SR-SAC with $\mathrm { R R } = 3 2$ for 5 seeds for all tasks in the DMC15-500k benchmark takes less than 4 GPU/days on an NVIDIA V100. For Atari $1 0 0 \mathrm { k }$ , running time depends primarily on the replay ratio chosen. At the highest replay ratio used (16) and with five seeds running in parallel, our code takes roughly 25 hours to complete $1 0 0 \mathrm { k }$ steps on an NVIDIA A100, yielding a cost of roughly 5 GPU/hours per training run.
|
| 349 |
+
|
| 350 |
+
# D EXPERIMENTAL DETAILS
|
| 351 |
+
|
| 352 |
+
We report in Table 6 the full list of tasks for the DMC15 benchmark. Our implementation of continuous control algorithms is based on the jaxrl codebase (Kostrikov, 2021). For REDQ, we use the best hyperparameters, as recommended by Chen et al. (2021), as well as a replay ratio of 20. For discrete control, we use a version of SPR implemented in Jax (Bradbury et al., 2018) in Dopamine (Castro et al., 2018). See Table 5 for a full list of the employed hyperparameters.
|
| 353 |
+
|
| 354 |
+
# D.1 FULL EXPERIMENTAL RESULTS
|
| 355 |
+
|
| 356 |
+
In Figure 16, we show the scaling curve for DMC15-1M.
|
| 357 |
+
|
| 358 |
+
We report in Table 4 the full per-game results for SR-SPR and in Figure 17,18,19,20,21 full experimental results for SR-SAC. For completeness, we also report the performance of the modified settings and of REDQ at the same replay ratios.
|
| 359 |
+
|
| 360 |
+
Table 4: Full results for individual games in Atari $1 0 0 \mathrm { k }$ for SR-SPR at various replay ratios.
|
| 361 |
+
|
| 362 |
+
<table><tr><td>Game</td><td>Random</td><td>Human</td><td>IRIS</td><td>SR-SPR:2</td><td>SR-SPR:4</td><td>SR-SPR:8</td><td>SR-SPR:16</td></tr><tr><td>Alien</td><td>227.8</td><td>7127.7</td><td>420.0</td><td>877.9</td><td>964.4</td><td>1015.5</td><td>1107.8</td></tr><tr><td>Amidar</td><td>5.8</td><td>1719.5</td><td>143.0</td><td>189.2</td><td>211.8</td><td>203.1</td><td>203.4</td></tr><tr><td>Assault</td><td>222.4</td><td>742.0</td><td>1524.4</td><td>891.9</td><td>987.3</td><td>1069.5</td><td>1088.9</td></tr><tr><td>Asterix</td><td>210.0</td><td>8503.3</td><td>853.6</td><td>836.7</td><td>894.2</td><td>916.5</td><td>903.1</td></tr><tr><td>Bank Heist</td><td>14.2</td><td>753.1</td><td>53.1</td><td>253.6</td><td>460.0</td><td>472.3</td><td>531.7</td></tr><tr><td>Battle Zone</td><td>2360.0</td><td>37187.5</td><td>13074.0</td><td>14493.5</td><td>17800.6</td><td>19398.4</td><td>17671.0</td></tr><tr><td>Boxing</td><td>0.1</td><td>12.1</td><td>70.1</td><td>36.1</td><td>42.0</td><td>46.7</td><td>45.8</td></tr><tr><td>Breakout</td><td>1.7</td><td>30.5</td><td>83.7</td><td>24.5</td><td>26.1</td><td>28.8</td><td>25.5</td></tr><tr><td>Chopper Command</td><td>811.0</td><td>7387.8</td><td>1565.0</td><td>1609.4</td><td>1933.7</td><td>2201.0</td><td>2362.1</td></tr><tr><td>Crazy Climber</td><td>10780.5</td><td>35829.4</td><td>59324.2</td><td>28004.7</td><td>38341.7</td><td>43122.3</td><td>45544.1</td></tr><tr><td>Demon Attack</td><td>152.1</td><td>1971.0</td><td>2034.4</td><td>2969.0</td><td>3016.2</td><td>2898.1</td><td>2814.4</td></tr><tr><td>Freeway</td><td>0.0</td><td>29.6</td><td>31.1</td><td>24.1</td><td>24.5</td><td>24.9</td><td>25.4</td></tr><tr><td>Frostbite</td><td>65.2</td><td>4334.7</td><td>259.1</td><td>1450.4</td><td>1809.9</td><td>1752.8</td><td>2584.8</td></tr><tr><td>Gopher</td><td>257.6</td><td>2412.5</td><td>2236.1</td><td>735.3</td><td>717.5</td><td>711.2</td><td>712.4</td></tr><tr><td>Hero</td><td>1027.0</td><td>30826.4</td><td>7037.4</td><td>6832.1</td><td>7195.7</td><td>7679.6</td><td>8524.0</td></tr><tr><td>Jamesbond</td><td>29.0</td><td>302.8</td><td>462.7</td><td>412.9</td><td>408.8</td><td>392.8</td><td>389.1</td></tr><tr><td>Kangaroo</td><td>52.0</td><td>3035.0 2665.5</td><td>838.2</td><td>1651.2</td><td>2024.1</td><td>3254.9</td><td>3631.7</td></tr><tr><td>Krull</td><td>1598.0</td><td>22736.3</td><td>6616.4 21759.8</td><td>5206.4</td><td>5364.3</td><td>5824.8</td><td>5914.4</td></tr><tr><td>KungFuMaster Ms Pacman</td><td>258.5 307.3</td><td>6951.6</td><td>999.1</td><td>14165.6</td><td>17656.5</td><td>17095.6</td><td>18649.4</td></tr><tr><td>Pong</td><td>-20.7</td><td>14.6</td><td>14.6</td><td>1472.6</td><td>1544.7</td><td>1522.6</td><td>1574.1</td></tr><tr><td>Private Eye</td><td>24.9</td><td>69571.3</td><td>100.0</td><td>-10.5 98.8</td><td>-5.5 95.8</td><td>-3.0</td><td>2.9</td></tr><tr><td>Qbert</td><td>163.9</td><td>13455.0</td><td>745.7</td><td>3431.7</td><td>3699.8</td><td>95.8</td><td>97.9</td></tr><tr><td>Road Runner</td><td>11.5</td><td>7845.0</td><td>9614.6</td><td>12199.0</td><td></td><td>3850.6</td><td>4044.1</td></tr><tr><td></td><td></td><td>42054.7</td><td>661.3</td><td>714.7</td><td>14287.3</td><td>13623.5</td><td>13463.4</td></tr><tr><td>Seaquest Up N Down</td><td>68.4 533.4</td><td>11693.2</td><td>3546.2</td><td>61851.2</td><td>766.6 91435.2</td><td>800.5 95501.1</td><td>819.0</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>112450.3</td></tr><tr><td>Games >Human</td><td>0</td><td>0</td><td>9</td><td>7</td><td>8</td><td>9</td><td>9</td></tr><tr><td>IQM (↑)</td><td>0.000</td><td>1.000</td><td>0.501</td><td>0.444</td><td>0.544</td><td>0.589</td><td>0.632</td></tr><tr><td>Optimality Gap (↓)</td><td>1.000</td><td>0.000</td><td>0.512</td><td>0.516</td><td>0.470</td><td>0.452</td><td>0.433</td></tr><tr><td>Median (↑)</td><td>0.000</td><td>1.000</td><td>0.289</td><td>0.336</td><td>0.523</td><td>0.560</td><td>0.685</td></tr><tr><td>Mean (↑)</td><td>0.000</td><td>1.000</td><td>1.046</td><td>0.910</td><td>1.111</td><td>1.188</td><td>1.272</td></tr></table>
|
| 363 |
+
|
| 364 |
+

|
| 365 |
+
Figure 15: Learning curves for SR-SPR (solid) and SPR (dashed) at various replay ratios. Note that all SR-SPR runs converge to similar TD errors, gradient norms and parameter norms, while these metrics greatly differ for SPR at different replay ratios. IQM training performance does not match evaluation performance, as ongoing training episodes are often disrupted by the reset procedure.
|
| 366 |
+
|
| 367 |
+
<table><tr><td>Parameter</td><td>Setting</td><td colspan="2"></td></tr><tr><td>Gray-scaling</td><td>True</td><td colspan="2"></td></tr><tr><td>Observation down-sampling</td><td>84x84</td><td colspan="2"></td></tr><tr><td>Frames stacked</td><td>4</td><td colspan="2"></td></tr><tr><td>Action repetitions</td><td>4</td><td colspan="2"></td></tr><tr><td>Reward clipping</td><td>[-1,1]</td><td colspan="2"></td></tr><tr><td>Terminal on loss of life</td><td>True</td><td colspan="2"></td></tr><tr><td>Max frames per episode</td><td>108K</td><td colspan="2"></td></tr><tr><td>Update</td><td>Distributional Q</td><td colspan="2"></td></tr><tr><td>Dueling</td><td>True</td><td colspan="2"></td></tr><tr><td>Support of Q-distribution</td><td>51</td><td colspan="2"></td></tr><tr><td>Discount factor</td><td>0.99</td><td colspan="2"></td></tr><tr><td>Minibatch size</td><td>32</td><td colspan="2">Parameter</td></tr><tr><td>Optimizer</td><td>Adam.</td><td></td><td>Setting</td></tr><tr><td>Optimizer: learning rate</td><td>0.0001</td><td>Discount factor</td><td>0.99</td></tr><tr><td>Optimizer: β1</td><td>0.9</td><td>Minibatch size</td><td>256</td></tr><tr><td>Optimizer: β2</td><td>0.999</td><td>Optimizer (all)</td><td>Adam</td></tr><tr><td>Optimizer: e</td><td>0.00015</td><td>Optimizer (all): learning rate</td><td>0.0003</td></tr><tr><td>Max gradient norm</td><td>10</td><td>Optimizer (all): β1</td><td>0.9</td></tr><tr><td>Priority exponent</td><td>0.5</td><td>Optimizer (all): β2</td><td>0.999</td></tr><tr><td>Priority correction</td><td>0.4→1</td><td>Optimizer (all): ∈</td><td>0.00015</td></tr><tr><td>Exploration</td><td>Noisy nets</td><td>Networks (all):activation</td><td>ReLU</td></tr><tr><td>Noisy nets parameter</td><td>0.5</td><td>Networks (all): n. hidden layers</td><td>2</td></tr><tr><td>Training steps</td><td>100K</td><td>Networks (all): hidden units</td><td>256</td></tr><tr><td>Evaluation trajectories</td><td>100</td><td>Initial Temperature</td><td>1</td></tr><tr><td>Min replay size for sampling</td><td>2000</td><td>Replay Buffer Size</td><td>106</td></tr><tr><td>Replay period every</td><td>1 step</td><td>Updates per step</td><td>Variable (1 to 128)</td></tr><tr><td>Updates per step</td><td>Variable (1,2,4,8,16)</td><td>Target network update period</td><td>1</td></tr><tr><td>Multi-step return length</td><td>10</td><td>T (EMA coefficient)</td><td>0.995</td></tr><tr><td>Q network: channels</td><td>32,64,64</td><td>Reset Interval (gradient steps)</td><td>2560000</td></tr><tr><td>Q network: filter size</td><td>8×8,4×4,3×3</td><td>Layers getting hard reset</td><td>All</td></tr><tr><td>Q network: stride</td><td>4,2,1</td><td></td><td></td></tr><tr><td>Q network: hidden units</td><td>512 ReLU</td><td colspan="2"></td></tr><tr><td>Non-linearity</td><td colspan="2">1</td><td></td></tr><tr><td>Target network update period</td><td colspan="2">2</td><td></td></tr><tr><td>入 (SPR loss coefficient)</td><td colspan="2">5</td><td></td></tr><tr><td>K(SPR prediction depth)</td><td colspan="2">Shifts (±4 pixels)</td><td></td></tr><tr><td>Data Augmentation</td><td colspan="2">Intensity(scale=0.05)</td><td></td></tr><tr><td>T (EMA coefficient)</td><td colspan="2">0.995</td><td></td></tr><tr><td>Reset Interval (gradient steps)</td><td colspan="2">40,000</td><td></td></tr><tr><td>Layers getting hard reset</td><td colspan="2">Final 2</td><td></td></tr><tr><td>Shrink and Perturb α</td><td colspan="2">0.8</td><td></td></tr><tr><td>Action selection</td><td colspan="2">Target network</td><td></td></tr></table>
|
| 368 |
+
|
| 369 |
+
Table 5: Hyperparameters for SR-SPR and SR-SAC. The ones introduced by this work are at the bottom of the respective tables.
|
| 370 |
+
|
| 371 |
+
<table><tr><td>Environment</td><td>Tasks</td></tr><tr><td>walker</td><td>run</td></tr><tr><td>quadruped</td><td>run,walk</td></tr><tr><td>reacher</td><td>hard</td></tr><tr><td>humanoid</td><td>run,walk,stand</td></tr><tr><td>swimmer</td><td>swimmer6</td></tr><tr><td>cheetah</td><td>run</td></tr><tr><td>hopper</td><td>hop,stand</td></tr><tr><td>acrobot</td><td>swingup</td></tr><tr><td>pendulum</td><td>swingup</td></tr><tr><td>finger</td><td>turn_hard</td></tr><tr><td>fish</td><td>swim</td></tr></table>
|
| 372 |
+
|
| 373 |
+

|
| 374 |
+
Table 6: The tasks from the DMC15 benchmark. We chose commonly-employed DMC tasks for which the optimal policy is not immediately found by SAC according to https://github.com/ denisyarats/pytorch_sac#results.
|
| 375 |
+
Figure 16: Scaling curve for SR-SAC and SAC on DMC15-1M.
|
| 376 |
+
|
| 377 |
+

|
| 378 |
+
Figure 17: Evaluation Returns on individual DMC15 environments for replay ratio 8.
|
| 379 |
+
|
| 380 |
+

|
| 381 |
+
Figure 18: Evaluation Returns on individual DMC15 environments for replay ratio 16.
|
| 382 |
+
|
| 383 |
+

|
| 384 |
+
Figure 19: Evaluation Returns on individual DMC15 environments for replay ratio 32.
|
| 385 |
+
|
| 386 |
+

|
| 387 |
+
Figure 20: Evaluation Returns on individual DMC15 environments for replay ratio 64.
|
| 388 |
+
|
| 389 |
+

|
| 390 |
+
Figure 21: Evaluation Returns on individual DMC15 environments for replay ratio 128.
|
md/dev/Q42f0dfjECO/Q42f0dfjECO.md
ADDED
|
@@ -0,0 +1,446 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# DIFFERENTIALLY PRIVATE FINE-TUNING OF LANGUAGE MODELS
|
| 2 |
+
|
| 3 |
+
Da $\mathbf { Y } \mathbf { u } ^ { 1 , 2 }$ Saurabh Naik4 Arturs Backurs3,∗ Sivakanth Gopi3,∗ Huseyin A. Inan $^ { 3 , * }$ Gautam Kamath5,∗ Janardhan Kulkarni3,∗ Yin Tat Lee3,6,∗ Andre Manoel3,∗ Lukas Wutschitz4,∗ Sergey Yekhanin3,∗ Huishuai Zhang2,∗
|
| 4 |
+
|
| 5 |
+
1Sun Yat-sen University† , 2Microsoft Research Asia
|
| 6 |
+
3Microsoft Research, 4Microsoft
|
| 7 |
+
5Cheriton School of Computer Science, University of Waterloo
|
| 8 |
+
6University of Washington
|
| 9 |
+
1yuda3@mail2.sysu.edu.cn, 2huzhang@microsoft.com
|
| 10 |
+
3{arturs.backurs, sigopi, huseyin.inan}@microsoft.com
|
| 11 |
+
3{jakul, amonteiroman, yekhanin}@microsoft.com
|
| 12 |
+
4{snaik, lukas.wutschitz}@microsoft.com
|
| 13 |
+
5g@csail.mit.edu, 6yintat@uw.edu
|
| 14 |
+
|
| 15 |
+
# ABSTRACT
|
| 16 |
+
|
| 17 |
+
We give simpler, sparser, and faster algorithms for differentially private finetuning of large-scale pre-trained language models, which achieve the state-ofthe-art privacy versus utility tradeoffs on many standard NLP tasks. We propose a meta-framework for this problem, inspired by the recent success of highly parameter-efficient methods for fine-tuning. Our experiments show that differentially private adaptations of these approaches outperform previous private algorithms in three important dimensions: utility, privacy, and the computational and memory cost of private training. On many commonly studied datasets, the utility of private models approaches that of non-private models. For example, on the MNLI dataset we achieve an accuracy of $8 7 . 8 \%$ using RoBERTa-Large and $8 3 . 5 \%$ using RoBERTa-Base with a privacy budget of $\varepsilon = 6 . 7$ . In comparison, absent privacy constraints, RoBERTa-Large achieves an accuracy of $9 0 . 2 \%$ . Our findings are similar for natural language generation when privately fine-tuning GPT-2. Our experiments also show that larger models are better suited for private fine-tuning: while they are well known to achieve superior accuracy non-privately, we find that they also better maintain their accuracy when privacy is introduced.
|
| 18 |
+
|
| 19 |
+
# 1 INTRODUCTION
|
| 20 |
+
|
| 21 |
+
Deep learning models are well known to leak sensitive information about the dataset when trained using conventional methods (Shokri et al., 2017; Carlini et al., 2019; 2021). To combat this issue, models can instead be trained to guarantee differential privacy (DP) (Dwork et al., 2006b), a strong notion of data privacy which limits the influence of any individual training point on the final model. While DP is one of the few approaches capable of providing machine learning models with rigorous privacy guarantees, it generally comes at a cost in terms of test accuracy. One oft-cited explanation is that the constraint of DP necessitates much more training data (Tramer & Boneh \` , 2021; Feldman, 2020; Brown et al., 2021). Unfortunately, more training data may be hard to acquire, particularly in settings where privacy is a concern.
|
| 22 |
+
|
| 23 |
+
Parallel to these developments, Transformer-based (Vaswani et al., 2017) large language models (LLMs), including the BERT (Devlin et al., 2019; Liu et al., 2019) and GPT (Radford et al., 2018; 2019; Brown et al., 2020) families, have enabled significant progress in natural language processing, achieving state-of-the-art accuracy in almost every task considered. These models are first pre-trained on an extremely large and diverse public dataset. The weights are then fine-tuned for each task of interest using a much smaller task-specific dataset. For example, a single pre-trained GPT-family model may be fine-tuned for various downstream tasks, such as email reply suggestion, sentence completion in text editors, language translation, and more. This two-stage paradigm can naturally be adapted to solve tasks in private learning, automatically addressing the aforementioned data shortage issue via the massive scale of the public pre-training dataset. One may pre-train the model on public data as usual,1 but then fine-tune the model privately.
|
| 24 |
+
|
| 25 |
+

|
| 26 |
+
Figure 1: An illustration of our framework. First, the model is pre-trained on a large, public dataset. Next, new parameters are introduced and privately fine-tuned on a smaller, private, task-specific dataset. The original parameters are frozen during this process. Finally, the fine-tuned new parameters may be released publicly and plugged-in to the model for downstream tasks, while still preserving privacy of the private dataset.
|
| 27 |
+
|
| 28 |
+
Table 1: Accuracy of fine-tuning for downstream tasks with RoBERTa-Large (in $\%$ ). Our results achieve accuracy comparable to full fine-tuning non-privately, while simultaneously guaranteeing differential privacy. We choose $\delta = 1 { \mathrm e } { - } 5$ for SST-2 and QNLI and $\delta = 1 \mathrm { e } { - } 6$ for MNLI and QQP due to their dataset sizes. Implementation details are in Section 4.1.
|
| 29 |
+
|
| 30 |
+
<table><tr><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>MNLI</td><td rowspan=1 colspan=1>SST-2</td><td rowspan=1 colspan=1>QQP</td><td rowspan=1 colspan=1>QNLI</td><td rowspan=1 colspan=1>Avg.</td><td rowspan=1 colspan=1>Trained params</td></tr><tr><td rowspan=1 colspan=1>Non-private fine-tuning</td><td rowspan=1 colspan=1>90.2</td><td rowspan=1 colspan=1>96.4</td><td rowspan=1 colspan=1>92.2</td><td rowspan=1 colspan=1>94.7</td><td rowspan=1 colspan=1>93.4</td><td rowspan=1 colspan=1>100%</td></tr><tr><td rowspan=1 colspan=1>Our results (ε= 6.7)</td><td rowspan=1 colspan=1>87.8</td><td rowspan=1 colspan=1>95.3</td><td rowspan=1 colspan=1>87.4</td><td rowspan=1 colspan=1>90.8</td><td rowspan=1 colspan=1>90.3</td><td rowspan=1 colspan=1>0.94%</td></tr></table>
|
| 31 |
+
|
| 32 |
+
Despite the success of these models, task-specific fine-tuning introduces a number of technical challenges. In the non-private setting, the immense size of LLMs makes it impractical to fine-tune the full model and store a separate copy of the parameters for hundreds of downstream tasks. Things only get worse with privacy, which leads to overheads in terms of running time, memory usage, and most importantly, accuracy. The magnitude of noise introduced to a model due to DP grows as the model size increases (Bassily et al., 2014; Abadi et al., 2016; Bun et al., 2014), which can overwhelm any signal for larger models. A recent line of work in the non-private literature has proposed parameter-efficient methods to alleviate the issues of storage and computational cost for fine-tuning (Houlsby et al., 2019; Li & Liang, 2021; Aghajanyan et al., 2020; Hu et al., 2021; Mahabadi et al., 2021). The main focus of our work is to explore parameter-efficiency in the context of private learning.
|
| 33 |
+
|
| 34 |
+
# 1.1 OUR CONTRIBUTIONS
|
| 35 |
+
|
| 36 |
+
Our primary contribution is to show that advanced parameter-efficient methods can lead to simpler and significantly improved algorithms for private fine-tuning. Our framework is illustrated in Figure 1. Our findings and contributions are summarized as follows:
|
| 37 |
+
|
| 38 |
+
State-of-the-art utility and privacy. Empirical evaluation of our algorithms reveals that they achieve state-of-the-art accuracy versus privacy tradeoffs, improving upon the previous best (Yu et al., 2021b). More importantly, for many fine-tuning tasks, the utility of models trained with DP approaches that of non-private models. For example, privately fine-tuning RoBERTa-Large on the MNLI data set (Williams et al., 2018), we achieve an accuracy of $8 7 . 8 \%$ with a privacy budget of $( \varepsilon = 6 . 7 , \delta = 1 \mathrm { e } . 6 )$ . Without privacy guarantees, RoBERTa-Large achieves an accuracy of ${ \bar { 9 0 . 2 \% } }$ (GPT-3 is known to achieve $9 1 . 7 \%$ (Hu et al., 2021)); see Table 1 for a summary. We also explore private natural language generation tasks, fine-tuning GPT-2 models on the E2E dataset (Novikova et al., 2017). Again, the utility approaches non-private levels: we achieve a ROUGE-L score of 0.6755 with GPT-2-Large and $( \varepsilon = 5 . 4 , \delta = 1 \mathrm { e } { - } 5 )$ , compared to 0.72 without privacy.
|
| 39 |
+
|
| 40 |
+
Larger models are better. Prior work has consistently shown that larger language models achieve better accuracy for downstream tasks. Our results give evidence that this phenomenon extends to the private setting. For example, on the MNLI dataset, RoBERTa-Base achieves an accuracy of $8 3 . 5 \%$ whereas RoBERTa-Large achieves an accuracy of $8 7 . 8 \%$ , both under a privacy budget of $( \varepsilon = 6 . 7 , \delta = 1 \mathrm { e } . 6 )$ . Similarly, privately fine-tuning with E2E, GPT-2-Small, GPT-2-Medium, and GPT-2-Large achieve ROUGE-L scores of 0.6219, 0.6645 and 0.6755 respectively, all under a privacy budget of $( \varepsilon = 5 . 4 , \delta = 1 { \mathrm { e } } { \cdot } 5 )$ . While established in the non-private setting, we find this phenomenon quite surprising under DP. There is often a tension when choosing private model architectures: larger models may have higher capacity, but necessitate the introduction of more noise. Consequently, smaller and simpler private models achieve the better accuracy in several settings (Papernot et al., 2019; Tramer & Boneh \` , 2021). In contrast, our experiments show that fine-tuning the biggest models achieves the best accuracy.2
|
| 41 |
+
|
| 42 |
+
Simpler, sparser, and faster. Beyond accuracy concerns, DP requirements also lead to significant overheads in terms of computation and memory usage. The large number of parameters contributes to the high cost of training LLMs, and things get worse under privacy, which has been documented to increase training time by up to two orders of magnitude (Carlini et al., 2019; Subramani et al., 2021). The parameter-efficient approaches we employ partially offset this issue: as we only update a small fraction of the total number of parameters, training becomes considerably more computationally and memory efficient. Furthermore, as in the non-private setting, this framework leads to a modular design, where a single large pre-trained model can be augmented with lightweight modifications for each individual downstream task.
|
| 43 |
+
|
| 44 |
+
To the best of our knowledge, we are the first to fine-tune GPT-2-Large using differential privacy, the largest model trained thus far using DP. Given our state-of-the-art results for a variety of standard NLP tasks using advanced fine-tuning techniques, we believe that our paper will serve as a benchmark for further work in this direction. For example, the best average accuracy achieved by the prior work of Yu et al. (2021b) on four standard NLP tasks in Table 1 is $8 3 . 9 \%$ using $\varepsilon = 8$ (and the same $\delta$ as in Table 1), whereas we can achieve an average accuracy of $9 0 . 3 \%$ using $\varepsilon = 6 . 7$ by a combination of better algorithms, larger models, and new privacy accounting techniques.
|
| 45 |
+
|
| 46 |
+
Finally, though recently considered elsewhere (see Section 5), we put further focus on the framing of public pre-training and private fine-tuning as an important conceptual direction in DP deep learning.
|
| 47 |
+
|
| 48 |
+
# 2 PRELIMINARIES AND PRIOR ALGORITHM BASELINES
|
| 49 |
+
|
| 50 |
+
Recall the formal definition of differential privacy.
|
| 51 |
+
|
| 52 |
+
Definition 2.1 (Differential Privacy (DP) (Dwork et al., 2006b;a)). A randomized algorithm $\mathcal { A }$ is $( \varepsilon , \delta )$ -differentially private if for any two neighboring datasets $D$ and $D ^ { \prime }$ , which differ in exactly the data pertaining to a single user, and for all sets $s$ of possible outputs: $\operatorname* { P r } [ A ( D ) \in { \mathcal { S } } ] \leq e ^ { \varepsilon } \operatorname* { P r } [ A ( D ^ { \prime } ) \in { \mathcal { S } } ] + \delta$ .
|
| 53 |
+
|
| 54 |
+
We review prior techniques for private fine-tuning.
|
| 55 |
+
|
| 56 |
+
# 2.1 FULL FINE-TUNING VIA DPSGD
|
| 57 |
+
|
| 58 |
+
To train a machine learning model with privacy, the most popular algorithm is the celebrated DP stochastic gradient descent (DPSGD) (Song et al., 2013; Bassily et al., 2014; Abadi et al., 2016). This optimization method serves as a drop-in replacement for SGD, augmenting it with the addition of per-example gradient clipping and Gaussian noise addition steps. These two steps serve to limit and mask the contribution of a single example. Two key points to note are that a) per-example gradient clipping incurs significant computational and memory overheads in most implementations, and b) noise introduced due to privacy grows as the square-root as the number of model parameters. With this tool in place, the most basic fine-tuning strategy is to train all parameters using DPSGD.
|
| 59 |
+
|
| 60 |
+
# 2.2 REPARAMETRIZED GRADIENT PERTURBATION
|
| 61 |
+
|
| 62 |
+
To mitigate the limitations of DPSGD, a recent work of Yu et al. (2021b) introduced an elegant method called reparametrized gradient perturbation (RGP). RGP exploits the implicit low-rank structure in the gradient updates of SGD to substantially improve upon DPSGD. Specifically, they reparametrize each layer’s weight matrix $W$ into $L R + { \tilde { W } }$ , where $L$ and $R$ are low-rank gradientcarrier matrices and $\tilde { W }$ is the residual weight. The authors show that one can obtain a lowdimensional projection of $W$ ’s gradient by taking gradients only of the low-rank matrices $L$ and $R$ (and not the high-rank $\tilde { W }$ ). Privacy is introduced by clipping and noising these low-dimensional gradients of $L$ and $R$ . While this low-dimensional projection loses some of the signal in $W$ ’s gradient, it turns out to contain enough to still achieve high accuracy. At the same time, the low-dimensional gradients alleviate the aforementioned issues related to privatization, significantly reducing the memory consumption and noise introduced.
|
| 63 |
+
|
| 64 |
+
# 3 OUR APPROACH
|
| 65 |
+
|
| 66 |
+
# 3.1 A META-FRAMEWORK
|
| 67 |
+
|
| 68 |
+
We introduce our approach as a meta-framework for private deep learning, which abstracts the key principles of recent fine-tuning methods.
|
| 69 |
+
|
| 70 |
+
Suppose $f ( W _ { \mathrm { P T } } ; x )$ is a pre-trained model where $W _ { \mathrm { P T } }$ are the pre-trained weights and $x$ is any input. We create a new fine-tuning model
|
| 71 |
+
|
| 72 |
+
$$
|
| 73 |
+
f _ { \mathrm { F T } } ( W _ { \mathrm { P T } } , \theta ; x )
|
| 74 |
+
$$
|
| 75 |
+
|
| 76 |
+
which incorporates additional trainable parameters $\theta$ , where $\dim ( \theta ) \ll \dim ( W _ { \mathrm { P T } } )$ . That is, the number of new parameters in $\theta$ is a small fraction of the original number of parameters in the pretrained weights $W _ { \mathrm { P T } }$ . Fine-tuning is done by running DPSGD on the additional parameters $\theta$ , while freezing the weights of pre-trained model $W _ { \mathrm { P T } }$ . The new parameters are initialized to $\theta _ { 0 }$ such that
|
| 77 |
+
|
| 78 |
+
$$
|
| 79 |
+
\begin{array} { r } { f _ { \mathrm { F T } } ( W _ { \mathrm { P T } } , \theta _ { 0 } ; x ) = f ( W _ { \mathrm { P T } } ; x ) . } \end{array}
|
| 80 |
+
$$
|
| 81 |
+
|
| 82 |
+
The initialization condition (2) is very important, as it ensures that fine-tuning starts at the pre-trained model and improves it by modifying the parameters $\theta$ . Most fine-tuning methods are additive and have the following special form:
|
| 83 |
+
|
| 84 |
+
$$
|
| 85 |
+
\begin{array} { r } { f _ { \mathrm { F T } } ( W _ { \mathrm { P T } } , \theta ; x ) = f ( W _ { \mathrm { P T } } + \pi ( \theta ) ; x ) , } \end{array}
|
| 86 |
+
$$
|
| 87 |
+
|
| 88 |
+
i.e., they modify the pre-trained weights by adding a correction term $\pi ( \theta )$ parametrized by $\theta$
|
| 89 |
+
|
| 90 |
+
Recent work in the non-private literature has described concrete instantiations of this framework (Houlsby et al., 2019; Mahabadi et al., 2021; Hu et al., 2021), which (crucially) are effective when $\dim ( \theta ) ^ { \cdot } \ll \dim ( W _ { \mathrm { P T } } )$ . In the non-private setting, such reparametrizations are useful for reducing the computation and memory required for fine-tuning, and enable lightweight and plug-in modifications to the base model for different downstream tasks. At the same time, they maintain (or sometimes surpass) the accuracy achieved by full fine-tuning.
|
| 91 |
+
|
| 92 |
+
We give some intuition as to why parameter-efficient methods can to be more effective for private fine-tuning, especially on smaller datasets. For simplicity, we assume that the fine-tuning method is additive as in (3), such that the fine-tuned weights $\dot { W _ { \mathrm { F T } } } = W _ { \mathrm { P T } } + \pi ( \theta )$ . We can imagine that
|
| 93 |
+
|
| 94 |
+
$W _ { \mathrm { F T } }$ lies on a manifold passing through $W _ { \mathrm { P T } }$ of very small dimension (equal to the dimension of $\theta$ ) compared to the dimension of $W _ { \mathrm { P T } }$ . Even if the parameters $\theta$ are very noisy due to the noise added during DPSGD, we will always stay in this manifold. In particular, we are not disturbing the pre-trained weights in most directions (those orthogonal to the manifold near $W _ { \mathrm { P T } }$ ). If we run DPSGD on all the weights instead, then we add noise in all directions, thus potentially unlearning the knowledge learned during pre-training, especially in low data regimes. However, this intuition may not always be true; see the remark at the end of our experiments on NLU tasks.
|
| 95 |
+
|
| 96 |
+
Besides substantial gains in the accuracy, the above method of reparametrization has several other advantages:
|
| 97 |
+
|
| 98 |
+
• A single pre-trained model such as BERT or GPT is generally applied to hundreds of downstream tasks via fine-tuning. Private fine-tuning using previous methods requires updating all parameters and storing a different copy of the fine-tuned model per task. This creates substantial overheads for storing and deploying, and can be very expensive in practice. On the other hand, the reparametrization (1) means that we only need to store a single pretrained model that can be shared across many downstream tasks. Each downstream task requires only a small number of new parameters that can be plugged in. • Differentially private training requires computing and storing per-example gradients, which increases the memory footprint. In our approach, however, learning is done in a much lower dimension, hence saving on the memory cost as compared to prior works. Finally, we expect that (1) also gives a more communication-efficient method of fine-tuning in distributed settings such as federated learning, due to the significantly smaller number of parameters learned during fine-tuning.
|
| 99 |
+
|
| 100 |
+
# 3.2 INSTANTIATING THE META-FRAMEWORK
|
| 101 |
+
|
| 102 |
+
In this section, we discuss a few ways to instantiate our meta-framework. This list is non-exhaustive, but covers the methods we employ in our experiments.
|
| 103 |
+
|
| 104 |
+
# 3.2.1 FINE-TUNING VIA LOW-RANK ADAPTATION
|
| 105 |
+
|
| 106 |
+
Low-Rank Adaptation (LoRA) (Hu et al., 2021) is an additive fine-tuning scheme as defined in (3). For each dense weight matrix $\dot { W } _ { \mathrm { P T } } ^ { i }$ of size $a \times b$ in the pre-trained network, we add a low-rank correction term $L ^ { i } R ^ { i }$ , i.e.,
|
| 107 |
+
|
| 108 |
+
$$
|
| 109 |
+
W ^ { i } = W _ { \mathrm { P T } } ^ { i } + L ^ { i } R ^ { i } ,
|
| 110 |
+
$$
|
| 111 |
+
|
| 112 |
+
where $L ^ { i } \in \mathbb { R } ^ { a \times r } , R ^ { i } \in \mathbb { R } ^ { r \times b }$ are new trainable parameters. Hu et al. (2021) apply this reparameterization only to the Transformer attention weights $( W _ { q } , W _ { v } )$ , and freeze all other weights (e.g., $W _ { k }$ and $W _ { o }$ and those in the feed-forward layers). The rank $r$ is typically chosen to be small, e.g., $r = 4 , 1 6 , 6 4$ . Since most parameters in Transformer architectures are dense weight matrices, choosing a small $r$ results in a nearly square-root reduction in the number of parameters.
|
| 113 |
+
|
| 114 |
+
# 3.2.2 FINE-TUNING VIA ADAPTERS
|
| 115 |
+
|
| 116 |
+
Houlsby et al. (2019) propose adapter-based fine-tuning, in which we modify the architecture of the pre-trained model by adding new “adapter” layers after each attention and feed-forward layer. Adapter layers are bottleneck layers with residual connections. Specifically, given an input $x$ , an adapter layer $A$ performs
|
| 117 |
+
|
| 118 |
+
$$
|
| 119 |
+
A ( x ) = U ( \tau ( D ( x ) ) ) + x ,
|
| 120 |
+
$$
|
| 121 |
+
|
| 122 |
+
where $U$ is an up-projection affine linear map, $D$ is a down-projection affine linear map, and $\tau$ is a non-linear activation function such as the Gaussian error Linear Unit (GeLU) (Hendrycks & Gimpel, 2016). If $x$ has dimension $d$ , then $U \in \mathbb { R } ^ { d \times r } , D \in \mathbb { R } ^ { r \times d }$ for some $r \ll d$ . Thus, the number of introduced parameters is significantly less than the number of parameters in the pre-trained model. When fine-tuning, the parameters of the original model are frozen, and only parameters of the adapter layers, as well as layer normalizations, are modified. Note that fine-tuning with adapters is not an additive fine-tuning framework as in (3), but is captured by the broader framework in (1).
|
| 123 |
+
|
| 124 |
+
Table 2: Memory and speed comparison for RoBERTa-Large. The rank is chosen as $r = 1 6$ for RGP and LoRA. The speed is measured by the wall-clock time for training one epoch of the SST-2 dataset on a single Tesla V100 GPU with gradient accumulation for batch size 2000.
|
| 125 |
+
|
| 126 |
+
<table><tr><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>Memory (GB)</td><td rowspan=1 colspan=1>Speed (seconds per epoch)</td></tr><tr><td rowspan=1 colspan=1>Full fine-tuning (DPSGD)</td><td rowspan=1 colspan=1>27.9</td><td rowspan=1 colspan=1>715</td></tr><tr><td rowspan=1 colspan=1>RGP</td><td rowspan=1 colspan=1>9.1</td><td rowspan=1 colspan=1>296</td></tr><tr><td rowspan=1 colspan=1>DP LoRA</td><td rowspan=1 colspan=1>6.1</td><td rowspan=1 colspan=1>271</td></tr></table>
|
| 127 |
+
|
| 128 |
+
# 3.2.3 FINE-TUNING VIA COMPACTER
|
| 129 |
+
|
| 130 |
+
The recent work of Mahabadi et al. (2021) introduces Compacters (Compact adapters), a method which further improves the parameter efficiency of adapters. This is done by replacing the dense matrices in the up-projection $U$ and down-projection $D$ by tensor products of smaller matrices, thus reducing the number of trainable parameters. Specifically, they replace the dense matrix $M _ { \ell }$ in the adapter layer $\ell$ by a low-rank parameterized hypercomplex multiplication (LPHM) layer, i.e., each dense matrix $\boldsymbol { M _ { \ell } } ^ { \cdot } \in \mathbb { R } ^ { a \times b }$ is expressed as
|
| 131 |
+
|
| 132 |
+
$$
|
| 133 |
+
M _ { \ell } = \sum _ { i = 1 } ^ { n } A _ { i } \otimes \left( S _ { i } ^ { \ell } T _ { i } ^ { \ell } \right)
|
| 134 |
+
$$
|
| 135 |
+
|
| 136 |
+
where $A _ { i } \in \mathbb { R } ^ { n \times n } , S _ { i } ^ { \ell } \in \mathbb { R } ^ { a / n \times k } , T _ { i } ^ { \ell } \in \mathbb { R } ^ { k \times b / n }$ and $\otimes$ is the matrix Kronecker product. Note the matrices $A _ { i }$ are not indexed by the layer $\ell$ because these matrices are shared among all the adapter layers. Since each adapter layers has two dense matrices (one for up-projection and one for down-projection), if there are $L$ adapter layers, this reduces the number of parameters from $L ( 2 a b )$ to $L ( \bar { 2 ( a + b ) k ) } + n ^ { 3 }$ . In practice, $a$ and $b$ are chosen to be either the model dimension $d$ or the intermediate representation dimension $r$ in the adapters, $n$ is typically chosen to be a small constant such as $n = 2 , 4 , 8 , 1 2$ and $k$ is chosen to be 1.
|
| 137 |
+
|
| 138 |
+
# 3.2.4 WHY DOES PARAMETER-EFFICIENT TUNING WORK?
|
| 139 |
+
|
| 140 |
+
Theoretical explanation of success of parameter-efficient fine-tuning methods is active area of research in deep learning. Indeed, since trends have consistently shown that model accuracy increases with size, how can one achieve competitive accuracy while fine-tuning less than $1 \%$ of the parameters? One popular hypothesis is intrinsic dimensionality (Li et al., 2018), which posits that the minimum number of parameters needed to train a machine learning model may be much less than the total number of model parameters. Aghajanyan et al. (2020) explore this hypothesis in the context of fine-tuning LLMs, showing that one can achieve most of their accuracy by training only a very small number of parameters (chosen via a random projection). Perhaps surprisingly, they find that as the model size increases, intrinsic dimension decreases, in the limit exhibiting zero-shot learning. While we did not explore this hypothesis in the context of DP due to computational restrictions, we believe it may be an interesting lens through which one can understand the effectiveness of private parameter-efficient fine-tuning.
|
| 141 |
+
|
| 142 |
+
# 3.3 COMPARISION WITH BASELINE ALGORITHMS
|
| 143 |
+
|
| 144 |
+
We highlight some key algorithmic differences between our proposed methods and the baselines of full fine-tuning and RGP.
|
| 145 |
+
|
| 146 |
+
• DPSGD and RGP both require updating all parameters of the pre-trained model, whereas our proposed methods update only a tiny fraction (between $0 . 0 5 \%$ and $1 \%$ ). The rightmost columns of Tables 3 and 4 list the number of parameters trained by these algorithms. • RGP performs a low-rank decomposition of weight matrices which is similar to LoRA, though there are subtle differences. Recall that in RGP, at the beginning of each iteration $t$ , the historical weight matrix $W _ { t - 1 }$ is decomposed to find a low-rank product $L R$ . The gradients on $L$ and $R$ are then projected back to the full parameter space to perform the descent step. Hence, RGP keeps modifying the pre-trained weights during learning. LoRA can be viewed as a simplification of RGP. LoRA reparametrizes $W _ { \mathrm { F T } } : = W _ { \mathrm { P T } } + L R$ , where the pre-trained weight matrix $W _ { \mathrm { P T } }$ is frozen during training. Hence, compared to
|
| 147 |
+
|
| 148 |
+
Table 3: Accuracy for fine-tuning with RoBERTa-Base (in $\%$ ). The privacy parameters are $\varepsilon = 6 . 7$ , and $\delta = 1 { \mathrm e } { - } 5$ for SST-2 and QNLI and 1e-6 for MNLI and QQP. Bold indicates the best accuracy with DP. Numbers for non-private fine-tuning are from Liu et al. (2019) and Hu et al. (2021).
|
| 149 |
+
|
| 150 |
+
<table><tr><td rowspan=1 colspan=2>Method</td><td rowspan=1 colspan=1>MNLI</td><td rowspan=1 colspan=1>SST-2</td><td rowspan=1 colspan=1>QQP</td><td rowspan=1 colspan=1>QNLI</td><td rowspan=1 colspan=1>Avg.</td><td rowspan=1 colspan=1>Trained params</td></tr><tr><td rowspan=2 colspan=1>Full</td><td rowspan=1 colspan=1>w/o DP</td><td rowspan=1 colspan=1>87.6</td><td rowspan=1 colspan=1>94.8</td><td rowspan=1 colspan=1>91.9</td><td rowspan=1 colspan=1>92.8</td><td rowspan=1 colspan=1>91.8</td><td rowspan=2 colspan=1>100%</td></tr><tr><td rowspan=1 colspan=1>DP</td><td rowspan=1 colspan=1>53.1</td><td rowspan=1 colspan=1>82.6</td><td rowspan=1 colspan=1>74.4</td><td rowspan=1 colspan=1>63.9</td><td rowspan=1 colspan=1>68.5</td></tr><tr><td rowspan=1 colspan=1>LoRA</td><td rowspan=1 colspan=1>w/o DP</td><td rowspan=1 colspan=1>87.5</td><td rowspan=1 colspan=1>95.1</td><td rowspan=1 colspan=1>90.8</td><td rowspan=1 colspan=1>93.3</td><td rowspan=1 colspan=1>91.7</td><td rowspan=1 colspan=1>0.24%</td></tr><tr><td rowspan=1 colspan=1>RGP</td><td rowspan=1 colspan=1>DP</td><td rowspan=1 colspan=1>80.1</td><td rowspan=1 colspan=1>91.6</td><td rowspan=1 colspan=1>85.5</td><td rowspan=1 colspan=1>87.2</td><td rowspan=1 colspan=1>86.1</td><td rowspan=1 colspan=1>100%</td></tr><tr><td rowspan=1 colspan=1>Adapter</td><td rowspan=1 colspan=1>DP</td><td rowspan=1 colspan=1>83.4</td><td rowspan=1 colspan=1>92.5</td><td rowspan=1 colspan=1>85.6</td><td rowspan=1 colspan=1>87.5</td><td rowspan=1 colspan=1>87.3</td><td rowspan=1 colspan=1>1.4% (r = 48)</td></tr><tr><td rowspan=1 colspan=1>Compacter</td><td rowspan=1 colspan=1>DP</td><td rowspan=1 colspan=1>82.6</td><td rowspan=1 colspan=1>92.3</td><td rowspan=1 colspan=1>84.7</td><td rowspan=1 colspan=1>85.1</td><td rowspan=1 colspan=1>86.2</td><td rowspan=1 colspan=1>0.055% (r = 96,n = 8)</td></tr><tr><td rowspan=1 colspan=1>LoRA</td><td rowspan=1 colspan=1>DP</td><td rowspan=1 colspan=1>83.5</td><td rowspan=1 colspan=1>92.2</td><td rowspan=1 colspan=1>85.7</td><td rowspan=1 colspan=1>87.3</td><td rowspan=1 colspan=1>87.2</td><td rowspan=1 colspan=1>0.94% (r = 16)</td></tr></table>
|
| 151 |
+
|
| 152 |
+
RGP, LoRA eliminates the decomposition and the projection to the full parameter space at each iteration, simplifying the implementation and reducing the running time and memory cost. This is summarized in Table 2. We observe that DP LoRA reduces the memory cost by about $3 3 \%$ and the training speed by $8 \%$ . As we will see, this simplification also results in improved utility.
|
| 153 |
+
|
| 154 |
+
• Neither full fine-tuning nor RGP fall into our meta-framework described by (1). Thus, if a pre-trained model is to be applied to several downstream tasks, one must store a separate set of weights for each task, incurring a significant memory cost and losing the plug-in functionality. In contrast, our methods are much more lightweight.
|
| 155 |
+
|
| 156 |
+
# 4 EXPERIMENTS
|
| 157 |
+
|
| 158 |
+
We experimentally evaluate our methods for DP fine-tuning to demonstrate their utility, privacy, and parameter-efficiency. We investigate both language understanding and text generation tasks to establish that our techniques are applicable to a variety of tasks and model architectures. Our code is publicly available at https://github.com/AnonymousAKES/ Differentially-Private-Fine-tuning-of-Language-Models.
|
| 159 |
+
|
| 160 |
+
# 4.1 FINE-TUNING FOR LANGUAGE UNDERSTANDING TASKS
|
| 161 |
+
|
| 162 |
+
We first compare our methods with state-of-the-art fine-tuning algorithms using models from the BERT family, which was used in the prior work (Yu et al., 2021b). Specifically, we use RoBERTa models (Liu et al., 2019), which are pre-trained on public data collected from the web. RoBERTaBase has 125M parameters and RoBERTa-Large has 355M parameters. We choose four downstream tasks: MNLI, QQP, QNLI, and SST-2 from GLUE (Wang et al., 2018), following Yu et al. (2021b).
|
| 163 |
+
|
| 164 |
+
Implementation Details: For fine-tuning with adapters, we may choose the intermediate representation dimension $r$ , shared across all adapter layers. For fine-tuning with Compacter, we can choose both $r$ and the Kronecker product kernel dimension $n$ in (6). For LoRA fine-tuning, we add bottleneck branches for both the attention layers and the feedforward layers, which differs slightly from the addition of bottleneck branches for only the $W _ { q }$ and $W _ { v }$ matrices of the attention layers as done by Hu et al. (2021). Given the same bottleneck representation dimension $r$ in (4), our new implementation uses twice as many trainable parameters as the original paper, and achieves some improvements for learning with DP. We perform privacy accounting using the approach of Gopi et al. (2021), which currently gives the tightest bounds.
|
| 165 |
+
|
| 166 |
+
Hyperparameter choice: Given the large number of hyperparameter choices, e.g., the intermediate representation dimension, learning rate, weight decay, privacy parameter $\delta$ , and model size, an exhaustive grid search over all hyperparameters is expensive. Our hyperparameter choices are informed by prior work and are as follows. For privacy parameters, we use $\delta = 1 \mathrm { e } { - } 5$ for SST-2 and QNLI and $\delta = 1 \mathrm { e } { - } 6$ for QQP and MNLI due to their dataset sizes, and use noise multipliers 0.92, 0.83, 0.66 and 0.65 for SST-2, QNLI, QQP, and MNLI, respectively, which is the same as $\mathrm { Y u }$ et al. (2021b). In Appendix B, we run experiments under different privacy parameters. The proposed framework performs well under a wide range choices of $\varepsilon$ and $\delta$ . The clipping threshold is 10 for all methods. The batch size is 2000. In Appendix D, we show the performance of the proposed algorithm is stable across a wide range of choices of clipping thresholds and batch sizes. For adapters and Compacter, we follow the original papers and choose $r$ from $\{ 1 6 , 4 8 , 9 6 \}$ and $n$ from $\{ 4 , 8 , 1 2 \}$ . For LoRA, we choose the best-performing rank $r$ from the set $\{ 4 , 1 6 , 4 8 , 6 4 \}$ . The best performing hyperparameters are noted in Tables 3 and 4. We train for 20 epochs using AdamW (Loshchilov & Hutter, 2019) with weight decay 1e-2 and search over four learning rates $\{ 5 \mathrm { e } { - } 4 , 1 \mathrm { e } { - } 3 , 2 \mathrm { e } { - } 3 , 5 \mathrm { e } { - } 3 \}$ .
|
| 167 |
+
|
| 168 |
+
Table 4: Accuracy for fine-tuning with RoBERTa-Large $( \mathrm { i n } \% )$ ). The privacy parameters are $\varepsilon = 6 . 7$ , and $\delta = 1 { \mathrm e } { - } 5$ for SST-2 and QNLI and $\delta = 1 \mathrm { e } { - } 6$ for MNLI and QQP. Bold indicates the best accuracy with DP. Numbers for non-private fine-tuning are from Liu et al. (2019) and Hu et al. (2021).
|
| 169 |
+
|
| 170 |
+
<table><tr><td rowspan=1 colspan=2>Method</td><td rowspan=1 colspan=1>MNLI</td><td rowspan=1 colspan=1>SST-2</td><td rowspan=1 colspan=1>QQP</td><td rowspan=1 colspan=1>QNLI</td><td rowspan=1 colspan=1>Avg.</td><td rowspan=1 colspan=1>Trained params</td></tr><tr><td rowspan=1 colspan=1>Full</td><td rowspan=1 colspan=1>w/o DP</td><td rowspan=1 colspan=1>90.2</td><td rowspan=1 colspan=1>96.4</td><td rowspan=1 colspan=1>92.2</td><td rowspan=1 colspan=1>94.7</td><td rowspan=1 colspan=1>93.4</td><td rowspan=1 colspan=1>100%</td></tr><tr><td rowspan=1 colspan=1>LoRA</td><td rowspan=1 colspan=1>w/o DP</td><td rowspan=1 colspan=1>90.6</td><td rowspan=1 colspan=1>96.2</td><td rowspan=1 colspan=1>91.6</td><td rowspan=1 colspan=1>94.9</td><td rowspan=1 colspan=1>93.3</td><td rowspan=1 colspan=1>0.23%</td></tr><tr><td rowspan=1 colspan=1>RGP</td><td rowspan=1 colspan=1>DP</td><td rowspan=1 colspan=1>86.1</td><td rowspan=1 colspan=1>93.0</td><td rowspan=1 colspan=1>86.7</td><td rowspan=1 colspan=1>90.0</td><td rowspan=1 colspan=1>88.9</td><td rowspan=1 colspan=1>100%</td></tr><tr><td rowspan=1 colspan=1>Adapter</td><td rowspan=1 colspan=1>DP</td><td rowspan=1 colspan=1>87.7</td><td rowspan=1 colspan=1>93.9</td><td rowspan=1 colspan=1>86.3</td><td rowspan=1 colspan=1>90.7</td><td rowspan=1 colspan=1>89.7</td><td rowspan=1 colspan=1>1.4% (r = 48)</td></tr><tr><td rowspan=1 colspan=1>Compacter</td><td rowspan=1 colspan=1>DP</td><td rowspan=1 colspan=1>87.5</td><td rowspan=1 colspan=1>94.2</td><td rowspan=1 colspan=1>86.2</td><td rowspan=1 colspan=1>90.2</td><td rowspan=1 colspan=1>89.5</td><td rowspan=1 colspan=1>0.053% (r =96,n = 8)</td></tr><tr><td rowspan=1 colspan=1>LoRA</td><td rowspan=1 colspan=1>DP</td><td rowspan=1 colspan=1>87.8</td><td rowspan=1 colspan=1>95.3</td><td rowspan=1 colspan=1>87.4</td><td rowspan=1 colspan=1>90.8</td><td rowspan=1 colspan=1>90.3</td><td rowspan=1 colspan=1>0.94% (r =16)</td></tr></table>
|
| 171 |
+
|
| 172 |
+
Results: We report the prediction accuracy in Tables 3 and 4. Our experiments using RoBERTaBase serve as a direct comparison to Yu et al. (2021b) who only trained the base model, whereas RoBERTa-Large experiments demonstrate the significance of using larger models. Our key findings are: (1) On all datasets, our methods achieve the best accuracy while training a tiny fraction of parameters; larger models give significant improvements. (2) Noticeable improvements in $\varepsilon$ versus Yu et al. (2021b) are primarily due to new privacy accountants based on Fourier-based numerical composition (Koskela et al., 2020; 2021; Gopi et al., 2021); we use the accountant in Gopi et al. (2021) since it is the most efficient. (3) Private adapters provide the best average performance for RoBERTa-Base, whereas LoRA outperforms all other methods for RoBERTa-Large.
|
| 173 |
+
|
| 174 |
+
Remark: While our experiments indicate that full fine-tuning does not achieve competitive performance, there could be a choice of hyperparameters that improves upon the reported numbers, e.g., “mega” batch sizes (in the millions) in Anil et al. (2021). We note that our main message is that one does not need to fine-tune all parameters to achieve the best accuracy. Nevertheless, it is interesting to wonder if full fine-tuning with DPSGD can match the accuracy of parameter-efficient methods. A positive answer would imply that private and non-private fine-tuning conceptually mirror each other.
|
| 175 |
+
|
| 176 |
+
Update: A concurrent work by Li et al (Li et al., 2022) show that using a larger batch size and training with full-precision improves the performance of full fine-tuning via DPSGD, and obtains similar performance as our algorithms. Thus, poor performance of DPSGD in our experiments is due to the suboptimal choice of hyperparameters and also due to precision issues, although we use same hyperparameters for all the algorithms. We run new experiments with hyperparameters of (Li et al., 2022) in full precision mode, and get improvements around $1 \%$ even for our algorithms. We report these findings in Appendix C.
|
| 177 |
+
|
| 178 |
+
# 4.2 FINE-TUNING FOR NATURAL LANGUAGE GENERATION (NLG)
|
| 179 |
+
|
| 180 |
+
Next, we study private fine-tuning for text generation problems using the GPT-2 series of models on the End-2-End (E2E) NLG challenge (Novikova et al., 2017), one of the primary benchmarks used in recent works on non-private fine-tuning (Hu et al., 2021; Li & Liang, 2021). We use GPT-2-Small (117M parameters), GPT-2-Medium (345M parameters), and GPT-2-Large (774M parameters).4 To the best of our knowledge, we are the first to privately fine-tune for E2E or fine-tune GPT-2-Large. The purpose of this section is not to evaluate various fine-tuning algorithms, but to show that private fine-tuning is competitive with non-private fine-tuning for text generation problems. Due to the high cost of training, we report experimental results only for fine-tuning with LoRA.
|
| 181 |
+
|
| 182 |
+
In Appendix F, we present additional experiments on NLG that include private fine-tuning of the GPT-2-XL model with 1.5 billion parameters. Other noticeable points in the additional experiments include 1) we show improved performance using better hyperparameters; 2) we test different privacy parameters; 3) we consider a new dataset DART (Nan et al., 2021).
|
| 183 |
+
|
| 184 |
+
Table 5: Metrics on the E2E NLG task $\mathit { \check { \Psi } } \varepsilon = 5 . 4 , \delta = 1 { \mathrm { e } } . 5 )$ . Non-DP results from Hu et al. (2021).
|
| 185 |
+
|
| 186 |
+
<table><tr><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>BLEU</td><td rowspan=1 colspan=1>NIST</td><td rowspan=1 colspan=1>MET</td><td rowspan=1 colspan=1>ROUGE-L</td><td rowspan=1 colspan=1>CIDEr</td></tr><tr><td rowspan=1 colspan=1>GPT-2-Small +DP</td><td rowspan=1 colspan=1>59.26</td><td rowspan=1 colspan=1>6.13</td><td rowspan=1 colspan=1>36.6</td><td rowspan=1 colspan=1>64.1</td><td rowspan=1 colspan=1>1.63</td></tr><tr><td rowspan=1 colspan=1>GPT-2-Medium+DP</td><td rowspan=1 colspan=1>64.2</td><td rowspan=1 colspan=1>7.77</td><td rowspan=1 colspan=1>40.02</td><td rowspan=1 colspan=1>66.45</td><td rowspan=1 colspan=1>2.00</td></tr><tr><td rowspan=1 colspan=1>GPT-2-Large + DP</td><td rowspan=1 colspan=1>64.51</td><td rowspan=1 colspan=1>8.22</td><td rowspan=1 colspan=1>41.5</td><td rowspan=1 colspan=1>67.55</td><td rowspan=1 colspan=1>2.13</td></tr><tr><td rowspan=1 colspan=1>GPT-2-Medium</td><td rowspan=1 colspan=1>70.4</td><td rowspan=1 colspan=1>8.85</td><td rowspan=1 colspan=1>46.8</td><td rowspan=1 colspan=1>71.8</td><td rowspan=1 colspan=1>2.53</td></tr><tr><td rowspan=1 colspan=1>GPT-2-Large</td><td rowspan=1 colspan=1>70.4</td><td rowspan=1 colspan=1>8.89</td><td rowspan=1 colspan=1>46.8</td><td rowspan=1 colspan=1>72.0</td><td rowspan=1 colspan=1>2.47</td></tr></table>
|
| 187 |
+
|
| 188 |
+
E2E NLG challenge: The E2E dataset in Novikova et al. (2017) contains template-like information in the restaurant domain to be mapped to natural language with end-to-end training. The dataset consists of 42K training samples, 4.6K validation samples, and 4.6K test samples. We use standard metrics such as BLUE, ROUGE-L, etc., used in (Hu et al., 2021) for evaluation.
|
| 189 |
+
|
| 190 |
+
Hyperparameter choice: For LoRA, we choose the bottleneck rank $r = 4$ in (4) and fine-tune $W _ { q }$ and $W _ { v }$ matrices of the attention layers as in the original paper. We optimize using AdamW with learning rate 2e-4, weight decay 1e-2 and train our models for 5 epochs using batch size 64. We take the gradient clipping parameter to be 1.0 and set the noise multiplier as 0.5.
|
| 191 |
+
|
| 192 |
+
Results: The results of our experiments are summarized in the Table 5, which reiterate the main themes of this paper: private fine-tuning with a parameter-efficient approach performs close to their non-private counterparts and show consistent improvement in the utility as the model size increases.
|
| 193 |
+
|
| 194 |
+
# 5 RELATED WORK
|
| 195 |
+
|
| 196 |
+
Some work studies private language models on more traditional architectures such as LSTMs (Hochreiter & Schmidhuber, 1997), either training with DPSGD (McMahan et al., 2018; Carlini et al., 2019) or related heuristics (Ramaswamy et al., 2020). Though pre-training on public data is suggested (McMahan et al., 2018), public data appears to only be used in one of these works for honest hyperparameter selection (Ramaswamy et al., 2020). A few more recent works consider training LLMs with DP. Anil et al. (2021) privately train BERT-Large from scratch, compared to our work which focuses on private fine-tuning. (Hoory et al., 2021; Basu et al., 2021) perform private full fine-tuning of BERT models. Hoory et al. (2021) achieve accuracy which is comparable to the non-private model, but additionally supplement the public pre-training data with additional domain-relevant material, while we use off-the-shelf pre-trained models. Basu et al. (2021) observe significant drops in utility, compared to our parameter-efficient methods which do not. While Kerrigan et al. (2020) consider public pre-training and private fine-tuning, their experiments are on much smaller architectures (i.e., feedforward networks with three hidden layers). A simultaneous work of Ginart et al. (2022) investigates private prediction (rather than learning) for next-token prediction. A subsequent work by Senge et al. (2021) also investigates the effect of private fine-tuning on various NLP tasks.
|
| 197 |
+
|
| 198 |
+
In a concurrent work, Li et al. (2022) also investigate DP fine-tuning of LLMs. In several cases, their results demonstrate qualitatively similar findings as ours. While our experiments focus primarily on parameter-efficient fine-tuning methods, interestingly, they show that private full fine-tuning can also achieve comparable utility if the experimental setup is configured properly, e.g., using suitable hyperparameters. In Appendix C, we run experiments under the setup in Li et al. (2022). We show their setup can also improve the performance of our methods.
|
| 199 |
+
|
| 200 |
+
# 6 CONCLUSION
|
| 201 |
+
|
| 202 |
+
So far, DP deep learning has focused on training models from scratch. The spectacular success of transfer learning in real-world applications, however, shows that private fine-tuning is an equally pertinent problem to study and deserves more attention. We show that by combining recent advances in NLP, parameter-efficiency, privacy accounting, and using larger models, one can privately fine-tune models whose utility approaches that of non-private models. We hope our work inspires more study on the core problem of private fine-tuning, which we believe to be a central direction for research in private machine learning, leading to more interaction between the LLM and DP communities.
|
| 203 |
+
|
| 204 |
+
# ACKNOWLEDGMENTS
|
| 205 |
+
|
| 206 |
+
The authors would like to thank Rabeeh Karimi Mahabadi for sharing hyperparameters based on experiments in Mahabadi et al. (2021). Janardhan Kulkarni would like to thank Edward Hu for sharing many ideas on fine-tuning. Gautam Kamath is supported by an NSERC Discovery Grant.
|
| 207 |
+
|
| 208 |
+
# REFERENCES
|
| 209 |
+
|
| 210 |
+
Martin Abadi, Andy Chu, Ian Goodfellow, H Brendan McMahan, Ilya Mironov, Kunal Talwar, and Li Zhang. Deep learning with differential privacy. In Proceedings of the 2016 ACM Conference on Computer and Communications Security, CCS ’16, pp. 308–318, New York, NY, USA, 2016. ACM.
|
| 211 |
+
|
| 212 |
+
Armen Aghajanyan, Luke Zettlemoyer, and Sonal Gupta. Intrinsic dimensionality explains the effectiveness of language model fine-tuning. arXiv preprint arXiv:2012.13255, 2020.
|
| 213 |
+
|
| 214 |
+
Noga Alon, Raef Bassily, and Shay Moran. Limits of private learning with access to public data. In Advances in Neural Information Processing Systems 32, NeurIPS ’19, pp. 10342–10352. Curran Associates, Inc., 2019.
|
| 215 |
+
|
| 216 |
+
Ehsan Amid, Arun Ganesh, Rajiv Mathews, Swaroop Ramaswamy, Shuang Song, Thomas Steinke, Vinith M Suriyakumar, Om Thakkar, and Abhradeep Thakurta. Public data-assisted mirror descent for private model training. arXiv preprint arXiv:2112.00193, 2021.
|
| 217 |
+
|
| 218 |
+
Rohan Anil, Badih Ghazi, Vineet Gupta, Ravi Kumar, and Pasin Manurangsi. Large-scale differentially private BERT. arXiv preprint arXiv:2108.01624, 2021.
|
| 219 |
+
|
| 220 |
+
Raef Bassily, Adam Smith, and Abhradeep Thakurta. Private empirical risk minimization: Efficient algorithms and tight error bounds. In Proceedings of the 55th Annual IEEE Symposium on Foundations of Computer Science, FOCS ’14, pp. 464–473, Washington, DC, USA, 2014. IEEE Computer Society.
|
| 221 |
+
|
| 222 |
+
Raef Bassily, Om Thakkar, and Abhradeep Guha Thakurta. Model-agnostic private learning. In Advances in Neural Information Processing Systems 31, NeurIPS ’18, pp. 7102–7112. Curran Associates, Inc., 2018.
|
| 223 |
+
|
| 224 |
+
Raef Bassily, Albert Cheu, Shay Moran, Aleksandar Nikolov, Jonathan Ullman, and Steven Wu. Private query release assisted by public data. In Proceedings of the 37th International Conference on Machine Learning, ICML ’20, pp. 695–703. JMLR, Inc., 2020a.
|
| 225 |
+
|
| 226 |
+
Raef Bassily, Shay Moran, and Anupama Nandi. Learning from mixtures of private and public populations. In Advances in Neural Information Processing Systems 33, NeurIPS ’20, pp. 2947– 2957. Curran Associates, Inc., 2020b.
|
| 227 |
+
|
| 228 |
+
Priyam Basu, Tiasa Singha Roy, Rakshit Naidu, Zumrut Muftuoglu, Sahib Singh, and Fatemehsadat Mireshghallah. Benchmarking differential privacy and federated learning for BERT models. arXiv preprint arXiv:2106.13973, 2021.
|
| 229 |
+
|
| 230 |
+
Amos Beimel, Kobbi Nissim, and Uri Stemmer. Private learning and sanitization: Pure vs. approximate differential privacy. Theory of Computing, 12(1):1–61, 2016.
|
| 231 |
+
|
| 232 |
+
Elad Ben Zaken, Shauli Ravfogel, and Yoav Goldberg. Bitfit: Simple parameter-efficient fine-tuning for transformer-based masked language-models. arXiv preprint arXiv:, 2021.
|
| 233 |
+
|
| 234 |
+
Gavin Brown, Mark Bun, Vitaly Feldman, Adam Smith, and Kunal Talwar. When is memorization of irrelevant training data necessary for high-accuracy learning? In Proceedings of the 53nd Annual ACM Symposium on the Theory of Computing, STOC ’21, pp. 123–132, New York, NY, USA, 2021. ACM.
|
| 235 |
+
|
| 236 |
+
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.
|
| 237 |
+
|
| 238 |
+
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 Advances in Neural Information Processing Systems 33, NeurIPS ’20. Curran Associates, Inc., 2020.
|
| 239 |
+
|
| 240 |
+
Mark Bun, Jonathan Ullman, and Salil Vadhan. Fingerprinting codes and the price of approximate differential privacy. In Proceedings of the 46th Annual ACM Symposium on the Theory of Computing, STOC ’14, pp. 1–10, New York, NY, USA, 2014. ACM.
|
| 241 |
+
|
| 242 |
+
Han Cai, Chuang Gan, Ligeng Zhu, and Song Han. TinyTL: Reduce memory, not parameters for efficient on-device learning. In Advances in Neural Information Processing Systems 33, NeurIPS ’20, pp. 11285–11297. Curran Associates, Inc., 2020.
|
| 243 |
+
|
| 244 |
+
Nicholas Carlini, Chang Liu, Ulfar Erlingsson, Jernej Kos, and Dawn Song. The secret sharer: ´ Evaluating and testing unintended memorization in neural networks. In 28th USENIX Security Symposium, USENIX Security ’19, pp. 267–284. USENIX Association, 2019.
|
| 245 |
+
|
| 246 |
+
Nicholas Carlini, Florian Tramer, Eric Wallace, Matthew Jagielski, Ariel Herbert-Voss, Katherine \` Lee, Adam Roberts, Tom Brown, Dawn Song, Ulfar Erlingsson, Alina Oprea, and Colin Raffel. Extracting training data from large language models. In 30th USENIX Security Symposium, USENIX Security ’21, pp. 2633–2650. USENIX Association, 2021.
|
| 247 |
+
|
| 248 |
+
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), NAACL-HLT ’19, pp. 4171–4186, 2019.
|
| 249 |
+
|
| 250 |
+
Cynthia Dwork, Krishnaram Kenthapadi, Frank McSherry, Ilya Mironov, and Moni Naor. Our data, ourselves: Privacy via distributed noise generation. In Proceedings of the 24th Annual International Conference on the Theory and Applications of Cryptographic Techniques, EUROCRYPT ’06, pp. 486–503, Berlin, Heidelberg, 2006a. Springer.
|
| 251 |
+
|
| 252 |
+
Cynthia Dwork, Frank McSherry, Kobbi Nissim, and Adam Smith. Calibrating noise to sensitivity in private data analysis. In Proceedings of the 3rd Conference on Theory of Cryptography, TCC ’06, pp. 265–284, Berlin, Heidelberg, 2006b. Springer.
|
| 253 |
+
|
| 254 |
+
Vitaly Feldman. Does learning require memorization? a short tale about a long tail. In Proceedings of the 52nd Annual ACM Symposium on the Theory of Computing, STOC ’20, pp. 954–959, New York, NY, USA, 2020. ACM.
|
| 255 |
+
|
| 256 |
+
Antonio Ginart, Laurens van der Maaten, James Zou, and Chuan Guo. Submix: Practical private prediction for large-scale language models. arXiv preprint arXiv:2201.00971, 2022.
|
| 257 |
+
|
| 258 |
+
Sivakanth Gopi, Yin Tat Lee, and Lukas Wutschitz. Numerical composition of differential privacy. arXiv preprint arXiv:2106.02848, 2021.
|
| 259 |
+
|
| 260 |
+
Dan Hendrycks and Kevin Gimpel. Gaussian error linear units (gelus). arXiv preprint arXiv:1606.08415, 2016.
|
| 261 |
+
|
| 262 |
+
Sepp Hochreiter and Jurgen Schmidhuber. Long short-term memory. ¨ Neural Computation, 9(8): 1735–1780, 1997.
|
| 263 |
+
|
| 264 |
+
Shlomo Hoory, Amir Feder, Avichai Tendler, Alon Cohen, Sofia Erell, Itay Laish, Hootan Nakhost, Uri Stemmer, Ayelet Benjamini, Avinatan Hassidim, and Yossi Matias. Learning and evaluating a differentially private pre-trained language model. In Proceedings of the Third Workshop on Privacy in Natural Language Processing, PrivateNLP ’21, pp. 21–29, 2021.
|
| 265 |
+
|
| 266 |
+
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, pp. 2790–2799. PMLR, 2019.
|
| 267 |
+
|
| 268 |
+
Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, and Weizhu Chen. Lora: Low-rank adaptation of large language models. arXiv preprint arXiv:2106.09685, 2021.
|
| 269 |
+
|
| 270 |
+
Zhanglong Ji and Charles Elkan. Differential privacy based on importance weighting. Machine Learning, 93(1):163–183, 2013.
|
| 271 |
+
|
| 272 |
+
Peter Kairouz, Monica Ribero, Keith Rush, and Abhradeep Thakurta. (nearly) dimension indepen- ´ dent private ERM with adagrad rates via publicly estimated subspaces. In Proceedings of the 34th Annual Conference on Learning Theory, COLT ’21, pp. 2717–2746, 2021.
|
| 273 |
+
|
| 274 |
+
Gavin Kerrigan, Dylan Slack, and Jens Tuyls. Differentially private language models benefit from public pre-training. arXiv preprint arXiv:2009.05886, 2020.
|
| 275 |
+
|
| 276 |
+
Antti Koskela, Joonas Jalk ¨ o, and Antti Honkela. Computing tight differential privacy guarantees ¨ using fft. In International Conference on Artificial Intelligence and Statistics, pp. 2560–2569. PMLR, 2020.
|
| 277 |
+
|
| 278 |
+
Antti Koskela, Joonas Jalk ¨ o, Lukas Prediger, and Antti Honkela. Tight differential privacy for ¨ discrete-valued mechanisms and for the subsampled gaussian mechanism using fft. In International Conference on Artificial Intelligence and Statistics, pp. 3358–3366. PMLR, 2021.
|
| 279 |
+
|
| 280 |
+
Brian Lester, Rami Al-Rfou, and Noah Constant. The power of scale for parameter-efficient prompt tuning. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing (EMNLP), EMNLP ’21. Association for Computational Linguistics, 2021.
|
| 281 |
+
|
| 282 |
+
Chunyuan Li, Heerad Farkhoor, Rosanne Liu, and Jason Yosinski. Measuring the intrinsic dimension of objective landscapes. In Proceedings of the 6th International Conference on Learning Representations, ICLR ’18, 2018.
|
| 283 |
+
|
| 284 |
+
Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. 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), ACL-IJCNLP ’21, pp. 4582–4597, 2021.
|
| 285 |
+
|
| 286 |
+
Xuechen Li, Florian Tramer, Percy Liang, and Tatsunori Hashimoto. Large language models can \` be strong differentially private learners. In Proceedings of the 10th International Conference on Learning Representations, ICLR ’22, 2022.
|
| 287 |
+
|
| 288 |
+
Terrance Liu, Giuseppe Vietri, Thomas Steinke, Jonathan Ullman, and Steven Wu. Leveraging public data for practical private query release. In Proceedings of the 38th International Conference on Machine Learning, ICML ’21, pp. 6968–6977. JMLR, Inc., 2021.
|
| 289 |
+
|
| 290 |
+
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.
|
| 291 |
+
|
| 292 |
+
Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In Proceedings of the 7th International Conference on Learning Representations, ICLR ’19, 2019.
|
| 293 |
+
|
| 294 |
+
Zelun Luo, Daniel J Wu, Ehsan Adeli, and Li Fei-Fei. Scalable differential privacy with sparse network finetuning. In Proceedings of the 2021 IEEE Computer Society Conference on Computer Vision and Pattern Recognition, CVPR ’21, pp. 5059–5068, Washington, DC, USA, 2021. IEEE Computer Society.
|
| 295 |
+
|
| 296 |
+
Rabeeh Karimi Mahabadi, James Henderson, and Sebastian Ruder. Compacter: Efficient low-rank hypercomplex adapter layers. arXiv preprint arXiv:2106.04647, 2021.
|
| 297 |
+
|
| 298 |
+
H Brendan McMahan, Daniel Ramage, Kunal Talwar, and Li Zhang. Learning differentially private recurrent language models. In Proceedings of the 6th International Conference on Learning Representations, ICLR ’18, 2018.
|
| 299 |
+
|
| 300 |
+
Paulius Micikevicius, Sharan Narang, Jonah Alben, Gregory Diamos, Erich Elsen, David Garcia, Boris Ginsburg, Michael Houston, Oleksii Kuchaiev, Ganesh Venkatesh, et al. Mixed precision training. arXiv preprint arXiv:1710.03740, 2017.
|
| 301 |
+
|
| 302 |
+
Linyong Nan, Dragomir Radev, Rui Zhang, Amrit Rau, Abhinand Sivaprasad, Chiachun Hsieh, Xiangru Tang, Aadit Vyas, Neha Verma, Pranav Krishna, Yangxiaokang Liu, Nadia Irwanto, Jessica Pan, Faiaz Rahman, Ahmad Zaidi, Mutethia Mutuma, Yasin Tarabar, Ankit Gupta, Tao Yu, Yi Chern Tan, Xi Victoria Lin, Caiming Xiong, Richard Socher, and Nazneen Fatema Rajani. DART: open-domain structured data record to text generation. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, NAACL-HLT ’21, pp. 432–447. Association for Computational Linguistics, 2021.
|
| 303 |
+
|
| 304 |
+
Anupama Nandi and Raef Bassily. Privately answering classification queries in the agnostic PAC model. In Proceedings of the 31st International Conference on Algorithmic Learning Theory, ALT ’20, pp. 687–703. JMLR, Inc., 2020.
|
| 305 |
+
|
| 306 |
+
Jekaterina Novikova, Ondˇrej Dusek, and Verena Rieser. The E2E dataset: New challenges for ˇ end-to-end generation. In Proceedings of the 18th Annual SIGdial Meeting on Discourse and Dialogue, SIGDIAL ’17, pp. 201–206. Association for Computational Linguistics, 2017.
|
| 307 |
+
|
| 308 |
+
Myle Ott, Sergey Edunov, David Grangier, and Michael Auli. Scaling neural machine translation. In Proceedings of the Third Conference on Machine Translation (WMT), 2018.
|
| 309 |
+
|
| 310 |
+
Nicolas Papernot, Mart´ın Abadi, Ulfar Erlingsson, Ian Goodfellow, and Kunal Talwar. Semisupervised knowledge transfer for deep learning from private training data. In Proceedings of the 5th International Conference on Learning Representations, ICLR ’17, 2017.
|
| 311 |
+
|
| 312 |
+
Nicolas Papernot, Shuang Song, Ilya Mironov, Ananth Raghunathan, Kunal Talwar, and Ulfar Er- ´ lingsson. Scalable private learning with PATE. In Proceedings of the 6th International Conference on Learning Representations, ICLR ’18, 2018.
|
| 313 |
+
|
| 314 |
+
Nicolas Papernot, Steve Chien, Shuang Song, Abhradeep Thakurta, and Ulfar Erlingsson. Making the shoe fit: Architectures, initializations, and tuning for learning with privacy. https:// openreview.net/forum?id $=$ rJg851rYwH, 2019.
|
| 315 |
+
|
| 316 |
+
Jonas Pfeiffer, Aishwarya Kamath, Andreas Ruckl ¨ e, Kyunghyun Cho, and Iryna Gurevych. Adapter- ´ fusion: Non-destructive task composition for transfer learning. In Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: Main Volume, EACL ’21, pp. 487–503. Association for Computational Linguistics, 2021.
|
| 317 |
+
|
| 318 |
+
Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving language understanding by generative pre-training, 2018.
|
| 319 |
+
|
| 320 |
+
Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners, 2019.
|
| 321 |
+
|
| 322 |
+
Swaroop Ramaswamy, Om Thakkar, Rajiv Mathews, Galen Andrew, H Brendan McMahan, and Franc¸oise Beaufays. Training production language models without memorizing user data. arXiv preprint arXiv:2009.10031, 2020.
|
| 323 |
+
|
| 324 |
+
Andreas Ruckl ¨ e, Gregor Geigle, Max Glockner, Tilman Beck, Jonas Pfeiffer, Nils Reimers, and ´ Iryna Gurevych. Adapterdrop: On the efficiency of adapters in transformers. arXiv preprint arXiv:2010.11918, 2020.
|
| 325 |
+
|
| 326 |
+
Manuel Senge, Timour Igamberdiev, and Ivan Habernal. One size does not fit all: Investigating strategies for differentially-private learning across nlp tasks. arXiv preprint arXiv:2112.08159, 2021.
|
| 327 |
+
|
| 328 |
+
Reza Shokri, Marco Stronati, Congzheng Song, and Vitaly Shmatikov. Membership inference attacks against machine learning models. In Proceedings of the 38th IEEE Symposium on Security and Privacy, SP ’17, pp. 3–18, Washington, DC, USA, 2017. IEEE Computer Society.
|
| 329 |
+
|
| 330 |
+
Shuang Song, Kamalika Chaudhuri, and Anand D Sarwate. Stochastic gradient descent with differentially private updates. In Proceedings of the 2013 IEEE Global Conference on Signal and Information Processing, GlobalSIP ’13, pp. 245–248, Washington, DC, USA, 2013. IEEE Computer Society.
|
| 331 |
+
|
| 332 |
+
Pranav Subramani, Nicholas Vadivelu, and Gautam Kamath. Enabling fast differentially private sgd via just-in-time compilation and vectorization. In Advances in Neural Information Processing Systems 34, NeurIPS ’21. Curran Associates, Inc., 2021.
|
| 333 |
+
|
| 334 |
+
Zhiliang Tian, Yingxiu Zhao, Ziyue Huang, Yu-Xiang Wang, Nevin Zhang, and He He. SeqPATE: Differentially private text generation via knowledge distillation, 2022. URL https: //openreview.net/forum?id $^ { = 5 }$ sP_PUUS78v.
|
| 335 |
+
|
| 336 |
+
Florian Tramer and Dan Boneh. Differentially private learning needs better features (or much more \` data). In Proceedings of the 9th International Conference on Learning Representations, ICLR ’21, 2021.
|
| 337 |
+
|
| 338 |
+
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 30, NIPS ’17, pp. 5998–6008. Curran Associates, Inc., 2017.
|
| 339 |
+
|
| 340 |
+
Alex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R Bowman. Glue: A multi-task benchmark and analysis platform for natural language understanding. In International Conference on Learning Representations, 2018.
|
| 341 |
+
|
| 342 |
+
Adina Williams, Nikita Nangia, and Samuel Bowman. A broad-coverage challenge corpus for sentence understanding through inference. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), NAACL-HLT ’18, pp. 1112–1122. Association for Computational Linguistics, 2018.
|
| 343 |
+
|
| 344 |
+
Da Yu, Huishuai Zhang, Wei Chen, and Tie-Yan Liu. Do not let privacy overbill utility: Gradient embedding perturbation for private learning. In Proceedings of the 9th International Conference on Learning Representations, ICLR ’21, 2021a.
|
| 345 |
+
|
| 346 |
+
Da Yu, Huishuai Zhang, Wei Chen, Jian Yin, and Tie-Yan Liu. Large scale private learning via low-rank reparametrization. In Proceedings of the 38th International Conference on Machine Learning, ICML ’21. JMLR, Inc., 2021b.
|
| 347 |
+
|
| 348 |
+
Yingxue Zhou, Zhiwei Steven Wu, and Arindam Banerjee. Bypassing the ambient dimension: Private SGD with gradient subspace identification. In Proceedings of the 9th International Conference on Learning Representations, ICLR ’21, 2021.
|
| 349 |
+
|
| 350 |
+
Table 6: Test accuracy for fine-tuning RoBERTa-Large with different privacy parameters. The number of training samples is denoted by $n$ . The values of $\sigma$ are noise multipliers. Numbers in the brackets are the changes compared to the results in Table 4 $\varepsilon = 6 . 7$ , $\delta = \Theta ( 1 / n ) ,$ ).
|
| 351 |
+
|
| 352 |
+
<table><tr><td rowspan=1 colspan=1>Taks</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>δ=1/n</td><td rowspan=1 colspan=1>δ=1/10n</td><td rowspan=1 colspan=1>δ=1/100n</td><td rowspan=1 colspan=1>δ=1/1000n</td><td rowspan=1 colspan=1>Accuracy (in %)</td></tr><tr><td rowspan=1 colspan=1>MNLI</td><td rowspan=1 colspan=1>1.88</td><td rowspan=1 colspan=1>ε=1</td><td rowspan=1 colspan=1>ε = 1.35</td><td rowspan=1 colspan=1>ε=1.49</td><td rowspan=1 colspan=1>ε = 1.61</td><td rowspan=1 colspan=1>86.8 (-1.0%)</td></tr><tr><td rowspan=1 colspan=1>QQP</td><td rowspan=1 colspan=1>1.88</td><td rowspan=1 colspan=1>ε=1</td><td rowspan=1 colspan=1>ε = 1.40</td><td rowspan=1 colspan=1>ε= 1.54</td><td rowspan=1 colspan=1>ε = 1.67</td><td rowspan=1 colspan=1>85.2 (-2.2%)</td></tr><tr><td rowspan=1 colspan=1>QNLI</td><td rowspan=1 colspan=1>3.01</td><td rowspan=1 colspan=1>ε=1</td><td rowspan=1 colspan=1>ε= 1.48</td><td rowspan=1 colspan=1>ε = 1.64</td><td rowspan=1 colspan=1>ε = 1.79</td><td rowspan=1 colspan=1>88.0 (-2.8%)</td></tr><tr><td rowspan=1 colspan=1>SST-2</td><td rowspan=1 colspan=1>3.63</td><td rowspan=1 colspan=1>ε=1</td><td rowspan=1 colspan=1>ε = 1.47</td><td rowspan=1 colspan=1>ε= 1.64</td><td rowspan=1 colspan=1>ε= 1.80</td><td rowspan=1 colspan=1>93.1 (-2.2%)</td></tr><tr><td rowspan=1 colspan=1>MNLI</td><td rowspan=1 colspan=1>0.91</td><td rowspan=1 colspan=1>e=3</td><td rowspan=1 colspan=1>ε = 4.12</td><td rowspan=1 colspan=1>ε= 4.51</td><td rowspan=1 colspan=1> = 4.89</td><td rowspan=1 colspan=1>87.4 (-0.4%)</td></tr><tr><td rowspan=1 colspan=1>QQP</td><td rowspan=1 colspan=1>0.93</td><td rowspan=1 colspan=1>ε=3</td><td rowspan=1 colspan=1>ε= 4.10</td><td rowspan=1 colspan=1>= 4.49</td><td rowspan=1 colspan=1>ε= 4.86</td><td rowspan=1 colspan=1>86.8 (-0.6%)</td></tr><tr><td rowspan=1 colspan=1>QNLI</td><td rowspan=1 colspan=1>1.29</td><td rowspan=1 colspan=1>ε=3</td><td rowspan=1 colspan=1>ε = 4.45</td><td rowspan=1 colspan=1>£= 4.90</td><td rowspan=1 colspan=1>ε = 5.33</td><td rowspan=1 colspan=1>89.9 (-0.9%)</td></tr><tr><td rowspan=1 colspan=1>SST-2</td><td rowspan=1 colspan=1>1.52</td><td rowspan=1 colspan=1>ε=3</td><td rowspan=1 colspan=1>ε = 4.37</td><td rowspan=1 colspan=1>= 4.83</td><td rowspan=1 colspan=1>e = 5.25</td><td rowspan=1 colspan=1>94.1 (-1.2%)</td></tr></table>
|
| 353 |
+
|
| 354 |
+
# A ADDITIONAL RELATED WORK
|
| 355 |
+
|
| 356 |
+
There exist other parameter-efficient tuning methods which we did not evaluate in our work. Some of these include random subspace projection (exploiting intrinsic dimensionality (Li et al., 2018; Aghajanyan et al., 2020)), prefix and prompt tuning (Li & Liang, 2021; Lester et al., 2021), tuning only biases (Cai et al., 2020; Ben Zaken et al., 2021), and other architecture variants including Adapters (Pfeiffer et al., 2021; Ruckl ¨ e et al. ´ , 2020). An interesting direction for future work is to see whether parameter-efficient tuning approaches specifically designed for the private setting can achieve higher utility. We also mention zero-shot learning, in which no task-specific dataset is required and thus perfect privacy is achieved. Currently, zero-shot approaches achieve low utility compared to fine-tuning, though it is possible that future models may narrow this gap.
|
| 357 |
+
|
| 358 |
+
Finally, our investigation fits more broadly into a line of work employing public data for private data analysis. Some works on image classification consider pre-training on a large public dataset and fine-tuning on a smaller private dataset (Abadi et al., 2016; Papernot et al., 2019; Tramer & \` Boneh, 2021; Luo et al., 2021). In particular, Luo et al. (2021) investigate the role of parameter efficiency in private fine-tuning ResNet models, and propose strategies to choose which parameters to fine-tune. One line of work uses unlabeled public data to train a student model (Papernot et al., 2017; 2018; Bassily et al., 2018), including one work simultaneous to our own for natural language generation Tian et al. (2022). Another recent idea uses a small amount of public data to identify a lower-dimensional subspace of the gradients in which to perform private descent (Zhou et al., 2021; Yu et al., 2021a; Kairouz et al., 2021). A simultaneous work of Amid et al. (2021) uses public data in the mirror map for a private mirror descent algorithm. Finally, other works (both theoretical and experimental) investigate the role of public data in private query release, synthetic data generation, and prediction (Ji & Elkan, 2013; Beimel et al., 2016; Alon et al., 2019; Nandi & Bassily, 2020; Bassily et al., 2020a;b; Liu et al., 2021).
|
| 359 |
+
|
| 360 |
+
# B EXPERIMENTS WITH DIFFERENT PRIVACY PARAMETERS
|
| 361 |
+
|
| 362 |
+
Now we test our framework under different privacy constraints. Specifically, we run LoRA on the language understanding tasks with various choices of privacy parameters $\varepsilon$ and $\delta$ . We consider both RoBERTa-Base and RoBERTa-Large.
|
| 363 |
+
|
| 364 |
+
For the RoBERTa-Large model, we set $\varepsilon = 1$ and 3 with $\delta$ being the same as those in Section 4. We use the PRV accountant (Gopi et al., 2021). After getting the noise multipliers, we also reduce the value of $\delta$ and report the corresponding value of $\varepsilon$ . The hyperparameters are the same as those in Section 4. We run experiments on all four tasks, i.e., MNLI $( n \sim 3 9 2 \mathrm { k } )$ ), QQP $( n \sim 3 6 4 \mathrm { k } )$ , QNLI $( n \sim 1 0 4 \mathrm { k } )$ , and SST-2 $( n \sim 6 7 \mathrm { k } )$ . We report the results in Table 6. The performance of our framework is decent even with very tight privacy budgets. For instance, with $\varepsilon \ < \ 2$ and $\delta = 1 / 1 0 0 0 n$ , the accuracy gap between the non-private baseline is only 3.8 for MNLI and 2.1 for SST-2.
|
| 365 |
+
|
| 366 |
+

|
| 367 |
+
Figure 2: Test accuracy (in $\%$ ) of fine-tuning the RoBERTa-Base model on MNLI and SST-2 with various choices of $\varepsilon$ .
|
| 368 |
+
|
| 369 |
+
Table 7: Accuracy for fine-tuning downstream tasks with RoBERTa-Base $( \mathrm { i n } \ \% )$ ). Experiments are run with full-precision. We also scale up the batch size according to the dataset size compared to SST-2. The privacy parameters are $\varepsilon = 6 . 7$ , and $\delta = 1 \mathrm { e } { - } 5$ for SST-2 and QNLI and 1e-6 for MNLI and QQP.
|
| 370 |
+
|
| 371 |
+
<table><tr><td rowspan=1 colspan=2>Method</td><td rowspan=1 colspan=1>MNLI</td><td rowspan=1 colspan=1>SST-2</td><td rowspan=1 colspan=1>QQP</td><td rowspan=1 colspan=1>QNLI</td><td rowspan=1 colspan=1>Average Accuracy</td></tr><tr><td rowspan=2 colspan=1>Full</td><td rowspan=1 colspan=1>w/o DP</td><td rowspan=1 colspan=1>87.6</td><td rowspan=1 colspan=1>94.8</td><td rowspan=1 colspan=1>91.9</td><td rowspan=1 colspan=1>92.8</td><td rowspan=1 colspan=1>91.8</td></tr><tr><td rowspan=1 colspan=1>DP</td><td rowspan=1 colspan=1>83.2</td><td rowspan=1 colspan=1>85.9</td><td rowspan=1 colspan=1>86.2</td><td rowspan=1 colspan=1>84.8</td><td rowspan=1 colspan=1>85.0</td></tr><tr><td rowspan=1 colspan=1>Adapter</td><td rowspan=1 colspan=1>DP</td><td rowspan=1 colspan=1>84.6</td><td rowspan=1 colspan=1>92.9</td><td rowspan=1 colspan=1>87.4</td><td rowspan=1 colspan=1>89.2</td><td rowspan=1 colspan=1>88.5</td></tr><tr><td rowspan=1 colspan=1>LoRA</td><td rowspan=1 colspan=1>DP</td><td rowspan=1 colspan=1>84.5</td><td rowspan=1 colspan=1>92.7</td><td rowspan=1 colspan=1>87.1</td><td rowspan=1 colspan=1>88.3</td><td rowspan=1 colspan=1>88.2</td></tr></table>
|
| 372 |
+
|
| 373 |
+
For the RoBERTa-Base model, we try various choices of $\varepsilon$ . The values of $\varepsilon$ are chosen from [0.1, 0.5, 1, 3, 5, 8, 12]. All other settings are the same as those in Section 4. We run experiments on the MNLI and SST-2 datasets. The results are presented in Figure 2. Our framework performs well for a wide range of $\varepsilon$ . We note that our algorithm achieves meaningful accuracy even for very tight privacy parameters $\varepsilon = 0 . 5$ and 1. Such values of $\varepsilon$ are rarely explored when training deep models with differential privacy.
|
| 374 |
+
|
| 375 |
+
# C FINE-TUNING FOR LANGUAGE UNDERSTANDING TASKS WITH LARGE BATCH SIZE AND FULL-PRECISION
|
| 376 |
+
|
| 377 |
+
Li et al. (2022) show the performance of fine-tuning the full model can be significantly improved with proper configuration. In this section, we re-evaluate the tasks in Table 3 and 4 under the configuration in Li et al. (2022) and show such a configuration also improves the performance of our methods.
|
| 378 |
+
|
| 379 |
+
The configuration in Li et al. (2022) has two major differences compared to that in Section 4.1. The first difference is Li et al. (2022) run experiments with full-precision while the experiments in Section 4.1 use half-precision. Using half-precision is a common approach to speed up NLP experiments (Ott et al., 2018). However, half-precision may incur underflow issue which impacts the model performance (Micikevicius et al., 2017). The second difference is they use larger batch size for larger datasets. For example, the batch size for MNLI is roughly six times larger than the batch size for SST-2 in Li et al. (2022). In Section 4.1, we use the same batch size for all datasets.
|
| 380 |
+
|
| 381 |
+
Table 8: Accuracy for fine-tuning downstream tasks with RoBERTa-Large (in $\%$ ). Experiments are run with full-precision. We also scale up the batch size according to the dataset size compared to SST-2. The privacy parameters are $\varepsilon = 6 . 7$ , and $\delta = 1 { \mathrm e } { - } 5$ for SST-2 and QNLI and $\delta = 1 \mathrm { e } { - } 6$ for MNLI and QQP.
|
| 382 |
+
|
| 383 |
+
<table><tr><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>hod</td><td rowspan=1 colspan=1>MNLI</td><td rowspan=1 colspan=1>SST-2</td><td rowspan=1 colspan=1>QQP</td><td rowspan=1 colspan=1>QNLI</td><td rowspan=1 colspan=1>Average Accuracy</td></tr><tr><td rowspan=2 colspan=1>Full</td><td rowspan=1 colspan=1>w/o DP</td><td rowspan=1 colspan=1>90.2</td><td rowspan=1 colspan=1>96.4</td><td rowspan=1 colspan=1>92.2</td><td rowspan=1 colspan=1>94.7</td><td rowspan=1 colspan=1>93.4</td></tr><tr><td rowspan=1 colspan=1>DP</td><td rowspan=1 colspan=1>86.4</td><td rowspan=1 colspan=1>90.9</td><td rowspan=1 colspan=1>87.5</td><td rowspan=1 colspan=1>89.4</td><td rowspan=1 colspan=1>88.6</td></tr><tr><td rowspan=1 colspan=1>Adapter</td><td rowspan=1 colspan=1>DP</td><td rowspan=1 colspan=1>88.6</td><td rowspan=1 colspan=1>94.5</td><td rowspan=1 colspan=1>87.8</td><td rowspan=1 colspan=1>91.6</td><td rowspan=1 colspan=1>90.6</td></tr><tr><td rowspan=1 colspan=1>LoRA</td><td rowspan=1 colspan=1>DP</td><td rowspan=1 colspan=1>89.0</td><td rowspan=1 colspan=1>95.3</td><td rowspan=1 colspan=1>88.4</td><td rowspan=1 colspan=1>92.4</td><td rowspan=1 colspan=1>91.3</td></tr></table>
|
| 384 |
+
|
| 385 |
+

|
| 386 |
+
Figure 3: Test accuracy (in $\%$ ) of fine-tuning RoBERTa-Base with differentially private LoRA on the SST-2 dataset. Our algorithm performs well on a wide range of hyperparameters.
|
| 387 |
+
|
| 388 |
+
Table 9: Non-private metrics on the E2E NLG task, using full fine-tuning.
|
| 389 |
+
|
| 390 |
+
<table><tr><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>BLEU</td><td rowspan=1 colspan=1>NIST</td><td rowspan=1 colspan=1>MET</td><td rowspan=1 colspan=1>ROUGE-L</td><td rowspan=1 colspan=1>CIDEr</td></tr><tr><td rowspan=1 colspan=1>GPT-2-Medium</td><td rowspan=1 colspan=1>68.2</td><td rowspan=1 colspan=1>8.62</td><td rowspan=1 colspan=1>46.2</td><td rowspan=1 colspan=1>71.0</td><td rowspan=1 colspan=1>2.47</td></tr><tr><td rowspan=1 colspan=1>GPT-2-Large</td><td rowspan=1 colspan=1>68.5</td><td rowspan=1 colspan=1>8.78</td><td rowspan=1 colspan=1>46.0</td><td rowspan=1 colspan=1>69.9</td><td rowspan=1 colspan=1>2.45</td></tr></table>
|
| 391 |
+
|
| 392 |
+
We follow the above setup and re-evaluate DP-LoRA and DP-Adapter. The results are in Table 7 and 8. The results of full fine-tuning with differential privacy are directly adopted from Li et al. (2022). The configuration in Li et al. (2022) further improves the strong results in Table 3 and 4. For example, we achieve $8 9 . 0 \%$ accuracy on the MNLI dataset, which is only $1 . 2 \%$ lower than the accuracy without DP constraint. Moreover, the benefit of the proposed framework over full finetuning is still clear. The average accuracy of the proposed algorithms is ${ \sim } 3 \%$ higher than that of full fine-tuning.
|
| 393 |
+
|
| 394 |
+
# D ON THE INFLUENCE OF HYPERPARAMETERS
|
| 395 |
+
|
| 396 |
+
Here we demonstrate that our algorithms perform well for a wide range of hyperparameters. We study two hyperparameters that are directly related to the variance of noise: clipping threshold and batchsize. The clipping threshold is chosen from $[ 0 . 1 , 1 . 0 , 3 . 0 , 5 . 0 , 1 0 . 0 ]$ and the batchsize is chosen from [200, 500, 1000, 2000, 4000]. We note that we keep the number of updates the same as that in Section 4 when the batchsize is changed. We fine-tune the RoBERTa-Base model with differentially private LoRA $( r = 1 6 )$ ) on the SST-2 dataset. The results are presented in Figure 3. DP LoRA performs well for all the hyperparameters considered. The gap between the best accuracy and the worst accuracy is only $2 \%$ .
|
| 397 |
+
|
| 398 |
+
# E FULL FINE-TUNING WITH GPT-2
|
| 399 |
+
|
| 400 |
+
All results in Table 5 (in the main body), both private and non-private, perform fine-tuning using LoRA. In Table 9, we additionally report utility of non-private full fine-tuning. These numbers are taken from Table 1 of Li & Liang (2021). In general, these numbers are slightly lower than those obtained by performing non-private fine-tuning with LoRA.
|
| 401 |
+
|
| 402 |
+
Table 10: Metrics on the E2E NLG task. Non-DP results from Hu et al. (2021), except for GPT-2- XL, which was not reported in the paper. We ran GPT-2-XL with hyperparameters presented in $\mathrm { H u }$ et al. (2021). Bold indicates the best accuracy with DP. DP parameters are $( \varepsilon = 6 . 0 , \delta = 1 \mathrm { e } { - } 5 )$ . Val perp stands for validation perplexity.
|
| 403 |
+
|
| 404 |
+
<table><tr><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>Val perp</td><td rowspan=1 colspan=1>BLEU</td><td rowspan=1 colspan=1>NIST</td><td rowspan=1 colspan=1>MET</td><td rowspan=1 colspan=1>ROUGE-L</td><td rowspan=1 colspan=1>CIDEr</td></tr><tr><td rowspan=1 colspan=1>GPT-2-Small + DP</td><td rowspan=1 colspan=1>4.51</td><td rowspan=1 colspan=1>63.8</td><td rowspan=1 colspan=1>7.19</td><td rowspan=1 colspan=1>39.5</td><td rowspan=1 colspan=1>67.5</td><td rowspan=1 colspan=1>1.87</td></tr><tr><td rowspan=1 colspan=1>GPT-2-Medium + DP</td><td rowspan=1 colspan=1>4.02</td><td rowspan=1 colspan=1>65.5</td><td rowspan=1 colspan=1>8.45</td><td rowspan=1 colspan=1>42.7</td><td rowspan=1 colspan=1>67.9</td><td rowspan=1 colspan=1>2.23</td></tr><tr><td rowspan=1 colspan=1>GPT-2-Large + DP</td><td rowspan=1 colspan=1>3.87</td><td rowspan=1 colspan=1>66.7</td><td rowspan=1 colspan=1>8.63</td><td rowspan=1 colspan=1>44.0</td><td rowspan=1 colspan=1>67.8</td><td rowspan=1 colspan=1>2.33</td></tr><tr><td rowspan=1 colspan=1>GPT-2-XL + DP</td><td rowspan=1 colspan=1>3.79</td><td rowspan=1 colspan=1>66.1</td><td rowspan=1 colspan=1>8.53</td><td rowspan=1 colspan=1>43.0</td><td rowspan=1 colspan=1>68.1</td><td rowspan=1 colspan=1>2.28</td></tr><tr><td rowspan=1 colspan=1>GPT-2-Medium</td><td rowspan=1 colspan=1>3.19</td><td rowspan=1 colspan=1>70.4</td><td rowspan=1 colspan=1>8.85</td><td rowspan=1 colspan=1>46.8</td><td rowspan=1 colspan=1>71.8</td><td rowspan=1 colspan=1>2.53</td></tr><tr><td rowspan=1 colspan=1>GPT-2-Large</td><td rowspan=1 colspan=1>3.06</td><td rowspan=1 colspan=1>70.4</td><td rowspan=1 colspan=1>8.89</td><td rowspan=1 colspan=1>46.8</td><td rowspan=1 colspan=1>72.0</td><td rowspan=1 colspan=1>2.47</td></tr><tr><td rowspan=1 colspan=1>GPT-2-XL</td><td rowspan=1 colspan=1>3.01</td><td rowspan=1 colspan=1>69.4</td><td rowspan=1 colspan=1>8.78</td><td rowspan=1 colspan=1>46.2</td><td rowspan=1 colspan=1>71.5</td><td rowspan=1 colspan=1>2.49</td></tr></table>
|
| 405 |
+
|
| 406 |
+
Table 11: Metrics on the E2E NLG task. Bold indicates the best accuracy with DP. DP parameters satisfy $\mathit { \check { \Psi } } ( \varepsilon = 3 . 0 , \delta = 1 \mathrm { e } { - } 5 )$ , $( \varepsilon = 3 . 4 , \delta = 1 / 1 0 n )$ , $( \varepsilon = 3 . 9 , \delta = 1 / 1 0 0 n )$ and $( \varepsilon = 4 . 5 , \delta =$ $1 / 1 0 0 0 n \rangle$ ). Val perp stands for validation perplexity.
|
| 407 |
+
|
| 408 |
+
<table><tr><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>Val perp</td><td rowspan=1 colspan=1>BLEU</td><td rowspan=1 colspan=1>NIST</td><td rowspan=1 colspan=1>MET</td><td rowspan=1 colspan=1>ROUGE-L</td><td rowspan=1 colspan=1>CIDEr</td></tr><tr><td rowspan=1 colspan=1>GPT-2-Small + DP</td><td rowspan=1 colspan=1>4.59</td><td rowspan=1 colspan=1>62.7</td><td rowspan=1 colspan=1>7.03</td><td rowspan=1 colspan=1>39.2</td><td rowspan=1 colspan=1>66.4</td><td rowspan=1 colspan=1>1.85</td></tr><tr><td rowspan=1 colspan=1>GPT-2-Medium +DP</td><td rowspan=1 colspan=1>4.08</td><td rowspan=1 colspan=1>65.2</td><td rowspan=1 colspan=1>8.31</td><td rowspan=1 colspan=1>42.2</td><td rowspan=1 colspan=1>68.1</td><td rowspan=1 colspan=1>2.22</td></tr><tr><td rowspan=1 colspan=1>GPT-2-Large +DP</td><td rowspan=1 colspan=1>3.92</td><td rowspan=1 colspan=1>66.7</td><td rowspan=1 colspan=1>8.60</td><td rowspan=1 colspan=1>43.6</td><td rowspan=1 colspan=1>68.1</td><td rowspan=1 colspan=1>2.29</td></tr><tr><td rowspan=1 colspan=1>GPT-2-XL + DP</td><td rowspan=1 colspan=1>3.85</td><td rowspan=1 colspan=1>67.6</td><td rowspan=1 colspan=1>8.64</td><td rowspan=1 colspan=1>44.9</td><td rowspan=1 colspan=1>68.6</td><td rowspan=1 colspan=1>2.36</td></tr></table>
|
| 409 |
+
|
| 410 |
+
# F ADDITIONAL EXPERIMENTS ON NATURAL LANGUAGE GENERATION
|
| 411 |
+
|
| 412 |
+
In this section, we perform additional experiments on private fine-tuning for text generation problems using the GPT-2 series of models. This includes the private fine-tuning of the GPT-2-XL model with 1.5B parameters. There are three main points to note compared to our results in the main body: 1) We show an improved performance on E2E NLG challenge using better hyperparameters; 2) We conduct experiments on E2E dataset with different privacy parameters to show that large language models perform strong even with smaller privacy budgets; 3) Finally, we conduct new experiments on DART dataset.
|
| 413 |
+
|
| 414 |
+
# F.1 IMPROVING THE PERFORMANCE ON E2E NLG CHALLENGE
|
| 415 |
+
|
| 416 |
+
We improve the results of Table 5 with the following set of new hyperparameters.
|
| 417 |
+
|
| 418 |
+
Hyperparameter choice: For LoRA, we choose the bottleneck rank $r = 4$ in (4) and fine-tune $W _ { q }$ and $W _ { v }$ matrices of the attention layers as in the original paper. We optimize using AdamW with learning rate 4e-4, weight decay 1e-2 and train our models for 20 epochs. We use batch size 128. We take the gradient clipping parameter to be 1.0 and the noise multiplier to be 0.6 for the accountant in Gopi et al. (2021), achieving $\varepsilon = 6 . 0 , \delta = 1 \mathrm { e } { - 5 }$ .
|
| 419 |
+
|
| 420 |
+
Results: The results of our experiments are summarized in the Table 10.
|
| 421 |
+
|
| 422 |
+
# F.2 EXPERIMENTS WITH DIFFERENT PRIVACY PARAMETERS
|
| 423 |
+
|
| 424 |
+
On E2E dataset, we test our framework with smaller privacy budgets $\varepsilon < 5$ and $\delta \ll 1 / n$ ) where $n$ is the number of samples in the training data.
|
| 425 |
+
|
| 426 |
+
Hyperparameter choice: The hyperparameter choices are similar as in Section F.1. The only difference is that we increase the noise multiplier to be 0.71 for the accountant in Gopi et al. (2021), achieving the following $( \varepsilon , \delta )$ pairs: $( \varepsilon = 3 . 0 , \delta = 1 \mathrm { e } { - } 5 )$ , $( \varepsilon = 3 . 4 , \delta = 1 / 1 0 n )$ , $( \varepsilon = 3 . 9 , \delta =$ $1 / 1 0 0 n )$ and $( \varepsilon = 4 . 5 , \delta = 1 / 1 0 0 0 n )$ .
|
| 427 |
+
|
| 428 |
+
Results: The results of our experiments are summarized in the Table 11.
|
| 429 |
+
|
| 430 |
+
There are a couple of interesting observations comparing Table 11 with Table 10. First, we observe that although privacy budget is tight in Table 11, the results are quite similar to Table 10, which
|
| 431 |
+
|
| 432 |
+
Table 12: Metrics on the DART dataset. Non-DP results from Hu et al. (2021), except for GPT-2- XL, which was not reported in the paper. We ran GPT-2-XL with hyperparameters presented in $\mathrm { H u }$ et al. (2021). Bold indicates the best accuracy with DP. DP parameters are $( \varepsilon = 6 . 8 , \delta = 1 \mathrm { e } { - } 5 )$ ). Val perp stands for validation perplexity. Unlike all other metrics, the lower the TER metric is the better for the performance of the model.
|
| 433 |
+
|
| 434 |
+
<table><tr><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>Val perp</td><td rowspan=1 colspan=1>BLEU</td><td rowspan=1 colspan=1>MET</td><td rowspan=1 colspan=1>TER</td></tr><tr><td rowspan=1 colspan=1>GPT-2-Small +DP</td><td rowspan=1 colspan=1>3.82</td><td rowspan=1 colspan=1>38.5</td><td rowspan=1 colspan=1>0.34</td><td rowspan=1 colspan=1>0.53</td></tr><tr><td rowspan=1 colspan=1>GPT-2-Medium + DP</td><td rowspan=1 colspan=1>3.30</td><td rowspan=1 colspan=1>42.0</td><td rowspan=1 colspan=1>0.36</td><td rowspan=1 colspan=1>0.51</td></tr><tr><td rowspan=1 colspan=1>GPT-2-Large + DP</td><td rowspan=1 colspan=1>3.10</td><td rowspan=1 colspan=1>43.1</td><td rowspan=1 colspan=1>0.36</td><td rowspan=1 colspan=1>0.5</td></tr><tr><td rowspan=1 colspan=1>GPT-2-XL + DP</td><td rowspan=1 colspan=1>3.00</td><td rowspan=1 colspan=1>43.8</td><td rowspan=1 colspan=1>0.37</td><td rowspan=1 colspan=1>0.5</td></tr><tr><td rowspan=1 colspan=1>GPT-2-Medium</td><td rowspan=1 colspan=1>2.67</td><td rowspan=1 colspan=1>47.1</td><td rowspan=1 colspan=1>0.39</td><td rowspan=1 colspan=1>0.46</td></tr><tr><td rowspan=1 colspan=1>GPT-2-Large</td><td rowspan=1 colspan=1>2.89</td><td rowspan=1 colspan=1>47.5</td><td rowspan=1 colspan=1>0.39</td><td rowspan=1 colspan=1>0.45</td></tr><tr><td rowspan=1 colspan=1>GPT-2-XL</td><td rowspan=1 colspan=1>2.83</td><td rowspan=1 colspan=1>48.1</td><td rowspan=1 colspan=1>0.39</td><td rowspan=1 colspan=1>0.46</td></tr></table>
|
| 435 |
+
|
| 436 |
+
shows that our methods also perform very well under stronger privacy guarantees. A more interesting observation is that under smaller epsilon regimes, the performance for private fine-tuning of GPT-2-XL model improves. Observe that the performance improvement is more prominent going from GPT-2-Small to GPT-2-XL in this setting, which may indicate that larger models can be even more effective in private learning when the privacy budgets are tight.
|
| 437 |
+
|
| 438 |
+
# F.3 PERFORMING EXPERIMENTS ON DART DATASET
|
| 439 |
+
|
| 440 |
+
We study the DART dataset as a text generation problem for private fine-tuning of GPT-2 series of models.
|
| 441 |
+
|
| 442 |
+
DART: DART was introduced as an open-domain data-to-text dataset by Nan et al. (2021). The dataset consists of 62K training samples, 6.9K validation samples, and 12K test samples. In comparison to E2E, the dataset is larger and the task is more challenging.
|
| 443 |
+
|
| 444 |
+
Hyperparameter choice: The hyperparameter choices are similar as in the previous setting. The only difference is that we use batch size 256 for the experiments on DART. This achieves $\varepsilon =$ $6 . 8 , \delta = 1 \mathrm { e } \mathrm { - } 5$ on DART using the accountant in Gopi et al. (2021).
|
| 445 |
+
|
| 446 |
+
Results: The results of our experiments are summarized in the Table 12.
|
md/dev/Qg2vi4ZbHM9/Qg2vi4ZbHM9.md
ADDED
|
@@ -0,0 +1,472 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# STYLEALIGN: ANALYSIS AND APPLICATIONS OF ALIGNED STYLEGAN MODELS
|
| 2 |
+
|
| 3 |
+
Zongze Wu The Hebrew University
|
| 4 |
+
|
| 5 |
+
Yotam Nitzan Tel-Aviv University
|
| 6 |
+
|
| 7 |
+
Eli Shechtman Adobe Research
|
| 8 |
+
|
| 9 |
+
Dani Lischinski The Hebrew University
|
| 10 |
+
|
| 11 |
+
# ABSTRACT
|
| 12 |
+
|
| 13 |
+
In this paper, we perform an in-depth study of the properties and applications of aligned generative models. We refer to two models as aligned if they share the same architecture, and one of them (the child) is obtained from the other (the parent) via fine-tuning to another domain, a common practice in transfer learning. Several works already utilize some basic properties of aligned StyleGAN models to perform image-to-image translation. Here, we perform the first detailed exploration of model alignment, also focusing on StyleGAN. First, we empirically analyze aligned models and provide answers to important questions regarding their nature. In particular, we find that the child model’s latent spaces are semantically aligned with those of the parent, inheriting incredibly rich semantics, even for distant data domains such as human faces and churches. Second, equipped with this better understanding, we leverage aligned models to solve a diverse set of tasks. In addition to image translation, we demonstrate fully automatic cross-domain image morphing. We further show that zero-shot vision tasks may be performed in the child domain, while relying exclusively on supervision in the parent domain. We demonstrate qualitatively and quantitatively that our approach yields state-of-the-art results, while requiring only simple fine-tuning and inversion.
|
| 14 |
+
|
| 15 |
+
# 1 INTRODUCTION
|
| 16 |
+
|
| 17 |
+
Transfer Learning (TL) refers to the process in which a parent model, pretrained for some source domain/task, is used to improve the performance of a child model on a different target domain and/or task (Pan & Yang, 2009). The assumption underlying TL is that some knowledge learnt by the parent model is transferable to the new domain or task (Pan & Yang, 2009; Torrey & Shavlik, 2010; Yosinski et al., 2014). The most common TL approach is fine-tuning, where the parent’s parameters are used to initialize those of the child. Next, the child’s parameters, or sometimes just a subset of them, are trained on the target domain/task. Once TL is completed, the child posseses some of the parent’s knowledge, despite the fact that the model parameters may have changed.
|
| 18 |
+
|
| 19 |
+
Existing TL literature typically examines the performance of the child model, e.g., in terms of classification accuracy (He et al., 2019), or FID score (Karras et al., 2020a), without paying much attention to the relationship between parent and child models, induced by the transfer process. Typically, the child model is simply applied to the task it was trained on, while the parent model is no longer used, having fulfilled its purpose. In this work, we provide a complementary perspective, which focuses on analyzing and leveraging the shared knowledge between the two models. Specifically, we consider the case where the TL is performed by fine-tuning the same architecture. We refer to models obtained in this manner as aligned models.
|
| 20 |
+
|
| 21 |
+
Several recent works (Pinkney & Adler, 2020; bryandlee, 2020; Kwong et al., 2021; Song et al., 2021; Gal et al., 2021) use aligned models in a novel manner. In all cases, an unconditional GAN, specifically StyleGAN2 (Karras et al., 2020b) is fine-tuned from domain $A$ to domain $B$ . However, instead of applying the child model as an unconditional generator, it is used in conjunction with the parent model to form an image translation pipeline. First, an image from domain $A$ is embedded into the latent space of the parent StyleGAN2 model. The resulting latent code is then fed either into the child model (bryandlee, 2020; Song et al., 2021; Gal et al., 2021), or into a hybrid model created by layer swapping, i.e., by combining layers from the parent and the child (Pinkney & Adler, 2020; Kwong et al., 2021).
|
| 22 |
+
|
| 23 |
+
These methods have achieved great results in image-to-image translation between several domains. Most notably, translating real human face images to a variety of styles such as cartoons and oil paintings (Pinkney & Adler, 2020; Kwong et al., 2021; Song et al., 2021), but also translating humans to dogs and cats to wildlife (bryandlee, 2020; Gal et al., 2021). However, they focus on a specific application (image-to-image translation) and do not explore or leverage aligned models further. As a result, many questions arise but remain unanswered. For example, which parts of the network change in the TL process, and which knowledge is inherited by the child from its parent? To which degree do the answers to these questions depend on the similarity between the parent and child domains? And, is knowledge not used by the child model completely lost or could it be recovered? Finally, what further applications, besides image-to-image translation, can be solved using aligned models?
|
| 24 |
+
|
| 25 |
+
In this work, we delve deeper into model alignment. In light of previous works, we specifically focus on the state-of-the-art unconditional GAN architecture, StyleGAN2 (Karras et al., 2020b). The process of obtaining aligned models is incredibly simple: we start with a parent StyleGAN2 model trained on domain $A$ and fine-tune it fully for domain $B$ , yielding an aligned child model.
|
| 26 |
+
|
| 27 |
+
We divide the investigation of model alignment into two parts. First, in Section 3, we perform the first empirical analysis of the phenomenon, answering the questions posed above, as well as others. This analysis provides some surprising and novel insights that shed light on aligned StyleGAN2 models. For example, we discover that when fine tuning to a similar target domain, the parts of the model that change the most are the feature convolution weights in the synthesis network. In contrast, the changes in the mapping network and affine layers are negligible (see Figure 1). This crucially implies that the learned latent spaces $\mathcal { W }$ and $s$ are barely affected by the fine-tuning. This explains our next discovery – that semantically meaningful directions in the latent space of the parent model, retain the same (or similar) semantics in the child model (see Figure 2). As the data domains become more distant, the mapping network and affine layers become more affected, which results in a weaker degree of semantic alignment. However, even in extreme cases, such as human faces and churches, some semantic alignment occurs. Another surprising discovery is that the semantic latent controls that seemingly disappear after transfer to the child model, are in fact merely hidden, rather than forgotten, and reappear if the child is retrained back to the parent’s domain.
|
| 28 |
+
|
| 29 |
+
Second, in Section 4, we use aligned models to solve several popular Computer Vision and Computer Graphics tasks. We start with the aforementioned image-to-image translation task (Section 4.1), examine a number of alternatives, and show that aligned models obtain state-of-the-art results for a variety of scenarios. This is especially impactful, as using aligned models for image translation is incredibly simple compared to dedicated methods for the same task, each devising its custom architecture and losses. Next, we explore additional tasks, for which aligned models have not been used before. In Section 4.2 we describe a simple method for fully automatic image morphing between fairly dissimilar domains, such as human to dog faces, which previously necessitated sophisticated methods (Aberman et al., 2018; Fish et al., 2020). Examples of smooth morphs are included in the accompanying video. In Section 4.3, we use aligned models to solve zero-shot classification and regression tasks in domain $B$ , where the supervision is available strictly in domain $A$ . Conceptually, our method reduces a task in a zero-shot or few-shot setting to the same task in a different data domain where supervision is plentiful.
|
| 30 |
+
|
| 31 |
+
In summary, while several previous works took advantage of aligned models implicitly, ours is the first work to conduct a thorough empirical study of this phenomenon. Our study reveals various interesting properties that we then use to further leverage aligned models for a variety of applications, almost effortlessly achieving state-of-the-art performance.
|
| 32 |
+
|
| 33 |
+
# 2 RELATED WORK
|
| 34 |
+
|
| 35 |
+
Latent Space of GANs: With the rapid evolution of GANs (Goodfellow et al., 2014) in recent years, understanding and controlling their latent representation has attracted considerable attention. Specifically, it has been shown that the intermediate latent space of StyleGAN (Karras et al., 2019; 2020b;a) possesses appealing properties, such as being semantically rich, disentangled and smooth. Many recent works have proposed methods to interpret the semantics encoded in that space and its extensions and apply them to image editing (Jahanian et al., 2019; Shen et al., 2020a; Hark ¨ onen ¨ et al., 2020; Tewari et al., 2020; Abdal et al., 2020; Wu et al., 2020; Patashnik et al., 2021).
|
| 36 |
+
|
| 37 |
+
In order to benefit from these properties in real images, it is necessary to obtain the latent code from which a pretrained GAN can reconstruct the original input image. This task, commonly referred to as GAN Inversion, has been tackled by numerous recent works, either by using: (i) optimization (Abdal et al., 2019; Karras et al., 2020b); or (ii) an encoder (Guan et al., 2020; Pidhorskyi et al., 2020; Richardson et al., 2021; Tov et al., 2021); or (iii) a hybrid approach using both (Zhu et al., 2016; Baylies, 2019; Zhu et al., 2020a). See Xia et al. (2021) for a more thorough review.
|
| 38 |
+
|
| 39 |
+
Image-to-Image translation: The seminal pix2pix work by Isola et al. (2017), first introduced the use of conditional GANs to solve various supervised image-to-image translation tasks. Since then, their work has been extended to allow image synthesis in various different settings: high-resolution (Wang et al., 2018a), semantic image (Park et al., 2019; Zhu et al., 2020b; Liu et al., 2019b), multidomain (Choi et al., 2018), multimodal (Zhu et al., 2017b), and using a pre-trained generator (Nitzan et al., 2020; Richardson et al., 2021; Luo et al., 2020). Another scenario that has received significant attention is unsupervised image-to-image translation (Liu et al., 2017; Zhu et al., 2017a; Kim et al., 2017; Choi et al., 2020; Lee et al., 2020b), where no paired data samples are given.
|
| 40 |
+
|
| 41 |
+
Regardless of the setting, all of the aforementioned works train an neural network, designed explicitly for the translation task. Recently, several works (Pinkney & Adler, 2020; bryandlee, 2020; Kwong et al., 2021; Song et al., 2021; Gal et al., 2021) have taken a different approach towards image-to-image translation. They observe that significant correspondence between generated images in different domains exists when an unconditional generator, such as StyleGAN2 (Karras et al., 2020b), is fine-tuned between the two domains. Accordingly, these works take a two-step approach towards image-to-image translation. First, they invert a given image into the latent space of StyleGAN in domain $A$ and then forward the output latent code through a StyleGAN model for domain $B$ . The latter model is obtained either by directly fine-tuning from the former model (bryandlee, 2020; Song et al., 2021; Gal et al., 2021) or by layer swapping (Pinkney & Adler, 2020; Kwong et al., 2021), i.e., forming a model whose layers are partially those of the fine-tuned model and partially those of the model for domain $A$ .
|
| 42 |
+
|
| 43 |
+
In this work, we delve deeper into this phenomenon, which we refer to as model alignment, and go beyond the image-to-image translation task. For example, we demonstrate that the alignment property goes beyond high-level properties, such as pose, and that multiple fine-grained latent semantics are also aligned. We leverage this property for tasks such as morphing and zero-shot classification.
|
| 44 |
+
|
| 45 |
+
Fine-tuning and Catastrophic Forgetting: Fine-tuning was proven advantageous across fields, settings and tasks and therefore became a standard practice in the deep learning literature. Prominent advantages of fine-tuning are enabling few-shot tasks such as classification (Chen et al., 2019) and unconditional generation (Wang et al., 2018b; Mo et al., 2020; Wang et al., 2020; Li et al., 2020; Ojha et al., 2021), improved performance in a wide variety of tasks (Devlin et al., 2018; Radford et al., 2018; He et al., 2020) and faster training convergence (Wang et al., 2018b; He et al., 2019).
|
| 46 |
+
|
| 47 |
+
While fine-tuning can be an effective technique for solving a new task, it has been well known for over 30 years (McCloskey & Cohen, 1989) that in the process the model “forgets” how to solve the original task, a phenomenon referred to as Catastrophic Forgetting (CF). For example, once a GAN for a certain domain $A$ , is fine-tuned to another domain $B$ , the resulting model can only generate images in domain $B$ (Seff et al., 2017; Zhai et al., 2019). In settings such as continual learning and multi-task learning, CF is undesirable. In recent years, there has been progress in mitigating it using dedicated methods (Kirkpatrick et al., 2017; Kemker et al., 2018). CF has been also studied in the context of GANs (Liang et al., 2018; Li et al., 2020; Thanh-Tung & Tran, 2020).
|
| 48 |
+
|
| 49 |
+
Aforementioned previous works devised methods to obtain a better child model using fine-tuning. From a fine-tuning perspective, this means the model would perform better on the new task. From a CF perspective, this means the model’s performance on the previous task should not be impaired. We differ from these works significantly, as we make no deliberate effort to affect what happens during training of the child model. Instead, we investigate the relationship between the parent and child models after na¨ıve fine-tuning, and then use it to solve a variety of applications.
|
| 50 |
+
|
| 51 |
+
# 3 ANALYSIS OF ALIGNED STYLEGAN MODELS
|
| 52 |
+
|
| 53 |
+
As explained earlier, several previous works observed that a significant correspondence exists between images in different domains, generated from the same latent code by a parent StyleGAN2 model and a child model obtained from it via fine tuning. Our goal is to further understand the relation between the parent and the child models. Below, we explore several aspects.
|
| 54 |
+
|
| 55 |
+

|
| 56 |
+
Figure 1: Effect of resetting the weights of different components in child models (Mega, Dog) to their initial values, which come from the parent model (FFHQ). Resetting the feature convolution weights causes the most drastic changes. Also see Figure 8.
|
| 57 |
+
|
| 58 |
+
Which parts of the network change during transfer? Recall that the StyleGAN2 model is composed of a mapping function ( $\mathcal { Z }$ to $\mathcal { W }$ ), affine transformations $\mathcal { W }$ to $s$ ), feature convolution layers, and tRGB convolution layers that transform feature maps to RGB images. We transfer a parent StyleGAN2 model pretrained on FFHQ to the Mega cartoon dataset (Pinkney & Adler, 2020) and to AFHQ dog faces dataset (Choi et al., 2020), using ADA (Karras et al., 2020a). After the transfer, we reset the weights of each of the above components in the child models (Mega, Dog) to their initial values in the parent model. The results of this experiment are shown in Figure 1. We observe that the greatest effect on the generated results is caused by resetting the feature convolution layers, which changes the content and structure. Resetting the weights of other components, results in milder changes in both children. This implies that feature convolution layers change the most during transfer. The results also suggest that for the dog model, the affine and tRGB layers have changed significantly more than for the cartoon model. We attribute this difference to the distance between the data domains, and additional experiments in the appendix (Figure 8) support this hypothesis.
|
| 59 |
+
|
| 60 |
+
While resetting the mapping network has a stronger effect on the dog model, note that the changes are fairly subtle in both datasets, implying that the mapping network changes very little. Effectively, this means that the same $z \in { \mathcal { Z } }$ is mapped to similar codes in the $\mathcal { W }$ spaces of the parent and the child; in other words, the two $\mathcal { W }$ spaces are point-wise aligned. This is a crucial observation as it explains the success of previous works (Pinkney & Adler, 2020; bryandlee, 2020; Kwong et al., 2021) in performing image translation based on aligned models. Simply put, the two latent spaces may be viewed as a single shared latent space. Thus, inversion serves as an encoder from the source domain to this latent space, and the generator is a decoder to the target domain. Viewed in this light, alignment-based image translation resembles several previous image translation approaches (Liu et al., 2017; Huang et al., 2018; Liu et al., 2019a), which are based on shared latent spaces.
|
| 61 |
+
|
| 62 |
+
Semantic alignment for similar domains. In addition to point-wise alignment, we find that the $\mathcal { W }$ and $s$ latent spaces of the child model are also semantically aligned with those of the parent model. By semantic alignment, we refer to the property that latent space controls that affect various semantic attributes of images generated by the parent, have the same (or analogous) effect in the child model. This phenomenon is demonstrated below, both qualitatively and quantitatively.
|
| 63 |
+
|
| 64 |
+
We demonstrate alignment on closely related domains, by first fine-tuning a parent pretrained on FFHQ (Karras et al., 2019) to the Mega cartoon face dataset (Pinkney & Adler, 2020) and the Metface portrait dataset (Karras et al., 2020a). Next, we apply a variety of latent semantic controls learnt by the parent to the child models. The controls are either individual channels in StyleSpace $s$ , identified by Wu et al. (2020), or directions in $\mathcal { W }$ space, from InterFaceGAN (Shen et al., 2020b). We manipulate images using these controls “as is” in the parent and child models. The initial latent code is obtained by inverting a real image with an e4e encoder (Tov et al., 2021). As may be seen in Figures 2 and 9, regardless of the edited property, or the latent space used, the semantic controls affect the parent and the child models in exactly the same manner. Also see Figures 10 and 11.
|
| 65 |
+
|
| 66 |
+
To perform a quantitative evaluation we measure the alignment by calculating the overlap between semantic controls found independently in the parent and child models. Since latent directions in $\mathcal { W }$ are affinely related to channels in $s$ , we only examine overlap between style channels. Concretely, we follow Wu et al. (2020) to discover localized channels in both models, and report the number of localized channels for each semantic region in Table 1(a). As can be seen, there is consistently large amount of overlapping channels in the same semantic region. We verify that this overlap is not coincidental: performing the same experiment for two unaligned FFHQ models (trained from different random initializations) shows that they have much fewer overlapping channels (see Table 4).
|
| 67 |
+
|
| 68 |
+

|
| 69 |
+
Figure 2: Semantic controls discovered for a parent FFHQ model retain their function in the children models (Mega and Metface). This holds for individual channels in $s$ (bangs, smile, gaze), as well as for directions in $\mathcal { W }$ (pose, age, gender).
|
| 70 |
+
Table 1: Number of localized StyleSpace channels for various semantic regions. Each column corresponds to a semantic region in parent model, and each row to a semantic region in child model. The number of localized channels that are shared between parent and child are in the center (an empty space denotes 0). (a) After transferring from natural face to portrait, a number of localized channels retain their functions in the same areas (large values on the diagonal), rather than changing their function to other areas (all zeros except diagonal). (b) Even when transferring between more distant domains (human to dog face), we can see that multiple channels retain their function in the same areas (nose, ear), or shift to semantically corresponding areas (from human clothes to a dog’s torso, from human hair to dog’s ears). Note that the dog face segmentation have no mouth region.
|
| 71 |
+
|
| 72 |
+
<table><tr><td></td><td>19</td><td>eyebrow eye ear nose mouth neck cloth hair 5 41 21</td><td>32</td><td></td><td></td><td></td></tr><tr><td>torso 25 eye 3</td><td></td><td></td><td></td><td></td><td>46</td><td>3462 4</td></tr><tr><td>ear 142</td><td></td><td>2</td><td></td><td></td><td></td><td>13</td></tr><tr><td>nose 81</td><td></td><td>4</td><td>10</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td>(b) FFHQ2Dog</td><td></td><td></td><td></td><td></td></tr></table>
|
| 73 |
+
|
| 74 |
+
To the best of our knowledge, we are the first to quantitatively measure the fine-grained semantic alignment phenomenon. Our experiments indicate that aligned models for related domains are indeed strongly semantically aligned. This phenomenon enables many applications based on transferring knowledge and supervision between aligned models. E.g., zero-shot editing as demonstrated in Figure 2 and zero-shot classification/regression as discussed in Section 4.3.
|
| 75 |
+
|
| 76 |
+
Semantic alignment for more distant domains. To examine the degree of semantic alignment across a wider domain gap, we consider StyleGAN2 models transferred from FFHQ to AFHQ dog faces (Choi et al., 2020). Figure 3 demonstrates that, even in this case, there are still multiple single-channel controls that retain their semantic meaning (e.g., big eyes, black hair, short hair). Furthermore, there are also multi-channel editing directions in latent space that exhibit the same behavior, such as curly hair or small face (from StyleCLIP (Patashnik et al., 2021)), as well as pose (from InterFaceGAN (Shen et al., 2020b)). This appears to be the case for visual attributes that are common to both domains, while controls for attributes that are not present in the target domain (such as glasses, lipstick, or beard) seem to have no effect on the child model. However, as we discuss later, the relevant knowledge is not lost; rather, it is only hidden.
|
| 77 |
+
|
| 78 |
+
The retained controls reflect some interesting analogies between the domains: for example, controls for hair color and curliness in humans, control fur color and curliness in dogs, while hair length translates to length of dog ears. Interestingly, psychologists have also observed a correlation between the hair length in women and the ear shape of their preferred dog breeds (Coren, 1999), which is consistent with the folk belief that people look like their dogs. The gradual emergence of some of these analogies is clearly revealed when examining the samples generated by the model as it evolves during the transfer process. Figure 4 shows images obtained for the same latent vector $z \in { \mathcal { Z } }$ (in each row), as the training progresses. In the top row, we can see how human hair gradually evolves into dog ears, and the human nose and mouth gradually evolve into the dog’s nose and muzzle, while the pose remains mostly unchanged. A similarly smooth transition may be observed when transferring from AFHQ dogs to cats, as shown in the bottom row.
|
| 79 |
+
|
| 80 |
+

|
| 81 |
+
Figure 3: Semantic alignment between single-channel and multi-channel controls for more distant domains (humans and dogs). See also Figure 12 and supp. videos.
|
| 82 |
+
Figure 4: A smooth transition in images generated from the same $z \in { \mathcal { Z } }$ during finetuning. The epoch number appears above each column. The most significant visual changes occur in early epochs (0–16). Also see Figure 13 and supplementary videos.
|
| 83 |
+
|
| 84 |
+
Using the same quantitative evaluation method as before, we further quantify the alignment between a parent FFHQ model and a child AFHQ dogs model. Results are displayed in Table 1(b). As can be seen, a smaller number of channels preserve their semantics when transferred to AFHQ dog as compared to MetFace. Nevertheless, we still observe semantic alignment, albeit weaker, as human ears and hair overlap with dog ears, human cloth control the dog torso, etc.
|
| 85 |
+
|
| 86 |
+
We next experiment with even farther domains, with barely any similarity between parent and child, such as human faces and churches, which were also examined by Ojha et al. (2021). Despite lack of commonality, the latent direction that controls face pose in the parent still controls the church pose in the child model (see Figure 14). We further examine a double transfer, with FFHQ as parent, AFHQ dog as child and LSUN bedroom as grandchild. The pose direction in FFHQ still controls the pose in the grandchild bedroom model, as shown in Figure 14.
|
| 87 |
+
|
| 88 |
+
Are latent semantics forgotten or hidden? As shown in Table 1(b), when transferring between distant domains, only a small portion of the localized controls retain a similar semantic function. An interesting question that arises is: are the remaining controls completely “forgotten” during the transfer learning, or do they simply become inactive? To examine this, we retrain the child AFHQ dog model back to the FFHQ domain, thereby obtaining a grandchild model, and report the alignment between the original parent and the grandchild models (both for FFHQ) in Table 3. It may be seen that the effect of many of the localized controls are restored. For example, out of the 41 channels that control the ears in FFHQ, only 2 retain a similar function in AFHQ dogs, but 20 regain their function in the grandchild model. This implies that these channels were merely hidden, but not forgotten, during the first transfer learning stage. It should be emphasized that there is barely any such alignment between two unrelated models, even when they are trained on the same dataset, as shown in Table 4. Thus, the significant alignment between parent and grandchild (in Table 3) cannot be attributed to re-learning when fine tuning from the child to the grandchild.
|
| 89 |
+
|
| 90 |
+
Locality bias in semantics transfer. We explore this aspect and conclude that only some of the semantic alignment can be attributed to locality bias (see the discussion in appendix Section A.3).
|
| 91 |
+
|
| 92 |
+

|
| 93 |
+
Figure 5: Comparison of I2I translation (cat2dog and dog2wild in the AFHQ dataset) with two stateof-the-art methods. Our method generates realistic target domain images that capture the pose from the source image. In contrast, both CUT and F-LSeSim fail to generate realistic images since they follow the shape of the source domain image too closely. A quantitative comparison in the table below indicates our method is superior by a wide margin, in both FID and KID.
|
| 94 |
+
|
| 95 |
+
# 4 APPLICATIONS
|
| 96 |
+
|
| 97 |
+
We next apply aligned models to solve three kinds of tasks: image-to-image translation (Sec. 4.1), cross-domain image morphing (Sec. 4.2) and zero-shot classification and regression (Section 4.3). Efficient training of generators for different resolutions is described in the appendix (Sec. A.4).
|
| 98 |
+
|
| 99 |
+
# 4.1 CROSS-DOMAIN IMAGE TRANSLATION
|
| 100 |
+
|
| 101 |
+
As demonstrated earlier, aligned models generate images with similar high-level semantic attributes, given the same latent code. This makes it trivial to translate images between the domains of the parent and the child models, even when these domains are more distant than realistic faces and cartoons or paintings of human faces. For example, it is easy to translate between faces of different species, which typically involves significant changes in both structure and appearance. Furthermore, there’s no need for task-specific training or losses; all that is needed is a pair of aligned models and an inversion method to embed real images into the latent space of the source domain StyleGAN.
|
| 102 |
+
|
| 103 |
+
In Section A.5 we perform a systematic study of which inversion methods (encoder or latent optimization), and which latent spaces $( \mathscr { W } / \mathscr { W } { + } / \mathscr { Z } / \mathscr { Z } { + } )$ ), are most effective for image translation. Some previous works (Pinkney & Adler, 2020; Kwong et al., 2021) that considered only similar domains have used the $\mathcal { W } / \mathcal { W } 4$ spaces. We find that $\mathcal { Z }$ space yields same level of results for similar domains, but superior results for distant domains, qualitatively and quantitatively. This could be directly explained with a previous observation. For both settings the $\mathcal { Z }$ space is trivially shared, as it is a non-learned space. However, only for similar domains are the $\mathcal { W } / \mathcal { W } 4$ spaces aligned and shared.
|
| 104 |
+
|
| 105 |
+
In Figure 5 we compare our I2I results to two state-of-the-art methods, CUT (Park et al., 2020) and F-LSeSim (Zheng et al., 2021). It may be seen that our method produces realistic and natural looking results, while these two previous methods exhibit severe artifacts, and attempt to follow the shape in the source image too closely, yielding unrealistic results. The table in Figure 5 provides quantitative support for our qualitative observations, yielding significantly lower FID and KID scores for both cat2dog and dog2wild translations. Figure 21 demonstrates our method’s ability to perform image translation between dissimilar domains.
|
| 106 |
+
|
| 107 |
+
In addition to the I2I scenario examined above, aligned models are also able to perform referencebased image translation, where the resulting image combines the content of a source image with the style from a second (reference) image (Huang et al., 2018; Choi et al., 2020). StyleGAN inherently supports content and style disentanglement through style mixing. Specifically, we combine the early latent code (below $3 2 \times 3 2$ resolution) from a source image, with the late latent code (above or equal to $3 2 \times 3 2$ resolution) from a target domain reference image, and feed it to the target model to generate the result, as demonstrated in Figure 22. Figure 23 and Table 6 show that here, as well as for I2I, inversion via $\mathcal { Z } _ { o p t }$ works better than other inversions/spaces for multi-modal image translation. Figure 6 demonstrates that our results are better than those of current state-of-the-art methods, StarGAN-v2 (Choi et al., 2020) and OverLORD (Gabbay & Hoshen, 2021).
|
| 108 |
+
|
| 109 |
+

|
| 110 |
+
|
| 111 |
+

|
| 112 |
+
Figure 6: Comparison of reference-based image translation with StarGAN2 and OverLORD. Our method generates realistic target domain images that combine pose and structure from the source image with texture and color from the reference. StarGAN2 follows the source shape too closely, resulting in non-realistic animals (1st example in dog2cat, all examples in wild2dog). OverLORD’s results preserve the appearance of the reference well, but sometimes fail to capture the pose and structure (e.g., ear shape) from the source image (2nd and 3rd examples in wild2dog). A quantitative comparison in the table below indicates superior performance of our method in both FID and KID.
|
| 113 |
+
|
| 114 |
+
# 4.2 CROSS-DOMAIN IMAGE MORPHING
|
| 115 |
+
|
| 116 |
+
Image morphing is a popular visual effect of smoothly transitioning between a pair of input images (Wolberg, 1998), which typically requires either manual or automatic correspondences, in order to define a warp field. Cross-domain morphing, where the two images are from different domains, $A$ and $B$ , is particularly challenging (Aberman et al., 2018; Fish et al., 2020). However, using a pair of aligned StyleGAN models for the two domains, it is possible to perform cross-domain image morphing automatically without the need for correspondences, or any other input! The two input images are first embedded into the $\mathcal { W } +$ space of the corresponding generators, using e4e encoders (Tov et al., 2021). Next, a smooth transition is obtained by linearly interpolating between the resulting latent codes, while also interpolating between the model weights. Wang et al. (2019) previously proposed interpolating model weights in order to obtain a smooth transition between the “effects” of two different networks. We note that they do not discuss morphing real images, which is a slightly different setting, and requires also interpolating latent codes as we propose here.
|
| 117 |
+
|
| 118 |
+
Layer swapping, proposed by Pinkney & Adler (2020), is an alternative approach to morph between domains. We discuss the differences between the two approaches in Section A.7. Concisely, our proposed method ensures a continuous smooth transition, while layer swapping performs the transition as a series of discrete steps, rather than continuously.
|
| 119 |
+
|
| 120 |
+
We demonstrate automatic morphing between dog and cat faces in Figures 24 and 25, and dog and human faces in Figures 26 and 27. Interpolating the model weights (along each column) yields a smooth transition between domains (different species, but the same pose and fur color), while interpolating the $\mathcal { W } \mathcal { + }$ latent codes (along each row) smoothly transitions inside each domain (same species, varying pose and fur color). In fact, any trajectory in this 2D interpolation space yields a smooth morph sequence between two input images. We simultaneously interpolate along both dimensions to create the sequences shown in the supplementary video.
|
| 121 |
+
|
| 122 |
+

|
| 123 |
+
Figure 7: Zero-shot dog attribute classification using aligned models (FFHQ and AFHQ dogs). In the top row a human “black hair” classifier becomes a “black fur” classifier, a “curly hair” classifier is able to classify “curly fur”, and a “long hair” classifier becomes a “down-pointing ears” classifier. The neutral columns correspond to images whose prediction scores are close to the cutoff value.
|
| 124 |
+
|
| 125 |
+
# 4.3 KNOWLEDGE TRANSFER FROM PARENT TO CHILD DOMAIN
|
| 126 |
+
|
| 127 |
+
Vision tasks on human faces have been researched for years. Consequently, numerous datasets with detailed annotations exist. For example, images in the CelebA dataset (Liu et al., 2015) are labeled with 40 attributes such as “Young”, “Curly hair”, “Smiling”, etc. Such annotations are not available for almost any other domain, such as animal faces, severely limiting the range of tasks that can be solved. As discussed earlier, this issue is a prominent motivation for transfer learning. However, common transfer learning approaches are not applicable in the “zero-shot” setting, where there is abundant labeled data in the source domain, but strictly unlabeled data in the target domain.
|
| 128 |
+
|
| 129 |
+
We next show that this problem can be solved effectively for directly comparable attributes across domains by leveraging aligned models. Consider the case of head pose (specifically, yaw): a clear and comparable attribute for both humans and dogs, however for humans there is abundant labeled data and for dogs there is none. As demonstrated earlier, the latent pose semantics are aligned in the two models, and the parent’s yaw editing direction continues to edit yaw in the child. As shown earlier, this holds for additional attributes. Thus, despite a major gap between the two domains in image space, the gap in the latent space is considerably smaller, enabling transfer of knowledge between these domains. While na¨ıvely applying a model trained on the source images to the target images would fail, this approach works well when applied on the latent representation. To demonstrate this approach, we solve several zero-shot classification and regression tasks using models trained in the latent space of the parent StyleGAN model.
|
| 130 |
+
|
| 131 |
+
For regression tasks, we use LARGE (Nitzan et al., 2021), which demonstrated that the distance in $\mathcal { W } +$ space to the decision hyperplane associated with a semantic property, gauges the degree of that attribute in image space. See appendix (Section A.6) for more details. Zero-shot yaw regression results are depicted in Figures 28 and 29. As evident, the estimated yaw not only captures the correct tendency, but also produces a value that qualitatively seems reasonably close to actual yaw degree.
|
| 132 |
+
|
| 133 |
+
For classification tasks we take a similar approach. We simply replace the linear regression model with a logistic regression model and use a cutoff value of 0.5. As shown in Figure 7, our method can turn classifiers for human faces to classifiers for dog faces. These results also demonstrate that the attributes are not required to be exactly identical (pose to pose) but could be comparable in a more broad sense (long hair in humans to down-pointing ears in dogs).
|
| 134 |
+
|
| 135 |
+
# 5 CONCLUSION
|
| 136 |
+
|
| 137 |
+
In this work, we performed the first extensive investigation of the properties of aligned generative models. We initially answered several open questions, crucial for their understanding. The findings demonstrated impressive and surprising properties, such as semantic alignment across distant domains and knowledge being “hidden” instead of being forgotten. We then leveraged our new insights to apply aligned models for a multitude of tasks. Interestingly, we obtain state-of-the-art results for those tasks with a single, simple fine-tuning based method. We hope that our work can inspire others to consider aligned models as a simple paradigm for solving a wide range of tasks.
|
| 138 |
+
|
| 139 |
+
# 6 ETHICS STATEMENT
|
| 140 |
+
|
| 141 |
+
This work performs an extensive study of the properties of aligned generative models and applies such models for several computer vision tasks. In general, generative models and learning-based algorithms raise several concerns. Notably, generative models may be used to produce deceiving or offending content, e.g. deepfakes (Wikipedia, 2021), and data-driven algorithms may perpetuate biases exiting in their training sets. However, these concerns are general to the entire fields and are not amplified by this work.
|
| 142 |
+
|
| 143 |
+
# 7 REPRODUCIBILITY
|
| 144 |
+
|
| 145 |
+
Throughout the paper we provide detailed information facilitating reproduction of our results. For example, in each experiment we specify the choices of latent space, specific layer and inversion method (e.g., Sections 4.1, 4.2 and A.5). Similarly, when applying latent editing directions we specify with which method were they identified and in what space (e.g., Section 3, A.3). Additionally, we provide in the appendix (Section A.8) the information required to reproduce the child models. We expect these to be sufficient for independent replication of our main findings. Separately, source code and pretrained models have been made available in the project’s repository.
|
| 146 |
+
|
| 147 |
+
# 8 ACKNOWLEDGMENTS
|
| 148 |
+
|
| 149 |
+
We thank Daniel Cohen-Or for helpful discussions and encouragement and the anonymous reviewers for their comments. This work was supported in part by a gift from Adobe, by the Israel Science Foundation (grant no. 2492/20), and the Joint NSFC-ISF Research Grant Program (3611/21).
|
| 150 |
+
|
| 151 |
+
# REFERENCES
|
| 152 |
+
|
| 153 |
+
Rameen Abdal, Yipeng Qin, and Peter Wonka. Image2stylegan: How to embed images into the StyleGAN latent space? In Proceedings of the IEEE international conference on computer vision, pp. 4432–4441, 2019.
|
| 154 |
+
|
| 155 |
+
Rameen Abdal, Peihao Zhu, Niloy Mitra, and Peter Wonka. StyleFlow: attribute-conditioned exploration of StyleGAN-generated images using conditional continuous normalizing flows. arXiv preprint arXiv:2008.02401, 2020.
|
| 156 |
+
|
| 157 |
+
Kfir Aberman, Jing Liao, Mingyi Shi, Dani Lischinski, Baoquan Chen, and Daniel Cohen-Or. Neural best-buddies: Sparse cross-domain correspondence. ACM Transactions on Graphics (TOG), 37 (4):69, 2018.
|
| 158 |
+
|
| 159 |
+
David Bau, Bolei Zhou, Aditya Khosla, Aude Oliva, and Antonio Torralba. Network Dissection: quantifying interpretability of deep visual representations. In Proc. CVPR, pp. 6541–6549, 2017.
|
| 160 |
+
|
| 161 |
+
Peter Baylies. stylegan-encoder. https://github.com/pbaylies/stylegan-encoder, 2019. Accessed: January 2021.
|
| 162 |
+
|
| 163 |
+
bryandlee. FreezeG. https://github.com/bryandlee/FreezeG, 2020. Accessed: May 2021.
|
| 164 |
+
|
| 165 |
+
Wei-Yu Chen, Yen-Cheng Liu, Zsolt Kira, Yu-Chiang Frank Wang, and Jia-Bin Huang. A closer look at few-shot classification. arXiv preprint arXiv:1904.04232, 2019.
|
| 166 |
+
|
| 167 |
+
Yunjey Choi, Minje Choi, Munyoung Kim, Jung-Woo Ha, Sunghun Kim, and Jaegul Choo. StarGAN: Unified generative adversarial networks for multi-domain image-to-image translation. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 8789–8797, 2018.
|
| 168 |
+
|
| 169 |
+
Yunjey Choi, Youngjung Uh, Jaejun Yoo, and Jung-Woo Ha. StarGAN v2: Diverse image synthesis for multiple domains. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 8188���8197, 2020.
|
| 170 |
+
|
| 171 |
+
Stanley Coren. Do people look like their dogs? Anthrozoos¨ , 12(2):111–114, 1999.
|
| 172 |
+
|
| 173 |
+
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.
|
| 174 |
+
|
| 175 |
+
N. Fish, R. Zhang, L. Perry, D. Cohen-Or, E. Shechtman, and C. Barnes. Image morphing with perceptual constraints and STN alignment. Computer Graphics Forum, 39(6):303–313, 2020.
|
| 176 |
+
|
| 177 |
+
Aviv Gabbay and Yedid Hoshen. Scaling-up disentanglement for image translation. arXiv preprint arXiv:2103.14017, 2021.
|
| 178 |
+
|
| 179 |
+
Rinon Gal, Or Patashnik, Haggai Maron, Gal Chechik, and Daniel Cohen-Or. StyleGAN-NADA: CLIP-guided domain adaptation of image generators. arXiv preprint arXiv:2108.00946, 2021.
|
| 180 |
+
|
| 181 |
+
Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. In Advances in neural information processing systems, pp. 2672–2680, 2014.
|
| 182 |
+
|
| 183 |
+
Shanyan Guan, Ying Tai, Bingbing Ni, Feida Zhu, Feiyue Huang, and Xiaokang Yang. Collaborative learning for faster StyleGAN embedding. arXiv preprint arXiv:2007.01758, 2020.
|
| 184 |
+
|
| 185 |
+
Erik Hark ¨ onen, Aaron Hertzmann, Jaakko Lehtinen, and Sylvain Paris. GANSpace: Discovering ¨ interpretable GAN controls. arXiv preprint arXiv:2004.02546, 2020.
|
| 186 |
+
|
| 187 |
+
Kaiming He, Ross Girshick, and Piotr Dollar. Rethinking imagenet pre-training. In ´ Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 4918–4927, 2019.
|
| 188 |
+
|
| 189 |
+
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.
|
| 190 |
+
|
| 191 |
+
Xun Huang, Ming-Yu Liu, Serge Belongie, and Jan Kautz. Multimodal unsupervised image-toimage translation. In ECCV, 2018.
|
| 192 |
+
|
| 193 |
+
Phillip Isola, Jun-Yan Zhu, Tinghui Zhou, and Alexei A Efros. Image-to-image translation with conditional adversarial networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 1125–1134, 2017.
|
| 194 |
+
|
| 195 |
+
Ali Jahanian, Lucy Chai, and Phillip Isola. On the “steerability” of generative adversarial networks. arXiv preprint arXiv:1907.07171, 2019.
|
| 196 |
+
|
| 197 |
+
Tero Karras, Samuli Laine, and Timo Aila. A style-based generator architecture for generative adversarial networks. In Proc. CVPR, pp. 4401–4410, 2019.
|
| 198 |
+
|
| 199 |
+
Tero Karras, Miika Aittala, Janne Hellsten, Samuli Laine, Jaakko Lehtinen, and Timo Aila. Training generative adversarial networks with limited data. In Proc. NeurIPS, 2020a.
|
| 200 |
+
|
| 201 |
+
Tero Karras, Samuli Laine, Miika Aittala, Janne Hellsten, Jaakko Lehtinen, and Timo Aila. Analyzing and improving the image quality of StyleGAN. In Proc. CVPR, pp. 8110–8119, 2020b.
|
| 202 |
+
|
| 203 |
+
Ronald Kemker, Marc McClure, Angelina Abitino, Tyler Hayes, and Christopher Kanan. Measuring catastrophic forgetting in neural networks. In Proceedings of the 32nd AAAI Conference on Artificial Intelligence, pp. 3390–3398, 2018.
|
| 204 |
+
|
| 205 |
+
Taeksoo Kim, Moonsu Cha, Hyunsoo Kim, Jung Kwon Lee, and Jiwon Kim. Learning to discover cross-domain relations with generative adversarial networks. In International Conference on Machine Learning, pp. 1857–1865. PMLR, 2017.
|
| 206 |
+
|
| 207 |
+
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.
|
| 208 |
+
|
| 209 |
+
Sam Kwong, Jialu Huang, and Jing Liao. Unsupervised image-to-image translation via pre-trained StyleGAN2 network. IEEE Transactions on Multimedia, 2021.
|
| 210 |
+
|
| 211 |
+
Cheng-Han Lee, Ziwei Liu, Lingyun Wu, and Ping Luo. Maskgan: Towards diverse and interactive facial image manipulation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 5549–5558, 2020a.
|
| 212 |
+
|
| 213 |
+
Hsin-Ying Lee, Hung-Yu Tseng, Qi Mao, Jia-Bin Huang, Yu-Ding Lu, Maneesh Kumar Singh, and Ming-Hsuan Yang. DRIT $^ { + + }$ : Diverse image-to-image translation via disentangled representations. International Journal of Computer Vision, pp. 1–16, 2020b.
|
| 214 |
+
|
| 215 |
+
Yijun Li, Richard Zhang, Jingwan Lu, and Eli Shechtman. Few-shot image generation with elastic weight consolidation. arXiv preprint arXiv:2012.02780, 2020.
|
| 216 |
+
|
| 217 |
+
Kevin J Liang, Chunyuan Li, Guoyin Wang, and Lawrence Carin. Generative adversarial network training is a continual learning problem. arXiv preprint arXiv:1811.11083, 2018.
|
| 218 |
+
|
| 219 |
+
Ming-Yu Liu, Thomas Breuel, and Jan Kautz. Unsupervised image-to-image translation networks. In Advances in neural information processing systems, pp. 700–708, 2017.
|
| 220 |
+
|
| 221 |
+
Ming-Yu Liu, Xun Huang, Arun Mallya, Tero Karras, Timo Aila, Jaakko Lehtinen, and Jan Kautz. Few-shot unsupervised image-to-image translation. In IEEE International Conference on Computer Vision (ICCV), 2019a.
|
| 222 |
+
|
| 223 |
+
Xihui Liu, Guojun Yin, Jing Shao, Xiaogang Wang, et al. Learning to predict layout-to-image conditional convolutions for semantic image synthesis. In Advances in Neural Information Processing Systems, pp. 570–580, 2019b.
|
| 224 |
+
|
| 225 |
+
Ziwei Liu, Ping Luo, Xiaogang Wang, and Xiaoou Tang. Deep learning face attributes in the wild, 2015.
|
| 226 |
+
|
| 227 |
+
Xuan Luo, Xuaner Zhang, Paul Yoo, Ricardo Martin-Brualla, Jason Lawrence, and Steven M. Seitz. Time-travel rephotography. arXiv preprint arXiv:2012.12261, 2020.
|
| 228 |
+
|
| 229 |
+
Michael McCloskey and Neal J. Cohen. Catastrophic interference in connectionist networks: The sequential learning problem. In Gordon H. Bower (ed.), Psychology of Learning and Motivation, volume 24, pp. 109–165. Academic Press, 1989.
|
| 230 |
+
|
| 231 |
+
Sangwoo Mo, Minsu Cho, and Jinwoo Shin. Freeze the discriminator: a simple baseline for finetuning GANs. arXiv preprint arXiv:2002.10964, 2020.
|
| 232 |
+
|
| 233 |
+
Yotam Nitzan, Amit Bermano, Yangyan Li, and Daniel Cohen-Or. Face identity disentanglement via latent space mapping. ACM Trans. Graph., 39(6), November 2020. ISSN 0730-0301. doi: 10.1145/3414685.3417826. URL https://doi.org/10.1145/3414685.3417826.
|
| 234 |
+
|
| 235 |
+
Yotam Nitzan, Rinon Gal, Ofir Brenner, and Daniel Cohen-Or. LARGE: Latent-based regression through GAN semantics. arXiv preprint arXiv:2107.11186, 2021.
|
| 236 |
+
|
| 237 |
+
Utkarsh Ojha, Yijun Li, Jingwan Lu, Alexei A Efros, Yong Jae Lee, Eli Shechtman, and Richard Zhang. Few-shot image generation via cross-domain correspondence. arXiv preprint arXiv:2104.06820, 2021.
|
| 238 |
+
|
| 239 |
+
Sinno Jialin Pan and Qiang Yang. A survey on transfer learning. IEEE Transactions on knowledge and data engineering, 22(10):1345–1359, 2009.
|
| 240 |
+
|
| 241 |
+
Taesung Park, Ming-Yu Liu, Ting-Chun Wang, and Jun-Yan Zhu. Semantic image synthesis with spatially-adaptive normalization. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2337–2346, 2019.
|
| 242 |
+
|
| 243 |
+
Taesung Park, Alexei A Efros, Richard Zhang, and Jun-Yan Zhu. Contrastive learning for unpaired image-to-image translation. In European Conference on Computer Vision, pp. 319–345. Springer, 2020.
|
| 244 |
+
|
| 245 |
+
Or Patashnik, Zongze Wu, Eli Shechtman, Daniel Cohen-Or, and Dani Lischinski. StyleCLIP: Textdriven manipulation of StyleGAN imagery. arXiv preprint arXiv:2103.17249, 2021.
|
| 246 |
+
|
| 247 |
+
Stanislav Pidhorskyi, Donald A Adjeroh, and Gianfranco Doretto. Adversarial latent autoencoders. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 14104–14113, 2020.
|
| 248 |
+
|
| 249 |
+
Justin NM Pinkney and Doron Adler. Resolution dependant GAN interpolation for controllable image synthesis between domains. arXiv preprint arXiv:2010.05334, 2020.
|
| 250 |
+
|
| 251 |
+
Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving language understanding by generative pre-training. preprint, 2018.
|
| 252 |
+
|
| 253 |
+
Elad Richardson, Yuval Alaluf, Or Patashnik, Yotam Nitzan, Yaniv Azar, Stav Shapiro, and Daniel Cohen-Or. Encoding in style: a StyleGAN encoder for image-to-image translation. In Proc. IEEE/CVF CVPR, pp. 2287–2296, 2021.
|
| 254 |
+
|
| 255 |
+
Ari Seff, Alex Beatson, Daniel Suo, and Han Liu. Continual learning in generative adversarial nets. arXiv preprint arXiv:1705.08395, 2017.
|
| 256 |
+
|
| 257 |
+
Yujun Shen, Jinjin Gu, Xiaoou Tang, and Bolei Zhou. Interpreting the latent space of GANs for semantic face editing. In Proc. CVPR, pp. 9243–9252, 2020a.
|
| 258 |
+
|
| 259 |
+
Yujun Shen, Ceyuan Yang, Xiaoou Tang, and Bolei Zhou. InterFaceGAN: interpreting the disentangled face representation learned by GANs. arXiv preprint arXiv:2005.09635, 2020b.
|
| 260 |
+
|
| 261 |
+
Guoxian Song, Linjie Luo, Jing Liu, Wan-Chun Ma, Chunpong Lai, Chuanxia Zheng, and Tat-Jen Cham. AgileGAN: stylizing portraits by inversion-consistent transfer learning. ACM Transactions on Graphics (TOG), 40(4):1–13, 2021.
|
| 262 |
+
|
| 263 |
+
Ayush Tewari, Mohamed Elgharib, Gaurav Bharaj, Florian Bernard, Hans-Peter Seidel, Patrick Perez, Michael Zollh ´ ofer, and Christian Theobalt. StyleRig: Rigging StyleGAN for 3d control ¨ over portrait images. arXiv preprint arXiv:2004.00121, 2020.
|
| 264 |
+
|
| 265 |
+
Hoang Thanh-Tung and Truyen Tran. Catastrophic forgetting and mode collapse in GANs. In 2020 International Joint Conference on Neural Networks (IJCNN), pp. 1–10. IEEE, 2020.
|
| 266 |
+
|
| 267 |
+
Lisa Torrey and Jude Shavlik. Transfer learning. In Handbook of research on machine learning applications and trends: algorithms, methods, and techniques, pp. 242–264. IGI global, 2010.
|
| 268 |
+
|
| 269 |
+
Omer Tov, Yuval Alaluf, Yotam Nitzan, Or Patashnik, and Daniel Cohen-Or. Designing an encoder for StyleGAN image manipulation. arXiv preprint arXiv:2102.02766, 2021.
|
| 270 |
+
|
| 271 |
+
Ting-Chun Wang, Ming-Yu Liu, Jun-Yan Zhu, Andrew Tao, Jan Kautz, and Bryan Catanzaro. Highresolution image synthesis and semantic manipulation with conditional GANs. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 8798–8807, 2018a.
|
| 272 |
+
|
| 273 |
+
Xintao Wang, Ke Yu, Chao Dong, Xiaoou Tang, and Chen Change Loy. Deep network interpolation for continuous imagery effect transition. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 1692–1701, 2019.
|
| 274 |
+
|
| 275 |
+
Yaxing Wang, Chenshen Wu, Luis Herranz, Joost van de Weijer, Abel Gonzalez-Garcia, and Bogdan Raducanu. Transferring GANs: generating images from limited data. In Proceedings of the European Conference on Computer Vision (ECCV), pp. 218–234, 2018b.
|
| 276 |
+
|
| 277 |
+
Yaxing Wang, Abel Gonzalez-Garcia, David Berga, Luis Herranz, Fahad Shahbaz Khan, and Joost van de Weijer. MineGAN: effective knowledge transfer from GANs to target domains with few images. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 9332–9341, 2020.
|
| 278 |
+
|
| 279 |
+
Wikipedia. Deepfake. https://en.wikipedia.org/wiki/Deepfake, 2021.
|
| 280 |
+
|
| 281 |
+
George Wolberg. Image morphing: a survey. The Visual Computer, 14(8):360–372, 1998.
|
| 282 |
+
|
| 283 |
+
Zongze Wu, Dani Lischinski, and Eli Shechtman. StyleSpace analysis: Disentangled controls for StyleGAN image generation. arXiv:2011.12799, 2020.
|
| 284 |
+
|
| 285 |
+
Weihao Xia, Yulun Zhang, Yujiu Yang, Jing-Hao Xue, Bolei Zhou, and Ming-Hsuan Yang. GAN inversion: A survey, 2021.
|
| 286 |
+
|
| 287 |
+
Tete Xiao, Yingcheng Liu, Bolei Zhou, Yuning Jiang, and Jian Sun. Unified perceptual parsing for scene understanding. In Proc. ECCV, pp. 418–434, 2018.
|
| 288 |
+
|
| 289 |
+
Jason Yosinski, Jeff Clune, Yoshua Bengio, and Hod Lipson. How transferable are features in deep neural networks? In Z. Ghahramani, M. Welling, C. Cortes, N. Lawrence, and K. Q. Weinberger (eds.), Advances in Neural Information Processing Systems, volume 27, 2014.
|
| 290 |
+
|
| 291 |
+
Changqian Yu, Jingbo Wang, Chao Peng, Changxin Gao, Gang Yu, and Nong Sang. BiSeNet: Bilateral segmentation network for real-time semantic segmentation. In Proceedings of the European conference on computer vision (ECCV), pp. 325–341, 2018.
|
| 292 |
+
|
| 293 |
+
Mengyao Zhai, Lei Chen, Frederick Tung, Jiawei He, Megha Nawhal, and Greg Mori. Lifelong GAN: Continual learning for conditional image generation. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 2759–2768, 2019.
|
| 294 |
+
|
| 295 |
+
Chuanxia Zheng, Tat-Jen Cham, and Jianfei Cai. The spatially-correlative loss for various image translation tasks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 16407–16417, 2021.
|
| 296 |
+
|
| 297 |
+
Jiapeng Zhu, Yujun Shen, Deli Zhao, and Bolei Zhou. In-domain GAN inversion for real image editing. arXiv preprint arXiv:2004.00049, 2020a.
|
| 298 |
+
|
| 299 |
+
Jun-Yan Zhu, Philipp Krahenb ¨ uhl, Eli Shechtman, and Alexei A. Efros. Generative visual manipula- ¨ tion on the natural image manifold. In Proceedings of European Conference on Computer Vision (ECCV), 2016.
|
| 300 |
+
|
| 301 |
+
Jun-Yan Zhu, Taesung Park, Phillip Isola, and Alexei A Efros. Unpaired image-to-image translation using cycle-consistent adversarial networks. In Proc. IEEE ICCV, pp. 2223–2232, 2017a.
|
| 302 |
+
|
| 303 |
+
Jun-Yan Zhu, Richard Zhang, Deepak Pathak, Trevor Darrell, Alexei A Efros, Oliver Wang, and Eli Shechtman. Toward multimodal image-to-image translation. In Advances in Neural Information Processing Systems, 2017b.
|
| 304 |
+
|
| 305 |
+
Peihao Zhu, Rameen Abdal, Yipeng Qin, and Peter Wonka. SEAN: Image synthesis with semantic region-adaptive normalization. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 5104–5113, 2020b.
|
| 306 |
+
|
| 307 |
+
# A APPENDIX
|
| 308 |
+
|
| 309 |
+
# A.1 EFFECT OF TUNING ON INDIVIDUAL FEATURE CONVOLUTION LAYERS
|
| 310 |
+
|
| 311 |
+
As part of our investigation of which parts of the network change during fine-tuning, we also examine in more detail the effect of resetting the weights of individual feature convolution layers on the generated images. We reset one layer at a time and measure the perceptual change in an image using LPIPS. Results are displayed in Table 2. As may be seen, each layer has an effect on the image, but resetting the middle resolution layers (32, 64, 128) induces the greatest LPIPS change.
|
| 312 |
+
|
| 313 |
+
# A.2 FURTHER SEMANTIC ALIGNMENT ANALYSIS
|
| 314 |
+
|
| 315 |
+
Since many semantic attributes cannot be controlled by a single style channel, nor by a single manipulation direction in $\mathcal { W }$ , we also compare the effect of different semantic manipulation directions in StyleSpace, which are discovered for the parent model using CLIP (Patashnik et al., 2021). Figures 10 and 11 demonstrate that these compound manipulations, e.g., expressions and hair styles, also retain their semantics in the child models.
|
| 316 |
+
|
| 317 |
+
# A.3 LOCALITY BIAS IN SEMANTICS TRANSFER.
|
| 318 |
+
|
| 319 |
+
We have demonstrated that a variety of localized controls retain their function during transfer learning between FFHQ and AFHQ. However, since the faces in these two datasets are roughly aligned, it is interesting to examine whether this occurs due to overlap between the corresponding semantic regions. To examine this, we perform transfer learning from a model pretrained on FFHQ (at $2 5 6 \times 2 5 6$ resolution) to three different versions of the same dataset: (i) shifted 60 pixels to the right, (ii) shifted 60 pixels downward, and (iii) flipped upside down. Figure 15 shows that the shifts, and particularly the flip, affect the identity/appearance of the images generated from the same latent codes in $\mathcal { Z }$ , however other high-level characteristics, such as gender, age, or hair length, remain similar. We also show the effect of manipulating five different style channels across different layers and different semantic regions. For the horizontally shifted dataset, all five channels retain their function. For the vertical shift, four out of the five channels retain their function (channel 15 45 that controls lipstick loses its effect). For the upside down flip, two out of five channels (9 409 for gaze and 12 479 for blond hair) retain their function. In summary, for 11 out of 15 cases, the function of a channel was transferred despite a significant change in the locality. Thus, locality bias cannot explain all of the alignment that occurs.
|
| 320 |
+
|
| 321 |
+
There are, however, some interesting examples of strong locality bias. Channel 6 501 controls smiling in the parent FFHQ model, but after an upside-down flip it controls receding hairline, this implies locality bias does contribute to channel-wise semantics transfer, since the forehead of the flipped faces overlaps the mouth location in the original images.
|
| 322 |
+
|
| 323 |
+
# A.4 SEMANTIC ALIGNMENT BETWEEN DIFFERENT RESOLUTIONS
|
| 324 |
+
|
| 325 |
+
Given a high resolution StyleGAN2 model, an aligned lower resolution model may be easily obtained by simply removing the high resolution layers, and fine-tuning to convergence. The finetuning is necessary, as without it the model generates low-contrast images, as shown in Figure 30. This works well because StyleGAN2 inherently supports multi-resolution synthesis, with the generator containing ToRGB layers and the discriminator containing corresponding FromRGB layers that directly operate in image space for different resolutions. Assuming a high resolution $( 1 0 2 4 \times 1 0 2 4 )$ model is already available, creating a low-resolution model $( 5 1 2 \times 5 1 2 )$ in this way is computationally efficient, requiring less than 2 days of fine-tuning on a single GTX1080Ti GPU, compared to more than one month of training from scratch. Figure 30 shows that the resulting low-resolution model is highly aligned with the original: the same latent code $z \in { \mathcal { Z } }$ generates nearly the same image, and the semantic controls in the parent model have the same effect in the child model. One of the important consequences of such alignment is that there’s no need to spend weeks of GPU time to re-discover the semantic StyleSpace controls (Wu et al., 2020). Furthermore, given an inversion model (Tov et al., 2021) for the parent model, it may be fine-tuned for the child model within a few GPU hours, instead of 2-3 days of training from scratch.
|
| 326 |
+
|
| 327 |
+
# A.5 METHODS AND SPACES FOR IMAGE TRANSLATION
|
| 328 |
+
|
| 329 |
+
To determine which latent space and inversion method (encoder or optimization) is best suited for translation of real images, we explore a number of alternatives. We modify the pSp encoder (Richardson et al., 2021) to embed images into W, $\mathcal { Z }$ , and $\mathcal { Z } +$ (Song et al., 2021) spaces. For $\mathcal { W } +$ we use the e4e encoder (Tov et al., 2021), which is based on pSp, but generates $\mathcal { W } +$ codes with better alignment with the latent manifold. We also modify the latent optimization method from the official StyleGAN2 implementation (Karras et al., 2020b) to embed into these different spaces. For $\mathcal { Z } / \mathcal { Z } +$ , it is crucial to use the truncation trick for both image inversion and generation, otherwise the translation results might exhibit strong artifacts (we use a truncation coefficient of 0.7). Inversion results corresponding to these different methods are shown in Figure 16 for AFHQ dogs and cats.
|
| 330 |
+
|
| 331 |
+
Examples of I2I translation (dog2wild and cat2dog) using these different inversion methods are shown in Figure 17. While inversion of source domain images to $\mathcal { W } +$ yields arguably the best reconstructions, when translating to the target domain via $\mathcal { W }$ or $\mathcal { W } +$ , the color palette of the results seems wrong, especially for the dog2wild translation. We attribute this to the fact that the mapping function (from $\mathcal { Z }$ to $\mathcal { W }$ ) changes when fine tuning the parent to the child, which affects the color palette, and translating using ${ \ w } / { \ w } +$ latent codes ignores this change. Translations via $\mathcal { Z } +$ or ${ \mathcal { Z } } \mathrm { + } _ { o p t }$ inversion also suffer from occasional color artifacts (mainly in the dog2wild examples).
|
| 332 |
+
|
| 333 |
+
Both $\mathcal { Z }$ and $\mathcal { Z } _ { o p t }$ , on the other hand, yield satisfactory translation results. We prefer $\mathcal { Z } _ { o p t }$ because it tends to produce a vivid color palette and to maintain a stronger resemblance of the source images, in terms of pose, shape, and colors. Quantitatively, translating via $\mathcal { Z } _ { o p t }$ inversion achieves best FID and KID over the other plausible alternatives, as reported in Table 5. Therefore we use translation via $\mathcal { Z } _ { o p t }$ as our preferred method.
|
| 334 |
+
|
| 335 |
+
We perform similar study for translation between nearby domains (FFHQ and cartoon) in Figure 18, 19 and 20. In our subjective opinion, translation via $\mathcal { Z } _ { o p t }$ still achieves the most cartoonish look. However, translations via $\mathcal { W }$ bear closer resemblance to the input portrait, while still achieving a satisfactory cartoonish look. As discussed in the text, this may be attributed to the fact that, for similar domains, the mapping function changes little during fine-tuning, resulting in pointwise alignment of the $\mathcal { W }$ spaces of the parent and child models.
|
| 336 |
+
|
| 337 |
+
# A.6 ZERO-SHOT REGRESSION
|
| 338 |
+
|
| 339 |
+
To leverage aligned models for regression tasks, we use LARGE (Nitzan et al., 2021), which demonstrated that the distance in $\mathcal { W } +$ space to the decision hyperplane associated with a semantic property, gauges the degree of that attribute in image space. As their method is designed for a few-shot setting, we simplify it slightly for our setting where the training data in the source domain is abundant. Concisely, we simply use the distances calculated in specific layers known to control certain attributes as the input features for the regression model. We demonstrate this approach for head pose regression and use the first four layers, which are known to control the pose in StyleGAN (Karras et al., 2019; Nitzan et al., 2021). At inference time, we use e4e (Tov et al., 2021) to encode images of the target domain into the $\mathcal { W } +$ space of the child model, compute the distances of the first four layers from the decision hyperplane, and input them to the human face yaw estimation model.
|
| 340 |
+
|
| 341 |
+
The zero-shot yaw regression results for AFHQ dogs and cats are depicted in Figures 28 and 29. As can be seen, the estimated yaw not only captures the correct tendency, but also produces a value that qualitatively seems reasonably close to actual yaw degree.
|
| 342 |
+
|
| 343 |
+
# A.7 METHODS TO BLEND ALIGNED MODELS
|
| 344 |
+
|
| 345 |
+
Layer swapping was introduced by Pinkney & Adler (2020) as a method to generate images of a new domain by “blending” together two existing data domains. It does that by creating a hybrid model contains layers from two aligned models. Specifically, the first (coarse) layers are taken from one model and the last (fine) layers are taken from another. We note that this method blends the two data domains in a specific manner. Thanks to the hierarchical structure of StyleGAN (Karras et al., 2019), the created model inherits the structure (coarse layers) from one model and texture from another (fine layers). Pinkney & Adler (2020) also mentioned that the fine layers could be interpolated between the models, however this idea wasn’t applied in practice.
|
| 346 |
+
|
| 347 |
+
The layer swapping method was shown to produce visually pleasing results on the task of stylizing human portraits (Pinkney & Adler, 2020; Song et al., 2021). However, there are a few disadvantages to this method. First, when domains are more distant (e.g. faces of humans and dogs), the results obtained by this approach are less intuitive and visually pleasing (see Figures 31 to 33). This coincides well with our observation from Figure 8. Since the feature convolution layers change much more significantly when transferring to a distant domain, the layers of a layer-swapped model are more alien to each other. Second, the number of intermediate steps is limited by the number of convolution layers in the generator, which is at most 18. This prevents the application of layer swapping for creating a smooth transition between images from different domains.
|
| 348 |
+
|
| 349 |
+
In our morphing application (Section 4.2), we present an alternative method to blend two aligned models. There we propose to perform a simple linear interpolation of all model weights to achieve a gradual transition. We compare the results of this approach with layer swapping in Figures 31 to 33. Please note that our proposed method is able to obtain “blended” images that seem more smooth and natural.
|
| 350 |
+
|
| 351 |
+
# A.8 FINE-TUNING IMPLEMENTATION DETAILS
|
| 352 |
+
|
| 353 |
+
Given a model pretrained on the parent domain, we fine-tune it on the child domain. Specifically, we use model config-f and the default hyper-parameters from the official Nvidia StyleGAN2 and StyleGAN2-ADA implementations in tensorflow. We use the augmentations of StyleGAN2-ADA only when the child domain is AFHQ or Metface.
|
| 354 |
+
|
| 355 |
+
Note that StyleGAN2-ADA implementation chooses the config based on input image resolution. It uses config-f for image resolution above $5 1 2 \times 5 1 2$ , and config-e for other resolutions. To use config-f without worrying about image resolution, one can specify the flag --cfg stylegan2 when using tran.py, and change line 179 in train.py from spec.fmaps $\ c = ~ 1$ if res $> = ~ 5 1 2$ else 0.5 to spec.fmaps $\ c = ~ 1$ .
|
| 356 |
+
|
| 357 |
+
# A.9 DETECTING LOCALIZED CHANNELS
|
| 358 |
+
|
| 359 |
+
We follow $\mathrm { W u }$ et al. (2020) to discover localized channels in the StyleGAN model. To reduce noise, we only consider channels to be localized if they have the strongest gradient in the same semantic region over $7 5 \%$ of sampling images, rather than $5 0 \%$ used in the original paper. For FFHQ and Metface models, we use the semantic segmentation maps from BiSeNet (Yu et al., 2018) pretrained on CelebAMask-HQ (Lee et al., 2020a). For AFHQ dogs, we using the semantic segmentation maps from a unified parsing network (Xiao et al., 2018) pretrained on Broden $^ +$ (Bau et al., 2017).
|
| 360 |
+
|
| 361 |
+

|
| 362 |
+
Figure 8: We reset the weights of different components in child models (Mega, dog, church) to their initial values, which come from the parent model (FFHQ). When resetting the weights in feature convolution layers, the output images change more drastically (content, structure), while resetting the weights of other components causes milder effects. This implies feature convolution layers contain most of new learned knowledge.
|
| 363 |
+
|
| 364 |
+
Table 2: We measure the extent to which the change in each feature convolution layer (during finetuning) affects the generated images. Given a parent FFHQ model and a child AFHQ dog model, we reset the feature convolution weights for each resolution of the child model to their original values in the parent model, and measure the LPIPS distance between the images generated by child model before and after resetting the weights. A higher LPIPS score indicates a more significant change in image space. It may be seen that the greatest change is caused by resetting the middle resolution layers (32, 64, 128).
|
| 365 |
+
|
| 366 |
+
<table><tr><td>Resolution</td><td>4</td><td>8</td><td>16</td><td>32</td><td>64</td><td>128</td><td>256</td><td>512</td></tr><tr><td>LPIPS</td><td>0.156</td><td>0.385</td><td>0.390</td><td>0.432</td><td>0.440</td><td>0.405</td><td>0.369</td><td>0.355</td></tr></table>
|
| 367 |
+
|
| 368 |
+
Table 3: The number of localized StyleSpace controls for various semantic regions for an FFHQ parent model and an FFHQ grandchild model, with training flow from FFHQ (parent) to AFHQ dog (child) then back to FFHQ (grandchild). Each column corresponds to a semantic region for parent and each row to a semantic region for grandchild. The number of localized channels shared between two models is indicated for each pair of semantic regions.
|
| 369 |
+
|
| 370 |
+
<table><tr><td></td><td></td><td>eyebrow 19</td><td>eye 5</td><td>ear 41</td><td>nose 21</td><td>mouth 32</td><td>neck 46</td><td>cloth 34</td><td>hair 62</td></tr><tr><td>eyebrow</td><td>29</td><td>8</td><td></td><td></td><td>1</td><td></td><td>1</td><td></td><td></td></tr><tr><td>eye</td><td>9</td><td></td><td>3</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>ear</td><td>45</td><td></td><td></td><td>20</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>nose</td><td>23</td><td></td><td></td><td></td><td>8</td><td></td><td></td><td></td><td></td></tr><tr><td>mouth</td><td>55</td><td></td><td></td><td></td><td></td><td>11</td><td></td><td></td><td></td></tr><tr><td>neck</td><td>61</td><td></td><td></td><td></td><td>1</td><td></td><td>15</td><td></td><td></td></tr><tr><td>cloth</td><td>65</td><td></td><td></td><td></td><td></td><td></td><td></td><td>19</td><td></td></tr><tr><td>hair</td><td>70</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>33</td></tr></table>
|
| 371 |
+
|
| 372 |
+
<table><tr><td></td><td></td><td>eyebrow 19</td><td>eye 5</td><td>ear 41</td><td>nose 21</td><td>mouth 32</td><td>neck 46</td><td>cloth 34</td><td>hair 62</td></tr><tr><td>eyebrow</td><td>22</td><td></td><td></td><td></td><td></td><td>1</td><td>1</td><td></td><td></td></tr><tr><td>eye</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>1</td></tr><tr><td>ear</td><td>44</td><td></td><td></td><td></td><td></td><td>1</td><td>1</td><td>1</td><td></td></tr><tr><td>nose</td><td>19</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>mouth</td><td>28</td><td></td><td></td><td>1</td><td>1</td><td>1</td><td></td><td></td><td></td></tr><tr><td>neck</td><td>43</td><td></td><td></td><td>1</td><td></td><td>1</td><td>1</td><td></td><td>1</td></tr><tr><td>cloth</td><td>32</td><td></td><td></td><td>2</td><td>1</td><td></td><td></td><td>1</td><td></td></tr><tr><td>hair</td><td>85</td><td></td><td></td><td></td><td></td><td>1</td><td>2</td><td></td><td>2</td></tr></table>
|
| 373 |
+
|
| 374 |
+
Table 4: The number of localized StyleSpace controls for various semantic regions for two randomly initialized FFHQ models. Each column corresponds to a semantic region in one model and each row to a semantic region in the other model. The number of localized channels shared between two models is indicated for each pair of semantic regions. It is evident that the two models only have a small number of overlap channels across unrelated semantic regions (for example, hair and eye). This experiment serves as a negative control to show that a large number of overlap channels only occurs when the two models have parent and child relation, as is the case in Table 1
|
| 375 |
+
|
| 376 |
+

|
| 377 |
+
Figure 9: Semantic alignment: semantic controls discovered for the parent model (FFHQ) retain their function in the children models (Mega and Metface). This holds for individual channels in $s$ (bangs, smile, gaze), where the layer and channel number is indicated under each column. Semantic alignment is also observed for manipulation directions in $\mathcal { W }$ (pose, age, gender).
|
| 378 |
+
|
| 379 |
+

|
| 380 |
+
Figure 10: Semantic alignment of multiple channels: semantically meaningful directions in StyleSpace discovered in the parent model (FFHQ), detected using StyleCLIP (Patashnik et al., 2021), still control the same attributes in children models (Mega and Metface).
|
| 381 |
+
|
| 382 |
+

|
| 383 |
+
Figure 11: Semantic alignment of multiple channels: semantically meaningful directions in StyleSpace discovered in the parent model (FFHQ), detected using StyleCLIP (Patashnik et al., 2021), still control the same attributes in children models (Mega and Metface).
|
| 384 |
+
|
| 385 |
+

|
| 386 |
+
Figure 12: Examples of semantic alignment between single-channel, as well as multi-channel controls discovered for the parent model (StyleGAN2 trained on FFHQ) and a child model (AFHQ dogs). While the analogy between hair in humans and fur in dogs seems intuitive, there are also some less obvious analogies, such as hair length and ear length.
|
| 387 |
+
|
| 388 |
+

|
| 389 |
+
Figure 13: During transfer learning between domains, we can observe a smooth transition in images generated from the same latent code $z \in { \mathcal { Z } }$ . The top row demonstrates this for transfer from FFHQ to AFHQ dogs, while the bottom rows shows this for transfer from AFHQ dogs to cats. The number of epochs is indicated above each column. The most significant visual changes occur in early epochs (0–16), while later epochs mainly improve image quality and realism without significant changes in semantic attributes.
|
| 390 |
+
|
| 391 |
+

|
| 392 |
+
Figure 14: Some degree of semantic alignment is present even when the source and target domains are very dissimilar. In the top two rows, we show that the latent direction that controls pose in the parent FFHQ model still controls pose in the child LSUN church model. In the bottom two rows, we examine a double transfer, with FFHQ as parent, AFHQ dog as child and LSUN bedroom as grandchild. The pose direction in FFHQ still controls the pose in the grandchild bedroom model.
|
| 393 |
+
|
| 394 |
+

|
| 395 |
+
Figure 15: To understand whether locality bias contributes to semantics transfer, we fine-tune a pretrained FFHQ model in $2 5 6 \times 2 5 6$ resolution, to (i) a FFHQ dataset shifted 60 pixels to the right, (ii) a FFHQ dataset shifted 60 pixels downward, and (iii) a FFHQ dataset flipped upside-down. We examine the semantics transfer for 5 channels across different layers and different semantic regions. For the shift right case, all 5 channels retain their function. For the shift down case, 4 out of 5 channels retain their function (channel 15 45 loses its function for lipstick). For the upside-down flip, 2 out of 5 (9 409 gaze and 12 479 blond hair) retain their function. In summary, for 11 out of 15 cases, the semantic function of channels is transferred even if we break the locality bias. These results imply that the transfer of semantics cannot be fully attributed to locality bias.
|
| 396 |
+
|
| 397 |
+

|
| 398 |
+
Figure 16: To invert real images of animal faces to different latent spaces, we examine both encoders and latent optimization based methods. We use the pSp encoder (Richardson et al., 2021) as a backbone and modify it to embed into $\mathcal { W }$ , $\mathcal { Z }$ , and $\mathcal { Z } +$ (Song et al., 2021) spaces. For the $\mathcal { W } \mathcal { + }$ space, we use e4e (Tov et al., 2021), which also uses pSp (Richardson et al., 2021) as backbone. For optimization based inversion, we modify the optimization code from StyleGAN2 (Karras et al., 2020b) to $\mathcal { Z }$ or $\mathcal { Z } +$ space (two rightmost columns). All of the inversion methods yield reasonably faithful reconstructions, with occasional artifacts in the $\mathcal { Z }$ and ${ \mathcal { Z } } \mathrm { + } _ { o p t }$ reconstructions. Note that, as we show below, that better reconstruction does not necessarily yield the best image translation.
|
| 399 |
+
|
| 400 |
+

|
| 401 |
+
Figure 17: Comparison of I2I results (dog2wild in the top four rows, cat2dog in the four bottom ones) for the different inversions shown in Figure 16. The color palette appears to be wrong for both $\mathcal { W } +$ and $\mathcal { W }$ encoding, especially for the dog to wildlife translation. This is not surprising, since the mapping function changes during fine tuning (see Figure 1), affecting the color palette, and inverting into the $\mathcal { W }$ or $\mathcal { W } +$ spaces ignores the difference between the mapping functions of the parent and child. Translations via $\mathcal { Z } +$ or ${ \mathcal { Z } } \mathrm { + } _ { o p t }$ inversion also suffer from occasional color artifacts (mainly in the dog2wild examples). Translations via either $\mathcal { Z }$ or $\mathcal { Z } _ { o p t }$ provide satisfactory results. We prefer $\mathcal { Z } _ { o p t }$ because it typically yields a more vivid color palette, while slightly better capturing the characteristics of the source images (especially in the dog2wild examples).
|
| 402 |
+
|
| 403 |
+

|
| 404 |
+
Figure 18: To invert real images of human faces to different latent spaces, we examine both encoders and latent optimization based methods. We use the pSp encoder (Richardson et al., 2021) as a backbone and modify it to embed into $\mathcal { W }$ space. For the $\mathcal { W } \mathcal { + }$ space, we use e4e (Tov et al., 2021), which also uses pSp (Richardson et al., 2021) as backbone. We also experimented with using the pSp encoder to $\mathcal { Z }$ , and $\mathcal { Z } +$ (Song et al., 2021) spaces, but training does not converge and results are unrealistic. For optimization-based inversion, we modify the optimization code from StyleGAN2 (Karras et al., 2020b) to $\mathcal { W }$ , $\mathcal { W } \mathcal { + }$ , $\mathcal { Z }$ or $\mathcal { Z } +$ spaces. In terms of reconstruction quality alone, $\mathcal { W } \mathcal { + }$ typically yields the best inversions; however, as we show below, better reconstruction does not necessarily yield the best image translation.
|
| 405 |
+
|
| 406 |
+

|
| 407 |
+
Figure 19: Comparison of I2I results (for real faces to cartoon-like, using FFHQ parent and Mega child) for the different inversions shown in Figure 18. Translation results via $\mathcal { W } _ { o p t }$ and $\mathcal { W } \mathrm { + } _ { o p t }$ contain strong artifacts. In our subjective opinion, translation via $\mathcal { Z } _ { o p t }$ achieves the most cartoonish look. However, translations via $\mathcal { W }$ bear closer resemblance to the input portrait, while still achieving a satisfactory cartoonish look. As discussed in the text, this may be attributed to the fact that, for similar domains, the mapping function changes little during fine-tuning, resulting in pointwise alignment of the $\mathcal { W }$ spaces of the parent and child models.
|
| 408 |
+
|
| 409 |
+
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Zenc</td><td rowspan=1 colspan=1>Z+enc</td><td rowspan=1 colspan=1>Zopt</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Zenc</td><td rowspan=1 colspan=1>Z+enc</td><td rowspan=1 colspan=1>Zopt</td></tr><tr><td rowspan=1 colspan=1>cat2dog</td><td rowspan=1 colspan=1>48.8</td><td rowspan=1 colspan=1>68.5</td><td rowspan=1 colspan=1>34.2</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>16.1</td><td rowspan=1 colspan=1>34.8</td><td rowspan=1 colspan=1>7.36</td></tr><tr><td rowspan=1 colspan=1>dog2wild</td><td rowspan=1 colspan=1>22.1</td><td rowspan=1 colspan=1>24.8</td><td rowspan=1 colspan=1>10.9</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>10.9</td><td rowspan=1 colspan=1>12.2</td><td rowspan=1 colspan=1>2.19</td></tr><tr><td rowspan=2 colspan=1>wild2dogdog2cat</td><td rowspan=2 colspan=1>60.030.4</td><td rowspan=1 colspan=1>62.5</td><td rowspan=1 colspan=2>34.7</td><td rowspan=1 colspan=1>15.5</td><td rowspan=1 colspan=1>22.7</td><td rowspan=2 colspan=1>5.983.79</td></tr><tr><td rowspan=1 colspan=1>21.1</td><td rowspan=1 colspan=2>17.9</td><td rowspan=1 colspan=1>14.5</td><td rowspan=1 colspan=1>5.49</td></tr><tr><td rowspan=1 colspan=8>(a)FID (b)KID×10³</td></tr></table>
|
| 410 |
+
|
| 411 |
+

|
| 412 |
+
Table 5: A quantitative comparison of I2I translation via different latent spaces and inversion methods. Based on the qualitative results shown in Figure 17, we consider encoder-based inversion for $\mathcal { Z }$ and $\mathcal { Z } +$ spaces, and latent optimization method for $\mathcal { Z }$ space, to be promising methods and further examine them using FID and KID scores. Our results indicate that inversion $\mathcal { Z }$ using latent optimization achieves the best FID and KID for I2I translation tasks.
|
| 413 |
+
Figure 20: Image Toonification using our $\mathcal { Z } _ { o p t }$ method.
|
| 414 |
+
|
| 415 |
+

|
| 416 |
+
Figure 21: Aligned models enable effective image translation between dissimilar domains (human face and dog face). Some interesting analogies emerge in these translations. For example, as the human hair becomes longer, so does the dog’s fur, while the dog’s ears change from “candle flame” ears, to “bat” ears, and finally to folded (“down-pointing”) ears. The fur color is mainly determined by the human hair color, and the dog pose mimics that of the human.
|
| 417 |
+
|
| 418 |
+

|
| 419 |
+
Figure 22: Reference-based image translation. Given a real dog image as source and a real cat image as reference, we aim to obtain a cat image that keeps the content (mainly pose) from the source and the style (fur texture and color) from the reference. We first invert the input real images to latent space of StyleGAN, then take style codes for all layers below $n$ (low resolution) from the source, and style codes for layers above or equal to $n$ (high resolution) from the reference. The layer index $n$ is indicated above each column. Thus, index 0 represents the inverted reference, and index 23 represents the translation of the source to the target domain (cats), while the other indices correspond to standard style mixing in StyleGAN. We can see that when $n$ is around 6, the images combine the pose of the source with the style of the reference.
|
| 420 |
+
|
| 421 |
+
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>W+ enc</td><td rowspan=1 colspan=1>Z+ enc</td><td rowspan=1 colspan=1>Z enc</td><td rowspan=1 colspan=1>z_opts</td><td rowspan=1 colspan=1>W+ enc</td><td rowspan=1 colspan=1>Z+ enc</td><td rowspan=1 colspan=1>Z enc</td><td rowspan=1 colspan=1>z_opts</td></tr><tr><td rowspan=1 colspan=1>dog2cat</td><td rowspan=1 colspan=1>10.3</td><td rowspan=1 colspan=1>11.2</td><td rowspan=1 colspan=1>13.7</td><td rowspan=1 colspan=1>9.22</td><td rowspan=1 colspan=1>4.87</td><td rowspan=1 colspan=1>4.85</td><td rowspan=1 colspan=1>6.56</td><td rowspan=1 colspan=1>3.43</td></tr><tr><td rowspan=2 colspan=1>wild2dogcat2dogdog2wild</td><td rowspan=2 colspan=1>44.542.137.9</td><td rowspan=2 colspan=1>37.644.328.3</td><td rowspan=1 colspan=1>36.6</td><td rowspan=1 colspan=1>27.4</td><td rowspan=1 colspan=1>27.2</td><td rowspan=2 colspan=1>21.128.216.2</td><td rowspan=2 colspan=1>18.827.012.5</td><td rowspan=2 colspan=1>14.817.03.64</td></tr><tr><td rowspan=1 colspan=1>40.718.5</td><td rowspan=1 colspan=1>30.49.65</td><td rowspan=1 colspan=1>27.621.5</td></tr><tr><td rowspan=1 colspan=7>(a)FID (b) KID×10³</td><td rowspan=1 colspan=2>03</td></tr></table>
|
| 422 |
+
|
| 423 |
+
Table 6: A quantitative comparison of reference-based image translation using different inversion methods and latent spaces. It may be seen that the latent optimization method for $\mathcal { Z }$ achieves the best FID and KID for such translation tasks.
|
| 424 |
+
|
| 425 |
+

|
| 426 |
+
Figure 23: A qualitative comparison of reference-based image translation for different methods and spaces. Since here the colors are determined by the higher layers of the generator, whose style parameters come from the inversion of the reference image, the translation via $\mathcal { W } \mathcal { + }$ does not suffer from color palette issues. Thus, both translations via $\mathcal { W } \mathcal { + }$ and via $\mathcal { Z } _ { o p t }$ look satisfactory.
|
| 427 |
+
|
| 428 |
+

|
| 429 |
+
Figure 24: Given a pair of real images from domain $A$ (top-left) and $B$ (bottom-right), we smoothly transition between them by interpolating their latent codes in $\mathcal { W } +$ , as well as the model weights. $t _ { 1 }$ is the interpolation coefficient for the latent codes, while $t _ { 2 }$ is the coefficient for the model weights. In the same column (fixed $t _ { 1 }$ ), we obtain a smooth transition between the domains (different species, but the same pose and fur color). In the same row (fixed $t _ { 2 }$ ), we have a smooth transition inside the same domain (same species, varying pose and fur color). Any trajectory between the top-left and bottom-right corners yields a smooth morph sequence between two input images. See the accompanying video, which progresses along the diagonal $t _ { 1 } = t _ { 2 }$ .
|
| 430 |
+
|
| 431 |
+

|
| 432 |
+
Figure 25: Given a pair of real images from domain $A$ (top-left) and $B$ (bottom-right), we smoothly transition between them by interpolating their latent codes in $\mathcal { W } +$ , as well as the model weights. $t _ { 1 }$ is the interpolation coefficient for the latent codes, while $t _ { 2 }$ is the coefficient for the model weights. In the same column (fixed $t _ { 1 }$ ), we obtain a smooth transition between the domains (different species, but the same pose and fur color). In the same row (fixed $t _ { 2 }$ ), we have a smooth transition inside the same domain (same species, varying pose and fur color). Any trajectory between the top-left and bottom-right corners yields a smooth morph sequence between two input images. See the accompanying video, which progresses along the diagonal $t _ { 1 } = t _ { 2 }$ .
|
| 433 |
+
|
| 434 |
+

|
| 435 |
+
Figure 26: Given a pair of real images from domain $A$ (top-left) and $B$ (bottom-right), we smoothly transition between them by interpolating their latent codes in $\mathcal { W } +$ , as well as the model weights. $t _ { 1 }$ is the interpolation coefficient for the latent codes, while $t _ { 2 }$ is the coefficient for the model weights. In the same column (fixed $t _ { 1 }$ ), we obtain a smooth transition between the domains (different species, but the same pose and similar fur/hair color). In the same row (fixed $t _ { 2 }$ ), we have a smooth transition inside the same domain (same species, varying pose and color). Any trajectory between the topleft and bottom-right corners yields a smooth morph sequence between two input images. See the accompanying video, which progresses along the diagonal $t _ { 1 } = t _ { 2 }$ .
|
| 436 |
+
|
| 437 |
+

|
| 438 |
+
Figure 27: Given a pair of real images from domain $A$ (top-left) and $B$ (bottom-right), we smoothly transition between them by interpolating their latent codes in $\mathcal { W } +$ , as well as the model weights. $t _ { 1 }$ is the interpolation coefficient for the latent codes, while $t _ { 2 }$ is the coefficient for the model weights. In the same column (fixed $t _ { 1 }$ ), we obtain a smooth transition between the domains (different species, but the same pose and similar fur/hair color). In the same row (fixed $t _ { 2 }$ ), we have a smooth transition inside the same domain (same species, varying pose and color). Any trajectory between the topleft and bottom-right corners yields a smooth morph sequence between two input images. See the accompanying video, which progresses along the diagonal $t _ { 1 } = t _ { 2 }$ .
|
| 439 |
+
|
| 440 |
+

|
| 441 |
+
Figure 28: Demonstration of our zero-shot dog yaw regression model. The images are from AFHQ dog dataset, split into several bins (rows), based on the regressed yaw values. The images shown are randomly picked from each bin (no cherry picking). The estimated yaw values capture the correct tendency (right facing to left facing), and in most cases appear to be close to the actual yaw degree.
|
| 442 |
+
|
| 443 |
+

|
| 444 |
+
Figure 29: Demonstration of our zero-shot cat yaw regression model. The images are from AFHQ cat dataset, split into several bins (rows), based on the regressed yaw values. The images shown are randomly picked from each bin (no cherry picking). The estimated yaw values capture the correct tendency (right facing to left facing), and in most cases appear to be close to the actual yaw degree.
|
| 445 |
+
|
| 446 |
+

|
| 447 |
+
Figure 30: Starting from a pretrained StyleGAN2 model for FFHQ $1 0 2 4 \times 1 0 2 4$ resolution as parent, we use its weights to initialize models for $5 1 2 \times 5 1 2$ or $2 5 6 \times 2 5 6$ resolution. Before fine tuning (FT), it only generates low contrast images. After fine tuning (“Original” column), similar images with the same attributes (identity, hair length, gender, etc.) as parent model are generated given the same code $z \in { \mathcal { Z } }$ . Note that the generated images are not pixel-wise identical, but the different style channels retain their semantic function, as demonstrated by the four rightmost columns.
|
| 448 |
+
|
| 449 |
+

|
| 450 |
+
Figure 31: A comparison between layer swapping and model weight interpolation. We demonstrate transitioning between FFHQ and Mega using three different ways. Layer swapping: $A B$ means using a hybrid model whose low resolution layers come from model A, and high resolution layers from model B, while Layer swapping: $B A$ means the opposite roles (low from B, high from A). The resolution at which the switching occurs is shown above each result. The swapping resolution used by Toonify (Pinkney & Adler, 2020) is either $1 6 \times 1 6$ or $3 2 \times 3 2$ . Weight interpolation instead linearly interpolates the weights of all layers between model A and B. The interpolation ratio is shown shown above each result.
|
| 451 |
+
|
| 452 |
+

|
| 453 |
+
Figure 32: A comparison between layer swapping and model weight interpolation. Here we demonstrate transitioning between AFHQ dog and cat. Refer to Figure 31 for more details.
|
| 454 |
+
|
| 455 |
+

|
| 456 |
+
Figure 33: A comparison between layer swapping and model weight interpolation. Here we demonstrate transitioning between FFHQ and AFHQ dog. Refer to Figure 31 for more details.
|
| 457 |
+
|
| 458 |
+

|
| 459 |
+
Figure 34: Generative image translation from parent FFHQ model to child LSUN church model and grandchild FFHQ using the same latent code $z$ . Since the domain gap between FFHQ and LSUN church is too large, we can barely see any correspondence. But the parent FFHQ model and grandchild FFHQ models generate faces with highly similar attributes and identity. This implies that knowledge that was not transferred from task A (FFHQ generation) to task B (LSUN church generation), is only hidden in the latter model’s latent space, rather than forgotten.
|
| 460 |
+
|
| 461 |
+

|
| 462 |
+
Figure 35: Applying the “Beard” and “Black hair” manipulation directions from parent FFHQ model to a child LSUN church model. The manipulation directions are discovered by StyleCLIP (Patashnik et al., 2021). Most manipulation directions from the FFHQ parent do not change anything in the child church model. Surprisingly, the beard direction from FFHQ appear to control the amount of trees in the church model to some extent, and the black hair direction from FFHQ makes the church building darker in the child model.
|
| 463 |
+
|
| 464 |
+

|
| 465 |
+
Figure 36: Semantic alignment between parent and grandchild model. We first train a StyleGAN model on FFHQ (parent), then fine tune on LSUN church (child), and finally fine tune back to FFHQ (grandchild). We can see that the same channel still controls the same attribute between parent and grandchild model. Interestingly, channel 15 45 controls lipstick in the parent model, but makes the face slightly pink in the grandchild model. Although the exact function has changed after fine tuning, it is still semantically related to the original function.
|
| 466 |
+
|
| 467 |
+

|
| 468 |
+
Figure 37: We demonstrate the ability of our method to perform I2I tasks that only change texture, while preserving the structure. Although this dataset has paired edge maps and shoe images, the pairing information is not used by our method. We slightly blur the edge maps to make the images more continuous. We first train a StyleGAN model on the shoes dataset (parent), then fine tune on edge maps dataset (child). Since edge maps mostly represent the structure of objects, and do not contain color or texture, we train an e4e encoder to $\mathcal { W } +$ from whose output we only use the parts that control generator resolutions below $3 2 \times 3 2$ (same as was done for multi-modal image translation). The parts that control higher-resolution layers are sampled, yielding multiple possible shoe images (sharing the same structure) for each edge map.
|
| 469 |
+
|
| 470 |
+
<table><tr><td></td><td>Mega</td><td>Metface</td><td>Dog</td><td>Cat</td><td>Wild</td><td>Unrelated FFHQ</td></tr><tr><td>L1 in W</td><td>0.033</td><td>0.057</td><td>0.162</td><td>0.172</td><td>0.141</td><td>0.391</td></tr></table>
|
| 471 |
+
|
| 472 |
+
Table 7: Average L1 distance between $w \in \mathcal { W }$ vectors mapped from the same latent code $z \in { \mathcal { Z } }$ for different pairs of models. Using a pretrained FFHQ model as parent, it is fine-tuned on different datasets separately. We sample 100K random $z$ vectors and compute the corresponding $w$ for each model. The mean change (per coordinate of $w$ ) is reported for each child model. It may be clearly seen that in models fine-tuned to nearby domains (Mega, Metface) the change in $w$ is much smaller than to more distant domains (Dog, Cat, Wild), and an order of magnitude smaller than the difference to another FFHQ model, trained independently. These results quantitatively demonstrate that the change in the mapping function is very small for similar domains, larger for more distant domains, but even for distant domains the mapping functions are more closely related than those of two separately trained models.
|
md/dev/RRGVCN8kjim/RRGVCN8kjim.md
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SPARSE DETR: EFFICIENT END-TO-END OBJECT DETECTION WITH LEARNABLE SPARSITY
|
| 2 |
+
|
| 3 |
+
Byungseok $\mathbf { R o h } ^ { 1 * \dagger }$ , JaeWoong $\mathbf { S h i n ^ { 2 * \ddagger } }$ , Wuhyun $\mathbf { S h i n ^ { 1 * } }$ , Saehoon Kim1
|
| 4 |
+
1KakaoBrain
|
| 5 |
+
2Lunit
|
| 6 |
+
|
| 7 |
+
{peter.roh,aiden.hsin,sam.kim}@kakaobrain.com jwoong.shin@lunit.io
|
| 8 |
+
|
| 9 |
+
# ABSTRACT
|
| 10 |
+
|
| 11 |
+
DETR is the first end-to-end object detector using a transformer encoder-decoder architecture and demonstrates competitive performance but low computational efficiency on high resolution feature maps. The subsequent work, Deformable DETR, enhances the efficiency of DETR by replacing dense attention with deformable attention, which achieves $1 0 \times$ faster convergence and improved performance. Deformable DETR uses the multiscale feature to ameliorate performance, however, the number of encoder tokens increases by $2 0 \times$ compared to DETR, and the computation cost of the encoder attention remains a bottleneck. In our preliminary experiment, we observe that the detection performance hardly deteriorates even if only a part of the encoder token is updated. Inspired by this observation, we propose Sparse DETR that selectively updates only the tokens expected to be referenced by the decoder, thus help the model effectively detect objects. In addition, we show that applying an auxiliary detection loss on the selected tokens in the encoder improves the performance while minimizing computational overhead. We validate that Sparse DETR achieves better performance than Deformable DETR even with only $10 \%$ encoder tokens on the COCO dataset. Albeit only the encoder tokens are sparsified, the total computation cost decreases by $38 \%$ and the frames per second (FPS) increases by $42 \%$ compared to Deformable DETR. Code is available at https://github.com/kakaobrain/sparse-detr.
|
| 12 |
+
|
| 13 |
+
# 1 INTRODUCTION
|
| 14 |
+
|
| 15 |
+
In recent years, we have witnessed the dramatic advancement and the success of object detection in deep learning. Diverse object detection methods have been proposed, but the existing algorithms that perform positive matching with the ground truth as a heuristic way require non-maximum suppression (NMS) post-processing of near-duplicate predictions. Recently, Carion et al. (2020) has introduced a fully end-to-end detector DETR by eliminating the need for NMS post-processing through a set-based objective. The training objective is designed by employing the Hungarian algorithm that considers both classification and regression costs, and achieves highly competitive performance. However, DETR is unable to use multi-scale features such as feature pyramid networks (Lin et al., 2017), which are commonly used in object detection to improve the detection of small objects. The main reason is increased memory usage and computation by adding Transformer (Vaswani et al., 2017) architecture. As a result, its ability to detect small objects is relatively poor.
|
| 16 |
+
|
| 17 |
+
To address this problem, Zhu et al. (2021) has proposed a deformable-attention inspired by the deformable convolution (Dai et al., 2017) and reduced the quadratic complexity to linear complexity through key sparsification in the attention module. By using deformable attention, deformable DETR addresses the slow convergence and high complexity issue of DETR, which enables the encoder to use multi-scale features as an input and significantly improves performance on detecting small objects. However, using the multi-scale features as an encoder input increases the number of tokens to be processed by about 20 times. Eventually, despite efficient computation for the same token length, the overall complexity increases back again, making the model inference slower even than vanilla DETR.
|
| 18 |
+
|
| 19 |
+
In general, natural images often contain large background regions irrelevant to the objects of interest, and accordingly, in end-to-end detectors, the tokens corresponding to the background also occupy a significant portion. In addition, the importance of each regional feature is not identical, which has been proven by the two-stage detectors successfully do their job by focusing only on the foreground. It suggests that there exists considerable regional redundancy that can be reduced in the detection tasks and seeking to devise an efficient detector focusing on the salient regions is a necessary and natural direction. In our preliminary experiments, we observe the following: (a) during inference of a fully-converged Deformable DETR model on the COCO validation dataset, the encoder tokens referenced by the decoder account for only about $45 \%$ of the total, and (b) retraining a new detector while updating only the encoder tokens preferred by the decoder from another fully-trained detector, barely suffers performance loss(0.1 AP degradation). See Appendix A.9 for the details.
|
| 20 |
+
|
| 21 |
+
Inspired by this observation, we propose a learnable decoder cross-attention map predictor to sparsify encoder tokens. In the existing methods (Carion et al., 2020; Zhu et al., 2021), the encoder takes all the tokens, i.e. the backbone features combined with corresponding positional embeddings, as input without discrimination. Meanwhile, our approach distinguishes encoder tokens to be referenced later in the decoder and considers only those tokens in self-attention. Therefore, this can significantly reduce the number of encoder tokens involved in the computation and reduce the total computational cost. We further propose the encoder auxiliary loss for selected encoder tokens to improve detection performance while minimizing computational overhead. The proposed auxiliary loss not only improves performance, but also allows training a larger number of encoder layers.
|
| 22 |
+
|
| 23 |
+
Extensive experiments on the COCO 2017 benchmark (Lin et al., 2014) demonstrate that Sparse DETR effectively reduces computational cost while achieving better detection performance. Without bells and whistles, Sparse DETR using Swin-T (Liu et al., 2021) backbone achieves $4 8 . 2 \mathrm { \ A P }$ with $38 \%$ reduction of the entire computational cost compared to the 48.0 AP baseline and $4 9 . 2 \mathrm { \ A P }$ with $23 \%$ reduction. In the case of the experiment that achieves 48.2 AP using only $10 \%$ of encoder tokens, the computational cost of the transformer encoder block is reduced by approximately $82 \%$ .
|
| 24 |
+
|
| 25 |
+
We summarize our contributions as follows:
|
| 26 |
+
|
| 27 |
+
• We propose encoder token sparsification method for an efficient end-to-end object detector, by which we lighten the attention complexity in the encoder. This efficiency enables stacking more encoder layers than Deformable DETR, leading to performance improvement within the same computational budget.
|
| 28 |
+
• We propose two novel sparsification criteria to sample the informative subset from the entire token set: Objectness Score $( O S )$ and Decoder cross-Attention Map (DAM). Based on the decoder cross-attention map criterion, the sparsified model preserves detection performance even when using only $10 \%$ of the whole tokens.
|
| 29 |
+
We adopt an encoder auxiliary loss only for the selected tokens. This additional loss not only stabilizes the learning process, but also greatly improves performance, with only marginally increased training time.
|
| 30 |
+
|
| 31 |
+
# 2 RELATED WORK
|
| 32 |
+
|
| 33 |
+
Efficient computation in vision transformers. It is a well-known problem that the attention computation in Transformers incurs the high time and memory complexity. The vision transformers need to digest even bigger token sets as input so that a large body of works (Parmar et al., 2018; Child et al., 2019a; Ho et al., 2019; Wang et al., 2020; Katharopoulos et al., 2020; Choromanski et al., 2021; Kitaev et al., 2020) has been proposed lightweight attention mechanisms for them. Most of those works shed light on the complexity that resides only in a single-scale attention module, which hinders direct extension to the multi-scale features generally required in object detection.
|
| 34 |
+
|
| 35 |
+
One of the promising approaches for the lighter transformer attention is input-dependent token sparsification. DynamicViT (Rao et al., 2021) and IA-RED $^ 2$ (Pan et al., 2021), similar to our work, both propose jointly-learned token selectors generating the sparsity patterns to be overlaid on the input tokens. Those approaches mainly focus on sparsifying a backbone network evaluated on the classification tasks, while our interest lies in a sparse encoder of the end-to-end object detectors.
|
| 36 |
+
|
| 37 |
+
On the other hand, there has been a line of works sharing the spirit with ours in that they aim at sparse transformers in the DETR-based framework. Deformable DETR (Zhu et al., 2021) conducts sparse attention computation by sampling only a fraction of the entire key set with learnable 2-d offsets, which enables to use multi-scale feature maps with a reasonable computational cost. It can be viewed as a key sparsification method but with dense queries, while our approach further reduces the query set pursuing even more sparsity. PnP-DETR (Wang et al., 2021) shortens the token length of the transformer encoder by introducing the Polling and Pull (PnP) module to sample the foreground tokens and condense the background tokens into a smaller set. However, their method cannot naively be integrated with Deformable DETR, since their sparsification breaks the 2d spatial structure of the token set assumed in the deformable attention. On the contrary, Sparse DETR preserves the 2d sample space of the set and can be seamlessly combined with the deformable attention, which facilitates handling the multi-scale features. Thus, our approach gets benefits from both the deformable key sampling and the proposed query sparsification. Most of all, we propose explicit objectives for the token selection network, whereas the aforementioned works have no explicit objective implying their beliefs in a good selection strategy, merely relying on the final detection objective.
|
| 38 |
+
|
| 39 |
+
Auxiliary Loss. Auxiliary loss (Lee et al., 2015; Szegedy et al., 2015) is widely adopted to deliver gradients to the early layers of deep networks. DETR variants employ auxiliary Hungarian matching objectives at the end of every decoder layer with extra FFN heads so that each decoder layer directly learns to detect the correct number of objects out of the decoder’s outputs. Unlike the decoder’s object queries whose number is relatively small(e.g. 300), the number of encoder’s tokens has much larger scales when using multi-scale features. Thus, extending the layerwise auxiliary loss to the multi-scale encoder increases the training time cost by feeding too many tokens to the attached FFN heads. In Sparse DETR, thanks to the sparsity already induced in the encoder, we can instantly economize that cost while enjoying the auxiliary gradients in a wider range of intermediate layers.
|
| 40 |
+
|
| 41 |
+
# 3 APPROACH
|
| 42 |
+
|
| 43 |
+
In this section, we present our main contributions: (a) formulating a generalized saliency-based token sparsification scheme for the encoder, (b) proposing the effective saliency criteria with which that scheme can practically work, and (c) employing the encoder auxiliary losses and the top- $k$ decoder query selection to improve the performance. Before describing the details, we revisit the key components of DETR (Carion et al., 2020) and Deformable DETR (Zhu et al., 2021).
|
| 44 |
+
|
| 45 |
+
# 3.1 PRELIMINARY
|
| 46 |
+
|
| 47 |
+
DETR. DETR takes the flattened spatial feature map ${ \bf x } _ { \mathrm { f e a t } } \in \mathbb { R } ^ { N \times D }$ from a backbone network into the transformer encoder, where $N$ denotes the number of tokens (i.e. features) and $D$ denotes token dimension. The encoder iteratively updates $\mathbf { x } _ { \mathrm { f e a t } }$ by several vanilla self-attention modules. Then, the transformer decoder takes both the refined encoder tokens (i.e. encoder output) and $M$ learnable object queries $\{ q _ { i } \} _ { i = 1 \cdots M }$ as inputs and predicts a tuple of a class score $\mathbf { c } \in [ \bar { 0 } , 1 ] ^ { C }$ and a bounding box $\mathbf { b } \in [ 0 , 1 ] ^ { 4 }$ for each object query $q _ { i }$ , denoted as $\{ \hat { \bf y } _ { i } \} = \{ ( { \bf c } _ { i } , { \bf b } _ { i } ) \}$ , where $C$ denotes the number of classes. All components including the backbone network are jointly trained by performing the bipartite matching between the ground truth $\left\{ \mathbf { y } _ { i } \right\}$ and predictions $\left\{ \hat { \mathbf { y } } _ { i } \right\}$ .
|
| 48 |
+
|
| 49 |
+
Deformable DETR. Deformable DETR replaces the vanilla dense attention, which is the main computational bottleneck in DETR, with a deformable attention module. This significantly reduces the computational cost and improves the convergence. Suppose that we have the same size of a set of queries (denoted as $\Omega _ { q } )$ ) and a set of keys (denoted as $\Omega _ { k }$ ), which means $| \Omega _ { q } | = | \Omega _ { k } | =$ $N$ . The conventional dense attention computes the attention weight $A _ { q k }$ for every pair $\{ ( q , k ) :$ $q \in \Omega _ { q } , k \in \Omega _ { k } \}$ , resulting in quadratic complexity with respect to $N$ . Deformable attention reduces this quadratic complexity into the linear one by only considering relevant keys for each query. Specifically, deformable attention computes attention weight $A _ { q k }$ for all queries and a small set of keys: $\{ ( q , \dot { k } ) : q \in \Omega _ { q } , k \in \Omega _ { q k } \}$ , where $\Omega _ { q k } \subset \Omega _ { k }$ and $\left| \Omega _ { q k } \right| = \mathbf { \bar { \Psi } } K \ll N$ .
|
| 50 |
+
|
| 51 |
+
Due to this key sparsification, Deformable DETR is able to use the multi-scale features of the backbone network, improving the detection performance of small objects significantly. Paradoxically, using the multi-scale feature increases the number of tokens in the transformer encoder by about $2 0 \times$ compared to DETR, making that the encoder becomes the computational bottleneck of deformable DETR. This motivates us to develop a sparsification method to reduce the number of tokens in the encoder aggressively, which is described in the next sections.
|
| 52 |
+
|
| 53 |
+

|
| 54 |
+
Figure 1: Attention complexity. The circles in the square matrix represent the attention between keys and queries. The gray/white circles correspond to preserved/removed connection respectively, and darker gray on the diagonal positions means where the token attends to itself. (a) Dense attention in DETR takes quadratic complexity. (b) Deformable DETR uses key sparsification, thus takes linear complexity. (c) Sparse DETR further uses query sparsification. Attention in Sparse DETR also takes linear complexity, but is much lighter than Deformable DETR’s.
|
| 55 |
+
|
| 56 |
+
# 3.2 ENCODER TOKEN SPARSIFICATION
|
| 57 |
+
|
| 58 |
+
In this section, we introduce our token sparsification scheme that the encoder module selectively refines a small number of encoder tokens. This encoder token subset is obtained from the backbone feature map $\mathbf { X } _ { \mathrm { f e a t } }$ with a certain criterion, which is described in the subsequent section. For features that are not updated in this process, the values of $\mathbf { X } _ { \mathrm { f e a t } }$ are passed through the encoder layers without being changed.
|
| 59 |
+
|
| 60 |
+
Formally, suppose that we have a scoring network $g : \mathbb { R } ^ { d } \mathbb { R }$ that measures saliency of each token in $\mathbf { x } _ { \mathrm { f e a t } }$ . We then define $\rho$ -salient regions $\Omega _ { s } ^ { \rho }$ as the top- $\cdot \rho \%$ tokens with the highest scores, for a given keeping ratio $\rho$ , i.e. $S = | \Omega _ { s } ^ { \rho } | = \rho \cdot | \Omega _ { q } | \ll | \Omega _ { q } | = N$ . Then, the $i$ -th encoder layer updates the features $\mathbf { x } _ { i - 1 }$ by:
|
| 61 |
+
|
| 62 |
+
$$
|
| 63 |
+
\mathbf { x } _ { i } ^ { j } = \left\{ \begin{array} { l l } { \mathbf { x } _ { i - 1 } ^ { j } } & { j \notin \Omega _ { s } ^ { \rho } } \\ { \operatorname { L N } ( \operatorname { F F N } ( \mathbf { z } _ { i } ^ { j } ) + \mathbf { z } _ { i } ^ { j } ) } & { j \in \Omega _ { s } ^ { \rho } , \mathrm { ~ w h e r e ~ } \mathbf { z } _ { i } ^ { j } = \operatorname { L N } ( \operatorname { D e f A t t n } ( \mathbf { x } _ { i - 1 } ^ { j } , \mathbf { x } _ { i - 1 } ) + \mathbf { x } _ { i - 1 } ^ { j } ) , } \end{array} \right.
|
| 64 |
+
$$
|
| 65 |
+
|
| 66 |
+
where DefAttn refers to deformable attention, LN to layer normalization (Ba et al., 2016), and FFN to a feed-forward network. Even in the case of unselected tokens, the values are still passed through the encoder layer, so they can be referenced as keys when updating the selected tokens. This means that the unselected tokens can hand over information to the selected tokens without losing the value of themselves while minimizing the computational cost. Here, we use deformable attention for refining tokens in $\Omega _ { s } ^ { \rho }$ , but the proposed encoder token sparsification is applicable regardless of which attention method the encoder uses.
|
| 67 |
+
|
| 68 |
+
Complexity of Attention Modules in Encoder. Deformable DETR reduces the attention complexity through key sparsification, and we further reduce the attention complexity through query sparsification, as shown in Fig. 1. Conventional dense attention in DETR requires quadratic complexity $O ( N ^ { 2 } )$ , where $N$ is the query length. Deformable attention requires linear complexity $O ( N K )$ , where $K \ll N$ is the number of keys for each query. Sparse attention requires only $O ( S K )$ , where $S \ll N$ is the number of salient encoder queries.
|
| 69 |
+
|
| 70 |
+
# 3.3 FINDING SALIENT ENCODER TOKENS
|
| 71 |
+
|
| 72 |
+
In this section, we introduce how to find a salient token set $\Omega _ { s } ^ { \rho }$ from a backbone feature $\mathbf { x } _ { \mathrm { f e a t } }$ . We propose a method for determining saliency using a cross attention map from the transformer decoder. Before presenting our approach, we first discuss a simple yet effective method based on the objectness scores obtained from a separate detection head. The limitation of this simple approach motivates us to develop an advanced one, which is described in the following paragraph.
|
| 73 |
+
|
| 74 |
+

|
| 75 |
+
Figure 2: Illustration on how to learn a scoring network by predicting binarized Decoder crossAttention Map (DAM), where a dashed orange arrow means a backpropagation path. The bottom box shows the forward/backward passes in Sparse DETR, and the top boxes present how to construct DAM for learning the scoring network. See Appendix A.1 for implementation details of scoring net.
|
| 76 |
+
|
| 77 |
+
Objectness Score. Measuring objectness per each input token (i.e. feature $\mathbf { x } _ { \mathrm { f e a t . } }$ ) of encoder is very natural to determine which ones from a backbone feature should be further updated in the transformer encoder. It is widely known that feature map from a pretrained backbone network is able to find the saliency of objects, which is why the region proposal network (RPN) has been successfully adopted in many object detectors (Ren et al., 2015; Dai et al., 2016; He et al., 2017). Inspired by this observation, we introduce an additional detection head and Hungarian loss to the backbone feature map, where the structure of the newly added head is the same as the one of the final detection head in the decoder. Then, we can select the top- $\rho \%$ encoder tokens with the highest class scores as a salient token set $\Omega _ { s } ^ { \rho }$ . This approach is effective to sparsify encoder tokens, but we believe that it is sub-optimal to the transformer decoder, because the selected encoder tokens from the separate detection head are not explicitly considered for the decoder.
|
| 78 |
+
|
| 79 |
+
Decoder Cross-Attention Map. We consider another approach to select a subset of encoder tokens that are highly relevant to the decoder in a more explicit manner. We observe that the crossattention maps from the transformer decoder could be used for measuring the saliency, because the decoder gradually attends to a subset of encoder output tokens that are favorable to detect objects as training continues. Motivated by this, we introduce a scoring network that predicts a pseudo groundtruth of the saliency defined by decoder cross-attention maps, and use it to determine which encoder tokens should be further refined on the fly. Fig. 2 summarizes how to train a scoring network, and details are presented below.
|
| 80 |
+
|
| 81 |
+
To determine the saliency of each input token of encoder $\mathbf { x } _ { \mathrm { f e a t } }$ , we have to aggregate the decoder cross-attentions between all object queries and the encoder output. This procedure produces a single map of the same size as the feature map from the backbone, which is defined as Decoder crossAttention Map (DAM). In the case of the dense attention, DAM can be easily obtained by summing up attention maps from every decoder layer. In case of deformable attention, for each encoder token, the corresponding value of DAM can be obtained by accumulating the attention weights of decoder object queries whose attention offsets are directed toward the encoder output tokens. Refer to the Appendix A.2 for the details in the DAM creation.
|
| 82 |
+
|
| 83 |
+
To train the scoring network, we binarize DAM so that the top- $\cdot \rho \%$ (by attention weights) of encoder tokens is only retained. This is because our goal is to find a small subset of encoder tokens that the decoder references the most, rather than precisely predicting how much each encoder token will be referenced by the decoder. This binarized DAM implies the one-hot target that indicates whether each encoder token is included in the top- $\cdot \rho \%$ most referenced encoder tokens. Then, we consider a 4-layer scoring network $g$ to predict how likely a given encoder token is included in the top- $\rho \%$ most referenced tokens, and the network is trained by minimizing the binary cross entropy (BCE) loss between the binarized DAM and prediction:
|
| 84 |
+
|
| 85 |
+
$$
|
| 86 |
+
\mathcal { L } _ { d a m } = - \frac { 1 } { N } \sum _ { i = 1 } ^ { N } \mathrm { { B C E } } ( g ( \mathbf { x } _ { \mathrm { { f e a t } } } ) _ { i } , \mathbf { D A M } _ { i } ^ { \mathrm { { b i n } } } ) ,
|
| 87 |
+
$$
|
| 88 |
+
|
| 89 |
+

|
| 90 |
+
Figure 3: Sparse DETR architecture. Sparse DETR introduces three additional components: (a) the scoring network, (b) auxiliary heads in the encoder, and (c) the auxiliary head to select the top- $k$ tokens for the decoder. Sparse DETR measures the saliency of encoder tokens by using the scoring network, and selects the top- $\cdot \rho \%$ tokens, which is referred to as (1) in the diagram. After refining only the selected tokens in the encoder blocks, the auxiliary head selects the top- $k$ tokens from the encoder output, which is served as the decoder object queries. This process is referred to as (2) in the diagram. In addition, we remark that additional auxiliary heads in each encoder block play a key role in achieving improved performance. Only sparsified encoder tokens are passed to the encoder auxiliary heads for efficiency. All auxiliary heads in the encoder and decoder are trained with a Hungarian loss as described in Deformable DETR (Zhu et al., 2021).
|
| 91 |
+
|
| 92 |
+
where $\mathrm { D A M } _ { i } ^ { \mathrm { b i n } }$ means the binarized DAM value of the ith encoder token.
|
| 93 |
+
|
| 94 |
+
One may say that since DAM in the early phase of training is not accurate, pruning out the encoder tokens based on the result in the decoder degrades the final performance or hurts the convergence. However, we empirically observe that the optimization is very stable even in the early phase of training, and achieves better performance compared to the method based on objectness score. We describe detailed comparisons in the experiments section.
|
| 95 |
+
|
| 96 |
+
# 3.4 ADDITIONAL COMPONENTS
|
| 97 |
+
|
| 98 |
+
In this section, we introduce two additional components: (a) auxiliary losses on the encoder tokens and (b) top- $k$ decoder queries selection. We empirically observe that these greatly help improve the final performance and stabilize the optimization. The overall architecture of Sparse DETR including these components is depicted in Fig. 3.
|
| 99 |
+
|
| 100 |
+
Encoder Auxiliary Loss. In DETR variants, auxiliary detection heads are attached to decoder tilayers, but not to encoder layers. Due to a significantly larger number of encoder tokens (about 18k tokens) compared to decoder tokens (about 300), encoder auxiliary heads will heavily increase the computational cost. In Sparse DETR, however, only part of encoder tokens are refined by the encoder, and adding auxiliary heads only for sparsified encoder tokens is not a big burden.
|
| 101 |
+
|
| 102 |
+
We empirically observe that applying an auxiliary detection head along with Hungarian loss on the selected tokens stabilizes the convergence of deeper encoders by alleviating the vanishing gradient issue and even improves the detection performance. We conjecture that, following the analysis in Sun et al. (2021), applying Hungarian loss at the intermediate layers helps distinguish the confusing features in the encoder, which contributes to the detection performance in the final head.
|
| 103 |
+
|
| 104 |
+
Top- $k$ Decoder Queries. In DETR and Deformable DETR, decoder queries are given by only learnable object queries or with predicted reference points via another head after the encoder. In Efficient DETR (Yao et al., 2021), decoder takes a part of encoder output as input, similar to RoI Pooling (Ren et al., 2015). Here, an auxiliary detection head is attached to the encoder output $\mathbf { x } _ { \mathrm { e n c } }$ and the head calculates the objectness (class) score of each encoder output. Based on the score, the top- $k$ encoder outputs are passed as decoder queries, similar to objectness score-based encoder token sparsification. Since this outperforms the methods based on learnable object queries or the two-stage scheme, we include this top- $k$ decoder query selection in our final architecture.
|
| 105 |
+
|
| 106 |
+
Table 1: Detection results of Sparse DETR on COCO 2017 val set. Top- $k$ & BBR denotes that we sample the top- $k$ object queries instead of using the learned object queries (Yao et al., 2021), and perform bounding box refinement in the decoder block (Zhu et al., 2021), respectively. Note that the proposed encoder auxiliary loss is only applied to Sparse DETR. FLOPs and FPS are measured in the same way as used in Zhu et al. (2021). The results marked by $\dag , \ddag$ are the reported ones from Zhu et al. (2021) and Wang et al. (2021), respectively.
|
| 107 |
+
|
| 108 |
+
<table><tr><td rowspan="2">Method</td><td rowspan="2">Epochs</td><td rowspan="2">Keeping ratio (p)</td><td rowspan="2">Top-k &BBR</td><td colspan="6">AP50 AP75 APs APM APL</td><td rowspan="2"></td><td colspan="2"></td></tr><tr><td>AP</td><td></td><td></td><td></td><td></td><td></td><td>params FLOPs FPS</td><td></td></tr><tr><td colspan="10">ResNet-50 backbone:</td><td></td><td></td><td></td><td></td></tr><tr><td>F-RCNN-FPNt</td><td>109</td><td>N/A</td><td></td><td>42.0</td><td>62.1</td><td>45.5</td><td>26.6</td><td>45.4</td><td>53.4</td><td>42M</td><td>180G</td><td></td><td>26</td></tr><tr><td>DETRt</td><td>500</td><td>100%</td><td></td><td>42.0</td><td>62.4</td><td>44.2</td><td>20.5</td><td>45.8</td><td>61.1</td><td></td><td>41M</td><td>86G</td><td>28</td></tr><tr><td>DETR-DC5†</td><td>500</td><td>100%</td><td></td><td>43.3</td><td>63.1</td><td>45.9</td><td>22.5</td><td>47.3</td><td></td><td>61.1</td><td>41M</td><td>187G</td><td>12</td></tr><tr><td rowspan="2">PnP-DETR$</td><td>500</td><td>33%</td><td></td><td>41.1</td><td>61.5</td><td>43.7</td><td>20.8</td><td>44.6</td><td>60.0</td><td></td><td>-</td><td>1</td><td>-</td></tr><tr><td>500</td><td>50%</td><td></td><td>41.8</td><td>62.1</td><td>44.4</td><td>21.2</td><td>45.3</td><td>60.8</td><td>-</td><td></td><td>1</td><td>-</td></tr><tr><td rowspan="2">PnP-DETR-DC5‡</td><td>500</td><td>33%</td><td></td><td>42.7</td><td>62.8</td><td></td><td>45.1</td><td>22.4</td><td>46.2</td><td>60</td><td>-</td><td>-</td><td>-</td></tr><tr><td>500</td><td>50%</td><td></td><td>43.1</td><td>63.4</td><td>45.3</td><td>22.7</td><td>46.5</td><td></td><td>61.1</td><td>1</td><td>-</td><td>-</td></tr><tr><td rowspan="2">Deformable-DETR</td><td>50</td><td>100%</td><td></td><td>43.9</td><td>62.8</td><td>47.8</td><td>26.1</td><td></td><td>47.4</td><td>58.0</td><td>40M</td><td>173G</td><td>19.1</td></tr><tr><td>50</td><td>100% 10%</td><td>√</td><td>46.0</td><td>65.2</td><td>49.8</td><td>28.2</td><td>49.1</td><td></td><td>61.0</td><td>41M</td><td>177G</td><td>18.2</td></tr><tr><td rowspan="5">Sparse-DETR</td><td>50 50</td><td></td><td>√</td><td></td><td>45.3 65.8</td><td>49.3</td><td>28.4</td><td></td><td>48.3</td><td>60.1</td><td>41M</td><td>105G</td><td>25.3</td></tr><tr><td></td><td>20%</td><td>√</td><td></td><td>45.6 65.8</td><td></td><td>49.6</td><td>28.5</td><td>48.6</td><td>60.4</td><td>41M</td><td>113G</td><td>24.8</td></tr><tr><td>50</td><td>30%</td><td>√</td><td>46.0</td><td>65.9</td><td>49.7</td><td></td><td>29.1</td><td>49.1</td><td>60.6</td><td>41M</td><td>121G</td><td>23.2</td></tr><tr><td>50</td><td>40%</td><td>√</td><td>46.2</td><td>66.0</td><td>50.3</td><td>28.7</td><td></td><td>49.0</td><td>61.4</td><td>41M</td><td>128G</td><td>21.8</td></tr><tr><td>50</td><td>50%</td><td>√</td><td>46.3</td><td>66.0</td><td>50.1</td><td>29.0</td><td>49.5</td><td></td><td>60.8</td><td>41M</td><td>136G</td><td>20.5</td></tr><tr><td colspan="2">Swin-T backbone:</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 colspan="2">DETR</td><td>500</td><td>100%</td><td></td><td>45.4</td><td>66.2</td><td>48.1</td><td>22.9</td><td>49.5</td><td>65.9</td><td>45M</td><td>92G</td><td>26.8</td></tr><tr><td colspan="2">Deformable-DETR</td><td>50</td><td>100%</td><td></td><td>45.7</td><td>65.3</td><td>49.9</td><td>26.9</td><td>49.4</td><td>61.2</td><td>40M</td><td>180G</td><td>15.9</td></tr><tr><td colspan="2"></td><td>50</td><td>100%</td><td>√</td><td>48.0</td><td>68.0</td><td>52.0</td><td>30.3</td><td>51.4</td><td>63.7</td><td>41M</td><td>185G</td><td>15.4</td></tr><tr><td colspan="2" rowspan="6">Sparse-DETR</td><td>50</td><td>10%</td><td>√</td><td>48.2</td><td>69.2</td><td>52.3</td><td>29.8</td><td>51.2</td><td>64.5</td><td>41M</td><td>113G</td><td>21.2</td></tr><tr><td>50</td><td></td><td>20%</td><td>√</td><td>48.8</td><td>69.4</td><td>53.0</td><td></td><td></td><td></td><td>41M</td><td>121G</td><td>20.0</td></tr><tr><td>50</td><td>30%</td><td></td><td>√</td><td>49.1</td><td>69.5</td><td></td><td>30.4 31.4</td><td>51.9 52.5</td><td>64.8 65.1</td><td>41M</td><td>129G</td><td>18.9</td></tr><tr><td>50</td><td></td><td></td><td>√</td><td>49.2</td><td>69.5</td><td>53.5 53.5</td><td>31.4</td><td>52.9</td><td>64.8</td><td>41M</td><td>136G</td><td>18.0</td></tr><tr><td>50</td><td>40% 50%</td><td>√</td><td></td><td>49.3</td><td>69.5</td><td>53.3</td><td>32.0</td><td>52.7</td><td>64.9</td><td>41M</td><td>144G</td><td>17.2</td></tr></table>
|
| 109 |
+
|
| 110 |
+
# 4 EXPERIMENTS
|
| 111 |
+
|
| 112 |
+
We compare Sparse DETR with the conventional object detectors, including the recently proposed ones in the DETR family. In addition, we conduct an ablation study to support our claims in Section 3, presenting the performance comparison between token selection criteria (OS vs. DAM), the effectiveness of the encoder auxiliary loss, and the dynamic sparsification during inference.
|
| 113 |
+
|
| 114 |
+
Implementation Details. We use ResNet-50 (He et al., 2016) and Swin Transformer (Liu et al., 2021) as pre-trained backbone networks, where Swin Transformer is one of the state-of-the-art architecture in the ViT family. We stack 6 encoder and 6 decoder layers, each with an auxiliary head at the end. We train the model on a $4 \times \mathsf { V } 1 0 0$ GPU machine with a total batch size of 16, for 50 epochs, where the initial learning rate is 0.0002 and decayed by 1/10 at the 40 epoch. Unless otherwise specified, we use the same hyperparameters as in Deformable DETR.
|
| 115 |
+
|
| 116 |
+
# 4.1 COMPARISON WITH OBJECT DETECTION BASELINES
|
| 117 |
+
|
| 118 |
+
Baselines. We compare Sparse DETR with Faster-RCNN with FPN (Lin et al., 2017), DETR (Carion et al., 2020), Deformable DETR (Zhu et al., 2021), and $\mathrm { P n P }$ DETR (Wang et al., 2021). We also compare with DETR and Deformable DETR that uses Swin-Tiny (Liu et al., 2021) as a backbone. Here, for brevity, we denote Deformable DETR with the top- $k$ object query selection and bounding box refinement, as Deformable ${ \mathrm { D E T R } } +$ . In Sparse DETR, encoder tokens are sparsified with keeping ratios of $10 \%$ , $20 \%$ , $30 \%$ , $40 \%$ , and $50 \%$ , using DAM criterion. We demonstrate detection performance and inference costs on COCO val2017 dataset.
|
| 119 |
+
|
| 120 |
+
Result. Table 1 shows the results of Sparse DETR and the other baselines on COCO val2017 set. Remarkably, on the ResNet-50 backbone, Sparse DETR with a keeping ratio over $30 \%$ outperforms all the baselines while minimizing the computational cost. Even with the keeping ratio reduced down to $10 \%$ , Sparse DETR still performs better than most baselines except for Deformable ${ \mathrm { D E T R } } +$ . More surprisingly, on the Swin-T backbone, Sparse DETR only with the keeping ratio $10 \%$ outperforms all the baselines with no exception, while improving FPS by $3 8 \%$ compared to Deformable DETR $^ +$ .
|
| 121 |
+
|
| 122 |
+

|
| 123 |
+
Figure 4: Selection criteria. Comparison of the performance with respect to encoder token selection criteria for different backbones.
|
| 124 |
+
|
| 125 |
+

|
| 126 |
+
Figure 5: Correlation graph. Correlation graphs of OS and DAM during training.
|
| 127 |
+
|
| 128 |
+
Remark that, compared to the most competitive baseline, Deformable $\mathrm { D E T R + }$ , the improvement in $\mathsf { A P } _ { L }$ is relatively noticeable on the Swin-T backbone even under the extreme sparsity of $10 \%$ , while the performance gap on the ResNet-50 backbone comes evenly from different sizes of objects. We conjecture that it is because a single token in Swin-T can hold a wider region of information than the one in ResNet-50, so even if we aggressively sparsify the encoder token, the network seems to have enough information to detect objects.
|
| 129 |
+
|
| 130 |
+
# 4.2 COMPARISON BETWEEN TOKEN SELECTION CRITERIA
|
| 131 |
+
|
| 132 |
+
Baselines. To verify the benefits of the proposed saliency criteria, we compare three token sparsification criteria: random, Objectness Score (OS), and Decoder cross-Attention Map (DAM). The random baseline samples a fixed ratio of arbitrary tokens. Note that the proposed encoder auxiliary loss is applied for all the methods.
|
| 133 |
+
|
| 134 |
+
Result. As illustrated in Fig. 4, the random strategy suffers noticeable performance degradation. On the other hand, the DAM-based model outperforms the OS-based model at every ratio and almost catches up with the non-sparse baseline when using $50 \%$ of encoder tokens. See the Appendix A.4 for detailed results of this experiment.
|
| 135 |
+
|
| 136 |
+
To analyze the reason that DAM-based model outperforms its counterpart, we measure the overlap between the encoder tokens referred by the decoder and the tokens refined by the encoder. As a metric, we compute a scalar correlation Corr as:
|
| 137 |
+
|
| 138 |
+
$$
|
| 139 |
+
\mathrm { \Gamma } _ { C o r r } : = \frac { \sum _ { x \in \Omega _ { D } \cap \Omega _ { s } ^ { \rho } } \mathrm { D A M } _ { x } } { \sum _ { x \in \Omega _ { D } } \mathrm { D A M } _ { x } } ,
|
| 140 |
+
$$
|
| 141 |
+
|
| 142 |
+
where $\Omega _ { D }$ is the encoder token set referred by the decoder and $\mathrm { D A M } _ { x }$ is the DAM-value corresponding to token $x$ . This Corr metric indicates the ratio of tokens polished by the encoder among the tokens referred by the decoder.
|
| 143 |
+
|
| 144 |
+
Fig. 5 demonstrates that Corr of DAM-based model rises higher than that of OS-based model. This result implies that DAM-based model is a more suitable sparsification method for the decoder, because the tokens referenced by the decoder are explicitly refined in the encoder, which achieves better detection performance. See the Appendix A.4 for detailed results of this experiment.
|
| 145 |
+
|
| 146 |
+

|
| 147 |
+
Figure 6: Ablation of # encoder layers.
|
| 148 |
+
Figure 7: Dynamic sparsification.
|
| 149 |
+
|
| 150 |
+
# 4.3 EFFECTIVENESS OF THE ENCODER AUXILIARY LOSS
|
| 151 |
+
|
| 152 |
+
Owing to the sparsified token set in our model, we can apply the auxiliary loss to the encoder layers without sacrificing too much computational cost. Apart from improved efficiency and performance, we find another benefit of the encoder auxiliary loss that allows us to safely stack more encoder layers without failing to converge.
|
| 153 |
+
|
| 154 |
+
As shown in Fig. 6, the encoder auxiliary loss not only enhances detection performance, but also consistently increases detection performance as the encoder layers doubled to 12. However, we observe that the training without its assistance utterly fails when using 12 encoder layers. We argue that gradient propagated through decoder cross-attention vanishes as we stack more encoder layers, thus intermediate gradients from the auxiliary loss are required. The observations reported in Appendix A.5 supports this assertion and Appendix A.6 details the results of Fig. 6.
|
| 155 |
+
|
| 156 |
+
# 4.4 DYNAMIC SPARSIFICATION FOR INFERENCE STAGE
|
| 157 |
+
|
| 158 |
+
To deploy the models in various hardware conditions of real-world applications, one often should retrain them at different scales according to the performance-computation trade-off required. We evaluate if our model trained with a fixed sparsity can adapt well to dynamic sparsity at inference time to check out Sparse DETR can avoid that hassle. Figure 7 shows the performance under the varied keeping ratio $( \rho )$ during inference when the model trained using the Swin-T backbone and $30 \%$ of encoder tokens with the DAM-based method. When the inference keeping ratio is small, the performance of dynamic sparsification is slightly degraded, but the overall performance is satisfactory at various keeping ratios given that only a single model is used.
|
| 159 |
+
|
| 160 |
+
PnP DETR introduces dynamic ratio training to achieve similar performance to the fixed keeping ratio counterpart. However, without the additional trick, it suffers significant performance degradation, for instance, $5 . 0 \ \mathrm { A P }$ drop when training/inference keeping ratio is 0.33/0.5, despite the increased number of encoder tokens. On the contrary, Sparse DETR achieves 0.2 AP improvement in a similar condition where the training/inference keeping ratio is 0.3/0.5. To conclude, our method shows better robustness compared to $\mathrm { P n P }$ DETR without further treatment, showing a greater potential of dynamic adaptation to different hardware environments. Note that any technique such as dynamic ratio training is orthogonal to our method and introducing it may bring even more robustness.
|
| 161 |
+
|
| 162 |
+
# 5 CONCLUSION
|
| 163 |
+
|
| 164 |
+
In this paper, we have presented encoder token sparsification algorithm that lowers the computational cost of the encoder, which is a computational bottleneck in the DETR and Deformable DETR. By doing so, the proposed Sparse DETR architecture outperforms the Deformable DETR even when using only $10 \%$ of the encoder token, and decreases the overall computation by $38 \%$ , and increases the FPS by $42 \%$ compared to the Deformable DETR. We hope that our proposed method will provide insights to effectively detect objects in the transformer structure in the future.
|
| 165 |
+
|
| 166 |
+
# REFERENCES
|
| 167 |
+
|
| 168 |
+
Lei Jimmy Ba, Jamie Ryan Kiros, and Geoffrey E. Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016.
|
| 169 |
+
|
| 170 |
+
Alexei Baevski and Michael Auli. Adaptive input representations for neural language modeling. In ICLR (Poster). OpenReview.net, 2019.
|
| 171 |
+
|
| 172 |
+
Nicolas Carion, Francisco Massa, Gabriel Synnaeve, Nicolas Usunier, Alexander Kirillov, and Sergey Zagoruyko. End-to-end object detection with transformers. In ECCV, 2020.
|
| 173 |
+
|
| 174 |
+
Rewon Child, Scott Gray, Alec Radford, and Ilya Sutskever. Generating long sequences with sparse transformers. CoRR, abs/1904.10509, 2019a.
|
| 175 |
+
|
| 176 |
+
Rewon Child, Scott Gray, Alec Radford, and Ilya Sutskever. Generating long sequences with sparse transformers. CoRR, abs/1904.10509, 2019b.
|
| 177 |
+
|
| 178 |
+
Krzysztof Marcin Choromanski, Valerii Likhosherstov, David Dohan, Xingyou Song, Andreea Gane, Tamas Sarl ´ os, Peter Hawkins, Jared Quincy Davis, Afroz Mohiuddin, Lukasz Kaiser, ´ David Benjamin Belanger, Lucy J. Colwell, and Adrian Weller. Rethinking attention with performers. In ICLR. OpenReview.net, 2021.
|
| 179 |
+
|
| 180 |
+
Jifeng Dai, Yi Li, Kaiming He, and Jian Sun. R-FCN: object detection via region-based fully convolutional networks. In NIPS, pp. 379–387, 2016.
|
| 181 |
+
|
| 182 |
+
Jifeng Dai, Haozhi Qi, Yuwen Xiong, Yi Li, Guodong Zhang, Han Hu, and Yichen Wei. Deformable convolutional networks. In ICCV, 2017.
|
| 183 |
+
|
| 184 |
+
Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In CVPR, 2009.
|
| 185 |
+
|
| 186 |
+
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, 2016.
|
| 187 |
+
|
| 188 |
+
Kaiming He, Georgia Gkioxari, Piotr Dollar, and Ross B. Girshick. Mask R-CNN. In ´ ICCV, 2017.
|
| 189 |
+
|
| 190 |
+
Dan Hendrycks and Kevin Gimpel. Bridging nonlinearities and stochastic regularizers with gaussian error linear units. CoRR, abs/1606.08415, 2016.
|
| 191 |
+
|
| 192 |
+
Jonathan Ho, Nal Kalchbrenner, Dirk Weissenborn, and Tim Salimans. Axial attention in multidimensional transformers. CoRR, abs/1912.12180, 2019.
|
| 193 |
+
|
| 194 |
+
Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, and Franc¸ois Fleuret. Transformers are rnns: Fast autoregressive transformers with linear attention. In ICML, volume 119 of Proceedings of Machine Learning Research, pp. 5156–5165. PMLR, 2020.
|
| 195 |
+
|
| 196 |
+
Nikita Kitaev, Lukasz Kaiser, and Anselm Levskaya. Reformer: The efficient transformer. In ICLR. OpenReview.net, 2020.
|
| 197 |
+
|
| 198 |
+
Chen-Yu Lee, Saining Xie, Patrick Gallagher, Zhengyou Zhang, and Zhuowen Tu. DeeplySupervised Nets. In Guy Lebanon and S. V. N. Vishwanathan (eds.), Proceedings of the Eighteenth International Conference on Artificial Intelligence and Statistics, volume 38 of Proceedings of Machine Learning Research, pp. 562–570, San Diego, California, USA, 09–12 May 2015. PMLR.
|
| 199 |
+
|
| 200 |
+
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 ´ ECCV, 2014.
|
| 201 |
+
|
| 202 |
+
Tsung-Yi Lin, Piotr Dollar, Ross Girshick, Kaiming He, Bharath Hariharan, and Serge Belongie.´ Feature pyramid networks for object detection. In CVPR, 2017.
|
| 203 |
+
|
| 204 |
+
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 ICCV, 2021.
|
| 205 |
+
|
| 206 |
+
Bowen Pan, Yifan Jiang, Rameswar Panda, Zhangyang Wang, Rogerio Feris, and Aude Oliva. ´ IA-RED2: Interpretability-aware redundancy reduction for vision transformers. arXiv preprint arXiv:2106.12620, 2021.
|
| 207 |
+
|
| 208 |
+
Niki Parmar, Ashish Vaswani, Jakob Uszkoreit, Lukasz Kaiser, Noam Shazeer, Alexander Ku, and Dustin Tran. Image transformer. In ICML, volume 80 of Proceedings of Machine Learning Research, pp. 4052–4061. PMLR, 2018.
|
| 209 |
+
|
| 210 |
+
Yongming Rao, Wenliang Zhao, Benlin Liu, Jiwen Lu, Jie Zhou, and Cho-Jui Hsieh. DynamicViT: efficient vision transformers with dynamic token sparsification. arXiv preprint arXiv:2106.02034, 2021.
|
| 211 |
+
|
| 212 |
+
Shaoqing Ren, Kaiming He, Ross B. Girshick, and Jian Sun. Faster R-CNN: towards real-time object detection with region proposal networks. In NIPS, pp. 91–99, 2015.
|
| 213 |
+
|
| 214 |
+
Byungseok Roh, Wuhyun Shin, Ildoo Kim, and Sungwoong Kim. Spatilly consistent representation learning. In CVPR. IEEE, 2021.
|
| 215 |
+
|
| 216 |
+
Peize Sun, Yi Jiang, Enze Xie, Wenqi Shao, Zehuan Yuan, Changhu Wang, and Ping Luo. What makes for end-to-end object detection? In ICML, volume 139, pp. 9934–9944, 2021.
|
| 217 |
+
|
| 218 |
+
Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott E. Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. In CVPR, pp. 1–9. IEEE Computer Society, 2015.
|
| 219 |
+
|
| 220 |
+
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.
|
| 221 |
+
|
| 222 |
+
Huiyu Wang, Yukun Zhu, Bradley Green, Hartwig Adam, Alan L. Yuille, and Liang-Chieh Chen. Axial-deeplab: Stand-alone axial-attention for panoptic segmentation. In ECCV (4), volume 12349 of Lecture Notes in Computer Science, pp. 108–126. Springer, 2020.
|
| 223 |
+
|
| 224 |
+
Qiang Wang, Bei Li, Tong Xiao, Jingbo Zhu, Changliang Li, Derek F. Wong, and Lidia S. Chao. Learning deep transformer models for machine translation. In ACL (1), pp. 1810–1822. Association for Computational Linguistics, 2019.
|
| 225 |
+
|
| 226 |
+
Tao Wang, Li Yuan, Yunpeng Chen, Jiashi Feng, and Shuicheng Yan. PnP-DETR: towards efficient visual analysis with transformers. In ICCV, 2021.
|
| 227 |
+
|
| 228 |
+
Zhuyu Yao, Jiangbo Ai, Boxun Li, and Chi Zhang. Efficient DETR: improving end-to-end object detector with dense prior. arXiv preprint arXiv:2104.01318, 2021.
|
| 229 |
+
|
| 230 |
+
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.
|
| 231 |
+
|
| 232 |
+
# A APPENDIX
|
| 233 |
+
|
| 234 |
+
# A.1 IMPLEMENTATION DETAILS OF THE SCORING NETWORK
|
| 235 |
+
|
| 236 |
+
The scoring network is consists of 4 linear layers where Layer Normalization (Ba et al., 2016) comes before the first layer and every layer except for the last one is followed by GELU (Hendrycks & Gimpel, 2016) activation. The output dimension of the 1st layer is 256 and halved to 128 and 64 at the 2nd and 3rd layers. The last layer outputs 1-d logit for the BCE loss. Since the network locally processes the input tokens in a token-wise manner, the final decisions may overlook global statistics without additional treatment. To remedy this issue, we set aside half of the output dimension of the first layer as a global feature, and average them across the whole token set, then concatenate it with each of the remained local features to maintain the original dimension. We also exclude the tokens that correspond to the zero-padded area when selecting top- $\cdot \rho \%$ scores, thereby we can prevent those tokens from participating in Hungarian matching process and getting meaningless gradients from the detection objective.
|
| 237 |
+
|
| 238 |
+
# A.2 DAM CREATION IN DEFORMABLE ATTENTION
|
| 239 |
+
|
| 240 |
+
As attention offset calculated in deformable attention is a fractional position, deformable attention uses bilinear interpolation to get values. Thus, we also use bilinear interpolation to obtain DAM.
|
| 241 |
+
|
| 242 |
+
Assume that, one of the attention offsets, weights and the reference point of decoder object query $q$ is calculated as $p , A$ and $r$ , respectively. Then, deformable attention takes values as:
|
| 243 |
+
|
| 244 |
+
$$
|
| 245 |
+
\sum _ { x } A \cdot G ( x , r + p ) \cdot v ( x )
|
| 246 |
+
$$
|
| 247 |
+
|
| 248 |
+
, where $x$ enumerates all integral spatial locations in the feature map, $G ( \cdot , \cdot )$ is the bilinear interpolation kernel defined as $G ( a , b ) = \operatorname* { m a x } ( 0 , 1 - | a _ { x } - b _ { x } | ) \cdot \operatorname* { m a x } ( 0 , 1 - | a _ { y } - b _ { y } | )$ and $v$ is the values. Similarly, we accumulate DAM-value for location $x$ as:
|
| 249 |
+
|
| 250 |
+
$$
|
| 251 |
+
\sum _ { ( p , A , r ) } A \cdot G ( x , r + p )
|
| 252 |
+
$$
|
| 253 |
+
|
| 254 |
+
. Then, we accumulate DAM over every decoder object query.
|
| 255 |
+
|
| 256 |
+
# A.3 ALTERNATIVE OBJECTIVES FOR DAM-BASED MODEL
|
| 257 |
+
|
| 258 |
+
As a training objective of the scoring network using DAM, we can consider other alternatives as long as they can encourage the predicted scores to represent the relative saliency of the encoder tokens. One of the naive alternatives is the regression loss by which the scoring network directly predicts the values in DAM. The ranking loss can be another choice with which the network focuses more on learning the relativeness rather than estimating the set of salient tokens.
|
| 259 |
+
|
| 260 |
+
Figure 8 shows the default BCE loss outperforms the alternatives. First, it is well-known that the regression problem is much harder than classification. Furthermore, since the value of DAM changes during training, the regression loss to predict the accurate value is more difficult. In case of the pairwise ranking loss, ranking the DAM elements may also be unstable as DAM gradually evolves. Meanwhile, the BCE loss may reduce those element-level noises down to the set-level in that its binary (keep or drop) targets retain more consistency compared to the exact values or ranks. Refer to Table 2 to see the exact values of the points represented in Figure 8.
|
| 261 |
+
|
| 262 |
+

|
| 263 |
+
Figure 8: DAM loss ablation
|
| 264 |
+
|
| 265 |
+
Table 2: Comparision between the alternative objectives for DAM-based scoring network.
|
| 266 |
+
|
| 267 |
+
<table><tr><td>Loss</td><td>Keeping ratio (p)</td><td>AP AP50</td><td>AP75</td><td>APs</td><td>APM</td><td>APL</td></tr><tr><td rowspan="4">smoothed L1</td><td>10%</td><td>47.8 68.9</td><td>51.7</td><td>29.8</td><td>50.9</td><td>64.0</td></tr><tr><td>20%</td><td>48.4 69.0</td><td>52.5</td><td>31.1</td><td>51.4</td><td>64.7</td></tr><tr><td>30%</td><td>48.6 69.0</td><td>52.6</td><td>31.1</td><td>51.9</td><td>64.7</td></tr><tr><td>40%</td><td>48.6 69.3</td><td>52.9</td><td>33.4</td><td>51.8</td><td>64.5</td></tr><tr><td rowspan="4">ranking</td><td>10%</td><td>48.0 69.1</td><td>52.1</td><td>29.9</td><td>51.4</td><td>64.6</td></tr><tr><td>20%</td><td>48.7 69.5</td><td>53.0</td><td>31.1</td><td>51.8</td><td>65.1</td></tr><tr><td>30%</td><td>48.8 69.2</td><td>52.8</td><td>31.4</td><td>52.0</td><td>64.9</td></tr><tr><td>40%</td><td>48.9 69.3</td><td>53.1</td><td>31.5</td><td>52.2</td><td>64.7</td></tr><tr><td rowspan="4">BCE</td><td>10%</td><td>48.2 69.2</td><td>52.3</td><td>29.8</td><td>51.2</td><td>64.5</td></tr><tr><td>20%</td><td>48.8 69.4</td><td>53.0</td><td>30.4</td><td>51.9</td><td>64.8</td></tr><tr><td>30%</td><td>49.1 69.5</td><td>53.5</td><td>31.4</td><td>52.5</td><td>65.1</td></tr><tr><td>40%</td><td>49.2 69.5</td><td>53.5</td><td>31.4</td><td>52.9</td><td>64.8</td></tr></table>
|
| 268 |
+
|
| 269 |
+
Table 3: Comparison between token selection criteria.
|
| 270 |
+
|
| 271 |
+
<table><tr><td>Scoring method</td><td>Keeping</td><td colspan="6"></td><td colspan="3"></td></tr><tr><td rowspan="2"></td><td rowspan="2">ratio (p) ResNet-50 backbone:</td><td>AP AP50</td><td></td><td>AP75</td><td>APs</td><td>APM</td><td>APL</td><td>params</td><td>FLOPs</td><td>FPS</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td rowspan="2">N/A</td><td>100%</td><td>46.3</td><td>65.8</td><td>50.1</td><td>29.0</td><td>49.4</td><td>61.7</td><td>41M</td><td>177G</td><td>18.2</td></tr><tr><td>0%</td><td>42.2</td><td>63.0</td><td>45.6</td><td>25.9</td><td>45.3</td><td>56.5</td><td>36M</td><td>91G</td><td>35.0</td></tr><tr><td rowspan="4">random</td><td>10% 20%</td><td>43.6 44.0</td><td>64.3 64.8</td><td>47.2 47.8</td><td>26.7 27.3</td><td>46.9</td><td>58.4</td><td>41M</td><td>102G</td><td>27.7</td></tr><tr><td>30%</td><td>44.0</td><td></td><td></td><td></td><td>47.0</td><td>58.4</td><td>41M</td><td>110G</td><td>25.6</td></tr><tr><td></td><td></td><td>64.9</td><td>47.5</td><td>27.4</td><td>47.4</td><td>58.2</td><td>41M</td><td>117G</td><td>24.1</td></tr><tr><td>40% 50%</td><td>44.5 44.4</td><td>65.1</td><td>48.0 48.0</td><td>27.3 27.8</td><td>47.8 47.4</td><td>59.8 59.2</td><td>41M 41M</td><td>125G</td><td>22.5 21.1</td></tr><tr><td rowspan="5">OS</td><td>10%</td><td>44.9</td><td>64.8 65.2</td><td>48.7</td><td>27.9</td><td>47.8</td><td>60.4</td><td>41M</td><td>133G 106G</td><td>26.6</td></tr><tr><td>20%</td><td>45.5</td><td>65.5</td><td>49.3</td><td>28.7</td><td>48.3</td><td>60.5</td><td>41M</td><td>114G</td><td>24.7</td></tr><tr><td>30%</td><td>45.7</td><td>65.8</td><td>49.5</td><td>29.7</td><td>48.5</td><td>60.8</td><td>41M</td><td>121G</td><td>23.2</td></tr><tr><td>40%</td><td>45.8</td><td>65.5</td><td>49.8</td><td>29.1</td><td>48.8</td><td></td><td>41M</td><td></td><td>21.8</td></tr><tr><td>50%</td><td>46.0</td><td>65.9</td><td>49.8</td><td>28.8</td><td>48.9</td><td>60.5 60.6</td><td>41M</td><td>129G 136G</td><td>20.6</td></tr><tr><td rowspan="5">DAM</td><td>10%</td><td>45.3</td><td>65.8</td><td>49.3</td><td>28.4</td><td>48.3</td><td>60.1</td><td>41M</td><td>105G</td><td>26.5</td></tr><tr><td>20%</td><td>45.6</td><td>65.8</td><td>49.6</td><td>28.5</td><td>48.6</td><td>60.4</td><td>41M</td><td>113G</td><td>24.8</td></tr><tr><td>30%</td><td>46.0</td><td>65.9</td><td>49.7</td><td>29.1</td><td>49.1</td><td>60.6</td><td>41M</td><td>121G</td><td>23.2</td></tr><tr><td>40%</td><td>46.2</td><td>66.0</td><td>50.3</td><td>28.7</td><td>49.0</td><td>61.4</td><td>41M</td><td>128G</td><td>21.8</td></tr><tr><td>50%</td><td>46.3</td><td>66.0</td><td>50.1</td><td>29.0</td><td>49.5</td><td>60.8</td><td>41M</td><td>136G</td><td>20.5</td></tr><tr><td colspan="2">Swin-T backbone:</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td rowspan="2">N/A</td><td>100% 0%</td><td>49.4 43.7</td><td>69.4</td><td>53.5</td><td>31.9</td><td>52.6</td><td>65.1</td><td>41M</td><td>185G</td><td>15.4</td></tr><tr><td>10%</td><td>45.5</td><td>65.8</td><td>46.9</td><td>27.0</td><td>46.7</td><td>60.0</td><td>37M</td><td>96G</td><td>26.5</td></tr><tr><td rowspan="5">random</td><td>20%</td><td>45.6</td><td>67.6</td><td>48.8</td><td>28.4</td><td>48.5</td><td>62.2</td><td>41M</td><td>110G</td><td>22.1</td></tr><tr><td>30%</td><td></td><td>67.5</td><td>49.2</td><td>28.6</td><td>49.1</td><td>62.2</td><td>41M</td><td>118G</td><td>20.8</td></tr><tr><td></td><td>46.2</td><td>68.1</td><td>49.7</td><td>29.5</td><td>49.7</td><td>63.0</td><td>41M</td><td>125G</td><td>19.7</td></tr><tr><td>40%</td><td>46.5</td><td>68.2</td><td>50.0</td><td>29.9</td><td>49.8</td><td>63.0</td><td>41M</td><td>133G</td><td>18.7</td></tr><tr><td>50%</td><td>47.2</td><td>68.3</td><td>50.9</td><td>29.1</td><td>50.4</td><td>63.9</td><td>41M</td><td>141G</td><td>17.7</td></tr><tr><td rowspan="5">OS</td><td>10%</td><td>48.0</td><td>69.1</td><td>52.1</td><td>29.9</td><td>51.1</td><td>64.4</td><td>42M</td><td>114G</td><td>21.4</td></tr><tr><td>20%</td><td>48.3</td><td>69.1</td><td>52.5</td><td>30.4</td><td>51.6</td><td>64.2</td><td>42M</td><td>122G</td><td>20.2</td></tr><tr><td>30%</td><td>48.6</td><td>69.2</td><td>53.0</td><td>31.0</td><td>52.0</td><td>64.6</td><td>42M</td><td>129G</td><td>18.6</td></tr><tr><td>40%</td><td>48.9</td><td>69.4</td><td>53.1</td><td>33.0</td><td>51.9</td><td>64.5</td><td>42M</td><td>137G</td><td>18.2</td></tr><tr><td>50%</td><td>49.0</td><td>69.2</td><td>53.5</td><td>31.2</td><td>52.4</td><td>65.0</td><td>42M</td><td>145G</td><td>17.2</td></tr><tr><td rowspan="5">DAM</td><td>10%</td><td>48.2</td><td>69.2</td><td>52.3</td><td>29.8</td><td>51.2</td><td>64.5</td><td>41M</td><td>113G</td><td>21.2</td></tr><tr><td>20%</td><td>48.8</td><td>69.4</td><td>53.0</td><td>30.4</td><td>51.9</td><td>64.8</td><td>41M</td><td>121G</td><td>20.0</td></tr><tr><td>30%</td><td>49.1</td><td>69.5</td><td>53.5</td><td>31.4</td><td>52.5</td><td>65.1</td><td>41M</td><td>129G</td><td>18.9</td></tr><tr><td>40%</td><td>49.2</td><td>69.5</td><td>53.5</td><td>31.4</td><td>52.9</td><td>64.8</td><td>41M</td><td>136G</td><td>18.0</td></tr><tr><td>50%</td><td>49.3</td><td>69.5</td><td>53.3</td><td>32.0</td><td>52.7</td><td>64.9</td><td>41M</td><td>144G</td><td>17.2</td></tr></table>
|
| 272 |
+
|
| 273 |
+

|
| 274 |
+
Figure 9: Layerwise gradient norm in DETR variants. An observation of the vanishing gradient problem on DETR variants with different backbones by measuring $\ell ^ { 2 }$ -norm of gradients in a layerwise manner. The first letter in $x$ -axis label represents module name, specifically, ‘B’ for the backbone and ‘E’ for the encoder, and the second number represents $i$ -th layer in that module. (a), (b): Layerwise gradient norm of DETR with ResNet-50 backbone. With the default settings(PostLN), the gradient scale generally decreases as more encoder layers are stacked, while the Pre-LN technique preserves gradient magnitude even in deeper early layers. (c) : Layerwise gradient norm of Deformable-DETR with Swin-T backbone. In this case, the Pre-LN fails to prevent vanishing gradient while the encoder auxiliary loss(denoted as Post-LN $^ +$ EncAux) proposed in this paper effectively resolves this issue.
|
| 275 |
+
|
| 276 |
+
# A.4 EXPERIMENTAL DETAILS FOR DIFFERENT TOKEN SELECTION CRITERIA
|
| 277 |
+
|
| 278 |
+
Table 3 contains the specific values used to plot (a) ResNet-50 and (b) Swin-T backbone in Figure 4. Additionally, they also include a lower-bound baseline that has no scoring method with keeping ratio $0 \%$ , meaning that the entire encoder block is removed and the backbone features are directly passed to the decoder. Even with the lowest keeping ratio $10 \%$ , all the scoring methods including random criterion outperform this lower-bound baseline. Note that all experiments reported in Table 3 except for the keeping ratio $0 \%$ use the encoder auxiliary loss for training.
|
| 279 |
+
|
| 280 |
+
# A.5 VANISHING GRADIENT PROBLEM IN THE DEEP END-TO-END DETECTORS
|
| 281 |
+
|
| 282 |
+
As shown in Section 4.2 in Carion et al. (2020), they observe that the performance of DETR gradually improves with more encoder layers. To reproduce this result, we used the default settings of the official code, but only changed the number of encoder layers. However, we fail to train the DETR model when using more than 9 encoder layers, which is probably due to different hyperparameters from the ones used in their experiments. Interestingly, we also found that the DETR model converges stably with the Pre-LN architecture(Baevski & Auli, 2019; Child et al., 2019b; Wang et al., 2019) that is known to be a better choice than the canonical Post-LN when the number of layers of transformer increases. We used the pre norm option the authors already have implemented in their code.
|
| 283 |
+
|
| 284 |
+
Table 4: Effectiveness of the encoder auxiliary loss using Swin-T. When the number of encoder layers is more than 9, the model training fails, but if the encoder auxiliary loss is adopted, the model training is feasible regardless of the number of encoder layers, and accuracy is improved.
|
| 285 |
+
|
| 286 |
+
<table><tr><td rowspan="2">#of encoder</td><td rowspan="2">Keeping ratio (p)</td><td rowspan="2">Aux. loss</td><td colspan="6"></td><td rowspan="2"></td><td colspan="2"></td></tr><tr><td>AP</td><td>AP50</td><td>AP75</td><td>APs</td><td>APM</td><td>APL</td><td>params FLOPs</td><td>FPS</td></tr><tr><td rowspan="9">6</td><td>100%</td><td></td><td>48.0</td><td>68.0</td><td>52</td><td>30.3</td><td>51.4</td><td>63.7</td><td>41M</td><td>185G</td><td>15.4</td></tr><tr><td>100%</td><td>√</td><td>49.4</td><td>69.4</td><td>53.5</td><td>31.9</td><td>52.6</td><td>65.1</td><td>41M</td><td>185G</td><td>15.4</td></tr><tr><td>10%</td><td></td><td>46.8</td><td>68.0</td><td>50.6</td><td>29.7</td><td>49.7</td><td>63.3</td><td>41M</td><td>113G</td><td>21.2</td></tr><tr><td>20%</td><td></td><td>47.5</td><td>68.3</td><td>51.4</td><td>31.4</td><td>50.4</td><td>64.4</td><td>41M</td><td>121G</td><td>20.0</td></tr><tr><td>30%</td><td></td><td>47.6</td><td>67.9</td><td>51.4</td><td>29.9</td><td>51.1</td><td>63.9</td><td>41M</td><td>129G</td><td>18.9</td></tr><tr><td>40%</td><td></td><td>47.6</td><td>68.2</td><td>51.5</td><td>30.3</td><td>50.8</td><td>64.0</td><td>41M</td><td>136G</td><td>18.0</td></tr><tr><td>10%</td><td></td><td>48.2</td><td>69.2</td><td>52.3</td><td>29.8</td><td>51.2</td><td>64.5</td><td>41M</td><td>113G</td><td>21.2</td></tr><tr><td>20%</td><td></td><td>48.8</td><td>69.4</td><td>53.0</td><td>30.4</td><td>51.9</td><td>64.8</td><td>41M</td><td>121G</td><td>20.0</td></tr><tr><td>30%</td><td>√>>></td><td>49.1</td><td>69.5</td><td>53.5</td><td>31.4</td><td>52.5</td><td>65.1</td><td>41M</td><td>129G</td><td>18.9</td></tr><tr><td>9</td><td>40%</td><td></td><td>49.2</td><td>69.5</td><td>53.5</td><td>31.4</td><td>52.9</td><td>64.8</td><td>41M</td><td>136G</td><td>18.0</td></tr><tr><td rowspan="5">12</td><td>100%</td><td>√</td><td>49.7</td><td>69.4</td><td>54.1</td><td>32.4</td><td>52.9</td><td>65.4</td><td>44M</td><td>220G</td><td>12.8</td></tr><tr><td>100%</td><td>√</td><td>50.1</td><td>69.6</td><td>54.6</td><td>32.2</td><td>53.4</td><td>65.8</td><td>46M</td><td>261G</td><td>11.0</td></tr><tr><td>10%</td><td></td><td>49.0</td><td>69.5 69.6</td><td>53.5 53.5</td><td>31.6</td><td>52.2</td><td>65.2</td><td>46M</td><td>128G</td><td>19.2</td></tr><tr><td>20% 30%</td><td>>></td><td>49.4 49.3</td><td>69.4</td><td>53.6</td><td>31.9 31.7</td><td>52.8 52.5</td><td>65.4 65.6</td><td>46M 46M</td><td>143G 158G</td><td>17.5</td></tr><tr><td>40%</td><td></td><td>49.8</td><td>69.8</td><td>54.3</td><td>33.1</td><td>53.4</td><td>65.4</td><td>46M</td><td>173G</td><td>15.6 14.6</td></tr></table>
|
| 287 |
+
|
| 288 |
+
Figure 9(a) and 9(b) illustrate that gradient norm of each layer from bottom to top in 6 and 12 encoder layers when using Post-LN and Pre-LN, respectively. We compute the $\ell ^ { 2 }$ -norm of the gradients for all parameters in a particular layer, as if they are concatenated into a single vector. To see training dynamics in the early stage of training, we track the gradients computed on a fixed set of training data and average them over the first 150 steps with a batch size of 2. Note that we applied Pre-LN only to the encoder module for a fair comparison between only the early modules although it could be used in any other transformer modules, e.g. backbone or decoder.
|
| 289 |
+
|
| 290 |
+
We found that the vanishing gradient issue is generally observed regardless of the encoder size. When we double the size of the encoder, as one can expect, the gradient in the early layers ends up with an even smaller scale, which may have caused the convergence failure. Meanwhile, the PreLN technique seems to significantly alleviate this issue even for the deeper encoder by maintaining the gradient scale evenly through the encoder layers and conveying a strong training signal to the backbone layers.
|
| 291 |
+
|
| 292 |
+
On the other hand, as shown in Figure 9(c), Deformable-DETR suffers from the same problem of vanishing gradient and even the Pre-LN technique does not help in this case. Meanwhile, the encoder auxiliary loss proposed in our paper drastically amplifies the gradient magnitude in the early layers by providing aggressive intermediate objectives for each encoder layer. Note that it also creates good synergy with our main sparsification strategy owing to reduced training cost. We claim that this observation supports our motivation of introducing the encoder auxiliary loss.
|
| 293 |
+
|
| 294 |
+
# A.6 EXPERIMENTAL DETAILS FOR EFFECTIVENESS OF THE ENCODER AUXILIARY LOSS
|
| 295 |
+
|
| 296 |
+
Table 4 presents the detailed values of Figure 4. As shown in the Table 4 and discussed in Section A.5, training of a deeper encoder of more than 9 layers fails without the auxiliary loss, but if it is adopted, the convergence becomes feasible as the intermediate gradients provided to the early encoder layers augment the vanishing gradient back-propagated from the decoder module.
|
| 297 |
+
|
| 298 |
+
Table 5: Detection results of Sparse DETR with SCRL initialization using ResNet-50. The same environment and hyperparameters as Experiments section are used, except for initializing the backbone with SCRL (Roh et al., 2021) model. The results marked by $\ S$ mean that the backbone network is initialized by SCRL instead of the ImageNet (Deng et al., 2009) pre-trained one.
|
| 299 |
+
|
| 300 |
+
<table><tr><td rowspan="2">Method</td><td rowspan="2">Keeping ratio (p)</td><td colspan="6"></td><td rowspan="2"></td><td colspan="2"></td></tr><tr><td>AP</td><td>AP50</td><td>AP75</td><td>APs</td><td>APM</td><td>APL</td><td>params FLOPs</td><td>FPS</td></tr><tr><td rowspan="5">Sparse-DETR</td><td>10%</td><td>45.3</td><td>65.8</td><td>49.3</td><td>28.4</td><td>48.3</td><td>60.1</td><td>41M</td><td>105G</td><td>25.3</td></tr><tr><td>20%</td><td>45.6</td><td>65.8</td><td>49.6</td><td>28.5</td><td>48.6</td><td>60.4</td><td>41M</td><td>113G</td><td>24.8</td></tr><tr><td>30%</td><td>46.0</td><td>65.9</td><td>49.7</td><td>29.1</td><td>49.1</td><td>60.6</td><td>41M</td><td>121G</td><td>23.2</td></tr><tr><td>40%</td><td>46.2</td><td>66.0</td><td>50.3</td><td>28.7</td><td>49.0</td><td>61.4</td><td>41M</td><td>128G</td><td>21.8</td></tr><tr><td>50%</td><td>46.3</td><td>66.0</td><td>50.1</td><td>29.0</td><td>49.5</td><td>60.8</td><td>41M</td><td>136G</td><td>20.5</td></tr><tr><td rowspan="5">Sparse-DETR$</td><td>10%</td><td>46.9</td><td>67.2</td><td>51.0</td><td>30.2</td><td>49.7</td><td>62.3</td><td>41M</td><td>105G</td><td>25.3</td></tr><tr><td>20%</td><td>47.3</td><td>67.1</td><td>51.4</td><td>29.7</td><td>50.3</td><td>62.7</td><td>41M</td><td>113G</td><td>24.8</td></tr><tr><td>30%</td><td>47.4</td><td>67.3</td><td>51.4</td><td>30.1</td><td>50.5</td><td>62.4</td><td>41M</td><td>121G</td><td>23.2</td></tr><tr><td>40%</td><td>47.7</td><td>67.4</td><td>51.6</td><td>30.0</td><td>50.8</td><td>62.9</td><td>41M</td><td>128G</td><td>21.8</td></tr><tr><td>50%</td><td>47.9</td><td>67.5</td><td>52.1</td><td>30.5</td><td>51.2</td><td>63.2</td><td>41M</td><td>136G</td><td>20.5</td></tr></table>
|
| 301 |
+
|
| 302 |
+
Table 6: Performance of Sparse DETR with Swin-B. The same environment and hyperparameters as Experiments section are used, except for changing the backbone to a larger scale. Note that Aux. loss means only the ones applied to the encoder layers.
|
| 303 |
+
A.7 EFFECTIVENESS OF USING A DENSE REPRESENTATION AS BACKBONE INITIALIZATION
|
| 304 |
+
|
| 305 |
+
<table><tr><td rowspan="2">Backbone</td><td rowspan="2">Keeping ratio (p)</td><td rowspan="2">Aux. loss</td><td colspan="5"></td><td rowspan="2"></td><td colspan="2">FLOPs</td></tr><tr><td>AP</td><td>AP50</td><td>AP75 APs</td><td>APM</td><td>APL</td><td>params</td><td>FPS</td></tr><tr><td rowspan="5">Swin-T</td><td>100%</td><td></td><td>48.0</td><td>68.0</td><td>52.0</td><td>30.3</td><td>51.4</td><td>63.7</td><td>41M</td><td>185G</td><td>15.4</td></tr><tr><td>10%</td><td></td><td>48.2</td><td>69.2</td><td>52.3</td><td>29.8</td><td>51.2</td><td>64.5</td><td>41M</td><td>113G</td><td>21.2</td></tr><tr><td>20%</td><td></td><td>48.8</td><td>69.4</td><td>53.0</td><td>30.4</td><td>51.9</td><td>64.8</td><td>41M</td><td>121G</td><td>20.0</td></tr><tr><td>30%</td><td></td><td>49.1</td><td>69.5</td><td>53.5</td><td>31.4</td><td>52.5</td><td>65.1</td><td>41M</td><td>129G</td><td>18.9</td></tr><tr><td>40%</td><td><>>></td><td>49.2</td><td>69.5</td><td>53.5</td><td>31.4</td><td>52.9</td><td>64.8</td><td>41M</td><td>136G</td><td>18.0</td></tr><tr><td rowspan="5">Swin-B</td><td>100%</td><td></td><td>52.5</td><td>72.9</td><td>56.9</td><td>34.7</td><td>56.5</td><td>69.6</td><td>101M</td><td>400G</td><td>7.6</td></tr><tr><td>10%</td><td></td><td>52.2</td><td>73.5</td><td>57.0</td><td>34.0</td><td>56.3</td><td>70.3</td><td>101M</td><td>335G</td><td>8.8</td></tr><tr><td>20%</td><td></td><td>53.1</td><td>73.8</td><td>57.9</td><td>34.6</td><td>56.9</td><td>70.6</td><td>101M</td><td>343G</td><td>8.6</td></tr><tr><td>30%</td><td><>>></td><td>53.2</td><td>73.7</td><td>57.7</td><td>35.3</td><td>56.8</td><td>70.8</td><td>101M</td><td>350G</td><td>8.4</td></tr><tr><td>40%</td><td></td><td>53.3</td><td>73.4</td><td>58.0</td><td>36.3</td><td>57.2</td><td>70.9</td><td>101M</td><td>358G</td><td>8.2</td></tr></table>
|
| 306 |
+
|
| 307 |
+
Recently, many self-supervised learning methods through contrastive learning have been studied, and in particular, methods for obtaining dense representations with better performance for localization downstream tasks such as object detection are in the spotlight. In order to check whether our proposed method is effective even when such dense representation is used, the backbone network is initialized with the SCRL (Roh et al., 2021) model that aims to learn dense representations in a selfsupervised way instead of initializing with the ImageNet (Deng et al., 2009) pre-trained one. Just as the SCRL model outperformed the ImageNet pre-trained model in various localization downstream tasks, our proposed method, Sparse DETR, also shows better performance in all keeping ratios $( \rho )$ without the influence of encoder token sparsification as shown in Table 5.
|
| 308 |
+
|
| 309 |
+
# A.8 USING A LARGER TRANSFORMER-BASED BACKBONE(SWIN-B)
|
| 310 |
+
|
| 311 |
+
We perform experiments on Sparse DETR with Swin-Base(Liu et al., 2021) backbone to see if our method shows similar efficiency and performance gain even when using a heavier transformer-based backbone. Table 6 illustrates a comparison of COCO detection performance between Swin-T and Swin-B backbone under the varied sparsity. Due to the increased capacity, using Swin-B backbone significantly boosts up the baseline AP up to 52.5 $( + 4 . 5 ) $ but with $2 . 4 \times$ parameters and $2 . 1 \times$ com
|
| 312 |
+
|
| 313 |
+

|
| 314 |
+
Figure 10: Distribution of the ratio of non-zero values of DAM on COCO 2017 val set.
|
| 315 |
+
|
| 316 |
+
Table 7: Two-stage encoder token sparsification with a varied keeping ratio. COCO detection performance when the encoder tokens are sparsified at the later stage with the top- ${ \cdot \rho \% }$ binarized DAMs pre-computed from the former stage. All models are Deformable-DETR $^ +$ with Swin-T backbone and the encoder auxiliary loss is not applied. Note that the performance of the $50 \%$ model(47.9 AP) hardly degenerates compared to the baseline(48.0 AP).
|
| 317 |
+
|
| 318 |
+
<table><tr><td>Keeping ratio (p)</td><td>AP AP50</td><td>AP75</td><td>APs</td><td>APM</td><td>APL</td></tr><tr><td>100%</td><td>48.0 68.0</td><td>52.0</td><td>30.3</td><td>51.4</td><td>63.7</td></tr><tr><td>10%</td><td>44.0 66.0</td><td>47.2</td><td>26.9</td><td>46.8</td><td>61.0</td></tr><tr><td>20%</td><td>44.9 66.3</td><td>48.3</td><td>28.2</td><td>48.2</td><td>61.4</td></tr><tr><td>30%</td><td>46.5 67.3</td><td>50.2</td><td>30.9</td><td>49.7</td><td>62.3</td></tr><tr><td>40%</td><td>47.3 67.9</td><td>51.3</td><td>30.7</td><td>50.7</td><td>63.4</td></tr><tr><td>50%</td><td>47.9 67.8</td><td>52.0</td><td>29.8</td><td>51.4</td><td>63.7</td></tr></table>
|
| 319 |
+
|
| 320 |
+
putational cost. With the keeping ratio of $40 \%$ and the encoder auxiliary loss, the performance gap remains at a similar leve $( + 4 . 1 )$ . We can also observe consistent performance gains as the keeping ratio gets higher while the increasing gap converges more quickly than Swin-T. It may be because a single visual token of Swin-B can incorporate a wider range of information due to the deeper attention hierarchies and a smaller number of tokens is required to fully represent all the objects in an image. Note that the efficiency of a backbone network is behind the scope of this paper. Our work is orthogonal to the backbone sparsification approaches, e.g. DynamicViT (Rao et al., 2021), and we leave the integration with those works as future work.
|
| 321 |
+
|
| 322 |
+
A.9 THE PRELIMINARY EXPERIMENTS: WHY PURSUE A SPARSE ENCODER?
|
| 323 |
+
|
| 324 |
+
Using a model trained with Deformable-DETR, we have analyzed the number of encoder output tokens referenced by the decoder’s object query. Unlike using the bilinear interpolation described in the appendix A.2 to generate DAMs for training with pseudo-labels, in this analysis, we do not use bilinear interpolation to calculate how many encoder tokens are directly referenced by the decoder object query. To analyze the non-zero values of DAM, we use a Deforamble DETR model trained with Top- $k$ sampling strategy (Yao et al., 2021) and bounding box refinement (Zhu et al., 2021) using ResNet-50 backbone. Fig. 10 illustrates the distribution of the ratio of non-zero values of DAM on COCO val2017 dataset. As shown in Fig. 10, on average, only $45 \%$ of encoder tokens were referenced by object queries.
|
| 325 |
+
|
| 326 |
+
This observation naturally raises a question: Can we preserve the detection performance even if we focus, in the first place, only on the encoder tokens that the decoder might have preferred? As a preliminary experiment to answer this question, we trained the detector restricting token updates to the subset to which the decoder could have referred if there had been no such restriction. To this end, we performed the two-stage learning as follows: (i) We first obtained the DAMs of the entire training data by feeding them to a fully-trained Deformable-DETR model. (ii) Then, we retrained another model from the scratch by updating only a subset of tokens determined by the binarized DAM preserving top- $\rho \%$ of the elements(refer to Section3.3 for more details). Table 7 shows the performance on COCO detection for different keeping ratio $\rho$ . We found that the two-stage model almost catches up with the baseline $\rho = 1 0 0 \%$ as the keeping ratio is raised close to $45 \%$ , namely the percentage of non-zero values in DAM computed on the validation dataset earlier.
|
| 327 |
+
|
| 328 |
+
These observations have strongly motivated us to develop the encoder token sparsification method presented in the main text. Note that our main algorithm differs from this preliminary experiment in some aspects: (a) A DAM is obtained from the jointly learning decoder, not from the separately trained decoder, and (b) a binarized DAM is utilized as a prediction target of the scoring network rather than used directly as a sparsification mask.
|
| 329 |
+
|
| 330 |
+
# A.10 VISUALIZATIONS OF SELECTED ENCODER TOKENS
|
| 331 |
+
|
| 332 |
+
We visualize selected encoder tokens and top- $k$ decoder queries for each criterion, OS, and DAM. In the first row, selected encoder tokens from the backbone feature map are visualized as yellow regions, whereas unselected tokens are visualized as purple regions. In the second row, selected top$k$ decoder queries from encoder output are visualized in the same manner. In the final row, DAM values and Corr metrics are visualized. Corr is measured as in Section 4.2.
|
| 333 |
+
|
| 334 |
+
Interestingly, the DAM-based selection seems to better capture the objects than OS-based selection. The OS-based selection also captures objects well, but it typically focuses on the high-frequency edges that are not only in the foreground but also in the background. On the other hand, the DAMbased selection captures the boundary of the objects and also their inner areas and is less distracted from the background edges. We analyze that DAM focuses on the boundary of objects to lower the regression loss, and attends to the inside of objects to lower the classification loss. Finally, the scoring network predicts such a DAM well, and refining the encoder tokens according to it finally helps achieve better detection performance.
|
| 335 |
+
|
| 336 |
+

|
| 337 |
+
Figure 11: Visualization of selected tokens and DAM for COCO validation image #289960
|
| 338 |
+
|
| 339 |
+

|
| 340 |
+
Figure 12: Visualization of selected tokens and DAM for COCO validation image #22396
|
| 341 |
+
|
| 342 |
+

|
| 343 |
+
Figure 13: Visualization of selected tokens and DAM for COCO validation image #46252
|
| 344 |
+
|
| 345 |
+

|
| 346 |
+
Figure 14: Visualization of selected tokens and DAM for COCO validation image #6040
|
| 347 |
+
|
| 348 |
+

|
| 349 |
+
Figure 15: Visualization of selected tokens and DAM for COCO validation image #17379
|
md/dev/TQ75Md-FqQp/TQ75Md-FqQp.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/URNZQmbxpwh/URNZQmbxpwh.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/UYS38ssi1M/UYS38ssi1M.md
ADDED
|
@@ -0,0 +1,442 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# LEARNING GFLOWNETS FROM PARTIAL EPISODES FOR IMPROVED CONVERGENCE AND STABILITY
|
| 2 |
+
|
| 3 |
+
Anonymous authors Paper under double-blind review
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
Generative flow networks (GFlowNets) are a family of algorithms for training a sequential sampler of discrete objects under an unnormalized target density and have been successfully used for various probabilistic modeling tasks. Existing training objectives for GFlowNets are either local to states or transitions, or propagate a reward signal over an entire sampling trajectory. We argue that these alternatives represent opposite ends of a gradient bias-variance tradeoff and propose a way to exploit this tradeoff to mitigate its harmful effects. Inspired by the $\mathrm { T D } ( \lambda )$ algorithm in reinforcement learning, we introduce subtrajectory balance or SubTB(??), a GFlowNet training objective that can learn from partial action subsequences of varying lengths. We show that SubTB(??) accelerates sampler convergence in previously studied and new environments and enables training GFlowNets in environments with longer action sequences and sparser reward landscapes than what was possible before. We also perform a comparative analysis of stochastic gradient dynamics, shedding light on the bias-variance tradeoff in GFlowNet training and the advantages of subtrajectory balance.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Generative flow networks (GFlowNets; Bengio et al., 2021a) are generative models that construct objects lying in a target space $\chi$ by taking sequences of actions sampled from a learned policy. GFlowNets are trained so as to make the probability of sampling an object $x \in \chi$ proportional to a given nonnegative reward $R ( x )$ . GFlowNets’ use of a parametric policy that can generalize to states not seen during training makes them a competitive alternative to methods based on local exploration in various probabilistic modeling tasks (Bengio et al., 2021a; Malkin et al., 2022; Zhang et al., 2022; Jain et al., 2022; Deleu et al., 2022).
|
| 12 |
+
|
| 13 |
+
GFlowNets solve the variational inference problem of approximating a target distribution over $\chi$ with the distribution induced by the sampling policy, and they are trained by algorithms reminiscent of reinforcement learning (although GFlowNets model the diversity present in the reward distribution, rather than maximizing reward by seeking its mode). In most past works (Bengio et al., 2021a; Malkin et al., 2022; Zhang et al., 2022; Jain et al., 2022), GFlowNets are trained by exploratory sampling from the policy and receive their training signal from the reward of the sampled object. The flow matching (FM) and detailed balance (DB) learning objectives for GFlowNets proposed in Bengio et al. (2021a;b) resemble temporal difference learning (Sutton & Barto, 2018).
|
| 14 |
+
|
| 15 |
+
A third objective, trajectory balance (TB), was proposed in Malkin et al. (2022) to address the problem of slow temporal credit assignment with the FM and DB objectives. The TB objective propagates learning signals over entire episodes, while the temporal difference-like objectives (FM and DB) make updates local to states or actions. It has been hypothesized by Malkin et al. (2022) that the improved credit assignment with TB comes at the cost of higher gradient variance, analogous to the bias-variance tradeoff seen in temporal difference learning $\textstyle ( \mathrm { T D } ( n )$ or $\mathrm { T D } ( \lambda ) )$ with different eligibility trace schemes (Sutton & Barto, 2018; Kearns & Singh, 2000; van Hasselt et al., 2018; Bengio et al., 2020). This hypothesis is one of the starting points for the present paper.
|
| 16 |
+
|
| 17 |
+
In this paper, we propose a new learning objective for GFlowNets, called subtrajectory balance (SubTB, or SubTB(??) when its real-valued hyperparameter $\lambda$ is specified). Building upon theoretical results of Bengio et al. (2021b); Malkin et al. (2022), we show how the SubTB(??) objective allows the flexibility of learning from partial experiences of any length. Experiments on two synthetic and four real-world domains support the following empirical claims:
|
| 18 |
+
|
| 19 |
+
(1) SubTB(??) improves convergence of GFlowNets in previously studied environments: models trained with SubTB(??) approach the target distribution in fewer training iterations and are less sensitive to hyperparameter choices.
|
| 20 |
+
(2) SubTB(??) enables training of GFlowNets in environments where past approaches perform poorly due to sparsity of the reward function or length of action sequences.
|
| 21 |
+
(3) The benefits of SubTB(??) are explained by lower variance of the stochastic gradient, with the parameter $\lambda$ allowing interpolation between the high-bias, low-variance DB objective and the low-bias, high-variance TB objective.
|
| 22 |
+
|
| 23 |
+
# 2 METHOD
|
| 24 |
+
|
| 25 |
+
# 2.1 PRELIMINARIES
|
| 26 |
+
|
| 27 |
+
In this section, we summarize the necessary preliminaries on GFlowNets. We follow the notation of Malkin et al. (2022), to which the reader is directed for a more thorough exposition written with a view towards motivating the trajectory and subtrajectory balance objectives. A deeper introduction is given in Bengio et al. (2021b).
|
| 28 |
+
|
| 29 |
+
Let $G = ( S , { \mathcal { A } } )$ be a directed acyclic graph. The vertices $s \in S$ are called states and the directed edges $( u { \longrightarrow } \nu ) \in { \mathcal { A } }$ are actions. If $( u { } \nu )$ is an edge, we say $\nu$ is a child of $u$ and $u$ is a parent of $\nu$ . There is a unique initial state $s _ { 0 } \in S$ with no parents. States with no children are called terminal, and the set of terminal states is denoted by $\chi$ .
|
| 30 |
+
|
| 31 |
+
A trajectory or an action sequence is a sequence of states $\tau = ( s _ { m } { } s _ { m + 1 } { } \dots { } s _ { n } )$ ), where each $\left( { { s _ { i } } \mathord { \left/ { \vphantom { { s _ { i } } \sum _ { i + 1 } } } \right. \kern - delimiterspace } } \right)$ is an action. The trajectory is complete if $s _ { m } = s _ { 0 }$ and $s _ { n }$ is terminal. The set of complete trajectories is denoted by $\mathcal { T }$ .
|
| 32 |
+
|
| 33 |
+
A (forward) policy is a collection of distributions $P _ { F } ( - | s )$ over the children of every nonterminal state $s \in S$ . A forward policy determines a distribution over $\mathcal { T }$ by
|
| 34 |
+
|
| 35 |
+
$$
|
| 36 |
+
P _ { F } ( \tau = ( s _ { 0 } { \longrightarrow } \ldots { } \ldots { } \longrightarrow s _ { n } ) ) = \prod _ { i = 0 } ^ { n - 1 } P _ { F } ( s _ { i + 1 } | s _ { i } ) .
|
| 37 |
+
$$
|
| 38 |
+
|
| 39 |
+
Any distribution over complete trajectories that arises from a forward policy satisfies a Markov property: the marginal choice of action out of a state $s$ is independent of how $s$ was reached. Conversely, any Markovian distribution over $\mathcal { T }$ arises from a forward policy (Bengio et al., 2021b).
|
| 40 |
+
|
| 41 |
+
A forward policy can thus be used to sample terminal states $x \in \chi$ by starting at $s _ { 0 }$ and iteratively sampling actions from $P _ { F }$ , or, equivalently, taking the terminating state of a complete trajectory $\tau \sim P _ { F } ( \tau )$ . The marginal likelihood of sampling $x \in \chi$ is the sum of likelihoods of all complete trajectories that terminate at $x$ .
|
| 42 |
+
|
| 43 |
+
Suppose that a nontrivial (not identically 0) nonnegative reward function $R : X \mathbb { R } _ { \geq 0 }$ is given. The learning problem solved by GFlowNets is to estimate a policy $P _ { F }$ such that the likelihood of sampling $x \in \chi$ is proportional to $R ( x )$ . That is, there should exist a constant $Z$ such that
|
| 44 |
+
|
| 45 |
+
$$
|
| 46 |
+
R ( x ) = Z \sum _ { \substack { \tau = ( s _ { 0 } \ldots s _ { n } = x ) } } P _ { F } ( \tau ) \quad \forall x \in X .
|
| 47 |
+
$$
|
| 48 |
+
|
| 49 |
+
If (2) is satisfied, then $\begin{array} { r } { Z = \sum _ { x \in X } R ( x ) } \end{array}$
|
| 50 |
+
|
| 51 |
+
# 2.2 GFLOWNET TRAINING OBJECTIVES
|
| 52 |
+
|
| 53 |
+
Because the sum in (2) may be intractable to compute, it is in general not possible to directly convert this constraint into a training objective. To solve this problem, GFlowNet training objectives introduce auxiliary variables in the parametrization in various ways, but all have the property that (2) is satisfied at the global optimum. The key properties of these objectives are summarized in Table 1.
|
| 54 |
+
|
| 55 |
+
Flow matching (FM; Bengio et al., 2021a). Motivating the ‘flow network’ terminology, Bengio et al. (2021a) proved that (2) is satisfied if $P _ { F }$ arises from an edge flow function satisfying certain constraints. Namely, an assignment $F : \mathcal { A } \mathbb { R } _ { \geq 0 }$ of a nonnegative number (flow) to each action defines a policy via
|
| 56 |
+
|
| 57 |
+
$$
|
| 58 |
+
P _ { F } ( t | s ) = { \frac { F ( s \to t ) } { \sum _ { t ^ { \prime } : ( s \to t ^ { \prime } ) \in \mathcal { A } } F ( s \to t ^ { \prime } ) } } .
|
| 59 |
+
$$
|
| 60 |
+
|
| 61 |
+
A sufficient condition for the terminating distribution of $P _ { F }$ to be proportional to the reward $R ( x )$ is that a family of flow-matching (flow in $=$ flow out) conditions is satisfied at all interior states and a
|
| 62 |
+
|
| 63 |
+
Table 1: Summary of GFlowNet training objectives.
|
| 64 |
+
|
| 65 |
+
<table><tr><td>Objective</td><td>Parametrization</td><td>Locality</td></tr><tr><td>Flow matching Detailed balance</td><td>edge flowF(s→→t; 0) state flow F(s;0),policies PF(-|-;0),Pb(-|-;0)</td><td>state s action s-→t</td></tr><tr><td>Trajectory balance</td><td>initial state flow Z0,policies PF(-|-;0),PB(-|-;0)</td><td>complete trajectory t</td></tr><tr><td>Subtrajectory balance</td><td>state flow F(s;0),policies PF(-|-;0),Pb(-|-;0)</td><td>(partial) trajectory t</td></tr></table>
|
| 66 |
+
|
| 67 |
+
family of reward-matching conditions is satisfied at terminal states:
|
| 68 |
+
|
| 69 |
+
$$
|
| 70 |
+
\forall t \in S \setminus ( X \cup \{ s _ { 0 } \} ) ,
|
| 71 |
+
$$
|
| 72 |
+
|
| 73 |
+
$$
|
| 74 |
+
\sum _ { s : ( s t ) \in \mathcal { A } } F ( s t ) = \sum _ { u : ( t u ) \in \mathcal { A } } F ( t u )
|
| 75 |
+
$$
|
| 76 |
+
|
| 77 |
+
$$
|
| 78 |
+
\forall x \in X .
|
| 79 |
+
$$
|
| 80 |
+
|
| 81 |
+
The flow $F ( s { \longrightarrow } t )$ is then proportional to the marginal likelihood that a complete trajectory sampled from $P _ { F }$ includes the action $s { \longrightarrow } t$ .
|
| 82 |
+
|
| 83 |
+
In Bengio et al. (2021a), a GFlowNet is described by a parametric estimate of the edge flow function, $F ( u \to \nu ; \theta )$ (a neural net with parameters $\theta$ ). These conditions can be converted into objectives that are minimized when (4) is satisfied. For example, the flow-matching objective at a nonterminal state $s$ is defined by
|
| 84 |
+
|
| 85 |
+
$$
|
| 86 |
+
\mathcal { L } _ { \mathrm { F M } } ( s ) = ( \log \frac { \sum _ { s : ( s t ) \in \mathcal { A } } F ( s t ; \theta ) + \epsilon } { \sum _ { u : ( t u ) \in \mathcal { A } } F ( t u ; \theta ) + \epsilon } ) ^ { 2 } ,
|
| 87 |
+
$$
|
| 88 |
+
|
| 89 |
+
where $\epsilon$ is a smoothing constant that can safely be set to 0 if the flows are constrained to be strictly positive, and a similar objective (or a constraint by construction) is defined to force the flow $F ( s { \xrightarrow { } } x )$ into terminal states $x$ to match $R ( x )$ . If these objectives are globally minimized for all states $s$ , then the policy $P _ { F } ( - | - ; \theta )$ defined by $F ( - ; \theta )$ via (3) satisfies (2), with $\begin{array} { r } { Z = \sum _ { t : ( s _ { 0 } t ) \in \mathcal { A } } F ( s t ; \theta ) = } \end{array}$ $\textstyle \sum _ { x \in X } R ( x )$ . The question of how to sample states $s$ for training is discussed below.
|
| 90 |
+
|
| 91 |
+
Detailed balance (DB; Bengio et al., 2021b; Malkin et al., 2022). In the DB parametrization, a forward policy model $P _ { F } ( - | - ; \theta )$ is learned directly, jointly with two additional objects: a backward policy model $P _ { B } ( - | - ; \theta )$ , which can predict a distribution over the parents of any noninitial state, and a state flow function $F ( s ; \theta )$ (typically parametrized in the log domain). The detailed balance conditions state that
|
| 92 |
+
|
| 93 |
+
$$
|
| 94 |
+
F ( s ; \theta ) P _ { F } ( t | s ; \theta ) = F ( t ; \theta ) P _ { B } ( s | t ; \theta )
|
| 95 |
+
$$
|
| 96 |
+
|
| 97 |
+
for all actions $( s { } t )$ and $F ( x ; \theta ) = R ( x )$ for $x$ terminal. Satisfaction of these conditions for all actions $( s { } t )$ and $x \in \chi$ implies that $P _ { F }$ samples proportionally to the reward (i.e., satisfies (2), with $Z = F ( s _ { 0 } ) )$ ). The DB condition (6) can be converted into a squared log-ratio objective $\mathcal { L } _ { \mathrm { D B } } ( s \to t )$ in the same way that (4) yields (5), and $\mathcal { L } _ { \mathrm { D B } } ( s \to t )$ can be optimized over sampled actions $( s { } t )$ .
|
| 98 |
+
|
| 99 |
+
Trajectory balance (TB; Malkin et al., 2022). The parametrization required for the TB objective includes forward and backward policy models $P _ { F } ( - | \bar { - } ; \theta )$ and $P _ { B } ( - | - ; \bar { \theta } )$ , as well as an estimate $Z _ { \theta }$ of the constant of proportionality in (2). Satisfaction of the following condition for all complete trajectories $\tau = ( s _ { 0 } { \longrightarrow } \dotsm { \longrightarrow } s _ { n } )$ implies that (2) is satisfied:
|
| 100 |
+
|
| 101 |
+
$$
|
| 102 |
+
Z _ { \theta } P _ { F } ( \tau ; \theta ) = R ( s _ { n } ) P _ { B } ( \tau | s _ { n } ; \theta ) ,
|
| 103 |
+
$$
|
| 104 |
+
|
| 105 |
+
where we have used the conventions
|
| 106 |
+
|
| 107 |
+
$$
|
| 108 |
+
P _ { F } ( \tau ; \theta ) = \prod _ { i = 0 } ^ { n - 1 } P _ { F } ( s _ { i + 1 } | s _ { i } ; \theta ) , \quad P _ { B } ( \tau | s _ { n } ; \theta ) = \prod _ { i = 0 } ^ { n - 1 } P _ { B } ( s _ { i } | s _ { i + 1 } ; \theta ) .
|
| 109 |
+
$$
|
| 110 |
+
|
| 111 |
+
The condition (7) can again be made into a squared log-ratio objective $\mathcal { L } _ { \mathrm { T B } } ( \tau )$ and optimized for complete trajectories $\tau$ taken from some training policy. In Malkin et al. (2022), the TB objective was empirically demonstrated to have better convergence properties than FM and DB on various problem domains.
|
| 112 |
+
|
| 113 |
+
Training policy and exploration. Global minimization of the FM, DB, and TB objectives for all values of their respective arguments (states, actions, or complete trajectories) implies satisfaction of (2). Therefore, given a sufficiently expressive model and convergence of the optimization procedure, a GFlowNet policy that samples $x$ with likelihood proportional to $R ( x )$ can be trained by minimizing any of these losses over a distribution with full support, enabling offline training of GFlowNets. As in other RL algorithms, the distribution over sampled states, actions, or episodes can be fixed and off-policy, or can vary over the course of training and use available information about terminal states in interesting ways (Zhang et al., 2022; Deleu et al., 2022). The simplest approach, which is also taken in this paper, is on-policy learning or a very similar off-policy variant that flattens the current policy to ensure exploration. Complete trajectories $\tau = ( s _ { 0 } { } . . . { } s _ { n } )$ are sampled from the forward policy $P _ { F } ( - | \bar { - } ; \theta )$ (tempered or mixed with a uniform policy with a small weight so as to ensure full support and exploration). One then takes gradient descent steps on $\mathcal { L } _ { \mathrm { T B } } ( \bar { \tau } )$ , on $\mathcal { L } _ { \mathrm { D B } } ( s _ { i } \{ s _ { i + 1 } \} )$ over all actions in $\tau$ , or on $\mathcal { L } _ { \mathrm { F M } } ( s _ { i } )$ for all intermediate states in $\tau$ .
|
| 114 |
+
|
| 115 |
+
The GFlowNets in this paper are trained on-policy, or off-policy with a training policy that is a mixture of $P _ { F }$ with a uniform policy: $\tau = ( s _ { 0 } { } s _ { 1 } { } \dots { } s _ { n } )$ is sampled with $s _ { i + 1 } ~ \sim ~ ( 1 ~ -$ $\epsilon ) P _ { F } ( s _ { i + 1 } | s _ { i } ; \theta ) + \epsilon \frac { 1 } { \# \{ t : ( s t ) \in \mathcal { A } \} }$ . Here $\epsilon$ is the random exploration weight.
|
| 116 |
+
|
| 117 |
+
# 2.3 SUBTRAJECTORY BALANCE: LEARNING FROM PARTIAL EPISODES
|
| 118 |
+
|
| 119 |
+
Recall the GFlowNet parametrization used in the DB objective above, with a state flow estimator $F ( - | \mathrm { - } ; \theta )$ and a pair of policies $P _ { F } ( - | - ; \theta ) , P _ { B } ( - | - ; \theta )$ . It is shown in $\ S \mathrm { A } . 2$ of Malkin et al. (2022) that the detailed balance conditions (6) are satisfied for all actions if and only if the following subtrajectory balance constraint holds for all (not necessarily complete) trajectories $\tau = ( s _ { m } { } \dots { } s _ { n } )$ :
|
| 120 |
+
|
| 121 |
+
$$
|
| 122 |
+
F ( s _ { m } ; \theta ) \prod _ { i = m } ^ { n - 1 } P _ { F } ( s _ { i + 1 } | s _ { i } ; \theta ) = F ( s _ { n } ; \theta ) \prod _ { i = m } ^ { n - 1 } P _ { B } ( s _ { i } | s _ { i + 1 } ; \theta ) ,
|
| 123 |
+
$$
|
| 124 |
+
|
| 125 |
+
where we again enforce that $F ( x ; \theta ) = R ( x )$ if $x$ is terminal. Observe that the DB condition (6) is a special case of (8) when the trajectory consists of one action, and the TB condition (7) is precisely the case when $\tau$ is complete, with the identification $Z _ { \theta } = F ( s _ { 0 } ; \theta )$ .
|
| 126 |
+
|
| 127 |
+
The above constraint yields the subtrajectory balance objective
|
| 128 |
+
|
| 129 |
+
$$
|
| 130 |
+
\mathcal { L } _ { \mathrm { S u b T B } } ( \tau ) = \left( \log \frac { F ( s _ { m } ; \theta ) \prod _ { i = m } ^ { n - 1 } P _ { F } ( s _ { i + 1 } | s _ { i } ; \theta ) } { F ( s _ { n } ; \theta ) \prod _ { i = m } ^ { n - 1 } P _ { B } ( s _ { i } | s _ { i + 1 } ; \theta ) } \right) ^ { 2 } .
|
| 131 |
+
$$
|
| 132 |
+
|
| 133 |
+
If this objective is made equal to 0 for all partial trajectories $\tau$ , where $R { \big ( } s _ { n } { \big ) }$ is substituted for $F ( s _ { n } ; \theta )$ if $s _ { n }$ is terminal, then the policy $P _ { F }$ satisfies the desired condition (2). (Proof: When $\mathcal { L } _ { \mathrm { S u b T B } } ( \tau ) = 0$ , (8) is satisfied, implying satisfaction of both (7) and (6). Either of these conditions is a sufficient condition for (2), as shown by Bengio et al. (2021b); Malkin et al. (2022).)
|
| 134 |
+
|
| 135 |
+
Extracting subtrajectories for training. Suppose that an episode (complete trajectory) $\tau =$ $\mathbf { \Phi } ^ { ' } s _ { 0 } { \longrightarrow } s _ { 1 } { \longrightarrow } \mathbf { \Phi } . \mathbf { \Phi } . \mathbf { \Phi } \longrightarrow s _ { n } )$ is sampled for training. There are ${ \binom { n + 1 } { 2 } } = O ( n ^ { 2 } )$ nontrivial subtrajectories:
|
| 136 |
+
|
| 137 |
+
$$
|
| 138 |
+
\tau _ { i : j } : = ( s _ { i } { \longrightarrow } s _ { i + 1 } { \longrightarrow } \ldots { \longrightarrow } s _ { j } ) , \quad 0 \leq i < j \leq n .
|
| 139 |
+
$$
|
| 140 |
+
|
| 141 |
+
Having sampled a complete trajectory $\tau$ for training, we make gradient steps on a convex combination of the subtrajectory balance losses $\mathcal { L } _ { \mathrm { { S u b T B } } } ( \tau _ { i : j } )$ : $\theta \gets \theta - \bar { \nabla } _ { \theta } \mathcal { L }$ , where
|
| 142 |
+
|
| 143 |
+
$$
|
| 144 |
+
\mathcal { L } = \frac { \sum _ { 0 \leq i < j \leq n } \lambda ^ { j - i } \mathcal { L } _ { \mathrm { S u b T B } } ( \tau _ { i : j } ) } { \sum _ { 0 \leq i < j \leq n } \lambda ^ { j - i } } .
|
| 145 |
+
$$
|
| 146 |
+
|
| 147 |
+
Here $\lambda > 0$ is a hyperparameter controlling the weights assigned to subtrajectories of different lengths, and when $\lambda$ is set to 1, it leads to a uniform weighting scheme. Notice that the $\lambda \to 0 ^ { + }$ limit leads precisely to the average detailed balance loss $\mathcal { L } _ { \mathrm { D B } } ( s _ { i } \{ s _ { i + 1 } )$ over all transitions in $\tau$ , while the $\lambda \to + \infty$ limit gives the trajectory balance objective $\mathcal { L } _ { \mathrm { T B } } ( \tau )$ .1
|
| 148 |
+
|
| 149 |
+
Other schemes for weighting subtrajectories are possible and should be explored in future work.
|
| 150 |
+
|
| 151 |
+
Computational considerations. It may appear that the optimization of (11) induces a computation cost that is quadratic in the trajectory length. However, a closer inspection of the gradient of (11) with respect to the state flows $\log F ( s _ { i } ; \theta )$ and the forward and backward policy logits shows that gradient computation requires only one forward and one backward pass through the neural networks giving log $F ( s ; \theta )$ , $\log \bar { P _ { F } } ( - | s _ { i } ; \theta )$ , and $\log P _ { B } ( - | s _ { i } ; \theta )$ . The quadratic computation cost is incurred only in performing linear operations on these log-flows and policy logits, not in the evaluation of the deep networks. Thus the SubTB loss has little computation overhead over DB or TB.
|
| 152 |
+
|
| 153 |
+
Hypothesized benefits. We hypothesize that SubTB(??) brings two benefits to GFlowNet training:
|
| 154 |
+
|
| 155 |
+
VARIANCE REDUCTION. The TB loss terms $\mathcal { L } _ { \mathrm { T B } } ( \tau )$ for trajectories $\tau$ that take a given sequence of actions until a state $s$ , then diverge, share the terms $\log Z$ and the policy logits for all transitions preceding $s$ inside the square. However, the ‘tail’ of the TB loss, involving the forward and backward policy logits for transitions that appear after $s$ in $\tau$ , can be seen as a stochastic least-squares regression target. That is, if $s = s _ { m }$ in a trajectory $\tau = ( s _ { 0 } { } s _ { 1 } { } \dots { } s _ { n } )$ , then
|
| 156 |
+
|
| 157 |
+
$$
|
| 158 |
+
\log \left( Z \cdot \prod _ { i = 0 } ^ { m - 1 } \frac { P _ { F } ( s _ { i + 1 } | s _ { i } ) } { P _ { B } ( s _ { i } | s _ { i + 1 } ) } \right)
|
| 159 |
+
$$
|
| 160 |
+
|
| 161 |
+
is regressed to
|
| 162 |
+
|
| 163 |
+
$$
|
| 164 |
+
\log \left( R ( s _ { n } ) \cdot \prod _ { i = m } ^ { n - 1 } { \frac { P _ { B } ( s _ { i } | s _ { i + 1 } ) } { P _ { F } ( s _ { i + 1 } | s _ { i } ) } } \right) .
|
| 165 |
+
$$
|
| 166 |
+
|
| 167 |
+
Similarly, for trajectories that share the transitions following $s$ but may differ in their initial actions, (12) is a stochastic regression target for (13).
|
| 168 |
+
|
| 169 |
+
The subtrajectory balance loss terms $\mathcal { L } _ { \mathrm { S u b T B } } ( \tau _ { m : j } )$ for partial trajectories beginning at $s$ regress the log-state flow $\dot { \log { F ( s ) } }$ to (parts of) expressions like (13), while loss terms $\mathcal { L } _ { \mathrm { { S u b T B } } } ( \tau _ { i : m } )$ regress (parts of) expressions like (12) to the log-state flow $\log F ( s )$ . The learned $\log F ( s )$ is thus a learned estimate of a stochastic piece of the TB loss for trajectories that contain $s$ . Replacing a stochastic term in the TB loss by a learned estimate of its expectation is guaranteed to introduce bias into the gradient (with respect to the gradient of the TB loss), but is expected to reduce variance. This is akin to the variance-reducing effect of actor-critic methods in RL.
|
| 170 |
+
|
| 171 |
+
This hypothesis is studied empirically in our experiments and in particular $\ S 4 . 1 . 1$ , where we provide evidence that SubTB(??) is a practically useful interpolation between TB (high variance) and DB (low variance, high bias relative to the true TB gradient) losses.
|
| 172 |
+
|
| 173 |
+
FASTER LEARNING DUE TO GENERALIZATION OF STATE FLOWS. Another benefit of subtrajectory balance for convergence speed may come from the ability of estimated state flow functions $\log F ( s ; \theta )$ to be modeled with high precision and generalize between states $s$ faster than the often high-dimensional policy logits $\log \bar { P _ { F } } ( - | s ; \theta )$ , $\log { \bar { P } _ { B } ( - | s ; \theta ) }$ . Such generalization is important in problems where the state graph becomes ‘wide’ far from the initial state, making the learning signal sparse at states that are near termination. Indeed, in all of our experiment domains except the hypergrids in $\ S 4 . 1$ – and for the largest hypergrids – the number of terminal states is many orders of magnitude larger than the total number of states seen in training.
|
| 174 |
+
|
| 175 |
+
# 3 RELATED WORK
|
| 176 |
+
|
| 177 |
+
Eligibility traces. SubTB(??) draws inspiration from the $\mathrm { T D } ( \lambda )$ algorithm in RL (Sutton, 1988; Sutton & Barto, 2018), which forms an estimate of the expected return via a convex combination of $n$ -step returns, each weighed by $( 1 - \lambda ) \lambda ^ { n - 1 }$ . The parameter $\lambda \in [ 0 , 1 ]$ enables a bias-variance tradeoff (Kearns & Singh, 2000). Intuitively, larger $\lambda$ leads to lower bias and higher variance, since the estimate of the expected return approaches the single-point Monte Carlo estimate as $\lambda 1$ . We take inspiration from this idea to mix together different (possibly all) subtrajectories, akin to how $n$ -step returns are mixed together. We hypothesize that the right mixing may reduce variance, compared to TB, with the additional benefits of inducing consistency between the flows of intermediate states, and thus of helping propagate credit faster and enable faster convergence. In addition, GFlowNet training objectives are reminiscent of residual gradient RL methods (Baird, 1995; Zhang et al., 2020) since the “endpoint” (e.g. $F ( s _ { n } )$ in (9)) is also considered in the gradient.
|
| 178 |
+
|
| 179 |
+
MaxEnt RL. RL has a rich literature on energy-based, or maximum entropy, methods (Ziebart, 2010; Mnih et al., 2016; Haarnoja et al., 2017; Nachum et al., 2017; Schulman et al., 2017; Haarnoja et al., 2018), which are close or equivalent to the GFlowNet framework in certain settings (in particular when the MDP has a tree structure (Bengio et al., 2021a)). Also related are methods that maximize entropy not on the policy, but rather on the state visitation distribution (Hazan et al., 2019; Islam et al., 2019; Zhang et al., 2021) or some proxy of it (Eysenbach et al., 2018), which achieve a similar objective to GFlowNet models by flattening the state visitation distribution. If the state graph of the environment is a directed tree, the loss $\mathcal { L } _ { \mathrm { S u b T B } }$ on individual subtrajectories is equivalent to that of path consistency learning (Nachum et al., 2017). However, attempts to use path consistency learning in settings without intermediate rewards have only computed the loss on subtrajectories that have length 1 or include a terminal state (Guo et al., 2021).
|
| 180 |
+
|
| 181 |
+

|
| 182 |
+
Figure 3: $L ^ { 1 }$ distance between empirical and target distributions over the course of training on the hypergrid environment. SubTB( $\lambda = 0 . 9 )$ ) consistently gives faster convergence than TB, the strongest objective from past work, on all grid sizes. The difference is especially visible for the harder variant of the reward function (last row). The $x$ -axis is the cumulative number of training trajectories (episodes).
|
| 183 |
+
|
| 184 |
+
# 4 EXPERIMENTS
|
| 185 |
+
|
| 186 |
+
# 4.1 HYPERGRID: ROBUSTNESS TO SPARSE REWARDS
|
| 187 |
+
|
| 188 |
+
We study the synthetic hypergrid environment introduced in Bengio et al. (2021a). The set of interior states is a $d$ -dimensional hypergrid of size $H \times H \times \cdots \times H$ with a multimodal reward function concentrated near each of the $2 ^ { d }$ corners of the hypergrid (see Bengio et al. (2021a); Malkin et al. (2022) and Fig. 1). The initial state is $( 0 , \bar { 0 , } \ldots , 0 )$ , and each action is a step that increments one of the $d$ coordinates by 1 without leaving the grid. A special termination action is also allowed from each state. This environment is designed to challenge a learning agent to infer and discover new modes from those that have been already been visited.
|
| 189 |
+
|
| 190 |
+

|
| 191 |
+
Figure 1: $1 6 \times 1 6$ hypergrid reward function.
|
| 192 |
+
|
| 193 |
+
We study various sizes of 2-dimensional and 4-dimensional hypergrids, using the hardest variant of the reward function from past work (the minimal reward, away from the corners of the grid, is set to $1 0 ^ { - 3 }$ ). We train GFlowNets to sample from the target reward functions and plot the evolution of the $L ^ { 1 }$ distance between the target distribution and the empirical distribution of the last $2 \cdot 1 0 ^ { 5 }$ states seen in training.2 In all cases, we tune the learning rates for the TB and SubTB $\lambda = 0 . 9 ,$ objectives. (See $\ S \mathrm { A }$ for details.)
|
| 194 |
+
|
| 195 |
+
The results (mean and standard deviation over three random runs) are shown in the first two rows of Fig. 3. Models trained with SubTB $( \lambda )$ converge faster, and with less variance between random seeds, to the true distribution than with TB for all hypergrid sizes.
|
| 196 |
+
|
| 197 |
+
We also study an even sparser variant of the environment, in which the background reward is set to $1 0 ^ { - 4 }$ . In this case, SubTB $( \lambda )$ continues to perform strongly (last row of Fig. 3), while models trained with TB do not even discover all modes of the target distribution for grids larger than $8 \times 8$ (Fig. 2).
|
| 198 |
+
|
| 199 |
+

|
| 200 |
+
Figure 2: Distribution of $2 \times$ $1 0 ^ { \bar { 5 } }$ samples from GFlowNets trained on the harder variant of the $3 2 \times 3 2$ grid with TB and SubTB(??) objectives.
|
| 201 |
+
|
| 202 |
+
Additional results are given in $\ S \mathrm { A } . 1$ . In particular, SubTB(??) continues to perform strongly when only subtrajectories of less than a certain length are used for training, which can be beneficial in realistic settings where only partial episodes are given. We also show the effect of $\lambda$ on the convergence rate (Fig. A.2) and of more exploratory training policies (Fig. A.3).
|
| 203 |
+
|
| 204 |
+

|
| 205 |
+
Figure 4: Mean cosine similarity between small-batch $( 2 ^ { k } )$ and large-batch (1024) gradients at selected training iterations. Left: Small-batch vs. large-batch gradients of DB, SubTB $( \lambda )$ , and TB objectives. Right: Small-batch DB, SubTB $( \lambda )$ , and TB gradients vs. large-batch TB gradient.
|
| 206 |
+
|
| 207 |
+
# 4.1.1 A CLOSER LOOK AT GRADIENT VARIANCE
|
| 208 |
+
|
| 209 |
+
We take a closer look at gradient bias and variance to understand the benefits of training GFlowNets with SubTB $( \lambda )$ . The methodology of these experiments is inspired by Ilyas et al. (2020).
|
| 210 |
+
|
| 211 |
+
We train GFlowNets on the $8 \times 8$ grid environment using SubTB $\lambda \ : = \ : 0 . 8 )$ and monitor various gradient metrics during training. To remove the effect of parameter sharing between policies at different states and to isolate the effect of the objective, we use a tabular representation of the GFlowNet, i.e., all flows and policy logits are optimized as independent parameters.
|
| 212 |
+
|
| 213 |
+
Gradient variance. To measure gradient variance, we use the following procedure for each training objective (DB, TB, or SubTB(??)). A large batch of $2 ^ { 1 0 } \ = \ 1 0 2 4$ trajectories is sampled, and the gradient $g _ { j } ^ { ( 0 ) }$ of the objective with respect to the policy logits at all states is computed for each trajectory $\tau _ { j }$ in the batch. Then, for each $k \in \{ 0 , 1 , \ldots , 9 \}$ , the gradients $g _ { i } ^ { ( 0 ) }$ are combined into $2 ^ { 1 0 - k }$ sub-batches, each of size $2 ^ { k }$ . The subbatch gradient $g _ { i } ^ { ( k ) }$ for the $i .$ -th sub-batch is set to the average of trajectory gradients $g _ { j } ^ { ( 0 ) }$ contained within the sub-batch and computed for $i \in \{ 1 , 2 , \ldots , 2 ^ { 1 0 - k } \}$ . We then report the average cosine similarity between the sub-batch and full-batch gradients:
|
| 214 |
+
|
| 215 |
+
$$
|
| 216 |
+
{ \frac { 1 } { 2 ^ { 1 0 - k } } } \sum _ { i = 1 } ^ { 2 ^ { 1 0 - k } } { \frac { g _ { i } ^ { ( k ) } \cdot g _ { 1 } ^ { ( 1 0 ) } } { \left\| g _ { i } ^ { ( k ) } \right\| \left\| g _ { 1 } ^ { ( 1 0 ) } \right\| } } .
|
| 217 |
+
$$
|
| 218 |
+
|
| 219 |
+
If this quantity is positive, then gradient steps of infinitesimally small norm along the stochastic sub-batch gradient decrease the full-batch objective in expectation. Fig. 4 (left) shows the dependence of this metric on $k$ at various iterations. A steeper curve, such as those of DB and SubTB $( \lambda )$ , indicates lower gradient variance.
|
| 220 |
+
|
| 221 |
+

|
| 222 |
+
Figure 5: Mean cosine similarity between small-batch (64) and large-batch (1024) gradients on the $\mathrm { \bar { 8 } } \times \mathrm { 8 }$ grid environment. Above: Self-similarity of the DB, SubTB $( \lambda )$ , and TB gradients, showing $\mathrm { D B } < \mathrm { S u b } \bar { \mathrm { T B } } ( \lambda )$ $< \mathrm { T B }$ in gradient variance. Below: Similarity of small-batch DB, SubTB $( \lambda )$ , and TB gradients to the large-batch TB gradient, showing that the small-batch SubTB(??) gradient is a good estimator of large-batch TB.
|
| 223 |
+
|
| 224 |
+
Fig. 5 (top) shows the metric at $k = 6$ (corresponding to the batch size of 64 used for training) over the course of training. We see that the DB gradient has the highest self-consistency at all iterations, TB has the lowest, and SubTB $\lambda = 0 . 8 )$ ) is in between.
|
| 225 |
+
|
| 226 |
+
Gradient bias. We next compare the small-batch stochastic gradients with large-batch stochastic gradients, using different objectives for the small and full batches. Specifically, we compare the small-batch DB, SubTB $( \lambda )$ , and TB gradients with the full-batch TB gradient. (The full-batch TB gradient can be seen as a ‘canonical’ gradient against which bias can be measured, as its expectation equals the gradient of the KL divergence between the distribution over trajectories defined by $P _ { F }$ and that defined by the reward $R$ and $P _ { B }$ ; see $\ S \mathrm { A } . 3$ of Malkin et al. (2022).)
|
| 227 |
+
|
| 228 |
+
Fig. 5 (bottom) shows the cosine similarity at the batch size used for training. Notably, at intermediate iterations, the similarity of SubTB(??) with TB is higher than that of TB with TB: despite its bias, the small-batch SubTB(??) gradient estimates the full-batch TB gradient better than the small-batch TB gradient does. Fig. 4 (right) shows the dependence of the similarity on $k$ at selected iterations and suggests that this effect may be even larger for smaller batch sizes. Moreover, at $k = 1 0$ , the similarity of SubTB(??) vs. TB always lies between DB vs. TB and TB vs. TB, indicating that SubTB(??) interpolates between TB’s unbiased and DB’s biased estimates of the TB gradient.
|
| 229 |
+
|
| 230 |
+
The effect of learned state flows. For additional experiments, see $\ S \mathrm { A } . 2$ .
|
| 231 |
+
|
| 232 |
+

|
| 233 |
+
Figure 6: Correlation between marginal sampling log-likelihood and log-reward on the molecule task. For each hyperparameter setting on the $x \cdot$ -axis, we plot the best result over choices of the other hyperparameter $( \mathrm { s } ) - \alpha$ in the left plot, $\beta$ in the centre plot, and both $\alpha$ and $\beta$ in the right plot – with a solid line. The mean result over values of other hyperparameter(s) is plotted with a dashed line.
|
| 234 |
+
|
| 235 |
+
# 4.2 SMALL MOLECULE SYNTHESIS
|
| 236 |
+
|
| 237 |
+
We use $\operatorname { S u b T B } ( \lambda )$ to train models on the molecule generation task of Bengio et al. (2021a). The task is to generate binders of the sEH (soluble epoxide hydrolase) protein, based on a docking prediction (Trott & Olson, 2010). To be precise, molecules are generated by sequentially joining ‘blocks’ from a fixed library to the partial molecular graph (Jin et al., 2020; Kumar et al., 2012), resulting in a state space of estimated size $1 0 ^ { 1 2 }$ . The reward function $R$ is given by a pretrained proxy model made available by Bengio et al. (2021a). To adjust the greediness of the agent, an inverse temperature hyperparameter $\beta$ is used, i.e., the reward used for training is $R ( x ) = \widetilde { R } ( x ) ^ { \beta }$ , where $\widetilde { R } ( \boldsymbol { x } )$ is the proxy’s prediction.
|
| 238 |
+
|
| 239 |
+
We train models with the DB, TB, and SubTB $( \lambda )$ objectives, with four values each of $\lambda , \beta$ , and learning rate, averaging the results over 3 random runs for each setting. We measure how well the trained models match the target distribution by the correlation of $\log R ( x )$ and $\log p _ { \theta } ( x )$ , the log-probability assigned to $x$ by the GFlowNet, computed on a held-out set of terminal states $x$ . 3
|
| 240 |
+
|
| 241 |
+
The results are shown in Fig. 6. SubTB $( \lambda )$ , in particular with $\lambda = 1$ , performs better than both DB and TB when the optimal hyperparameters $\alpha , \beta$ are used (solid lines) and is far more robust to the choice of hyperparameters (dashed lines). Additional details can be found in $\ S \mathbf { B }$ .
|
| 242 |
+
|
| 243 |
+
# 4.3 SEQUENCE GENERATION
|
| 244 |
+
|
| 245 |
+
We consider three sequence generation tasks in which sequences are generated left to right, with each action appending one symbol from a vocabulary to a partial sequence: a synthetic task with varying sequence lengths and vocabulary sizes (§4.3.1), a practical biological sequence design task $( \ S 4 . 3 . 2 )$ , and a new protein design task with longer sequences (4.3.3). For all three tasks, we consider the baselines Soft Actor-Critic (Haarnoja et al., 2018; Christodoulou, 2019), A2C with Entropy regularization (Williams & Peng, 1991; Mnih et al., 2016) and MARS-like MCMC (Xie et al., 2021) and compare them with three GFlowNet training objectives: TB, FM, and SubTB $( \lambda )$ .
|
| 246 |
+
|
| 247 |
+
In $\ S \mathrm { F }$ , we also study a non-autoregressive sequence generation problem (inverse protein folding).
|
| 248 |
+
|
| 249 |
+
# 4.3.1 BIT SEQUENCES
|
| 250 |
+
|
| 251 |
+
We consider the synthetic sequence generation setting from Malkin et al. (2022), where the goal is to generate sequences of bits of fixed length $n = 1 2 0$ . The reward is specified by a set of modes $M ^ { ^ { - } } \subset X = \{ 0 , \bar { 1 } \} ^ { n }$ that is unknown to the learning agent. The reward of a generated sequence $x$ is defined in terms of Hamming distance $d$ from the modes: $R ( x ) = \mathrm { { e x p } } ( - \mathrm { { m i n } } _ { y \in M } d ( x , y ) { \bar { ) } }$ .
|
| 252 |
+
|
| 253 |
+
The vocabulary size can be varied: for any integer $k$ dividing 120, we take a vocabulary consisting of words of length $k$ (so that the vocabulary size is $2 ^ { k }$ and the full sequence is generated in $\frac { n } { k }$ actions). By varying the value of $k$ and keeping $n$ and $M$ constant, we study the behavior of learning agents with varying action space sizes and trajectory lengths without changing the underlying modeling problem. Most experiment settings are taken from Malkin et al. (2022); see $\ S C$ .
|
| 254 |
+
|
| 255 |
+

|
| 256 |
+
Figure 7: Left: For the number of bits $k \in \{ 1 , 2 , 4 , 6 , 8 , 1 0 \}$ in each vocabulary token, we plot the Spearman correlation between the sampling probability and reward on a test set for each method. Training with SubTB(??) leads to policies that have the highest correlation with the reward across all lengths and vocabulary sizes. Right: For $k = 1$ , the number of modes discovered by each method over the course of training is plotted. SubTB $( \lambda )$ discovers more modes faster.
|
| 257 |
+
|
| 258 |
+
Models are evaluated by computing the Spearman correlation, on a test set of sequences $x$ , between the probability of generating $x$ and the reward $R ( x )$ . We also track the number of modes discovered during the training process for all the methods, see Fig. 7. We find that models trained with the SubTB(??) objective have a higher Spearman correlation at the end of training and discover modes faster compared to the other GFlowNet objectives and non-GFlowNet baselines.
|
| 259 |
+
|
| 260 |
+
# 4.3.2 ANTIMICROBIAL PEPTIDE GENERATION
|
| 261 |
+
|
| 262 |
+
Next, we consider the task of generating peptides with antimicrobial properties (AMPs). These sequences have maximum length 60 and use a vocabulary of 20 amino acids (and an end-of-sequence token), resulting in a state space of size $2 1 ^ { 6 0 }$ . The reward function is a pretrained proxy neural network that estimates the antimicrobial activity. (See Jain et al. (2022) for details on this task.)
|
| 263 |
+
|
| 264 |
+
Table 2: Results on the AMP generation task (mean and standard error over 3 runs).
|
| 265 |
+
|
| 266 |
+
<table><tr><td>Algorithm</td><td>Top-100 Reward</td><td>Top-100 Diversity</td></tr><tr><td>GFN-LSubTB()</td><td>0.96 ± 0.02</td><td>42.23 ± 3.4</td></tr><tr><td>GFN-LTB</td><td>0.90 ± 0.03</td><td>31.42 ± 2.9</td></tr><tr><td>GFN-LFM/LDB</td><td>0.78 ± 0.05</td><td>12.61 ± 1.32</td></tr><tr><td>SAC</td><td>0.80± 0.01</td><td>8.36 ± 1.44</td></tr><tr><td>AAC-ER</td><td>0.79 ± 0.02</td><td>7.32 ± 0.76</td></tr><tr><td>MCMC</td><td>0.75± 0.02</td><td>12.56 ± 1.45</td></tr></table>
|
| 267 |
+
|
| 268 |
+
We train GFlowNets with the SubTB $( \lambda )$ , TB, and FM losses and compare them with baselines. To evaluate the trained models, we sample 2048 sequences from the policy, then compute the mean reward and mean pairwise edit distance of the top-100 reward sequences. The metrics and model architecture are taken from Malkin et al. (2022); see $\ S _ { \mathrm { D } }$ . The results are presented in Table 2. SubTB(??) provides significant improvements over all the baselines (including TB, FM, and DB GFlowNets) in both reward and diversity.
|
| 269 |
+
|
| 270 |
+
# 4.3.3 FLUORESCENT PROTEIN GENERATION
|
| 271 |
+
|
| 272 |
+
We consider the task of generating protein sequences with fluorescence properties (Trabucco et al., 2022) to evaluate SubTB(??) in settings with longer trajectories. In this task, sequences have a fixed length of 237, and the size of the state space is $\cdot$ . The proxy reward function $R ( x )$ is trained on a dataset of proteins with their fluorescence scores from Sarkisyan et al. (2016). The metrics and models are the same as in $\ S 4 . 3 . 2$ ; see $\ S \mathrm { E }$ for details.
|
| 273 |
+
|
| 274 |
+
Table 3: Results on the GFP generation task (mean and standard error over 3 runs).
|
| 275 |
+
|
| 276 |
+
<table><tr><td>Algorithm</td><td>Top-100 Reward</td><td>Top-100Diversity</td></tr><tr><td>GFN-LSubTB(λ)</td><td>1.18 ± 0.10</td><td>204.44 ± 0.45</td></tr><tr><td>GFN-LTB</td><td>0.76 ± 0.19</td><td>204.31 ± 0.44</td></tr><tr><td>GFN-LFM/LDB</td><td>0.30± 0.08</td><td>190.21 ± 6.78</td></tr><tr><td>SAC</td><td>0.23 ± 0.03</td><td>120.32 ± 15.57</td></tr><tr><td>AAC-ER</td><td>0.22 ± 0.02</td><td>113.65 ± 21.31</td></tr><tr><td>MCMC</td><td>0.28 ± 0.01</td><td>169.17 ± 12.44</td></tr></table>
|
| 277 |
+
|
| 278 |
+
The GFlowNet objectives outperform all other methods in both metrics, finding more diverse and higher-reward sequences (Table 3). SubTB(??) significantly outperforms TB, while achieving a similar diversity. We note that the advantage of SubTB(??) is greater than that in the AMP task (Table 2) and speculate that the benefits of SubTB(??) become more prominent for longer action sequences.
|
| 279 |
+
|
| 280 |
+
# 5 DISCUSSION AND CONCLUSION
|
| 281 |
+
|
| 282 |
+
We have given evidence of a bias-variance tradeoff in GFlowNet training algorithms. The highvariance stochastic regression objective of TB and the low-variance local consistency objective of DB lie at opposite ends of this range. We showed that SubTB(??) can harness the variance-reducing effects of local objectives while retaining the fast credit assignment properties of trajectory-level objectives. We see learnable strategies for selecting and weighting (sub)trajectories for training – e.g., a dynamic choice of $\lambda$ and an active-learning approach to sampling trajectories – as the most interesting questions for future work. The ability of subtrajectory objectives to learn from incomplete episodes also makes their application in RL environments an appealing research direction.
|
| 283 |
+
|
| 284 |
+
# REPRODUCIBILITY STATEMENT
|
| 285 |
+
|
| 286 |
+
We provide extensive experiment details, such as learning rates, batch sizes, number of training steps, choices of $\lambda$ , description of attempted hyperparameters, and additional clarifying experiments in the Appendices. Code for experiments on the hypergrid domain $( \ S 4 . 1 )$ and on the molecule domain (§4.2) is also provided with the submission.
|
| 287 |
+
|
| 288 |
+
# REFERENCES
|
| 289 |
+
|
| 290 |
+
Leemon Baird. Residual algorithms: Reinforcement learning with function approximation. International Conference on Machine Learning (ICML), 1995.
|
| 291 |
+
|
| 292 |
+
Emmanuel Bengio, Joelle Pineau, and Doina Precup. Interference and generalization in temporal difference learning. International Conference on Machine Learning (ICML), 2020.
|
| 293 |
+
|
| 294 |
+
Emmanuel Bengio, Moksh Jain, Maksym Korablyov, Doina Precup, and Yoshua Bengio. Flow network based generative models for non-iterative diverse candidate generation. Neural Information Processing Systems (NeurIPS), 2021a.
|
| 295 |
+
|
| 296 |
+
Yoshua Bengio, Salem Lahlou, Tristan Deleu, Edward Hu, Mo Tiwari, and Emmanuel Bengio. GFlowNet foundations. arXiv preprint 2111.09266, 2021b.
|
| 297 |
+
|
| 298 |
+
David Brookes, Hahnbeom Park, and Jennifer Listgarten. Conditioning by adaptive sampling for robust design. International Conference on Machine Learning (ICML), 2019.
|
| 299 |
+
|
| 300 |
+
Sidhartha Chaudhury, Sergey Lyskov, and Jeffrey J Gray. PyRosetta: a script-based interface for implementing molecular modeling algorithms using Rosetta. Bioinformatics, 26(5):689–691, 2010.
|
| 301 |
+
|
| 302 |
+
Petros Christodoulou. Soft actor-critic for discrete action settings. arXiv preprint 1910.07207, 2019.
|
| 303 |
+
|
| 304 |
+
Tristan Deleu, Antonio G ´ ois, Chris Emezue, Mansi Rankawat, Simon Lacoste-Julien, Stefan Bauer, ´ and Yoshua Bengio. Bayesian structure learning with generative flow networks. Uncertainty in Artificial Intelligence (UAI), 2022.
|
| 305 |
+
|
| 306 |
+
Benjamin Eysenbach, Abhishek Gupta, Julian Ibarz, and Sergey Levine. Diversity is all you need: Learning skills without a reward function. International Conference on Learning Representations (ICLR), 2018.
|
| 307 |
+
|
| 308 |
+
Han Guo, Bowen Tan, Zhengzhong Liu, Eric P. Xing, and Zhiting Hu. Text generation with efficient (soft) Q-learning. arXiv preprint 2106.07704, 2021.
|
| 309 |
+
|
| 310 |
+
Tuomas Haarnoja, Haoran Tang, Pieter Abbeel, and Sergey Levine. Reinforcement learning with deep energy-based policies. International Conference on Machine Learning (ICML), 2017.
|
| 311 |
+
|
| 312 |
+
Tuomas Haarnoja, Aurick Zhou, Pieter Abbeel, and Sergey Levine. Soft actor-critic: Off-policy maximum entropy deep reinforcement learning with a stochastic actor. International Conference on Machine Learning (ICML), 2018.
|
| 313 |
+
|
| 314 |
+
Elad Hazan, Sham Kakade, Karan Singh, and Abby Van Soest. Provably efficient maximum entropy exploration. International Conference on Machine Learning (ICML), 2019.
|
| 315 |
+
|
| 316 |
+
Andrew Ilyas, Logan Engstrom, Shibani Santurkar, Dimitris Tsipras, Firdaus Janoos, Larry Rudolph, and Aleksander Madry. A closer look at deep policy gradients. International Conference on Learning Representations (ICLR), 2020.
|
| 317 |
+
|
| 318 |
+
Riashat Islam, Zafarali Ahmed, and Doina Precup. Marginalized state distribution entropy regularization in policy optimization. arXiv preprint 1912.05128, 2019.
|
| 319 |
+
|
| 320 |
+
Moksh Jain, Emmanuel Bengio, Alex Hernandez-Garcia, Jarrid Rector-Brooks, Bonaventure F.P. Dossou, Chanakya Ekbote, Jie Fu, Tianyu Zhang, Micheal Kilgour, Dinghuai Zhang, Lena Simine, Payel Das, and Yoshua Bengio. Biological sequence design with GFlowNets. International Conference on Machine Learning (ICML), 2022.
|
| 321 |
+
|
| 322 |
+
Wengong Jin, Regina Barzilay, and Tommi Jaakkola. Chapter 11. junction tree variational autoencoder for molecular graph generation. Drug Discovery, pp. 228–249, 2020. ISSN 2041-3211.
|
| 323 |
+
|
| 324 |
+
Michael J Kearns and Satinder P Singh. Bias-variance error bounds for temporal difference updates. Conference on Learning Theory (COLT), 2000.
|
| 325 |
+
|
| 326 |
+
Ashutosh Kumar, Arnout Voet, and Kam Y.J. Zhang. Fragment based drug design: from experimental to computational approaches. Current medicinal chemistry, 19(30):5128–5147, 2012.
|
| 327 |
+
|
| 328 |
+
Nikolay Malkin, Moksh Jain, Emmanuel Bengio, Chen Sun, and Yoshua Bengio. Trajectory balance: Improved credit assignment in GFlowNets. Neural Information Processing Systems (NeurIPS), 2022.
|
| 329 |
+
|
| 330 |
+
Volodymyr Mnih, Adria Puigdomenech Badia, Mehdi Mirza, Alex Graves, Timothy Lillicrap, Tim Harley, David Silver, and Koray Kavukcuoglu. Asynchronous methods for deep reinforcement learning. Neural Information Processing Systems (NIPS), 2016.
|
| 331 |
+
|
| 332 |
+
Ofir Nachum, Mohammad Norouzi, Kelvin Xu, and Dale Schuurmans. Bridging the gap between value and policy based reinforcement learning. Neural Information Processing Systems (NIPS), 2017.
|
| 333 |
+
|
| 334 |
+
Malak Pirtskhalava, Anthony A Amstrong, Maia Grigolava, Mindia Chubinidze, Evgenia Alimbarashvili, Boris Vishnepolsky, Andrei Gabrielian, Alex Rosenthal, Darrell E Hurt, and Michael Tartakovsky. Dbaasp v3: Database of antimicrobial/cytotoxic activity and structure of peptides as a resource for development of new therapeutics. Nucleic Acids Research, 49(D1):D288–D297, 2021.
|
| 335 |
+
|
| 336 |
+
Carol A Rohl, Charlie EM Strauss, Kira MS Misura, and David Baker. Protein structure prediction using Rosetta. In Methods in enzymology, volume 383, pp. 66–93. Elsevier, 2004.
|
| 337 |
+
|
| 338 |
+
Karen S Sarkisyan, Dmitry A Bolotin, Margarita V Meer, Dinara R Usmanova, Alexander S Mishin, George V Sharonov, Dmitry N Ivankov, Nina G Bozhanova, Mikhail S Baranov, Onuralp Soylemez, et al. Local fitness landscape of the green fluorescent protein. Nature, 533(7603):397–401, 2016.
|
| 339 |
+
|
| 340 |
+
John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. arXiv preprint 1707.06347, 2017.
|
| 341 |
+
|
| 342 |
+
Sam Sinai, Richard Wang, Alexander Whatley, Stewart Slocum, Elina Locane, and Eric Kelsic. AdaLead: A simple and robust adaptive greedy search algorithm for sequence design. arXiv preprint 2010.02141, 2020.
|
| 343 |
+
|
| 344 |
+
Richard S Sutton. Learning to predict by the methods of temporal differences. Machine learning, 3 (1):9–44, 1988.
|
| 345 |
+
|
| 346 |
+
Richard S Sutton and Andrew G Barto. Reinforcement learning: An introduction. MIT Press, 2018.
|
| 347 |
+
|
| 348 |
+
Brandon Trabucco, Xinyang Geng, Aviral Kumar, and Sergey Levine. Design-bench: Benchmarks for data-driven offline model-based optimization. International Conference on Machine Learning (ICML), 2022.
|
| 349 |
+
|
| 350 |
+
Oleg Trott and Arthur J Olson. AutoDock Vina: improving the speed and accuracy of docking with a new scoring function, efficient optimization, and multithreading. Journal of computational chemistry, 31(2):455–461, 2010.
|
| 351 |
+
|
| 352 |
+
Hado van Hasselt, Yotam Doron, Florian Strub, Matteo Hessel, Nicolas Sonnerat, and Joseph Modayil. Deep reinforcement learning and the deadly triad. arXiv preprint 1812.02648, 2018.
|
| 353 |
+
|
| 354 |
+
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Neural Information Processing Systems (NIPS), 2017.
|
| 355 |
+
|
| 356 |
+
Ronald Williams and Jing Peng. Function optimization using connectionist reinforcement learning algorithms. Connection Science, 3:241–, 09 1991. doi: 10.1080/09540099108946587.
|
| 357 |
+
|
| 358 |
+
Yutong Xie, Chence Shi, Hao Zhou, Yuwei Yang, Weinan Zhang, Yong Yu, and Lei Li. MARS: Markov molecular sampling for multi-objective drug discovery. International Conference on Learning Representations (ICLR), 2021.
|
| 359 |
+
|
| 360 |
+
Chuheng Zhang, Yuanying Cai, Longbo Huang, and Jian Li. Exploration by maximizing Renyi ´ entropy for reward-free RL framework. Association for the Advancement of Artificial Intelligence (AAAI), 2021.
|
| 361 |
+
|
| 362 |
+
Dinghuai Zhang, Nikolay Malkin, Zhen Liu, Alexandra Volokhova, Aaron Courville, and Yoshua Bengio. Generative flow networks for discrete probabilistic modeling. International Conference on Machine Learning (ICML), 2022.
|
| 363 |
+
|
| 364 |
+
Shangtong Zhang, Wendelin Boehmer, and Shimon Whiteson. Deep residual reinforcement learning. Autonomous Agents and Multi-Agent Systems (AAMAS), 2020.
|
| 365 |
+
|
| 366 |
+
Brian D Ziebart. Modeling purposeful adaptive behavior with the principle of maximum causal entropy. Carnegie Mellon University, 2010.
|
| 367 |
+
|
| 368 |
+

|
| 369 |
+
Figure A.1: Additional results for hypergrid experiments. Above: The evolution of the $L ^ { 1 }$ between empirical sampling and target distributions on the harder variants of 4-dimensional grids, in the same format as Fig. 3. Below: The number of cumulative distinct terminal states visited as a function of training time on the standard 2-dimensional grid. Models trained with SubTB(??) discover more states faster.
|
| 370 |
+
|
| 371 |
+
# A EXPERIMENT DETAILS: HYPERGRID
|
| 372 |
+
|
| 373 |
+
The environment is identical to that in Malkin et al. (2022), with reward function parameters $( R _ { 0 } , R _ { 1 } , R _ { 2 } ) = ( 1 0 ^ { - 3 } , 0 . 5 , 2 )$ for the standard variant of the grid and $( 1 0 ^ { - 4 } , 1 . 0 , 3 . 0 )$ for the harder variant. The models giving logits of $P _ { F } ( - | s )$ and $P _ { B } ( - | s )$ , as well as $\log F ( s )$ , are MLPs of the same architecture as in Bengio et al. (2021a), taking a one-hot representation of the coordinates of $s$ as input and sharing all layers except the last. The initial state flow $\log Z = \log F ( s _ { 0 } )$ is an independent parameter whose learning rate is set to $1 0 \times$ the learning rate of other parameters.
|
| 374 |
+
|
| 375 |
+
All models are trained with the Adam optimizer and a batch size of 16 for a total of $1 0 ^ { 6 }$ trajectories (62500 batches). The optimal learning rate for each experiment is chosen from $\{ 0 . 0 0 0 5 , 0 . 0 0 0 7 5 , 0 . 0 0 1 , 0 . 0 0 3 , 0 . 0 0 5 , \bar { 0 } . 0 0 7 5 , 0 . 0 1 \}$ , and $\lambda = 0 . 9$ is chosen as the optimal value from the set $\{ 0 . 8 , 0 . 9 , 0 . 9 9 \}$ .
|
| 376 |
+
|
| 377 |
+
Gradient bias and variance experiments are conducted in the harder variant of the $8 \times 8$ grid. The tabular GFlowNet is trained using Adam with a learning rate 0.007 and the SubTB( $\lambda = 0 . 8 )$ objective.
|
| 378 |
+
|
| 379 |
+
# A.1 ADDITIONAL EXPERIMENTS
|
| 380 |
+
|
| 381 |
+
Fig. A.1 shows additional results on more difficult grid environments.
|
| 382 |
+
|
| 383 |
+
We perform another experiment in which only short (up to length 4) subtrajectories are used for training with the SubTB(??) objective (i.e., the sum in (11) is truncated to exclude pairs $( i , j )$ with $j - i > 4 )$ . The results, shown in Fig. A.4, show that SubTB(??) continues to perform strongly in this restricted setting.
|
| 384 |
+
|
| 385 |
+

|
| 386 |
+
Figure A.2: Empirical $L ^ { 1 }$ curves on the $8 \times 8$ grid for varying values of $\lambda$
|
| 387 |
+
|
| 388 |
+
Fig. A.2 shows the effect of the SubTB parameter $\lambda$ on the training curves, showing a gradual interpolation between DB and TB and fastest convergence at values slightly less than 1.
|
| 389 |
+
|
| 390 |
+
Fig. A.3 contains visualizations of the exploration behavior of different training algorithms. It shows that TB can perform better with off-policy training and can benefit from a higher temperature of the policy logits, but still does not learn as fast as SubTB $( \lambda )$ , nor does it find all the modes in the maximum number of training iterations.
|
| 391 |
+
|
| 392 |
+
A.2 MORE ON BIAS AND VARIANCE: THE EFFECT OF LEARNED STATE FLOWS
|
| 393 |
+
|
| 394 |
+
To better understand the variance-reducing properties of SubTB(??), we perform the gradient bias experiments with a modified computation of gradients that removes the factor of learning the state flows.
|
| 395 |
+
|
| 396 |
+
Recall from $\ S 2 . 1$ that a forward policy $P _ { F }$ uniquely determines a distribution over trajectories. If the initial state flow $Z$ and forward policy $P _ { F }$ are fixed, there is a unique state flow function $F ^ { F }$ and backward policy $P _ { B }$ that satisfy the detailed balance conditions (6). This ‘true forward’ flow function, written $\begin{array} { r } { F ^ { F } ( s ) = Z \sum _ { \tau : s \in \tau } P _ { F } ( \tau ) } \end{array}$ , is determined by an initial state flow fixed to the true partition function $\begin{array} { r } { Z = \sum _ { x \in X } R ( x ) } \end{array}$ and the learned forward policy $P _ { F }$ . Similarly, the ‘true backward’ flow function, written $\begin{array} { r } { F ^ { B } ( s ) = \sum _ { \tau : s \in \tau } P _ { B } ( \tau ) R ( x _ { \tau } ) } \end{array}$ where $x _ { \tau }$ is the terminal state of $\tau$ , is uniquely determined by the reward function $R$ and the learned backward policy $P _ { B }$ . In particular, $F ^ { B } ( s _ { 0 } ) =$ $\textstyle \sum _ { x \in X } R ( x )$ .
|
| 397 |
+
|
| 398 |
+

|
| 399 |
+
Figure A.3: Training GFlowNets on the harder variants of 2-dimensional grids using a tempered training policy (left), and a training policy that takes a uniformly random action with probability $\epsilon$ at each sampling step (right).
|
| 400 |
+
|
| 401 |
+

|
| 402 |
+
Figure A.4: Training GFlowNets using only short subtrajectories in different grid environments using the SubTB $\lambda = 0 . 9 ,$ ) objective.
|
| 403 |
+
|
| 404 |
+
We repeat the experiments on gradient bias, but by replacing the learned state flows $F$ in the losses by either the true forward or the true backward state flows ( $F ^ { F }$ or $F ^ { B }$ respectively) computed exactly using the current values of the learned $P _ { F }$ and $P _ { B }$ . (These modifications are not applied in training, but are used only to compute the gradient similarities. The small size of the environment makes computation of the true state flows tractable; this is not possible in general.)
|
| 405 |
+
|
| 406 |
+
The gradient similarity over the course of training is shown in Fig. A.5 (cf. Fig. 5 in the main text). The similar behavior of SubTB(??) with learned and true forward state flows suggests that the learned state flows remain close enough to their optimal values and that the variance-reducing benefits of SubTB(??) with true state flows are retained.
|
| 407 |
+
|
| 408 |
+
# B EXPERIMENT DETAILS: MOLECULES
|
| 409 |
+
|
| 410 |
+
All experiments with SubTB(??) are based upon the published code of Malkin et al. (2022), which extends that of Bengio et al. (2021a). The proxy model giving the reward, the held-out set of molecules used to compute the correlation metric, and the GFlowNet model architecture – a graph neural network – are identical to those in Bengio et al. (2021a), and the off-policy exploration rate and early stopping likelihood are the same as those tuned for the training with the TB objective in
|
| 411 |
+
|
| 412 |
+

|
| 413 |
+
Figure A.5: Gradient similarity with state flows analytically computed in two ways (see $\ S \mathrm { A } . 2 )$ . (Compare with Fig. 5.)
|
| 414 |
+
|
| 415 |
+
Malkin et al. (2022). All models are trained for a maximum of 50000 batches of 4 trajectories each. (Some training runs terminated early because of numerical overflows in the gradients, in which case we report the metric of the last stable model whose cumulative number of batches is a multiple of 5000.)
|
| 416 |
+
|
| 417 |
+
# C EXPERIMENT DETAILS: BIT SEQUENCES
|
| 418 |
+
|
| 419 |
+
The modes $M$ as well as the test sequences are selected as described in Malkin et al. (2022). The policy for all methods is parameterized by a Transformer (Vaswani et al., 2017) with 3 layers, dimension 64, and 8 attention heads. All methods are trained for 50,000 iterations with minibatch size of 16 using Adam optimizer. For GFlowNets with FM objective as well as the baselines, we use the exact same implementation and hyperparameters reported in Malkin et al. (2022). For TB and SubTB(??), we pick the best learning rate from $\{ 0 . 0 0 7 5 , \mathrm { \dot { 0 } } . 0 0 1 , 0 . 0 0 1 , 0 . 0 0 3 , 0 . 0 0 5 \}$ for forward logits, and for Z, use a learning rate of $1 0 \times$ the learning rate for forward logits. For SubTB $( \lambda )$ , we found the best $\lambda$ value of 1.9 from the values $\{ 0 . 8 , 0 . 9 , \bar { 1 } . 1 , 1 . 3 , 1 . 5 , 1 . 7 , 1 . 9 , 2 . 0 \}$ .
|
| 420 |
+
|
| 421 |
+
# D EXPERIMENT DETAILS: ANTIMICROBIAL PEPTIDE GENERATION
|
| 422 |
+
|
| 423 |
+
Following Malkin et al. (2022) we use the following amino acids: $[ { \bf \bar { \Psi } } { \bf A } ^ { \prime } , \mathrm { ~ \bar { \Psi } ~ } { \bf C } ^ { \prime } , \mathrm { ~ \bar { \Psi } ~ } { \bf D } ^ { \prime } , \mathrm { ~ \bar { \Psi } ~ } { \bf E } ^ { \prime } ,$ $^ { \mathrm { \tiny ~ v } } \mathrm { E } ^ { \prime } , \quad ^ { \mathrm { \tiny ~ v } } \mathrm { G } ^ { \prime } , \quad ^ { \mathrm { \tiny ~ v } } \mathrm { H } ^ { \prime } , \quad ^ { \mathrm { \tiny ~ v } } \mathrm { I } ^ { \prime } , \quad ^ { \mathrm { \tiny ~ v } } \mathrm { K } ^ { \prime } , \quad ^ { \mathrm { \tiny ~ v } } \mathrm { L } ^ { \prime } , \quad ^ { \mathrm { \tiny ~ v } } \mathrm { M } ^ { \prime } ,$ , ‘N’, ‘P’, ‘Q’, ‘R’, ‘S’, ‘T’ / $\mathrm { ~ \Delta ~ } ^ { \mathrm { \scriptstyle ~ v } \prime } , \mathrm { ~ \Delta ~ } ^ { \mathrm { \scriptstyle ~ v } \prime } , \mathrm { ~ \Delta ~ } ^ { \mathrm { \scriptstyle ~ v } \prime } ]$ . We take 6438 known AMP sequences and 9522 non-AMP sequences from the DBAASP database Pirtskhalava et al. (2021). The classifier that serves as the proxy reward function is trained on this dataset, using $2 0 \%$ of the data as the validation set. The reward model is a Transformer, with 4 hidden layers, hidden dimension 64, and 8 attention heads. We train it with a minibatch of size 256, with learning rate $1 0 ^ { - 4 }$ , and with early stopping on the validation set. We use a Transformer with 3 hidden layers with hidden dimension 64 with 8 attention heads as the architecture of the policy for all methods. All methods are trained for 20, 000 iterations, with a minibatch size of 16, using the reported hyperparameters for all the baselines from (Malkin et al., 2022). For TB and $\operatorname { S u b T B } ( \lambda )$ , we pick the best learning rates from $\{ 0 . 0 0 5 , 0 . 0 0 7 , 0 . 0 1 , 0 . 0 3 , 0 . 0 5 , 0 . 0 7 \}$ for forward logits and from $\{ 0 . 0 0 7 , 0 . 0 1 , 0 . 0 3 , \bar { 0 . 0 5 } \}$ for $\log Z$ . For SubTB(??), the best performing $\lambda$ value of 1.9 chosen from $\{ 0 . 9 , 0 . 9 9 , 1 . 1 , 1 . 2 , 1 . 3 , 1 . 4 , 1 . 6 , 1 . 7 , 1 . 8 , 1 . 9 , 2 . 0 \}$ is used.
|
| 424 |
+
|
| 425 |
+
# E EXPERIMENT DETAILS: FLUORESCENT PROTEIN GENERATION
|
| 426 |
+
|
| 427 |
+
We consider a variant of the GFP task from Trabucco et al. (2022). The vocabulary of amino acids is the same as $\ S _ { \mathrm { D } }$ : $[ { \bf \Psi } ^ { \mathrm { \tiny ~ \bullet } } \mathbb { A } ^ { \prime } , \mathrm { ~ \Psi ~ } ^ { \mathrm { \tiny ~ \bullet } } \mathbb { D } ^ { \prime } , \mathrm { ~ \Psi ~ } ^ { \mathrm { \tiny ~ \bullet } } \mathbb { E } ^ { \prime } , \mathrm { ~ \Psi ~ } ^ { \mathrm { \tiny ~ \bullet } } \mathbb { E } ^ { \prime } , \mathrm { ~ \Psi ~ } ^ { \mathrm { \tiny ~ \bullet } } \mathbb { H } ^ { \prime } , \mathrm { ~ \Psi ~ } ^ { \mathrm { \tiny ~ \bullet } } \mathbb { T } ^ { \prime } , \mathrm { ~ \Psi ~ } ^ { \mathrm { \tiny ~ \bullet } } \mathbb { K } ^ { \prime } ,$ $\cdot _ { \mathrm { ~ L ~ } ^ { \prime } }$ , $\mathbf { \Delta } \cdot _ { \mathrm { M } } \mathbf { \Delta } \prime$ , $\cdot _ { \mathrm { { N } } } \prime$ , $\cdot _ { \mathrm { { P } ^ { \prime } } }$ , $\cdot _ { \bigcirc } \prime$ , $\because _ { \mathrm { { R } ^ { \prime } } }$ , ‘S’, ‘T’, ‘V’, ‘W’, ‘Y’]. Following Trabucco et al. (2022), we consider the dataset of 56,086 proteins from Sarkisyan et al. (2016) processed based on Brookes et al. (2019). Each protein is accompanied by a score quantifying its fluorescence. As with the AMP data, we keep $2 0 \%$ of the data as a validation set used for early-stopping. The regressor trained with the dataset is a Transformer, with 4 hidden layers, hidden dimension 64, and 8 attention heads. We train it with a minibatch of size 256, with learning rate $1 0 ^ { - 4 }$ , with early stopping on the validation set. The architecture of the policy for all methods is a Transformer with 3 hidden layers with hidden dimension 64 with 8 attention heads. All methods are trained for 20, 000 iterations, with a minibatch size of 16. We use the same implementation for all methods as the ones used in $\ S _ { \mathrm { D } }$ .
|
| 428 |
+
|
| 429 |
+

|
| 430 |
+
Figure F.1: The Spearman correlation between the sampling probability and reward on a test set is plotted over the course of training for each value of $\lambda$ .
|
| 431 |
+
|
| 432 |
+
To define an exploratory training policy, we set the the random action probability to 0.01 selected from $\{ 0 . 0 0 0 1 , \bar { 0 . 0 0 0 5 } , \bar { 0 . 0 0 1 } , 0 . \bar { 0 1 } \}$ and the reward exponent $\beta$ (having the same meaning as in $\ S 4 . 2 )$ ) to 3 selected from $\{ 2 , 3 , 4 \}$ . For trajectory balance we use a learning rate of $5 \times 1 0 ^ { - 3 }$ selected from $\{ 1 0 ^ { - 5 } , 1 0 ^ { - 4 } , 5 \times 1 0 ^ { - 4 } , 1 0 ^ { - 3 } , 5 \times 1 0 ^ { - 3 } \}$ for the flow parameters and $1 \times 1 0 ^ { - 2 }$ for $\log Z$ . For SubTB $( \lambda )$ , we choose the best $\lambda$ from $\{ 0 . 7 , 0 . 8 , 0 . 9 , 0 . 9 9 \}$ , and found $\lambda = 0 . 9 9$ to perform the best. For TB and SubTB(??), we tune for the best learning rates from $\{ 0 . 0 0 0 1 , 0 . 0 0 0 3 , 0 . 0 0 0 5 , 0 . 0 0 0 7 5 , 0 . 0 0 1 \}$ for the forward logits. For $\log Z$ , we use a learning rate of $1 0 \times$ the learning rate for the forward logits.
|
| 433 |
+
|
| 434 |
+
For FM we use a learning rate of $1 0 ^ { - 3 }$ selected from $\{ 1 0 ^ { - 5 } , 1 0 ^ { - 4 } , 5 \times 1 0 ^ { - 4 } , 1 0 ^ { - 3 } , 5 \times 1 0 ^ { - 3 } \}$ with leaf loss coefficient $\lambda _ { T } = 3 0$ . For A2C with entropy regularization we share parameters between the actor and critic networks, and use learning rate of $5 \times 1 0 ^ { - 3 }$ selected from $\{ 1 0 ^ { - 5 } , 1 0 ^ { - 4 } , 5 \times$ $1 0 ^ { - 4 } , 1 0 ^ { - 3 } , 5 \times 1 0 ^ { - 3 } \}$ with entropy regularization coefficient $5 \times 1 0 ^ { - 2 }$ selected from $\{ 1 0 ^ { - 4 } , 1 0 ^ { - 3 } , 5 \times$ $1 0 ^ { - 3 } , 1 0 ^ { - 2 } , 5 \times 1 0 ^ { - 2 } \}$ . For SAC we use the formulation in Christodoulou (2019) with a learning rate of $1 0 ^ { - 3 }$ selected from $\{ 1 0 ^ { - 5 } , 1 0 ^ { - 4 } , 5 \times 1 0 ^ { - 4 } , 1 0 ^ { - 3 } , 5 \times 1 0 ^ { - 3 } \} ,$ , a target network update frequency of 400 and initial random steps of 200. For the MARS baseline, we set the learning rate to $5 \times 1 0 ^ { - 4 }$ selected from $\{ 1 0 ^ { - 5 } , 1 0 ^ { - 4 } , 5 \times 1 0 ^ { - 4 } , 1 0 ^ { - 3 } , 5 \times 1 0 ^ { - 3 } \}$ . We run the experiments on 3 seeds and report the mean and standard error over the three runs in Table 3.
|
| 435 |
+
|
| 436 |
+
# F INVERSE PROTEIN FOLDING: NON-AUTOREGRESSIVE SEQUENCE GENERATION
|
| 437 |
+
|
| 438 |
+
We consider the inverse protein folding problem suggested in Sinai et al. (2020). A target protein 3D backbone conformation is given, and the task is to sample amino acid sequences of a fixed length $L = 4 0$ from the Boltzmann distribution corresponding to their energy in the target conformation. The energy is provided by a physics model (Rohl et al., 2004; Chaudhury et al., 2010). The policy model is a 3-layer convolutional architecture that closely follows previous work (Sinai et al., 2020). Specifically, for the policy function, the convolution size was set to 7 with 32 hidden features and ReLU activation in each layer. The policy network has one additional convolutional layer of size 20 (number of amino acids), and without the activation function. The flow network has an additional two linear layers of sizes [1280,64], and [64, 1] with ReLU activation in between. We report mean result over three runs.
|
| 439 |
+
|
| 440 |
+
For this task, rather than generating sequences from left to right, we consider an action space in which actions modify one letter at a time at arbitrary positions. The first action uniformly randomly samples an amino acid sequence. On each subsequent action, the agent selects a position in the sequence and replaces the letter in this position with another letter in the vocabulary. Generation terminates after exactly $N = 4 0$ replacement steps. The forward policy is conditioned on the number of steps taken so far in the trajectory; the backward policy is fixed to be uniform over the $N \cdot L$ actions.
|
| 441 |
+
|
| 442 |
+
As a metric of how well the learned model matches the target distribution, we measure the correlation between $\log R ( x )$ and the marginal sampling likelihood $\log p _ { \theta } ( x )$ on a held-out set of terminal states. The results are presented in Fig. F.1. We observe that intermediate values of lambda lead to the best fit to the target distribution.
|
md/dev/VnurXbqxr0B/VnurXbqxr0B.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/XSEBx0iSjFQ/XSEBx0iSjFQ.md
ADDED
|
@@ -0,0 +1,374 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# RE-IMAGEN: RETRIEVAL-AUGMENTED TEXT-TO-IMAGE GENERATOR
|
| 2 |
+
|
| 3 |
+
Wenhu Chen, Hexiang Hu, Chitwan Saharia, William W. Cohen Google Research {wenhuchen,hexiang,sahariac,wcohen}@google.com
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
Research on text-to-image generation has witnessed significant progress in generating diverse and photo-realistic images, driven by diffusion and auto-regressive models trained on large-scale image-text data. Though state-of-the-art models can generate high-quality images of common entities, they often have difficulty generating images of uncommon entities, such as ‘Chortai (dog)’ or ‘Picarones (food)’. To tackle this issue, we present the Retrieval-Augmented Text-to-Image Generator (Re-Imagen), a generative model that uses retrieved information to produce high-fidelity and faithful images, even for rare or unseen entities. Given a text prompt, Re-Imagen accesses an external multi-modal knowledge base to retrieve relevant (image, text) pairs and uses them as references to generate the image. With this retrieval step, Re-Imagen is augmented with the knowledge of highlevel semantics and low-level visual details of the mentioned entities, and thus improves its accuracy in generating the entities’ visual appearances. We train ReImagen on a constructed dataset containing (image, text, retrieval) triples to teach the model to ground on both text prompt and retrieval. Furthermore, we develop a new sampling strategy to interleave the classifier-free guidance for text and retrieval conditions to balance the text and retrieval alignment. Re-Imagen achieves significant gain on FID score over COCO and WikiImage. To further evaluate the capabilities of the model, we introduce EntityDrawBench, a new benchmark that evaluates image generation for diverse entities, from frequent to rare, across multiple object categories including dogs, foods, landmarks, birds, and characters. Human evaluation on EntityDrawBench shows that Re-Imagen can significantly improve the fidelity of generated images, especially on less frequent entities.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Recent research efforts on conditional generative modeling, such as Imagen (Saharia et al., 2022), DALL·E 2 (Ramesh et al., 2022), and Parti (Yu et al., 2022), have advanced text-to-image generation to an unprecedented level, producing accurate, diverse, and even create images from text prompts. These models leverage paired image-text data at Web scale (with hundreds of millions of training examples), and powerful backbone generative models, i.e., autoregressive models (Van Den Oord et al., 2017; Ramesh et al., 2021; Yu et al., 2022), diffusion models (Ho et al., 2020; Dhariwal & Nichol, 2021), etc, and generate highly realistic images. Studying these models’ generation results, we discovered their outputs are surprisingly sensitive to the frequency of the entities (or objects) in the text prompts. In particular, when generating text prompts about frequent entities, these models often generate realistic images, with faithful grounding to the entities’ visual appearance. However, when generating from text prompts with less frequent entities, those models either hallucinate nonexistent entities, or output related frequent entities (see Figure 1), failing to establish a connection between the generated image and the visual appearance of the mentioned entity. This key limitation can greatly harm the trustworthiness of text-to-image models in real-world applications and even raise ethical concerns. In our studies, we found these models suffer from significant quality degradation in generating visual objects associated with under-represented groups.
|
| 12 |
+
|
| 13 |
+
In this paper, we propose a Retrieval-augmented Text-to-Image Generator (Re-Imagen), which alleviates such limitations by searching for entity information in a multi-modal knowledge base, rather than attempting to memorize the appearance of rare entities. Specifically, we define our multi-modal knowledge base encodes the visual appearances and descriptions of entities with a collection of reference <image, text> pairs’. To use this resource, Re-Imagen first uses the input text prompt to retrieve the most relevant <image, text> pairs from the external multi-modal knowledge base, then uses the retrieved knowledge as model additional inputs to synthesize the target images. Consequently, the retrieved references provide knowledge regarding the semantic attributes and the concrete visual appearance of mentioned entities to guide Re-Imagen to paint the entities in the target images.
|
| 14 |
+
|
| 15 |
+

|
| 16 |
+
Figure 1: Comparison of images generated by Imagen and Re-Imagen on less frequent entities. We observe that Imagen hallucinates the entities while Re-Imagen maintains better faithfulness.
|
| 17 |
+
|
| 18 |
+
The backbone of Re-Imagen is a cascaded diffusion model (Ho et al., 2022), which contains three independent generation stages (implemented as U-Nets (Ronneberger et al., 2015)) to gradually produce high-resolution (i.e., $1 0 2 4 \times 1 0 2 4 )$ images. In particular, we train Re-Imagen on a dataset constructed from the image-text dataset used by Imagen (Saharia et al., 2022), where each data instance is associated with the top-k nearest neighbors within the dataset, based on text-only BM25 score. The retrieved top-k <image, text> pairs will be used as a reference for the model attend to. During inference, we design an interleaved guidance schedule that switches between text guidance and retrieval guidance, which ensures both text alignment and entity alignment. We show some examples generated by Re-Imagen, and compare them against Imagen in Figure 1. We can qualitatively observe that our images are more faithful to the appearance of the reference entity.
|
| 19 |
+
|
| 20 |
+
To further quantitatively evaluate Re-Imagen, we present zero-shot text-to-image generation results on two challenging datasets: COCO (Lin et al., 2014) and WikiImages (Chang et al., 2022)1. ReImagen uses an external non-overlapping image-text database as the knowledge base for retrieval and then grounds on the retrieval to synthesize the target image. We show that Re-Imagen achieves the state-of-the-art performance for text-to-image generation on COCO and WikiImages, measured in FID score (Heusel et al., 2017), among non-fine-tuned models. For the non-entity-centric dataset COCO, the performance gain is coming from biasing the model to generate images with similar styles as the retrieved in-domain images. For the entity-centric dataset WikiImages, the performance gain comes from grounding the generation on retrieved images containing similar entities. We further evaluate Re-Imagen on a more challenging benchmark — EntityDrawBench, to test the model’s ability to generate a variety of infrequent entities (dogs, landmarks, foods, birds, animated characters) in different scenes. We compare Re-Imagen with Imagen (Saharia et al., 2022), DALLE 2 (Ramesh et al., 2022) and StableDiffusion (Rombach et al., 2022) in terms of faithfulness and photorealism with human raters. We demonstrate that Re-Imagen can generate faithful and realistic images on $80 \%$ over input prompts, beating the existing best models by at least $30 \%$ on EntityDrawBench. Analysis shows that the improvements are mostly coming from low-frequency visual entities.
|
| 21 |
+
|
| 22 |
+
To summarize, our key contributions are: (1) a novel retrieval-augmented text-to-image model ReImagen, which improves FID scores on two datasets; (2) interleaved classifier-free guidance during sampling to ensure both text alignment and entity fidelity; and (3) We introduce EntityDrawBench and show that Re-Imagen can significantly improve faithfulness on less-frequent entities.
|
| 23 |
+
|
| 24 |
+
# 2 RELATED WORK
|
| 25 |
+
|
| 26 |
+
Text-to-Image Diffusion Models There has been a wide-spread success (Ashual et al., 2022; Ramesh et al., 2022; Saharia et al., 2022; Nichol et al., 2021) in modeling text-to-image generation with diffusion models, which has outperformed GANs (Goodfellow et al., 2014) and auto-regressive Transformers (Ramesh et al., 2021) in photorealism and diversity (under similar model size), without training instability and mode collapsing issues. Among them, some recent large text-to-image models such as Imagen (Saharia et al., 2022), GLIDE (Nichol et al., 2021), and DALL-E2 (Ramesh et al., 2022) have demonstrated excellent generation from complex prompt inputs. These models achieve highly fine-grained control over the generated images with text inputs. However, they do not perform explicit grounding over external visual knowledge and are restricted to memorizing the visual appearance of every possible visual entity in their parameters. This makes it difficult for them to generalize to rare or even unseen entities. In contrast, Re-Imagen is designed to free the diffusion model from memorizing, as models are encouraged to retrieve semantic neighbors from the knowledge base and use retrievals as context to paint the image. Re-Imagen improves the grounding of the diffusion models to real-world knowledge and is therefore capable of faithful image synthesis.
|
| 27 |
+
|
| 28 |
+
Concurrent Work There are several concurrent works (Li et al., 2022; Blattmann et al., 2022; Ashual et al., 2022), that also leverage retrieval to improve diffusion models. RDM (Blattmann et al., 2022) is trained similarly to Re-Imagen, using examples and near neighbors, but the neighbors in RDM are selected using image features, and at inference time retrievals are replaced with user-chosen exemplars. RDM was shown to effectively transfer artistic style from exemplars to generated images. In contrast, our proposed Re-Imagen conditions on both text and multi-modal neighbors to generate the image includes retrieval at inference time and is demonstrated to improve performance on rare images (as well as more generally). KNN-Diffusion (Ashual et al., 2022) is more closely related work to us, as it also uses retrieval to the quality of generated images. However, KNN-Diffusion uses discrete image representations, while Re-Imagen uses the raw pixels, and Re-Imagen’s retrieved neighbors can be <image, text> pairs, while KNN-Diffusion’s are only images. Quantitatively, Re-Imagen outperforms KNN-Diffusion on the COCO dataset significantly.
|
| 29 |
+
|
| 30 |
+
Others Due to the space limit, we provide an additional literature review in Appendix A.
|
| 31 |
+
|
| 32 |
+
# 3 MODEL
|
| 33 |
+
|
| 34 |
+
In this section, we start with background knowledge, in the form of a brief overview of the cascaded diffusion models used by Imagen. Next, we describe the concrete technical details of how we incorporate retrieval for Re-Imagen. Finally, we discuss interleaved guidance sampling.
|
| 35 |
+
|
| 36 |
+
# 3.1 PRELIMINARIES
|
| 37 |
+
|
| 38 |
+
Diffusion Models Diffusion models (Sohl-Dickstein et al., 2015) are latent variable models, parameterized by $\theta$ , in the form of $\begin{array} { r } { p _ { \theta } ( { \pmb x } _ { 0 } ) : = \int p _ { \theta } ( { \pmb x } _ { 0 : T } ) d { \pmb x } _ { 1 : T } } \end{array}$ , where $\pmb { x } _ { 1 } , \cdots , \pmb { x } _ { T }$ are “noised” latent versions of the input image ${ \pmb x } _ { 0 } \sim { \pmb q } ( { \pmb x } _ { 0 } )$ . Note that the dimensionality of both latents and the image is the same throughout the entire process, with $\pmb { x } _ { 0 : T } \in \mathbb { R } ^ { d }$ and $d$ equals the product of <height, width, # of channels $>$ . The process that computes the posterior distribution $q ( { \pmb x } _ { 1 : T } | { \pmb x } _ { 0 } )$ is also called the forward (or diffusion) process, and is implemented as a predefined Markov chain that gradually adds Gaussian noise to the data according to a schedule $\beta _ { t }$ :
|
| 39 |
+
|
| 40 |
+
$$
|
| 41 |
+
q ( \pmb { x } _ { 1 : T } | \pmb { x } _ { 0 } ) = \prod _ { t = 1 } ^ { T } q ( \pmb { x } _ { t } | \pmb { x } _ { t - 1 } ) \qquad q ( \pmb { x } _ { t } | \pmb { x } _ { t - 1 } ) : = \mathcal { N } ( \pmb { x } _ { t } ; \sqrt { 1 - \beta _ { t } } \pmb { x } _ { t - 1 } , \beta _ { t } \pmb { I } )
|
| 42 |
+
$$
|
| 43 |
+
|
| 44 |
+
Diffusion models are trained to learn the image distribution by reversing the diffusion Markov chain. Theoretically, this reduces to learning to denoise ${ \pmb x } _ { t } \sim { \pmb q } ( { \pmb x } _ { t } | { \pmb x } _ { 0 } )$ into $\scriptstyle { \mathbf { { \mathit { x } } } } _ { 0 }$ , with a time re-weighted square error loss—see Ho et al. (2020) for the complete proof:
|
| 45 |
+
|
| 46 |
+
$$
|
| 47 |
+
\mathbb { E } _ { { \pmb x } _ { 0 } , { \epsilon } , t } [ { \pmb w } _ { t } \cdot | | \hat { \pmb x } _ { \theta } ( { \pmb x } _ { t } , { \pmb c } ) - { \pmb x } _ { 0 } | | _ { 2 } ^ { 2 } ]
|
| 48 |
+
$$
|
| 49 |
+
|
| 50 |
+
Here, the noised image is denoted as $\pmb { x } _ { t } : = \sqrt { \bar { \alpha } _ { t } } \pmb { x } _ { 0 } + \sqrt { 1 - \bar { \alpha } _ { t } } \epsilon$ , $\scriptstyle { \mathbf { { \mathit { x } } } } _ { 0 }$ is the ground-truth image, $^ c$ is the condition, $\mathbf { \epsilon } \gets \mathcal { N } ( \mathbf { 0 } , \mathbf { I } )$ is the noise term, $\alpha _ { t } : = 1 - \beta _ { t }$ and $\textstyle { \bar { \alpha } } _ { t } : = \prod _ { s = 1 } ^ { t } \alpha _ { s }$ . To simplify notation, we will allow the condition $^ c$ to include multiple conditioning signals, such as text prompts $c _ { p }$ , a low-resolution image input $c _ { x }$ (which is used in super-resolution), or retrieved neighboring images $c _ { n }$ (which are used in Re-Imagen). Imagen (Saharia et al., 2022) uses a U-Net (Ronneberger et al., 2015) to implement $\mathbf { \epsilon } _ { \theta } ( \boldsymbol { x } _ { t } , \boldsymbol { c } , \bar { t } )$ . The U-Net represents the reversed noise generator as follows:
|
| 51 |
+
|
| 52 |
+

|
| 53 |
+
Figure 2: An illustration of the text-to-image generation pipeline in the $6 4 \times$ diffusion model. Specifically, Re-Imagen learns a UNet to iteratively predict $\epsilon ( x _ { t } , c _ { n } , c _ { p } , t )$ that denoises the image. $\scriptstyle ( c _ { n }$ : a set of retrieved image-text pairs from the database; $c _ { p }$ : input text prompt; $t$ : current time-step)
|
| 54 |
+
|
| 55 |
+
$$
|
| 56 |
+
\hat { x } _ { \theta } ( x _ { t } , c ) : = ( x _ { t } - \sqrt { 1 - \bar { \alpha } _ { t } } \epsilon _ { \theta } ( x _ { t } , c , t ) ) / \sqrt { \bar { \alpha } _ { t } }
|
| 57 |
+
$$
|
| 58 |
+
|
| 59 |
+
During the training, we randomly sample $t \sim \mathcal { U } ( [ 0 , 1 ] )$ and image $\scriptstyle { \mathbf { { \vec { x } } } } _ { 0 }$ from the dataset $\mathcal { D }$ , and minimize the difference between $\hat { \pmb { x } } _ { \theta } ( { \pmb x } _ { t } , { \pmb c } )$ and $\scriptstyle { \mathbf { { \mathit { x } } } } _ { 0 }$ according to Equation 2. At the inference time, the diffusion model uses DDPM (Ho et al., 2020) to sample recursively as follows:
|
| 60 |
+
|
| 61 |
+
$$
|
| 62 |
+
{ \pmb x } _ { t - 1 } = \frac { \sqrt { \bar { \alpha } _ { t - 1 } } \beta _ { t } } { 1 - \bar { \alpha } _ { t } } \hat { \pmb x } _ { \theta } ( { \pmb x } _ { t } , { \pmb c } ) + \frac { \sqrt { \alpha _ { t } } ( 1 - \bar { \alpha } _ { t - 1 } ) } { 1 - \bar { \alpha } _ { t } } { \pmb x } _ { t } + \frac { \sqrt { ( 1 - \bar { \alpha } _ { t - 1 } ) \beta _ { t } } } { \sqrt { 1 - \bar { \alpha } _ { t } } } { \pmb \hat \omega } _ { t } { \pmb x } _ { t } ^ { - 1 }
|
| 63 |
+
$$
|
| 64 |
+
|
| 65 |
+
The model sets $\mathbfit { \mathbf { x } } _ { T }$ as a Gaussian noise with $T$ denoting the total number of diffusion steps, and then keeps sampling in reverse until step $T = 0$ , i.e. $\pmb { x } _ { T } \pmb { x } _ { T - 1 } \cdot \cdot \cdot$ , to reach the final image $\scriptstyle { \hat { \mathbf { x } } } _ { 0 }$ .
|
| 66 |
+
|
| 67 |
+
For better generation efficiency, cascaded diffusion models (Ho et al., 2022; Ramesh et al., 2022; Saharia et al., 2022) use three separate diffusion models to generate high-resolution images gradually, going from low resolution to high resolution. The three models $6 4 \times$ model, $2 5 6 \times$ super-resolution model, and $1 0 2 4 \times$ super-resolution model gradually increase the model resolution to $1 0 2 4 \times 1 0 2 4$ .
|
| 68 |
+
|
| 69 |
+
Classifier-free Guidance Ho & Salimans (2021) first proposed classifier-free guidance to trade off diversity and sample quality. This sampling strategy has been widely used due to its simplicity. In particular, Imagen (Saharia et al., 2022) adopts an adjusted $\epsilon$ -prediction as follows:
|
| 70 |
+
|
| 71 |
+
$$
|
| 72 |
+
\hat { \epsilon } = w \cdot \epsilon _ { \theta } ( x _ { t } , c , t ) - ( w - 1 ) \cdot \epsilon _ { \theta } ( x _ { t } , t )
|
| 73 |
+
$$
|
| 74 |
+
|
| 75 |
+
where $w$ is the guidance weight. The unconditional $\epsilon$ -prediction $\epsilon _ { \theta } ( x _ { t } , t )$ is calculated by dropping the condition, i.e. the text prompt.
|
| 76 |
+
|
| 77 |
+
# 3.2 GENERATING IMAGE WITH MULTI-MODAL KNOWLEDGE
|
| 78 |
+
|
| 79 |
+
Similar to Imagen (Saharia et al., 2022), Re-Imagen is a cascaded diffusion model, consisting of $6 4 \times$ , $2 5 6 \times$ , and $1 0 2 4 \times$ diffusion models. However, Re-Imagen augments the diffusion model with the new capability of leveraging multimodal ‘knowledge’ from the external database, thus freeing the model from memorizing the appearance of rare entities. For brevity (and concreteness) we present below a high-level overview of the $6 4 \times$ model: the others are similar.
|
| 80 |
+
|
| 81 |
+
Main Idea As shown in Figure 2, during the denoising process, Re-Imagen conditions its generation result not only on the text prompt $c _ { p }$ (and also with $c _ { x }$ for super-resolution), but on the neighbors $c _ { n }$ that were retrieved from the external knowledge base. Here, the text prompt $\pmb { c } _ { p } \in \mathbb { R } ^ { n \times d }$ is represented using a T5 embedding (Raffel et al., 2020), with $n$ being the text length and $d$ being the embedding dimension. Meanwhile, the top- $\mathbf { \nabla } \cdot \mathbf { k }$ neighbors $\begin{array} { r } { \mathbf { c } _ { n } : = [ \mathrm { < i m a g e } , \mathrm { t e x t } > _ { 1 } , \cdot \cdot \cdot } \end{array}$ , <image, text> $k _ { \ast }$ ] are retrieved from external knowledge base $\boldsymbol { B }$ , using the input prompt $p$ as the query and a retrieval similarity function $\gamma ( p , B )$ . We experimented with two different choices for the similarity function: maximum inner product scores for BM25 (Robertson et al., 2009) and CLIP (Radford et al., 2021).
|
| 82 |
+
|
| 83 |
+

|
| 84 |
+
Figure 3: The detailed architecture of our model. The retrieved neighbors are first encoded using the DStack encoder and then used to augment the intermediate representation of the denoising image (via cross-attention). The augmented representation is fed to the UStack to predict the noise.
|
| 85 |
+
|
| 86 |
+
Model Architecture We show the architecture of our model in Figure 3, where we decompose the UNet into the downsampling encoder (DStack) and the upsampling decoder (UStack). Specifically, the DStack takes an image, a text, and a time step as the input, and generates a feature map, which is denoted as $f _ { \theta } ( \pmb { x } _ { t } , \pmb { c } _ { p } , \breve { t } ) \in \mathbb { R } ^ { F \times F \times d }$ , with $F$ denoting the feature map width and $d$ denoting the hidden dimension. We share the same DStack encoder when we encode the retrieved <image, text> pairs (with $t$ set to zero) which produce a set of feature maps $f _ { \theta } ( \pmb { c } _ { n } , 0 ) \in \mathbb { R } ^ { K \times F \times F \times d }$ . We then use a multi-head attention module (Vaswani et al., 2017) to extract the most relevant information to produce a new feature map $f _ { \theta } ^ { \prime } ( { \pmb x } _ { t } , { \pmb c } _ { p } , { \pmb c } _ { n } , t ) = A t t n ( f _ { \theta } ( { \pmb x } _ { t } , { \pmb c } _ { p } , t ) , f _ { \theta } ( { \pmb c } _ { n } , 0 ) )$ . The upsampling stack decoder then predicts the noise term ${ \epsilon _ { \theta } } ( x _ { t } , c _ { p } , c _ { n } , t )$ and uses it to compute ${ \hat { \mathbf { x } } } _ { \theta }$ with Equation 3, which is either used for regression during training or DDPM sampling.
|
| 87 |
+
|
| 88 |
+
Model Training In order to train Re-Imagen, we construct a new dataset KNN-ImageText based on the 50M ImageText-dataset used in Imagen. There are two motivations for selecting this dataset. (1) the dataset contains many similar photos regarding specific entities, which is extremely helpful for obtaining similar neighbors, and (2) the dataset is highly sanitized with fewer unethical or harmful images. For each instance in the 50M ImageText-dataset, we search over the same dataset with text-to-text BM25 similarity to find the top-2 neighbors as $c _ { n }$ (excluding the query instance). We experimented with both CLIP and BM25 similarity scores, and retrieval was implemented with ScaNN (Guo et al., 2020). We train Re-Imagen on the KNN-ImageText by minimizing the loss function of Equation 2. During training, we also randomly drop the text and neighbor conditions independently with $10 \%$ chance. Such random dropping will help the model learn the marginalized noise term $\epsilon _ { \theta } ( x _ { t } , c _ { p } , t )$ and $\boldsymbol { \epsilon } _ { \theta } ( \boldsymbol { x } _ { t } , \boldsymbol { c } _ { n } , t )$ , which will be used for the classifier-free guidance.
|
| 89 |
+
|
| 90 |
+
Interleaved Classifier-free Guidance Different from existing diffusion models, our model needs to deal with more than one condition, i.e., text prompts $\mathbf { } c _ { t }$ and retrieved neighbors $c _ { n }$ , which allows new options for incorporating guidance. In particular, Re-Imagen could use classifier-free guidance by subtracting the unconditioned $\epsilon$ -predictions, or either of the two partially conditioned $\epsilon$ -predictions. Empirically, we observed that subtracting unconditioned $\epsilon$ -predictions (the standard classifier-free guidance of Figure 3.1) often leads to an undesired imbalance, where the outputs are either dominated by the text condition or the neighbor condition. Hence, we designed an interleaved guidance schedule that balances the two conditions. Formally, we define the two adjusted $\epsilon$ -predictions as:
|
| 91 |
+
|
| 92 |
+
$$
|
| 93 |
+
\begin{array} { r } { \hat { \epsilon } _ { p } = w _ { p } \cdot \epsilon _ { \theta } ( x _ { t } , c _ { p } , c _ { n } , t ) - ( w _ { p } - 1 ) \cdot \epsilon _ { \theta } ( x _ { t } , c _ { n } , t ) } \\ { \hat { \epsilon } _ { n } = w _ { n } \cdot \epsilon _ { \theta } ( x _ { t } , c _ { p } , c _ { n } , t ) - ( w _ { n } - 1 ) \cdot \epsilon _ { \theta } ( x _ { t } , c _ { p } , t ) } \end{array}
|
| 94 |
+
$$
|
| 95 |
+
|
| 96 |
+
where $\hat { \epsilon } _ { p }$ and $\hat { \epsilon } _ { n }$ are the text-enhanced and neighbor-enhanced $\epsilon$ -predictions, respectfully. Here, $w _ { p }$ is the text guidance weight and $w _ { n }$ is the neighbor guidance weight. We then interleave the two guidance predictions by a certain predefined ratio $\eta$ . Specifically, at each guidance step, we sample a [0, 1]-uniform random number $R$ , and $R < \eta$ , we use $\hat { \epsilon } _ { p }$ , and otherwise $\hat { \epsilon } _ { n }$ . We can adjust $\eta$ to balance the faithfulness w.r.t text description or the retrieved image-text pairs.
|
| 97 |
+
|
| 98 |
+
# 4 EXPERIMENTS
|
| 99 |
+
|
| 100 |
+
Re-Imagen consists of three submodels: a 2.5B $6 4 \times 6 4$ text-to-image model, a 750M $2 5 6 \times 2 5 6$ super-resolution model and a $4 0 0 \mathrm { M } 1 0 2 4 \times 1 0 2 4$ super-resolution model. We also have a Re-Imagensmall with 1.4B $6 4 \times 6 4$ text-to-image model to understand the impact of model size.
|
| 101 |
+
|
| 102 |
+
Table 1: MS-COCO results for text-to-image generation. We use a guidance weight of 1.25 for the $6 4 \times$ diffusion model and 5 for our $2 5 6 \times$ super-resolution model. († is fine-tuned)
|
| 103 |
+
|
| 104 |
+
<table><tr><td>Model</td><td>Params</td><td colspan="2">COCO FID ZS FID</td><td colspan="2">WikiImages FID ZS FID</td></tr><tr><td>GLIDE (Nichol et al., 2021)</td><td>5B</td><td>1</td><td>12.24</td><td>■</td><td>=</td></tr><tr><td>DALL-E2 (Ramesh et al.,2022)</td><td>~5B</td><td>=</td><td>10.39</td><td>=</td><td>=</td></tr><tr><td>Stable-Diffusion (Rombach et al., 2022)</td><td>1B</td><td>=</td><td>12.63</td><td>=</td><td>7.50</td></tr><tr><td>Imagen (Saharia et al., 2022)</td><td>3B</td><td>=</td><td>7.27</td><td>=</td><td>6.44</td></tr><tr><td>Make-A-Scene (Gafni et al.,2022)</td><td>4B</td><td>7.55†</td><td>11.84</td><td>=</td><td>=</td></tr><tr><td>Parti (Yu et al.,2022)</td><td>20B</td><td>3.22†</td><td>7.23</td><td>=</td><td></td></tr><tr><td colspan="6">Retrieval-Augmented Model</td></tr><tr><td>KNN-Diffusion (Ashual et al., 2022)</td><td></td><td>16.66</td><td></td><td></td><td></td></tr><tr><td>Memory-Driven Text-to-Image (Li et al.,2022)</td><td>=</td><td>19.47</td><td></td><td></td><td></td></tr><tr><td>Re-Imagen (y=BM25; B=IND; k=2)</td><td>3.6B</td><td>5.25</td><td>-</td><td>5.88</td><td>1</td></tr><tr><td>Re-Imagen (y=BM25; B=OOD; k=2)</td><td>3.6B</td><td>-</td><td>6.88</td><td>-</td><td>5.80</td></tr><tr><td>Re-Imagen-small (y=BM25;B=IND; k=2)</td><td>2.4B</td><td>5.73</td><td>=</td><td>6.32</td><td></td></tr><tr><td>Re-Imagen-small (y=BM25; B=OOD; k=2)</td><td>2.4B</td><td>1</td><td>7.32</td><td>1</td><td>6.04</td></tr></table>
|
| 105 |
+
|
| 106 |
+
We finetune these models on the constructed KNN-ImageText dataset. We evaluate the model under two settings: (1) automatic evaluation on COCO and WikiImages dataset, to measure the model’s general performance to generate photorealistic images, and (2) human evaluation on the newly introduced EntityDrawBench, to measure the model’s capability to generate long-tail entities.
|
| 107 |
+
|
| 108 |
+
Training and Evaluation details The fine-tuning was run for 200K steps on 64 TPU-v4 chips and completed within two days. We use Adafactor for the $6 4 \times$ model and Adam for the $2 5 6 \times$ superresolution model with a learning rate of 1e-4. We set the number of neighbors $k { = } 2$ and set $\scriptstyle \gamma = \mathrm { B M } 2 5$ during training. For the image-text database $\boldsymbol { B }$ , we consider three different variants: (1) the indomain training set, which contains non-overlapping small-scale in-domain image-text pairs from COCO or WikiImages, (2) the out-of-domain LAION dataset (Schuhmann et al., 2021) containing 400M <image, text> crawled pairs. Since indexing ImageText and LAION with CLIP encodings is expensive, we only considered the BM25 retriever for these databases.
|
| 109 |
+
|
| 110 |
+
# 4.1 EVALUATION ON COCO AND WIKIIMAGES
|
| 111 |
+
|
| 112 |
+
In these two experiments, we used the standard non-interleaved classifier-free guidance (Figure 3.1) with ${ \cal T } { = } 1 0 0 0$ steps for both the $6 4 \times$ diffusion model and $2 5 6 \times$ super-resolution model. The guidance weight $w$ for the $6 4 \times$ model is swept over [1.0, 1.25, 1.5, 1.75, 2.0], while the $2 5 6 \times 2 5 6$ superresolution models’ guidance weight $w$ is swept over [1.0, 5.0, 8.0, 10.0]. We select the guidance $w$ with the best FID score, which is reported in Table 1. We also demonstrate examples in Figure 4.
|
| 113 |
+
|
| 114 |
+
COCO Results COCO is the most widely-used benchmark for text-to-image generation models. Although COCO does not contain many rare entities, it does contain unusual combinations of common entities, so it is plausible that retrieval augmentation could also help with some challenging text prompts. We adopt FID (Heusel et al., 2017) score to measure image quality. Following the previous literature, we randomly sample 30K prompts from the validation set as input to the model. The generated images are compared with the reference images from the full validation set (42K). We list the results in two columns: FID-30K denotes that the model with access to the in-domain COCO train set, while Zero-shot FID-30K does not have access to any COCO data.
|
| 115 |
+
|
| 116 |
+
Re-Imagen can achieve a significant gain on FID by retrieving from external databases: roughly a 2.0 absolute FID improvement over Imagen. Its performance is even better than fine-tuned MakeA-Scene (Gafni et al., 2022). We found that Re-Imagen retrieving from OOD database achieves less gain than IND database, but still obtains a 0.4 FID improvement over Imagen. When comparing with other retrieval-augmented models, Re-Imagen is shown to outperform KNN-Diffusion and MemoryDriven T2I models by a significant margin of 11 FID score. We also note that Re-Imagen-small is also competent in the FID, which outperforms normal-sized Imagen with fewer parameters.
|
| 117 |
+
|
| 118 |
+
As COCO does not contain infrequent entities, retrievals from the in-domain database mainly provide useful ‘style knowledge’ for the model to ground on. Re-Imagen can better adapt to COCO distribution, thus achieving a better FID score. As can be seen in the upper part of from Figure 4, Re-Imagen with retrieval generates images of the same style as COCO, while without retrieval, the output is still high quality, but the style is less similar to COCO.
|
| 119 |
+
|
| 120 |
+

|
| 121 |
+
Figure 4: The retrieved top-2 neighbors of COCO and WikiImages and model generation.
|
| 122 |
+
|
| 123 |
+
WikiImages Results WikiImages is constructed based on the multimodal corpus provided in WebQA (Chang et al., 2022), which consists of <image, text> pairs crawled from Wikimedia Commons2. We filtered the original corpus to remove noisy data (see AppendixB), which leads to a total of 320K examples. We randomly sample 22K as our validation set to perform zero-shot evaluation, we further sample 20K prompts from the dataset as the input. Similar to the previous experiment, we also adopt the guidance weight schedule as before and evaluate $2 5 6 \times 2 5 6$ images.
|
| 124 |
+
|
| 125 |
+
From Table 1, we found that using the OOD database (LAION) actually achieves better performance than using the IND database. Unlike COCO, WikiImages contains mostly entity-focused images, thus the importance of finding relevant entities in the database is more important than distilling the styles from the training set—and since the scale of LAION-400M is $1 0 0 \mathrm { x }$ larger than an in-domain database, the chance of retrieving related entities is much higher, which leads to better performance. One example is depicted in the lower part of Figure 4, where the LAION retrieval finds ‘Island of San Giorgio Maggiore’, which helps the model generate the classical Renaissance-style church.
|
| 126 |
+
|
| 127 |
+
# 4.2 ENTITY FOCUSED EVALUATION ON ENTITYDRAWBENCH
|
| 128 |
+
|
| 129 |
+
Dataset Construction We introduce EntityDrawBench to evaluate the model’s capability to generate diverse sets of entities in different visual scenes. Specifically, we pick various types of visual entities (dog breeds, landmarks, foods, birds, and animated characters) from Wikipedia Commons, Google Landmarks and Fandom to construct our prompts. In total, we collect 250 entity-centric prompts for evaluation. These prompts are mostly very unique and we cannot find them on the Internet, let alone the model training data. The dataset construction details are in Appendix C. To evaluate the model’s capability to ground on broader types of entities, we also randomly select 20 objects like ‘sunglasses, backpack, vase, teapot, etc’ and write creative prompts for them. We compare our generation results with the results from DreamBooth (Ruiz et al., 2022) in Appendix H.
|
| 130 |
+
|
| 131 |
+
We use the constructed prompt as the input and its corresponding image-text pairs as the ‘retrieval’ for Re-Imagen, to generate four $1 0 2 4 \times 1 0 2 4$ images. For the other models, we feed the prompts directly also to generate four images. We pick the best image of 4 random samples to rate its Photorealism and Faithfulness by human raters. For photorealism, we rate 1 if the image is moderately realistic without noticeable artifacts. For the faithfulness measure, we rate 1 if the image is faithful to both the entity appearance and the text description.
|
| 132 |
+
|
| 133 |
+
EntityDrawBench Results We use the proposed interleaved classifier-free guidance (subsection 3.2) for the $6 4 \times$ diffusion model, which runs for 256 diffusion steps under a strong guidance weight of $w { = } 3 0$ for both text and neighbor conditions. For the $2 5 6 \times$ and $1 0 2 4 \times$ resolution models, we use a constant guidance weight of 5.0 and 3.0, respectively, with 128 and 32 diffusion steps.
|
| 134 |
+
|
| 135 |
+
Table 2: Human evaluation results for different models on different types of entities.
|
| 136 |
+
|
| 137 |
+
<table><tr><td rowspan="2">Model</td><td colspan="6">Faithfulness</td><td rowspan="2">Photorealism All</td></tr><tr><td>Dogs</td><td>Foods</td><td>Landmarks</td><td>Birds</td><td>Characters</td><td>Broader</td></tr><tr><td>Imagen</td><td>0.28</td><td>0.26</td><td>0.27</td><td>0.84</td><td>0.10</td><td>0.54</td><td>0.98</td></tr><tr><td>DALL-E 2</td><td>0.60</td><td>0.47</td><td>0.36</td><td>0.82</td><td>0.08</td><td>0.58</td><td>0.98</td></tr><tr><td>Stable-Diffusion</td><td>0.16</td><td>0.24</td><td>0.24</td><td>0.68</td><td>0.08</td><td>0.46</td><td>0.92</td></tr><tr><td>Re-Imagen (K=2)</td><td>0.80</td><td>0.80</td><td>0.82</td><td>0.92</td><td>0.54</td><td>0.80</td><td>0.98</td></tr></table>
|
| 138 |
+
|
| 139 |
+
The inference speed is 30-40 secs for 4 images on 4 TPU-v4 chips. We demonstrate our human evaluation results for faithfulness and photorealism in Table 2.
|
| 140 |
+
|
| 141 |
+
We can observe that Re-Imagen can in general achieve much higher faithfulness than the existing models while maintaining similar photorealism scores. When comparing with our backbone Imagen, we see the faithfulness score improves by around $40 \%$ , which indicates that our model is paying attention to the retrieved knowledge and assimilating it into the generation process.
|
| 142 |
+
|
| 143 |
+

|
| 144 |
+
Figure 5: The human evaluation scores for both frequent and infrequent entities.
|
| 145 |
+
|
| 146 |
+
We further partition the entities into ‘frequent’ and ‘infrequent’ categories based on their frequency (top $50 \%$ as ‘frequent’). We plot the faithfulness score for ‘frequent’ and ‘infrequent’ separately in Figure 5. We can see that Re-Imagen is less sensitive to the frequency of the input entities than the other models with only minor performance drops. This study reflects the effectiveness of text-toimage generation models on long-tail entities. More generation examples are shown in Appendix F.
|
| 147 |
+
|
| 148 |
+
# 4.3 ANALYSIS
|
| 149 |
+
|
| 150 |
+
Comparison to Other Models We demonstrate some examples from different models in Figure 6. As can be seen, the images generated from Re-Imagen strike a good balance between text alignment and entity fidelity. Unlike image editing to perform in-place modification, Re-Imagen can transform the neighbor entities both geometrically and semantically according to the text guidance. As a concrete example, Re-Imagen generates the Braque Saint-Germain (2nd row in Figure 6) on the grass, in a different viewpoint from to the reference image.
|
| 151 |
+
|
| 152 |
+
Impact of Number of Retrievals The number of retrievals $K$ is an important factor for Re-Imagen. We vary the number of $K$ for all three datasets to understand their impact on the model performance. From Figure 7, we found that on COCO and WikiImages, increasing K from 1 to 4 does not lead to many changes in the FID score. However, on EntityDrawBench, increasing K will dramatically improve the faithfulness of generated image. It indicates the importance of having multiple images to help Re-Imagen ground on the visual entity. We provide visual examples in Appendix D.
|
| 153 |
+
|
| 154 |
+
Text and Entity Faithfulness Trade-offs In our experiments, we found that there is a trade-off between faithefulness to the text prompt and faithfulness to the retrieved entity images. Based on Equation 6, by adjusting $\eta$ , i.e.the proportion of $\hat { \epsilon } _ { p }$ and $\boldsymbol { \hat { \epsilon } } _ { n }$ in the sampling schedule, we can control Re-Imagen so as to generate images that explore this tradeoff: decreasing $\eta$ will increase the entity’s entity faithfulness but decrease the text alignment. We found that having $\eta$ around 0.5 is usually a ‘sweet spot’ that balances both conditions.
|
| 155 |
+
|
| 156 |
+

|
| 157 |
+
Aflock of birds flyaround Visoki Decani church.
|
| 158 |
+
|
| 159 |
+

|
| 160 |
+
Figure 6: None-cherry picked examples from EntityDrawBench for different models.
|
| 161 |
+
Figure 7: Ablation Study of retrieval number K on different datasets.
|
| 162 |
+
|
| 163 |
+

|
| 164 |
+
Figure 8: Ablation study of interleaved guidance ratio $\eta$ to show the trade-off.
|
| 165 |
+
|
| 166 |
+
# 5 CONCLUSIONS
|
| 167 |
+
|
| 168 |
+
We present Re-Imagen, a retrieval-augmented diffusion model, and demonstrate its effectiveness in generating realistic and faithful images. We exhibit such advantages not only through automatic FID measures on standard benchmarks (i.e., COCO and WikiImage) but also through human evaluation of the newly introduced EntityDrawBench. We further demonstrate that our model is particularly effective in generating an image from text that mentions rare entities.
|
| 169 |
+
|
| 170 |
+
Re-Imagen still suffers from well-known issues in text-to-image generation, which we review below in section 5. In addition, Re-Imagen also has some unique limitations due to the retrieval-augmented modeling. First, because Re-Imagen is sensitive to retrieved image-text pairs it is conditioned on when the retrieved image is of low quality, there will be a negative influence on the generated image. Second, Re-Imagen sometimes still fails to generate high-quality images with highly compositional prompts, where multiple entities are involved. Thirdly, the super-resolution model is still not competent at capturing low-level details of retrieved entities leading to visual distortion. In future work, we plan to further investigate the above limitations and address them.
|
| 171 |
+
|
| 172 |
+
# ETHICS STATEMENT
|
| 173 |
+
|
| 174 |
+
Strong text-to-image generation models, i.e., Imagen (Saharia et al., 2022) and Parti (Yu et al., 2022), raise ethical challenges along dimensions such as the social bias. Re-Imagen is exposed to the same challenges, as we employed Web-scale datasets that are similar to the prior models.
|
| 175 |
+
|
| 176 |
+
The retrieval-augmented modeling techniques of Re-Imagen have substantially improved the controllability and attribution of the generated image. Like many basic research topics, this additional control could be used for beneficial or harmful purposes. One obvious danger is that Re-Imagen (or similar models) could be used for malicious purposes like spreading misinformation, e.g., by producing realistic images of specific people in misleading visual contexts. On the other side, additional control has many potential benefits. One general benefit is that Re-Imagen can reduce hallucination and increase the faithfulness of the generated image to the user’s intent. Another benefit is that the ability to work with tail entities makes the model more useful for minorities and other users in smaller communities: for example, Re-Imagen is more effective at generating images of landmarks famous in smaller communities or cultures and generating images of indigenous foods and cultural artifacts. We argue that this model can help decrease the frequency-caused bias in current neural network-based AI systems.
|
| 177 |
+
|
| 178 |
+
Considering such potential threats to the public, we will be cautious about code and API release. In future work, we will explore a framework for responsible use that balances the value of external auditing of research with the risks of unrestricted open access, allowing this work to be used in a safe and beneficial way.
|
| 179 |
+
|
| 180 |
+
# REFERENCES
|
| 181 |
+
|
| 182 |
+
Rameen Abdal, Yipeng Qin, and Peter Wonka. Image2stylegan: How to embed images into the stylegan latent space? In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 4432–4441, 2019.
|
| 183 |
+
|
| 184 |
+
Yuval Alaluf, Omer Tov, Ron Mokady, Rinon Gal, and Amit Bermano. Hyperstyle: Stylegan inversion with hypernetworks for real image editing. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 18511–18521, 2022.
|
| 185 |
+
|
| 186 |
+
Oron Ashual, Shelly Sheynin, Adam Polyak, Uriel Singer, Oran Gafni, Eliya Nachmani, and Yaniv Taigman. Knn-diffusion: Image generation via large-scale retrieval. arXiv preprint arXiv:2204.02849, 2022.
|
| 187 |
+
|
| 188 |
+
Andreas Blattmann, Robin Rombach, Kaan Oktay, and Bjorn Ommer. Retrieval-augmented diffu- ¨ sion models. arXiv preprint arXiv:2204.11824, 2022.
|
| 189 |
+
|
| 190 |
+
Sebastian Borgeaud, Arthur Mensch, Jordan Hoffmann, Trevor Cai, Eliza Rutherford, Katie Millican, George van den Driessche, Jean-Baptiste Lespiau, Bogdan Damoc, Aidan Clark, et al. Improving language models by retrieving from trillions of tokens. arXiv preprint arXiv:2112.04426, 2021.
|
| 191 |
+
|
| 192 |
+
Yingshan Chang, Mridu Narang, Hisami Suzuki, Guihong Cao, Jianfeng Gao, and Yonatan Bisk. Webqa: Multihop and multimodal qa. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 16495–16504, 2022.
|
| 193 |
+
|
| 194 |
+
Prafulla Dhariwal and Alexander Nichol. Diffusion models beat gans on image synthesis. Advances in Neural Information Processing Systems, 34:8780–8794, 2021.
|
| 195 |
+
|
| 196 |
+
Oran Gafni, Adam Polyak, Oron Ashual, Shelly Sheynin, Devi Parikh, and Yaniv Taigman. Make-a-scene: Scene-based text-to-image generation with human priors. arXiv preprint arXiv:2203.13131, 2022.
|
| 197 |
+
|
| 198 |
+
Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. In Advances in neural information processing systems, pp. 2672–2680, 2014.
|
| 199 |
+
|
| 200 |
+
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, pp. 3887–3896. PMLR, 2020.
|
| 201 |
+
|
| 202 |
+
Kelvin Guu, Kenton Lee, Zora Tung, Panupong Pasupat, and Mingwei Chang. Retrieval augmented language model pre-training. In Hal Daume III and Aarti Singh (eds.), ´ Proceedings of the 37th International Conference on Machine Learning, volume 119 of Proceedings of Machine Learning Research, pp. 3929–3938. PMLR, 13–18 Jul 2020. URL https://proceedings.mlr. press/v119/guu20a.html.
|
| 203 |
+
|
| 204 |
+
Amir Hertz, Ron Mokady, Jay Tenenbaum, Kfir Aberman, Yael Pritch, and Daniel Cohen-Or. Prompt-to-prompt image editing with cross attention control. arXiv preprint arXiv:2208.01626, 2022.
|
| 205 |
+
|
| 206 |
+
Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and Sepp Hochreiter. Gans trained by a two time-scale update rule converge to a local nash equilibrium. Advances in neural information processing systems, 30, 2017.
|
| 207 |
+
|
| 208 |
+
Jonathan Ho and Tim Salimans. Classifier-free diffusion guidance. In NeurIPS 2021 Workshop on Deep Generative Models and Downstream Applications, 2021.
|
| 209 |
+
|
| 210 |
+
Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33:6840–6851, 2020.
|
| 211 |
+
|
| 212 |
+
Jonathan Ho, Chitwan Saharia, William Chan, David J Fleet, Mohammad Norouzi, and Tim Salimans. Cascaded diffusion models for high fidelity image generation. J. Mach. Learn. Res., 23: 47–1, 2022.
|
| 213 |
+
|
| 214 |
+
Urvashi Khandelwal, Omer Levy, Dan Jurafsky, Luke Zettlemoyer, and Mike Lewis. Generalization through memorization: Nearest neighbor language models. In International Conference on Learning Representations, 2019.
|
| 215 |
+
|
| 216 |
+
Patrick Lewis, Ethan Perez, Aleksandra Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Kuttler, Mike Lewis, Wen-tau Yih, Tim Rockt ¨ aschel, et al. Retrieval-augmented genera- ¨ tion for knowledge-intensive nlp tasks. Advances in Neural Information Processing Systems, 33: 9459–9474, 2020.
|
| 217 |
+
|
| 218 |
+
Bowen Li, Philip HS Torr, and Thomas Lukasiewicz. Memory-driven text-to-image generation. arXiv preprint arXiv:2208.07022, 2022.
|
| 219 |
+
|
| 220 |
+
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 ´ European conference on computer vision, pp. 740–755. Springer, 2014.
|
| 221 |
+
|
| 222 |
+
Alexander Long, Wei Yin, Thalaiyasingam Ajanthan, Vu Nguyen, Pulak Purkait, Ravi Garg, Alan Blair, Chunhua Shen, and Anton van den Hengel. Retrieval augmented classification for long-tail visual recognition. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 6959–6969, 2022.
|
| 223 |
+
|
| 224 |
+
Alex Nichol, Prafulla Dhariwal, Aditya Ramesh, Pranav Shyam, Pamela Mishkin, Bob McGrew, Ilya Sutskever, and Mark Chen. Glide: Towards photorealistic image generation and editing with text-guided diffusion models. arXiv preprint arXiv:2112.10741, 2021.
|
| 225 |
+
|
| 226 |
+
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, pp. 8748–8763. PMLR, 2021.
|
| 227 |
+
|
| 228 |
+
Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, Peter J Liu, et al. Exploring the limits of transfer learning with a unified text-to-text transformer. J. Mach. Learn. Res., 21(140):1–67, 2020.
|
| 229 |
+
|
| 230 |
+
Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-shot text-to-image generation. In International Conference on Machine Learning, pp. 8821–8831. PMLR, 2021.
|
| 231 |
+
|
| 232 |
+
Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical textconditional image generation with clip latents. arXiv preprint arXiv:2204.06125, 2022.
|
| 233 |
+
|
| 234 |
+
Stephen Robertson, Hugo Zaragoza, et al. The probabilistic relevance framework: Bm25 and beyond. Foundations and Trends $\textsuperscript { \textregistered }$ in Information Retrieval, 3(4):333–389, 2009.
|
| 235 |
+
|
| 236 |
+
Daniel Roich, Ron Mokady, Amit H Bermano, and Daniel Cohen-Or. Pivotal tuning for latent-based editing of real images. arXiv preprint arXiv:2106.05744, 2021.
|
| 237 |
+
|
| 238 |
+
Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Bjorn Ommer. High- ¨ resolution image synthesis with latent diffusion models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 10684–10695, 2022.
|
| 239 |
+
|
| 240 |
+
Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networks for biomedical image segmentation. In International Conference on Medical image computing and computerassisted intervention, pp. 234–241. Springer, 2015.
|
| 241 |
+
|
| 242 |
+
Nataniel Ruiz, Yuanzhen Li, Varun Jampani, Yael Pritch, Michael Rubinstein, and Kfir Aberman. Dreambooth: Fine tuning text-to-image diffusion models for subject-driven generation. arXiv preprint arXiv:2208.12242, 2022.
|
| 243 |
+
|
| 244 |
+
Chitwan Saharia, William Chan, Saurabh Saxena, Lala Li, Jay Whang, Emily Denton, Seyed Kamyar Seyed Ghasemipour, Burcu Karagol Ayan, S Sara Mahdavi, Rapha Gontijo Lopes, et al. Photorealistic text-to-image diffusion models with deep language understanding. arXiv preprint arXiv:2205.11487, 2022.
|
| 245 |
+
|
| 246 |
+
Christoph Schuhmann, Robert Kaczmarczyk, Aran Komatsuzaki, Aarush Katta, Richard Vencu, Romain Beaumont, Jenia Jitsev, Theo Coombes, and Clayton Mullis. Laion- $4 0 0 \mathrm { m }$ : Open dataset of clip-filtered 400 million image-text pairs. In NeurIPS Workshop Datacentric AI, number FZJ2022-00923. Julich Supercomputing Center, 2021. ¨
|
| 247 |
+
|
| 248 |
+
Yawar Siddiqui, Justus Thies, Fangchang Ma, Qi Shan, Matthias Nießner, and Angela Dai. Retrievalfuse: Neural 3d scene reconstruction with a database. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 12568–12577, 2021.
|
| 249 |
+
|
| 250 |
+
Jascha Sohl-Dickstein, Eric Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. In International Conference on Machine Learning, pp. 2256–2265. PMLR, 2015.
|
| 251 |
+
|
| 252 |
+
Omer Tov, Yuval Alaluf, Yotam Nitzan, Or Patashnik, and Daniel Cohen-Or. Designing an encoder for stylegan image manipulation. ACM Transactions on Graphics (TOG), 40(4):1–14, 2021.
|
| 253 |
+
|
| 254 |
+
Aaron Van Den Oord, Oriol Vinyals, et al. Neural discrete representation learning. Advances in neural information processing systems, 30, 2017.
|
| 255 |
+
|
| 256 |
+
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.
|
| 257 |
+
|
| 258 |
+
Tengfei Wang, Yong Zhang, Yanbo Fan, Jue Wang, and Qifeng Chen. High-fidelity gan inversion for image attribute editing. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 11379–11388, 2022.
|
| 259 |
+
|
| 260 |
+
Tobias Weyand, Andre Araujo, Bingyi Cao, and Jack Sim. Google landmarks dataset v2-a largescale benchmark for instance-level recognition and retrieval. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 2575–2584, 2020.
|
| 261 |
+
|
| 262 |
+
Rui Xu, Minghao Guo, Jiaqi Wang, Xiaoxiao Li, Bolei Zhou, and Chen Change Loy. Texture memory-augmented deep patch-based image inpainting. IEEE Transactions on Image Processing, 30:9112–9124, 2021.
|
| 263 |
+
|
| 264 |
+
Jiahui Yu, Yuanzhong Xu, Jing Yu Koh, Thang Luong, Gunjan Baid, Zirui Wang, Vijay Vasudevan, Alexander Ku, Yinfei Yang, Burcu Karagol Ayan, et al. Scaling autoregressive models for contentrich text-to-image generation. arXiv preprint arXiv:2206.10789, 2022.
|
| 265 |
+
|
| 266 |
+
Jiapeng Zhu, Yujun Shen, Deli Zhao, and Bolei Zhou. In-domain gan inversion for real image editing. In European conference on computer vision, pp. 592–608. Springer, 2020.
|
| 267 |
+
|
| 268 |
+
Jun-Yan Zhu, Philipp Krahenb ¨ uhl, Eli Shechtman, and Alexei A Efros. Generative visual manipu- ¨ lation on the natural image manifold. In European conference on computer vision, pp. 597–613. Springer, 2016.
|
| 269 |
+
|
| 270 |
+
# A EXTENDED LITERATURE REVIEW
|
| 271 |
+
|
| 272 |
+
As aforementioned in the main text, in this section, we provide an additional review of related works, on (1) Retrieval-augmented Generative Models; and (2) Text-guided Image Editing.
|
| 273 |
+
|
| 274 |
+
Retrieval-Augmented Generative Models Knowledge grounding has also drawn significant attention in the natural language processing (NLP) community. Different semi-parametric models like KNN-LM (Khandelwal et al., 2019), RAG (Lewis et al., 2020), REALM (Guu et al., 2020), RETRO (Borgeaud et al., 2021) have been proposed to leverage external textual knowledge into the transformer language models. These models have demonstrated great advantages in increasing the language model’s faithfulness and reducing the computation/memory cost. Such attempts have also been made in visual tasks like image recognition (Long et al., 2022), 2-D scene reconstruction (Siddiqui et al., 2021), and image inpainting (Xu et al., 2021). Our proposed method follows the same theme to incorporate visual knowledge into a pre-trained text-to-image generation model to help the model generalize to long-tail entities or even unseen entities without scaling up the parameters.
|
| 275 |
+
|
| 276 |
+
Text-Guided Image Editing The work of text-guided image editing aims at preserving the object’s appearance while changing certain contexts in the image. Previously, GANs (Goodfellow et al., 2014) have been used to achieve significant performance on image editing (Zhu et al., 2016; Abdal et al., 2019; Zhu et al., 2020; Roich et al., 2021; Tov et al., 2021; Wang et al., 2022; Alaluf et al., 2022). The problem is also known as inversion as it normally requires finding the initial noise vector added in the generation process. More recently, Prompt-to-Prompt (Hertz et al., 2022) propose to use pre-trained text-image models for image editing. Image editing is focused on performing in-place modifications to the input image, either changing the global styles or editing a local region specifically without modifying the object’s appearance. However, we treat the retrieved image as ‘knowledge’ and ground on it to synthesize new images. Thus, we are not restricted to in-place modifications and are able to perform more sophisticated transformations over the objects.
|
| 277 |
+
|
| 278 |
+
# B WIKIIMAGES DATASET
|
| 279 |
+
|
| 280 |
+
The WikiImages dataset is taken from WebQA (Chang et al., 2022). Images were crawled from Wikimedia Commons via the Bing Visual Search API. Since lots of Wikimedia’s topics are not visually interesting, the authors seeded with natural scenes and gradually refine the search pool to obtain more interesting images. The images are mostly containing entities from Wikipedia or WikiData. However, the original dataset still contains heavy noises. Therefore, we apply further filtering to obtain the more plausible ones for image generation. Specifically, we remove all the image-text pairs with text lengths larger than 15 tokens and all the text with a date or wiki-id information.
|
| 281 |
+
|
| 282 |
+
# C ENTITYDRAWBENCH
|
| 283 |
+
|
| 284 |
+
For dog breeds and birds, we sample 50 from Wikipedia Commons3 as our candidates. For landmarks, we sample 50 from Google Landmarks (Weyand et al., 2020) as our candidate. For foods, we sample 50 from Wikipedia4 as our candidates. For film characters, we collected 50 images from Starwars from Fandom5. We use appropriately paired source images as the retrieved ‘knowledge’. For each entity category, we write 5 prompt templates with an entity name placeholder, which describes the entity in different scenes. Each entity will sample a template and replace the placeholder with the entity’s name to generate a prompt, which is used as input to the text-to-image generation model.
|
| 285 |
+
|
| 286 |
+

|
| 287 |
+
Figure 9: The construction process of EntityDrawBench. We first list entity names and then find their source images from Wikimedia, and finally generate prompts related to these entities.
|
| 288 |
+
|
| 289 |
+
We list all the prompt templates as Figure 10.
|
| 290 |
+
|
| 291 |
+
Figure 10: The EntityDrawBench prompt templates for all the different entity categories.
|
| 292 |
+
|
| 293 |
+
<table><tr><td rowspan=1 colspan=1>Type</td><td rowspan=1 colspan=1>Template 1</td><td rowspan=1 colspan=1>Template2</td><td rowspan=1 colspan=1>Template3</td><td rowspan=1 colspan=1>Template 4</td><td rowspan=1 colspan=1>Template 5</td></tr><tr><td rowspan=1 colspan=1>Dog</td><td rowspan=1 colspan=1>[DOG] is sleeping on the ground.</td><td rowspan=1 colspan=1>[DOG] is running by the river.</td><td rowspan=1 colspan=1>[DOG] is catching a frisbee.</td><td rowspan=1 colspan=1>[DOG] is takinga shower.</td><td rowspan=1 colspan=1>[DOG] is fighting with anotherdog.</td></tr><tr><td rowspan=1 colspan=1>Food</td><td rowspan=1 colspan=1>[FOOD] is placed on the grass.</td><td rowspan=1 colspan=1>[FOOD] is served with wine.</td><td rowspan=1 colspan=1>[FOOD] with popcorn on theside.</td><td rowspan=1 colspan=1>A dog is beside [FOOD](food).</td><td rowspan=1 colspan=1>[FOOD] is decorated withflowers.</td></tr><tr><td rowspan=1 colspan=1>Landmark</td><td rowspan=1 colspan=1>A dog is sitting in front of[LANDMARK]</td><td rowspan=1 colspan=1>A big crowd of tourists in frontof[LANDMARK].</td><td rowspan=1 colspan=1>A rainy day in [LANDMARK].</td><td rowspan=1 colspan=1>[LANDMARK] s lit upduring the night.</td><td rowspan=1 colspan=1>cars parking in front of[LANDMARK].</td></tr><tr><td rowspan=1 colspan=1>Bird</td><td rowspan=1 colspan=1>A [BIRD] is docking on a pier.</td><td rowspan=1 colspan=1>A [BIRD] is drinking water.</td><td rowspan=1 colspan=1>A [BIRD]is flapping its wings.</td><td rowspan=1 colspan=1>A[BIRD] is diving fromthe sky.</td><td rowspan=1 colspan=1>A [BIRD] is swimming in theriver.</td></tr><tr><td rowspan=1 colspan=1>Character</td><td rowspan=1 colspan=1>The StarWars character [ENTITY] isflying in the sky.</td><td rowspan=1 colspan=1>The StarWars character [ENTITY] isstanding in the water.</td><td rowspan=1 colspan=1>The StarWars character [ENTITY]is standing in the garden.</td><td rowspan=1 colspan=1>The character [ENTITY] isin a shopping mall.</td><td rowspan=1 colspan=1>The StarWars character[ENTITY] is in the kitchen.</td></tr></table>
|
| 294 |
+
|
| 295 |
+
# D IMPACT OF RETRIEVAL NUMBER K
|
| 296 |
+
|
| 297 |
+
We change the retrieval number K from 1 to 2 to see its impact on the model output. We show some examples in Figure 11 to demonstrate the advantage of having multiple retrievals to help the model better capture the visual appearance of the given entities.
|
| 298 |
+
|
| 299 |
+
Reference
|
| 300 |
+
|
| 301 |
+

|
| 302 |
+
|
| 303 |
+

|
| 304 |
+
|
| 305 |
+

|
| 306 |
+
Figure 11: Generation Examples for setting K to 1 and 2.
|
| 307 |
+
|
| 308 |
+

|
| 309 |
+
|
| 310 |
+
Hallacas (a traditional dish) is decorated with flowers.
|
| 311 |
+
|
| 312 |
+

|
| 313 |
+
|
| 314 |
+
We demonstrate different types of sampling strategy to leverage two conditions: standard joint condition guidance sampling, weighted guidance sampling, and our proposed interleaved guidance sampling.
|
| 315 |
+
|
| 316 |
+
The standard joint condition guidance only considers the joint diffusion score $\epsilon ( x _ { t } , c _ { n } , c _ { p } )$ to meet both conditions. In contrast, weighted guidance sampling uses the weighted sum of text-enhanced epsilon $\hat { \epsilon } _ { p }$ and neighbor-enhanced epsilon $\boldsymbol { \hat { \epsilon } } _ { n }$ . Our interleaved classifier guidance switches between $\hat { \epsilon } _ { p }$ and $\boldsymbol { \hat { \epsilon } } _ { n }$ , with a ratio of $\eta : 1 - \eta$ . We plot their conceptual difference in Figure 12. Essentially, $\epsilon _ { n }$ and $\epsilon _ { p }$ do not have dependency in weighted sampling, however, they are dependent in interleaved sampling. In an extreme case where $\epsilon _ { n }$ and $\epsilon _ { p }$ are contradictory to each other, the model will get stuck in a local region. In contrast, Interleaved sampling can alleviate this issue.
|
| 317 |
+
|
| 318 |
+

|
| 319 |
+
Figure 12: Weighted Guidance Sampling vs. Interleaved Guidance Sampling.
|
| 320 |
+
|
| 321 |
+
We compare $2 0 \mathrm { d o g }$ images generated from these three sampling strategies in EntityDrawBench. We vary the number of diffusion step to observe their human evaluation score curve and show case some generated outputs in Figure 13. As can be seen, the joint decoding is either dominated by the retrieval image or by the text prompt. Weighted and Interleave can help balance the two conditions to generate better images. We also found that with less sampling steps ${ \tt K } = 2 0 0$ , “weighted” sampling actually achieves better results than “interleaved” sampling. However, as the sampling steps increase, our proposed “interleaved” sampling achieves better human evaluation score.
|
| 322 |
+
|
| 323 |
+

|
| 324 |
+
EntityDrawBench Human Score vs. NFE
|
| 325 |
+
|
| 326 |
+
Figure 13: Different classifier-free guidance sampling strategy (Interleave is ours).
|
| 327 |
+
|
| 328 |
+
# F GENERATION EXAMPLES
|
| 329 |
+
|
| 330 |
+
We provide more generation examples in Figure 14 and Figure 15.
|
| 331 |
+
|
| 332 |
+

|
| 333 |
+
Figure 14: Extra None-cherry picked examples from EntityDrawBench for different models.
|
| 334 |
+
|
| 335 |
+

|
| 336 |
+
Figure 15: Extra None-cherry picked examples from EntityDrawBench for different models.
|
| 337 |
+
|
| 338 |
+
# G IMAGINARY EXAMPLES
|
| 339 |
+
|
| 340 |
+
We provide generation results for imaginary scene in Figure 16.
|
| 341 |
+
|
| 342 |
+

|
| 343 |
+
Figure 16: Imaginary Scenes generated by Re-Imagen.
|
| 344 |
+
|
| 345 |
+
# H COMPARISON WITH DREAMBOOTH
|
| 346 |
+
|
| 347 |
+
We also add comparison to DreamBooth (Ruiz et al., 2022). We adopt almost the same input images from DreamBooth and display our generation results in Figure 17, Figure 18 and Figure 19.
|
| 348 |
+
|
| 349 |
+
Re-Imagen
|
| 350 |
+
|
| 351 |
+
# DreamBooth
|
| 352 |
+
|
| 353 |
+

|
| 354 |
+
Figure 17: Imaginary Scenes generated by Re-Imagen.
|
| 355 |
+
|
| 356 |
+
# Re-Imagen
|
| 357 |
+
|
| 358 |
+
# DreamBooth
|
| 359 |
+
|
| 360 |
+

|
| 361 |
+
Figure 18: Imaginary Scenes generated by Re-Imagen.
|
| 362 |
+
|
| 363 |
+

|
| 364 |
+
Re-Imagen
|
| 365 |
+
Figure 19: Imaginary Scenes generated by Re-Imagen.
|
| 366 |
+
|
| 367 |
+
# DreamBooth
|
| 368 |
+
|
| 369 |
+
# I FAILURE EXAMPLES
|
| 370 |
+
|
| 371 |
+
We found that Re-Imagen can also fail in a lot of cases. We demonstrate a few examples in Figure 20. As can be seen, the model sometimes has a few failure modes: (1) the text input prior is too strong like ‘Zoom’ will be interpreted as a ‘Zoom-in’ picture by the model. (2) the model cannot ground the retrieval text on the retrieval image, for example, the model believes that only the ‘beef tenderloin inside the bowl’ is ‘Escudella’ rather than the whole stew, therefore generating ‘beef tenderloin on the grass’. (3) the model can sometimes mess up two conditions, for example, the reference ‘Australian Pinscher’ and the ‘rabbit’ in the prompt gets mixed into a single object.
|
| 372 |
+
|
| 373 |
+

|
| 374 |
+
Figure 20: Failure examples from EntityDrawBench for dogs, landmarks, and foods.
|
md/dev/XVjTT1nw5z/XVjTT1nw5z.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/XcDVT8HarS/XcDVT8HarS.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/XzTtHjgPDsT/XzTtHjgPDsT.md
ADDED
|
@@ -0,0 +1,479 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# COORDINATION AMONG NEURAL MODULESTHROUGH A SHARED GLOBAL WORKSPACE
|
| 2 |
+
|
| 3 |
+
Anirudh Goyal 1, Aniket Didolkar1, Alex Lamb 5, Kartikeya Badola 6, Nan Rosemary Ke 2, Nasim Rahaman 1, 3, Jonathan Binas 1, Charles Blundell 2, Michael Mozer 4, Yoshua Bengio 1
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
Deep learning has seen a movement away from representing examples with a monolithic hidden state towards a richly structured state. For example, Transformers segment by position, and object-centric architectures decompose images into entities. In all these architectures, interactions between different elements are modeled via pairwise interactions: Transformers make use of self-attention to incorporate information from other positions and object-centric architectures make use of graph neural networks to model interactions among entities. We consider how to improve on pairwise interactions in terms of global coordination and a coherent, integrated representation that can be used for downstream tasks. In cognitive science, a global workspace architecture has been proposed in which functionally specialized components share information through a common, bandwidth-limited communication channel. We explore the use of such a communication channel in the context of deep learning for modeling the structure of complex environments. The proposed method includes a shared workspace through which communication among different specialist modules takes place but due to limits on the communication bandwidth, specialist modules must compete for access. We show that capacity limitations have a rational basis in that (1) they encourage specialization and compositionality and (2) they facilitate the synchronization of otherwise independent specialists.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Deep Learning has seen a movement towards more structured models with cleaner separation between different pieces of information often handled by different components. The induced structure, and separation of knowledge has improved generalization, model-size scaling, and long-range dependencies (Berner et al., 2019; Vinyals et al., 2019; Brown et al., 2020). This opens up questions about how to achieve coherence and coordination between different components in such architectures. Looking back to the 1980s, the focus in AI was much less on learning and more on constructing articulated, multi-component architectures and examining how intelligence might emerge from interactions among this collection of simple, functionally specialized components (Fodor, 1983; Braitenberg, 1986; Minsky, 1988; Brooks, 1991). Each
|
| 12 |
+
|
| 13 |
+

|
| 14 |
+
Figure 1: Step 1: an ensemble of specialist modules doing their own default processing; at a particular computational stage, depending upon the input, a subset of the specialists becomes active. Step 2: the active specialists get to write information in a shared global workspace. Step 3: the contents of the workspace are broadcast to all specialists.
|
| 15 |
+
|
| 16 |
+
of these specialist modules is on the scale of a typical component of a computer program, like a subroutine that implements a narrow, prespecified function from certain input contents to certain output contents. Through appropriate communication and coordination, a set of specialists can achieve complex, dynamic, and flexible behavior patterns.
|
| 17 |
+
|
| 18 |
+
As a concrete illustration, consider the task of driving a car in terms of specialists. One specialist might monitor the position of the car with respect to lines on the road, and another specialist might adjust the steering direction based on the perceptual data. In addition, there might be specialists which provide alerts when certain events occur, such as loud sounds, reaching a critical intersection on a route, or coming into close proximity to the car in front. To execute the task of driving the car properly, all these specialists need to interact coherently and broadcast their individual information to each other.
|
| 19 |
+
|
| 20 |
+
Arguably, modern ML and AI has yet to develop broad architectural frameworks for learning both the specialist modules and how they should interact, while the classical view lacks an articulate story about how learning could take place successfully in such frameworks. In this article, we revisit this classical view with modern machine learning tools based on end-to-end learning and differentiable memory and attention mechanisms. Inspired by the Global Workspace Theory (Baars, 1993; Dehaene et al., 1998; Shanahan and Baars, 2005; Shanahan, 2006; 2010; 2012; Dehaene et al., 2017) from cognitive neuroscience, we argue that more flexibility and generalization emerge through an architecture of specialists if their training encourages them to communicate effectively with one another via the bottleneck of a shared workspace (Figure. 1).
|
| 21 |
+
|
| 22 |
+
Distributed specialist modules. From a computational perspective, articulated multi-component architectures composed of sparsely interacting specialist modules show desirable scaling properties (e.g., more specialists can seamlessly be added), increased robustness (the system can tolerate the removal of or changes in individual specialists), and efficiency (information is processed predominantly locally, reducing the cost of communication between specialists). However, modularization also requires mechanisms to establish sharing of compatible representations across specialists, a form of shared internal language. While portions of a task might be solved by independent specialists, synchronization is critical particularly when there are statistical, functional, or causal dependencies among the specialists.
|
| 23 |
+
|
| 24 |
+
Coherence through a shared workspace. In cognitive neuroscience, the Global Workspace Theory (GWT) (Baars, 1993; Dehaene et al., 2017) suggests an architecture allowing specialist modules to interact. The key claim of GWT is the existence of a shared representation—sometimes called a blackboard, sometimes a workspace—that can be modified by any specialist and that is broadcast to all specialists, along with the notion that write access is limited to maintain coherence. Our interpretation of this restriction on write access is that it stems from an assumption on the form of the joint distribution between high-level concepts. In this paper, we explore a communication and coordination scheme similar to the one proposed by GWT for modern neural network architectures like Transformers (Vaswani et al., 2017; Dehghani et al., 2018; Parmar et al., 2018; Radford et al., 2019; Brown et al., 2020) and attention-based modular architectures (Goyal et al., 2019; Rahaman et al., 2020; Mittal et al., 2020a; Goyal et al., 2020; Madan et al., 2021).
|
| 25 |
+
|
| 26 |
+
In terms of our driving example, the workspace could be used to override default behaviors by giving high priority to specialist modules which provide alerts of various sorts (loud sounds, presence of a child on the street), allowing specialists which respond to such alerts to take control of behavior over default driving routines. This scenario implies that prioritization of signals in a shared workspace is critical.
|
| 27 |
+
|
| 28 |
+
A shared communication channel necessitates common representations. For a multitude of specialist modules to cooperate, a common language is necessary (Baars, 1997). For example, in the driving scenario, alerts may come from auditory or visual processing specialists, but regardless of the source, a signal for danger must be placed in the workspace to override default behavior, whether that behavior is controlled by a radio-tuning specialist or a steering specialist. Although specialist modules can be pre-wired to have compatible communication interfaces, we will model an architecture in which an ensemble of specialist modules is trained in coordination, which should lead to a shared language (Colagrosso and Mozer, 2005). Internally, individual specialists can use whatever form of representations that serves them, but their inputs and outputs require alignment with other specialists in order to synchronize. For example, an unusual event such as a rough thud under the wheels might not have been previously experienced, but the mere signalling of novelty could override default specialists. Without a global communication channel, specialists would have to learn to communicate through pairwise interactions, which might limit coordination of behavior in novel situations: global communication ensures exchangeability of knowledge to achieve systematic generalization.
|
| 29 |
+
|
| 30 |
+

|
| 31 |
+
Figure 2: Using a Shared Workspace for creating global coherence in RIMs, Transformers, TIMs and Universal Transformers (UT). (Top Half) All four of these architectures use pairwise communication (using key-value attention) to establish coherence between individual specialist modules. In the case of RIMs (Goyal et al., 2019) and TIMs (Lamb et al., 2021), these specialists are independent modules that compete with each other in order to take control over the state update based on a given input. In the case of Transformers (Vaswani et al., 2017) and Universal Transformers (Dehghani et al., 2018), each specialist is associated with a different position. Activated specialists are denoted by a blue shade and the intensity depends on the degree of activation. In the case of Universal Transformers, the state update dynamics for each position is shared across all layers and all positions (denoted by a yellow triangle). (Bottom Half) We replace pairwise communication with a shared workspace to create global coherence between different specialists. Communication using the shared workspace is a two-step process (as denoted by 1 and 2 in the figures). In the first step (1), specialists compete for write access to the shared workspace, resulting in a subset of them being activated (in blue), and only the activated specialists perform the write operation on the workspace. In the second step (2), the contents of the shared workspace are broadcast to all the specialists.
|
| 32 |
+
|
| 33 |
+
# 2 SYNCHRONIZING NEURAL MODULES THROUGH A SHARED WORKSPACE
|
| 34 |
+
|
| 35 |
+
We investigate a neural architecture reminiscent of the GW model, where a number of sparsely communicating specialist modules interact via a shared working memory. In particular, we extend the Transformer (Vaswani et al., 2017), attention and slot-based modular architectures (Goyal et al., 2019) by adding a shared workspace and allowing modules (each representing an entity) to compete for write access in each computational stage.
|
| 36 |
+
|
| 37 |
+
Key-value attention. Key-value attention defines the backbone of updates to the hidden states in the proposed model. This form of attention is widely used in self-attention models and performs well on a wide array of tasks (Bahdanau et al., 2014; Vaswani et al., 2017; Santoro et al., 2018). Key-value attention selects an input value based on the match of a query vector to a key vector associated with each value. To allow differentiability and thus easier learnability, selection is soft and computes a convex combination of all the values. Such a mechanism makes it possible to change on-the-fly both the source of input and how the shared workspace is updated. It also makes the outputs of the specialists and the elements of the memory permutation invariant: they should be considered as an unordered set of elements to be selected by an attention mechanism from the contents of specialists. More precisely, soft attention uses the product of a query (represented as a matrix $Q$ of dimensionality $N _ { r } \times d$ , with $N _ { r }$ queries, and $d$ the dimension of each query) with a set of $N _ { o }$ objects each associated with a key as a row in matrix $K ^ { T }$ $( N _ { o } \times d )$ . After normalization with a softmax the resulting convex weights are used to combine the values $V _ { i }$ (row $i$ of matrix $V$ ): where the softmax is applied to each row of its argument matrix, yielding a set of convex weights. For our experiments, we use multihead dot product attention.
|
| 38 |
+
|
| 39 |
+
Neural modules with pairwise interactions. Our approach to synchronizing neural modules is highly general and mostly agnostic to the task, domain, or specific choice of architecture, with the only requirement being that the model consists of multiple specialist modules which either operate independently or have sparse interactions requiring to only match pairs of modules at a time. Our goal is to explore how introducing a shared workspace can help these modules to become better synchronized and coordinated. We show the utility of the shared workspace for synchronization in (a) Transformers (Vaswani et al., 2017), in which all interactions between positions are performed via attention, and (b) slot-based architectures like Recurrent Independent Mechanisms or RIMs (Goyal et al., 2019) in which all pairwise interactions between modules are performed via attention. In the context of slot-based architectures, each slot’s content is associated with a specialist module, whereas in Transformers different entities each associated with a different position acts as a specialist module (Figure 2).
|
| 40 |
+
|
| 41 |
+
Both Transformers and RIMs utilize a self-attention mechanism for sharing information between modules, typically implemented in a pairwise manner, i.e., each specialist attends to every other specialist. Instead, we facilitate information sharing among specialist modules through a limited capacity shared workspace. In this framework at each computational stage, different specialists compete for write access to the common workspace. The contents of the workspace, in turn, are broadcast to all specialist modules simultaneously.
|
| 42 |
+
|
| 43 |
+
Notation. The input is processed through a sequence of computational stages indexed by $t$ , and at each stage, $n _ { s }$ entities are operated on (i.e., $n _ { s }$ different modules in slot-based architectures like RIMs or $n _ { s }$ different positions in the case of Transformers). Each of these $n _ { s }$ specialist modules has a distinct internal $n _ { h }$ -dimensional state $\mathbf { \Delta } _ { h _ { t } ^ { k } }$ , for $k \in \{ 1 , . . . , n _ { s } \}$ . The specialist modules communicate with each other via a shared workspace divided into $n _ { m }$ memory slots, each consisting of a vector of $n _ { l }$ elements, denoted $M = [ \pmb { m } _ { 1 } ; \dots \pmb { m } _ { j } ; \dots \pmb { m } _ { n _ { m } } ]$ . The shared workspace is updated across different computational stages i.e., different time-steps in recurrent architecture and different layers in the case of Transformers. At each computational stage $t$ , different specialists compete for writing in the shared workspace, but all specialists can read from the current state of the workspace. In the case of an autoregressive task, we can restrict the information sharing to previous positions and keep a separate version of the workspace for each position.
|
| 44 |
+
|
| 45 |
+
# 2.1 SPECIFICS OF THE SHARED WORKSPACE.
|
| 46 |
+
|
| 47 |
+
Step 1: Process Input to obtain an entity representation for each specialist. The first step is external to the proposed method, and involves processing the input to form the initial representation vector for each of the different specialists. Different common deep learning architectures can be used to form the representation of different specialists. For example, Transformers start with a matrix $n _ { s } \times n _ { h }$ whose rows are initialized as the $n _ { h }$ -dimensional embeddings of the input at each position of the sequence. Slot-Based Recurrent architectures like RIMs consist of a single-layer recurrent structure where the hidden state $\mathbf { h } _ { t }$ at computational stage $t$ is decomposed into the substates of the $n _ { s }$ specialists, $\mathbf { h } _ { t } ^ { k }$ for $k = 1 , . . . n _ { s }$ .
|
| 48 |
+
|
| 49 |
+
In the proposed scheme, within each computational stage, the updates of the hidden state of different specialists follow a two-step process. First, specialists compete and write to a shared workspace. Second, information from the workspace gets broadcast to all the specialists, as detailed next.
|
| 50 |
+
|
| 51 |
+
Step 2: Writing Information in the shared workspace. The specialists compete to write into the shared workspace, whose contents need to be updated in the context of new information received from different specialists. This step ensures that only the critically important signals make it to the shared workspace, therefore preventing the workspace from being cluttered. Let matrix $\pmb { R }$ represent the combined state of all the specialists (i.e. $h _ { t } ^ { k } \mathbf { \Sigma } ^ { \ast } \forall k \in \{ 1 , \dots , \mathbf { \bar { n } } _ { s } \}$ as the rows of $\pmb { R }$ ). In order to implement the competition between specialists to write into the workspace, we use a key-query-value attention mechanism. In this case, the query is a function of the state of the current workspace memory content, represented by matrix $M$ (with one row per slot of the memory), i.e $\widetilde { Q } = M \widetilde { W } ^ { q }$ . Keys and values are a function of the information from the specialists i.e., a function of $\pmb { R }$ . We apply dot product attention to get the updated memory matrix: $\begin{array} { r } { M \gets \operatorname { s o f t m a x } \left( \frac { \widetilde { Q } ( R \widetilde { W } ^ { e } ) ^ { \mathrm { T } } } { \sqrt { d _ { e } } } \right) R \widetilde { W } ^ { v } } \end{array}$ . The use of a regular softmax to write into $M$ leads to a standard soft competition among different specialists to write in the shared workspace. One can also use a top- $k$ softmax (Ke et al., 2018) to select a fixed number of specialists allowed to write in the shared workspace: based on the pre-softmax values, a fixed number of $k$ specialists which have the highest values are selected, and get access to write in the shared workspace. Selection with a top- $k$ softmax is a hybrid between hard and soft selection. We denote the set of thus selected specialists as $\mathcal { F } _ { t }$ . We note that we can apply the attention mechanism multiple times to distill information from different specialists into the shared workspace. Here, the contents of the shared workspace are updated in the gated way as proposed in RMC (Santoro et al., 2018). We ask the reader to refer to appendix section $\textrm { C }$ for more details.
|
| 52 |
+
|
| 53 |
+
Step 3: Broadcast of information from the shared workspace. Each specialist then updates its state using the information broadcast from the shared workspace. We again utilize an attention mechanism to perform this consolidation. All the specialists create queries ${ \widehat { q } } _ { k } = h _ { t } ^ { k } { \widehat { W } } ^ { q }$ , which are matched with the keys $\widehat { \pmb { \kappa } } _ { j } = ( \pmb { m } _ { j } \widehat { W } ^ { e } ) ^ { \mathrm { T } } \quad \forall k \in \{ 1 , \dots , n _ { s } \}$ , $j \in \{ 1 , \dots , n _ { m } \}$ from the updated memory slots, forming attention weights $\begin{array} { r } { s _ { k , j } = \mathrm { s o f t m a x } \left( \frac { \widehat { q } _ { k } \widehat { \kappa } _ { j } } { \sqrt { d _ { e } } } \right) } \end{array}$ The memory slot values generated by each slot of the shared workspace and the attention weights are then used to update the state of all the specialists: $\begin{array} { r } { \pmb { h } _ { t } ^ { k } \pmb { h } _ { t } ^ { k } + \sum _ { j } s _ { k , j } \widehat { \pmb { v } } _ { j } } \end{array}$ where $\widehat { \pmb { v } } _ { j } = \pmb { m } _ { j } \widehat { \pmb { W } } ^ { v } \quad \forall k \in \{ 1 , \dots , \overset { \cdot } { n } _ { s } \}$ . After receiving the broadcast information from the workspace, each specialist update their state by applying some dynamics function i.e., one step update of LSTM or GRU units in the case of recurrent architectures, and a feedforward layer in the case of Transformers. This yields the new value $\boldsymbol { h } _ { t + 1 } ^ { k }$ for the $k \mathrm { . }$ -th specialist, from which we start the next stage $( t + 1 )$ .
|
| 54 |
+
|
| 55 |
+
Replacing pairwise interactions among neural modules with interaction facilitated by the shared workspace allows for the following:
|
| 56 |
+
|
| 57 |
+
1. Higher-order $( H O )$ interaction among neural modules. The two-step write-read process first allows each memory slot to store a ‘filtered summary’ of the current input where the ‘filter’ is determined by the previous state of that slot (‘Query’ for the write step). Neural modules then summarize the information contained in these slots and update their state. Hence unlike pairwise interaction, messages passed among neural modules in the shared workspace setting also include HO interaction terms; those consisting of more than 2 modules at a time. Naturally, HO interaction require that messages passed among neural modules lie in the same representation space, which is precisely what we aim to achieve by allowing message passing only via a singular global channel.
|
| 58 |
+
|
| 59 |
+
2. Dynamic filtering due to persistence of memory. With a shared workspace (SW), contents of the memory slot play a key role in filtering and summarizing the information contained in the input at a given time step. Persistence of memory throughout an episode 1) would allow the memory layer to summarize and filter information based on what it has seen thus far 2) should ideally lead to better generalization as the model is able to dynamically modify its filtering machinery for a particular input. In contrast, “inducing points” in Set Transformers (Lee et al., 2019) are fixed after training and hence the bottleneck cannot adjust itself on the fly for any new input. We present comparisons on several tasks in section 4. They show the importance of these two properties by comparing performance of SW with a) $2 \times \mathrm { S e l f }$ -Attention (to simulate HO interaction without global communication) b) a version without memory persistence, in Appendix D.
|
| 60 |
+
|
| 61 |
+
Computational Complexity of using shared workspace for synchronizing different specialists. To encourage a coherent global coordination, Transformers and slot-based recurrent architectures rely on pairwise interactions captured via an attention mechanism. Unfortunately, such attention mechanisms scale quadratically with the number of specialists. Here, we propose a method which uses a shared workspace to create global coherence between different specialists and in the process, replaces the pairwise interactions of conventional dot-product attention. The computational complexity of the proposed method is thus linear in the number of specialists. In our experimentation, the number of memory slots is practically constant, which suggests a very favourable scaling behavior, and certainly much less than quadratic. As a point of reference, what would correspond to the number of slots in human working memory (Baars, 1993) is indeed very small (less than 10 slots).
|
| 62 |
+
|
| 63 |
+
# 3 RELATED WORK
|
| 64 |
+
|
| 65 |
+
This work taps into a line of reasoning put forward by historical works, such as Minsky (1988); Braitenberg (1986); Fodor (1983), wherein it is argued that in order to be able to deal with a wide spectrum of conditions and tasks, an intelligent system should be comprised of many interacting specialized modules or programs, rather than a single “one-size-fits-all” entity. While modular architectures have been the subject of a number of research directions, (Jacobs et al., 1991; Bottou and Gallinari, 1991; Ronco et al., 1997; Reed and De Freitas, 2015; Andreas et al., 2016; Rosenbaum et al., 2017; Fernando et al., 2017; Shazeer et al., 2017; Rosenbaum et al., 2019; Goyal and Bengio,
|
| 66 |
+
|
| 67 |
+
2020), we focus here on a mechanism for achieving coherence and synchronization between specialist modules via a global workspace shared between all specialists.
|
| 68 |
+
|
| 69 |
+
Prior works have explored incorporating slot-based memory in the context of recurrent neural networks (Graves et al., 2014; 2016; Santoro et al., 2018). In the context of transformers, Burtsev and Sapunov (2020) introduce memory tokens that are processed in addition to sequence tokens, whereas Dai et al. (2019) (Transformer-XL) propose to partition a long sequence to smaller segments and use the activations of the previous segment in memory while processing the current segment. Building on the latter, Rae et al. (2019) propose to store activations from prior segments in a compressed memory. However, these methods do not restrict memory writes to be sparse and competitive. Recent advances in this direction include the global neuronal workspace (GNW) model (Dehaene and Changeux, 2011), which identifies the global workspace with a large network of excitatory pyramidal neurons with long-range axonal processes connecting prefrontal and parietal cortices. Further, deploying a shared workspace to establish coherence between different specialists as opposed to using all-pair communication has an added benefit, in that it allows us to tackle the $O ( n ^ { 2 } )$ complexity of selfattention. This makes our work related to previous work on reducing the computational complexity of dot product attention in Transformers. Lee et al. (2019) introduce the $I S A B$ module, which maps between sets and comprises two dot-product attention layers. In the first layer, a set of trainable parameters are used as queries and the elements of the input set as keys; in the second layer, the output of the first layer is used as keys and the input set as queries. However, unlike in this work, the intermediate states (corresponding to the output of the first layer) are not maintained across layers. Concurrent to our work, (Jaegle et al., 2021) also introduced the idea of using a latent bottleneck for addressing quadratic complexity by learning a bottleneck but there are important differences. For example. in Perceiver the latent bottleneck iteratively queries the information about different positions, and does not maintain the representation of the different specialists. More precisely, in our proposed method different specialists write information in the workspace and then information gets read from the shared workspace. In Perceiver, the latent bottleneck iteratively reads information from the set of positions. We also show the applicability of the proposed idea both for slot based models and Transformers.
|
| 70 |
+
|
| 71 |
+
The proposed model can also be seen as integrating out different ideas popular in modular architectures (Andreas et al., 2016; Goyal et al., 2019), memory networks (Graves et al., 2014; Santoro et al., 2018) and mixture of experts (Jacobs et al., 1991), and hence combining some of their benefits in a unified architecture. The proposed model is factored as a set of specialists (incorporating modularity). The proposed model achieves coordination among different specialists via the use of a shared workspace (in the Neural Turing machines, there is only a single specialist i.e., without any modularity). Multiple experts can be active at the same time (generally not the case with a mixture of experts).
|
| 72 |
+
|
| 73 |
+
# 4 EXPERIMENTS
|
| 74 |
+
|
| 75 |
+
Here we briefly outline the tasks on which we applied the idea of the shared workspace and direct the reader to the appendix for some more experiments (Appendix G), full details on each task and details on hyperparameter settings for the model. The experiments have the following goals: (a) Demonstrate that the use of the shared workspace can improve results on a wide array of challenging benchmark tasks, with the goal of demonstrating the practical utility and breadth of the technique. (b) Show that the shared workspace addresses coherence between different specialists by achieving improved performance without requiring all pairwise interactions. Finally, to show wide applicability of our model, we integrate SW in TIMs (Lamb et al., 2021), SCOFF (Goyal et al., 2020) and BRIMs (Mittal et al., 2020b) and show improvements over the default communication method used in each.
|
| 76 |
+
|
| 77 |
+
Making sense of the visual input. Using a shared workspace introduces a bottleneck in sharing of information between specialists. Since the size of the workspace is limited and generally much lower than the number of specialists, there is a limit to the amount of information that can be exchanged among specialists. We hypothesize that mediating communication through a limited capacity workspace should encourage the model to look at relevant information that is important for the downstream objective. We test this hypothesis on a set of visually challenging benchmarks. For our experiments, we use either Transformers or RIMs as a backbone. We consider variants of Transformers based on different subsets of important properties. Transformers [TR]: Self-attention based multi-layer architecture (Vaswani et al., 2017) with shared parameters across layers. Set transformer [ISAB]: Transformers where self attention is replaced by ISAB module (Lee et al., 2019). Sparse
|
| 78 |
+
|
| 79 |
+

|
| 80 |
+
Figure 3: Detecting Equilateral Triangles. Here, we compare the performance of the Transformers with shared workspace to other Transformer baselines. Here, we plot the test accuracy for each model.
|
| 81 |
+
|
| 82 |
+
<table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>Top-1 %</td><td rowspan=1 colspan=1>Top-5 %</td></tr><tr><td rowspan=1 colspan=1>ISABSTRTR</td><td rowspan=1 colspan=1>65.3±0.02570.6±0.0870.83±0.44</td><td rowspan=1 colspan=1>83.6±0.01187.33±0.0687.8±0.08</td></tr><tr><td rowspan=1 colspan=1>TR+HC</td><td rowspan=1 colspan=1>70.17±0.31</td><td rowspan=1 colspan=1>88.33±0.2</td></tr><tr><td rowspan=1 colspan=1>TR+HSW (OURS)</td><td rowspan=1 colspan=1>71.07±0.04</td><td rowspan=1 colspan=1>88.6±0.49</td></tr><tr><td rowspan=1 colspan=1>TR+ SSW (OURS)</td><td rowspan=1 colspan=1>71.33±0.34</td><td rowspan=1 colspan=1>88.3±0.05</td></tr></table>
|
| 83 |
+
|
| 84 |
+
Table 1: Comparison on CATER Object Tracking. Here, we compare the Top-1 and Top-5 accuracy of Transformers with shared workspace and Transformers with self-attention. We can see that Transformers with a shared workspace outperform those with pairwise selfattention.
|
| 85 |
+
|
| 86 |
+
Transformers [STR]: Transformers with sparse factorizations of the attention matrix (Child et al., 2019). High Capacity Transformers $[ \mathrm { T R + H C } ]$ : Same as TR but with different parameters across layers. Transformers with Shared Workspace with soft-competition $\scriptstyle \left[ \mathrm { T R + S S W } \right]$ : Transformers with different positions competing with each other to write in shared workspace using soft-competition. Transformers with Shared Workspace with top- $k$ competition $\mathrm { [ T R + H S W ] }$ : Transformers with different positions competing with each other to write in shared workspace using top- $k$ competition. For a more detailed description of all the tasks described below, we ask the reader to appendix section E.
|
| 87 |
+
|
| 88 |
+
Detecting Equilateral Triangles. We first use a simple toy task to test our hypothesis where the model should detect equilateral triangles in images (Ahmad and Omohundro, 2009). Each image is of size $6 4 \times 6 4$ and contains 3 randomly placed clusters of points. For equilateral triangles, the midpoints of these clusters are equidistant from each other. This is a binary classification task where the model has to predict whether the three given clusters form an equilateral triangle or not. To feed an image into a Transformer, we follow the same methodology as used in vision Transformers (Dosovitskiy et al., 2020). We first divide an image into equal sized $4 \times 4$ patches and treat each patch as a different input position of the Transformer.
|
| 89 |
+
|
| 90 |
+
To solve this task correctly, the model only needs to attend to relevant information i.e., to patches that contain the cluster of points. Therefore, using a limited capacity shared workspace should be useful here. Our results (presented in Figure
|
| 91 |
+
|
| 92 |
+

|
| 93 |
+
Figure 4: Comparison on Sort-of-CLEVR relational reasoning. Speed of convergence for relational and non-relational questions in the sort-ofclevr dataset. We can see that the proposed model converges much faster than the baselines in both cases.
|
| 94 |
+
|
| 95 |
+
3) confirm this hypothesis. We can see that Transformers with shared workspace attention converge much faster and reach higher accuracy as compared to the baseline Transformer. Our method also outperforms Set Transformer by a significant margin.
|
| 96 |
+
|
| 97 |
+
Multi MNIST Generation. In this task, we train an Image Transformer (Parmar et al., 2018) (pixelby-pixel, raster-order generative model) for next-pixel prediction on the “MultiMNIST dataset” where each image consists of 4 independently sampled MNIST digits stacked horizontally to form one image (see Figure 10 for demonstration). The main aim of this task is to observe the inductive biases that allow for specialization of mechanisms in TIMs (Lamb et al., 2021). Each image in the MultiMNIST dataset can be broken down into different sets of independent spatial components. Since the digits which make up the image are independently selected, the joint distribution of pixel intensities in any one of the four sections of the image is statistically independent of the pixel intensities in any other section of the image. Moreover each section of the image can be further broken down into independent spatial components: one that pertains to the background and one that pertains to the foreground. One can expect that architectures that are made up of sparsely interacting different mechanisms to naturally capture this statistical independence by dividing labour among different mechanisms. While, for monolithic architectures, a major portion of their training time will be spent in learning these statistical independencies from scratch. We find that replacing the pairwise communication in TIMs with a shared workspace $( \mathrm { T I M s } + \mathrm { S W } )$ ) leads to better and more interpretable division of labor among specialists as shown in Figure 5. From the figure, It is clear that the TIMs model is unable to divide labour among specialists with mechanism 2 being activation for all the pixels in the image. On the other hand, we can see that TIMs $+ \ S W$ is able to divide labor among specialists with each mechanism focusing on a different aspect of the image. We can see that mechanism 2 gets activated for the digits which are present towards the centre of each of the 4 columns while mechanisms 3 and 4 cover the background of the digits, with mechanism 3 covering the area between adjacent digits and mechanism 4 covering the area above and below the digits. Thus, we can see that using a shared workspace aids the division of labor among different specialists. We also find that TIMs $+ \thinspace S \mathbf { W }$ results in the least cross-entropy loss in the test set when compared to TIMs and Image Transformers (Parmar et al., 2018). Results shown in appendix Table 5.
|
| 98 |
+
|
| 99 |
+
CATER: Object Tracking. Cater is a spatiotemporal reasoning video dataset introduced in Girdhar and Ramanan (2019). Each video contains 3D objects organized in a $6 \times 6$ grid. Each object affords certain actions that can be performed on them. These actions result in movement of the concerned objects and change in their positions. Some of these actions include: rotate, pick-place, slide, contain. Throughout the duration of the video, a number of these actions are performed to get the final state of the grid. Note that only a single object undergoes an action, at any instant. The task that we focus on here is called localization. In this task, the goal is to predict the location of the target object in the final frame. In this case the target object is called a snitch. The snitch as well as the other objects move across the $6 \times 6$ grid. In some scenarios, the snitch may be covered by other objects hence hiding it from the view. In such cases, tracking the movement of the snitch across frames becomes essential. Therefore, capturing long-range temporal dependencies is essential to solve this task.
|
| 100 |
+
|
| 101 |
+
The information exchange limit enforced by the limited capacity of the shared workspace should
|
| 102 |
+
|
| 103 |
+

|
| 104 |
+
Figure 5: This figure shows the mechanism activation map for all 4 mechanims used in the multimnist generation task for both TIMs and TIMs $^ +$ SW. Both the images in the figure correspond to the activation maps from 4 different examples. Each activation map contains 4 mechanisms shown from left to right in a single row. Each mechanism is shown using a $3 2 \times 3 2$ image, a particular pixel in a mechanism activation map is shown in white if that mechanism was used during the generation of that pixel while generating the image.
|
| 105 |
+
|
| 106 |
+
be useful here as well. For CATER, in some frames the snitch is not visible as it is covered by other objects. Therefore, ideally the model only needs to attend to frames in which the snitch is visible. Additionally, if the snitch is visible throughout the video in all frames, then to accurately predict the final position of the snitch, the model only needs to attend to the final frame of the video and can completely ignore the initial frames. The results for this task are presented in Table 1. We also experimented with both soft competition $\mathrm { T R } { + } \mathrm { S } \mathrm { S } \mathrm { W }$ and hard competition $\mathrm { T R } { + } \mathrm { H S } \mathrm { W }$ , with only $k = 5$ specialists writing into the shared workspace. We can see that models with a shared workspace outperform those with pairwise multihead attention thus confirming our hypothesis about the benefits of a shared workspace for this task. As shown in Table 1 proposed method convincingly outperforms the Set Transformer.
|
| 107 |
+
|
| 108 |
+
Relational Reasoning $:$ Sort-of-CLEVR. In relational reasoning, the model is tasked with answering questions about certain properties of various objects and their relations with other objects. The model is presented with an image and a question for that image. This task has a clear sparse structure as in order to answer the questions correctly, it needs to only reason about a specific subset of objects that the question mentions. For this task, we use the Sort-of-CLEVR dataset (Santoro et al., 2017).
|
| 109 |
+
|
| 110 |
+
Each image in Sort-of-CLEVR is of size $7 5 \times 7 5$ and contains 6 randomly placed geometrical shapes of 6 possible colors and 2 possible shapes. Each image comes with 10 relational questions and 10 nonrelational questions. Non-relational questions only consider properties of individual objects. On the other hand, relational questions consider relations among multiple objects. For more details about the question see appendix Figure 8. The input to the model consists of the image and the corresponding question. We first obtain a sequence of equal-sized patches for the image as in vision Transformers (Dosovitskiy et al., 2020). We concatenate the resulting patch sequence with the representation of the question and pass the combined sequence through the Transformer. Sort-of-CLEVR has a finite number of possible answers, hence this task is setup as a classification task.
|
| 111 |
+
|
| 112 |
+
We present the results for this task in Figure 4. We observe that the Transformers with the shared workspace converge faster and outperform the baselines for relational as well as non-relational questions. The superior performance with shared memory can be attributed to the inherent sparsity of this task. For instance, in non-relational questions, the model only needs to attend to a single object referenced in the question to answer it correctly, while relational questions only consider a small subset of objects in the image, thus sparsity is helpful for both these types of questions. Therefore, the limited capacity of the shared workspace forces the model to attend to only relevant information.
|
| 113 |
+
|
| 114 |
+
Shared Workspace for Physical Reasoning. In this task, we consider a set of bouncing balls and the model is tasked with predicting the trajectory of the balls at each step. In order to solve this task, a coherent picture of where and which objects will collide needs to be established by the learner. We use the bouncing-ball dataset from Van Steenkiste et al. (2018). We train the model for
|
| 115 |
+
|
| 116 |
+
<table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>Num. Slots</td><td rowspan=1 colspan=1>ARI个</td><td rowspan=1 colspan=1>MSE↓</td></tr><tr><td rowspan=1 colspan=1>SCOFF</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>0.276±0.001</td><td rowspan=1 colspan=1>0.083±0.0</td></tr><tr><td rowspan=1 colspan=1>SCOFF +SW</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>0.154±0.007</td><td rowspan=1 colspan=1>0.135±0.002</td></tr><tr><td rowspan=1 colspan=1>SCOFF + SW</td><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>0.487±0.085</td><td rowspan=1 colspan=1>0.059±0.0</td></tr><tr><td rowspan=1 colspan=1>SCOFF + SW</td><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>0.915±0.0</td><td rowspan=1 colspan=1>0.035±0.0</td></tr><tr><td rowspan=1 colspan=1>SCOFF +SW</td><td rowspan=1 colspan=1>8</td><td rowspan=1 colspan=1>0.891±0.001</td><td rowspan=1 colspan=1>0.039±0.0</td></tr><tr><td rowspan=1 colspan=1>SCOFF+ SW</td><td rowspan=1 colspan=1>10</td><td rowspan=1 colspan=1>0.351±0.001</td><td rowspan=1 colspan=1>0.08±0.0</td></tr></table>
|
| 117 |
+
|
| 118 |
+
Table 2: Here we show the performance of SCOFF augmented with shared workspace attention on the bouncing balls task. We also analyse the effect of varying number of slots in the shared workspace. This also shows that by increasing the number of slots performance decreases hence validating claims regarding bandwidth limited communication channel via shared workspace.
|
| 119 |
+
|
| 120 |
+
next-step prediction. We compare the proposed approach against SCOFF (Goyal et al., 2020). The results of our comparison are shown in Table 2. We use the ARI and MSE metric for comparison. ARI measures how well the different balls are segregated into different slots, higher ARI means better segregation. We can see that using a shared workspace results in higher ARI as compared to pairwise communication in SCOFF. Thus, using a shared workspace results in better division of labor among specialists. We also compare the proposed method against other baselines in appendix section F.1.
|
| 121 |
+
|
| 122 |
+
Shared Workspace for Atari Video Games. We start by training RIMs, RIMs $^ +$ shared workspace (SW) on three "source" games (Pong, River Raid, and Seaquest) and test if the learned features transfer to a different subset of randomly selected "target" games (Alien, Asterix, Boxing, Centipede, Gopher, Hero, James Bond, Krull, Robotank, Road Runner, Star Gunner, and Wizard of Wor). We take a sufficient number of specialists in RIMs (10). We train on source games for 10M steps, and then fine-tune on transfer games for 10M more steps. We choose these games as they were also used in the original RIMs paper (Goyal et al., 2019). Using a suite of 36 game pairs, we find that RIMs $+ \thinspace \mathrm { S W }$ outperforms RIMs on both game A (a median performance ratio of 1.13; mean of 1.16) and game B (a median performance ratio of 1.11; mean of 1.15). The improved performance with RIMs $^ +$ SW is due to better forward transfer (knowledge acquired for game A facilitates the learning of game B) and reduced backward interference (knowledge acquired for game B does not disrupt knowledge acquired for game A), presumably thanks to a more appropriate modularization of knowledge.
|
| 123 |
+
|
| 124 |
+
# 5 CONCLUSION
|
| 125 |
+
|
| 126 |
+
Inspired by cognitive neuroscience global workspace theories, we have proposed a shared workspace model for establishing coherence among modular neural specialists while exchanging information in a systematic way. We show that using a limited capacity shared workspace as a bottleneck for mediating communication among specialists results in better performance across a wide range of visual reasoning benchmarks as compared to the pairwise interactions typically used in self-attention schemes. The proposed approach combines several key properties: knowledge and expertise is divided among specialists, they compete to post new contents to the workspace, and after being updated, the shared workspace is accessible to all specialists for their own updates.
|
| 127 |
+
|
| 128 |
+
# ETHICS STATEMENT
|
| 129 |
+
|
| 130 |
+
The authors do not foresee any negative social impacts of this work, but of course the accumulation of improvements in ML could be misused as it may give more power to nefarious agents.
|
| 131 |
+
|
| 132 |
+
# REPRODUCIBILITY STATEMENT
|
| 133 |
+
|
| 134 |
+
We use Algorithms 1 and 2 for our experiments, we will be releasing the code after the review process.
|
| 135 |
+
We also provide our code in the supplementary material.
|
| 136 |
+
|
| 137 |
+
# REFERENCES
|
| 138 |
+
|
| 139 |
+
S. Ahmad and S. Omohundro. Equilateral triangles: A challenge for connectionist vision. 2009.
|
| 140 |
+
|
| 141 |
+
Jacob Andreas, Marcus Rohrbach, Trevor Darrell, and Dan Klein. Neural module networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 39–48, 2016.
|
| 142 |
+
|
| 143 |
+
Bernard J Baars. A cognitive theory of consciousness. Cambridge University Press, 1993.
|
| 144 |
+
|
| 145 |
+
Bernard J Baars. In the theatre of consciousness. global workspace theory, a rigorous scientific theory of consciousness. Journal of Consciousness Studies, 4(4):292–309, 1997.
|
| 146 |
+
|
| 147 |
+
Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. arXiv preprint arXiv:1409.0473, 2014.
|
| 148 |
+
|
| 149 |
+
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.
|
| 150 |
+
|
| 151 |
+
Léon Bottou and Patrick Gallinari. A framework for the cooperation of learning algorithms. In Advances in neural information processing systems, pages 781–788, 1991.
|
| 152 |
+
|
| 153 |
+
Valentino Braitenberg. Vehicles: Experiments in synthetic psychology. MIT press, 1986.
|
| 154 |
+
|
| 155 |
+
Rodney A Brooks. Intelligence without representation. Artificial intelligence, 47(1-3):139–159, 1991.
|
| 156 |
+
|
| 157 |
+
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.
|
| 158 |
+
|
| 159 |
+
Mikhail S Burtsev and Grigory V Sapunov. Memory transformer. arXiv preprint arXiv:2006.11527, 2020.
|
| 160 |
+
|
| 161 |
+
Rewon Child, Scott Gray, Alec Radford, and Ilya Sutskever. Generating long sequences with sparse transformers. arXiv preprint arXiv:1904.10509, 2019.
|
| 162 |
+
|
| 163 |
+
Michael D. Colagrosso and Michael C Mozer. Theories of access consciousness. In L. K. Saul, Y. Weiss, and L. Bottou, editors, Advances in Neural Information Processing Systems 17, pages 289–296. MIT Press, 2005. URL http://papers.nips.cc/paper/ 2715-theories-of-access-consciousness.pdf.
|
| 164 |
+
|
| 165 |
+
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.
|
| 166 |
+
|
| 167 |
+
S. Dehaene, H. Lau, and S. Kouider. What is consciousness, and could machines have it? Science, 358(6362):486–492, 2017.
|
| 168 |
+
|
| 169 |
+
Stanislas Dehaene and Jean-Pierre Changeux. Experimental and theoretical approaches to conscious processing. Neuron, 70(2):200–227, 2011.
|
| 170 |
+
|
| 171 |
+
Stanislas Dehaene, Michel Kerszberg, and Jean-Pierre Changeux. A neuronal model of a global workspace in effortful cognitive tasks. Proceedings of the national Academy of Sciences, 95(24): 14529–14534, 1998.
|
| 172 |
+
|
| 173 |
+
Mostafa Dehghani, Stephan Gouws, Oriol Vinyals, Jakob Uszkoreit, and Łukasz Kaiser. Universal transformers. arXiv preprint arXiv:1807.03819, 2018.
|
| 174 |
+
|
| 175 |
+
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.
|
| 176 |
+
|
| 177 |
+
Chrisantha Fernando, Dylan Banarse, Charles Blundell, Yori Zwols, David Ha, Andrei A Rusu, Alexander Pritzel, and Daan Wierstra. Pathnet: Evolution channels gradient descent in super neural networks. arXiv preprint arXiv:1701.08734, 2017.
|
| 178 |
+
|
| 179 |
+
Jerry A Fodor. The modularity of mind. MIT press, 1983.
|
| 180 |
+
|
| 181 |
+
Rohit Girdhar and Deva Ramanan. CATER: A diagnostic dataset for compositional actions and temporal reasoning. CoRR, abs/1910.04744, 2019. URL http://arxiv.org/abs/1910. 04744.
|
| 182 |
+
|
| 183 |
+
Anirudh Goyal and Yoshua Bengio. Inductive biases for deep learning of higher-level cognition. arXiv preprint arXiv:2011.15091, 2020.
|
| 184 |
+
|
| 185 |
+
Anirudh Goyal, Alex Lamb, Jordan Hoffmann, Shagun Sodhani, Sergey Levine, Yoshua Bengio, and Bernhard Schölkopf. Recurrent independent mechanisms. arXiv preprint arXiv:1909.10893, 2019.
|
| 186 |
+
|
| 187 |
+
Anirudh Goyal, Alex Lamb, Phanideep Gampa, Philippe Beaudoin, Sergey Levine, Charles Blundell, Yoshua Bengio, and Michael Mozer. Object files and schemata: Factorizing declarative and procedural knowledge in dynamical systems. arXiv preprint arXiv:2006.16225, 2020.
|
| 188 |
+
|
| 189 |
+
Alex Graves, Greg Wayne, and Ivo Danihelka. Neural turing machines. CoRR, abs/1410.5401, 2014. URL http://arxiv.org/abs/1410.5401.
|
| 190 |
+
|
| 191 |
+
Alex Graves, Greg Wayne, Malcolm Reynolds, Tim Harley, Ivo Danihelka, Agnieszka GrabskaBarwinska, Sergio Gómez Colmenarejo, Edward Grefenstette, Tiago Ramalho, John Agapiou, et al. ´ Hybrid computing using a neural network with dynamic external memory. Nature, 538(7626): 471–476, 2016.
|
| 192 |
+
|
| 193 |
+
Robert A Jacobs, Michael I Jordan, Steven J Nowlan, and Geoffrey E Hinton. Adaptive mixtures of local experts. Neural computation, 3(1):79–87, 1991.
|
| 194 |
+
|
| 195 |
+
Andrew Jaegle, Felix Gimeno, Andrew Brock, Andrew Zisserman, Oriol Vinyals, and Joao Carreira. Perceiver: General perception with iterative attention. arXiv preprint arXiv:2103.03206, 2021.
|
| 196 |
+
|
| 197 |
+
Andrej Karpathy. karpathy/mingpt, Aug 2020. URL https://github.com/karpathy/ minGPT.
|
| 198 |
+
|
| 199 |
+
Nan Rosemary Ke, Anirudh Goyal ALIAS PARTH GOYAL, Olexa Bilaniuk, Jonathan Binas, Michael C Mozer, Chris Pal, and Yoshua Bengio. Sparse attentive backtracking: Temporal credit assignment through reminding. In Advances in neural information processing systems, pages 7640–7651, 2018.
|
| 200 |
+
|
| 201 |
+
Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
|
| 202 |
+
|
| 203 |
+
Alex Lamb, Di He, Anirudh Goyal, Guolin Ke, Chien-Feng Liao, Mirco Ravanelli, and Yoshua Bengio. Transformers with competitive ensembles of independent mechanisms, 2021. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ 1TIrbngpW0x.
|
| 204 |
+
|
| 205 |
+
Juho Lee, Yoonho Lee, Jungtaek Kim, Adam Kosiorek, Seungjin Choi, and Yee Whye Teh. Set transformer: A framework for attention-based permutation-invariant neural networks. In International Conference on Machine Learning, pages 3744–3753, 2019.
|
| 206 |
+
|
| 207 |
+
Kanika Madan, Nan Rosemary Ke, Anirudh Goyal, Bernhard Schölkopf, and Yoshua Bengio. Meta attention networks: Meta-learning attention to modulate information between recurrent independent mechanisms. In International Conference on Learning Representations, 2021. URL https: //openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ Lc28QAB4ypz.
|
| 208 |
+
|
| 209 |
+
Marvin Minsky. Society of mind. Simon and Schuster, 1988.
|
| 210 |
+
|
| 211 |
+
Sarthak Mittal, Alex Lamb, Anirudh Goyal, Vikram Voleti, Murray Shanahan, Guillaume Lajoie, Michael Mozer, and Yoshua Bengio. Learning to combine top-down and bottom-up signals in recurrent neural networks with attention over modules. In International Conference on Machine Learning, pages 6972–6986. PMLR, 2020a.
|
| 212 |
+
|
| 213 |
+
Sarthak Mittal, Alex Lamb, Anirudh Goyal, Vikram Voleti, Murray Shanahan, Guillaume Lajoie, Michael Mozer, and Yoshua Bengio. Learning to combine top-down and bottom-up signals in recurrent neural networks with attention over modules. In International Conference on Machine Learning, pages 6972–6986. PMLR, 2020b.
|
| 214 |
+
|
| 215 |
+
Myle Ott, Sergey Edunov, Alexei Baevski, Angela Fan, Sam Gross, Nathan $\mathrm { N g }$ , David Grangier, and Michael Auli. fairseq: A fast, extensible toolkit for sequence modeling. In Proceedings of NAACL-HLT 2019: Demonstrations, 2019.
|
| 216 |
+
|
| 217 |
+
Niki Parmar, Ashish Vaswani, Jakob Uszkoreit, Lukasz Kaiser, Noam Shazeer, Alexander Ku, and Dustin Tran. Image transformer. In International Conference on Machine Learning, pages 4055–4064. PMLR, 2018.
|
| 218 |
+
|
| 219 |
+
Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9, 2019.
|
| 220 |
+
|
| 221 |
+
Jack W Rae, Anna Potapenko, Siddhant M Jayakumar, and Timothy P Lillicrap. Compressive transformers for long-range sequence modelling. arXiv preprint arXiv:1911.05507, 2019.
|
| 222 |
+
|
| 223 |
+
Nasim Rahaman, Anirudh Goyal, Muhammad Waleed Gondal, Manuel Wuthrich, Stefan Bauer, Yash Sharma, Yoshua Bengio, and Bernhard Schölkopf. S2rms: Spatially structured recurrent modules. arXiv preprint arXiv:2007.06533, 2020.
|
| 224 |
+
|
| 225 |
+
Scott Reed and Nando De Freitas. Neural programmer-interpreters. arXiv preprint arXiv:1511.06279, 2015.
|
| 226 |
+
|
| 227 |
+
Eric Ronco, Henrik Gollee, and Peter J Gawthrop. Modular neural networks and self-decomposition. Technical Report CSC-96012, 1997.
|
| 228 |
+
|
| 229 |
+
Clemens Rosenbaum, Tim Klinger, and Matthew Riemer. Routing networks: Adaptive selection of non-linear functions for multi-task learning. arXiv preprint arXiv:1711.01239, 2017.
|
| 230 |
+
|
| 231 |
+
Clemens Rosenbaum, Ignacio Cases, Matthew Riemer, and Tim Klinger. Routing networks and the challenges of modular and compositional computation. arXiv preprint arXiv:1904.12774, 2019.
|
| 232 |
+
|
| 233 |
+
Adam Santoro, David Raposo, David G Barrett, Mateusz Malinowski, Razvan Pascanu, Peter Battaglia, and Timothy Lillicrap. A simple neural network module for relational reasoning. In Advances in neural information processing systems, pages 4967–4976, 2017.
|
| 234 |
+
|
| 235 |
+
Adam Santoro, Ryan Faulkner, David Raposo, Jack Rae, Mike Chrzanowski, Theophane Weber, Daan Wierstra, Oriol Vinyals, Razvan Pascanu, and Timothy Lillicrap. Relational recurrent neural networks. In Advances in Neural Information Processing Systems, pages 7299–7310, 2018.
|
| 236 |
+
|
| 237 |
+
Murray Shanahan. A cognitive architecture that combines internal simulation with a global workspace. Consciousness and cognition, 15(2):433–449, 2006.
|
| 238 |
+
|
| 239 |
+
Murray Shanahan. Embodiment and the inner life: Cognition and Consciousness in the Space of Possible Minds. Oxford University Press, USA, 2010.
|
| 240 |
+
|
| 241 |
+
Murray Shanahan. The brain’s connective core and its role in animal cognition. Philosophical Transactions of the Royal Society B: Biological Sciences, 367(1603):2704–2714, 2012.
|
| 242 |
+
|
| 243 |
+
Murray Shanahan and Bernard Baars. Applying global workspace theory to the frame problem. Cognition, 98(2):157–176, 2005.
|
| 244 |
+
|
| 245 |
+
Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc Le, Geoffrey Hinton, and Jeff Dean. Outrageously large neural networks: The sparsely-gated mixture-of-experts layer. arXiv preprint arXiv:1701.06538, 2017.
|
| 246 |
+
|
| 247 |
+
Sjoerd Van Steenkiste, Michael Chang, Klaus Greff, and Jürgen Schmidhuber. Relational neural expectation maximization: Unsupervised discovery of objects and their interactions. arXiv preprint arXiv:1802.10353, 2018.
|
| 248 |
+
|
| 249 |
+
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, pages 5998–6008, 2017.
|
| 250 |
+
|
| 251 |
+
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.
|
| 252 |
+
|
| 253 |
+
# Part I
|
| 254 |
+
|
| 255 |
+
# Appendix
|
| 256 |
+
|
| 257 |
+
A PSEUDO CODES
|
| 258 |
+
|
| 259 |
+
Alg. 1 shows the integration of shared workspace with RIMs (Goyal et al., 2019). We replace the direct module to module interaction via attention in RIMs, with shared workspace. Specialists compete to write in the shared workspace, and the contents of the workspace are broadcasted to all the specialists.
|
| 260 |
+
|
| 261 |
+
Alg. 2 shows the integration of the shared workspace with TIMs (Lamb et al., 2021). Again we replace the direct module to module communication in TIMs, with a shared workspace.
|
| 262 |
+
|
| 263 |
+
# Algorithm 1: Shared Workspace integration with RIMs
|
| 264 |
+
|
| 265 |
+
Input: Current sequence element, $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ and previous state of the specialist, $\{ h _ { t - 1 , k } \}$ , for $k \in \{ 1 , \ldots , n _ { s } \}$ and structure of memory as a matrix $M$ with row wise compartmentalized memories, where $m _ { i }$ refers to the state of slot $_ { i }$ (total number of slots is $n _ { m }$ ).
|
| 266 |
+
|
| 267 |
+
Step 1: Process image by position $p$ with fully convolutional net • $\pmb { c } _ { p } = [ \mathrm { C N N } ( \pmb { x } _ { t } ) ] _ { p }$ • $\boldsymbol { z } _ { t } = [ c _ { p } \boldsymbol { e } _ { p } ]$ (concatenate encoding of position to CNN output)
|
| 268 |
+
|
| 269 |
+
Step 2: Specialists compete to be selected to update the workspace based on current input
|
| 270 |
+
• qk = ht−1,kW q
|
| 271 |
+
• $\begin{array} { r } { s _ { k } = \operatorname { s o f t m a x } \left( \frac { q _ { k } \kappa } { \sqrt { d _ { e } } } \right) } \end{array}$ , where $\pmb { \kappa } = ( z _ { t } \pmb { W } ^ { e } ) ^ { \mathrm { T } }$
|
| 272 |
+
• Construct a set $\dot { \mathcal { F } } _ { t }$ which contains the indices of the $n _ { \mathrm { s e l } }$ specialists that have the largest $s _ { k }$ $\bar { \boldsymbol { h } } _ { t , k } = \left\{ \begin{array} { l l } { g _ { k } \left( \boldsymbol { s } _ { k } \boldsymbol { z } _ { t } \boldsymbol { W } ^ { v } , \boldsymbol { h } _ { t - 1 , k } \right) \quad } & { k \in \mathcal { F } _ { t } , } \\ { \boldsymbol { h } _ { t - 1 , k } \quad } & { k \notin \mathcal { F } _ { t } , } \end{array} \right.$
|
| 273 |
+
• $\pmb { a } _ { k } = s _ { k } z _ { t } W ^ { v } \forall k \in \mathcal { F } _ { t }$ (Scaled Dot Product Attention)
|
| 274 |
+
Step 3: Activated specialists write in a shared workspace
|
| 275 |
+
• $\widetilde { Q } = M \widetilde { W } ^ { q }$
|
| 276 |
+
• $\pmb { R } = [ M ; \pmb { A } ]$ where $\pmb { A }$ is the matrix whose rows are the ${ \pmb a } _ { k } \forall k \in \mathcal { F } _ { t }$
|
| 277 |
+
• $\begin{array} { r } { M \gets \operatorname { s o f t m a x } \left( \frac { \widetilde { Q } ( R \widetilde { W } ^ { e } ) ^ { \mathrm { T } } } { \sqrt { d _ { e } } } \right) R \widetilde { W } ^ { v } } \end{array}$
|
| 278 |
+
|
| 279 |
+
# Step 4: Broadcast of information from the shared workspac
|
| 280 |
+
|
| 281 |
+
$$
|
| 282 |
+
\begin{array} { r l } & { \widehat { \widehat { q } } _ { k } = \widehat { h } _ { t , k } \widehat { W } ^ { q } \quad \forall k \in \{ 1 , \ldots , \widehat { n } _ { s } \} } \\ & { s _ { k , j } = \operatorname { s o f t m a x } \left( \frac { \widehat { q } _ { k } \widehat { \kappa } _ { j } } { \sqrt { d _ { e } } } \right) \mathrm { ~ w h e r e ~ } \widehat { \kappa } _ { j } = ( m _ { j } \widehat { W } ^ { e } ) ^ { \mathrm { T } } \quad \forall k \in \{ 1 , \ldots , n _ { s } \} , j \in \{ 1 , \ldots , n _ { m } \} } \\ & { h _ { t , k } = \widehat { h } _ { t , k } + \sum _ { j } s _ { k , j } \widehat { v } _ { j } \mathrm { ~ w h e r e ~ } \widehat { v } _ { j } = m _ { j } \widehat { W } ^ { v } \quad \forall k \in \{ 1 , \ldots , n _ { s } \} } \end{array}
|
| 283 |
+
$$
|
| 284 |
+
|
| 285 |
+
# B HYPERPARAMETERS
|
| 286 |
+
|
| 287 |
+
Table 3 lists the different hyper-parameters.
|
| 288 |
+
|
| 289 |
+
# Parameters in RIMs+SW:
|
| 290 |
+
|
| 291 |
+
RIMs with shared workspace has three set of parameters:
|
| 292 |
+
|
| 293 |
+
• Parameters corresponding to Input attention Parameters for the attention for the $k$ -th specialist $\theta _ { k } = ( W _ { k } ^ { \bar { q } } , W ^ { e } , \bar { W } ^ { v } )$ corresponding to query, keys, and values respectively. Each specialist has different query parameters but share the same keys and values (which are function of the input). In the table it corresponds to the inp keys, inp values, inp heads respectively.
|
| 294 |
+
|
| 295 |
+
• Writing in a shared workspace: Parameters corresponding to the writing in the memory. Here, we follow the similar mechanisms as in RMC(Santoro et al., 2018), where shared
|
| 296 |
+
|
| 297 |
+
# Algorithm 2: Shared Workspace integration with TIMs
|
| 298 |
+
|
| 299 |
+
Notation: Consider $\pmb { h } _ { l }$ as the output of the ${ l ^ { t h } }$ transformer layer. Let sequence length of original input be $T$ and embedding dimension of transformer be $D$ . Let the transformer be composed of $n _ { b }$ mechanisms and memory be denoted as a matrix $M$ with row wise compartmentalized memories, where $m _ { i }$ refers to the state of slot $_ { i }$ (total number of slots is $n _ { m }$ ). Consider $\begin{array} { r } { { h } _ { l } ^ { k } = { \bf \dot { h } } _ { l } [ : } \end{array}$ , $( k - 1 ) D / n _ { b } : k D / n _ { b } ]$ to be the hidden state of mechanism indexed $k$ at layer $l$ .
|
| 300 |
+
|
| 301 |
+
Initialization: Convert the raw input $X \in \mathbb { R } ^ { T \times v o c a b \_ s i z e }$ to
|
| 302 |
+
$h _ { 0 } = .$ positional_encodin $\jmath + \bar { E } m b e d d i n g ( X )$ where $\pmb { h } _ { 0 } \in \mathbb { R } ^ { T \times D }$ . Initialize memory matrix $M$ which remains common for all layers in the transformer.
|
| 303 |
+
|
| 304 |
+
Input to the layer l: $\pmb { h } _ { l - 1 }$ having shape $\mathbb { R } ^ { T \times D }$
|
| 305 |
+
|
| 306 |
+
# Step 1: Mechanisms compete to be selected to update the workspace based on the input they receive from the previous layer
|
| 307 |
+
|
| 308 |
+
• W c ∈ RD/nb×1• $c _ { k } = { \pmb h } _ { l - 1 } ^ { k } W _ { k } ^ { c } \quad \forall k \in \{ 1 , \dots , n _ { b } \}$ • $c = s o f t m a x ( c o n c a t ( c _ { 1 } , . . , c _ { n _ { b } } ) )$ , $\boldsymbol { c } \in \mathbb { R } ^ { T \times n _ { b } }$
|
| 309 |
+
|
| 310 |
+
• For each time step $t$ in the original sequence of length $T$ , we use the soft score $c$ to select the top $n _ { s e l }$ mechanisms which would self-attend and write to the memory. Hence generating set $\mathcal { F } _ { t }$ which stores the indices of $n _ { s e l }$ mechanisms for position $t \in \{ 1 , 2 , . . . , T \}$ . Also construct $\boldsymbol { c } _ { k } ^ { * } \in \mathbb { R } ^ { T \times D / n _ { b } }$ where
|
| 311 |
+
|
| 312 |
+
$$
|
| 313 |
+
c _ { k } ^ { * } [ t , : ] = \left\{ { c [ t ] [ k ] } \atop { 0 \quad k \notin \mathcal { F } _ { t } , } \right.
|
| 314 |
+
$$
|
| 315 |
+
|
| 316 |
+
Step 2: Selected mechanisms self-attend and update their hidden state $\bullet \ : \dot { r e s i d u a l _ { k } } = { \pmb h } _ { l - 1 } ^ { k }$ • $\bar { h } _ { l } ^ { k } = c _ { k } ^ { * } \odot S e l f A t t e n t i o n ( h _ { l - 1 } ^ { k } ) + r e s i d u a l _ { k } \quad \forall k \in \{ 1 , \ldots , n _ { b } \}$
|
| 317 |
+
|
| 318 |
+
# Step 3: Selected mechanisms write on the shared workspace
|
| 319 |
+
|
| 320 |
+
• Memory matrix $M$ was last modified by mechanisms of layer $l - 1$
|
| 321 |
+
• Let $\mathbf { \Delta } _ { a _ { k } } \dot { = } c _ { k } ^ { * } \odot \bar { h } _ { l } ^ { k }$ and $\mathbf { a } = c o n c a t ( \mathbf { a } _ { 1 } , . . , \mathbf { a } _ { n _ { b } } )$ . Absorb the first dimension (corresponding to position in the sequence) in the batch dimension by reshaping $\textbf { \em a }$ . Perform the same steps as in algorithm 1.
|
| 322 |
+
• $\widetilde { Q } = M \widetilde { W } ^ { q }$
|
| 323 |
+
• $\pmb { R } = [ M ; \pmb { A } ]$ where $\pmb { A } = \pmb { a } \pmb { W } ^ { v }$
|
| 324 |
+
• $\begin{array} { r } { M \gets \operatorname { s o f t m a x } \left( \frac { { \widetilde Q } ( R \widetilde W ^ { e } ) ^ { \mathrm { T } } } { \sqrt { d _ { e } } } \right) R \widetilde W ^ { v } } \end{array}$
|
| 325 |
+
|
| 326 |
+
# Step 4: Broadcast of information from the shared workspace
|
| 327 |
+
|
| 328 |
+
• Reshape the new memory to bring back the sequence dimension. Perform the same steps as in algorithm 1. • $\widehat { \pmb q } _ { k } = \dot { \bar { \pmb h } } _ { l } ^ { k } \widehat { \pmb W } ^ { q } \quad \forall k \in \{ 1 , \dots , n _ { b } \}$
|
| 329 |
+
• $\begin{array} { r } { s _ { k , j } = \mathrm { s o f t m a x } \left( \frac { \widehat { q } _ { k } \widehat { \kappa } _ { j } } { \sqrt { d _ { e } } } \right) } \end{array}$ where $\widehat { \kappa } _ { j } = ( m _ { j } \widehat { W } ^ { e } ) ^ { \mathrm { T } } \quad \forall k \in \{ 1 , \ldots , n _ { b } \} , \ j \in \{ 1 , \ldots , n _ { m } \}$
|
| 330 |
+
• $\begin{array} { r } { \pmb { h } _ { l } ^ { k } = \pmb { \bar { h } } _ { l } ^ { k } + \sum _ { j } s _ { k , j } \pmb { \widehat { v } } _ { j } } \end{array}$ where $\widehat { \pmb { v } } _ { j } = { \pmb { m } } _ { j } \widehat { \pmb { W } } ^ { v } \quad \forall k \in \{ 1 , \dots , n _ { b } \}$
|
| 331 |
+
|
| 332 |
+

|
| 333 |
+
Figure 6: A demonstration of the detecting equilateral triangles task.
|
| 334 |
+
|
| 335 |
+
Table 3: Generic Hyperparameters for the proposed model (for RIMs)
|
| 336 |
+
|
| 337 |
+
<table><tr><td>Parameter</td><td>Value 6</td></tr><tr><td>Number of specialists (ns) Size of each specialist Number of memory slots (nm)</td><td>85</td></tr><tr><td>Optimizer learning rate</td><td>Adam(Kingma and Ba, 2014) 1:10-4</td></tr><tr><td>batch size</td><td>64</td></tr><tr><td>Inp keys</td><td>64</td></tr><tr><td>Inp Values</td><td>85</td></tr><tr><td>Inp Heads</td><td>4</td></tr><tr><td>Inp Dropout</td><td>0.1</td></tr><tr><td>Number of memory slots</td><td>4</td></tr><tr><td>Number of memory heads</td><td></td></tr><tr><td></td><td>1</td></tr><tr><td>Size of attention head</td><td>32</td></tr><tr><td>Key size</td><td>32</td></tr><tr><td>Number of MLP layers in Attention</td><td>3</td></tr><tr><td>Gate Style</td><td>'unit’</td></tr><tr><td>Memory Attention Heads</td><td>4</td></tr><tr><td>Memory Attention keys</td><td>32</td></tr><tr><td></td><td>32</td></tr><tr><td>Memory Attention Values</td><td></td></tr></table>
|
| 338 |
+
|
| 339 |
+
workspace is seen as a Matrix with row wise compartmentalized memories (i.e slots) i.e $\widetilde { W } ^ { q }$ , $\hat { \overline { { W } } } ^ { e }$ , $\widetilde { W } ^ { v }$ . In the table it corresponds to number of memory slots, number of memory heads, size of attention head, key size and number of mlp layers in attention. These are the same hyper-paramter as in RMC (Santoro et al., 2018). We tried two different set of hyper-parameters (a) where we only have a single slot and (b) where we have 4 slots.
|
| 340 |
+
|
| 341 |
+
• Broadcast of Information from the shared workspace: In this process, the information in the workspace gets broadcasted to all the specialists such that each specialist produces a query, and the keys and values are a function of the memory state. Each specialist gets information from the memory according to its query, and this information is used to update the state of each specialist in a residual fashion. This corresponds to the parameters of $\widehat { W } ^ { v }$ , $\widehat { W } ^ { q }$ , $\widehat { W } ^ { e }$ in the table i.e memory attention heads, memory attention keys, and memory attention values. We did not do any hyper-parameter search for these hyper-parameters.
|
| 342 |
+
|
| 343 |
+
# Resources Used:
|
| 344 |
+
|
| 345 |
+
• For vision tasks like Sort-of-clever, Equilateral triangle, CIFAR classification, it takes about 6 hours to run 200 epochs on V100 (32G) GPU.
|
| 346 |
+
|
| 347 |
+
• It takes about 2 days to train the proposed model on bouncing ball task for 100 epochs on V100 (32G) GPU. We did not do any hyper-parameter search specific to a particular dataset (i.e 4Balls or 678Balls or Curtain Task). We ran the proposed model for different number of memory slots (i.e 2/4/8) for all the different datasets.
|
| 348 |
+
|
| 349 |
+
• For Starcraft task, it takes about 5 days to train on V100 (16G) GPU with batch size of 4.
|
| 350 |
+
|
| 351 |
+
# C IMPLEMENTATION DETAILS
|
| 352 |
+
|
| 353 |
+
Writing Information in the shared workspace. While writing information to the shared workspace, we update the workspace using a gating mechanism as proposed in Santoro et al. (2018). The gating mechanism consists of input and forget gates. Let $\bar { M } ^ { t - 1 }$ and $M ^ { t }$ be the previous and updated memory matrix respectively. Let $M$ be the result of the attention mechanism as described in step 2 of section 2.1. Let $X _ { 1 \dots n _ { s } }$ be the input to $n _ { s }$ specialists. The gating mechanism can be formulated as follows.
|
| 354 |
+
|
| 355 |
+
$$
|
| 356 |
+
\begin{array} { l } { { \displaystyle \bar { X } = \frac { 1 } { n _ { s } } \sum _ { i = 1 } ^ { n _ { s } } \mathrm { r e l u } ( X _ { i } \times W ^ { 1 } ) } \ ~ } \\ { { \displaystyle K = \bar { X } + \mathrm { t a n h } ( M ^ { t - 1 } ) } \ ~ } \\ { { \displaystyle I = \mathrm { s i g m o i d } ( K W ^ { I } ) } \ ~ } \\ { { \displaystyle F = \mathrm { s i g m o i d } ( K W ^ { F } ) } \ ~ } \\ { { \displaystyle M ^ { t } = I \times \mathrm { t a n h } ( M ) + F \times M ^ { t - 1 } } } \end{array}
|
| 357 |
+
$$
|
| 358 |
+
|
| 359 |
+
Here, $\pmb { I }$ and $\pmb { F }$ indicate the input and forget gates respectively. Note that $W ^ { 1 }$ is shared across all $n _ { s }$ specialists.
|
| 360 |
+
|
| 361 |
+
# D PROPERTIES OF SHARED WORKSPACE
|
| 362 |
+
|
| 363 |
+
In section 2, we claim that higher-order interaction terms and effects due to persistence of memory are key contributors to Shared Workspace performance. We support those claims here:
|
| 364 |
+
|
| 365 |
+
Shared Workspace vs repeated self attention Higher-order interaction can be simulated by repeating the self-attention step multiple times at the same layer/time-step. However, due to the absence of a global communication channel, there is no constraint that the messages passed among the neural modules should lie in the same representation space. We modify a standard transformer where we repeat the self-attention step two times in every layer. We expect that $2 \times \mathrm { S e l f }$ Attention will perform worse than SW. We also run a model where both self-attention as well as shared workspace is used by the transformer to update its state.
|
| 366 |
+
|
| 367 |
+
Persistence of Memory To check whether persistence is crucial for our model to perform well, we run a model where we re-initialize the shared workspace at every layer. Again we expect that removing memory persistence should result in a drop in performance and speed of convergence.
|
| 368 |
+
|
| 369 |
+
We run these models on sort-of-clevr dataset and present the results in figure 7
|
| 370 |
+
|
| 371 |
+
We note that removing persistence of memory results in significantly slower convergence. Replacing SW with $2 \times \mathbf { S } \mathbf { A }$ results in a significant drop in performance.
|
| 372 |
+
|
| 373 |
+

|
| 374 |
+
Figure 7: Comparison on Sort-of-CLEVR relational reasoning. Speed of convergence for relational and non-relational questions in the sort-of-clevr dataset. We can see that the Shared Workspace model converges faster and generalizes better as compared to all the other models. Here SW refers to shared workspace, $2 \times \mathbf { S } \mathbf { A }$ refers to applying self-attention twice in the same layer, $\mathrm { S W } { + } \mathrm { S A }$ refers using both Shared Workspace and Self Attention in each transformer layer.
|
| 375 |
+
|
| 376 |
+
# Relationalquestions:
|
| 377 |
+
|
| 378 |
+
1.What is the shape ofthe object closest to the red object $2 \Rightarrow$ square
|
| 379 |
+
2.What isthe shape of theobject furthest totheorange object $\wr \Rightarrow$ circle
|
| 380 |
+
3.How many objects have same shape with the blue object?=3
|
| 381 |
+
|
| 382 |
+

|
| 383 |
+
|
| 384 |
+
# Non-relational questions:
|
| 385 |
+
|
| 386 |
+
1.What is the shape of the red object $\Rightarrow$ Circle
|
| 387 |
+
2.Is green object placed on the left side of the image?⇒yes
|
| 388 |
+
3.Is orange object placed on the upside of the image?= no
|
| 389 |
+
|
| 390 |
+
Figure 8: A sample from the sort-of-clevr dataset.
|
| 391 |
+
|
| 392 |
+
# E TRANSFORMER TASKS
|
| 393 |
+
|
| 394 |
+
# E.1 DETECTING EQUILATERAL TRIANGLES
|
| 395 |
+
|
| 396 |
+
A demonstration of this task can be found in figure 6. We use images of size $6 4 \times 6 4$ for this task. Our training dataset consists of 50000 examples and we evaluate on 10000 examples. We follow the same setup as vision transformers Dosovitskiy et al. (2020) for this task. We divide the image into patches of size $4 \times 4$ , this sequence of patches is fed as input to a 4-layered transformer along with the CLS token which is used for classification. We set hidden dim to 256 and ffn dim to 512. For the proposed model $\mathrm { T R } { + } { \cal S } { \cal S } { \cal W } _ { ; }$ , $\mathrm { T R } { + } \mathrm { H S W }$ ), We use a query and key size of 32, and value size of 64. We use 4 heads during reading from and writing into the shared workspace which consist of 8 memory slots. For the baseline models (TR, $\mathrm { T R } + \mathrm { H C }$ , STR), we use query, key and value size of 64 and 4 heads. For training, we use a batch size of 64. We train the model for 200 epochs using Adam optimizer with a learning rate of 0.0001. We anneal the learning rate using cosine annealing.
|
| 397 |
+
|
| 398 |
+
# E.2 SORT-OF-CLEVR
|
| 399 |
+
|
| 400 |
+
Figure 8 shows a sample from this dataset. The images in this dataset are of size $7 5 \times 7 5$ . Each question is encoded into 11 bits. The first 6 bits indicate color, the next 2 bits indicate question type (relational or non-relational), and the remaining 3 bits indicate question subtype (according to figure 8). We use a 4-layered transformer for this task with hidden dim set to 256 and ffn dim set to 512. For the proposed model $\mathrm { T R } { + } \mathrm { S S W } _ { \mathrm { \Omega } }$ , $\mathrm { T R } { + } \mathrm { H S W }$ ), We use a query and key size of 32, and value size of 64. We use 4 heads during reading from and writing into the shared workspace which consists of 8 memory slots. For the baseline models (TR, $\mathrm { T R } + \mathrm { H C }$ , STR), we use query, key and value size of 64 and 4 heads. We encode the 11 bit question into a 256 dimensional vector representation and concatenate it with the sequence of $1 5 \times 1 5$ sized patched obtained from the image.
|
| 401 |
+
|
| 402 |
+
We use the representation corresponding to the CLS token for classification. We train the model using cross-entropy loss. We use a batch size of 64 and train the model for 100 epochs. We use Adam optimizer with a learning rate of 0.0001 for training.
|
| 403 |
+
|
| 404 |
+
# E.3 CATER: OBJECT TRACKING
|
| 405 |
+
|
| 406 |
+
Each CATER video consists of about 300 frames of size $2 2 4 \times 2 2 4$ . We first sample frames at a sampling rate of 6 which results in 50 frames. From these 50 frames, we stack 5 consecutive frames together and pass each stack through a 18 layered resnet. The corresponding sequence of 10 frames is passed as input to the transformer. This task is setup as a classification task where we have to predict which cell in the $6 \times 6$ grid contains the snitch in the final frame. We use a 6-layered transformer with hidden dim set to 512 and ffn dim set to 2048. For the proposed model $\mathrm { T R } { + } \mathrm { S S W }$ , $\mathrm { T R + H S W }$ ), We use a query and key size of 32, and value size of 64. We use 8 heads during reading from and writing into the shared workspace which consists of 8 memory slots. For the baseline models (TR, $\mathrm { T R } + \mathrm { H C }$ , STR), we use query, key and value size of 64 and 8 heads.
|
| 407 |
+
|
| 408 |
+
# F RIMS TASKS
|
| 409 |
+
|
| 410 |
+
# F.1 BOUNCING BALL
|
| 411 |
+
|
| 412 |
+
The dataset consists of 50,000 training examples and 10,000 test examples showing ${ \sim } 5 0$ frames of either 4 solid balls bouncing in a confined square geometry (4Balls), 6-8 balls bouncing in a confined geometry (678Balls), 3 balls bouncing in a confined geometry with an occluded region (Curtain), or balls of different colors (Colored 4Balls) and (Colored 678Balls). We train baselines as well as the proposed shared workspace extension (e.g., RIMs $+ \ S \mathbf { W } _ { \mathbf { \alpha } }$ ). As shown in Fig. 9, we study the performance of the proposed model compared with LSTM, RIMs and RMC. The first 10 frames of ground truth are fed in and then the system is rolled out for the next 35 time steps. During the rollout phase, the proposed method performs better than the baselines in accurately predicting the dynamics of the balls as reflected by cross entropy (CE).
|
| 413 |
+
|
| 414 |
+
We trained baselines as well as proposed model for about 100 epochs. We use the same architecture for encoder as well as decoder as in (Van Steenkiste et al., 2018). Hyper-parameters specific to the proposed architecture are listed in Tab. 3.
|
| 415 |
+
|
| 416 |
+

|
| 417 |
+
Figure 9: Bouncing ball motion: Prediction error comparison of the proposed method, LSTM, RIMs and RMC baseline. Given 10 frames of ground truth, the model predicts the rollout over the next 35 steps. Here, we present the BCE for the 30th frame and $4 5 \mathrm { t h }$ frame. The proposed SW extension performs better than other baselines in accurately predicting the dynamics, with an increasing advantage as the number of unrolled steps (30 vs 45) and balls ((a) vs (b)) increases. Results are an average over 5 random seeds.
|
| 418 |
+
|
| 419 |
+
# G INTEGRATING SW WITH MORE ARCHITECTURES
|
| 420 |
+
|
| 421 |
+
# G.1 TIMS
|
| 422 |
+
|
| 423 |
+
TIMs was proposed by Lamb et al. (2021). A transformer network is divided into ‘independent mechanisms’ which update their state via sharing information between positions and sharing information between mechanisms. The information sharing step between mechanisms can be replaced by SW to create TIMs $+ \mathbf { S } \mathbf { W } .$ .
|
| 424 |
+
|
| 425 |
+
# G.1.1 MULTIMNIST GENERATION
|
| 426 |
+
|
| 427 |
+
In this task, we train an Image Transformer Parmar et al. (2018) (pixel-by-pixel, raster-order generative model) for next pixel prediction task on the “MultiMNIST dataset”
|
| 428 |
+
|
| 429 |
+
Table 4: Hyperparameters for MultiMNIST Task
|
| 430 |
+
|
| 431 |
+
<table><tr><td>Parameter</td><td>Value</td></tr><tr><td>Common Parameters</td><td></td></tr><tr><td>Optimizer</td><td>Adam(Kingma and Ba, 2014)</td></tr><tr><td>Learning rate</td><td>1:10-3 12</td></tr><tr><td>Batch size</td><td>8</td></tr><tr><td>Number of attention heads</td><td></td></tr><tr><td>TR</td><td></td></tr><tr><td>Size of transformer layer</td><td>256</td></tr><tr><td>TIMs</td><td></td></tr><tr><td>Number of mechanisms Size of mechanism</td><td>4 48</td></tr><tr><td></td><td></td></tr><tr><td>TIMs+SW</td><td></td></tr><tr><td>Number of mechanisms</td><td>4 40</td></tr><tr><td>Size of mechanism</td><td>2</td></tr><tr><td>Number of memory slots</td><td>160</td></tr><tr><td>Size of memory slots Memory Attention Heads</td><td>8</td></tr><tr><td>Gate Style</td><td></td></tr><tr><td></td><td>'unit'</td></tr><tr><td>Number of MLP layers in Attention</td><td>2</td></tr></table>
|
| 432 |
+
|
| 433 |
+
Each $3 2 \times 3 2$ image in this dataset is made up of four randomly selected (and augmented) MNIST digits (resized to $3 2 \times 8 \time 1 0 \mathrm { \Omega }$ ) placed side-by-side as shown in figure 10. The digits themselves are selected independently of one-another.
|
| 434 |
+
|
| 435 |
+
The main aim of creating such a task is to observe the working of independent mechanisms in architectures such as TIMs (Lamb et al., 2021). Each image in the MultiMNIST dataset can be broken down into different sets of independent spatial components. Since the digits which make up the image are independently selected, the joint distribution of pixel intensities in any one of the four sections of the image is statistically independent of the pixel intensities in any other section of the image. Moreover each section of the image can be further broken down into independent spatial components: one that pertains to the background and one that pertains to the foreground.
|
| 436 |
+
|
| 437 |
+
It is expected that a monolithic architecture (having a single computational unit) would have to devote a significant portion of its training to learn the statistical independence between the different constituents of the image. On the other hand, architectures made up of sparsely interacting independent mechanisms have a natural way of capturing such statistical independence. A division of labour where each mechanism is focused on the generation of a distinct independent constituent of the image should allow for better generalization on the test set. Once the generation of a constituent is completed, the task can be handed over to some other mechanism based on current position in the image.
|
| 438 |
+
|
| 439 |
+
For this experiment we train a standard transformer with shared parameters across all layers (denoted by TR), TIMs (Lamb et al., 2021) with 4 mechanisms, and a modified version of TIMs with 4 mechanisms where the pair-wise communication between the mechanisms is replaced by communication via a shared workspace (denoted by $\mathrm { T I M s } { + } \mathrm { S W } )$ .
|
| 440 |
+
|
| 441 |
+
Training. We follow the minGPT Image Transformer setup Karpathy (2020) for our experiments. All three of the configurations have 8 layers, 8 heads for multi-headed attention and use the exact same parameter initialization and base architecture. We train all three of the models for 20 epochs.
|
| 442 |
+
|
| 443 |
+
In the TR model, all of the 8 monolithic layers share the same set of parameters. In TIMs and $\mathrm { T I M s } { + } \mathrm { S W } ,$ , the first two layers are the standard monolithic layers having shared parameters. The middle four layers in both of these architectures are modular layers with four mechanisms. These four
|
| 444 |
+
|
| 445 |
+
<table><tr><td>Model</td><td>Loss</td></tr><tr><td>TR</td><td>0.000058</td></tr><tr><td>TIMs (4 mechanisms)</td><td>0.000050</td></tr><tr><td>TIMs+SW (4 mechanisms)</td><td>0.000042</td></tr></table>
|
| 446 |
+
|
| 447 |
+
Table 5: MultiMNIST Generation Task: We report cross-entropy loss between the generated pixel values and the true pixel values on the test set of MultiMNIST Generation Task (smaller numbers are better)
|
| 448 |
+
|
| 449 |
+

|
| 450 |
+
Figure 10: A randomly selected batch of 16 images from the MultiMNIST generation dataset (4 rows and 4 columns)
|
| 451 |
+
|
| 452 |
+
layers share the same set of parameters. In the case of $\mathrm { T I M s } { + } { \cal { S } } \mathrm { W } ,$ the four mechanisms in these layers communicate via a shared workspace (having 2 memory slots). This shared workspace is common for all four middles layers and is absent in TIMs where the mechanisms communicate via pair-wise competition as proposed in the original paper. TIMs and $\mathrm { T I M s } { + } \mathrm { S W }$ architectures are concluded by two more monolithic layers which again share the same parameters.
|
| 453 |
+
|
| 454 |
+
For all three models to have comparable number of parameters, we chose the transformer embedding dimension to be 256 for TR model, 192 for TIMs model and 160 for $\mathrm { T I M s } { + } \mathrm { S W }$ model. In TIMs and $\mathrm { T I M s } { + } \mathrm { S W } ,$ the embedding dimension is divided equally among the four specialists. Each memory slot in the shared workspace of the $\mathrm { T I M s } { + } \mathrm { S W }$ model has a 160 dimensional embedding and the model uses four heads to perform read and write operations on the shared workspace. Total number of parameters for all three architectures lie between 1M and 1.8M.
|
| 455 |
+
|
| 456 |
+
Results. We observe the best cross-entropy loss in 20 epochs on the test set of the MultiMNIST dataset for the next pixel prediction task in the table 5. We further plot the sixth layer “mechanism activation score” of TIMs and $\mathrm { T I M s } { + } S \mathrm { W }$ while generating the first four images of the test set in the best epoch (shown in figure 5).
|
| 457 |
+
|
| 458 |
+
# G.1.2 USING WORKSPACE FOR LANGUAGE MODELLING
|
| 459 |
+
|
| 460 |
+
We train our models on the WikiText-103 dataset by posing a language modeling problem. The dataset is divided into train, test and validation sets which are composed out of 28,475, 60 and 60 articles respectively. The total number of tokens in the train set is more than 103 million, hence the name of the dataset. This dataset retains numbers, punctuation and case.
|
| 461 |
+
|
| 462 |
+
Training. We train our models for 15 epochs for the next word prediction task on the WikiText-103 dataset and report the perplexity on the validation set. We show the results using TIMs (Lamb et al., 2021) with 4 mechanisms and TIMs $+ \mathbf { S } \mathbf { W }$ with 4 mechanisms (where we replace the pairwise communication in TIMs with communication via a shared workspace like in the MultiMNIST experiment). We modify the FAIRSEQ Ott et al. (2019) transformer language model class for all of our experiments.
|
| 463 |
+
|
| 464 |
+
For $\mathrm { T I M s } { + } \mathrm { S W }$ , we train and test two different variants: TIMs+SSW uses soft attention to generate the activation scores of competing independent mechanisms whereas TIMs+HSW uses top-k attention with ${ \bf k } = 2$ .
|
| 465 |
+
|
| 466 |
+
Since in this test, our aim is to compare the performance of the two models for the language modeling task, the architectures are only made up of a transformer decoder. In both of the models, there are 8 transformer decoder layers divided into 3 sets. The first 2 layers are standard monolithic decoder layers which share the same parameters. The next 4 layers are modular layers (TIMs layers or $\mathrm { T I M s } { + } \mathrm { S W }$ layers depending on the model choice). These layers also share the same parameters among themselves. The last 2 layers are again standard monolothic decoder layers, both sharing the same parameters.
|
| 467 |
+
|
| 468 |
+
The inputs to the network are 1024 dimensional word embeddings, input to a transformer layer of dimension 1024 and feed forward dimension of 2048.
|
| 469 |
+
|
| 470 |
+
Both of the networks have 8 attention heads with head dimension of 128. The total transformer layer size of $8 \times 1 2 8 = 1 0 2 4$ is equally divided among the four mechanisms. In the case of TIMs, these mechanisms (in layers 3,4,5) interact via pair-wise communication, whereas in TIMs+SSW and TIMs $+ \mathrm { H S W }$ , these mechanisms interact via a shared workspace. The shared workspace has 2 memory slots, each 1024 dimensional, having 4 attention heads for reading and writing.
|
| 471 |
+
|
| 472 |
+
Table 6: Hyperparameters for WikiText-103 Language Modeling Task
|
| 473 |
+
|
| 474 |
+
<table><tr><td>Parameter Value</td></tr><tr><td>Common Parameters</td></tr><tr><td>Optimizer Adam(Kingma and Ba, 2014)</td></tr><tr><td>Learning rate 5:10-4</td></tr><tr><td>Adam betas 0.99, 0.98</td></tr><tr><td>Weight decay</td></tr><tr><td>0.01 lr scheduler ‘inverse square root'</td></tr><tr><td>Max tokens per gpu 3078</td></tr><tr><td>Batch size multiple 8 8</td></tr><tr><td>Number of attention heads</td></tr><tr><td>Transformer layer size 1024</td></tr><tr><td>Number of Mechanisms</td></tr><tr><td>Update frequency</td></tr><tr><td>Number of warmup updates 4000</td></tr><tr><td>Starting Warmup lr 1·10-7</td></tr><tr><td>TIMs+SSW</td></tr><tr><td>Number of memory slots 2 1024 4</td></tr><tr><td>Size of memory slots</td></tr><tr><td>Memory Attention Heads 'unit'</td></tr><tr><td>Gate Style</td></tr><tr><td>Number of MLP layers in Attention 3 False</td></tr><tr><td>top-k competition</td></tr><tr><td>TIMs+HSW</td></tr><tr><td>Number of memory slots 2</td></tr><tr><td>Size of memory slots 1024</td></tr><tr><td>Memory Attention Heads</td></tr><tr><td>4 Gate Style 'unit'</td></tr><tr><td>Number of MLP layers in Attention 3</td></tr><tr><td>top-k competition True, k=2</td></tr></table>
|
| 475 |
+
|
| 476 |
+
Results. We plot the perplexity (per epoch) on the validation set. All models have comparable number of parameters (within a $10 \%$ difference). We note that TIMs performs poorly on this dataset but adding shared workspace improves the performance consistently. We also note that sparsity indeed helps as TIMs+HSW performed the best.
|
| 477 |
+
|
| 478 |
+

|
| 479 |
+
Figure 11: Per epoch validation perplexity for TIMs, $\mathrm { T I M s } { + } \mathrm { S S W }$ , $\mathrm { T I M s } { + } \mathrm { H S W }$ for wikitext-103 language modeling task
|
md/dev/ZTK3SefE8_Z/ZTK3SefE8_Z.md
ADDED
|
@@ -0,0 +1,443 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SYMBOLIC PHYSICS LEARNER: DISCOVERING GOVERNING EQUATIONS VIA MONTE CARLO TREE SEARCH
|
| 2 |
+
|
| 3 |
+
Fangzheng $\mathbf { S u n ^ { 1 } }$ , Yang $\mathbf { L i u ^ { 2 } }$ , Jian-Xun Wang3, Hao Sun4,∗
|
| 4 |
+
|
| 5 |
+
1Northeastern University, Boston, MA, USA; 2University of Chinese Academy of Sciences, Beijing, China; 3University of Notre Dame, Notre Dame, IN, USA; 4Renmin University of China, Beijing, China. Emails: sun.fa@northeastern.edu; liuyang22@ucas.ac.cn; jwang33@nd.edu; haosun@ruc.edu.cn
|
| 6 |
+
|
| 7 |
+
# ABSTRACT
|
| 8 |
+
|
| 9 |
+
Nonlinear dynamics is ubiquitous in nature and commonly seen in various science and engineering disciplines. Distilling analytical expressions that govern nonlinear dynamics from limited data remains vital but challenging. To tackle this fundamental issue, we propose a novel Symbolic Physics Learner (SPL) machine to discover the mathematical structure of nonlinear dynamics. The key concept is to interpret mathematical operations and system state variables by computational rules and symbols, establish symbolic reasoning of mathematical formulas via expression trees, and employ a Monte Carlo tree search (MCTS) agent to explore optimal expression trees based on measurement data. The MCTS agent obtains an optimistic selection policy through the traversal of expression trees, featuring the one that maps to the arithmetic expression of underlying physics. Salient features of the proposed framework include search flexibility and enforcement of parsimony for discovered equations. The efficacy and superiority of the SPL machine are demonstrated by numerical examples, compared with state-of-the-art baselines.
|
| 10 |
+
|
| 11 |
+
# 1 INTRODUCTION
|
| 12 |
+
|
| 13 |
+
We usually learn the behavior of a nonlinear dynamical system through its nonlinear governing differential equations. These equations can be formulated as $\dot { \mathbf { y } } ( t ) = d \mathbf { y } / d t = \mathcal { F } ( \mathbf { y } ( t ) )$ , where $\mathbf { y } ( t ) ~ = ~ \{ y _ { 1 } ( \hat { t } ) , y _ { 2 } ( t ) , . . . , y _ { n } ( t ) \} ^ { \hat { } } \in ~ \mathbb { R } ^ { 1 \times n _ { s } }$ denotes the system state at time $t$ , $\mathcal F ( \cdot )$ a nonlinear function set defining the state motions and $n _ { s }$ the system dimension. The explicit form of $\mathcal F ( \cdot )$ for some nonlinear dynamics remains underexplored. For example, in a mounted double pendulum system, the mathematical description of the underlying physics might be unclear due to unknown viscous and frictional damping forms. These uncertainties yield critical demands for the discovery of nonlinear dynamics given observational data. Nevertheless, distilling the analytical form of governing equations from limited noisy data, commonly seen in practice, is an intractable challenge.
|
| 14 |
+
|
| 15 |
+
Ever since the early work on the data-driven discovery of nonlinear dynamics (Džeroski & Todorovski, 1993; Dzeroski & Todorovski, 1995), many scientists have stepped into this field of study. During the recent decade, the escalating advances in machine learning, data science, and computing power have enabled several milestone efforts of unearthing the governing equations for nonlinear dynamical systems. Notably, a breakthrough model named SINDy (Sparse Identification of Nonlinear Dynamics) (Brunton et al., 2016) has shed light on tackling this achallenge. SINDy was invented to determine the sparse solution among a pre-defined basis function library recursively through a sequential threshold ridge regression (STRidge) algorithm. SINDy quickly became one of the state-of-art methods and kindled significant enthusiasm in this field of study (Rudy et al., 2017; Long et al., 2018; Champion et al., 2019; Chen et al., 2021; Sun et al., 2021; Rao et al., 2022). However, the success of this sparsity-promoting approach relies on a properly defined candidate function library that requires good prior knowledge of the system. It is also restricted by the fact that a linear combination of candidate functions might be insufficient to recover complicated mathematical expressions. Moreover, when the library size is massive, it empirically fails to hold the sparsity constraint.
|
| 16 |
+
|
| 17 |
+
At the same time, attempts have been made to tackle the nonlinear dynamics discovery problems by introducing neural networks with activation functions replaced by commonly seen mathematical operators (Martius & Lampert, 2017; Sahoo et al., 2018; Kim et al., 2019; Long et al., 2019). The intricate formulas are obtained via symbolic expansion of the well-trained network. This interpretation of physical laws results in larger candidate pools compared with the library-based representation of physics employed by SINDy. Nevertheless, since the sparsity of discovered expressions is primarily achieved by empirical pruning of the network weights, this framework exhibits sensitivity to userdefined thresholds and may fall short to produce parsimonious equations for noisy and scarce data.
|
| 18 |
+
|
| 19 |
+
Alternatively, another inspiring work (Bongard & Lipson, 2007; Schmidt & Lipson, 2009) reenvisioned the data-driven nonlinear dynamics discovery tasks by casting them into symbolic regression problems which have been profoundly resolved by the genetic programming (GP) approach (Koza & Koza, 1992; Billard & Diday, 2003). Under this framework, a symbolic regressor is established to identify the governing equations that best describe the underlying physics through free combination of mathematical operators and symbols, leading to great flexibility in model selection. One essential weakness of this early methodology is that, driven exclusively by the goal of empirically seeking the best-fitting expression (e.g. minimizing the mean-square error) in a genetic expansion process, the GP-based model usually over-fits the target system with numerous false-positive terms under data noise, even sometimes at a subtle level, causing huge instability and uncertainty. However, this ingenious idea has inspired a series of subsequent endeavors (Cornforth & Lipson, 2012; Gaucel et al., 2014; Ly & Lipson, 2012; Quade et al., 2016; Vaddireddy et al., 2020). In a more recent work, Deep Symbolic Regression (DSR) (Petersen et al., 2021; Mundhenk et al., 2021), a reinforcement learning-based model was established and generally outperformed the GP based models including the commercial Eureqa software (Langdon & Gustafson, 2010). Additionally, the AI-Feynman methods (Udrescu & Tegmark, 2020; Udrescu et al., 2020; Udrescu & Tegmark, 2021) ameliorated symbolic regression for distilling physics laws from data by combining neural network fitting with a suite of physics-inspired techniques. This approach is also highlighted by a recursive decomposition of a complicated mathematical expression into different parts on a tree-based graph, which disentangles the original problem and speeds up the discovery. It outperformed Eureqa in the uncovering Feynman physics equations (Feynman et al., 1965). However, this approach is built upon ad-hoc steps and, to some extent, lacks flexible automation in equation discovery.
|
| 20 |
+
|
| 21 |
+
The popularity of adopting the tree-based symbolic reasoning of mathematical formulas (Lample & Charton, 2019) has been rising recently to discover unknown mathematical expressions with a reinforcement learning agent (Kubalík et al., 2019; Petersen et al., 2021; Mundhenk et al., 2021). However, some former work attempting to apply the Monte Carlo tree search (MCTS) algorithm as an alternative to GP for symbolic regression (Cazenave, 2013; White et al., 2015; Islam et al., 2018; Lu et al., 2021) failed to leverage the full flexibility of this algorithm, resulting in the similar shortage that GP-based symbolic regressors possess as discussed earlier. Despite these outcomes, we are conscious of the strengths of the MCTS algorithm in equation discovery: it enables the flexible representation of search space with customized computational grammars to guide the search tree expansion. A sound mathematical underpinning for the trade-off between exploration and exploitation is remarkably advantageous as well. These features make it possible to inform the MCTS agent by our prior physics knowledge in nonlinear dynamics discovery rather than randomly searching in large spaces.
|
| 22 |
+
|
| 23 |
+
Contribution. We propose a promising model named Symbolic Physics Learner (SPL) machine, empowered by MCTS, for discovery of nonlinear dynamics. This architecture relies on a grammar composed of (i) computational rules and symbols to guide the search tree spanning and (ii) a composite objective rewarding function to simultaneously evaluate the generated equations with observational data and enforce the sparsity of the expression. Moreover, we design multiple adjustments to the conventional MCTS by: (1) replacing the expected reward in UCT score with maximum reward to better fit the equation discovery objective, (2) employing an adaptive scaling in policy evaluation which would eliminate the uncertainty of the reward value range owing to the unknown error of the system state derivatives, and (3) transplanting modules with high returns to the subsequent search as a single leaf node. With these adjustments, the SPL machine is capable of efficiently uncovering the best path to formulate the complex governing equations of the target dynamical system.
|
| 24 |
+
|
| 25 |
+
# 2 BACKGROUND
|
| 26 |
+
|
| 27 |
+
In this section, we expand and explain the background concepts brought up in the introduction to the SPL architecture, including the expression tree (parse tree) and the MCTS algorithm.
|
| 28 |
+
|
| 29 |
+
Expression tree. Any mathematical expression can be represented by a combinatorial set of symbols and mathematical operations, and further expressed by a parse tree structure (Hopcroft et al., 2006; Kusner et al., 2017) empowered by a context-free grammar (CFG). A CFG is a formal grammar characterized by a tuple comprised of 4 elements, namely, $\mathcal { G } = ( V , \Sigma , R , S )$ , where $V$ denotes a finite set of non-terminal nodes, $\Sigma$ a finite set of terminal nodes, $R$ a finite set of production rules, each interpreted as a mapping from a single non-terminal symbol in $V$ to one or multiple terminal/non-terminal node(s) in $( V \cup \Sigma ) ^ { * }$ where $^ *$ represents the Kleene star operation, and $S$ a single non-terminal node standing for a start symbol. In our work, equations are symbolized into parse trees: we define the start node as equation symbol $f$ , terminal symbols (leaf nodes) corresponding to the independent variables formulating the equation (e.g, $x , y )$ , and a placeholder symbol $C$ for identifiable constant coefficients that stick to specific production rules. The non-terminal nodes between root and leaf nodes are represented by some symbols distinct from the start and terminal nodes (i.e., $M _ { ☉ }$ ). The production rules denote the commonly seen mathematical operators: unary rules (one non-terminal node mapping to one node) for operators like $\cos ( \cdot ) , \exp ( \cdot ) , \bar { \log ( | \cdot | ) }$ , and binary rules (one non-terminal node mapping to two nodes) for operators such $\mathrm { ~ \imath s ~ } + , - , \times , \dot { \mathrm { ~ \cdot ~ } }$ . A parse tree is then generated via a pre-order traversal of production rules rooted at $f$ and terminates when all leaf nodes are entirely filled with terminal symbols. Each mathematical expression can be represented by such a traversal set of production rules.
|
| 30 |
+
|
| 31 |
+
Monte Carlo tree search. Monte Carlo tree search (MCTS) (Coulom, 2006) is an algorithm for searching optimal decisions in large combinatorial spaces represented by search trees. This technique complies with the best-first search principle based on the evaluations of stochastic simulations. It has already been widely employed in and proved the spectacular success by various gaming artificial intelligence systems, including the famous AlphaGo and AlphaZero (Silver et al., 2017) for computer Go game. A basic MCTS algorithm is composed of an iterative process with four steps:
|
| 32 |
+
|
| 33 |
+
1. Selection. The MCTS agent, starting from the root node, moves through the visited nodes of the search tree and selects the next node according to a given selection policy until it reaches an expandable node or a leaf node.
|
| 34 |
+
2. Expansion. At an expandable node, the MCTS agent expands the search tree by selecting one of its unvisited children.
|
| 35 |
+
3. Simulation. After expansion, if the current node is non-terminal, the agent performs one or multiple independent simulations starting from the current node until reaching the terminal state. In this process, actions are randomly selected.
|
| 36 |
+
4. Backpropagation. Statistics of nodes along the path from the current node to the root are updated with respect to search results (scores evaluated from the terminate states reached).
|
| 37 |
+
|
| 38 |
+
To maintain a proper balance between the less-tested paths and the best policy identified so far, the MCTS agent sticks to a trade-off between exploration and exploitation by taking action that maximizes the Upper Confidence Bounds applied for Trees (UCT), formulated as (Kocsis & Szepesvári, 2006):
|
| 39 |
+
|
| 40 |
+
$$
|
| 41 |
+
U C T ( s , a ) = Q ( s , a ) + c \sqrt { \ln [ N ( s ) ] / N ( s , a ) }
|
| 42 |
+
$$
|
| 43 |
+
|
| 44 |
+
where $Q ( s , a )$ is the average result/reward of playing action $a$ in state $s$ in the simulations performed in the history, encouraging the exploitation of current best child node; $N ( s )$ is number of times state $s$ visited, $N ( s , a )$ the number of times action $a$ has been selected at state $s$ , and $\sqrt { \ln [ N ( s ) ] / N ( s , a ) }$ consequently encourages exploration of less-visited child nodes. Constant $c$ controls the balance between exploration and exploitation, empirically defined upon the specific problem. Theoretical analysis of UCT-based MCTS (e.g., convergence, guarantees) is referred to Shah et al. (2019).
|
| 45 |
+
|
| 46 |
+
# 3 METHODS
|
| 47 |
+
|
| 48 |
+
Existing studies show that the MCTS agent continuously gains knowledge of specified tasks via the expansion of the search tree and, based on the backpropagation of evaluation results (i.e., rewards and number of visits), render a proper selection policy on visited states to guide the upcoming searching (Silver et al., 2017). In the proposed SPL machine, such a process is integrated with the symbolic reasoning of mathematical expressions to reproduce and evaluate valid mathematical expressions of the physical laws in nonlinear dynamics step-by-step, and then obtain a favorable selection policy pointing to the best solution. This algorithm is depicted in Figure 1 with an illustrative example and its overall training scheme is shown in Algorithm 1. Discussion of the hyperparameter setting for this algorithm is given in Appendix Section A.
|
| 49 |
+
|
| 50 |
+

|
| 51 |
+
Figure 1: Schematic architecture of the SPL machine for nonlinear dynamics discovery. The graph explains the 4 MCTS phases of one learning episode with an illustrative example.
|
| 52 |
+
|
| 53 |
+
Rewarding. To evaluate the mathematical expression $\tilde { f }$ projected from a parse tree, we define a numerical reward $r \in \mathcal { R } \subset \mathbb { R }$ based on this expression and input data ${ \mathcal { D } } = \{ { \bf Y } ; \dot { Y } _ { i } \}$ , serving as the search result of the current expansion or simulation. It is formulated as
|
| 54 |
+
|
| 55 |
+
$$
|
| 56 |
+
r = \frac { \eta ^ { n } } { 1 + \sqrt { \frac { 1 } { N } \left. \dot { Y } _ { i } - \tilde { f } ( \mathbf { Y } ) \right. _ { 2 } ^ { 2 } } }
|
| 57 |
+
$$
|
| 58 |
+
|
| 59 |
+
where $\mathbf { Y } = \{ \mathbf { y } _ { 1 } , \mathbf { y } _ { 2 } , . . . , \mathbf { y } _ { m } \} \in \mathbb { R } ^ { m \times N }$ is the $m$ dimensional state variables of a dynamical system, $\dot { Y } _ { i } \in \mathbb { R } ^ { 1 \times N }$ the numerically estimated state derivative for ith dimension, and $N$ the number of measurement data points. $\eta$ denotes a discount factor, assigned slightly smaller than 1; $n$ is empirically defined as the total number of production rules in the parse tree. This numerator arrangement is designated to penalize non-parsimonious solutions. This rewarding formulation outputs a reasonable assessment to the distilled equations and encourages parsimonious solution by discounting the reward of a non-parsimonious one. The rooted mean square error (RMSE) in denominator evaluates the goodness-of-fit of the discovered equation w.r.t. the measurement data.
|
| 60 |
+
|
| 61 |
+
Training scheme. A grammar $\mathcal { G } = ( V , \Sigma , R , S )$ is defined with appropriate nodes and production rules to cover all possible forms of equations. To keep track of non-terminal nodes of the parsing tree, we apply a last-in-first-out (LIFO) strategy and denote the non-terminal node placed last on the stack $N T$ as the current node. We define the action space $A = R$ and the state space $s$ as all possible traversals of complete/incomplete parse trees (i.e., production rules selected) in ordered sequences. At the current state $s _ { t } = [ a _ { 1 } , a _ { 2 } , . . . a _ { t } ]$ where $t \in \mathbb N$ is the discrete traversal step-index of the upcoming production rule, the MCTS agent masks out the invalid production rules for current non-terminal node and on that basis selects a valid rule as action $a _ { t + 1 }$ (i.e, the left-hand side of a valid production rule is the current non-terminal symbol). Consequently, the parse tree gains a new terminal/non-terminal branch in accordance with $a _ { t + 1 }$ , meanwhile the agent finds itself in a new state $s _ { t + 1 } = [ a _ { 1 } , a _ { 2 } , . . . a _ { t } , a _ { t + 1 } ]$ . The agent subsequently pops off the current non-terminal symbol from $N T$ and pushes the non-terminal nodes, if there are any, on the right-hand side of the selected rule onto the stack. Once the agent attains an unvisited node, a certain amount of simulations are performed, where the agent starts to randomly select the next node until the parse tree is completed.
|
| 62 |
+
|
| 63 |
+
1 Input: Grammar $G = ( V , \Sigma , R , S )$ , measurement data ${ \mathcal { D } } = \{ \mathbf { Y } ; { \dot { Y } } _ { i } \}$ ;
|
| 64 |
+
2 Parameters: discount/regularization factor $\eta$ , exploration rate $c$ , $t _ { m a x }$ ; # $\eta$ controls equation parsimony;
|
| 65 |
+
3 Output: Optimal governing equation $\tilde { f } ^ { \star }$ ;
|
| 66 |
+
4 for each episode do
|
| 67 |
+
5 Selection: Initialize $s _ { 0 } = \emptyset , t = 0 , N T = [ S ]$ ;
|
| 68 |
+
6 while $s _ { t }$ expandable and $t < t _ { m a x }$ do
|
| 69 |
+
7 Choose $a _ { t + 1 } = \arg \operatorname* { m a x } _ { \mathcal { A } } U C T ( s _ { t } , a )$ ;
|
| 70 |
+
8 Take action $a _ { t + 1 }$ , observe $s ^ { \prime } , N T$ ;
|
| 71 |
+
9 $s _ { t + 1 } \gets s ^ { \prime }$ note as visited, $t \gets t + 1$ ;
|
| 72 |
+
10 end
|
| 73 |
+
11 Expansion: Randomly take an unvisited path with action $a$ , observe $s ^ { \prime } , N T$ ;
|
| 74 |
+
12 $s _ { t + 1 } \gets s ^ { \prime }$ note as visited, $t \gets t + 1$ ;
|
| 75 |
+
13 if $N T = \emptyset$ then
|
| 76 |
+
14 Project $\tilde { f }$ , Backpropagate $r _ { t + 1 }$ and visited count and finish the episode;
|
| 77 |
+
15 end
|
| 78 |
+
16 Simulation: Fix the starting point $s _ { t } , N T$ ;
|
| 79 |
+
17 for each simulation do
|
| 80 |
+
18 while $s _ { t }$ non-terminal and $t < t _ { m a x }$ do
|
| 81 |
+
19 Randomly take an action $a$ , observe $s ^ { \prime } , N T$ ;
|
| 82 |
+
20 $s _ { t + 1 } \gets s ^ { \prime } , t \gets t + 1$ ;
|
| 83 |
+
21 end
|
| 84 |
+
22 if $N T = \emptyset$ then
|
| 85 |
+
23 Project $\tilde { f }$ and calculate $r _ { t + 1 }$ ;
|
| 86 |
+
24 end
|
| 87 |
+
25 end
|
| 88 |
+
26 Backpropagate simulation results;
|
| 89 |
+
27 end
|
| 90 |
+
|
| 91 |
+
The reward is calculated or the maximal size is exceeded, resulting in a zero reward. The best result from the attempts counts as the reward of the current simulation phase and backpropagates from the current unvisited node all the way to the root node.
|
| 92 |
+
|
| 93 |
+
Greedy search. Different from the MCTS-based gaming AIs where the agents are inclined to pick the action with a high expected reward (average returns), the SPL machine seeks the unique optimal solution. In the proposed training framework, we apply a greedy search heuristic to encourage the agent to explore the branch which yields the best solution in the past: $Q ( s , a )$ is defined as the maximum reward of the state-action pair, and its value is backpropagated from the highest reward in the simulations upon the selection of the pair. Meanwhile, to overcome the local minima problems due to this greedy approach in policy search, we enforce a certain level of randomness by empirically adopting the $\epsilon$ -greedy algorithm, a commonly seen approach in reinforcement learning models.
|
| 94 |
+
|
| 95 |
+
Adaptive-scaled rewarding. Owing to the unknown level of error from the numerically estimated state derivatives, the range of the RMSE in the SPL reward function is unpredictable. This uncertainty affects the scale of rewarding values thus the balance between exploration and exploitation is presented in Eq. (1). Besides adding “1” to the denominator of Eq. (2) to avoid dramatically large numerical rewards, we also apply an adaptive scale of the reward, given by
|
| 96 |
+
|
| 97 |
+
$$
|
| 98 |
+
Q ( s , a ) = { \frac { r ^ { * } ( s , a ) } { \operatorname* { m a x } _ { s ^ { \prime } \in S , a ^ { \prime } \in A } Q ( s ^ { \prime } , a ^ { \prime } ) } }
|
| 99 |
+
$$
|
| 100 |
+
|
| 101 |
+
where $r ^ { * }$ denotes the maximum reward of the state-action pair. It is scaled by the current maximum reward among all states $s$ and actions $\mathcal { A }$ to reach an equilibrium that the $Q$ -values are stretched to the scale $[ 0 , 1 ]$ at any time. This self-adaptive fashion yields a well-scaled calculation of UCT under different value ranges of rewards throughout the training.
|
| 102 |
+
|
| 103 |
+
Module transplantation. A function can be decomposed into smaller modules where each is simpler than the original one (Udrescu et al., 2020). This modularity feature, as shown in Figure 2, helps us develop a divide-and-conquer heuristic for distilling some complicated functions: after every certain amount of MCTS iterations, the discovered parse trees with high rewards are picked out and thereupon
|
| 104 |
+
|
| 105 |
+
reckoned as individual production rules and appended to the set of production rules $R$ ; accordingly, these trees are “transplanted” to the future ones as their modules (i.e, the leaves). To avoid early overfitting problem, we incrementally enlarge the sizes of such modules from a baseline length
|
| 106 |
+
|
| 107 |
+

|
| 108 |
+
Figure 2: A module transplantation process: A complete parse serves as a single production rule and is appended to the grammar pool.
|
| 109 |
+
|
| 110 |
+
to the maximum allowed size of the parse tree throughout the iterations. The augmentation part of $R$ is refreshed whenever new production rules are created, keeping only the ones engendering high rewards. This approach accelerates the policy search by capturing and locking some modules that likely contribute to, or appear as part of the optimal solution, especially in the cases of the mathematical expression containing “deep” operations (e.g., high-order polynomials) whose structures are difficult for the MCTS agent to repeatedly obtain during the selection and expansion.
|
| 111 |
+
|
| 112 |
+
# 4 SYMBOLIC REGRESSION: FINDING MATHEMATICAL FORMULAS
|
| 113 |
+
|
| 114 |
+
# 4.1 DATA NOISE & SCARCITY
|
| 115 |
+
|
| 116 |
+
Data scarcity and noise are commonly seen in measurement data and become one of the bottleneck issues for discovering the governing equations of nonlinear dynamics. Tackling the challenges in high-level data scarcity and noise situations is traditionally regarded as an essential robustness indicator for a nonlinear dynamics discovery model. To this end, we present an examination of the proposed SPL machine by an equation discovery task in the presence of multiple levels of data noise and
|
| 117 |
+
|
| 118 |
+

|
| 119 |
+
Figure 3: The effect of data noise/scarcity on recovery rate. The heatmaps demonstrate the recovery rate of GP and the SPL machine under different data conditions, summarized over 100 independent trials.
|
| 120 |
+
|
| 121 |
+
volume, comparing with a GP-based symbolic regressor (implemented with gplearn python package)1. The target equation is $f ( x ) = 0 . 3 x ^ { 3 } + 0 . 5 x ^ { 2 } + 2 x$ , and the independent variable $X$ is uniformly sampled in the given range $[ - 1 0 , 1 0 ]$ . Gaussian white noise is added to the dependent variable $Y$ with the noise level defined as the root-mean-square ratio between the noise and the exact values. For discovery, the two models are fed with equivalent search space: $\{ + , - , \times , \div , c o s t , x \}$ as candidate mathematical operations and symbols. The hyperparameters of the SPL machine are set as $\eta = 0 . 9 9$ , $t _ { m a x } = 5 0$ , and 10,000 episodes of training is regarded as one trail. For the GP-based symbolic regressor, the population of programs is set as 2,000, the number of generations as 20. The range of constant coefficient values is $[ - 1 0 , 1 0 ]$ . For 16 different data noise and scarcity levels, each model was performed 100 independent trails. The recovery rates are displayed as a $4 \times 4$ mesh grid w.r.t. different noise/scarcity levels in Figure 3. It is observed that the SPL machine outperforms the GP-based symbolic regressor in all the cases. A T-test also proves that the recovery rate of the SPL machine is significantly higher than that of GP (e.g., $p$ -value $= 1 . 0 6 \times 1 0 ^ { - 7 }$ ).
|
| 122 |
+
|
| 123 |
+
# 4.2 NGUYEN’S SYMBOLIC REGRESSION BENCHMARK
|
| 124 |
+
|
| 125 |
+
Nguyen’s symbolic regression benchmark task (Uy et al., 2011) is widely used to test the model’s robustness in symbolic regression problems. Given a set of allowed operators, a target equation, and data generated by the specified equation (see Table 1 for example), the tested model is supposed to distill the mathematical expression that is identical to the target equation, or equivalent to it (e.g., Nguyen-7 equation can be recovered as $\log ( x ^ { 3 } + x ^ { 2 } + x + 1 )$ , Nguyen-10 equation can be recovered as $\sin ( x + y )$ , and Nguyen-11 equation can be recovered as $\exp ( y \log ( x ) ) )$ . Some variants of Nguyen’s benchmark equations are also considered in this experiment. Their discoveries require numerical estimation of the constant coefficient values. Each equation generates two datasets: one for training and another for testing. The discovered equation that perfectly fits the testing data is regarded as a successful discovery (i.e., the discovered equation should be identical or equivalent to the target one). The recovery rate is calculated based on 100 independent tests for each task. In these benchmark tasks, three algorithms are tested: GP-based symbolic regressor, the neural-guided GP (NGGP) (Mundhenk et al., 2021), and the SPL machine. Note that NGGP is an improved approach over DSR (Petersen et al., 2021). They are given the same set of candidate operations: √ $\{ + , - , \times , \div , \exp ( \cdot ) , \cos ( \cdot ) , \sin ( \cdot ) \}$ for all benchmarks and $\{ { \sqrt { \cdot } } , \ln ( \cdot ) \}$ are added to the 7, 8, 11 benchmarks. The hyperparameters of the GP-based symbolic regressor are the same as those mentioned in Section 4.1; configurations of the NGGP models are obtained from its source code2; detailed setting of the benchmark tasks and the SPL model is described in Appendix Section B. The success rates are shown in Table 1. It is observed that the SPL machine and the NGGP model both produce reliable results in Nguyen’s benchmark problems and the SPL machine slightly outperforms NGGP. This experiment betokens the capacity of the SPL machine in discovery of equations with divergent forms.
|
| 126 |
+
|
| 127 |
+
Table 1: Recovery rate of three algorithms in Nguyen’s benchmark symbolic regression problems. The SPL machine outperforms the other two models in average recovery rate.
|
| 128 |
+
|
| 129 |
+
<table><tr><td>Benchmark</td><td>Expression</td><td>SPL</td><td>NGGP</td><td>GP</td></tr><tr><td>Nguyen-1</td><td>x²+x²+x</td><td>100%</td><td>100%</td><td>99%</td></tr><tr><td>Nguyen-2</td><td>x²+x²+x²+x</td><td>100%</td><td>100%</td><td>90%</td></tr><tr><td>Nguyen-3</td><td>+x4+x²+x²+x 25</td><td>100%</td><td>100%</td><td>34%</td></tr><tr><td>Nguyen-4</td><td>x+x+x4+x²+x²+x</td><td>99%</td><td>100%</td><td>54%</td></tr><tr><td>Nguyen-5</td><td>sin(x²) cos(𝑥) -1</td><td>95%</td><td>80%</td><td>12%</td></tr><tr><td>Nguyen-6</td><td>sin(x²)+sin(x+x²)</td><td>100%</td><td>100%</td><td>11%</td></tr><tr><td>Nguyen-7</td><td>ln(𝑥 +1) + ln(x²+ 1)</td><td>100%</td><td>100%</td><td>17%</td></tr><tr><td>Nguyen-8</td><td>√x</td><td>100%</td><td>100%</td><td>100%</td></tr><tr><td>Nguyen-9</td><td>sin(x) + sin(y²)</td><td>100%</td><td>100%</td><td>76%</td></tr><tr><td>Nguyen-10</td><td>2 sin(x) cos(y)</td><td>100%</td><td>100%</td><td>86%</td></tr><tr><td>Nguyen-11</td><td>xy</td><td>100%</td><td>100%</td><td>13%</td></tr><tr><td>Nguyen-12</td><td>x4-x²+¹y²-y</td><td>28%</td><td>4%</td><td>0%</td></tr><tr><td>Nguyen-1c</td><td>3.39x +2.12x² +1.78x</td><td>100%</td><td>100%</td><td>0%</td></tr><tr><td>Nguyen-2c</td><td>0.48x4 +3.39x+2.12x² +1.78x</td><td>94%</td><td>100%</td><td>0%</td></tr><tr><td>Nguyen-5c</td><td>sin(x²) cos(x) -0.75</td><td>95%</td><td>98%</td><td>1%</td></tr><tr><td>Nguyen-8c</td><td>√1.23x</td><td>100%</td><td>100%</td><td>56%</td></tr><tr><td>Nguyen-9c</td><td>sin(1.5x) + sin(0.5y²)</td><td>96%</td><td>90%</td><td>0%</td></tr><tr><td>Average</td><td></td><td>94.5%</td><td>92.4%</td><td>38.2%</td></tr></table>
|
| 130 |
+
|
| 131 |
+
Ablation Study: We consider four ablation studies by removing: (a) the adaptive scaling in reward calculation, (b) the discount factor $\eta ^ { n }$ that drives equation parsimony in Eq. (2), (c) module transplantation in tree generation, and (d) all of the above. The four models were tested on the first 12 Nguyen equations (see Appendix Section C). Results show the average recovery rates for these models are all smaller than that produced by SPL (see Appendix Table C.1), where the module transplantation brings the largest effect. Hence, these modules are critical to guarantee the proposed model efficacy.
|
| 132 |
+
|
| 133 |
+
5 PHYSICAL LAW DISCOVERY: FREE FALLING BALLS WITH AIR RESISTANCE
|
| 134 |
+
|
| 135 |
+
It is well known that, in 1589–1592, Galileo dropped two objects of unequal mass from the Leaning Tower of Pisa and drew a conclusion that their velocities were not affected by the mass. This has been well recognized globally as the “textbook” physical law for the vertical motion of a free-falling object:
|
| 136 |
+
|
| 137 |
+
Table 2: Baseline models ( $\dot { c } _ { i }$ : unknown constants).
|
| 138 |
+
|
| 139 |
+
<table><tr><td>Physics Model</td><td>Derived model expression</td></tr><tr><td>Model-1</td><td>H(t)= co+cit + c2t²+c3t3</td></tr><tr><td>Model-2</td><td>H(t)= Co +Cit + C2eCt</td></tr><tr><td>Model-3</td><td>H(t)= co + c1 log(cosh(c2t))</td></tr></table>
|
| 140 |
+
|
| 141 |
+
the height of the object is formulated as $\begin{array} { r } { H ( t ) = h _ { 0 } + v _ { 0 } t - \frac { 1 } { 2 } g t ^ { 2 } } \end{array}$ , where $h _ { 0 }$ denotes initial height, $v _ { 0 }$ the initial velocity, and $g$ the gravitational acceleration. However, this ideal situation is rarely reached in our daily life because air resistance serves as a significant damping factor that prevents the above physical law from occurring in real-life cases.
|
| 142 |
+
|
| 143 |
+
Many efforts have been made to uncover the effect of the air resistance and derive mathematical models to describe the free-falling objects with air resistance (Clancy, 1975; Lindemuth, 1971; Greenwood et al., 1986). This section provides data-driven discovery of the physical laws of relationships between height and time in the cases of free-falling objects with air resistance based on multiple experimental ball-drop datasets (de Silva et al., 2020), which contain the records of 11 different types of balls dropped from a
|
| 144 |
+
|
| 145 |
+
Table 3: Mean square error (MSE) between ball motion prediction with the measurements in the test set. The SPL machine reaches the best prediction results in most (9 out of 11) cases.
|
| 146 |
+
|
| 147 |
+
<table><tr><td>Type</td><td>SPL</td><td>Model-1</td><td>Model-2</td><td>Model-3</td></tr><tr><td>baseball</td><td>0.3</td><td>2.798</td><td>94.589</td><td>3.507</td></tr><tr><td>blue basketball</td><td>0.457</td><td>0.513</td><td>69.209</td><td>2.227</td></tr><tr><td>green basketball</td><td>0.088</td><td>0.1</td><td>85.435</td><td>1.604</td></tr><tr><td>volleyball</td><td>0.111</td><td>0.574</td><td>80.965</td><td>0.76</td></tr><tr><td>bowling ball</td><td>0.003</td><td>0.33</td><td>87.02</td><td>3.167</td></tr><tr><td>golf ball</td><td>0.009</td><td>0.214</td><td>86.093</td><td>1.684</td></tr><tr><td>tennis ball</td><td>0.091</td><td>0.246</td><td>72.278</td><td>0.161</td></tr><tr><td>whiffle ball 1</td><td>1.58</td><td>1.619</td><td>65.426</td><td>0.21</td></tr><tr><td>whiffle ball 2</td><td>0.099</td><td>0.628</td><td>58.533</td><td>0.966</td></tr><tr><td>yellow whiffle ball</td><td>0.428</td><td>17.341</td><td>44.984</td><td>2.57</td></tr><tr><td>orange whiffle ball</td><td>0.745</td><td>0.379</td><td>36.765</td><td>3.257</td></tr></table>
|
| 148 |
+
|
| 149 |
+
bridge (see Appendix Figure D.1). For discovery, each dataset is split into a training set (records from the first 2 seconds) and a testing set (records after 2 seconds). Three mathematically derived physics models are selected from the literature as baseline models3,4,5 for this experiment (see Table 2), and the unknown constant coefficient values are estimated by Powell’s conjugate direction method (Powell, 1964). Based on our prior knowledge of the physical law that may appear in this case, we use $\{ + , - , \times , \div , \exp ( \cdot ) , \cosh ( \cdot ) , \log ( \cdot ) \}$ as the candidate grammars for the SPL discovery, with terminal nodes $\{ t , c o n s t \}$ . The hyperparameters are set as $\eta = 0 . 9 9 9 9$ , $t _ { m a x } = 2 0$ , and one single discovery is built upon 6,000 episodes of training. The physical laws distilled by SPL from training data are applied to the test data and compared with the ground truth. Their prediction errors, in terms of MSE, are presented in Table 3 (the SPL-discovered equations are shown in Appendix Table D.1). The full results can be found in Appendix Section D. It can be concluded that the data-driven discovery of physical laws leads to a better approximation of the free-falling objects with air resistance.
|
| 150 |
+
|
| 151 |
+
# 6 CHAOTIC DYNAMICS DISCOVERY: THE LORENZ SYSTEM
|
| 152 |
+
|
| 153 |
+
The first nonlinear dynamics discovery example is a 3-dimensional Lorenz system (Lorenz, 1963) whose dynamical behavior $( x , y , z )$ is governed by $\dot { x } = \sigma ( y -$ $x ) , \dot { y } = x ( \rho - z ) - y , \dot { z } = x y - \beta z$ with parameters $\sigma = 1 0$ , $\beta = 8 / 3$ , and $\rho = 2 8$ . The Lorenz attractor has two lobes and the system, starting from anywhere, makes cycles around one lobe before switching to the other and iterates repeatedly, exhibiting strong chaos. The synthetic system states $( x , y , z )$ are generated by solving the nonlinear differential equations using the Matlab ode113 (Shampine, 1975; Shampine & Reichelt, 1997) function. $5 \%$ Gaussian white noise is added to the clean data to generate noisy measurement.
|
| 154 |
+
|
| 155 |
+
Table 4: Summary of the discovered governing equations for Lonrez system. Each cell concludes if target physics terms are distilled (if yes, number of false positive terms in uncovered expression).
|
| 156 |
+
|
| 157 |
+
<table><tr><td>Model</td><td>宝</td><td>y</td><td>之</td></tr><tr><td>Eureqa</td><td>Yes (1)</td><td>Yes (3)</td><td>Yes (1)</td></tr><tr><td>pySINDy</td><td>Yes (1)</td><td>No (N/A)</td><td>Yes (2)</td></tr><tr><td>NGGP</td><td>Yes (10)</td><td>Yes (8)</td><td>Yes (16)</td></tr><tr><td>SPL</td><td>Yes (0)</td><td>Yes (0)</td><td>Yes (0)</td></tr></table>
|
| 158 |
+
|
| 159 |
+
The derivatives of the system states $( \dot { x } , \dot { y } , \dot { z } )$ are unmeasured but estimated by central difference and smoothed by the Savitzky–Golay filter (Savitzky & Golay, 1964) in order to reduce the noise effect.
|
| 160 |
+
|
| 161 |
+
In this experiment, the proposed SPL machine is compared with three benchmark methods: Eureqa, pySINDy and NGGP. For Eureqa, NGGP, and the SPL machine, $\{ + , - , \times , \div \}$ are used as candidate operations; the upper bound of complexity is set to be 50; for pySINDy, the candidate function library includes all polynomial basis of $( x , y , z )$ from degree 1 to degree 4. Appendix Table E.1 presents the distilled governing equations by each approach and Table 4 summarizes these results: the SPL machine uncovers the explicit form of equations accurately in the context of active terms, whereas Eureqa, pySINDy and NGGP yield several false-positive terms in the governing equations. In particular, although Eureqa and NGGP are capable of uncovering the correct terms, their performance is very sensitive to the measurement noise as indicated by the redundant terms (despite with small coefficients) shown in Appendix Table E.1. Overall, the baseline methods fail to handle the large noise effect, essentially limiting their applicability in nonlinear dynamics discovery. It is evident that the SPL machine is capable of distilling the concise symbolic combination of operators and variables to correctly formulate parsimonious mathematical expressions that govern the Lorenz system, outperforming the baseline methods of Eureqa, pySINDy and NGGP.
|
| 162 |
+
|
| 163 |
+
# 7 EXPERIMENTAL DYNAMICS DISCOVERY: DOUBLE PENDULUM
|
| 164 |
+
|
| 165 |
+
This section shows SPL-based discovery of a chaotic double pendulum system with experimental data (Asseman et al., 2018) as shown in Appendix Figure E.3. The governing equations are given by:
|
| 166 |
+
|
| 167 |
+
$$
|
| 168 |
+
\begin{array} { r l } & { \dot { \omega } _ { 1 } = c _ { 1 } \dot { \omega } _ { 2 } \cos ( \Delta \theta ) + c _ { 2 } \omega _ { 2 } ^ { 2 } \sin ( \Delta \theta ) + c _ { 3 } \sin ( \theta _ { 1 } ) + \mathcal { R } _ { 1 } ( \theta _ { 1 } , \theta _ { 2 } , \dot { \theta } _ { 1 } , \dot { \theta } _ { 2 } ) , } \\ & { \dot { \omega } _ { 2 } = c _ { 1 } \dot { \omega } _ { 1 } \cos ( \Delta \theta ) + c _ { 2 } \omega _ { 1 } ^ { 2 } \sin ( \Delta \theta ) + c _ { 3 } \sin ( \theta _ { 2 } ) + \mathcal { R } _ { 2 } ( \theta _ { 1 } , \theta _ { 2 } , \dot { \theta } _ { 1 } , \dot { \theta } _ { 2 } ) } \end{array}
|
| 169 |
+
$$
|
| 170 |
+
|
| 171 |
+
where $\theta _ { 1 } , \theta _ { 2 }$ denote the angular displacements; $\omega _ { 1 } = \dot { \theta } _ { 1 }$ , $\omega _ { 2 } ~ = ~ { \dot { \theta } } _ { 2 }$ the velocities; $\dot { \omega } _ { 1 } , \dot { \omega } _ { 2 }$ the accelerations; $\mathcal { R } _ { 1 }$ and $\mathcal { R } _ { 2 }$ denote the unknown damping forces. Note that $\Delta \theta = \theta _ { 1 } - \theta _ { 2 }$ .
|
| 172 |
+
|
| 173 |
+
The data source contains multiple camera-sensed datasets. Here, 5,000 denoised random sub-samples from 5 datasets are used for training, 2,000 random sub-samples from another 2 datasets for validation, and 1 dataset for testing. The derivatives of the system states are numerically estimated by the same approach discussed in the Lorenz case. Some prior physics knowledge is employed to guide the discovery: (1) the terms $\dot { \omega } _ { 2 } \cos ( \Delta \theta )$ for $\dot { \omega } _ { 1 }$ and $\dot { \omega } _ { 1 } \cos ( \Delta \theta )$ for $\dot { \omega } _ { 2 }$ are assumed to be part of the governing equations based on the Lagrange derivation; (2) the angles $( \theta _ { 1 } , \theta _ { 2 } , \Delta \theta )$ are under the trigonometric functions $\cos ( \cdot )$ and $\sin ( \cdot )$ ; (3) directions of velocities/relative velocities may appear in damping. Production rules fulfilling the above prior knowledge are exhibited in Appendix Section E.2. The hyperparameters are set as $\eta = 1$ , $t _ { m a x } = 2 0$ , and 40,000 episodes of training are regarded as one trail. 5 independent trials are performed and the equations with the highest validation scores are selected as the final results. The uncovered equations are given as follows:
|
| 174 |
+
|
| 175 |
+
$$
|
| 176 |
+
\dot { \omega } _ { 1 } = - 0 . 0 9 9 1 \dot { \omega } _ { 2 } \cos ( \Delta \theta ) - 0 . 1 0 3 \omega _ { 2 } ^ { 2 } \sin ( \Delta \theta ) - 6 9 . 2 7 4 \sin ( \theta _ { 1 } ) + 0 . 5 1 5 \cos ( \theta _ { 1 } ) ,
|
| 177 |
+
$$
|
| 178 |
+
|
| 179 |
+
$$
|
| 180 |
+
\begin{array} { r } { \dot { \omega } _ { 2 } = - 1 . 3 6 8 \dot { \omega } _ { 1 } \cos ( \Delta \theta ) + 1 . 3 6 3 \omega _ { 1 } ^ { 2 } \sin ( \Delta \theta ) - 9 2 . 9 1 3 \sin ( \theta _ { 2 } ) + 0 . 0 3 2 \omega _ { 1 } , } \end{array}
|
| 181 |
+
$$
|
| 182 |
+
|
| 183 |
+
where the explicit expression of physics in an ideal double pendulum system, as displayed in Eq. (5), are successfully distilled and damping terms are estimated. This set of equation is validated through interpolation on the testing set and compared with the smoothed derivatives, as shown in Appendix Figure E.4. The solution appears felicitous as the governing equations of the testing responses.
|
| 184 |
+
|
| 185 |
+
# 8 CONCLUSION AND DISCUSSION
|
| 186 |
+
|
| 187 |
+
This paper introduces a Symbolic Physics Learner (SPL) machine to tackle the challenge of distilling the mathematical structure of equations for physical systems (e.g., nonlinear dynamics) with scarce/noisy data. This framework is built upon the expression tree interpretation of mathematical operations and variables and an MCTS agent that searches for the optimistic policy to reconstruct the target mathematical formula. With some remarkable adjustments to the MCTS algorithms, the SPL model straightforwardly accepts our prior or domain knowledge, or any sort of constraints of the tasks in the grammar design while leveraging great flexibility in expression formulation. The robustness of the proposed SPL machine for complex target expression discovery within a large search space is indicated in the Nguyen’s symbolic regression benchmark problems, where the SPL machine outperforms state-of-the-art symbolic regression methods. Moreover, encouraging results are obtained in the tasks of discovering physical laws and nonlinear dynamics, based on synthetic or experimental datasets. While the proposed SPL machine shows huge potential in both symbolic regression and physical law discovery tasks, there are still some imperfections that can be improved: (i) the computational cost is high for constant coefficient value estimation due to repeated calls for an optimization process, (ii) graph modularity is underexamined, and (iii) robustness against extreme data noise and scarcity is not optimal. These limitations are further explained in Appendix Section F.
|
| 188 |
+
|
| 189 |
+
# ACKNOWLEDGMENTS
|
| 190 |
+
|
| 191 |
+
The work is supported by the National Natural Science Foundation of China (No. 92270118) and the Beijing Outstanding Young Scientist Program (No. BJJWZYJH012019100020098).
|
| 192 |
+
|
| 193 |
+
# REFERENCES
|
| 194 |
+
|
| 195 |
+
Alexis Asseman, Tomasz Kornuta, and Ahmet Ozcan. Learning beyond simulated physics. In Modeling and Decision-making in the Spatiotemporal Domain Workshop–NIPS, 2018.
|
| 196 |
+
|
| 197 |
+
L Billard and E Diday. From the statistics of data to the statistics of knowledge: symbolic data analysis. Journal of the American Statistical Association, 98(462):470–487, 2003.
|
| 198 |
+
|
| 199 |
+
Josh Bongard and Hod Lipson. Automated reverse engineering of nonlinear dynamical systems. Proceedings of the National Academy of Sciences, 104(24):9943–9948, 2007.
|
| 200 |
+
|
| 201 |
+
Steven L Brunton, Joshua L Proctor, and J Nathan Kutz. Discovering governing equations from data by sparse identification of nonlinear dynamical systems. Proceedings of the national academy of sciences, 113(15):3932–3937, 2016.
|
| 202 |
+
|
| 203 |
+
Tristan Cazenave. Monte-carlo expression discovery. International Journal on Artificial Intelligence Tools, 22(01):1250035, 2013.
|
| 204 |
+
|
| 205 |
+
Kathleen Champion, Bethany Lusch, J Nathan Kutz, and Steven L Brunton. Data-driven discovery of coordinates and governing equations. Proceedings of the National Academy of Sciences, 116(45): 22445–22451, 2019.
|
| 206 |
+
|
| 207 |
+
Zhao Chen, Yang Liu, and Hao Sun. Physics-informed learning of governing equations from scarce data. Nature Communications, 12:6136, 2021.
|
| 208 |
+
|
| 209 |
+
Laurence Joseph Clancy. Aerodynamics. John Wiley & Sons, 1975.
|
| 210 |
+
|
| 211 |
+
Theodore Cornforth and Hod Lipson. Symbolic regression of multiple-time-scale dynamical systems. In Proceedings of the 14th annual conference on Genetic and evolutionary computation, pp. 735–742, 2012.
|
| 212 |
+
|
| 213 |
+
Rémi Coulom. Efficient selectivity and backup operators in monte-carlo tree search. In International conference on computers and games, pp. 72–83. Springer, 2006.
|
| 214 |
+
|
| 215 |
+
Brian M de Silva, David M Higdon, Steven L Brunton, and J Nathan Kutz. Discovery of physics from data: universal laws and discrepancies. Frontiers in artificial intelligence, 3:25, 2020.
|
| 216 |
+
|
| 217 |
+
Saso Dzeroski and Ljupco Todorovski. Discovering dynamics: from inductive logic programming to machine discovery. Journal of Intelligent Information Systems, 4(1):89–108, 1995.
|
| 218 |
+
|
| 219 |
+
Sašo Džeroski and Ljupéo Todorovski. Discovering dynamics. In Proc. tenth international conference on machine learning, pp. 97–103, 1993.
|
| 220 |
+
|
| 221 |
+
Richard P Feynman, Robert B Leighton, and Matthew Sands. The feynman lectures on physics; vol. i. American Journal of Physics, 33(9):750–752, 1965.
|
| 222 |
+
|
| 223 |
+
Sébastien Gaucel, Maarten Keijzer, Evelyne Lutton, and Alberto Tonda. Learning dynamical systems using standard symbolic regression. In European Conference on Genetic Programming, pp. 25–36. Springer, 2014.
|
| 224 |
+
|
| 225 |
+
Margaret Stautberg Greenwood, Charles Hanna, and Rev John W Milton. Air resistance acting on a sphere: Numerical analysis, strobe photographs, and videotapes. The Physics Teacher, 24(3): 153–159, 1986.
|
| 226 |
+
|
| 227 |
+
John E Hopcroft, Rajeev Motwani, and Jeffrey D Ullman. Automata theory, languages, and computation. International Edition, 24(2), 2006.
|
| 228 |
+
|
| 229 |
+
Mohiul Islam, Nawwaf N Kharma, and Peter Grogono. Expansion: A novel mutation operator for genetic programming. In IJCCI, pp. 55–66, 2018.
|
| 230 |
+
|
| 231 |
+
Samuel Kim, Peter Lu, Srijon Mukherjee, Michael Gilbert, Li Jing, Vladimir Ceperic, and Marin Soljacic. Integration of neural network-based symbolic regression in deep learning for scientific discovery. arXiv preprint arXiv:1912.04825, 2019.
|
| 232 |
+
|
| 233 |
+
Levente Kocsis and Csaba Szepesvári. Bandit based monte-carlo planning. In European conference on machine learning, pp. 282–293. Springer, 2006.
|
| 234 |
+
|
| 235 |
+
John R Koza and John R Koza. Genetic programming: on the programming of computers by means of natural selection, volume 1. MIT press, 1992.
|
| 236 |
+
|
| 237 |
+
Jiˇrí Kubalík, Jan Žegklitz, Erik Derner, and Robert Babuška. Symbolic regression methods for reinforcement learning. arXiv preprint arXiv:1903.09688, 2019.
|
| 238 |
+
|
| 239 |
+
Matt J Kusner, Brooks Paige, and José Miguel Hernández-Lobato. Grammar variational autoencoder. In Proceedings of the 34th International Conference on Machine Learning, pp. 1945–1954. JMLR. org, 2017.
|
| 240 |
+
|
| 241 |
+
Guillaume Lample and François Charton. Deep learning for symbolic mathematics. arXiv preprint arXiv:1912.01412, 2019.
|
| 242 |
+
|
| 243 |
+
William B Langdon and Steven M Gustafson. Genetic programming and evolvable machines: ten years of reviews. Genetic Programming and Evolvable Machines, 11(3):321–338, 2010.
|
| 244 |
+
|
| 245 |
+
Jeffrey Lindemuth. The effect of air resistance on falling balls. American Journal of Physics, 39(7): 757–759, 1971.
|
| 246 |
+
|
| 247 |
+
Zichao Long, Yiping Lu, Xianzhong Ma, and Bin Dong. Pde-net: Learning pdes from data. In International Conference on Machine Learning, pp. 3208–3216. PMLR, 2018.
|
| 248 |
+
|
| 249 |
+
Zichao Long, Yiping Lu, and Bin Dong. Pde-net 2.0: Learning pdes from data with a numericsymbolic hybrid deep network. Journal of Computational Physics, 399:108925, 2019.
|
| 250 |
+
|
| 251 |
+
Edward N Lorenz. Deterministic nonperiodic flow. Journal of the atmospheric sciences, 20(2): 130–141, 1963.
|
| 252 |
+
|
| 253 |
+
Qiang Lu, Fan Tao, Shuo Zhou, and Zhiguang Wang. Incorporating actor-critic in monte carlo tree search for symbolic regression. Neural Computing and Applications, pp. 1–17, 2021.
|
| 254 |
+
|
| 255 |
+
Daniel L Ly and Hod Lipson. Learning symbolic representations of hybrid dynamical systems. The Journal of Machine Learning Research, 13(1):3585–3618, 2012.
|
| 256 |
+
|
| 257 |
+
Georg S Martius and Christoph Lampert. Extrapolation and learning equations. In 5th International Conference on Learning Representations, ICLR 2017-Workshop Track Proceedings, 2017.
|
| 258 |
+
|
| 259 |
+
T Nathan Mundhenk, Mikel Landajuela, Ruben Glatt, Claudio P Santiago, Daniel M Faissol, and Brenden K Petersen. Symbolic regression via neural-guided genetic programming population seeding. arXiv preprint arXiv:2111.00053, 2021.
|
| 260 |
+
|
| 261 |
+
Brenden K Petersen, Mikel Landajuela Larma, Terrell N Mundhenk, Claudio Prata Santiago, Soo Kyung Kim, and Joanne Taery Kim. Deep symbolic regression: Recovering mathematical expressions from data via risk-seeking policy gradients. In International Conference on Learning Representations, 2021.
|
| 262 |
+
|
| 263 |
+
Michael JD Powell. An efficient method for finding the minimum of a function of several variables without calculating derivatives. The computer journal, 7(2):155–162, 1964.
|
| 264 |
+
|
| 265 |
+
Markus Quade, Markus Abel, Kamran Shafi, Robert K Niven, and Bernd R Noack. Prediction of dynamical systems by symbolic regression. Physical Review E, 94(1):012214, 2016.
|
| 266 |
+
|
| 267 |
+
Chengping Rao, Pu Ren, Yang Liu, and Hao Sun. Discovering nonlinear PDEs from scarce data with physics-encoded learning. In International Conference on Learning Representations, pp. 1–19, 2022.
|
| 268 |
+
|
| 269 |
+
Samuel H Rudy, Steven L Brunton, Joshua L Proctor, and J Nathan Kutz. Data-driven discovery of partial differential equations. Science Advances, 3(4):e1602614, 2017.
|
| 270 |
+
|
| 271 |
+
Subham Sahoo, Christoph Lampert, and Georg Martius. Learning equations for extrapolation and control. In International Conference on Machine Learning, pp. 4442–4450, 2018.
|
| 272 |
+
|
| 273 |
+
Abraham Savitzky and Marcel JE Golay. Smoothing and differentiation of data by simplified least squares procedures. Analytical chemistry, 36(8):1627–1639, 1964.
|
| 274 |
+
|
| 275 |
+
Michael Schmidt and Hod Lipson. Distilling free-form natural laws from experimental data. science, 324(5923):81–85, 2009.
|
| 276 |
+
|
| 277 |
+
Devavrat Shah, Qiaomin Xie, and Zhi Xu. Non-asymptotic analysis of monte carlo tree search. arXiv preprint arXiv:1902.05213, 2019.
|
| 278 |
+
|
| 279 |
+
Lawrence F Shampine. Computer solution of ordinary differential equations. The initial value problem, 1975.
|
| 280 |
+
|
| 281 |
+
Lawrence F Shampine and Mark W Reichelt. The matlab ode suite. SIAM journal on scientific computing, 18(1):1–22, 1997.
|
| 282 |
+
|
| 283 |
+
David Silver, Julian Schrittwieser, Karen Simonyan, Ioannis Antonoglou, Aja Huang, Arthur Guez, Thomas Hubert, Lucas Baker, Matthew Lai, Adrian Bolton, et al. Mastering the game of go without human knowledge. Nature, 550(7676):354–359, 2017.
|
| 284 |
+
|
| 285 |
+
Fangzheng Sun, Yang Liu, and Hao Sun. Physics-informed spline learning for nonlinear dynamics discovery. In Proceedings of the Thirtieth International Joint Conference on Artificial Intelligence, pp. 2054–2061, 2021.
|
| 286 |
+
|
| 287 |
+
Silviu-Marian Udrescu and Max Tegmark. Ai feynman: A physics-inspired method for symbolic regression. Science Advances, 6(16):eaay2631, 2020.
|
| 288 |
+
|
| 289 |
+
Silviu-Marian Udrescu and Max Tegmark. Symbolic pregression: discovering physical laws from distorted video. Physical Review E, 103(4):043307, 2021.
|
| 290 |
+
|
| 291 |
+
Silviu-Marian Udrescu, Andrew Tan, Jiahai Feng, Orisvaldo Neto, Tailin Wu, and Max Tegmark. Ai feynman 2.0: Pareto-optimal symbolic regression exploiting graph modularity. arXiv preprint arXiv:2006.10782, 2020.
|
| 292 |
+
|
| 293 |
+
Nguyen Quang Uy, Nguyen Xuan Hoai, Michael O’Neill, Robert I McKay, and Edgar GalvánL��pez. Semantically-based crossover in genetic programming: application to real-valued symbolic regression. Genetic Programming and Evolvable Machines, 12(2):91–119, 2011.
|
| 294 |
+
|
| 295 |
+
Harsha Vaddireddy, Adil Rasheed, Anne E Staples, and Omer San. Feature engineering and symbolic regression methods for detecting hidden physics from sparse sensor observation data. Physics of Fluids, 32(1):015113, 2020.
|
| 296 |
+
|
| 297 |
+
David R White, Shin Yoo, and Jeremy Singer. The programming game: evaluating mcts as an alternative to gp for symbolic regression. In Proceedings of the Companion Publication of the 2015 Annual Conference on Genetic and Evolutionary Computation, pp. 1521–1522, 2015.
|
| 298 |
+
|
| 299 |
+
# APPENDIX
|
| 300 |
+
|
| 301 |
+
# A HYPERPARAMETER SETTING
|
| 302 |
+
|
| 303 |
+
We perform a parametric study on the value of discount factor $\eta$ based on Nguyen’s benchmark problems without measurement noise. Empirically, setting $\eta = 0 . 9 9 9 9$ ensures the scores of ground truth equations stand out and successfully enforces the sparsity in all experiments. For the discovery of very chaotic dynamical systems based on measurement data, we expect some physics terms from the governing equations to have a weak impact on the state variables (e.g., in the chaotic double pendulum system experiments, the effects from physics terms $\sin ( \theta _ { 1 } )$ and $\mathrm { s i n } ( \theta _ { 2 } )$ are hard to be captured), and the effect of data noise is unknown. Hence, we set $\eta = 1$ to leverage the full strength of data fitting to enable the detection of physics terms that are offset or overwhelmed by data noise but are pivotal to the systems. Nevertheless, we must acknowledge that this selection process is empirical, which depends on our desire for the degree of parsimony of the target equation(s).
|
| 304 |
+
|
| 305 |
+
As for the hyperparameters in the training schema (i.e., maximum module transplantation, episodes, maximum tree size, maximum augmented grammars), we have conducted parametric convergence tests for each experiment to ensure the learning curves (i.e., maximum scores in the history) converge. For example, as discussed in Section B, Table B.2 shows the setting of these hyperparameters.
|
| 306 |
+
|
| 307 |
+
# B NGUYEN’S BENCHMARK PROBLEMS
|
| 308 |
+
|
| 309 |
+
This section provides more detailed experiment settings for the Nguyen’s benchmark tasks that are described in Section 4.2 of the main text, where the training hyperparameters for the SPL machine in these equation discovery experiments are also listed. Table B.1 presents the candidate mathematical operations allowed for three tested models and Table B.2 displays training hyperparameters for the SPL machine in the Nguyen’s benchmark tasks.
|
| 310 |
+
|
| 311 |
+
Moreover, the utilization of CFG in the SPL machine facilitates the flexibility of applying some prior knowledge including the universal mathematical rules and constraints. This feature empirically turns out to be an accessible and scalable approach for avoiding meaningless mathematical expressions. In the Nguyen’s benchmark tasks, one or multiple mathematical constraints are given to the SPL machine. These constraints include
|
| 312 |
+
|
| 313 |
+
1. Only variables and constant values are allowed in trigonometric functions.
|
| 314 |
+
|
| 315 |
+
Table B.1: Candidate operators for each Nguyen’s benchmark task. const denotes constant values.
|
| 316 |
+
|
| 317 |
+
<table><tr><td></td><td rowspan=1 colspan=9>Benchmark Candidate Operations</td></tr><tr><td></td><td rowspan=1 colspan=7>Nguyen-1 +,-,×,÷,cos(-),sin(-),exp(·)</td><td rowspan=2 colspan=1>,sin(</td><td rowspan=17 colspan=1>+,-,×,÷,cos(-),sin(-),exp(-),log(),√+,-,×,÷,cos(-),sin(-),exp(-),log(-),√+,-,×,÷,cos(-),sin(-),exp(-),log(),√+,-,×,÷,cos(-),sin(-),exp(-),log(-),√,const</td></tr><tr><td></td><td rowspan=1 colspan=7>Nguyen-2 +,-,×,÷,cos(·),sin(.),exp()</td></tr><tr><td></td><td rowspan=1 colspan=3>Nguyen-3</td><td rowspan=1 colspan=4>×,÷,cos(·</td><td rowspan=1 colspan=1>,sin(·</td></tr><tr><td></td><td rowspan=1 colspan=3>Nguyen-4</td><td rowspan=1 colspan=4>X,÷,cos(</td><td rowspan=1 colspan=1>,sin(·</td></tr><tr><td></td><td rowspan=1 colspan=3>Nguyen-5</td><td rowspan=1 colspan=4>×,÷,cos(·</td><td rowspan=1 colspan=1>,sin(·</td></tr><tr><td></td><td rowspan=1 colspan=3>Nguyen-6</td><td rowspan=1 colspan=4>X,÷,cos(·</td><td rowspan=1 colspan=1>,sin(·</td></tr><tr><td></td><td rowspan=1 colspan=3>Nguyen-7</td><td rowspan=1 colspan=1>×</td><td rowspan=1 colspan=3>÷,cos(·</td><td rowspan=1 colspan=1>,sin(·</td><td rowspan=1 colspan=1>,exp(·</td></tr><tr><td></td><td rowspan=1 colspan=3>Nguyen-8</td><td rowspan=1 colspan=1>×</td><td rowspan=1 colspan=3>÷,cos(·</td><td rowspan=1 colspan=1>,sin(·</td><td rowspan=1 colspan=1>,exp(·</td></tr><tr><td></td><td rowspan=1 colspan=3>Nguyen-9</td><td rowspan=1 colspan=1>×</td><td rowspan=1 colspan=1>÷</td><td rowspan=1 colspan=2>cos(·</td><td rowspan=1 colspan=1>,sin(·</td><td rowspan=1 colspan=1>,exp(·</td></tr><tr><td></td><td rowspan=1 colspan=3>Nguyen-10</td><td rowspan=1 colspan=1>×</td><td rowspan=1 colspan=1>÷</td><td rowspan=1 colspan=1>Cos</td><td></td><td rowspan=1 colspan=1>,sin(·</td><td rowspan=1 colspan=1>,exp(.</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=2>Nguyen-11</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>×</td><td rowspan=1 colspan=1>÷</td><td rowspan=1 colspan=1>Cos</td><td></td><td rowspan=1 colspan=1>,sin(·</td><td rowspan=1 colspan=1>,exp(.</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=2>Nguyen-12</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>×</td><td rowspan=1 colspan=1>÷</td><td rowspan=1 colspan=1>Cos</td><td></td><td rowspan=1 colspan=1>,sin(·</td><td rowspan=1 colspan=1>,exp(.</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=3>Nguyen-1c</td><td rowspan=1 colspan=1>×</td><td rowspan=1 colspan=1>÷</td><td rowspan=1 colspan=1>Cos</td><td></td><td rowspan=1 colspan=1>,sin(·</td><td rowspan=1 colspan=1>,exp(.</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=3>Nguyen-2c</td><td rowspan=1 colspan=1>×</td><td rowspan=1 colspan=1>÷</td><td rowspan=1 colspan=2>cos(.</td><td rowspan=1 colspan=1>,sin(·</td><td rowspan=1 colspan=1>,exp(.</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Nguyen-5c</td><td rowspan=1 colspan=2>十,一</td><td rowspan=1 colspan=1>×</td><td rowspan=1 colspan=1>÷</td><td rowspan=1 colspan=1>Cos</td><td></td><td rowspan=1 colspan=1>,sin(·</td><td rowspan=1 colspan=1>,exp(·</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Nguyen-8c</td><td rowspan=1 colspan=2>十,一</td><td rowspan=1 colspan=1>×</td><td rowspan=1 colspan=1>÷</td><td rowspan=1 colspan=1>cos</td><td></td><td rowspan=1 colspan=1>,sin(·</td><td rowspan=1 colspan=1>,exp(.</td></tr><tr><td rowspan=1 colspan=4>Nguyen-9c</td><td rowspan=1 colspan=1>×</td><td rowspan=1 colspan=1>÷</td><td rowspan=1 colspan=2>cos(·</td><td rowspan=1 colspan=1>,sin(·</td><td rowspan=1 colspan=1>,exp(·</td></tr></table>
|
| 318 |
+
|
| 319 |
+
Table B.2: Training Hyperparameter settings for the SPL model in Nguyen’s benchmark tasks.
|
| 320 |
+
|
| 321 |
+
<table><tr><td>Benchmark</td><td>Maximum Module Transplantation</td><td>Episodes Between Module Transplantation</td><td>Maximum Tree Size</td><td>Maximum Augmented Grammars</td></tr><tr><td>Nguyen-1</td><td>20</td><td>10,000</td><td>50</td><td>5</td></tr><tr><td>Nguyen-2</td><td>20</td><td>10,000</td><td>50</td><td>5</td></tr><tr><td>Nguyen-3</td><td>20</td><td>100,000</td><td>50</td><td>5</td></tr><tr><td>Nguyen-4</td><td>20</td><td>100,000</td><td>50</td><td>5</td></tr><tr><td>Nguyen-5</td><td>20</td><td>100,000</td><td>50</td><td>5</td></tr><tr><td>Nguyen-6</td><td>20</td><td>10,000</td><td>50</td><td>5</td></tr><tr><td>Nguyen-7</td><td>20</td><td>5,000</td><td>50</td><td>5</td></tr><tr><td>Nguyen-8</td><td>20</td><td>5,000</td><td>50</td><td>5</td></tr><tr><td>Nguyen-9</td><td>20</td><td>10,000</td><td>50</td><td>5</td></tr><tr><td>Nguyen-10</td><td>20</td><td>10,000</td><td>50</td><td>5</td></tr><tr><td>Nguyen-11</td><td>20</td><td>10,000</td><td>50</td><td>5</td></tr><tr><td>Nguyen-12</td><td>20</td><td>100,000</td><td>50</td><td>5</td></tr><tr><td>Nguyen-1c</td><td>20</td><td>2,000</td><td>50</td><td>5</td></tr><tr><td>Nguyen-2c</td><td>20</td><td>10,000</td><td>50</td><td>5</td></tr><tr><td>Nguyen-5c</td><td>20</td><td>10.000</td><td>50</td><td>5</td></tr><tr><td>Nguyen-8c</td><td>20</td><td>2,000</td><td>50</td><td>5</td></tr><tr><td>Nguyen-9c</td><td>20</td><td>1,000</td><td>50</td><td>5</td></tr></table>
|
| 322 |
+
|
| 323 |
+
Table B.3: Mathematical constraints for the SPL machine in each Nguyen’s benchmark problem.
|
| 324 |
+
|
| 325 |
+
<table><tr><td>Benchmark</td><td>Constraints Utilization</td></tr><tr><td>Nguyen-1</td><td>{1,3}</td></tr><tr><td>Nguyen-2</td><td>{1,3}</td></tr><tr><td>Nguyen-3</td><td>{1,3}</td></tr><tr><td>Nguyen-4</td><td>{1,3}</td></tr><tr><td>Nguyen-5</td><td>{2,3}</td></tr><tr><td>Nguyen-6</td><td>{2,3}</td></tr><tr><td>Nguyen-7</td><td>{2,3}</td></tr><tr><td>Nguyen-8</td><td>0</td></tr><tr><td>Nguyen-9</td><td>{2,3,4}</td></tr><tr><td>Nguyen-10</td><td>{2,3,4}</td></tr><tr><td>Nguyen-11</td><td>{2,3}</td></tr><tr><td>Nguyen-12</td><td>{1,3,4}</td></tr><tr><td>Nguyen-1c</td><td>{1,3}</td></tr><tr><td>Nguyen-2c</td><td>{1,3}</td></tr><tr><td>Nguyen-5c</td><td>{2,3}</td></tr><tr><td>Nguyen-8c</td><td>0</td></tr><tr><td>Nguyen-9c</td><td>{2,3,4}</td></tr></table>
|
| 326 |
+
|
| 327 |
+
2. Variables in trigonometric functions, logarithms and roots are up to the polynomial of 3.
|
| 328 |
+
3. Trigonometric functions, logarithms and roots are not allowed to form unreasonable composite functions with each other, such as $\sin ( \cos ( . . . ) )$ .
|
| 329 |
+
4. Some small integers (e.g. 1, 2) are used directly as leaves.
|
| 330 |
+
|
| 331 |
+
They can be easily implemented into the SPL machine by defining or adjusting non-terminal nodes or production rules in the customized CFG. Constraints adopted by each task are shown in Table B.3.
|
| 332 |
+
|
| 333 |
+
# C RESULTS OF ABLATION STUDY
|
| 334 |
+
|
| 335 |
+
We consider four ablation studies by removing the following:
|
| 336 |
+
|
| 337 |
+
(a) the adaptive scaling in reward calculation, (b) the discount factor $\eta ^ { n }$ that drives equation parsimony in Eq. (2), (c) module transplantation in tree generation, (d) all of the above three.
|
| 338 |
+
|
| 339 |
+
The resulting models are denoted with Model A, Model B, Model C, and Model D (note that Model $\mathbf { D }$ is equivalent to the vanilla MCTS). The ablation study is performed on the 12 classic Nguyen’s benchmark problems, where the recovery rate of each model is calculated. The results of the ablation study are summarized in Table C.1. It is clear that module transplantation brings the largest gain in recovery rate. All the ablated models fail to uncover the Nguyen-12 equation (the most difficult case), where the coefficient 1/2 needs to be represented by mathematical operators and symbols, e.g., $x / ( x + x )$ , $y / ( y + y )$ , etc.
|
| 340 |
+
|
| 341 |
+
# D FREE FALLING BALLS WITH AIR RESISTANCE
|
| 342 |
+
|
| 343 |
+
This appendix section reveals more details on discovering the physical laws, in the context of relationships between height and time, for the cases of free-falling objects with air resistance based on multiple experimental ball-drop datasets (de Silva et al., 2020). The datasets contain the records of 11 different types of balls, as shown in Figure D.1, dropped from a bridge, collected at a $3 0 \mathrm { H z }$ sampling rate. The time between dropping and landing varies in each case due to the fact that air resistance has different effects on these free-dropping balls and induces divergent physical laws. Consequently, we consider each ball as an individual experiment and discover the physical law for each of them. The measurement dataset of a free-dropping ball is split into a training set (records from the first 2 seconds, 60 measurements) and a testing set (records after 2 seconds).
|
| 344 |
+
|
| 345 |
+
The physical laws of the three baseline models and distilled by the SPL machine from training data are exhibited in Table D.1. These discovered physical laws are then applied to forecast the height of the balls at the time slots in the testing dataset. These predictions, in comparison with the ground truth trajectory recorded, are shown in Figure D.2. The prediction error is shown in the Table 3 of the main text.
|
| 346 |
+
|
| 347 |
+
# E NONLINEAR DYNAMICS DISCOVERY
|
| 348 |
+
|
| 349 |
+
This appendix section elaborates more details on the two governing equation discovery experiments presented in the main text, including the datasets and full results.
|
| 350 |
+
|
| 351 |
+
Table C.1: Summary of the ablation study results.
|
| 352 |
+
|
| 353 |
+
<table><tr><td>Benchmark</td><td>Expression</td><td>SPL</td><td>Model A</td><td>Model B</td><td>Model C</td><td>Model D</td></tr><tr><td>Nguyen-1</td><td>+ +x 2 2</td><td>100%</td><td>100%</td><td>100%</td><td>14%</td><td>12%</td></tr><tr><td>Nguyen-2</td><td>x4 + +x</td><td>100%</td><td>100%</td><td>100%</td><td>0%</td><td>0%</td></tr><tr><td>Nguyen-3</td><td>+x4 +x² +x 25</td><td>100%</td><td>100%</td><td>100%</td><td>0%</td><td>0%</td></tr><tr><td>Nguyen-4</td><td>+x+x4+x²+x²+x 26</td><td>99%</td><td>96%</td><td>92%</td><td>0%</td><td>0%</td></tr><tr><td>Nguyen-5</td><td>sin(𝑥²)cos(x)-1</td><td>95%</td><td>95%</td><td>92%</td><td>92%</td><td>88%</td></tr><tr><td>Nguyen-6</td><td>sin(x²)+sin(x+x²)</td><td>100%</td><td>100%</td><td>96%</td><td>100%</td><td>100%</td></tr><tr><td>Nguyen-7</td><td>ln(x +1) +ln(x² + 1)</td><td>100%</td><td>100%</td><td>100%</td><td>100%</td><td>100%</td></tr><tr><td>Nguyen-8</td><td>√x</td><td>100%</td><td>100%</td><td>100%</td><td>100%</td><td>100%</td></tr><tr><td>Nguyen-9</td><td>sin(x)+sin(y²)</td><td>100%</td><td>100%</td><td>100%</td><td>100%</td><td>100%</td></tr><tr><td>Nguyen-10</td><td>2 sin(x) cos(y)</td><td>100%</td><td>100%</td><td>100%</td><td>0%</td><td>0%</td></tr><tr><td>Nguyen-11</td><td>x</td><td>100%</td><td>96%</td><td>96%</td><td>92%</td><td>87%</td></tr><tr><td>Nguyen-12</td><td>x4 2 + 1 -y</td><td>28%</td><td>0%</td><td>0%</td><td>0%</td><td>0%</td></tr><tr><td>Average</td><td></td><td>93.5%</td><td>90.58%</td><td>89.67%</td><td>49.83%</td><td>48.92%</td></tr></table>
|
| 354 |
+
|
| 355 |
+
Table D.1: Uncovered physics from the motions of free-falling balls by the SPL machine and three baseline models. Note that these formulas are the raw equations produced by SRL. Further simplification helps better parsimony of the formulas.
|
| 356 |
+
|
| 357 |
+
<table><tr><td>Type</td><td>Model</td><td>Expression</td></tr><tr><td>baseball</td><td>SPL Model-1 Model-2</td><td>H(t)= 47.8042 + 0.6253t- 4.5383t² H(t)= 47.682+ 1.456t- 5.629t² + 0.376t3 H(t)= 45.089- 8.156t + 5.448 exp(0t)</td></tr><tr><td>blue basketball</td><td>Model-3 SPL Model-1 Model-2</td><td>H(t)= 48.051- 183.467 log(cosh(0.217t)) H(t)= 46.4726-5.105t² + t³ -0.251t4 H(t)= 46.513-0.493t-3.912t² +0.03t H(t)= 43.522- 7.963t + 5.306 exp(0t)</td></tr><tr><td>green basketball</td><td>Model-3 SPL Model-1</td><td>H(t)= 46.402-84.791log(cosh(0.319t)) H(t)= 45.9087- 4.1465t² +log(cosh(1)) H(t)= 46.438-0.34t- 3.882t² - 0.055t3 H(t)= 43.512- 8.043t + 5.346 exp(0t)</td></tr><tr><td>volleyball</td><td>Model-2 Model-3 SPL Model-1 Model-2</td><td>H(t)= 46.391-124.424 log(cosh(0.263t)) H(t)= 48.0744-3.7772t² H(t)= 48.046+ 0.362t-4.352t² +0.218t</td></tr><tr><td>bowling ball</td><td>Model-3 SPL Model-1</td><td>H(t)= 45.32- 7.317t + 5.037exp(0t) H(t)= 48.124-107.816 log(cosh(0.27t)) H(t)= 46.1329-3.8173t² -0.2846t+4.14× 10-5 exp(20.7385t²)exp(-12.4538t3) H(t)= 46.139-0.091t-3.504t² -0.431t3</td></tr><tr><td>golf ball</td><td>Model-2 Model-3 SPL Model-1</td><td>H(t)= 43.336-8.525t + 5.676 exp(0t) H(t)= 46.342- 247.571log(cosh(0.189t)) H(t)= 49.5087-4.9633t² +log(cosh(t)) H(t)= 49.413+0.532t-5.061t²+0.102t3</td></tr><tr><td>tennis ball</td><td>Model-2 Model-3 SPL Model-1</td><td>H(t)= 46.356 -8.918t+ 5.964exp(0t) H(t)= 49.585-178.47log(cosh(0.23t)) H(t)= 47.8577-4.0574t² +log(cosh(0.121t))</td></tr><tr><td>whiffle ball</td><td>Model-2 Model-3 SPL Model-1</td><td>H(t)= 47.738+0.658t-4.901t²+0.325t H(t)= 45.016-7.717t+ 5.212 exp(0t) H(t)= 47.874- 114.19 log(cosh(0.269t)) H(t)= 4.1563t² -t + 47.0133exp(-0.1511t²) H(t)= 46.969+0.574t-4.505t²+0.522t</td></tr><tr><td>1 whiffle ball</td><td>Model-2 Model-3 SPL Model-1</td><td>H(t)= 44.259- 6.373t+ 4.689 exp(0t) H(t)= 47.062- 34.083log(cosh(0.462t)) H(t)= -18.6063 + 65.8583 exp(-0.0577t²) H(t)= 47.215+0.296t-4.379t²+0.421t3</td></tr><tr><td>2 yellow whiffle</td><td>Model-2 Model-3 SPL</td><td>H(t)= 44.443-6.744t + 4.813 exp(0t) H(t)= 47.255-38.29 log(cosh(0.447t)) H(t)= 148.9911/(log(cosh(t)) +3.065)-14.5828t²/(log(cosh(t)) +3.065)</td></tr><tr><td>ball</td><td>Model-1 Model-2 Model-3</td><td>+48.6092log(cosh(t))/(log(cosh(t)) + 3.065) H(t)= 48.613-0.047t-4.936t² +0.826t3 H(t)= 45.443- 6.789t+ 4.973exp(0t) H(t)= 48.594-12.49 log(cosh(0.86t))</td></tr><tr><td>orange whiffle ball</td><td>SPL Model-1 Model-2 Model-3</td><td>H(t)= -1.6626t + 47.8622 exp(-0.06815t²) H(t)= 47.836-1.397t-3.822t² +0.422t³ H(t)= 44.389-7.358t+ 5.152 exp(0t)</td></tr></table>
|
| 358 |
+
|
| 359 |
+

|
| 360 |
+
Figure D.1: The experimental balls that were dropped from the bridge (de Silva et al., 2020). From left to right: golf ball, tennis ball, whiffle ball 1, whiffle ball 2, baseball, yellow whiffle ball, orange whiffle ball, green basketball, and blue basketball. Volleyball is not shown here.
|
| 361 |
+
|
| 362 |
+

|
| 363 |
+
Figure D.2: Trajectories after 2 seconds predicted by uncovered physical laws.
|
| 364 |
+
|
| 365 |
+
# E.1 LORENZ SYSTEM
|
| 366 |
+
|
| 367 |
+
The 3-dimensional Lorenz system is governed by
|
| 368 |
+
|
| 369 |
+
$$
|
| 370 |
+
\begin{array} { l } { \dot { x } = \sigma ( y - x ) } \\ { \dot { y } = x ( \rho - z ) - y } \\ { \dot { z } = x y - \beta z } \end{array}
|
| 371 |
+
$$
|
| 372 |
+
|
| 373 |
+
with parameters $\sigma = 1 0$ , $\beta = 8 / 3$ , and $\rho = 2 8$ , under which the Lorenz attractor has two lobes and the system, starting from anywhere, makes cycles around one lobe before switching to the other and iterates repeatedly. The measurement data of the Lorenz system states in this experiment contains a clean signal with $5 \%$ Gaussian white noise. The derivatives of Lorenz’s state variables are unmeasured but numerically estimated and smoothed by the Savitzky–Golay filter. The noisy synthetic measurement data and numerically obtained derivatives are shown in Figure E.1.
|
| 374 |
+
|
| 375 |
+

|
| 376 |
+
Figure E.1: Lorenz system for the experiment. Noisy measurement data and numerically estimated derivatives smoothed by Savitzky–Golay filter.
|
| 377 |
+
|
| 378 |
+
Table E.1: Discovered governing equations for the Lorenz system.
|
| 379 |
+
|
| 380 |
+
<table><tr><td>Model</td><td>Discovered Governing Equations</td></tr><tr><td>Eureqa</td><td>x= -0.56-9.02x +9.01y y= -0.047+18.79x+1.86y-0.046xy-0.74xz = -3.04-2.23z +0.88xy</td></tr><tr><td>pySINDy</td><td>x = -0.46-9.18x +9.17y y= 22.32x+0.15y-0.85xz z = 6.04-2.83z +0.15x² + 0.81xy</td></tr><tr><td>NGGP</td><td>x = 0.0047 -10.02x + 10.01y - 0.007x² + 0.007xy - 0.37x/z - 0.00074x²y +0.00063x +0.00018x²z +0.00011xy² -6.59e-5xyz -0.00011y² y = 26.36x-1.5y-0.83xz -7.20x/z + 13.08y/z + 4.52e-5x³ -0.0038xz² -44.25x/z²+0.00028x/z -0.00017xz + 5.98e 6x32 = -0.64- 0.036y - 2.64z + 1.038xy+ 0.00021xz + 0.0011yz - 0.00021x/z</td></tr><tr><td>SPL</td><td>-8.04e-8y/x + 0.00022y/z - 8.04e-8z² - 0.00021xyz +0.00021xy/z -0.001y²z-0.00021y²/z+1.17y/z²-3.89e-7yz²/x+6.66e-9z²/x x = -9.966x + 9.964y y = 27.764x - 0.942y- 0.994xz</td></tr></table>
|
| 381 |
+
|
| 382 |
+
Table E.1 presents the distilled governing equations for the Lorenz system by the SPL machine compared with 3 baseline models. It is observed that the SPL machine uncovers the explicit form of equations accurately in the context of active terms, whereas Eureqa, pySINDy and NGGP yield several false-positive terms in the underlying governing equations. The predicted system responses (starting from a different initial condition) simulated from these uncovered equations are shown in Figure E.2. Although it is hard to reproduce the most accurate coefficients due to the tremendous errors induced by numerical differentiation of noisy measurement data as depicted in Figure E.1, the SPL machine is still capable of distilling the most concise symbolic combination of operators and variables to correctly formulate the parsimonious mathematical expressions that govern the Lorenz system dynamics. The predicted responses for the governing equations unearthed by the SPL machine simulate the system in a decent manner.
|
| 383 |
+
|
| 384 |
+

|
| 385 |
+
Figure E.2: Response prediction for 5 seconds by identified governing equations (dashed plots) under a different validation IC of Lorenz system, in comparison with the ground truth trajectory (grey).
|
| 386 |
+
|
| 387 |
+

|
| 388 |
+
Figure E.3: Double Pendulum system experiment and measurement data (Asseman et al., 2018): A. experiment setup. B. displacements of the two moving masses. C. model the system with $\theta _ { 1 }$ and $\theta _ { 2 }$ . D. angles of two masses transformed from displacements.
|
| 389 |
+
|
| 390 |
+
# E.2 MOUNTED DOUBLE PENDULUM SYSTEM
|
| 391 |
+
|
| 392 |
+
The second nonlinear dynamics discovery experiment is a chaotic double pendulum system (Asseman et al., 2018). The measured data, in form of videos, represents the chaotic motion of a double pendulum on the device shown in Figure E.3A filmed with a high-speed camera. The positional data is converted into angular form based on the geometry information (see the model shown in Figure E.3C). The governing equations can be derived using the Euler–Lagrange method, given by
|
| 393 |
+
|
| 394 |
+
$$
|
| 395 |
+
\begin{array} { r } { ( m _ { 1 } + m _ { 2 } ) l _ { 1 } \ddot { \theta } _ { 1 } + m _ { 2 } l _ { 2 } \ddot { \theta } _ { 2 } \cos ( \theta _ { 1 } - \theta _ { 2 } ) + m _ { 2 } l _ { 2 } \omega _ { 2 } ^ { 2 } \sin ( \theta _ { 1 } - \theta _ { 2 } ) + ( m _ { 1 } + m _ { 2 } ) g \sin ( \theta _ { 1 } ) = F _ { 1 } , } \\ { m _ { 2 } l _ { 2 } \ddot { \theta } _ { 2 } + m _ { 2 } l _ { 1 } \ddot { \theta } _ { 1 } \cos ( \theta _ { 1 } - \theta _ { 2 } ) - m _ { 2 } l _ { 1 } \omega _ { 1 } ^ { 2 } \sin ( \theta _ { 1 } - \theta _ { 2 } ) + m _ { 2 } g \sin ( \theta _ { 2 } ) = F _ { 2 } , } \end{array}
|
| 396 |
+
$$
|
| 397 |
+
|
| 398 |
+
which, by denoting $\omega$ as the velocity, can be converted to the following state-space form:
|
| 399 |
+
|
| 400 |
+
$$
|
| 401 |
+
\begin{array} { r l } & { \dot { \theta } _ { 1 } = \omega _ { 1 } , } \\ & { \dot { \theta } _ { 2 } = \omega _ { 2 } , } \\ & { \dot { \omega } _ { 1 } = c _ { 1 } \dot { \omega } _ { 2 } \cos ( \Delta \theta ) + c _ { 2 } \omega _ { 2 } ^ { 2 } \sin ( \Delta \theta ) + c _ { 3 } \sin ( \theta _ { 1 } ) + \mathcal { R } _ { 1 } ( \theta _ { 1 } , \theta _ { 2 } , \dot { \theta } _ { 1 } , \dot { \theta } _ { 2 } ) , } \\ & { \dot { \omega } _ { 2 } = c _ { 1 } \dot { \omega } _ { 1 } \cos ( \Delta \theta ) + c _ { 2 } \omega _ { 1 } ^ { 2 } \sin ( \Delta \theta ) + c _ { 3 } \sin ( \theta _ { 2 } ) + \mathcal { R } _ { 2 } ( \theta _ { 1 } , \theta _ { 2 } , \dot { \theta } _ { 1 } , \dot { \theta } _ { 2 } ) } \end{array}
|
| 402 |
+
$$
|
| 403 |
+
|
| 404 |
+
where $\Delta \theta = \theta _ { 1 } - \theta _ { 2 }$ , and $\mathcal { R } _ { 1 } ( \theta _ { 1 } , \theta _ { 2 } , \dot { \theta } _ { 1 } , \dot { \theta } _ { 2 } )$ and $\mathcal { R } _ { 2 } ( \theta _ { 1 } , \theta _ { 2 } , \dot { \theta } _ { 1 } , \dot { \theta } _ { 2 } )$ denote the damping terms for the last two differential equations.
|
| 405 |
+
|
| 406 |
+
The data source contains multiple video datasets. For this discovery, 5,000 denoised random subsamples from 5 datasets are used for training purposes, and 2,000 random sub-samples from another 2 datasets for validation, and 1 dataset for testing. Some prior knowledge guiding this discovery includes:
|
| 407 |
+
|
| 408 |
+
Table E.2: Discovered governing equations of the mounted double pendulum by the SPL model.
|
| 409 |
+
|
| 410 |
+
<table><tr><td>Phase</td><td>Expression</td></tr><tr><td>u1</td><td>-0.0991ω2 cos(△0) - 0.103ω2 sin(△0) - 69.274 sin(0i) + 0.515 cos(01)</td></tr><tr><td>2</td><td>-1.368ω1 c0s(△0) + 1.363ω² sin(△0) - 92.913 sin(02) + 0.032w1</td></tr></table>
|
| 411 |
+
|
| 412 |
+
1. the two terms $\dot { \omega } _ { 2 } \cos ( \Delta \theta )$ for $\dot { \omega } _ { 1 }$ and $\dot { \omega } _ { 1 } \cos ( \Delta \theta )$ for $\dot { \omega } _ { 2 }$ , which can be easily derived based on our prior knowledge on the system, are assumed known in the two governing equations. However, their coefficients are unknown and need to be estimated.
|
| 413 |
+
|
| 414 |
+
2. the remaining of the formulas are potentially comprised of the free combination of $\dot { \omega } _ { 1 } , \dot { \omega } _ { 2 }$ , $\omega _ { 1 } , \omega _ { 2 }$ , as well as the angles $( \theta _ { 1 } , \theta _ { 2 } , \Delta \theta )$ under the trigonometric functions $\cos ( \cdot )$ and $\sin ( \cdot )$ .
|
| 415 |
+
|
| 416 |
+
3. velocities and relative velocities of two masses, as well as their directions (sign function) might contribute to the damping.
|
| 417 |
+
|
| 418 |
+
Based on the above information, the candidate production rules for $\dot { \omega } _ { 1 }$ and $\dot { \omega } _ { 2 }$ equations are shown below, where non-terminal nodes are $V = \{ A , W , T , S \}$ and $C$ denotes the placeholder symbol for the constant coefficient values.
|
| 419 |
+
|
| 420 |
+
$$
|
| 421 |
+
\begin{array} { r l } & { A A + A , A A \times A , A C , A A + A , A W , } \\ & { W W \times W , W \omega _ { 1 } , W \omega _ { 2 } , W \dot { \omega } _ { 1 } , W \dot { \omega } _ { 2 } , } \\ & { A \cos ( T ) , A \sin ( T ) , T T + T , T T - T , T \theta _ { 1 } , T \theta _ { 2 } , } \\ & { A s i g n ( S ) , S S + S , S S - S , S \omega _ { 1 } , S \omega _ { 2 } , S \dot { \omega } _ { 1 } , S \dot { \omega } _ { 2 } , } \\ & { A \dot { \omega } _ { 1 } \cos ( \theta _ { 1 } - \theta _ { 2 } ) , A \dot { \omega } _ { 2 } \cos ( \theta _ { 1 } - \theta _ { 2 } ) . } \end{array}
|
| 422 |
+
$$
|
| 423 |
+
|
| 424 |
+
Note that our prior knowledge can be easily incorporated in the proposed SPL machine to improve the discovery performance, rather than relying on the free combination of mathematical operators and symbols. The hyperparameters are set as $\eta = 1$ , $t _ { m a x } = 2 0$ , and 40,000 episodes of training are regarded as one trail. 5 independent trials are performed and the equations with the highest validation scores are selected as the final result. The uncovered equations are shown in Table E.2. They are validated through interpolation on the testing set and compared with the smoothed derivatives, as shown in Figure E.4. The solution appears felicitous as the governing equations of the testing responses.
|
| 425 |
+
|
| 426 |
+
# F DISCUSSION AND FUTURE DIRECTIONS
|
| 427 |
+
|
| 428 |
+
The effectiveness of the proposed SPL machine is empowered by the following elements: (1) The use of MCTS enables the flexible representation of search space with customized computational grammars, composed of a finite set of mathematical operators and symbols, to guide the search tree expansion. (2) The exploration-exploitation trade-off nature of MCTS is remarkably useful for searching the optimal mathematical expression tree. (3) The key adjustments, including the greedy search, the adaptive-scaled rewarding, the reward regularizer, and the expression tree module transplantation, make it possible to efficiently uncover the best path to formulate complex equations. (4) The SPL machine straightforwardly accepts our prior or domain knowledge, or any sort of constraints of the tasks in the grammar design while leveraging great flexibility in expression formulation.
|
| 429 |
+
|
| 430 |
+
While SPL shows huge potential in both symbolic regression and governing equation discovery tasks, there are still some imperfections to be improved. In this appendix section, a few bottlenecks and their potential solutions are presented:
|
| 431 |
+
|
| 432 |
+
1. Computational cost. Computational cost for this framework is one of the major issues, especially when constant coefficient estimation is required. Evaluating the solution in the simulation phase happens very frequently for the MCTS algorithm where the policy selection relies heavily on a large number of historical rewards. However, the constant coefficient value estimation, which requires repeated calls for an optimization process and can be slow, is needed for evaluation purposes. In particular, the constant coefficient value is estimated via concurrently solving an optimization problem, e.g., by Powell’s conjugate direction method (Powell, 1964). For example, when the tree structure changes or is updated, the optimization of the constant coefficients should be re-performed simultaneously. The SPL machine is not the only symbolic regressor suffering from the computational cost in constant coefficient value estimation. In fact, the state-of-the-art symbolic regression model, the neural-guided GP (NGGP) (Mundhenk et al., 2021), becomes much slower in the Nguyen’s benchmark variant tasks (see Table E.3). The current implementation of the SPL machine tries to empirically avoid this issue by limiting the number of placeholders in a discovered expression and simplifying the expression before evaluation, but still cannot reach great efficiency. This bottleneck might be mitigated if parallel computing is introduced to the MCTS simulation phase.
|
| 433 |
+
|
| 434 |
+

|
| 435 |
+
Figure E.4: Discovered governing equations of the mounted double pendulum system on a different dataset in different time sections: in 2-8 seconds the two masses are in chaotic motions while in 30-36 seconds the masses tend to move periodically due to accumulative damping. $\ddot { \theta } _ { 1 }$ and ${ \ddot { \theta } } _ { 2 }$ are obtained through smoothed numerical differentiation and predicted from the discovered governing equations.
|
| 436 |
+
|
| 437 |
+
Table E.3: Average training time (in seconds) of SPL and NGGP in the Nguyen’s benchmark problems
|
| 438 |
+
|
| 439 |
+
<table><tr><td>Benchmark</td><td>SPL [s]</td><td>NGGP[s]</td></tr><tr><td>Nguyen-1</td><td>8.776</td><td>2.734</td></tr><tr><td>Nguyen-2</td><td>7.296</td><td>3.296</td></tr><tr><td>Nguyen-3</td><td>81.287</td><td>3.945</td></tr><tr><td>Nguyen-4</td><td>567.061</td><td>5.764</td></tr><tr><td>Nguyen-5</td><td>431.228</td><td>77.627</td></tr><tr><td>Nguyen-6</td><td>64.651</td><td>104.588</td></tr><tr><td>Nguyen-7</td><td>14.995</td><td>3.024</td></tr><tr><td>Nguyen-8</td><td>5.59</td><td>2.896</td></tr><tr><td>Nguyen-9</td><td>5.743</td><td>13.229</td></tr><tr><td>Nguyen-10</td><td>53.245</td><td>86.497</td></tr><tr><td>Nguyen-11</td><td>10.163</td><td>44.399</td></tr><tr><td>Nguyen-12</td><td>187.9</td><td>334.757</td></tr><tr><td>Nguyen-1c</td><td>452.734</td><td>362.075</td></tr><tr><td>Nguyen-2c</td><td>295.769</td><td>1188.215</td></tr><tr><td>Nguyen-5c</td><td>2178.891</td><td>1365.777</td></tr><tr><td>Nguyen-8c</td><td>77.892</td><td>129.349</td></tr><tr><td>Nguyen-9c</td><td>2001.402</td><td>3066.41</td></tr></table>
|
| 440 |
+
|
| 441 |
+
2. Graph modularity underexamined. The current design of the SPL training scheme does not leverage the full graph modularity: modules are reached by transforming a complete parse tree into a grammar. However, in some cases, there might be some influential modules appearing frequently as part of the tree. This type of graph modularity is described in the AIFeynman method (Udrescu et al., 2020). Deploying a more comprehensive graph modularity into the SPL machine will boost its efficacy in the complex equation and nonlinear dynamics discovery tasks.
|
| 442 |
+
|
| 443 |
+
3. Robustness against extreme data noise and scarcity. Although it is observed that this reinforcement learning-based method is able to unearth the parsimonious solution to the governing equations from synthetic or measurement data with a moderate level of noise and scarcity. It is not effective when the data condition is extreme, or if there are missing values that make it challenging to numerically calculate the state derivatives. It is reasonable to investigate the integration between the SPL framework with a differentiable surrogate model built upon neural networks (Long et al., 2018; Chen et al., 2021) or spline learning (Sun et al., 2021) for further robustness in nonlinear dynamics discovery tasks.
|
md/dev/akddwRG6EGi/akddwRG6EGi.md
ADDED
|
@@ -0,0 +1,416 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# High-dimensional Asymptotics of Feature Learning: How One Gradient Step Improves the Representation
|
| 2 |
+
|
| 3 |
+
Jimmy $\mathbf { B a } ^ { 1 }$ , Murat A. Erdogdu1, Taiji Suzuki2, Zhichao Wang3, Denny $\mathbf { W } \mathbf { u } ^ { 1 }$ , Greg Yang4
|
| 4 |
+
|
| 5 |
+
1University of Toronto and Vector Institute, 2University of Tokyo and RIKEN AIP, 3University of California, San Diego, 4Microsoft Research AI
|
| 6 |
+
|
| 7 |
+
{jba,erdogdu,dennywu}@cs.toronto.edu, taiji@mist.i.u-tokyo.ac.jp, zhw036@ucsd.edu, gregyang@microsoft.com
|
| 8 |
+
|
| 9 |
+
# Abstract
|
| 10 |
+
|
| 11 |
+
We study the first gradient descent step on the first-layer parameters $W$ in a twolayer neural network: √1N a⊤σ(W ⊤x), where W ∈ Rd×N , a ∈ RN $\textstyle { \frac { 1 } { n } } \sum _ { i = 1 } ^ { n } ( f ( { \dot { \mathbf { x } } } _ { i } ) - y _ { i } ) ^ { 2 }$ ed, and the training objective is the empiri. In the proportional asymptotic limit where $n , d , N \to \infty$ at the same rate, and an idealized student-teacher setting where the teacher $f ^ { * }$ is a single-index model, we compute the prediction risk of ridge regression on the conjugate kernel after one gradient step on $W$ with learning rate $\eta$ . We consider two scalings of the first step learning rate $\eta$ . For small $\eta$ , we establish a Gaussian equivalence property for the trained feature map, and prove that the learned kernel improves upon the initial random feature model, but cannot defeat the best linear model on the input. Whereas for sufficiently large $\eta$ , we prove that for certain $f ^ { * }$ , the same ridge estimator on trained features can go beyond this “linear regime” and outperform a wide range of (fixed) kernels. Our results demonstrate that even one gradient step can lead to a considerable advantage over random features, and highlight the role of learning rate scaling in the initial phase of training.
|
| 12 |
+
|
| 13 |
+
# 1 Introduction
|
| 14 |
+
|
| 15 |
+
We consider the training of a fully-connected two-layer neural network (NN) with $N$ neurons,
|
| 16 |
+
|
| 17 |
+
$$
|
| 18 |
+
f _ { \mathrm { N N } } ( \pmb x ) = \frac { 1 } { \sqrt { N } } \sum _ { i = 1 } ^ { N } a _ { i } \sigma ( \langle \pmb x , \pmb w _ { i } \rangle ) = \frac { 1 } { \sqrt { N } } \pmb a ^ { \top } \sigma ( \pmb W ^ { \top } \pmb x ) ,
|
| 19 |
+
$$
|
| 20 |
+
|
| 21 |
+
where $\pmb { x } \in \mathbb { R } ^ { d } , \pmb { W } \in \mathbb { R } ^ { d \times N } , \pmb { a } \in \mathbb { R } ^ { N }$ , $\sigma$ is the nonlinear activation function applied entry-wise, and the training objective is to minimize the empirical risk. Our analysis will be made in the proportional asymptotic limit, i.e., the number of training data $n$ , the input dimensionality $d$ , and the number of neurons $N$ jointly tend to infinity. Intuitively, this regime reflects the setting where the network width and data size are comparable, which is consistent with practical choices of model scaling.
|
| 22 |
+
|
| 23 |
+
When the first layer $W$ is fixed and the second layer $\textbf { \em a }$ is optimized, we arrive at a kernel model, where the kernel defined by features $\pmb { x } \mapsto \sigma ( \pmb { W } ^ { \top } \pmb { x } )$ (often called the hidden representation) is referred to as the conjugate kernel (CK) [Nea95]. When $W$ is randomly initialized, this model is an example of the random features (RF) model [RR08], the training and test performance of which has been extensively studied in the proportional limit [LLC18, MM22]. These precise characterizations reveal interesting phenomena also present in practical deep learning [BHMM19].
|
| 24 |
+
|
| 25 |
+
However, RF models do not fully explain the empirical success of NNs: one crucial advantage of deep learning is the ability to learn useful features [GDDM14, DCLT18] that “adapt” to the learning problem [Suz18]. In fact, recent works have shown that such adaptivity enables NNs optimized by gradient descent to outperform a wide range of linear/kernel estimators [AZL19, GMMM19]. While many explanations of this separation have been proposed, our starting point is the empirical finding that “non-kernel” behavior often occurs in the early phase of NN optimization, especially under large learning rates $[ \mathrm { J } \mathrm { S F } ^ { + } 2 0 $ , $\mathrm { F D P } ^ { + } 2 0 ]$ ]. The goal of this work is to answer the following question:
|
| 26 |
+
|
| 27 |
+
Can we precisely capture the emergence of feature learning in the early phase of gradient descent, and demonstrate its improvement over the initial (fixed) kernel in the proportional limit?
|
| 28 |
+
|
| 29 |
+
# 1.1 Contributions
|
| 30 |
+
|
| 31 |
+
Motivated by the above observations, we investigate a simplified scenario of the “early phase” of learning: how the first gradient step on the first-layer parameters $W$ impacts the representation of the two-layer NN (1.1). Specifically, we consider regression with the squared loss (MSE), and a studentteacher setting in the proportional asymptotic limit; we aim to characterize the prediction risk of the kernel ridge regression estimator on top of the first-layer CK feature $\pmb { x } \mapsto \sigma ( \pmb { W } ^ { \top } \pmb { x } )$ , before and after one gradient descent step on the empirical risk (starting from Gaussian initialization).
|
| 32 |
+
|
| 33 |
+
Following prior works on the precise asymptotics of RF regression $[ \mathrm { G L K ^ { + } } 2 0$ , DL20], we focus on the setting where the input $_ { \textbf { \em x } }$ is Gaussian and the teacher $f ^ { * }$ is a single-index model. In this case, the prediction risk of a large class of RF/kernel ridge regression estimators is lower-bounded by the $L ^ { 2 }$ -norm of the “nonlinear” component of the teacher $\| \mathsf { P } _ { > 1 } f ^ { * } \| _ { L ^ { 2 } } ^ { 2 }$ , i.e., they only learn linear functions on the input. After one gradient step on $W$ , we compute the CK ridge estimator using separate training data, and compare its prediction risk against this linear lower bound. Our analysis will be made under two choices of learning rate scalings:
|
| 34 |
+
|
| 35 |
+
• Small lr: $\eta = \Theta ( 1 )$ . In Section 4, we extend the Gaussian Equivalence Theorem (GET) in [HL20] to the updated feature map after one gradient descent step on W with learning rate $\overset { \cdot } { \eta } = \Theta ( 1 )$ ; this allows us to precisely characterize the prediction risk using random matrix theoretical tools. We prove that after one gradient step, the ridge regression estimator on the learned CK features already exhibits nontrivial improvement over the initial RF ridge regression model (see pink curve in Figure 1), but it remains in the “linear regime” and cannot outperform the best linear estimator on the input (black dashed line).
|
| 36 |
+
|
| 37 |
+

|
| 38 |
+
Figure 1: Prediction risk of ridge regression on trained CK features (erf) after one feature learning step. Markers represent empirical simulations and solid curves are predicted asymptotic values; red line indicates $\Theta ( d / n )$ rate.
|
| 39 |
+
|
| 40 |
+
• Large lr: $\eta = \Theta ( \sqrt { N } )$ . In Section 5, we analyze a larger learning rate that coincides with the maximal update parameterization in [YH20]. For certain target functions $f ^ { * }$ , we prove that kernel ridge regression after one feature learning step can achieve lower risk than the lower bound $\| \mathsf { P } _ { > 1 } f ^ { * } \| _ { L ^ { 2 } } ^ { 2 }$ ; thus, it outperforms a wide range of kernel estimators (see purple curve in Figure 1).
|
| 41 |
+
|
| 42 |
+
# 1.2 Related works
|
| 43 |
+
|
| 44 |
+
Asymptotics of kernel regression. Recent works provided precise analysis of RF and kernel models in the proportional limit $[ \mathrm { G L K ^ { + } } 2 0$ , DL20, LCM20, AP20, MM22]. These results typically build upon analyses of the spectrum of kernel matrices, a key ingredient in which is the “linearization” of nonlinear random matrices via Taylor expansion [EK10] or orthogonal polynomials [CS13, PW17].
|
| 45 |
+
|
| 46 |
+
Consequently, a large class of kernel models are essentially linear in the proportional asymptotic limit [LR20, BMR21]. In the case of RF models, a similar property is captured by the Gaussian Equivalence Theorem [GMKZ20, HL20, $\mathrm { G L R } ^ { + } 2 1 ]$ , which roughly states that RF estimators achieve the same prediction risk as a (noisy) linear model. For inputs with unit norm, [GMMM21, MMM21] showed that sample size $n = \Omega ( \dot { d } ^ { 2 } )$ is required to go beyond this “linear” regime. As we will see in certain settings, such a limitation can also be overcome (in the $n \asymp d$ scaling) by training the feature map for one gradient step with a sufficiently large learning rate.
|
| 47 |
+
|
| 48 |
+
Advantage of NNs over fixed kernels. It is well-known that under a specific initialization, the learning dynamics of overparameterized NNs can be described by the neural tangent kernel (NTK) [JGH18]. However, the NTK description essentially “freezes” the model around its initialization [COB19], and thus does not explain the presence of feature learning in NNs [YH20].
|
| 49 |
+
|
| 50 |
+
In fact, various works have shown that deep learning is more powerful than kernel methods in terms of approximation and estimation ability [Bac17, Suz18, IF19, SH20, GMMM20]. Moreover, in some specialized settings, NNs optimized with gradient-based methods can outperform the NTK (or more generally any kernel estimators) in terms of generalization error [AZL19, WLLM19, GMMM19, LMZ20, DM20, SA20, AZL20, RGKZ21, KWLS21, $\mathbf { A B A B } ^ { + } 2 1 ]$ (see [MKAS21, Table 2] for a survey). These results often require a careful analysis of the landscape (e.g., properties of global optimum) or optimization dynamics; in contrast, our goal is to precisely characterize the first gradient step and demonstrate a similar separation.
|
| 51 |
+
|
| 52 |
+
Early phase of NN optimization. Recent empirical studies suggest that properties of the final trained model is strongly influenced by the early stages of optimization [GAS19, LM20, PPVF21], and the NTK evolves most rapidly in the first few epochs $[ \mathrm { F D P } ^ { + } 2 0 ]$ . Large learning rate in the initial steps can impact the conditioning of loss surface $[ \mathrm { J } \mathrm { S } \mathrm { F } ^ { + } 2 0 $ , $\mathbf { C K L } ^ { + } 2 1 ]$ and potentially improve the generalization performance [LWM19, $\mathrm { L B D } ^ { + } 2 0 ]$ . Under structural assumptions on the data, it has been proved that one gradient step with sufficiently large learning rate can drastically decrease the training loss [CLB21], extract task-relevant features [DM20, FCB22], or escape the trivial stationary point at initialization [HCG21]. While these works also highlight the benefit of one feature learning step, to our knowledge this advantage has not been precisely characterized in the proportional regime (where the performance of RF models has been extensively studied).
|
| 53 |
+
|
| 54 |
+
# 2 Problem setup and assumptions
|
| 55 |
+
|
| 56 |
+
Notations. Throughout this paper, $\| \cdot \|$ denotes the $\ell _ { 2 }$ -norm for vectors and the $\ell _ { 2 } \to \ell _ { 2 }$ operator norm for matrices, and $\| \cdot \| _ { F }$ is the Frobenius norm. For matrix $M \in \mathbb { R } ^ { n \times n }$ , $\textstyle \operatorname { t r } ( M ) = { \frac { 1 } { n } } \operatorname { T r } ( M )$ is the normalized trace. $\mathcal { O } _ { d } ( \cdot )$ and $o _ { d } ( \cdot )$ stand for the standard big-O and little-o notations, where the subscript highlights the asymptotic variable; we write $\tilde { \mathcal { O } } ( \cdot )$ when the (poly-)logarithmic factors are ignored. $\mathcal { O } _ { d , \mathbb { P } } ( \cdot )$ (resp. $o _ { d , \mathbb { P } } ( \cdot ) _ { , }$ ) represents big-O (resp. little-o) in probability as $d \to \infty$ . $\Omega ( \cdot ) , \Theta ( \cdot )$ are defined analogously. $\Gamma$ is the standard Gaussian distribution in $\mathbb { R } ^ { d }$ . Given $f : \mathbb { R } ^ { d } \mathbb { R }$ , we denote its $L ^ { p }$ -norm w.r.t. $\Gamma$ as $\| f \| _ { L ^ { p } ( \mathbb { R } ^ { d } , \Gamma ) }$ , which we abbreviate as $\| f \| _ { L ^ { p } }$ when the context is clear.
|
| 57 |
+
|
| 58 |
+
# 2.1 Training procedure
|
| 59 |
+
|
| 60 |
+
Gradient descent on the 1st layer. Given training examples $\{ ( \pmb { x } _ { i } , y _ { i } ) \} _ { i = 1 } ^ { n }$ , we learn the two-layer NN (1.1) by minimizing the empirical risk: $\begin{array} { r } { { \mathcal { L } } ( f ) = \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \ell ( f ( \pmb { x } _ { i } ) , \overleftarrow { y _ { i } } ) } \end{array}$ , where $\ell$ is the squared loss $\textstyle \ell ( x , y ) = { \frac { 1 } { 2 } } ( x - y ) ^ { 2 }$ . As previously remarked, fixing the first layer $W$ at random initialization and learning the second layer $^ { a }$ yields an RF model, which is a convex problem with closed-form solution. In contrast, we are interested in learning the feature map (representation); hence we first fix $^ { a }$ (at initialization) and perform gradient descent on $W$ . We write the initialized first-layer as $W _ { 0 }$ , and the weights after one gradient step as $W _ { 1 }$ . The gradient update, which we refer to as the feature learning step, with learning rate $\eta$ is given as: $\pmb { W } _ { 1 } = \pmb { W } _ { 0 } + \eta \sqrt { N } \cdot \pmb { G } _ { 0 }$ where
|
| 61 |
+
|
| 62 |
+
$$
|
| 63 |
+
G _ { 0 } : = \frac { 1 } { n } X ^ { \top } \left[ \left( \frac { 1 } { \sqrt { N } } \left( y - \frac { 1 } { \sqrt { N } } \sigma ( X W _ { 0 } ) \pmb { a } \right) \pmb { a } ^ { \top } \right) \odot \sigma ^ { \prime } ( X W _ { 0 } ) \right] ,
|
| 64 |
+
$$
|
| 65 |
+
|
| 66 |
+
in which $\odot$ is the Hadamard product, $\sigma ^ { \prime }$ is the derivative of $\sigma$ (acting entry-wise), and we denoted the input feature matrix √ $\pmb { X } \in \mathbb { R } ^ { n \times d }$ , and the corresponding label vector $\boldsymbol { y } \in \mathbb { R } ^ { n }$ . We remark that the $\sqrt { N }$ -scaling in front of $\eta$ accounts for the $\scriptstyle { \frac { 1 } { \sqrt { N } } }$ -prefactor in our definition of two-layer NN (1.1).
|
| 67 |
+
|
| 68 |
+
Ridge regression for the 2nd layer. After obtaining the updated weights $W _ { 1 }$ , we evaluate the quality of the new CK features by computing the prediction risk of the kernel ridge regression estimator on top of the first-layer representation. Note that if ridge regression is performed on the same data $\boldsymbol { X }$ , then after one feature learning step, $W _ { 1 }$ is no longer independent of $\boldsymbol { X }$ , which significantly complicates the analysis. To circumvent this difficulty, we estimate the regression coefficients $\hat { \textbf { \textit a } }$ using a new set of training data $\{ \tilde { \pmb { x } } _ { i } , \tilde { y } _ { i } \} _ { i = 1 } ^ { n }$ , which for simplicity we assume to have the same size as the original dataset. This can be interpreted as the representation being “pretrained” on separate data before the ridge regression estimator is learned.
|
| 69 |
+
|
| 70 |
+
Denoting the feature matrix on the fresh training set $\{ \tilde { X } , \tilde { y } \}$ as $\begin{array} { r } { \Phi : = \frac { 1 } { \sqrt { N } } \sigma ( \tilde { { X } } W _ { 1 } ) \in \mathbb { R } ^ { n \times N } } \end{array}$ , the CK ridge regression estimator can be obtained by solving $\begin{array} { r } { \hat { \pmb { a } } = \mathrm { a r g m i n } _ { \pmb { a } } \left\{ \frac { 1 } { n } \| \tilde { \pmb { y } } - \pmb { \Phi } \pmb { a } \| ^ { 2 } + \frac { \lambda } { N } \| \pmb { a } \| ^ { 2 } \right\} } \end{array}$ .
|
| 71 |
+
|
| 72 |
+
# 2.2 Student-teacher setting and main assumptions
|
| 73 |
+
|
| 74 |
+
Given a target function (teacher model) $f ^ { * }$ and a learned model $\hat { f }$ , we evaluate the model performance using the prediction risk: $\mathcal { R } ( \hat { f } ) = \mathbb { E } _ { \pmb { x } } ( \hat { f } ( \pmb { x } ) - f ^ { * } ( \pmb { x } ) ) ^ { 2 } = \| \hat { f } - f ^ { * } \| _ { L ^ { 2 } } ^ { 2 }$ , where the expectation is taken over the test data from the same training distribution.
|
| 75 |
+
|
| 76 |
+
We utilize the orthogonal decomposition of the activation function $\sigma$ . Define the coefficients
|
| 77 |
+
|
| 78 |
+
$$
|
| 79 |
+
\mu _ { 0 } = \mathbb { E } [ \sigma ( z ) ] , \quad \mu _ { 1 } = \mathbb { E } [ z \sigma ( z ) ] , \quad \mu _ { 2 } = { \sqrt { \mathbb { E } [ \sigma ( z ) ^ { 2 } ] - \mu _ { 0 } ^ { 2 } - \mu _ { 1 } ^ { 2 } } } , \quad { \mathrm { ~ w h e r e ~ } } z \sim { \mathcal { N } } ( 0 , 1 ) .
|
| 80 |
+
$$
|
| 81 |
+
|
| 82 |
+
This implies $\sigma ( z ) = \mu _ { 0 } + \mu _ { 1 } z + \sigma _ { \bot } ( z )$ , where $\mathbb { E } [ \sigma _ { \perp } ( z ) ] = \mathbb { E } [ z \sigma _ { \perp } ( z ) ] = 0$ , and $\mathbb { E } [ \sigma _ { \perp } ( z ) ^ { 2 } ] = \mu _ { 2 } ^ { 2 }$ .
|
| 83 |
+
|
| 84 |
+
Similarly, for square integrable target function $f ^ { * }$ , we have the orthogonal decomposition
|
| 85 |
+
|
| 86 |
+
$$
|
| 87 |
+
f ^ { * } ( \pmb { x } ) = \mu _ { 0 } ^ { * } + \mu _ { 1 } ^ { * } \langle \pmb { x } , \pmb { \beta } _ { * } \rangle + \pmb { \mathrm { P } } _ { > 1 } f ^ { * } ( \pmb { x } ) , \mu _ { 1 } ^ { * } \pmb { \beta } _ { * } = \mathbb { E } [ \pmb { x } f ^ { * } ( \pmb { x } ) ] ,
|
| 88 |
+
$$
|
| 89 |
+
|
| 90 |
+
where $\mathsf { P } _ { > 1 }$ is the projector orthogonal to constant and linear functions in $L ^ { 2 } ( \mathbb { R } ^ { d } , \Gamma )$ , which implies that ${ \mathbb E } [ \mathsf { P } _ { > 1 } f ^ { * } ( { \pmb x } ) ] = 0 , { \mathbb E } [ { \pmb x } \mathsf { P } _ { > 1 } \bar { f } ^ { * } ( { \pmb x } ) ] = { \mathbf 0 }$ . As $d \to \infty$ , quantities defined in (2.3) satisfy $\| \beta _ { * } \| =$ 1, $\| \mathsf { P } _ { > 1 } f ^ { * } \| _ { L ^ { 2 } } \to \mu _ { 2 } ^ { * }$ , where $\mu _ { 0 } ^ { * } , \mu _ { 1 } ^ { * } , \mu _ { 2 } ^ { * }$ are bounded constants. Intuitively, $\mu _ { 0 } ^ { * } , \mu _ { 1 } ^ { * }$ , and $\mu _ { 2 } ^ { * }$ can be interpreted as the “magnitude” of the constant, linear, and nonlinear components of $f ^ { * }$ , respectively.
|
| 91 |
+
|
| 92 |
+
# Assumption 1.
|
| 93 |
+
|
| 94 |
+
1. Proportional limit. $n , d , N \to \infty , n / d \to \psi _ { 1 } , N / d \to \psi _ { 2 }$ , where $\psi _ { 1 } , \psi _ { 2 } \in ( 0 , \infty )$ .
|
| 95 |
+
|
| 96 |
+
2. Gaussian initialization. $\sqrt { d } \cdot [ \boldsymbol { W } _ { 0 } ] _ { i j } \stackrel { \mathrm { i . i . d . } } { \sim } \mathcal { N } ( 0 , 1 ) , ~ \sqrt { N } \cdot [ \boldsymbol { a } ] _ { j } \stackrel { \mathrm { i . i . d . } } { \sim } \mathcal { N } ( 0 , 1 ) , f o r ~ i \in [ d ] , j \in [ N ] .$
|
| 97 |
+
|
| 98 |
+
3. Normalized activation. The activation function $\sigma$ has $\lambda _ { \sigma }$ -bounded first three derivatives almost surely. In addition, $\sigma$ satisfies $\mu _ { 0 } = 0$ and $\mu _ { 1 } , \mu _ { 2 } \neq 0$ defined in (2.2).
|
| 99 |
+
|
| 100 |
+
4. Single-index teacher. Labels are generated as $y _ { i } = f ^ { * } ( { \pmb x } _ { i } ) + \varepsilon _ { i }$ , where $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ i.i.d. ∼ $\mathcal { N } ( 0 , \pmb { I } )$ , and $\varepsilon _ { i }$ is i.i.d. sub-Gaussian noise with mean 0 and variance $\sigma _ { \varepsilon } ^ { 2 }$ . The teacher $f ^ { * } ( { \pmb x } ) = \sigma ^ { * } ( \langle { \pmb x } , { \pmb \beta } _ { * } \rangle )$ , where $\beta _ { * } \in \mathbb { R } ^ { d }$ with $\| \beta _ { * } \| = 1$ , and $\sigma ^ { * }$ is Lipschitz with $\mu _ { 0 } ^ { * } = 0 ;$ , $\mu _ { 1 } ^ { * } \neq 0$ as defined in (2.3).
|
| 101 |
+
|
| 102 |
+
Remark. We make the following comments on the above assumptions.
|
| 103 |
+
|
| 104 |
+
• Following [HL20], we assume smooth centered activation to simplify the computation; empirical evidence suggests that similar result holds beyond this condition (e.g. $I L G C ^ { + } 2 I J ,$ . We also expect the Gaussian input assumption may be replaced by weaker orthogonality conditions as in [FW20].
|
| 105 |
+
|
| 106 |
+
• The single-index setting has been extensively studied in the proportional regime $I G L K ^ { + } 2 0$ , DL20, HL20]. However, prior works only considered training the coefficients $\textbf { \em a }$ on top of fixed feature map, and such RF models cannot efficiently learn a single-index $f ^ { * }$ in high dimensions [YS19].
|
| 107 |
+
|
| 108 |
+
Under Assumption 1, a relatively large sample size corresponds to larger $\psi _ { 1 }$ , and a relatively large network width corresponds to larger $\psi _ { 2 }$ . The proportional scaling of $n , d , N$ implies that the model width is not significantly larger than the training set size, in contrast to the polynomial overparameterization often required in NTK analyses [DZPS19], which may be less realistic in practical settings.
|
| 109 |
+
|
| 110 |
+
Importantly, the initialization of our two-layer NN (1.1) resembles the mean-field parameterization [MMN18, CB18]: the second layer is divided by an additional $\sqrt { N }$ -factor compared to the kernel (NTK) scaling — this ensures that $f _ { \mathrm { N N } } ( \pmb { x } ) =$ $o _ { d , \mathbb { P } } ( 1 )$ at initialization and enables feature learning (see [YH20, Corollary 3.10]). As an illustrative example in Figure 2, we plot the gradient descent trajectory of the first-layer parameters $W$ in two coordinates. Observe that under the meanfield parameterization (main figure), the neurons travel away from the initialization and align with the target function (black dashed lines), whereas in the NTK parameterization (subfigure, which omits the $\scriptstyle { \frac { 1 } { \sqrt { N } } }$ -prefactor), the parameters remain close to their initialization and hence do not learn useful features.
|
| 111 |
+
|
| 112 |
+

|
| 113 |
+
Figure 2: 2D visualization of optimization trajectory under mean-field (main) and NTK (subfigure) parameterizations. $f ^ { * }$ consists of two ReLU neurons and the student is a two-layer ReLU neural network. Darker color indicates earlier in training, and vice versa. We set $d = 5 1 2$ , $\psi _ { 1 } = \psi _ { 2 } =$ 10; both models are optimized until training losses are below $1 0 ^ { - 3 }$ .
|
| 114 |
+
|
| 115 |
+
# 3 Preliminary results
|
| 116 |
+
|
| 117 |
+
# 3.1 Lower bound for kernel ridge regression
|
| 118 |
+
|
| 119 |
+
To illustrate the benefits of feature learning, we compare the prediction risk of ridge regression on the trained CK (after one gradient step) against that on the initial RF and fixed kernels. Specifically, given training data $\{ \pmb { x } _ { i } , y _ { i } \} _ { i = 1 } ^ { n }$ , we consider the following classes of kernel models for comparison.
|
| 120 |
+
|
| 121 |
+
• Random features model. We introduce two RF kernels associated with (1.1) at initialization: the conjugate kernel (CK) defined by features $\begin{array} { r } { \phi _ { \mathrm { C K } } ( \pmb { x } ) = \frac { 1 } { \sqrt { N } } \sigma ( \pmb { W } _ { 0 } ^ { \top } \pmb { x } ) \in \mathbb { R } ^ { N } } \end{array}$ , and the neural tangent kernel (NTK) [JGH18] defined by features $\begin{array} { r } { \phi _ { \mathrm { N T K } } ( \pmb { x } ) \overset { \cdot } { = } \frac { 1 } { \sqrt { N d } } \pmb { \mathrm { V e c } } \big ( \pmb { \sigma } ^ { \prime } ( \pmb { W } _ { 0 } ^ { \top } \pmb { x } ) \pmb { x } ^ { \top } \big ) \in \mathbb { R } ^ { N d } } \end{array}$ . Given a feature map $\mathbf { R F } \in \{ \mathbf { C K } , \mathbf { N T K } \}$ , the RF ridge regression estimator can be written as
|
| 122 |
+
|
| 123 |
+
$$
|
| 124 |
+
\hat { f } _ { \mathrm { R F } } ( \boldsymbol { x } ) = \langle \phi _ { \mathrm { R F } } ( \boldsymbol { x } ) , \hat { a } \rangle , \hat { a } = \operatorname * { a r g m i n } _ { a \in \mathbb { R } ^ { N } } \Big \{ \frac { 1 } { n } \sum _ { i = 1 } ^ { n } ( y _ { i } - \langle \phi _ { \mathrm { R F } } ( \boldsymbol { x } _ { i } ) , a \rangle ) ^ { 2 } + \frac { \lambda } { N } \| a \| ^ { 2 } \Big \} .
|
| 125 |
+
$$
|
| 126 |
+
|
| 127 |
+
• Rotation invariant kernel model. Consider the inner-product kernel: $\begin{array} { r } { k ( \pmb { x } , \pmb { y } ) = g \bigg ( \frac { \langle \pmb { x } , \pmb { y } \rangle } { d } \bigg ) } \end{array}$ , and the Euclidean distance kernel: $\scriptstyle k ( { \pmb x } , { \pmb y } ) = g \left( { \frac { \| { \pmb x } - { \pmb y } \| ^ { 2 } } { d } } \right)$ , where $g$ satisfies the smoothness conditions in [EK10]. Denoting the associated RKHS with $\mathcal { H }$ , the kernel ridge estimator is given by
|
| 128 |
+
|
| 129 |
+
$$
|
| 130 |
+
\hat { f } _ { \mathrm { k e r } } = \underset { f \in \mathcal { H } } { \operatorname { a r g m i n } } \left\{ \frac { 1 } { n } \sum _ { i = 1 } ^ { n } ( y _ { i } - f ( x _ { i } ) ) ^ { 2 } + \lambda \Vert f \Vert _ { \mathcal { H } } ^ { 2 } \right\} \Rightarrow \hat { f } _ { \mathrm { k e r } } ( \boldsymbol { x } ) = k ( \boldsymbol { x } , \boldsymbol { X } ) ^ { \top } ( \boldsymbol { K } + \lambda \boldsymbol { I } ) ^ { - 1 } \boldsymbol { y } .
|
| 131 |
+
$$
|
| 132 |
+
|
| 133 |
+
We write the prediction risk of the above kernel estimators as $\mathcal { R } _ { \mathrm { C K } } ( \lambda ) , \mathcal { R } _ { \mathrm { N T K } } ( \lambda ) , \mathcal { R } _ { \mathrm { k e r } } ( \lambda )$ , respectively. The following lower bound on the prediction risk is a simple combination of existing results.
|
| 134 |
+
|
| 135 |
+
Proposition 1 ([HL20, MZ20, BMR21]). Under Assumption $I$ , we have
|
| 136 |
+
|
| 137 |
+
$$
|
| 138 |
+
\operatorname* { i n f } _ { \lambda > 0 } \operatorname* { m i n } \{ \mathcal { R } _ { \mathrm { C K } } ( \lambda ) , \mathcal { R } _ { \mathrm { N T K } } ( \lambda ) , \mathcal { R } _ { \mathrm { k e r } } ( \lambda ) \} \ge \| P _ { > 1 } f ^ { * } \| _ { L ^ { 2 } } ^ { 2 } + o _ { d , \mathbb { P } } ( 1 ) ,
|
| 139 |
+
$$
|
| 140 |
+
|
| 141 |
+
where $P _ { > 1 }$ denotes the projector orthogonal to constant and linear functions in $L ^ { 2 } ( \mathbb { R } ^ { d } , \Gamma )$ .
|
| 142 |
+
|
| 143 |
+
This proposition implies that in the proportional limit, ridge regression on the RF or rotationally invariant kernels defined above does not outperform the best linear estimator on the input – it cannot achieve vanishing risk unless the target function is linear $( \| \mathsf { P } _ { > 1 } f ^ { * } \| _ { L ^ { 2 } } = 0 )$ ). In the following, we compare the prediction risk of the ridge estimator on trained features against this lower bound.
|
| 144 |
+
|
| 145 |
+
# 3.2 Almost rank-1 property of the gradient matrix
|
| 146 |
+
|
| 147 |
+
Before we analyze the prediction risk of the ridge regression estimator on the trained CK, we first need to understand the gradient matrix $G _ { 0 }$ in (2.1). The following proposition shows that the first gradient step on $W$ can be approximated in operator norm by a rank-1 matrix under Assumption 1.
|
| 148 |
+
|
| 149 |
+
Proposition 2. Define $\begin{array} { r } { G _ { 0 } : = \frac { 1 } { \eta \sqrt { N } } ( W _ { 1 } - W _ { 0 } ) } \end{array}$ and a rank-1 matrix $\begin{array} { r } { \pmb { A } : = \frac { \mu _ { 1 } } { n \sqrt { N } } \pmb { X } ^ { \top } \pmb { y } \pmb { a } ^ { \top } } \end{array}$ . Given Assumption $I$ , there exist some constants $c , C > 0$ such that for all large $n , N$ , and $d$ , we have
|
| 150 |
+
|
| 151 |
+
$$
|
| 152 |
+
\| G _ { 0 } - A \| \leq \frac { C \log ^ { 2 } n } { \sqrt { n } } \cdot \| G _ { 0 } \| ,
|
| 153 |
+
$$
|
| 154 |
+
|
| 155 |
+
with probability at least 1 − ne−c log2 n.
|
| 156 |
+
|
| 157 |
+
Scaling of learning rate $\eta$ . Based on the above proposition, we can now specify an appropriate learning rate $\eta$ such that the change in the first-layer weights after one gradient descent step is neither insignificant nor unreasonably large. Assumption 1 implies that, for proportional √ $n , d , N$ , the initial weight matrix satisfies $\| \pmb { W } _ { 0 } \| = \Theta _ { d , \mathbb { P } } ( 1 ) , \| \pmb { W } _ { 0 } \| _ { F } = \Theta _ { d , \mathbb { P } } ( \sqrt { d } )$ , and due to Proposition 2, the first gradient step satisfies $\sqrt { N } \lVert G _ { 0 } \rVert = \Theta _ { d , \mathbb { P } } ( 1 ) , \sqrt { N } \lVert G _ { 0 } \rVert _ { F } = \Theta _ { d , \mathbb { P } } ( 1 )$ .
|
| 158 |
+
|
| 159 |
+
In light of the above scaling, if we write $\eta = \Theta ( N ^ { \alpha } )$ , then $\alpha \geq 0$ is required so that the change in the weight matrix is non-negligible (one may verify that for $\eta = o _ { d } ( 1 )$ , the test performance of kernel ridge regression remains unchanged after one GD step). On the other hand, when $\alpha > 1 / 2$ , the gradient update “overwhelms” the initialized parameters $W _ { 0 }$ , and the preactivation feature $\langle \pmb { x } , \pmb { w } _ { i } \rangle$ in the NN (1.1) becomes unbounded as $N \infty$ . This motivates us to consider the following two egimes of learning rate scaling.
|
| 160 |
+
|
| 161 |
+
In Section 4, we consider small step size $\eta = \Theta ( 1 )$ , which is parallel to common practice in NN optimization1. Whereas in Section 5, we analyze the larger step size $\eta = \Theta ( \sqrt { N } )$ , which resembles the learning rate scaling in the maximal update parameterization in [YH20]; in particular, from Lemma 10 in Appendix B.1, one can easily verify that given data point $\mathbf { \boldsymbol { x } } \sim \mathcal { N } ( \mathbf { \boldsymbol { 0 } } , \mathbf { \boldsymbol { I } } )$ , the change in each coordinate of the feature vector is roughly of the same order as its initialized magnitude, that is, for $i \in [ N ]$ , $\big | \sigma ( W _ { 1 } ^ { \top } \pmb { x } ) - \sigma ( \pmb { W } _ { 0 } ^ { \top } \pmb { x } ) \big | _ { i } \asymp \mathsf { \bar { | } } \bar { \sigma ( \pmb { W } _ { 0 } ^ { \top } \pmb { x } ) \big | _ { i } } = \tilde { \Theta } ( 1 )$ with probability 1 as $N \to \infty$ .
|
| 162 |
+
|
| 163 |
+
# 4 $\eta = \Theta ( 1 )$ : improvement over the initial CK
|
| 164 |
+
|
| 165 |
+
From Proposition 2, we observe that the dominant rank-1 direction in the first-step gradient matrix $G _ { 0 }$ contains information of the teacher model $f ^ { * }$ (through label vector $\textbf { { y } }$ ). Intuitively, this indicates that the learned feature map after one GD step $\mathbf { \boldsymbol { x } } \mapsto \bar { \sigma } ( \mathbf { \boldsymbol { W } } _ { 1 } ^ { \top } \mathbf { \boldsymbol { x } } )$ can “adapt” to $f ^ { * }$ , and hence we may expect the ridge regression estimator on the trained CK to achieve better performance. In this section, we precisely characterize the CK prediction risk under the small learning rate $\eta = \Theta ( 1 )$ . We first introduce the Gaussian equivalence property which will be useful in the risk computation.
|
| 166 |
+
|
| 167 |
+
# 4.1 The Gaussian equivalence property
|
| 168 |
+
|
| 169 |
+
The Gaussian Equivalence Theorem (GET) states that the performance of a nonlinear kernel model is the same as that of a noisy linear model. Specifically, for the ridge regression estimator, define
|
| 170 |
+
|
| 171 |
+
$$
|
| 172 |
+
\begin{array} { r l } & { \mathcal { R } _ { \mathrm { F } } ( \lambda ) = \mathbb { E } _ { { \pmb x } } \big ( \langle \phi _ { \mathrm { F } } ( { \pmb x } ) , \hat { \pmb a } _ { \lambda } \rangle - f ^ { * } ( { \pmb x } ) \big ) ^ { 2 } , } \\ & { \hat { \pmb a } _ { \lambda } = \mathrm { a r g m i n } _ { { \pmb a } } \Big \{ \displaystyle \frac { 1 } { n } \sum _ { i = 1 } ^ { n } ( y _ { i } - \langle \phi _ { \mathrm { F } } ( { \pmb x } _ { i } ) , \pmb a \rangle ) ^ { 2 } + \displaystyle \frac { \lambda } { N } \| \pmb a \| ^ { 2 } \Big \} , } \end{array}
|
| 173 |
+
$$
|
| 174 |
+
|
| 175 |
+
where $\mathrm { ~ F ~ } \in \ \{ \mathrm { C K } , \mathrm { G E } \}$ indicates the choice of feature map, which can be either the nonlinear CK feature $\begin{array} { r } { \phi _ { \mathrm { C K } } ( \pmb { x } ) = \frac { 1 } { \sqrt { N } } \sigma ( \pmb { W } ^ { \top } \pmb { x } ) } \end{array}$ , or the linear Gaussian equivalent (GE) feature $\phi _ { \mathrm { G E } } ( \pmb { x } ) =$ $\begin{array} { r } { \frac { 1 } { \sqrt { N } } \left( \mu _ { 1 } \pmb { W } ^ { \top } \pmb { x } + \mu _ { 2 } \pmb { z } \right) } \end{array}$ where $z \sim \mathcal { N } ( 0 , I )$ is independent of $_ { \textbf { \em x } }$ , $W$ . In the following, for both $\phi _ { \mathrm { C K } }$ and $\phi _ { \mathrm { G E } }$ , we take $W$ to be the updated weight matrix $W _ { 1 }$ after one GD step.
|
| 176 |
+
|
| 177 |
+
The Gaussian equivalence refers to the universality phenomenon $\mathcal { R } _ { \mathrm { C K } } ( \lambda ) \approx \mathcal { R } _ { \mathrm { G E } } ( \lambda )$ . For RF models (3.1), the GET has been rigorously proved in [HL20, MS22, MM22]. Furthermore, $[ \mathrm { G L R ^ { + } } 2 1$ , $\mathrm { L G C } ^ { + } 2 1 ]$ provided empirical evidence that such equivalence holds for more general feature maps, including the representation of certain pretrained NNs (e.g., see $[ \mathrm { L G C ^ { + } } 2 1$ , Figure 4]). Since our setting goes beyond RF models and cannot be covered by the prior results, we establish the GET for our trained feature map under small learning rate.
|
| 178 |
+
|
| 179 |
+
Theorem 3. Suppose that Assumption 1 holds and the activation $\sigma$ is an odd function. If the learning of $W _ { 1 }$ in (2.1) and estimation of $\hat { \pmb { a } } _ { \lambda }$ in (4.1) are performed on independent training data $\boldsymbol { X }$ and $\tilde { \boldsymbol { X } }$ , respectively, then the GET holds after the first-layer weight is trained for one gradient step with learning rate $\eta = \Theta ( 1 )$ ; that is, for the CK feature $\begin{array} { r } { \phi _ { \mathrm { C K } } ( \pmb { x } ) = \frac { 1 } { \sqrt { N } } \sigma ( \pmb { W } _ { 1 } ^ { \top } \pmb { x } ) } \end{array}$ , and $\lambda > 0$ ,
|
| 180 |
+
|
| 181 |
+
$$
|
| 182 |
+
| \mathcal { R } _ { \mathrm { C K } } ( \lambda ) - \mathcal { R } _ { \mathrm { G E } } ( \lambda ) | = o _ { d , \mathbb { P } } ( 1 ) .
|
| 183 |
+
$$
|
| 184 |
+
|
| 185 |
+
This is to say, for learning rate $\eta \ : = \ : \Theta ( 1 )$ , the Gaussian equivalent model provides an accurate description of the prediction risk of CK ridge regression after one feature learning step. The important observation is that even though the trained parameters in $W _ { 1 }$ are no longer i.i.d., the Gaussian equivalence property can still hold when $W _ { 1 } - W _ { 0 }$ remains “small” (in some norm, see (C.3) in Appendix C.1 for details), which entails that the neurons remain nearly orthogonal to one another.
|
| 186 |
+
|
| 187 |
+
Implications of Gaussian equivalence. Under the GET, we can alternatively compute $\mathcal { R } _ { \mathrm { G E } } ( \lambda )$ , the prediction risk of ridge regression on noisy Gaussian features $\phi _ { \mathrm { G E } }$ , which is much easier to analyze. Theorem 3 is empirically validated in Figure 3(a)(b), where we observe an agreement between the experimental values and the analytic predictions2 from Section 4.2. On the other hand, the GET also implies that the kernel estimator is essentially “linear” in high dimensions. For the squared loss, it is straightforward to verify that the Gaussian equivalent model cannot learn the nonlinear component of the target function $\mathsf { P } _ { > 1 } f ^ { * }$ as follows.
|
| 188 |
+
|
| 189 |
+
Fact 4. Under the same assumptions as Theorem 3, $\mathcal { R } _ { \mathrm { G E } } ( \lambda ) \geq \left. P _ { > 1 } f ^ { * } \right. _ { L ^ { 2 } } ^ { 2 }$ for any $\psi _ { 1 } , \psi _ { 2 } , \lambda > 0 .$
|
| 190 |
+
|
| 191 |
+
Hence when $\eta = \Theta ( 1 )$ , even though training the first-layer $W$ for one step can lead to non-trivial improvement over the initial RF model (which we precisely quantify in Section 4.2), the learned CK cannot outperform the best linear model on the input features. In other words, to (possibly) learn a nonlinear $f ^ { * }$ , the trained feature map needs to violate the GET. In the case of one gradient step on $W$ , this amounts to using a sufficiently large step size, which we analyze in Section 5.
|
| 192 |
+
|
| 193 |
+
# 4.2 Precise asymptotics of CK ridge regression
|
| 194 |
+
|
| 195 |
+
Having established the Gaussian equivalence property for the CK ridge estimator after one gradient step with $\eta = \Theta ( 1 )$ , we can now compute the asymptotic prediction risk for the trained kernel and compare with the initialized RF. To quantify the discrepancy in the prediction risk (4.1), we write $\mathcal { R } _ { 0 } ( \bar { \lambda } )$ as the prediction risk of the initialized RF ridge regression estimator (on the feature map $\pmb { x } \mapsto \sigma ( \pmb { W } _ { 0 } ^ { \top } \pmb { x } ) )$ , and $\mathcal { R } _ { 1 } ( \lambda )$ as the prediction risk of the ridge estimator on the trained feature map after one feature learning step $\pmb { x } \mapsto \sigma ( \pmb { W } _ { 1 } ^ { \top } \pmb { x } )$ .
|
| 196 |
+
|
| 197 |
+
Importantly, because of the dependency between the trained weights $W _ { 1 }$ and the teacher model $f ^ { * }$ (due to the gradient update (2.1)), we cannot simply apply a rotation invariance argument (e.g., [MM22, Lemma 9.2]) to remove the dependency on the true parameters $\beta _ { * }$ and reduce the prediction risk to the trace of certain rational functions of the kernel matrix. In other words, knowing the spectrum (or the Stieltjes transform) of the CK is not sufficient for these purposes. Instead, we utilize the GET and the almost rank-1 property of $G _ { 0 }$ in Proposition 2, which, in combination with techniques from operator-valued free probability theory [MS17, AP20], enables us to obtain the asymptotic expression of the difference in the prediction risk before and after one gradient step.
|
| 198 |
+
|
| 199 |
+
Theorem 5. Under the same assumptions as Theorem 3 and $\eta = \Theta ( 1 )$ , we have
|
| 200 |
+
|
| 201 |
+
$$
|
| 202 |
+
\mathcal { R } _ { 0 } ( \lambda ) - \mathcal { R } _ { 1 } ( \lambda ) \overset { \mathbb { P } } { } \delta ( \eta , \lambda , \psi _ { 1 } , \psi _ { 2 } ) \geq 0 ,
|
| 203 |
+
$$
|
| 204 |
+
|
| 205 |
+
where $\delta ( \eta , \lambda , \psi _ { 1 } , \psi _ { 2 } )$ is defined by (C.19) in Appendix C.3. Here, $\delta$ is a non-negative function of $\eta , \lambda , \psi _ { 1 } , \psi _ { 2 } \in ( 0 , + \infty )$ with parameters $\mu _ { 1 } ^ { * } , \mu _ { 1 } , \mu _ { 2 }$ , and it vanishes if and only $i f$ (at least) one of $\mu _ { 1 } ^ { * } , \mu _ { 1 }$ and $\eta$ is equal to zero.
|
| 206 |
+
|
| 207 |
+
Remark. Performance of the initial $R F$ ridge estimator $\mathcal { R } _ { 0 } ( \lambda )$ has been characterized by the prior works $I G L K ^ { + } 2 0$ , MM22]; hence, the precise asymptotics of $\delta$ provided in Theorem 5 allows us to explicitly compute the asymptotic prediction risk of the CK model after one gradient step, i.e. $\mathcal { R } _ { 1 } ( \lambda )$ .
|
| 208 |
+
|
| 209 |
+
Theorem 5 confirms our intuition that training the first-layer parameters improves the CK model, as shown in Figure 3(a)(b). Remarkably, this improvement (when $\delta > 0$ ) holds for any $\psi _ { 1 } , \psi _ { 2 } \in$ $( 0 , \infty )$ , that is, taking one gradient step (with learning rate $\eta = \Theta ( 1 ) )$ is always beneficial, even when the training set size $n$ is small. Moreover, we do not require the student and teacher models to have the same nonlinearity — a non-vanishing decrease in the prediction risk is present as long as $\mu _ { 1 } , \mu _ { 1 } ^ { * } \neq 0$ . On the other hand, the GET also implies an upper bound on the possible improvement: $\delta \leq \bar { \mathcal { R } } _ { 0 } ( \lambda ) - \mu _ { 2 } ^ { * 2 }$ as $n , d , N \to \infty$ ; this is to say, the trained CK remains in the “linear” regime.
|
| 210 |
+
|
| 211 |
+
Fore the details of Theorem 5, see Appendix C.3.2. Additionally, from inspecting the asymptotic risk formulae (C.19), we can arrive at the following characterization of two special cases of interest.
|
| 212 |
+
|
| 213 |
+
• Large sample regime $( \psi _ { 1 } \infty )$ ): $\delta$ is increasing with respect to the learning rate $\eta$ ; that is, taking a larger step results in greater decrease in the prediction risk, as shown in Figure 3(a).
|
| 214 |
+
|
| 215 |
+
• Large width regime $\psi _ { 2 } \infty ,$ ): In this case $\delta 0$ ; thus, the benefit of one-step feature learning (with $\eta = \Theta ( 1 ) _ { . }$ ) becomes less significant as the width increases, as shown in Figure 3(b).
|
| 216 |
+
|
| 217 |
+

|
| 218 |
+
Figure 3: Prediction risk of CK ridge regression on trained features: dots represent empirical simulations $d = 5 1 2$ , averaged over 50 runs) and solid curves are asymptotic predictions; dashed black line corresponds to the kernel lower bound (3.3). (a) $\eta = \Theta ( 1 )$ , $\sigma =$ tanh, $\sigma ^ { * } = { }$ SoftPlus; we set $\psi _ { 2 } = 2$ , $\lambda = 1 0 ^ { - 4 }$ , $\sigma _ { \varepsilon } = 0 . 2 5$ . (b) $\eta = \Theta ( 1 )$ , $\sigma = \operatorname { t a n h }$ , $\sigma ^ { * } = \mathrm { R e L U }$ ; we set $\psi _ { 1 } = 5$ , $\lambda = 1 0 ^ { - 2 }$ , $\sigma _ { \varepsilon } = 0 . 1$ . (c) $\eta = N ^ { \alpha }$ for $\alpha \in [ 0 , 1 / 2 ]$ ; brighter color represents larger step size. We choose $\sigma = \sigma ^ { * } = \operatorname { e r f }$ , $\psi _ { 2 } = 2$ , $\lambda = 1 0 ^ { - 3 }$ , and $\sigma _ { \varepsilon } = 0 . 1$ .
|
| 219 |
+
|
| 220 |
+
# 5 $\eta = \Theta ( \sqrt { N } )$ : improvement over the kernel lower bound
|
| 221 |
+
|
| 222 |
+
In this section, we consider a gradient step with large learning rate $\eta = \Theta ( \sqrt { N } )$ , which matches the asymptotic order of the Frobenius norm of the gradient $G _ { 0 }$ and that of the initialized weight matrix $W _ { 0 }$ . Note that after absorbing the prefactors, this learning rate scaling is analogous to the maximal update parameterization [YH20], which admits a feature learning limit. More specifically, the change in each coordinate of the feature vector $[ { \boldsymbol { \sigma } } ( \mathbf { W } ^ { \top } { \boldsymbol { \mathbf { x } } } ) ] _ { i }$ is $\tilde { \Theta } _ { d , \mathbb { P } } ( \bar { 1 } )$ , which has roughly the same order of magnitude as its value at initialization.
|
| 223 |
+
|
| 224 |
+
Due to the large step size, columns of the updated weight matrix $W _ { 1 }$ are no longer near-orthogonal, which is an important property in existing analyses of the Gaussian equivalence (e.g., see Proposition 13 in Appendix C.1 or [HL20, Equation (66)]). Indeed, we will see that in this regime, the ridge regression estimator on the trained CK features is no longer “linear” and can potentially outperform the kernel lower bound (3.3) in the proportional limit. However, in the absence of GET, it is difficult to derive the precise asymptotics of the CK model. As an alternative, we establish an upper bound on the prediction risk $\bar { \mathcal { R } } _ { 1 } ( \bar { \lambda } )$ , which we then compare against the kernel ridge lower bound.
|
| 225 |
+
|
| 226 |
+
Existence of a “good” solution. Given the trained first-layer weights $W _ { 1 }$ , we first construct a second-layer $\tilde { \mathbf { \alpha } }$ for which the prediction risk can be upper-bounded. For a pair of nonlinearities $( \sigma , \sigma ^ { * } )$ , we introduce a scalar $\tau ^ { * }$ which is the optimum of the following minimization problem:
|
| 227 |
+
|
| 228 |
+
$$
|
| 229 |
+
\tau ^ { * } : = \operatorname* { i n f } _ { \kappa \in \mathbb { R } } \mathbb { E } _ { \xi _ { 1 } } \Big [ \big ( \sigma ^ { * } ( \xi _ { 1 } ) - \mathbb { E } _ { \xi _ { 2 } } \sigma ( \kappa \xi _ { 1 } + \xi _ { 2 } ) \big ) ^ { 2 } \Big ] ,
|
| 230 |
+
$$
|
| 231 |
+
|
| 232 |
+
where $\xi _ { 1 } , \xi _ { 2 } \stackrel { \mathrm { i . i . d . } } { \sim } \mathcal { N } ( 0 , 1 )$ . We write $\kappa ^ { * }$ as an optimal value at which $\tau ^ { * }$ is attained (when $\tau ^ { * }$ is not achieved by a finite $\kappa$ , the same argument holds by introducing a small tolerance factor $\epsilon > 0$ in $\tau ^ { * }$ ; see Appendix D.2). Roughly speaking, $\tau ^ { * }$ approximates the prediction risk of a specific student model which takes the form of an average over a subset of neurons (after one feature learning step). In particular, the first term on the RHS of (5.1) containing $\sigma ^ { * }$ corresponds to the teacher $f ^ { * }$ , and the second term $\mathbb { E } _ { \xi _ { 2 } }$ represents the constructed student model. The following lemma shows that we can find some $\tilde { \mathbf { a } }$ on the trained CK features whose prediction risk is approximately $\tau ^ { * }$ , under the additional assumption that the activation function $\sigma$ is bounded. For more details, see Appendix D.
|
| 233 |
+
|
| 234 |
+
Lemma 6 (Informal). Suppose that Assumption √ $I$ holds and $\sigma$ is bounded. Then, after one gradient step on $W$ with $\eta = \Theta ( \sqrt { N } )$ , there exist some second-layer coefficients $\tilde { \mathbf { a } }$ such that the constructed student model $\begin{array} { r } { \tilde { f } ( \pmb { x } ) = \frac { 1 } { \sqrt { N } } \tilde { \pmb { a } } ^ { \top } \sigma ( \pmb { W } _ { 1 } ^ { \top } \pmb { x } ) } \end{array}$ achieves a prediction risk which is “close” to $\tau ^ { * }$ .
|
| 235 |
+
|
| 236 |
+
It is worth noting that the definition of $\tau ^ { * }$ does not involve the specific value of the learning rate $\eta$ . This is because for any choice of $\eta = \Theta ( \sqrt { N } )$ , due to the Gaussian initialization of $a _ { i }$ , we can find a subset of weights that receive a “good” learning rate (with high probability) such that the corresponding neurons are useful for learning the teacher model. In addition, observe that $\tau ^ { * }$ is a simple Gaussian integral which can be numerically or analytically computed (see Appendix D.2 for more examples). For instance, when $\sigma = \sigma ^ { * } =$ erf, one can easily verify that $\kappa ^ { * } = \sqrt { 3 }$ and $\tau ^ { * } = 0$ .
|
| 237 |
+
|
| 238 |
+
Prediction risk of ridge regression. Since we have established the existence of a “good” student model $\tilde { f }$ that can achieve a prediction risk close to $\tau ^ { * }$ (as defined in (5.1)), in what follows, we prove an upper bound for the prediction risk of the ridge regression estimator on the trained CK features $\mathcal { R } _ { 1 } ( \bar { \lambda } \bar { ) }$ in terms of the scalar $\tau ^ { * }$ . The proof of the following result is shown in Appendix D.3.
|
| 239 |
+
|
| 240 |
+
Theorem 7. Under the same assumptions as Lemma √ $6$ , after one gradient step on $W$ with $\eta =$ $\Theta ( { \sqrt { N } } )$ , there exist constants $C , \psi _ { 1 } ^ { * } > 0$ such that for any $n / d > \psi _ { 1 } ^ { * }$ , the ridge regression estimator (4.1) with regularization parameter $n ^ { \varepsilon - 1 } < N ^ { - 1 } \dot { \lambda } < n ^ { - \varepsilon }$ for some small $\varepsilon > 0$ satisfies
|
| 241 |
+
|
| 242 |
+
$$
|
| 243 |
+
\begin{array} { r } { \mathcal { R } _ { 1 } ( \lambda ) \leq 1 0 \tau ^ { * } + C \Big ( \sqrt { \tau ^ { * } } \cdot \sqrt { \frac { d } { n } } + \frac { d } { n } \Big ) , } \end{array}
|
| 244 |
+
$$
|
| 245 |
+
|
| 246 |
+
with probability 1 as $n , d , N \to \infty$ proportionally.
|
| 247 |
+
|
| 248 |
+
While Theorem 7 does not provide exact expression of the prediction risk, the upper bound still allows us to compare the prediction risk of the CK ridge regression before and after one large gradient step. In particular, if $\left. \mathsf { P } _ { > 1 } f ^ { * } \right. _ { L ^ { 2 } } ^ { 2 } \ge 1 0 \tau ^ { * }$ (the constant 10 is not optimized), we know that the trained CK can outperform the kernel lower bound (3.3) (and also the initialized CK) in the proportional limit, when the ratio $\psi _ { 1 } = n / d$ is sufficiently large. The following corollary provides two examples of this separation (see Figure 3(c)).
|
| 249 |
+
|
| 250 |
+
Corollary 8. Under the same conditions as Theorem 7, there exists a constant $\psi _ { 1 } ^ { * }$ such that for any $\psi _ { 1 } > \psi _ { 1 } ^ { * }$ , the following holds with probability $^ { l }$ when $n , d , N \to \infty$ proportionally:
|
| 251 |
+
|
| 252 |
+
• For $\sigma { = } \sigma ^ { * } { = } \mathrm { e r f }$ , we have $\mathcal { R } _ { 1 } ( \lambda ) { = } \mathcal { O } ( d / n )$ . • For $\sigma = \sigma ^ { * } = \operatorname { t a n h }$ , we have $\mathcal { R } _ { 1 } ( \lambda ) < \| \mathsf { P } _ { > 1 } f ^ { * } \| _ { L ^ { 2 } } ^ { 2 }$
|
| 253 |
+
|
| 254 |
+
In the two examples outlined above, training the features by taking one large gradient step on the first-layer parameters can lead to substantial improvement in the performance of the CK model. In fact, the new ridge regression estimator may outperform a wide range of kernel models as described in Section 3.1, and as shown in Figure 3(c). However, we emphasize that this separation is only present in specific pairs of $( \sigma , \sigma ^ { * } )$ for which the scalar $\tau ^ { * }$ is sufficiently small. In general settings, learning a good representation would likely require a training procedure that takes more than one gradient step (even if $f ^ { * }$ is as simple as a single-index model, see Figure 4(c) in Appendix A.1).
|
| 255 |
+
|
| 256 |
+
# 6 Conclusion
|
| 257 |
+
|
| 258 |
+
We investigated how the conjugate kernel of a two-layer neural network (1.1) benefits from feature learning in an idealized student-teacher setting, where the first-layer parameters $W$ are updated by one gradient descent step on the empirical risk. Based on the approximate low-rank property of the gradient matrix, we quantified the improvement in the prediction risk of conjugate kernel ridge regression under two different scalings of first-step learning rate $\eta$ . To the best of our knowledge, this is the first work that rigorously characterizes the precise asymptotics of kernel models (defined by neural networks) in the presence of feature learning.
|
| 259 |
+
|
| 260 |
+
We outline a few limitations of our current analysis as well as future directions.
|
| 261 |
+
|
| 262 |
+
• Dependence between $W _ { 1 }$ and $\boldsymbol { X }$ . One crucial assumption that we make is that the trained weight matrix $W _ { 1 }$ is independent of the data $\tilde { \boldsymbol X }$ on which the CK is computed. While this does not cover the important scenario where feature learning and kernel evaluation are performed on the same data, our setting is very natural in the analysis of pretrained models or transfer learning, which would be an interesting extension.
|
| 263 |
+
|
| 264 |
+
• Scaling of learning rate. Our findings illustrate that different learning rate scalings such as √ $\eta =$ $\Theta ( 1 )$ and $\eta \ : = \ : \Theta ( \sqrt { N } )$ result in drastically different behavior. One natural question to ask is whether there exists a “phase transition” in between the two regimes that dictates whether the GET holds. Interestingly, [RGKZ21] showed that instead of breaking the near-orthogonality of the weights $W$ (via large gradient step), one can also introduce sufficiently large low-rank shifts to the input $\boldsymbol { X }$ to enable the initial RF model to fit a nonlinear $f ^ { * }$ . Intuitively, this may be due to the “dual” relation of the inputs $\boldsymbol { X }$ and the weights $W$ in the CK model.
|
| 265 |
+
|
| 266 |
+
# Acknowledgement
|
| 267 |
+
|
| 268 |
+
The authors would like to thank (in alphabetical order) Konstantin Donhauser, Zhou Fan, Hong Hu, Masaaki Imaizumi, Ryo Karakida, Bruno Loureiro, Yue M. Lu, Atsushi Nitanda, Sejun Park, Ji Xu, Yiqiao Zhong for discussions and feedback on the manuscript.
|
| 269 |
+
|
| 270 |
+
JB was supported by NSERC Grant [2020-06904], CIFAR AI Chairs program, Google Research Scholar Program and Amazon Research Award. MAE was supported by NSERC Grant [2019- 06167], Connaught New Researcher Award, CIFAR AI Chairs program, and CIFAR AI Catalyst grant. TS was partially supported by JSPS KAKENHI (20H00576) and JST CREST. ZW was supported by NSF Grant DMS-2055340. DW was partially supported by a Borealis AI Fellowship. Part of this work was completed when DW interned at Microsoft Research (hosted by GY).
|
| 271 |
+
|
| 272 |
+
# References
|
| 273 |
+
|
| 274 |
+
$[ \mathrm { A B A B } ^ { + } 2 1 ]$ Emmanuel Abbe, Enric Boix Adsera, Matthew Brennan, Guy Bresler, and Dheeraj Nagaraj, The staircase property: How hierarchical structure can guide deep learning, Advances in Neural Information Processing Systems 34 (2021).
|
| 275 |
+
[ABAM22] Emmanuel Abbe, Enric Boix-Adsera, and Theodor Misiakiewicz, The mergedstaircase property: a necessary and nearly sufficient condition for sgd learning of sparse functions on two-layer neural networks, arXiv preprint arXiv:2202.08658 (2022).
|
| 276 |
+
[Ada15] Radoslaw Adamczak, A note on the hanson-wright inequality for random vectors with dependencies, Electronic Communications in Probability 20 (2015), 1–13.
|
| 277 |
+
$[ \mathrm { A D H ^ { + } } 1 9 ]$ Sanjeev Arora, Simon S Du, Wei Hu, Zhiyuan Li, Russ R Salakhutdinov, and Ruosong Wang, On exact computation with an infinitely wide neural net, Advances in Neural Information Processing Systems 32 (2019).
|
| 278 |
+
[AP20] Ben Adlam and Jeffrey Pennington, The neural tangent kernel in high dimensions: Triple descent and a multi-scale theory of generalization, International Conference on Machine Learning, PMLR, 2020, pp. 74–84.
|
| 279 |
+
[AZL19] Zeyuan Allen-Zhu and Yuanzhi Li, What can resnet learn efficiently, going beyond kernels?, Advances in Neural Information Processing Systems 32 (2019).
|
| 280 |
+
[AZL20] , Backward feature correction: How deep learning performs deep learning, arXiv preprint arXiv:2001.04413 (2020).
|
| 281 |
+
[AZLL19] Zeyuan Allen-Zhu, Yuanzhi Li, and Yingyu Liang, Learning and generalization in overparameterized neural networks, going beyond two layers, Advances in neural information processing systems 32 (2019).
|
| 282 |
+
[Bac17] Francis Bach, Breaking the curse of dimensionality with convex neural networks, The Journal of Machine Learning Research 18 (2017), no. 1, 629–681.
|
| 283 |
+
[Bac23] , Learning theory from first principles, MIT Press, 2023.
|
| 284 |
+
$[ \mathrm { B E S ^ { + } } 2 2 ]$ Jimmy Ba, Murat A Erdogdu, Taiji Suzuki, Zhichao Wang, Denny Wu, and Greg Yang, High-dimensional asymptotics of feature learning in the early phase of neural network training, In Preparation (2022).
|
| 285 |
+
[BHMM19] Mikhail Belkin, Daniel Hsu, Siyuan Ma, and Soumik Mandal, Reconciling modern machine-learning practice and the classical bias–variance trade-off, Proceedings of the National Academy of Sciences 116 (2019), no. 32, 15849–15854.
|
| 286 |
+
[BL20] Yu Bai and Jason D. Lee, Beyond linearization: On quadratic and higher-order approximation of wide neural networks, International Conference on Learning Representations, 2020.
|
| 287 |
+
[BM21] Antoine Bodin and Nicolas Macris, Model, sample, and epoch-wise descents: exact solution of gradient flow in the random feature model, Advances in Neural Information Processing Systems 34 (2021).
|
| 288 |
+
[BMR21] Peter L Bartlett, Andrea Montanari, and Alexander Rakhlin, Deep learning: a statistical viewpoint, Acta numerica 30 (2021), 87–201.
|
| 289 |
+
|
| 290 |
+
Lucas Benigni and Sandrine Pech ´ e,´ Eigenvalue distribution of some nonlinear models of random matrices, Electronic Journal of Probability 26 (2021), 1–37.
|
| 291 |
+
|
| 292 |
+
, Largest eigenvalues of the conjugate kernel of single-layered neural networks, arXiv preprint arXiv:2201.04753 (2022).
|
| 293 |
+
|
| 294 |
+
Zhi-Dong Bai and Jack W Silverstein, No eigenvalues outside the support of the limiting spectral distribution of large-dimensional sample covariance matrices, The Annals of Probability 26 (1998), no. 1, 316–345.
|
| 295 |
+
|
| 296 |
+
Zhidong Bai and Jack W Silverstein, Spectral analysis of large dimensional random matrices, vol. 20, Springer, 2010.
|
| 297 |
+
|
| 298 |
+
Lenaic Chizat and Francis Bach, On the global convergence of gradient descent for over-parameterized models using optimal transport, Advances in neural information processing systems, 2018, pp. 3036–3046.
|
| 299 |
+
|
| 300 |
+
, Implicit bias of gradient descent for wide two-layer neural networks trained with the logistic loss, Conference on Learning Theory, PMLR, 2020, pp. 1305–1338.
|
| 301 |
+
|
| 302 |
+
Lena ´ ¨ıc Chizat, Mean-field langevin dynamics: Exponential convergence and annealing, arXiv preprint arXiv:2202.01009 (2022).
|
| 303 |
+
|
| 304 |
+
Jeremy Cohen, Simran Kaur, Yuanzhi Li, J Zico Kolter, and Ameet Talwalkar, Gradient descent on neural networks typically occurs at the edge of stability, International Conference on Learning Representations, 2021.
|
| 305 |
+
|
| 306 |
+
Niladri S Chatterji, Philip M Long, and Peter L Bartlett, When does gradient descent with logistic loss find interpolating two-layer networks?, Journal of Machine Learning Research 22 (2021), no. 159, 1–48.
|
| 307 |
+
|
| 308 |
+
Lenaic Chizat, Edouard Oyallon, and Francis Bach, On lazy training in differentiable programming, Advances in Neural Information Processing Systems 32 (2019).
|
| 309 |
+
|
| 310 |
+
Xiuyuan Cheng and Amit Singer, The spectrum of random inner-product kernel matrices, Random Matrices: Theory and Applications 2 (2013), no. 04, 1350010.
|
| 311 |
+
|
| 312 |
+
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova, Bert: Pretraining of deep bidirectional transformers for language understanding, arXiv preprint arXiv:1810.04805 (2018).
|
| 313 |
+
|
| 314 |
+
Ethan Dyer and Guy Gur-Ari, Asymptotics of wide networks from feynman diagrams, International Conference on Learning Representations, 2020.
|
| 315 |
+
|
| 316 |
+
Oussama Dhifallah and Yue M Lu, A precise performance analysis of learning with random features, arXiv preprint arXiv:2008.11904 (2020).
|
| 317 |
+
|
| 318 |
+
Amit Daniely and Eran Malach, Learning parities with neural networks, Advances in Neural Information Processing Systems 33 (2020), 20356–20365.
|
| 319 |
+
|
| 320 |
+
Yen Do and Van Vu, The spectrum of random kernel matrices: universality results for rough and varying kernels, Random Matrices: Theory and Applications 2 (2013), no. 03, 1350005.
|
| 321 |
+
|
| 322 |
+
Edgar Dobriban and Stefan Wager, High-dimensional asymptotics of prediction: Ridge regression and classification, The Annals of Statistics 46 (2018), no. 1, 247– 279.
|
| 323 |
+
|
| 324 |
+
Konstantin Donhauser, Mingqi Wu, and Fanny Yang, How rotational invariance of common kernels prevents generalization in high dimensions, International Conference on Machine Learning, PMLR, 2021, pp. 2804–2814.
|
| 325 |
+
|
| 326 |
+
Simon S. Du, Xiyu Zhai, Barnabas Poczos, and Aarti Singh, Gradient descent provably optimizes over-parameterized neural networks, International Conference on Learning Representations, 2019.
|
| 327 |
+
|
| 328 |
+
Noureddine El Karoui, The spectrum of kernel random matrices, The Annals of Statistics 38 (2010), no. 1, 1–50.
|
| 329 |
+
|
| 330 |
+
On the impact of predictor geometry on the performance on highdimensional ridge-regularized generalized robust regression estimators, Probability Theory and Related Fields 170 (2018), no. 1, 95–175.
|
| 331 |
+
|
| 332 |
+
[FCB22] Spencer Frei, Niladri S Chatterji, and Peter L Bartlett, Random feature amplification: Feature learning and generalization in neural networks, arXiv preprint arXiv:2202.07626 (2022).
|
| 333 |
+
$[ \mathrm { F D P ^ { + } } 2 0 ]$ 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, Advances in Neural Information Processing Systems 33 (2020), 5850–5861.
|
| 334 |
+
[FM19] Zhou Fan and Andrea Montanari, The spectral norm of random inner-product kernel matrices, Probability Theory and Related Fields 173 (2019), no. 1-2, 27–85.
|
| 335 |
+
[FOBS06] Reza Rashidi Far, Tamer Oraby, Wlodzimierz Bryc, and Roland Speicher, Spectra of large block matrices, arXiv preprint cs/0610045 (2006).
|
| 336 |
+
[FW20] Zhou Fan and Zhichao Wang, Spectra of the conjugate kernel and neural tangent kernel for linear-width neural networks, Advances in neural information processing systems 33 (2020), 7710–7721.
|
| 337 |
+
[GAS19] Aditya Sharad Golatkar, Alessandro Achille, and Stefano Soatto, Time matters in regularizing deep networks: Weight decay and data augmentation affect early learning dynamics, matter little near convergence, Advances in Neural Information Processing Systems 32 (2019).
|
| 338 |
+
[GDDM14] Ross Girshick, Jeff Donahue, Trevor Darrell, and Jitendra Malik, Rich feature hierarchies for accurate object detection and semantic segmentation, Proceedings of the IEEE conference on computer vision and pattern recognition, 2014, pp. 580–587.
|
| 339 |
+
$[ \mathrm { G L K ^ { + } } 2 0 ]$ Federica Gerace, Bruno Loureiro, Florent Krzakala, Marc Mezard, and Lenka Zde-´ borova,´ Generalisation error in learning with random features and the hidden manifold model, International Conference on Machine Learning, PMLR, 2020, pp. 3452– 3462.
|
| 340 |
+
$[ \mathrm { G L R } ^ { + } 2 1 ]$ Sebastian Goldt, Bruno Loureiro, Galen Reeves, Florent Krzakala, Marc Mezard, and ´ Lenka Zdeborova,´ The gaussian equivalence of generative models for learning with shallow neural networks, Proceedings of Machine Learning Research vol 145 (2021), 1–46.
|
| 341 |
+
[GMKZ20] Sebastian Goldt, Marc Mezard, Florent Krzakala, and Lenka Zdeborov ´ a,´ Modeling the influence of data structure on learning in neural networks: The hidden manifold model, Physical Review X 10 (2020), no. 4, 041044.
|
| 342 |
+
[GMMM19] Behrooz Ghorbani, Song Mei, Theodor Misiakiewicz, and Andrea Montanari, Limitations of lazy training of two-layers neural network, Advances in Neural Information Processing Systems 32 (2019).
|
| 343 |
+
[GMMM20] , When do neural networks outperform kernel methods?, Advances in Neural Information Processing Systems 33 (2020), 14820–14830.
|
| 344 |
+
[GMMM21] Linearized two-layers neural networks in high dimension, The Annals of Statistics 49 (2021), no. 2, 1029–1054.
|
| 345 |
+
[GSJW20] Mario Geiger, Stefano Spigler, Arthur Jacot, and Matthieu Wyart, Disentangling feature and lazy training in deep neural networks, Journal of Statistical Mechanics: Theory and Experiment 2020 (2020), no. 11, 113301.
|
| 346 |
+
[HCG21] Karl Hajjar, Lena ´ ¨ıc Chizat, and Christophe Giraud, Training integrable parameterizations of deep neural networks in the infinite-width limit, arXiv preprint arXiv:2110.15596 (2021).
|
| 347 |
+
[HFS07] J William Helton, Reza Rashidi Far, and Roland Speicher, Operator-valued semicircular elements: solving a quadratic matrix equation with positivity constraints, International Mathematics Research Notices 2007 (2007), no. 9, rnm086–rnm086.
|
| 348 |
+
[HL20] Hong Hu and Yue M Lu, Universality laws for high-dimensional learning with random features, arXiv preprint arXiv:2009.07669 (2020).
|
| 349 |
+
[HMS18] J William Helton, Tobias Mai, and Roland Speicher, Applications of realizations (aka linearizations) to free probability, Journal of Functional Analysis 274 (2018), no. 1, 1–79.
|
| 350 |
+
[MS17] James A Mingo and Roland Speicher, Free probability and random matrices, vol. 35, Springer, 2017.
|
| 351 |
+
[MS22] Andrea Montanari and Basil N Saeed, Universality of empirical risk minimization, Conference on Learning Theory, PMLR, 2022, pp. 4310–4312.
|
| 352 |
+
[MZ20] Andrea Montanari and Yiqiao Zhong, The interpolation phase transition in neural networks: Memorization and generalization under lazy training, arXiv preprint arXiv:2007.12826v1 (2020).
|
| 353 |
+
[Nea95] Radford M Neal, Bayesian learning for neural networks, vol. 118, Springer Science & Business Media, 1995.
|
| 354 |
+
[Ngu21] Phan-Minh Nguyen, Analysis of feature learning in weight-tied autoencoders via the mean field lens, arXiv preprint arXiv:2102.08373 (2021).
|
| 355 |
+
[NS17] Atsushi Nitanda and Taiji Suzuki, Stochastic particle gradient descent for infinite ensembles, arXiv preprint arXiv:1712.05438 (2017).
|
| 356 |
+
[NWS22] Atsushi Nitanda, Denny Wu, and Taiji Suzuki, Convex analysis of the mean field langevin dynamics, arXiv preprint arXiv:2201.10469 (2022).
|
| 357 |
+
[Pec19] ´ S Pech ´ e,´ A note on the pennington-worah distribution, Electronic Communications in Probability 24 (2019), 1–7.
|
| 358 |
+
[PPVF21] Scott Pesme, Loucas Pillaud-Vivien, and Nicolas Flammarion, Implicit bias of sgd for diagonal linear networks: a provable benefit of stochasticity, Advances in Neural Information Processing Systems 34 (2021).
|
| 359 |
+
[PW17] Jeffrey Pennington and Pratik Worah, Nonlinear random matrix theory for deep learning, Advances in Neural Information Processing Systems, 2017, pp. 2637–2646.
|
| 360 |
+
[RGKZ21] Maria Refinetti, Sebastian Goldt, Florent Krzakala, and Lenka Zdeborova,´ Classifying high-dimensional gaussian mixtures: Where kernel methods fail and neural networks succeed, International Conference on Machine Learning, PMLR, 2021, pp. 8936– 8947.
|
| 361 |
+
[RR08] Ali Rahimi and Benjamin Recht, Random features for large-scale kernel machines, Advances in neural information processing systems, 2008, pp. 1177–1184.
|
| 362 |
+
[SA20] Taiji Suzuki and Shunta Akiyama, Benefit of deep learning with non-convex noisy gradient descent: Provable excess risk bound and superiority to kernel methods, arXiv preprint arXiv:2012.03224 (2020).
|
| 363 |
+
[SH20] Johannes Schmidt-Hieber, Nonparametric regression using deep neural networks with relu activation function, The Annals of Statistics 48 (2020), no. 4, 1875–1897.
|
| 364 |
+
[Suz18] Taiji Suzuki, Adaptivity of deep relu network for learning in besov and mixed smooth besov spaces: optimal rate and curse of dimensionality, arXiv preprint arXiv:1810.08033 (2018).
|
| 365 |
+
[TAP21] Nilesh Tripuraneni, Ben Adlam, and Jeffrey Pennington, Covariate shift in highdimensional random feature regression, arXiv preprint arXiv:2111.08234 (2021).
|
| 366 |
+
[Ver18] Roman Vershynin, High-dimensional probability: An introduction with applications in data science, vol. 47, Cambridge university press, 2018.
|
| 367 |
+
$[ \mathrm { V S L } ^ { + } 2 2 ]$ Rodrigo Veiga, Ludovic Stephan, Bruno Loureiro, Florent Krzakala, and Lenka Zdeborova,´ Phase diagram of stochastic gradient descent in high-dimensional two-layer neural networks, arXiv preprint arXiv:2202.00293 (2022).
|
| 368 |
+
$[ \mathrm { W G L } ^ { + } 2 0 ]$ Blake Woodworth, Suriya Gunasekar, Jason D Lee, Edward Moroshko, Pedro Savarese, Itay Golan, Daniel Soudry, and Nathan Srebro, Kernel and rich regimes in overparametrized models, Conference on Learning Theory, PMLR, 2020, pp. 3635– 3673.
|
| 369 |
+
[WLLM19] Colin Wei, Jason D Lee, Qiang Liu, and Tengyu Ma, Regularization matters: Generalization and optimization of neural nets vs their induced kernel, Advances in Neural Information Processing Systems, 2019, pp. 9712–9724.
|
| 370 |
+
[WX20] Denny Wu and Ji Xu, On the optimal weighted $\ell _ { 2 }$ regularization in overparameterized linear regression, Advances in Neural Information Processing Systems 33 (2020), 10112–10123.
|
| 371 |
+
|
| 372 |
+
<table><tr><td>[HY20]</td><td>Jiaoyang Huang and Horng-Tzer Yau, Dynamics of deep neural networks and neu- ral tangent hierarchy, International conference on machine learning, PMLR, 2020,</td></tr><tr><td>[IF19]</td><td>pp. 4542-4551. Masaaki Imaizumi and Kenji Fukumizu, Deep neural networks learn non-smooth functions effectively, The 22nd international conference on artificial intelligence and</td></tr><tr><td>[JGH18]</td><td>statistics, PMLR,2019, pp. 869-878. Arthur Jacot, Franck Gabriel, and Clément Hongler, Neural tangent kernel: Conver- gence and generalization in neural networks, Advances in neural information process-</td></tr><tr><td>[JSF+20]</td><td>ing systems, 2018, pp. 8571-8580. Stanislaw Jastrzebski, Maciej Szymczak, Stanislav Fort, Devansh Arpit, Jacek Tabor, Kyunghyun Cho, and Krzysztof Geras, The break-even point on optimization trajecto-</td></tr><tr><td>[JT20]</td><td>ries of deep neural networks, International Conference on Learning Representations, 2020. Ziwei Ji and Matus Telgarsky, Polylogarithmic width suffices for gradient descent to achieve arbitrarily small test error with shallow relu networks, International Confer-</td></tr><tr><td>[KWLS21]</td><td>ence on Learning Representations, 2020. Stefani Karp,Ezra Winston, Yuanzhi Li,and Aarti Singh, Local signal adaptivity: Provable feature learning in neural networks beyond kernels,Advances in Neural</td></tr><tr><td>[LBD+20]</td><td>Information Processing Systems 34 (2021). Aitor Lewkowycz, Yasaman Bahri, Ethan Dyer, Jascha Sohl-Dickstein,and Guy Gur- Ari, The large learning rate phase of deep learning: the catapult mechanism, arXiv</td></tr><tr><td>[LCM20]</td><td>preprint arXiv:2003.02218 (020). Zhenyu Liao, Romain Couillet,and Michael W Mahoney, A random matrix analysis of random fourier features: beyond the gaussian kernel, a precise phase transition, and the corresponding double descent, Advances in Neural Information Processing</td></tr><tr><td>[LGC+21]</td><td>Systems 33 (2020),13939-13950. Bruno Loureiro, Cedric Gerbelot, Hugo Cui, Sebastian Goldt,Florent Krzakala,Marc Mezard, and Lenka Zdeborova, Learning curves of generic features maps for realistic datasets with a teacher-student model, Advances in Neural Information Processing</td></tr><tr><td>[LLC18]</td><td>Systems 34 (2021). Cosme Louart, Zhenyu Liao, and Romain Couillet, A random matrix approach to neural networks, The Annals of Applied Probability 28 (2018), no.2,1190-1248.</td></tr><tr><td>[LM20]</td><td>Guillaume Leclerc and Aleksander Madry, The two regimes of deep network training, arXiv preprint arXiv:2002.10376 (2020).</td></tr><tr><td>[LMZ20]</td><td>Yuanzhi Li, Tengyu Ma, and Hongyang R Zhang, Learning over-parametrized two- layer neural networks beyond ntk, Conference on learning theory, PMLR,2020, pp. 2613-2682.</td></tr><tr><td>[LR20]</td><td>Tengyuan Liang and Alexander Rakhlin, Just interpolate: Kernel “ridgeless” regres- sion can generalize, The Annals of Statistics 48 (202O), no.3, 1329-1347.</td></tr><tr><td>[LWM19]</td><td>Yuanzhi Li, Colin Wei, and Tengyu Ma, Towards explaining the regularization effect of initial large learning rate in training neural networks,Advances in Neural Infor- mation Processing Systems,2019, pp. 11674-11685.</td></tr><tr><td>[MKAS21]</td><td>Eran Malach, Pritish Kamath, Emmanuel Abbe, and Nathan Srebro, Quantifying the benefit of using differentiable learning over tangent kernels, International Conference on Machine Learning,PMLR, 2021, pp. 7379-7389.</td></tr><tr><td>[MM22]</td><td>Song Mei and Andrea Montanari, The generalization error of random features regres- sion: Precise asymptotics and the double descent curve, Communications on Pure and Applied Mathematics 75 (2022), no.4, 667-766.</td></tr><tr><td>[MMM21]</td><td>Song Mei, Theodor Misiakiewicz, and Andrea Montanari, Generalization error of random feature and kernel methods: hypercontractivity and kernel matrix concentra-</td></tr><tr><td>[MMN18]</td><td>tion,Applied and Computational Harmonic Analysis (2021). Song Mei, Andrea Montanari,and Phan-Minh Nguyen, A mean field view of the land- scape of two-layer neural networks, Proceedings of the National Academy of Sciences 115 (2018), no. 33,E7665-E7671.</td></tr></table>
|
| 373 |
+
|
| 374 |
+
# [WZ21]
|
| 375 |
+
|
| 376 |
+
Zhichao Wang and Yizhe Zhu, Deformed semicircle law and concentration of nonlinear random matrices for ultra-wide neural networks, arXiv preprint arXiv:2109.09304 (2021).
|
| 377 |
+
|
| 378 |
+
Greg Yang, Tensor programs iii: Neural matrix laws, arXiv preprint arXiv:2009.10685 (2020).
|
| 379 |
+
|
| 380 |
+
Greg Yang and Edward J Hu, Feature learning in infinite-width neural networks, arXiv preprint arXiv:2011.14522 (2020).
|
| 381 |
+
|
| 382 |
+
Gilad Yehudai and Ohad Shamir, On the power and limitations of random features for understanding neural networks, Advances in Neural Information Processing Systems 32 (2019).
|
| 383 |
+
|
| 384 |
+
# Checklist
|
| 385 |
+
|
| 386 |
+
1. For all authors...
|
| 387 |
+
|
| 388 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
|
| 389 |
+
(b) Did you describe the limitations of your work? [Yes]
|
| 390 |
+
(c) Did you discuss any potential negative societal impacts of your work? [No]
|
| 391 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 392 |
+
|
| 393 |
+
2. If you are including theoretical results...
|
| 394 |
+
|
| 395 |
+
(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]
|
| 396 |
+
|
| 397 |
+
3. If you ran experiments...
|
| 398 |
+
|
| 399 |
+
(a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [N/A]
|
| 400 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [N/A]
|
| 401 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [N/A]
|
| 402 |
+
(d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [N/A]
|
| 403 |
+
|
| 404 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 405 |
+
|
| 406 |
+
(a) If your work uses existing assets, did you cite the creators? [N/A]
|
| 407 |
+
(b) Did you mention the license of the assets? [N/A]
|
| 408 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
|
| 409 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
|
| 410 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
|
| 411 |
+
|
| 412 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 413 |
+
|
| 414 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 415 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 416 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
md/dev/eLxADkHrBcR/eLxADkHrBcR.md
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# FULLY ONLINE META LEARNING
|
| 2 |
+
|
| 3 |
+
Anonymous authors Paper under double-blind review
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
While deep networks can learn complex functions such as classifiers, detectors, and trackers, many applications require models that continually adapt to changing input distributions, changing tasks, and changing environmental conditions. Indeed, this ability to continuously accrue knowledge and use past experience to learn new tasks quickly in continual settings is one of the key properties of an intelligent system. For complex and high-dimensional problems, simply updating the model continually with standard learning algorithms such as gradient descent may result in slow adaptation. Meta-learning can provide a powerful tool to accelerate adaptation yet is conventionally studied in batch settings. In this paper, we study how metalearning can be applied to tackle online problems of this nature, simultaneously adapting to changing tasks and input distributions and meta-training the model in order to adapt more quickly in the future. Extending meta-learning into the online setting presents its own challenges, and although several prior methods have studied related problems, they generally require a discrete notion of tasks, with known ground-truth task boundaries. Such methods typically adapt to each task in sequence, resetting the model between tasks, rather than adapting continuously across tasks. In many real-world settings, such discrete boundaries are unavailable, and may not even exist. To address these settings, we propose a Fully Online MetaLearning (FOML) algorithm, which does not require any ground truth knowledge about the task boundaries and stays fully online without resetting to pre-trained weights. Our experiments show that FOML was able to learn new tasks faster than the state-of-the-art online learning methods on various datasets.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Flexibility and rapid adaptation are a hallmark of intelligence: humans can not only solve complex problems, but they can also figure out how to solve them very rapidly, as compared to our current machine learning algorithms. Such rapid adaptation is crucial for both humans and computers: for humans, it is crucial for survival in changing natural environments, and it is also crucial for agents that classify photographs on the Internet, interpret text, control autonomous vehicles, and generally make accurate predictions with rapidly changing real-world data. While deep neural networks are remarkably effective for learning and representing accurate models He et al. (2015); Krizhevsky et al. (2012); Simonyan & Zisserman (2014); Szegedy et al. $\boxed { 2 0 1 5 }$ , they are comparatively unimpressive when it comes to adaptability, due to their computational and data requirements. Meta-learning in principle mitigates this problem, by leveraging the generalization power of neural networks to accelerate adaptation to new tasks Finn et al. (2019); Li et al. (2017); Nichol et al. (2018); Nichol & Schulman (2018); Park & Oliva (2019); Antoniou et al. (2018). However, standard meta-learning algorithms operate in batch mode, making them poorly suited for continuously evolving environments. More recently, online meta-learning methods have been proposed with the goal of enabling continual adaptation Finn et al. (2019); Jerfel et al. (2018); Yao et al. (2020); Nagabandi et al. (2018); Li & Hospedales (2020), where a constant stream of data from distinct tasks is used for both adaptation and meta-training. In this scheme, meta-training is used to accelerate how quickly the network can adapt to each new task it sees, and simultaneously use that data from each new task for meta-training. This further accelerates how quickly each subsequent task can be acquired. However, current online meta-learning methods fall short of the goal of creating an effective adaptation system for online data in several ways: (1) they typically require task boundaries in the data stream to be known, making them ill-suited to settings where task boundaries are ill-defined and tasks change or evolve gradually, a common tread in real-world; (2) as a result, they typically re-adapt from the meta-trained model on each task, resulting in a very “discrete” mode of operation, where the model adapts to a task, then resets, then adapts to a new one. These limitations restrict the applicability of current online meta-learning methods to real-world settings. We argue that task boundary assumption is somewhat artificial in online settings, where the stream of incoming data is cleanly partitioned into discrete and well-separated tasks presented in sequence. In this paper, we instead develop a fully online meta-learning approach, which does not assume knowledge of task boundaries and does not re-adapt for every new task from the meta parameters.
|
| 12 |
+
|
| 13 |
+

|
| 14 |
+
Figure 1: Comparison of standard online meta-learning and FOML: In standard online meta-learning (e.g., FTML Finn et al. (2019)), shown on the left, adaptation is performed on one task a time, and the algorithm “resets” the adaptation process at task boundaries. For example, a MAML-based method would reset the current parameters back to the meta-trained parameters. In our approach (right), knowledge of task boundaries is not required, and the algorithm continually keeps track of online parameters $\phi$ and meta-parameters $\theta$ . The online parameters are simply updated on the latest data, and the meta-parameters are updated to “pull” the online parameters toward fast-adapting solutions via a MAML-style meta-update.
|
| 15 |
+
|
| 16 |
+
Standard meta-learning methods consist of a meta-training phase, typically done with standard SGD, and an “inner loop” adaptation phase, which computes task specific parameter $\phi _ { i }$ for the task $\mathcal { T } _ { i }$ from a support set to make accurate predictions on a query set. For example, in model-agnostic metalearning (MAML), adaptation consists of taking a few gradient steps on the support set, starting from the meta-trained parameter vector $\theta$ , leading to a set of post-adaptation parameters, and meta-training optimizes the meta-trained parameters $\theta$ so that these gradient steps lead to good results. Previous extensions of such approaches into the online setting typically observe one task at a time, adapt to that task (i.e., compute post-adaptation parameters on it), and then reset $\phi _ { i }$ back to the meta-trained parameters $\theta$ at the beginning of the next task. Thus, the algorithm repeatedly adapts, resets back to pretrained meta parameters at the task boundary, adapts again, and repeats. This is illustrated in Figure 1 (left). However, in many realistic settings, the task boundaries are not known, and instead the tasks shift gradually over time. The discrete “resetting” procedure is a poor fit in such cases, and we would like to simply continue adapting the weights over time without ever resetting back to the meta-trained parameters, still benefit from a concurrent meta-training process. For example, a metatrained image-tagging model on the Internet (e.g., tagging friends in photographs) might gradually adapt to changing patterns and preferences of its users over time, where it would be unnatural to assume discrete shifts in what users want to tag. Similarly, a traffic prediction system might adapt to changing traffic patterns, including periodic changes due to seasons, and unexpected changes due to shifting economic conditions, weather, and accidents. In this spirit, our method does not require any knowledge on the task boundaries as well as stays fully-online through out the learning.
|
| 17 |
+
|
| 18 |
+
The main contribution of our paper is FOML (fully online meta-learning), an online meta-learning algorithm that continually updates its online parameters with each new datapoint or batch of datapoints, while simultaneously performing meta-gradient updates on a separate set of meta-parameters using a buffer of previously seen data. FOML does not require ground truth knowledge of task boundaries, and does not reset the online parameters back to the meta-parameters between tasks, instead updating the online parameters continually in a fully online fashion. We compare FOML empirically to strong baselines and a state-of-the-art prior online meta-learning method, showing that FOML learns to adapt more quickly, and achieves lower error rates, both on a simple sequential image classification task from prior work and a more complex benchmark that we propose based on the CIFAR100 dataset, with a sequence of 1200 tasks.
|
| 19 |
+
|
| 20 |
+
# 2 RELATED WORK
|
| 21 |
+
|
| 22 |
+
Online meta-learning brings together ideas from online learning, meta learning, and continual learning, with the aim of adapting quickly to each new task while simultaneously learning how to adapt even more quickly in the future. We discuss these three sets of approaches next.
|
| 23 |
+
|
| 24 |
+
Meta Learning: Meta learning methods try to learn the high-level context of the data, to behave well on new tasks (Learning to learn). These methods involve learning a metric space Koch et al. (2015); Vinyals et al. (2016); Snell et al. (2017); Yang et al. (2017), gradient based updates Finn et al. (2017); Li et al. (2017); Park & Oliva (2019); Nichol et al. (2018); Nichol & Schulman (2018), or some specific architecture designs Santoro et al. (2016); Munkhdalai & Yu (2017); Ravi & Larochelle (2016).
|
| 25 |
+
|
| 26 |
+
In this work, we are mainly interested in gradient based meta learning methods for online learning. MAML Finn et al. (2017) and its variants Nichol et al. (2018); Nichol & Schulman (2018); Li et al. $\textcircled { 2 0 1 7 }$ ; Park & Oliva (2019); Antoniou et al. (2018) first meta train the models in such a way that the meta parameters are close to the optimal task specific parameters (good initialization). This way, adaptation becomes faster when fine tuning from the meta parameters. However, directly adapting this approach into an online setting will require more relaxation on online learning assumptions, such as access to task boundaries and resetting back and froth from meta parameters. Our method does not require knowledge of task boundaries.
|
| 27 |
+
|
| 28 |
+
Online Learning: Online learning methods update their models based on the stream of data sequentially. There are various works on online learning using linear models Cesa-Bianchi & Lugosi (2006), non-linear models with kernels Kivinen et al. (2004); Jin et al. (2010), and deep neural networks Zhou $\boxed { \mathrm { e t ~ a l . } } \boxed { \mathbb { 2 0 1 2 } }$ . Online learning algorithms often simply update the model on the new data, and do not consider the past knowledge of the previously seen data to do this online update more efficiently. However, the online meta learning framework, allow us to keep track of previously seen data and with the “meta” knowledge we can update the online weights to the new data more faster and efficiently.
|
| 29 |
+
|
| 30 |
+
Continual Learning: A number of prior works on continual learning have addressed catastrophic forgetting McCloskey & Cohen (1989); Li & Hoiem (2017); Ratcliff (1990); Rajasegaran et al. $\bar { ( 2 0 1 9 ) } / \bar { 2 0 2 0 } \}$ , removing the need to store all prior data during training. Our method does not address catastrophic forgetting for the meta-training phase, because we must still store all data so as to “replay” it for meta-training, though it may be possible to discard or sub-sample old data (which we leave to future work). However, our adaptation process is fully online. A number of works perform metalearning for better continual learning, i.e. learning good continual learning strategies Al-Shedivat et al. (2017); Nagabandi et al. (2018); Javed & White (2019); Harrison et al. (2019); He et al. (2019); Beaulieu et al. (2020). However, these prior methods still perform batch-mode meta-training. In batch-mode meta-training, these methods first collect all of the past data and train a model with a meta-learning algorithm (e.g. MAML, Reptile) then take this pretrained weights and fine-tune this model with data from new task. Oh the other hand, our method performs the meta-training incrementally online. In other words, we do not stop at a task boundary and train a model will all data, and re-start again, our method continuously update meta-parameters.
|
| 31 |
+
|
| 32 |
+
The closest work to ours is the follow the meta-leader (FTML) method Finn et al. $\textcircled { 2 0 1 9 }$ and other online meta-learning methods $\underline { { \mathrm { [ Y a o e t a l . ] } } } ( \underline { { 2 0 2 0 } } )$ . FTML is a variant of MAML that finetunes to each new task in turn, resetting to the meta-trained parameters between every task. While this effectively accelerates acquisition of new tasks, it requires ground truth knowledge of task boundaries and, as we show in our experiments, our approach outperforms FTML even when FTML has access to task boundaries and our method does not. Note that the memory requirements for such methods increase with the number of adaptation gradient steps, and this limitation is also shared by our approach. Online-within-online meta-learning Denevi et al. (2019) also aims to accelerate online updates by leveraging prior tasks, but still requires knowledge of task boundaries. MOCA Harrison et al. (2020) instead aims to infer the task boundaries. In contrast, our method does not even attempt to find the task boundaries, but directly adapts without them. A number of related works also address continual learning via meta-learning, but with the aim of minimizing catastrophic forgetting Gupta et al. (2020); $\mathtt { \boxed { C a c c i a e t a l . } } \mathtt { \boxed { 2 0 2 0 } }$ . Our aim is not to address catastrophic forgetting. Our method also meta-trains from small datasets for thousands of tasks, whereas prior continual learning approaches typically focus on settings with fewer larger tasks (e.g., 10-100 tasks).
|
| 33 |
+
|
| 34 |
+
# 3 FOUNDATIONS
|
| 35 |
+
|
| 36 |
+
Prior to diving into online meta learning, we first briefly summarize meta learning, model agnostic meta-learning, and online learning in this section.
|
| 37 |
+
|
| 38 |
+
Meta-learning: Meta-learning address the problem of learning to learn. It uses the knowledge learned from previous tasks to quickly learn new tasks. Meta-learning assumes that the tasks are drawn from a stationary distribution $\tau \sim \mathbb { P } ( \tau )$ . During the meta-training phase (outer-loop), $N$ tasks are assumed to be drawn from this distribution to produce the meta-training set, and the model is trained in such a way that, when a new task with its own training and test data $\mathcal { T } = \{ \mathcal { D } _ { \mathcal { T } } ^ { t r } , \mathcal { D } _ { \mathcal { T } } ^ { t e } \}$ is T Tpresented to it at meta-test time, the model should be able to adapt to this task quickly (inner-loop). Using $\theta$ to denote the meta-trained parameters, the meta-learning objective is:
|
| 39 |
+
|
| 40 |
+
$$
|
| 41 |
+
\theta ^ { * } = \arg \operatorname* { m a x } _ { \theta } \mathbb { E } _ { \mathcal { D } _ { \mathcal { T } } ^ { t r } \mathrm { ~ w h e r e ~ } \mathcal { T } \sim \mathbb { P } ( \mathcal { T } ) } \left[ \mathcal { L } ( F _ { \theta } ( \mathcal { D } _ { \mathcal { T } } ^ { t r } ) , \mathcal { D } _ { \mathcal { T } } ^ { t e } ) \right] ,
|
| 42 |
+
$$
|
| 43 |
+
|
| 44 |
+
where $F _ { \theta }$ is the meta-learned adaptation process that reads in the training set $\mathcal { D } _ { t } ^ { t r }$ and outputs task-specific parameters, prototypes, or features (depending on the method) for the new task $\tau _ { i }$ .
|
| 45 |
+
|
| 46 |
+
Model-agnostic meta-learning: In MAML Finn et al. (2017), the inner-loop function is (stochastic) gradient descent. Hence, during the MAML inner-loop adaptation, $F _ { \theta } ( \mathcal { D } _ { i } ^ { t r } )$ becomes $\theta - \bar { \alpha } \nabla \mathcal { L } _ { \theta } ( \theta , \mathcal { D } _ { i } ^ { t r } )$ (or, more generally, multiple gradient steps). Intuitively, what this means is that meta-training with MAML produces a parameter vector $\theta$ that can quickly adapt to any task from the meta-training distribution via gradient descent on the task loss. The principle benefits of this is that, when faced with a new task that differs from those seen during meta-training, the algorithm “at worst” adapts with regular gradient descent, and at best is massively accelerated by the meta-training.
|
| 47 |
+
|
| 48 |
+
Online learning: In online learning, the model faces a sequence of loss functions $\{ \mathcal { L } _ { t } \} _ { t = 1 } ^ { \infty }$ and a sequence of data $\{ \mathcal { D } _ { t } = \{ ( x , y ) \} \} _ { t = 1 } ^ { \infty }$ for every time step $t$ . The function $f : x \hat { y }$ maps inputs $x$ to predictions $\hat { y }$ . The goal of an online learning algorithm is to find a set of parameters for each time step $\{ \phi \} _ { t = 1 } ^ { \infty }$ , such that the overall loss between the predictions $\hat { y }$ and the ground truth labels $y$ is minimized over the sequence. This is typically quantified in terms of regret:
|
| 49 |
+
|
| 50 |
+
$$
|
| 51 |
+
\mathrm { R e g r e t } _ { T } = \sum _ { t = 1 } ^ { T } \mathcal L _ { t } ( \phi , \mathcal D _ { t } ) - \sum _ { t = 1 } ^ { T } \mathcal L _ { t } ( \phi _ { t } , \mathcal D _ { t } ) .
|
| 52 |
+
$$
|
| 53 |
+
|
| 54 |
+
where, $\begin{array} { r } { \phi _ { t } = \mathrm { a r g m i n } _ { \phi } \mathcal { L } _ { t } ( \phi , \mathcal { D } _ { t } ) } \end{array}$ . The first term measures the loss from the online model, and the second term measures the loss of the best possible model on that task. Various online algorithms try to minimize the regret as much as possible when introducing new tasks.
|
| 55 |
+
|
| 56 |
+
# 4 ONLINE META-LEARNING: PROBLEM STATEMENT AND METHODS
|
| 57 |
+
|
| 58 |
+
In an online meta-learning setting Finn et al. $\underline { { \left( 2 0 1 9 \right) } }$ , the model $f _ { \phi }$ observes datapoints one at a time from an online data stream $s$ . Each datapoint consists of an input $\ v { x } _ { m } ^ { t }$ , where $t$ is the task index and $m$ is the index of the datapoint within that task, and a label $y _ { m } ^ { t }$ . The task changes over time and the model should be able to update the parameters $\phi$ to minimize the loss at each time step. The goal of online meta-learning is to quickly learn each new task $\mathcal { T } _ { t }$ and perform well as soon as possible according to the specified loss function.
|
| 59 |
+
|
| 60 |
+
Here, we define a task as a group of samples based on some discrete variable properties in the samples. For example, it can be grouped by classes, a set of classes, semantic categories or time stamp etc. A simple baseline solution would be to just train the model on the current task $\mathcal { T } _ { t }$ . We denote this baseline as TFS (Train from Scratch). For every new task, the model simply trains a new set of parameters using all of the data from the current task $\mathcal { T } _ { t }$ that has been seen so far:
|
| 61 |
+
|
| 62 |
+
$$
|
| 63 |
+
\phi _ { T F S } ^ { t } = \arg \operatorname* { m i n } _ { \phi } \frac { 1 } { M } \sum _ { m = 1 } ^ { M } \mathcal { L } _ { t } ( \phi , ( x _ { m } ^ { t } , y _ { m } ^ { t } ) ) .
|
| 64 |
+
$$
|
| 65 |
+
|
| 66 |
+
TFS has two issues. First, it requires the task boundaries to be known, which can make it difficult to apply to settings where this information is not available. Second, it does not utilize knowledge from other tasks, which greatly limits its performance even when task boundaries are available.
|
| 67 |
+
|
| 68 |
+
A straightforward way to utilize knowledge from other tasks in the online data stream is to store all the seen tasks in a large buffer $\boldsymbol { B }$ , and simply keep training the model on all of the seen tasks. We will refer to this baseline method as TOE (Train on Everything):
|
| 69 |
+
|
| 70 |
+
$$
|
| 71 |
+
\phi _ { T O E } ^ { t } = \arg \operatorname* { m i n } _ { \phi } \frac { 1 } { M t } \sum _ { i = 1 } ^ { t } \sum _ { m = 1 } ^ { M } \mathcal { L } _ { i } ( \phi , ( x _ { m } ^ { i } , y _ { m } ^ { i } ) ) .
|
| 72 |
+
$$
|
| 73 |
+
|
| 74 |
+
TOE learns a function that fits all of the previously seen samples. However, this function may be far from optimal for the task at hand, because the different tasks may be mutually exclusive. Therefore, fitting a single model on all of the previously seen tasks might not provide a good task-specific model for the current task. A more sophisticated baseline, which we refer to as FTL (Follow the Leader), pre-trains a model on all of the previous tasks, and then fine-tunes it only on the data from the current task. Note that this is subtly different from FTL in the classic online learning setting, due to the difference in problem formulation. This can be achieved by initializing $\phi$ with pretrained weights up to the previous task $\phi _ { T O E } ^ { t - 1 }$ :
|
| 75 |
+
|
| 76 |
+
$$
|
| 77 |
+
\phi _ { F T L } ^ { \mathrm { { \large { t } } } } = \arg \operatorname* { m i n } _ { \phi } \frac { 1 } { M } \sum _ { m = 1 } ^ { M } \mathcal { L } _ { t } ( \phi _ { T O E } ^ { t - 1 } , ( x _ { m } ^ { t } , y _ { m } ^ { t } ) ) .
|
| 78 |
+
$$
|
| 79 |
+
|
| 80 |
+
Here, for the task $t$ , we take a model that is pre-trained on all previously seen tasks $( f _ { \phi _ { T O E } ^ { t - 1 } } )$ and fine-tune on the current task data. In this way, FTL can use the past knowledge to more quickly adapt to the new task. However, pre-training on past tasks may not necessarily result in an initialization that is conducive to fast adaptation Finn et al. (2017); Nichol et al. (2018); Nichol & Schulman (2018); Li $\boxed { \mathrm { e t ~ a l . } } \textcircled { 1 2 0 1 7 }$ . Finn et al. Finn et al. $\mathbb { Z 0 1 9 }$ proposed a MAML-based online meta-learning approach, where MAML is used to meta-train a “meta-leader” model on all previously seen tasks, which is then adapted on all data from the current task. This way, the meta-leader parameters will be much closer to new task optimal parameters, and because of this it is much faster to adapt to new tasks from the online data.
|
| 81 |
+
|
| 82 |
+
$$
|
| 83 |
+
\begin{array} { r } { \phi _ { F T M L } ^ { t } = \underset { \phi _ { M A M L } ^ { t - 1 } } { \arg \operatorname* { m i n } } \mathbb { E } _ { ( x _ { m } ^ { t } , y _ { m } ^ { t } ) \sim T _ { t } } [ \mathcal { L } _ { t } \big ( \phi _ { M A M L } ^ { t - 1 } , ( x _ { m } ^ { t } , y _ { m } ^ { t } ) \big ) ] . } \\ { \mathrm { w h e r e } , ~ \phi _ { M A M L } ^ { t - 1 } = \underset { \phi } { \arg \operatorname* { m i n } } \mathbb { E } _ { T _ { j } \sim \mathcal { D } ( T _ { t - 1 } ) } [ \mathcal { L } _ { j } \big ( \phi - \nabla \mathcal { L } _ { j } ( \phi , \mathcal { D } _ { j } ^ { t r } ) , \mathcal { D } _ { j } ^ { t e } ) ] . } \end{array}
|
| 84 |
+
$$
|
| 85 |
+
|
| 86 |
+
Here, FTML algorithm first train a model using MAML algorithm on last seen t-1 tasks $\mathcal { T } _ { t - 1 } =$ $\{ T _ { 1 } , T _ { 2 } , . . . , T _ { t - 1 } \}$ to generate a meta-weights $\phi _ { M A M L } ^ { t - 1 }$ (Eq.7). After this pre-training stage, FTML algorithm fine-tunes the meta-weights using the data from next tasks to find optimal parameters $\phi _ { F T M L } ^ { t }$ for task t. FTL and FTML aim to efficiently use knowledge from past tasks to quickly adapt to the new task. However, the pre-trained weights from FTL do not guarantee fast adaptation, and both methods require ground-truth task boundaries. This assumption may not be realistic in real-world settings, where the tasks may change gradually and no external information is available to indicate task transitions. Although FTML can enable fast adaptation, the model needs to be “reset” at each task, essentially creating a “branch” on each task. This requires maintaining two independent learning processes: a) an adaptation process, whose result is discarded completely at the end of the task, and b) a meta-training process, which does not influence the current task at all, and is only used for forward transfer into future tasks. See Figure 1 for the branching in standard meta learning setting. This branching at task boundaries and “resetting” after the adaptation makes these the parameter trajectory not continuous, hence we argue that FTL and FTML are not fully online. In this work, our aim is to develop a fully online meta-learning method that continually performs both “fast” updates and “slow” meta-updates, does not periodically “reset” the adapted parameters back to the meta-parameters, and does not require any ground truth knowledge of task boundaries.
|
| 87 |
+
|
| 88 |
+
# 5 FULLY ONLINE META-LEARNING WITHOUT TASK BOUNDARIES
|
| 89 |
+
|
| 90 |
+
We first discuss the intuition behind how our approach handles online meta-learning without task boundaries. In many real-world tasks, we might expect the tasks in the online data stream to change gradually. This makes it very hard to draw a clear boundary between the tasks. Therefore, it is necessary to relax task boundary assumption if we want a robust online learner that can work on a real-world data stream. Additionally, since nearby data points are most likely to belong to the same or similar task, we would expect adaptation to each new data point to be much faster from a model that has already been adapted to other recent data points.
|
| 91 |
+
|
| 92 |
+
FOML maintains two separate parameter vectors for the online updates $( \phi )$ and the meta updates $\mathbf { \eta } ^ { ( \theta ) }$ . Both parameterize the same architecture, such that $f _ { \phi }$ and $f _ { \theta }$ represent the same neural network, but with different weights. The online model continuously reads in the latest datapoints from the online data stream, and updates the parameters $\phi$ in online fashion, without any boundaries or resets. However, simply updating the online model on each data point naïvely will not meta-train it to adapt more quickly, and may even result in drift, where the model forgets prior data. Therefore, we also incorporate a regularizer into the online update that is determined by a concurrent meta-learning process (see Fig. $\overline { { 2 } } )$ . Note that FOML only incorporates the meta-parameters into the online updates via the meta-learned regularization term, without ever resetting the online parameters back to the meta-parameters (in contrast, e.g., to FTML Finn et al. (2019))
|
| 93 |
+
|
| 94 |
+
The meta-updates of previous MAML-based online meta-learning approaches involve sampling data from all of the tasks seen so far, and then updating the meta-parameters $\theta$ based on the derivatives of the MAML objective. This provides a diverse sampling of tasks for the meta update, though it requires storing all of the seen data $\boxed { \mathrm { F i n n ~ e t ~ a l . } } \textcircled { 2 0 1 9 }$ . We also use a MAML-style update for the meta parameters, and also require storing the previously seen data. To this end, we will use $\boldsymbol { B }$ to denote a buffer containing all of the data seen so far. Each new datapoint is added to $\boldsymbol { B }$ once the label is observed.
|
| 95 |
+
|
| 96 |
+
However, since we do not assume knowledge of task boundaries, we cannot sample entire tasks from $\boldsymbol { B }$ , but instead must sample individual datapoints. We therefore adopt a different strategy, which we describe in Section $\boxed { 5 . 2 }$ as shown in $\mathrm { F i g } { \overline { { \bigcirc } } }$ instead of aiming to sample in complete tasks from the data buffer, we simply sample random past datapoints, and meta-train the regularizer so that the online updates retain good performance on all past data. We find that this strategy is effective at accelerating acquisition of future tasks in online meta-learning settings where the tasks are not mutual exclusive. We define both types of updates in detail in the next sections.
|
| 97 |
+
|
| 98 |
+

|
| 99 |
+
Figure 2: Overview of FOML learning: FOMLupdates the online parameters $\phi$ using only the most recent $K$ datapoints from the buffer $\boldsymbol { B }$ . Meta-learning learns a regularizer, parameterized by meta-parameters $\theta$ , via second-order MAML-style updates. The goal of metalearning is to make $\phi$ perform well on randomly sampled prior datapoints after performing $K$ steps with the metatrained regularizer.
|
| 100 |
+
|
| 101 |
+
# 5.1 FULLY ONLINE ADAPTATION
|
| 102 |
+
|
| 103 |
+
At each time step, FOML observes a data point $x _ { t }$ , predicts its label $\hat { y } _ { t }$ , then receives the true label $y _ { t }$ and updates the online parameters. In practice, we make updates after observing $N$ new datapoints $N = 1 0$ in our experiments), so as to reduce the variance of the gradient updates. We create a small dataset $\mathcal { D } _ { t r } ^ { j }$ with these $N$ datapoints for the time step $j$ . The true label for these datapoints can be from class labels, annotations, rewards, or even self-supervision, though we focus on the supervised classification setting in our experiments.
|
| 104 |
+
|
| 105 |
+
However, the online updates are based only on the most recent samples, and do not make use of any past data. Therefore, we need some mechanism for the (slower) meta-training process to “transfer” the knowledge it is distilling from the prior tasks into this online parameter vector. We can instantiate such a mechanism by introducing a regularizer into the online parameter update that depends on the meta-parameters $\theta$ , which we denote as $\mathcal { R } ( \phi , \theta )$ . While a variety of parameterizations could be used for $\mathcal { R } ( \phi , \theta )$ , we opt for a simple squared error term of the form $\mathcal { R } ( \bar { \phi } , \theta ) = ( \phi - \theta ) ^ { 2 }$ , resulting in the following online update at each step $j$ :
|
| 106 |
+
|
| 107 |
+
$$
|
| 108 |
+
\begin{array} { r l } & { \phi ^ { j } = \phi ^ { j - 1 } - \alpha _ { 1 } \nabla _ { \phi ^ { j - 1 } } \{ \mathcal { L } ( \phi ^ { j - 1 } ; \mathcal { D } _ { t r } ^ { j } ) + \beta _ { 1 } \mathcal { R } ( \phi ^ { j - 1 } , \theta ) \} } \\ & { \quad = \phi ^ { j - 1 } - \underbrace { \alpha _ { 1 } \nabla _ { \phi ^ { j - 1 } } \mathcal { L } ( \phi ^ { j - 1 } ; \mathcal { D } _ { t r } ^ { j } ) } _ { \mathrm { t a s k ~ s p e c i f i c ~ u p d a t e } } + \underbrace { 2 \alpha _ { 1 } \beta _ { 1 } ( \theta - \phi ^ { j - 1 } ) } _ { \mathrm { m e t a ~ d i r e c t i o n a l ~ u p d a t e } } } \end{array}
|
| 109 |
+
$$
|
| 110 |
+
|
| 111 |
+
In the case of classification, $\mathcal { L }$ is the cross-entropy loss. $\alpha _ { 1 } , \beta _ { 1 }$ are hyperparameters.
|
| 112 |
+
|
| 113 |
+
Next, we discuss how these meta-parameters are trained so as to maximize the effectiveness of this regularizer at accelerating adaption to new tasks.
|
| 114 |
+
|
| 115 |
+
# 5.2 META-LEARNING WITHOUT TASK BOUNDARIES
|
| 116 |
+
|
| 117 |
+
As discussed in the previous section, the online updates to $\phi ^ { j }$ include a regularizer $\mathcal { R }$ that transfers knowledge from the meta-parameters $\theta$ into each online update. Additionally, our method maintains a buffer $\boldsymbol { B }$ containing all data seen so far, which is used for the meta-update.
|
| 118 |
+
|
| 119 |
+
In contrast to prior methods, which explicitly draw a training and validation set from the buffer (i.e., a query and support set) and then perform a separate “inner loop” update on this training set Finn $\boxed { \dot { \mathrm { e t ~ a l . } } } \boxed { ( 2 0 1 9 ) }$ , our meta-updates recycle the inner loop adaptation that is already performed via the online updates, and therefore we only draw a validation set $\mathcal { D } _ { v a l } ^ { m }$ from the buffer $\boldsymbol { B }$ . Specifically, we sample a set of using the gradi $N$ datapoints at rt of the loss on m from and th $\boldsymbol { B }$ to form egulariz $\mathcal { D } _ { v a l } ^ { m }$ . We then upafter the last e the meta-updates on rameters . $\theta$ $\mathcal { D } _ { v a l } ^ { m }$ $\mathcal { R }$ $K$ $\phi$
|
| 120 |
+
|
| 121 |
+
In other words, we adjust the meta-parameters in such a way that, if an online update is regularized with this meta-weights, then the loss on the online update will be minimized. This can be expressed via following meta update:
|
| 122 |
+
|
| 123 |
+
$$
|
| 124 |
+
\left. \begin{array} { l } { { \displaystyle { \sf I a t e } : \int } _ { } \\ { { \theta = \theta - \alpha _ { 2 } \nabla _ { \theta } \left\{ { \mathcal L } \left( \phi ^ { j } ; { \mathcal D } _ { v a l } ^ { m } \right) + \beta _ { 2 } \sum _ { k = 0 } ^ { K } { \mathcal R } ( \theta , \phi ^ { j - k } ) \right\} } } } \end{array} \right.
|
| 125 |
+
$$
|
| 126 |
+
|
| 127 |
+
Here, the $\phi ^ { j }$ has dependence on $\theta$ due to the previous online update as shown in Eq. 9. Subsequently, $\theta$ and $\phi ^ { j }$ are only related via regularization term, unlike FTML Finn et al. (2019), which sets $\phi ^ { 0 } = \theta$ at every task boundary.
|
| 128 |
+
|
| 129 |
+
The choice of sampling $\mathcal { D } _ { v a l } ^ { m }$ at random from $\boldsymbol { B }$ has several interpretations. We can interpret this as regularizing $\phi$ to prevent the online parameters from drifting away from solutions that also work well on the entire data buffer. However, this interpretation is incomplete, since the meta-update doesn’t simply keep $\phi$ close to a single parameter vector that works well on $\mathcal { D } _ { v a l } ^ { m }$ , but rather changes the regularizer so that gradient updates with that regularizer maximally improve performance on $\mathcal { D } _ { v a l } ^ { m }$ . This has the effect of actually accelerating how quickly $\phi$ can adapt to new tasks using this regularizer, so long as past tasks are reasonably representative of prior tasks. We experimentally verify this claim in our experiments. Note, however, that this scheme does assume that the tasks are not mutually exclusive. We summarize the complete algorithm in Algorithm 1.
|
| 130 |
+
|
| 131 |
+
# Algorithm 1 Online Meta Learning with FOML
|
| 132 |
+
|
| 133 |
+
<table><tr><td colspan="2">1: procedure META TRAINING</td></tr><tr><td>2: Require:0,B,,BufferB,Data streamS</td><td> Initiate ° with .</td></tr><tr><td>3: ←</td><td></td></tr><tr><td>4:</td><td>while Data stream S available do</td></tr><tr><td>5: D↑S</td><td>V get new data from online data-stream</td></tr><tr><td>6: B↑B+Dj</td><td>>add new data to the buffer</td></tr><tr><td>7:</td><td>DDa←D > partition the data into train and validation splits</td></tr><tr><td>8:</td><td>ytr←fj-1(Dr) > make predictions on the train set</td></tr><tr><td>9: ↑11</td><td>-α1VΦj-1{Ltask(Φì-1;D𝑖r)+βR(ρj-1,0)}</td></tr><tr><td>10: yval←(Dval)</td><td>>Evaluate the updated model on the validation set</td></tr><tr><td>11: Dmt ~ random-sample(B)</td><td>> sample random batch from buffer</td></tr><tr><td>12:</td><td>0←0-a2VθLtask(Φ;Dmt)</td></tr><tr><td>13: j←j+1</td><td></td></tr></table>
|
| 134 |
+
|
| 135 |
+
# 6 EXPERIMENTAL EVALUATION
|
| 136 |
+
|
| 137 |
+
Our experiments focus on online meta-learning of image classification tasks. In these settings, an effective algorithm should adapt to changing tasks as quickly as possible, rapidly identify when the task has changed, and adjust its parameters accordingly. Furthermore, a successful algorithm should make use of past task shifts to meta-learn effectively, thus accelerating the speed with which it adapts to future task changes. In all cases, the algorithm receives one data point at a time, and the task changes periodically. In order to allow for a comparison with prior methods, which generally assume known task boundaries, the data stream is partitioned into discrete tasks, but our algorithm is not aware of which datapoint belongs to which tasks or where the boundaries occur. The prior methods, in contrast, are provided with this information, thus giving them an advantage. We first describe the specific task formulations, and then the prior methods that we compare to.
|
| 138 |
+
|
| 139 |
+
Online meta-learning should adapt to each task as quickly as possible, and use data from past to accelerate acquisition of future tasks. We report our learning curves, with one axis corresponding to the number of seen tasks, and the other axis corresponding to the cumulative error rate on that task. This error rate is computed using a held-out validation data for the task after adaptation.
|
| 140 |
+
|
| 141 |
+
We evaluate prior online meta-learning methods and baselines on three different datasets (RainbowMNIST, CIFAR100 and CELEBA). TOE (train on everything), TFS (train from scratch), FTL (follow the leader), FTML (follow the meta-leader) Finn et al. (2019), LwF Li & Hoiem (2017), iCaRL Rebuffi et al. (2016) and MOCA Harrison et al. (2020) are the baseline methods we compare against our method FOML. See Section 4 for more detailed description of these methods. Please see Appendix A.2 for more details on the baseline methods.
|
| 142 |
+
|
| 143 |
+
Datasets: We compare TOE, TFS, FTL, FTML, LwF, iCaLR and FOML on three different datasets. Rainbow-MNIST Finn et al. (2019) was created by changing the background color, scale and rotation of the MNIST dataset. It includes 7 different background colors, 2 scales (full and half) and 4 different rotations. This leads to a total of 56 number of tasks. Each individual task is to classify the images into 10 classes. We use the same partition with 900 samples per each task, as in prior work Finn $\boxed { \mathrm { e t ~ a l . } } \textcircled { 2 0 1 9 }$ . However, this task contains relatively simple images, and only 56 tasks. To create a much longer task sequence with significantly more realistic images, we modified the CIFAR-100 and CELEBA datasets to create an online meta-learning benchmark, which we call online-CIFAR100 and online-CELEBA, respectively. Every task is a randomly sampled set of classes, and the goal is to classify whether two images in this set belongs to same class or not. Specifically, each task corresponds to 5 classes, and every datapoint consists of a pair of images, each corresponding to one of the 5 classes for that task. The goal is to predict whether the two images belong to the same class or not. Note that different tasks are not mutually exclusive, which in principle should favor a TOE-style method, since meta-learning is known to underperform with non-mutually-exclusive tasks Yin et al. $\textcircled { 2 0 1 9 }$ . To make sure the data distribution changes smoothly over tasks, we only change a subset of the classes between consecutive tasks.
|
| 144 |
+
|
| 145 |
+

|
| 146 |
+
Figure 3: Comparison between online algorithms: We compare our method with baselines and prior approaches, including TFS (Train from Scratch), TOE (Train on Everything), FTL (Follow the Leader) and FTML (Follow the Meta Leader). a: Performance relative to the number of tasks seen over the course of online training on the Rainbow-MNIST dataset. As the number of task increases, FOML achieves lower error rates compared to other methods. We also compare our method with continual learning baselines: LwF Li & Hoiem (2017), iCaRL Rebuffi et al. $\boxed { 2 0 1 6 }$ and MOCA Harrison et al. (2020). MOCA Harrison et al. (2020) archive similar performance to ours at the end of the learning, but FOML makes significantly faster progress. b: Error rates on the Online-CIFAR100 dataset. Note that FOML not only achieves lower error rates on average, but also reaches the lowest error (of around $17 \%$ ) more quickly than the other methods. c: Performance of FOML on the CELEBA dataset. This dataset contains more than 1000 classes, and we follow the same protocol as in Online-CIFAR100 experiments. Our method, FOML, learns more quickly on this task as well.
|
| 147 |
+
|
| 148 |
+
Results on Rainbow-MNIST: As shown in $\mathrm { F i g } \bigstar \bigstar$ FOML attains the lowest error rate on most tasks in Rainbow-MNIST, except a small segment in the beginning. The performance of TFS is similar across all the tasks, and does not improve over time. This is because it resets its weights every time it encounters a new task, and therefore cannot not gain any advantage from past data. TOE has larger error rates at the start, but as we add more data into the buffer, TOE is able to improve. On the other hand, both FTL and FTML start with similar performance, but FTML achieve much lower error rates at the end of the sequence compared to FTL, consistently with prior work Finn et al. (2019). The final error rates of FOML are around $10 \%$ , and it reaches this performance significantly faster than FTML, after less than 20 tasks. Note that FTML also has access to task boundaries, while FOML does not.
|
| 149 |
+
|
| 150 |
+
Results on Online-CIFAR100 and Online-CELEBA: We use a Siamese network for this experiment, where each image is fed into a 7-layer convolutional network, and each branch outputs a 128 dimensional embedding vector. A difference of these vectors are fed into a fully connected layer for the final classification. Each task contains data from 5 classes, and each new task introduces three new classes, and retains two of the classes from the previous task, providing a degree of temporal coherence while still requiring each algorithm to handle persistent shift in the task. $\mathrm { F i g } \ 3$ shows the error rates of various online learning methods, where each method is trained over a sequence of 1200 tasks for online-CIFAR100. All the methods start with initial error rates of $50 \%$ . The tasks are not mutually exclusive, so in principle TOE can attain good performance, but it makes the slowest progress among all the methods, suggesting that simple pretraining is not sufficient to accelerate learning. FTL uses a similar pre-training strategy as TOE. However it has an adaptation stage where the model is fine-tuned on the new task. This allows it to make slower progress. As expected from prior work $\lvert \lvert \dim \operatorname { e t } \mathrm { a l . } \rvert \langle 2 0 1 9 \rvert$ , the meta-learning procedure used by FTML allows it to make faster progress than FTL. However, FOML makes faster progress on average, and achieves the lowest final error rate $( \sim 1 5 \%$ ) after sequence of 1200 tasks.
|
| 151 |
+
|
| 152 |
+

|
| 153 |
+
Figure 4: Ablation experiments: a) We vary the number of online updates $K$ used before the meta-update, to see how it affects the performance of our method. The performance of FOML improves as the number of online updates is increased. b) This experiment shows how FOML performs with and without meta updates, to confirm that the meta-training is indeed an essential component of our method. With meta-updates, FOML learns more quickly, and performance improves with more tasks.
|
| 154 |
+
|
| 155 |
+
# 6.1 ABLATION STUDIES
|
| 156 |
+
|
| 157 |
+
We perform various ablations by varying the number of online parameters used for the meta-update $K$ , importance of meta-model to analysis the properties of our method. For additional ablations, please see the Appendix.
|
| 158 |
+
|
| 159 |
+
Number of online parameters used for the meta-update: Our method periodically updates the online weights and meta weights. The meta-updates involves taking $K$ recent online parameters and updating the meta model via MAML gradient. Therefore, meta-updates depend on the trajectory of the online parameters. In this experiment, we investigate how the performance of FOML changes as we vary the number of parameters used for the meta-update $K$ in Algorithm $\underset { - , - } { \mathrm { ~ 1 ) } }$ . Fig 4 shows the performance of our method with various values of $K$ : $K = [ 1 , 2 , 3 , 5 , 1 0 ]$ . We can see that the performance improves when we update the meta parameters over longer trajectory of online parameters (larger $K$ ). We speculate that this is due to the longer sequences providing a clearer signal for how the meta-parameters influence online updates over many steps.
|
| 160 |
+
|
| 161 |
+
Importance of meta update: FOML keeps track of separate online parameters and meta-parameters, and each is updated via corresponding updates. However, only the online parameters $\phi$ are used for evaluation. The meta-parameters $\theta$ only influence them via the regularizer and do not directly affect evaluation. This might raise the question: how important is the contribution of the meta-parameters to the performance of the algorithm during online training? We train a model with and without meta-updates, and the performance is shown in $\mathrm { F i g } 4 .$ None that, the model without meta-updates is identical to our method, except that the meta-updates themselves are not performed. We can clearly see that the model trained with meta-updates outperforms a model trained without meta-updates. The model trained without meta-updates generally does not improve significantly as more tasks are seen, while the model trained with meta-updates improves with each task, and reaches significantly lower final error. This shows that, even though $\theta$ and $\phi$ are decoupled and only connected via a regularization, the meta-learning component of our method really is critical for its good performance.
|
| 162 |
+
|
| 163 |
+
# 7 CONCLUSION
|
| 164 |
+
|
| 165 |
+
We presented FOML, a MAML-based algorithm for online meta-learning that does not require ground truth knowledge of task boundaries, and does not require resetting the parameter vector back to the meta-learned parameters for every task. FOML is conceptually simple, maintaining just two parameter vectors over the entire online adaptation process: a vector of online parameters $\phi$ , which are updated continually on each new batch of datapoints, and a vector of meta-parameters $\theta$ , which are updated correspondingly with meta-updates to accelerate the online adaptation process, and influence the online updates via a regularizer. We find that even a relatively simple task sampling scheme that selects datapoints at random from a buffer of all seen data enables effective meta-training that accelerates the speed with which FOML can adapt to each new task, and we find that FOML reaches a final performance that is comparable to or better than baselines and prior methods, while learning to adapt quickly to new tasks significantly faster. While our work focuses on supervised classification problems, a particularly exciting direction for future work is to extend such online meta-learning methods to other types of online supervision that may be more readily available, including self-supervision and prediction, so that models equipped with online meta-learning can continually improve as they see more of the world.
|
| 166 |
+
|
| 167 |
+
# REFERENCES
|
| 168 |
+
|
| 169 |
+
Maruan Al-Shedivat, Trapit Bansal, Yuri Burda, Ilya Sutskever, Igor Mordatch, and Pieter Abbeel. Continuous adaptation via meta-learning in nonstationary and competitive environments. arXiv preprint arXiv:1710.03641, 2017.
|
| 170 |
+
|
| 171 |
+
Antreas Antoniou, Harrison Edwards, and Amos Storkey. How to train your maml. arXiv preprint arXiv:1810.09502, 2018.
|
| 172 |
+
|
| 173 |
+
Shawn Beaulieu, Lapo Frati, Thomas Miconi, Joel Lehman, Kenneth O Stanley, Jeff Clune, and Nick Cheney. Learning to continually learn. arXiv preprint arXiv:2002.09571, 2020.
|
| 174 |
+
|
| 175 |
+
Massimo Caccia, Pau Rodriguez, Oleksiy Ostapenko, Fabrice Normandin, Min Lin, Lucas Caccia, Issam Laradji, Irina Rish, Alexandre Lacoste, David Vazquez, et al. Online fast adaptation and knowledge accumulation: a new approach to continual learning. arXiv preprint arXiv:2003.05856, 2020.
|
| 176 |
+
|
| 177 |
+
Mathilde Caron, Hugo Touvron, Ishan Misra, Hervé Jégou, Julien Mairal, Piotr Bojanowski, and Armand Joulin. Emerging properties in self-supervised vision transformers. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 9650–9660, 2021.
|
| 178 |
+
|
| 179 |
+
Nicolo Cesa-Bianchi and Gábor Lugosi. Prediction, learning, and games. Cambridge university press, 2006.
|
| 180 |
+
|
| 181 |
+
Giulia Denevi, Dimitris Stamos, Carlo Ciliberto, and Massimiliano Pontil. Online-within-online meta-learning. In ADVANCES IN NEURAL INFORMATION PROCESSING SYSTEMS 32 (NIPS 2019), volume 32, pp. 1–11. Neural Information Processing Systems (NeurIPS 2019), 2019.
|
| 182 |
+
|
| 183 |
+
Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. In International Conference on Machine Learning, pp. 1126–1135. PMLR, 2017.
|
| 184 |
+
|
| 185 |
+
Chelsea Finn, Aravind Rajeswaran, Sham Kakade, and Sergey Levine. Online meta-learning. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pp. 1920–1930. PMLR, 09–15 Jun 2019.
|
| 186 |
+
|
| 187 |
+
Sebastian Flennerhag, Andrei A Rusu, Razvan Pascanu, Francesco Visin, Hujun Yin, and Raia Hadsell. Meta-learning with warped gradient descent. arXiv preprint arXiv:1909.00025, 2019.
|
| 188 |
+
|
| 189 |
+
Gunshi Gupta, Karmesh Yadav, and Liam Paull. La-maml: Look-ahead meta learning for continual learning. arXiv preprint arXiv:2007.13904, 2020.
|
| 190 |
+
|
| 191 |
+
James Harrison, Apoorva Sharma, Chelsea Finn, and Marco Pavone. Continuous meta-learning without tasks. arXiv preprint arXiv:1912.08866, 2019.
|
| 192 |
+
|
| 193 |
+
James Harrison, Apoorva Sharma, Chelsea Finn, and Marco Pavone. Continuous meta-learning without tasks. Advances in neural information processing systems, 33, 2020.
|
| 194 |
+
|
| 195 |
+
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. corr abs/1512.03385 (2015), 2015.
|
| 196 |
+
|
| 197 |
+
Xu He, Jakub Sygnowski, Alexandre Galashov, Andrei A Rusu, Yee Whye Teh, and Razvan Pascanu. Task agnostic continual learning via meta learning. arXiv preprint arXiv:1906.05201, 2019.
|
| 198 |
+
|
| 199 |
+
Khurram Javed and Martha White. Meta-learning representations for continual learning. arXiv preprint arXiv:1905.12588, 2019.
|
| 200 |
+
|
| 201 |
+
Ghassen Jerfel, Erin Grant, Thomas L Griffiths, and Katherine Heller. Reconciling meta-learning and continual learning with online mixtures of tasks. arXiv preprint arXiv:1812.06080, 2018.
|
| 202 |
+
|
| 203 |
+
Rong Jin, Steven CH Hoi, and Tianbao Yang. Online multiple kernel learning: Algorithms and mistake bounds. In International conference on algorithmic learning theory, pp. 390–404. Springer, 2010.
|
| 204 |
+
|
| 205 |
+
Jyrki Kivinen, Alexander J Smola, and Robert C Williamson. Online learning with kernels. IEEE transactions on signal processing, 52(8):2165–2176, 2004.
|
| 206 |
+
|
| 207 |
+
Gregory Koch, Richard Zemel, Ruslan Salakhutdinov, et al. Siamese neural networks for one-shot image recognition. In ICML deep learning workshop, volume 2. Lille, 2015.
|
| 208 |
+
|
| 209 |
+
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.
|
| 210 |
+
|
| 211 |
+
Da Li and Timothy Hospedales. Online meta-learning for multi-source and semi-supervised domain adaptation. In European Conference on Computer Vision, pp. 382–403. Springer, 2020.
|
| 212 |
+
|
| 213 |
+
Zhenguo Li, Fengwei Zhou, Fei Chen, and Hang Li. Meta-sgd: Learning to learn quickly for few-shot learning. arXiv preprint arXiv:1707.09835, 2017.
|
| 214 |
+
|
| 215 |
+
Zhizhong Li and Derek Hoiem. Learning without forgetting. IEEE transactions on pattern analysis and machine intelligence, 40(12):2935–2947, 2017.
|
| 216 |
+
|
| 217 |
+
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.
|
| 218 |
+
|
| 219 |
+
Tsendsuren Munkhdalai and Hong Yu. Meta networks. In International Conference on Machine Learning, pp. 2554–2563. PMLR, 2017.
|
| 220 |
+
|
| 221 |
+
Anusha Nagabandi, Chelsea Finn, and Sergey Levine. Deep online learning via meta-learning: Continual adaptation for model-based rl. arXiv preprint arXiv:1812.07671, 2018.
|
| 222 |
+
|
| 223 |
+
Alex Nichol and John Schulman. Reptile: a scalable metalearning algorithm. arXiv preprint arXiv:1803.02999, 2(3):4, 2018.
|
| 224 |
+
|
| 225 |
+
Alex Nichol, Joshua Achiam, and John Schulman. On first-order meta-learning algorithms. arXiv preprint arXiv:1803.02999, 2018.
|
| 226 |
+
|
| 227 |
+
Eunbyung Park and Junier B Oliva. Meta-curvature. arXiv preprint arXiv:1902.03356, 2019.
|
| 228 |
+
|
| 229 |
+
Jathushan Rajasegaran, Munawar Hayat, Salman Khan, Fahad Shahbaz Khan, and Ling Shao. Random path selection for incremental learning. Advances in Neural Information Processing Systems, 2019.
|
| 230 |
+
|
| 231 |
+
Jathushan Rajasegaran, Salman Khan, Munawar Hayat, Fahad Shahbaz Khan, and Mubarak Shah. itaml: An incremental task-agnostic meta-learning approach. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 13588–13597, 2020.
|
| 232 |
+
|
| 233 |
+
Roger Ratcliff. Connectionist models of recognition memory: constraints imposed by learning and forgetting functions. Psychological review, 97(2):285, 1990.
|
| 234 |
+
|
| 235 |
+
Sachin Ravi and Hugo Larochelle. Optimization as a model for few-shot learning. 2016.
|
| 236 |
+
|
| 237 |
+
Sylvestre-Alvise Rebuffi, Alexander Kolesnikov, and Christoph H Lampert. icarl: Incremental classifier and representation learning. corr abs/1611.07725 (2016). arXiv preprint arXiv:1611.07725, 2016.
|
| 238 |
+
|
| 239 |
+
Adam Santoro, Sergey Bartunov, Matthew Botvinick, Daan Wierstra, and Timothy Lillicrap. Metalearning with memory-augmented neural networks. In International conference on machine learning, pp. 1842–1850. PMLR, 2016.
|
| 240 |
+
|
| 241 |
+
Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014.
|
| 242 |
+
|
| 243 |
+
Jake Snell, Kevin Swersky, and Richard S Zemel. Prototypical networks for few-shot learning. arXiv preprint arXiv:1703.05175, 2017.
|
| 244 |
+
|
| 245 |
+
Xingyou Song, Wenbo Gao, Yuxiang Yang, Krzysztof Choromanski, Aldo Pacchiano, and Yunhao Tang. Es-maml: Simple hessian-free meta learning. arXiv preprint arXiv:1910.01215, 2019. Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 1–9, 2015. 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. Flood Sung Yongxin Yang, Li Zhang, Tao Xiang, Philip HS Torr, and Timothy M Hospedales. Learning to compare: Relation network for few-shot learning.(2018). 2017. Huaxiu Yao, Yingbo Zhou, Mehrdad Mahdavi, Zhenhui Li, Richard Socher, and Caiming Xiong. Online structured meta-learning. arXiv preprint arXiv:2010.11545, 2020. Mingzhang Yin, George Tucker, Mingyuan Zhou, Sergey Levine, and Chelsea Finn. Meta-learning without memorization. arXiv preprint arXiv:1912.03820, 2019. Michael Zhang, James Lucas, Jimmy Ba, and Geoffrey E Hinton. Lookahead optimizer: k steps forward, 1 step back. Advances in neural information processing systems, 32, 2019. Guanyu Zhou, Kihyuk Sohn, and Honglak Lee. Online incremental feature learning with denoising autoencoders. In Artificial intelligence and statistics, pp. 1453–1461. PMLR, 2012.
|
md/dev/g3faCfrwm7/g3faCfrwm7.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Just Ask for Calibration: Strategies for Eliciting Calibrated Confidence Scores from Language Models Fine-Tuned with Human Feedback
|
| 2 |
+
|
| 3 |
+
Katherine Tian,∗† Eric Mitchell,∗‡ Allan Zhou,‡ Archit Sharma,‡ Rafael Rafailov‡ Huaxiu Yao,‡ Chelsea Finn,‡ Christopher D. Manning‡
|
| 4 |
+
|
| 5 |
+
†Harvard University ‡Stanford University ktian@college.harvard.edu eric.mitchell@cs.stanford.edu
|
| 6 |
+
|
| 7 |
+
# Abstract
|
| 8 |
+
|
| 9 |
+
A trustworthy real-world prediction system should produce well-calibrated confidence scores; that is, its confidence in an answer should be indicative of the likelihood that the answer is correct, enabling deferral to an expert in cases of low-confidence predictions. Recent studies have shown that unsupervised pretraining produces large language models (LMs) whose conditional probabilities are remarkably well-calibrated. However, the most widelyused LMs are fine-tuned with reinforcement learning from human feedback (RLHF-LMs), and some studies have suggested that RLHFLMs produce conditional probabilities that are very poorly calibrated. In light of this perceived weakness, we conduct a broad evaluation of methods for extracting confidence scores from RLHF-LMs. For RLHF-LMs such as ChatGPT, GPT-4, and Claude, we find that verbalized confidences emitted as output tokens are typically better-calibrated than the model’s conditional probabilities on the TriviaQA, SciQ, and TruthfulQA benchmarks, often reducing the expected calibration error by a relative $50 \%$ .
|
| 10 |
+
|
| 11 |
+
# 1 Introduction
|
| 12 |
+
|
| 13 |
+
Real-world prediction systems invariably make errors. However, some mitigation of these errors is possible if the system produces well-calibrated1 confidence estimates. In this case, the system’s least confident predictions correspond to those that are most likely to be incorrect, potentially allowing these predictions to be skipped or overridden by a human. In the context of language models, one consequence of poor calibration may be hallucination, where a language model confidently asserts incorrect facts or reasoning. While the ability of very large LMs to absorb and synthesize knowledge about the outside world has gained significant attention (Brown et al., 2020; Roberts et al., 2020; Bubeck et al., 2023), relatively little attention has been given to their well-calibratedness (Kadavath et al., 2022). Further, most existing analyses of the calibratedness of LLMs focus on models trained with maximum likelihood, while in practice, the most widely-used LLMs (such as ChatGPT) are fine-tuned using methods such as reinforcement learning from human feedback (Christiano et al., 2017). Some findings suggest that RLHF-LMs may sacrifice well-calibrated predictions for the sake of closer adherence to user instructions in dialogue (Kadavath et al., 2022; OpenAI, 2023), as the reinforcement learning objective encourages the model to allocate probability mass to the most preferred answer(s), rather than matching the relative frequency of possible answers.
|
| 14 |
+
|
| 15 |
+

|
| 16 |
+
Figure 1: Verbalized confidence scores (blue) are better-calibrated than log probabilities (orange) for gpt-3.5-turbo. Raw model probabilities (top-left) are consistently over-confident. Verbalized numerical probabilities (bottom) are better-calibrated. Considering more answer choices (bottom-right) further improves verbalized calibration (as in ‘Considering the Opposite’ in psychology; Lord et al. (1985)). Verbalized expressions of likelihood (top-right) also provide improved calibration. Bar height is average accuracy of predictions in bin. Darker bars mean more predictions fall in that confidence range. Results computed on SciQ.
|
| 17 |
+
|
| 18 |
+
This paper evaluates several methods for extracting confidences about model predictions from
|
| 19 |
+
|
| 20 |
+

|
| 21 |
+
Figure 2: RLHF generally worsens the calibration of Llama-70B’s log probabilities, as measured by ECE (lower is better) or AUC (higher is better). However, this paper (Tables 1-5) will show that for several strong RLHF-LMs, the model’s verbalized confidence is often better-calibrated than its log probabilities, reversing some of this degradation. This reversal is strongest for TruthfulQA, an adversarial dataset testing common misconceptions and other difficult queries.
|
| 22 |
+
|
| 23 |
+
RLHF-LMs. Due to concerns that RLHF may cause systematic overconfidence in the model’s probabilities (Figure 2), as well as the general unavailability of per-token log-probabilities in widely used RLHF-LMs, we pay particular attention to prompts that elicit verbalized probabilities, i.e., the model expresses its confidence in token-space, as either numerical probabilities or another linguistic expression of uncertainty. We find that, surprisingly, popular RLHF-LMs are able to directly verbalize confidence scores that are better-calibrated than the model’s conditional probabilities (estimated via sampling), without any fine-tuning to learn verbalization. To further improve calibration, we take inspiration from research in human psychology showing that overconfidence can be mitigated by considering alternative answers before responding (Lord et al., 1985; Mussweiler et al., 2000). We show that prompting a model to produce several answer choices before giving its confidence scores significantly improves calibration of verbalized probabilities. Combined with temperature scaling (Guo et al., 2017), this approach generally provides better calibration than model probabilities for ChatGPT2, GPT- $4 ^ { 3 }$ , and Claude $2 ^ { 4 }$ across three datasets, often reducing expected calibration error (ECE) by over $50 \%$ .
|
| 24 |
+
|
| 25 |
+
Related Work. Several studies have examined the calibration of large LMs (Lin et al., 2022a; Park and Caragea, 2022; Kadavath et al., 2022; Xiao et al., 2022; Kuhn et al., 2023), finding that combining large pre-trained LMs with temperature scaling (Guo et al., 2017) produces very wellcalibrated predictions (Kadavath et al., 2022; Xiao et al., 2022; Kuhn et al., 2023). Other work focuses on the tendency of language and dialogue models to use linguistic expressions of uncertainty in a well-calibrated manner (Zhou et al., 2023; Mielke et al., 2022). However, existing studies focus on LMs trained purely with unsupervised learning (although Kadavath et al. (2022) briefly examine RLHF-LMs), while widely used models in practice are fine-tuned with instruction-tuning or RLHF (Christiano et al., 2017). RLHF has been shown to effectively leverage annotations of human preferences to control sentiment (Ziegler et al., 2020), improve summarization or instruction-following quality (Stiennon et al., 2022; Ouyang et al., 2022), and inject behavioral priors of harmlessness (Bai et al., 2022b,a). However, recent work has raised the question of whether or not RLHF harms calibration (OpenAI, 2023). Our work is the first to show that verbalized probabilities are often bettercalibrated than the model’s conditional probabilities for RLHF-LMs such as ChatGPT, GPT-4, and Claude, and Llama-2-70B-Chat.
|
| 26 |
+
|
| 27 |
+
# 2 Evaluating Calibration in RLHF-LMs
|
| 28 |
+
|
| 29 |
+
To study the calibration of RLHF-LMs, we conduct experiments with gpt-3.5-turbo (ChatGPT), gpt-4 (GPT-4), claude-1 (Claude 1), claude-2 (Claude 2), and Llama-2-70b-chat (Llama-2- 70B-Chat).
|
| 30 |
+
|
| 31 |
+
Metrics. We measure calibration with multiple metrics. To measure ECE (expected calibration error; Guo et al. (2017)), we bin model predictions by their confidence and measure the average accuracy of predictions in each confidence bin. The ECE is defined as the average (squared) error between the average accuracy and confidence within each bin, where each error is weighted by the fraction of samples falling within the bin. We report raw ECE as well as ECE with temperature scaling (ECE-t). Temperature scaling fits a single temperature value $\beta$ to the model’s confidences to minimize negative log likelihood (NLL) on the data, giving scaled probability ${ \tilde { p } } _ { i }$ of class $i$ as $\tilde { p } _ { i } \propto p _ { i } ^ { \beta }$ . See Figure 1 for a depiction of ECE binning. Although ECE is a standard and interpretable measure of calibration error, it completely fails to capture the confidences’ discriminative power.5 We therefore also report
|
| 32 |
+
|
| 33 |
+
Table 1: Measuring calibration of various methods for extracting confidences from gpt-3.5-turbo (ChatGPT). The model’s conditional probabilities are relatively poorly calibrated, whether using the model’s conditional probability of the label given the query (Label prob.) or the probability assigned to ‘True’ given the query, proposed answer, and a prompt asking if the answer is correct (‘Is True’ prob.). Surprisingly, directly verbalizing a probability (Verb. 1S and Verb. 2S) or an expression of confidence such as ‘highly likely’ (Ling. 1S) yields significantly better-calibrated confidence estimates. 1S refers to one-stage prediction, where the model provides an answer and confidence probability/expression together. 2S refers to two-stage prediction, where the model first gives only an answer, and then in a second stage a confidence. To color the table cells, for each column, we demean and scale by a constant to obtain a shade in [-1,1], where cyan indicates better and orange worse performance.
|
| 34 |
+
|
| 35 |
+
<table><tr><td></td><td colspan="4">TriviaQA</td><td colspan="4">SciQ</td><td colspan="4">TruthfulQA</td></tr><tr><td>Method</td><td>ECE</td><td>ECE-t</td><td>BS-t↓</td><td>AUC ↑</td><td>ECE</td><td>ECE-t↓</td><td>BS-t↓</td><td>AUC↑</td><td>ECE</td><td>ECE-t↓</td><td>BS-t↓</td><td>AUC↑</td></tr><tr><td>Label prob. ‘Is True’prob.</td><td>0.140 0.164</td><td>0.097 0.159</td><td>0.142</td><td>0.869</td><td>0.256</td><td>0.180</td><td>0.223</td><td>0.752</td><td>0.451 0.470</td><td>0.317 0.471</td><td>0.345 0.476</td><td>0.418 0.384</td></tr><tr><td>Entropy</td><td>1</td><td>丨</td><td>0.165</td><td>0.826 0.547</td><td>0.312 丨</td><td>0.309 一</td><td>0.309</td><td>0.677 0.483</td><td>一</td><td>丨</td><td>丨</td><td>0.236</td></tr><tr><td>Verb.1S top-1</td><td>0.068</td><td>0.076</td><td>0.138</td><td>0.879</td><td>0.234</td><td>0.084</td><td>0.214</td><td>0.744</td><td>0.389</td><td>0.256</td><td>0.322</td><td>0.545</td></tr><tr><td>Verb. 1S top-2 Verb. 1S top-4</td><td>0.050</td><td>0.053</td><td>0.139</td><td>0.894</td><td>0.132</td><td>0.050</td><td>0.201</td><td>0.766</td><td>0.361</td><td>0.115</td><td>0.252</td><td>0.485</td></tr><tr><td></td><td>0.054</td><td>0.057</td><td>0.144</td><td>0.896</td><td>0.065</td><td>0.051</td><td>0.209</td><td>0.763</td><td>0.203</td><td>0.189</td><td>0.284</td><td>0.455</td></tr><tr><td>Verb.2SCoT</td><td>0.110</td><td>0.123</td><td>0.168</td><td>0.830</td><td>0.323</td><td>0.246</td><td>0.296</td><td>0.683</td><td>0.419</td><td>0.259</td><td>0.292</td><td>0.551</td></tr><tr><td>Verb. 2S top-1</td><td>0.131</td><td>0.099</td><td>0.148</td><td>0.855</td><td>0.340</td><td>0.203</td><td>0.268</td><td>0.677</td><td>0.431</td><td>0.245</td><td>0.282</td><td>0.483</td></tr><tr><td>Verb. 2S top-2</td><td>0.047</td><td>0.045</td><td>0.147</td><td>0.887</td><td>0.169</td><td>0.040</td><td>0.201</td><td>0.768</td><td>0.395</td><td>0.101</td><td>0.224</td><td>0.517</td></tr><tr><td>Verb.2S top-4</td><td>0.050</td><td>0.051</td><td>0.156</td><td>0.861</td><td>0.130</td><td>0.046</td><td>0.211</td><td>0.729</td><td>0.270</td><td>0.156</td><td>0.246</td><td>0.463</td></tr><tr><td>Ling. 1S human</td><td>0.062</td><td>0.069</td><td>0.137</td><td>0.884</td><td>0.166</td><td>0.087</td><td>0.223</td><td>0.703</td><td>0.306</td><td>0.296</td><td>0.333</td><td>0.503</td></tr><tr><td>Ling. 1S-opt.</td><td>0.058</td><td>0.066</td><td>0.135</td><td>0.878</td><td>0.064</td><td>0.068</td><td>0.220</td><td>0.674</td><td>0.125</td><td>0.165</td><td>0.270</td><td>0.492</td></tr></table>
|
| 36 |
+
|
| 37 |
+
<table><tr><td></td><td colspan="4">TriviaQA</td><td colspan="4">SciQ</td><td colspan="4">TruthfulQA</td></tr><tr><td>Method</td><td>ECE</td><td>ECE-t↓</td><td>BS-t</td><td>AUC</td><td>ECE</td><td>ECE-t↓</td><td>BS-t←</td><td>AUC</td><td>ECE</td><td>ECE-t</td><td>BS-t</td><td>AUC </td></tr><tr><td>Label prob.</td><td>0.078</td><td>0.067</td><td>0.077</td><td>0.950</td><td>0.219</td><td>0.165</td><td>0.186</td><td>0.820</td><td>0.445</td><td>0.334</td><td>0.362</td><td>0.462</td></tr><tr><td>Verb.1S top-1</td><td>0.024</td><td>0.038</td><td>0.084</td><td>0.937</td><td>0.201</td><td>0.084</td><td>0.165</td><td>0.843</td><td>0.350</td><td>0.156</td><td>0.227</td><td>0.622</td></tr><tr><td>Verb. 1S top-2</td><td>0.025</td><td>0.034</td><td>0.084</td><td>0.949</td><td>0.140</td><td>0.048</td><td>0.185</td><td>0.813</td><td>0.315</td><td>0.112</td><td>0.228</td><td>0.623</td></tr><tr><td>Verb. 1S top-4</td><td>0.041</td><td>0.039</td><td>0.081</td><td>0.959</td><td>0.056</td><td>0.059</td><td>0.185</td><td>0.815</td><td>0.198</td><td>0.144</td><td>0.245</td><td>0.619</td></tr><tr><td>Ling. 1S-human</td><td>0.051</td><td>0.041</td><td>0.086</td><td>0.931</td><td>0.148</td><td>0.024</td><td>0.170</td><td>0.835</td><td>0.241</td><td>0.151</td><td>0.228</td><td>0.651</td></tr><tr><td>Ling.1S-opt.</td><td>0.056</td><td>0.051</td><td>0.088</td><td>0.927</td><td>0.028</td><td>0.052</td><td>0.172</td><td>0.828</td><td>0.082</td><td>0.105</td><td>0.212</td><td>0.632</td></tr></table>
|
| 38 |
+
|
| 39 |
+
Table 2: gpt-4’s verbalized probabilities are substantially better-calibrated than the model probabilities themselves, even after temperature scaling, similarly to gpt-3.5-turbo in Table 1.
|
| 40 |
+
|
| 41 |
+
Brier Score (BS; Brier (1950)) on temperaturescaled confidences (BS-t), a proper scoring rule (Ovadia et al., 2019) that is the mean squared error between the confidences and the correctness labels. Finally, we assess calibration using a metric from the selective classification literature (Geifman and El-Yaniv, 2017), specifically, the area under the curve of selective accuracy and coverage (AUC).
|
| 42 |
+
|
| 43 |
+
Datasets. Our experiments use three questionanswering datasets assessing factual knowledge. TriviaQA (Joshi et al., 2017) contains $6 5 0 \mathrm { k }$ question-answer pairs gathered by trivia enthusiasts; SciQ (Welbl et al., 2017) contains approximately 14k crowdsourced science exam questionanswer pairs; TruthfulQA (Lin et al., 2022b) contains 817 questions designed to test language models’ tendency to mimic human falsehoods. We sample 1000 questions from the validation split of TriviaQA (rc.web.nocontext) and SciQ and all 817 questions from the validation split of TruthfulQA (generation) for our experiments.
|
| 44 |
+
|
| 45 |
+
Evaluation protocol. For each dataset, we generate a response and corresponding confidence from each method on each of the evaluation questions. Because calibration essentially quantifies the relationship between model confidence and correctness, computing correctness is crucial to accurate measurements of calibration. However, we find doing so to be a challenge, especially in datasets where only a single ground-truth answer (but not aliases or semantically equivalent rephrases) is provided. To avoid excessive false negatives in our correctness computation as a result of exact-match evaluation, we use either GPT-4 or GPT-3.5 to evaluate whether a response is essentially equivalent to the ground truth answer; see Appendix C for the complete equivalence-checking procedure.
|
| 46 |
+
|
| 47 |
+
Methods. We compare a wide variety of methods for extracting confidence estimates from LLMs. For a comprehensive list of the prompts used for each method, see Appendix Table 6.
|
| 48 |
+
|
| 49 |
+
First, we consider two methods that leverage the true conditional distribution of the model to generate confidence scores. The simplest is Label prob., which uses the conditional probability distribution $p ( y | x )$ of the model given a question $x$ , which we estimate using $n = 1 0$ samples, since many RLHFLMs are closed-source and do not offer per-token probabilities.67 We return the most common answer, using the LLM-based equivalence function to determine when two lexically different answers are semantically equivalent. In a variation of the method described by Kadavath et al. (2022) (again, we use samples since model probabilities are not available), ‘Is True’ prob. samples a single answer $\hat { y }$ from the model given a question $x$ , and the probability it is true is estimated by the probability the model assigns to ‘True’ when asked if the given answer is true (where once again the probabilities are estimated via samples), i.e., $p ( \mathsf { T r u e } | x , \hat { y } )$ .
|
| 50 |
+
|
| 51 |
+
<table><tr><td></td><td colspan="4">TriviaQA</td><td colspan="4">SciQ</td><td colspan="4">TruthfulQA</td></tr><tr><td>Method</td><td>ECE</td><td>ECE-t ↓</td><td>BS-t</td><td>AUC</td><td>ECE</td><td>ECE-t↓</td><td>BS-t</td><td>AUC</td><td>ECE</td><td>ECE-t</td><td>BS-t</td><td>AUC </td></tr><tr><td>Label prob.</td><td>0.074</td><td>0.079</td><td>0.117</td><td>0.915</td><td>0.216</td><td>0.149</td><td>0.195</td><td>0.786</td><td>0.432</td><td>0.304</td><td>0.335</td><td>0.418</td></tr><tr><td>Verb. 1S top-1</td><td>0.049</td><td>0.059</td><td>0.160</td><td>0.839</td><td>0.265</td><td>0.103</td><td>0.247</td><td>0.663</td><td>0.440</td><td>0.134</td><td>0.204</td><td>0.411</td></tr><tr><td>Verb. 1S top-2</td><td>0.046</td><td>0.047</td><td>0.158</td><td>0.875</td><td>0.207</td><td>0.040</td><td>0.225</td><td>0.693</td><td>0.450</td><td>0.085</td><td>0.197</td><td>0.409</td></tr><tr><td>Verb. 1S top-4</td><td>0.075</td><td>0.079</td><td>0.176</td><td>0.814</td><td>0.151</td><td>0.057</td><td>0.226</td><td>0.667</td><td>0.372</td><td>0.105</td><td>0.183</td><td>0.377</td></tr><tr><td>Ling. 1S human</td><td>0.053</td><td>0.050</td><td>0.151</td><td>0.867</td><td>0.253</td><td>0.118</td><td>0.245</td><td>0.664</td><td>0.443</td><td>0.358</td><td>0.340</td><td>0.384</td></tr><tr><td>Ling.1S-opt.</td><td>0.074</td><td>0.060</td><td>0.149</td><td>0.863</td><td>0.089</td><td>0.082</td><td>0.238</td><td>0.623</td><td>0.139</td><td>0.148</td><td>0.228</td><td>0.350</td></tr></table>
|
| 52 |
+
|
| 53 |
+
Table 3: Claude-1 produces similar- or better-calibrated log probabilities to gpt-3.5-turbo, but is less able to verbalize well-calibrated confidences, compared to models in the GPT family of RLHF-LMs. Claude-1 has since been deprecated.
|
| 54 |
+
|
| 55 |
+
<table><tr><td></td><td colspan="4">TriviaQA</td><td colspan="4">SciQ</td><td colspan="4">TruthfulQA</td></tr><tr><td>Method</td><td>ECE</td><td>ECE-t↓</td><td>BS-t</td><td>AUC</td><td>ECE</td><td>ECE-t↓</td><td>BS-t</td><td>AUC </td><td>ECE</td><td>ECE-t ↓</td><td>BS-t</td><td>AUC </td></tr><tr><td>Label prob.</td><td>0.089</td><td>0.089</td><td>0.137</td><td>0.882</td><td>0.181</td><td>0.176</td><td>0.237</td><td>0.762</td><td>0.409</td><td>0.368</td><td>0.405</td><td>0.319</td></tr><tr><td>Verb. iS top-1</td><td>0.072</td><td>0.071</td><td>0.141</td><td>0.903</td><td>0.204</td><td>0.054</td><td>0.201</td><td>0.776</td><td>0.345</td><td>0.115</td><td>0.215</td><td>0.573</td></tr><tr><td>Verb.1S top-2</td><td>0.049</td><td>0.054</td><td>0.133</td><td>0.918</td><td>0.134</td><td>0.041</td><td>0.211</td><td>0.754</td><td>0.359</td><td>0.085</td><td>0.223</td><td>0.491</td></tr><tr><td>Verb. 1S top-4</td><td>0.072</td><td>0.063</td><td>0.158</td><td>0.890</td><td>0.048</td><td>0.052</td><td>0.216</td><td>0.711</td><td>0.274</td><td>0.075</td><td>0.208</td><td>0.473</td></tr><tr><td>Ling. 1S human</td><td>0.085</td><td>0.061</td><td>0.151</td><td>0.878</td><td>0.238</td><td>0.026</td><td>0.209</td><td>0.756</td><td>0.381</td><td>0.242</td><td>0.305</td><td>0.530</td></tr><tr><td>Ling. 1S-opt.</td><td>0.060</td><td>0.070</td><td>0.151</td><td>0.874</td><td>0.049</td><td>0.056</td><td>0.214</td><td>0.738</td><td>0.099</td><td>0.130</td><td>0.266</td><td>0.446</td></tr></table>
|
| 56 |
+
|
| 57 |
+
Table 4: Claude-2 has weaker conditional probabilities than Claude-1 and GPT- $^ *$ , but its verbalized calibration provides consistent improvement over conditional probabilities at a level comparable to GPT-3.5 and surpassing GPT- $^ *$ on TruthfulQA.
|
| 58 |
+
|
| 59 |
+
Next, we consider methods that extract confidence scores through verbalization (Lin et al., 2022a), i.e., where the model expresses its confidence in token space, either with numerical probabilities or linguistic expressions of likelihood.8 First, Verb. 1S top- $k$ prompts the model to produce $k$ guesses and a probability that each is correct all in a single response (i.e., ‘1 stage’). We take the highest-probability prediction and its associated probability as the model’s output and confidence. Verb. 2S top- $k$ similarly uses numerical probabilities, except the model is first asked to provide only its answers, and afterwards, in a second round of dialogue, asked to assign probabilities of correctness to each answer (i.e., ‘2 stages’). Verb. 2S CoT uses a chain-of-thought prompt before giving a single answer, and in a second round of dialogue, the model is prompted to assign a probability to that answer (with the chain of thought present in the model’s context). Ling. 1S-human uses linguistic likelihood expressions, rather than numerical probabilities, to express uncertainty. The model is prompted to assign confidences to its guesses by choosing from a set of linguistic expressions of uncertainty: {Almost certain, Likely, . . . , Almost no chance}. Each linguistic likelihood expression is mapped to a probability using responses from a human survey on social media with 123 respondents (FagenUlmschneider, 2023). Ling. 1S-opt. uses a held out set of calibration questions and answers to compute the average accuracy for each likelihood expression, using these ‘optimized’ values instead. Expressions that are not used for at least $\textstyle { \frac { 1 } { N } }$ of questions, where $N$ is the number of calibration questions, simply use the human probability.
|
| 60 |
+
|
| 61 |
+
# 3 Results
|
| 62 |
+
|
| 63 |
+
Tables 1–5 show the results of evaluating various methods for extracting confidence from RLHFLMs on gpt-3.5-turbo, gpt-4, claude-1, claude-2, and Llama-2-70b-chat, respectively. We distill several key conclusions from these experiments. 1. Large RLHF-LMs can often directly verbalize better-calibrated confidences (either a numerical confidence probability or an expression such as ‘highly likely’) than the models’ conditional probabilities. 2. Among the methods for verbalizing probabilities directly, we observe that generating and evaluating multiple hypotheses improves calibration (see Figure 1), similarly to humans (Lord et al., 1985), and corroborating a similar finding in LMs (Kadavath et al., 2022). 3. Language models can express their uncertainty with numerical probabilities as well or better than with words, which is surprising in light of longstanding difficulties in representing numbers in language models (Thawani et al., 2021). 4. Chainof-thought prompting does not improve verbalized calibration (see Appendix Figure 5 for additional CoT results). 5. The calibration of both Claude models’ conditional probabilities roughly falls between gpt-3.5-turbo and gpt-4; however, while Claude 1 is much weaker at verbalizing its confidence, Claude 2 is generally a bit stronger than gpt-3.5-turbo at verbalizing. The verbal calibration of the open source model Llama-2-70b-chat is generally weaker than that of closed source models but still demonstrates improvement over its conditional probabilities by some metrics, and does so most clearly on TruthfulQA.
|
| 64 |
+
|
| 65 |
+
<table><tr><td></td><td colspan="4">TriviaQA</td><td colspan="4">SciQ</td><td colspan="4">TruthfulQA</td></tr><tr><td>Method</td><td>ECE</td><td>ECE-t ↓</td><td>BS-t↓</td><td>AUC↑</td><td>ECE</td><td>ECE-t↓</td><td>BS-t</td><td>AUC</td><td>ECE</td><td>ECE-t ↓</td><td>BS-t </td><td>AUC</td></tr><tr><td>Label prob.</td><td>0.151</td><td>0.124</td><td>0.156</td><td>0.865</td><td>0.266</td><td>0.189</td><td>0.243</td><td>0.707</td><td>0.405</td><td>0.361</td><td>0.396</td><td>0.407</td></tr><tr><td>Verb.1S top-1</td><td>0.071</td><td>0.067</td><td>0.186</td><td>0.793</td><td>0.196</td><td>0.053</td><td>0.239</td><td>0.648</td><td>0.386</td><td>0.172</td><td>0.266</td><td>0.502</td></tr><tr><td>Verb. 1S top-2</td><td>0.060</td><td>0.073</td><td>0.194</td><td>0.815</td><td>0.153</td><td>0.032</td><td>0.230</td><td>0.667</td><td>0.340</td><td>0.037</td><td>0.227</td><td>0.440</td></tr><tr><td>Verb. 1S top-4</td><td>0.069</td><td>0.079</td><td>0.182</td><td>0.816</td><td>0.105</td><td>0.043</td><td>0.229</td><td>0.648</td><td>0.231</td><td>0.102</td><td>0.237</td><td>0.465</td></tr><tr><td>Ling. 1S human</td><td>0.179</td><td>0.115</td><td>0.195</td><td>0.749</td><td>0.071</td><td>0.101</td><td>0.252</td><td>0.603</td><td>0.376</td><td>0.366</td><td>0.383</td><td>0.407</td></tr><tr><td>Ling.1S-opt.</td><td>0.077</td><td>0.068</td><td>0.186</td><td>0.779</td><td>0.019</td><td>0.042</td><td>0.236</td><td>0.590</td><td>0.047</td><td>0.051</td><td>0.239</td><td>0.435</td></tr></table>
|
| 66 |
+
|
| 67 |
+
Table 5: With Llama2-70B-Chat, verbalized calibration provides improvement over conditional probabilities across some metrics, but the improvement is much less consistent compared to GPT- $^ *$ and Claude-\*.
|
| 68 |
+
|
| 69 |
+
# 4 Discussion
|
| 70 |
+
|
| 71 |
+
In summary, we study the calibration of widely used RLHF-LMs. We first replicate the finding for GPT-4 (OpenAI, 2023) that RLHF can worsen the calibration of a model’s conditional probabilities using the open-source Llama-2-70B base and chat models (Figure 2). To mitigate this regression and ease extraction of calibrated confidence scores for models for which log probabilities are not available, we propose and study new methods that can elicit calibrated confidences from RLHF-LMs by prompting the model to verbalize its confidence in token space. We find verbalized probabilities are better-calibrated than conditional probabilities across several closed models, with mixed results for Llama-2-70B-Chat.
|
| 72 |
+
|
| 73 |
+
Our results raise several questions for future work. Most notably, the difference between GPT-\*, Claude-\*, and Llama-2’s ability to verbalize confidence is significant. What factors are important for learning this skill? Additionally, the 1-stage and 2-stage verbalized numerical confidence prompts sometimes differ drastically in the calibration of their confidences. How can we reduce sensitivity of a model’s calibration to the prompt? Going beyond question-answering, can we leverage good calibration in short-answer settings to improve the reliability of long-form generations, perhaps by breaking down long-form generation into a sequence of short questions? Finally, to what extent does a language model’s calibration depend on the domain; do our conclusions in the context of factual recall hold in the context of reasoning or arithmetic? Answering these questions provides one path toward building more trustworthy and useful language systems.
|
| 74 |
+
|
| 75 |
+
Limitations. While our work demonstrates a promising new approach to generating calibrated confidences through verbalization, there are limitations that could be addressed in future work. First, our experiments are focused on factual recalloriented problems, and the extent to which our observations would hold for reasoning-heavy settings is an interesting open question. Additionally, the lack of technical details available for many state-ofthe-art closed RLHF-LMs may limit our ability to understand what factors enable a model to verbalize well-calibrated confidences and differences in this ability across different models. Finally, our study is limited to short-form question-answering; future work should extend this analysis to longer-form generation settings.
|
| 76 |
+
|
| 77 |
+
Acknowledgements. CF and CDM are CIFAR Fellows. EM gratefully acknowledges funding from a Knight-Hennessy Graduate Fellowship. AZ is supported by the NSF graduate research fellowship program. This research was supported in part by Juniper Networks, Apple, and ONR grant N00014- 20-1-2675. The authors thank Yoonho Lee and Noah Goodman for helpful feedback on calibration metrics and experiment design.
|
| 78 |
+
|
| 79 |
+
# References
|
| 80 |
+
|
| 81 |
+
Yuntao Bai, Andy Jones, Kamal Ndousse, Amanda Askell, Anna Chen, Nova DasSarma, Dawn Drain, Stanislav Fort, Deep Ganguli, Tom Henighan, Nicholas Joseph, Saurav Kadavath, Jackson Kernion, Tom Conerly, Sheer El-Showk, Nelson Elhage, Zac Hatfield-Dodds, Danny Hernandez, Tristan Hume, Scott Johnston, Shauna Kravec, Liane Lovitt, Neel Nanda, Catherine Olsson, Dario Amodei, Tom Brown, Jack Clark, Sam McCandlish, Chris Olah, Ben Mann, and Jared Kaplan. 2022a. Training a helpful and harmless assistant with reinforcement learning from human feedback.
|
| 82 |
+
|
| 83 |
+
Yuntao Bai, Saurav Kadavath, Sandipan Kundu, Amanda Askell, Jackson Kernion, Andy Jones, Anna Chen, Anna Goldie, Azalia Mirhoseini, Cameron McKinnon, Carol Chen, Catherine Olsson, Christopher Olah, Danny Hernandez, Dawn Drain, Deep Ganguli, Dustin Li, Eli Tran-Johnson, Ethan Perez, Jamie Kerr, Jared Mueller, Jeffrey Ladish, Joshua Landau, Kamal Ndousse, Kamile Lukosuite, Liane Lovitt, Michael Sellitto, Nelson Elhage, Nicholas Schiefer, Noemi Mercado, Nova DasSarma, Robert Lasenby, Robin Larson, Sam Ringer, Scott Johnston, Shauna Kravec, Sheer El Showk, Stanislav Fort, Tamera Lanham, Timothy Telleen-Lawton, Tom Conerly, Tom Henighan, Tristan Hume, Samuel R. Bowman, Zac Hatfield-Dodds, Ben Mann, Dario Amodei, Nicholas Joseph, Sam McCandlish, Tom Brown, and Jared Kaplan. 2022b. Constitutional AI: Harmlessness from ai feedback.
|
| 84 |
+
|
| 85 |
+
Glenn W. Brier. 1950. Verification of Forecasts Expressed in Terms of Probability. Monthly Weather Review, 78(1):1–3.
|
| 86 |
+
|
| 87 |
+
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. 2020. Language models are few-shot learners. In Advances in Neural Information Processing Systems, volume 33, pages 1877–1901. Curran Associates, Inc.
|
| 88 |
+
|
| 89 |
+
Sébastien Bubeck, Varun Chandrasekaran, Ronen Eldan, Johannes Gehrke, Eric Horvitz, Ece Kamar, Peter Lee, Yin Tat Lee, Yuanzhi Li, Scott Lundberg, Harsha Nori, Hamid Palangi, Marco Tulio Ribeiro, and Yi Zhang. 2023. Sparks of artificial general intelligence: Early experiments with GPT-4. ArXiv preprint arXiv:2303.12712.
|
| 90 |
+
|
| 91 |
+
Paul F Christiano, Jan Leike, Tom Brown, Miljan Martic, Shane Legg, and Dario Amodei. 2017. Deep reinforcement learning from human preferences. In Advances in Neural Information Processing Systems, volume 30. Curran Associates, Inc.
|
| 92 |
+
|
| 93 |
+
Wade Fagen-Ulmschneider. 2023. Perception of probability words. Ms., UIUC, 05-24-2023.
|
| 94 |
+
|
| 95 |
+
Yonatan Geifman and Ran El-Yaniv. 2017. Selective classification for deep neural networks. In Proceedings of the 31st International Conference on Neural Information Processing Systems, NIPS’17, page 4885–4894, Red Hook, NY, USA. Curran Associates Inc.
|
| 96 |
+
|
| 97 |
+
Chuan Guo, Geoff Pleiss, Yu Sun, and Kilian Q. Weinberger. 2017. On calibration of modern neural networks. In Proceedings of the 34th International Conference on Machine Learning, volume 70 of Proceedings of Machine Learning Research, pages 1321– 1330. PMLR.
|
| 98 |
+
|
| 99 |
+
Mandar Joshi, Eunsol Choi, Daniel Weld, and Luke Zettlemoyer. 2017. TriviaQA: A large scale distantly supervised challenge dataset for reading comprehension. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 1601–1611, Vancouver, Canada. Association for Computational Linguistics.
|
| 100 |
+
|
| 101 |
+
Saurav Kadavath, Tom Conerly, Amanda Askell, Tom Henighan, Dawn Drain, Ethan Perez, Nicholas Schiefer, Zac Hatfield-Dodds, Nova DasSarma, Eli Tran-Johnson, Scott Johnston, Sheer El-Showk, Andy Jones, Nelson Elhage, Tristan Hume, Anna Chen, Yuntao Bai, Sam Bowman, Stanislav Fort, Deep Ganguli, Danny Hernandez, Josh Jacobson, Jackson Kernion, Shauna Kravec, Liane Lovitt, Kamal Ndousse, Catherine Olsson, Sam Ringer, Dario Amodei, Tom Brown, Jack Clark, Nicholas Joseph, Ben Mann, Sam McCandlish, Chris Olah, and Jared Kaplan. 2022. Language models (mostly) know what they know. Arxiv arxiv:2207.05221.
|
| 102 |
+
|
| 103 |
+
Lorenz Kuhn, Yarin Gal, and Sebastian Farquhar. 2023. Semantic uncertainty: Linguistic invariances for uncertainty estimation in natural language generation. In The Eleventh International Conference on Learning Representations.
|
| 104 |
+
|
| 105 |
+
Stephanie Lin, Jacob Hilton, and Owain Evans. 2022a. Teaching models to express their uncertainty in words. Transactions on Machine Learning Research.
|
| 106 |
+
|
| 107 |
+
Stephanie Lin, Jacob Hilton, and Owain Evans. 2022b. TruthfulQA: Measuring how models mimic human falsehoods. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 3214–3252, Dublin, Ireland. Association for Computational Linguistics.
|
| 108 |
+
|
| 109 |
+
Charles Lord, Mark Lepper, and Elizabeth Preston. 1985. Considering the opposite: A corrective strategy for social judgment. Journal of personality and social psychology, 47:1231–43.
|
| 110 |
+
|
| 111 |
+
Sabrina J. Mielke, Arthur Szlam, Emily Dinan, and YLan Boureau. 2022. Reducing conversational agents’ overconfidence through linguistic calibration. Transactions of the Association for Computational Linguistics, 10:857–872.
|
| 112 |
+
|
| 113 |
+
Thomas Mussweiler, Fritz Strack, and Tim Pfeiffer. 2000. Overcoming the inevitable anchoring effect: Considering the opposite compensates for selective accessibility. Personality and Social Psychology Bulletin, 26(9):1142–1150.
|
| 114 |
+
|
| 115 |
+
OpenAI. 2023. Gpt-4 technical report.
|
| 116 |
+
|
| 117 |
+
Long Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida, Carroll Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, John Schulman, Jacob Hilton, Fraser Kelton, Luke Miller, Maddie Simens, Amanda Askell, Peter Welinder, Paul F Christiano, Jan Leike, and Ryan Lowe. 2022. Training language models to follow instructions with human feedback. In Advances in Neural Information Processing Systems, volume 35, pages 27730–27744. Curran Associates, Inc.
|
| 118 |
+
|
| 119 |
+
Yaniv Ovadia, Emily Fertig, Jie Ren, Zachary Nado, D. Sculley, Sebastian Nowozin, Joshua V. Dillon, Balaji Lakshminarayanan, and Jasper Snoek. 2019. Can you trust your model’s uncertainty? evaluating predictive uncertainty under dataset shift. In Proceedings of the 33rd International Conference on Neural Information Processing Systems, Red Hook, NY, USA. Curran Associates Inc.
|
| 120 |
+
|
| 121 |
+
Seo Yeon Park and Cornelia Caragea. 2022. On the calibration of pre-trained language models using mixup guided by area under the margin and saliency. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 5364–5374, Dublin, Ireland. Association for Computational Linguistics.
|
| 122 |
+
|
| 123 |
+
Adam Roberts, Colin Raffel, and Noam Shazeer. 2020. 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), pages 5418–5426, Online. Association for Computational Linguistics.
|
| 124 |
+
|
| 125 |
+
Nisan Stiennon, Long Ouyang, Jeff Wu, Daniel M. Ziegler, Ryan Lowe, Chelsea Voss, Alec Radford, Dario Amodei, and Paul Christiano. 2022. Learning to summarize from human feedback.
|
| 126 |
+
|
| 127 |
+
Avijit Thawani, Jay Pujara, Filip Ilievski, and Pedro Szekely. 2021. Representing numbers in NLP: a survey and a vision. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 644–656, Online. Association for Computational Linguistics.
|
| 128 |
+
|
| 129 |
+
Johannes Welbl, Nelson F. Liu, and Matt Gardner. 2017. Crowdsourcing multiple choice science questions. ArXiv, abs/1707.06209.
|
| 130 |
+
|
| 131 |
+
Yuxin Xiao, Paul Pu Liang, Umang Bhatt, Willie Neiswanger, Ruslan Salakhutdinov, and LouisPhilippe Morency. 2022. Uncertainty quantification with pre-trained language models: A large-scale empirical analysis. In Findings of the Association for Computational Linguistics: EMNLP 2022, pages 7273–7284, Abu Dhabi, United Arab Emirates. Association for Computational Linguistics.
|
| 132 |
+
|
| 133 |
+
Kaitlyn Zhou, Dan Jurafsky, and Tatsunori Hashimoto. 2023. Navigating the grey area: Expressions of overconfidence and uncertainty in language models.
|
| 134 |
+
|
| 135 |
+
Daniel M. Ziegler, Nisan Stiennon, Jeffrey Wu, Tom B. Brown, Alec Radford, Dario Amodei, Paul Christiano, and Geoffrey Irving. 2020. Fine-tuning language models from human preferences.
|
| 136 |
+
|
| 137 |
+

|
| 138 |
+
Usage of likelihood expressions by 3.5-turbo
|
| 139 |
+
|
| 140 |
+

|
| 141 |
+
Figure 3: gpt-3.5-turbo usage rate of each likelihood expression; the model displays much lower verbalized confidence on TruthfulQA than on standard factual recall problems.
|
| 142 |
+
Figure 4: gpt-4 usage rate of each likelihood expression; the model displays markedly lower verbalized confidence on TruthfulQA than on standard factual recall problems.
|
| 143 |
+
|
| 144 |
+
# A Additional Results
|
| 145 |
+
|
| 146 |
+
Here, we include the likelihood expression usage distribution for gpt-3.5 and gpt-4 in Figures 3 and 4, respectively. gpt-3.5 is systematically less confident for TruthfulQA. The contrast between model confidence for TriviaQA and SciQ compared with TruthfulQA is even more stark for gpt-4.
|
| 147 |
+
|
| 148 |
+
We also provide additional calibration results for chain-of-thought methods. We compare a onestage verbalized CoT prompt (Verb. 1S CoT), a two-stage verbalized CoT prompt (Verb. 2S CoT), and a two-stage verbalized method that uses CoT just before eliciting the numerical confidence (Verb. 2S Cot Prob) instead of before the guess, as shown for gpt-3.5 on Trivia QA, SciQ, and Truthful QA in Figure 5. We find that CoT does not noticeably improve calibration across any setting or dataset.
|
| 149 |
+
|
| 150 |
+
# B Fitting Procedure for Temperature and Probabilities for Linguistic Expressions
|
| 151 |
+
|
| 152 |
+
To fit the temperature that is used to compute ECEt and BS-t we split our total data into 5 folds. For each fold, we use it once to fit a temperature and evaluate metrics on the remaining folds. We find that fitting the temperature on $20 \%$ of the data yields relatively stable temperatures across folds. We report the average temperature-scaled ECE and BS as ECE-t and ${ \bf B S - t }$ .
|
| 153 |
+
|
| 154 |
+

|
| 155 |
+
Figure 5: Expected calibration error is not consistently improved for any CoT prompt variant on gpt-3.5-turbo.
|
| 156 |
+
|
| 157 |
+
To compute ECE and AUC for Ling. 1S-opt., we similarly split our total data into 5 folds, using 4 folds to fit the probabilities behind each linguistic expression of confidence, then evaluating on the remaining fold. To compute ECE-t and BS-t for Ling. 1S-opt, we hold out one of the 5 folds to fit temperature. We use 3 folds to fit probabilities for linguistic expressions, compute the temperature based on these probabilities on the temperature set, and evaluate metrics on the last fold. We then average metrics across all 20 rotations of folds.
|
| 158 |
+
|
| 159 |
+
# C Prompt Templates
|
| 160 |
+
|
| 161 |
+
The prompt template for each sampling method is provided in Table 6. The question is substituted for the variable $\$ 123,456,710N \}$ in each prompt. To evaluate answer correctness, we use gpt-3.5-turbo for SciQ and TruthfulQA and gpt-4 for TriviaQA due to gpt-3.5-turbo’s high disagreement with a human evaluator on TriviaQA. Using the ground truth answer as $\$ 523,456,7$ and the model-generated answer as \${PRED_ANSWER}, we use the following prompt template:
|
| 162 |
+
|
| 163 |
+
<table><tr><td rowspan=1 colspan=8>Method Template</td></tr><tr><td rowspan=1 colspan=8>Label prob. Provide your best guess for the following question. Give ONLY the guess,noother words orexplanation.\n\nForexample:\n\nGuess: <most likely guess,asshort as possible; not a complete sentence, just the guess!>\n\nThe questionis:${THE_QUESTION}</td></tr><tr><td rowspan=1 colspan=8>‘Is True'prob. Question: ${QUESTION}\nProposed Answer: ${ANSWER}\nIs the proposed answer:\n\t(A)True or\n\t(B) False?\n The proposed answer is:</td></tr><tr><td rowspan=1 colspan=8>Verb. 1S top-1 Provide your best guess and the probability that it is correct (0.0 to 1.0) forthe_following question. Give ONLY the guess and probability,no other words orexplanation.For example:\n\nGuess: <most likely guess,as short as possible; nota complete sentence,just the guess!>\n Probability:<the probability between 0.0and 1.0 that your guess is correct,without any extra commentary whatsoever;justthe probability!>\n\nThe question is:${THE_QUESTION}</td></tr><tr><td rowspan=1 colspan=8>Verb.1S top-k Provide your ${k} best guesses and the probability that each is correct (0.0 to1.0)for the following question.Give ONLY the guesses and probabilities,no otherwords or explanation. For example:\n\nG1: <first most likely guess,as short aspossible;not a complete sentence,just the guess!>\n\nP1: <the probability between0.0 and 1.0 that G1 is correct, without any extra commentary whatsoever; justthe probability!> ... G${k}: <${k}-th most likely guess,as short as possible;not a complete sentence, just the guess!>\n\nP${k}: <the probability between 0.0and 1.0 that G${k} is correct,without any extra commentary whatsoever; just theprobability!> \n\nThe question is: ${THE_QUESTION}</td></tr><tr><td rowspan=1 colspan=8>Verb.2SCoT Provide your best guess for the following question. Before giving your answer,provide a step-by-step explanation of your thought process. Then on a new linegive the guess with no other words or explanation.\n\nFor example:\n\nExplanation:<one sentence step-by-step explanation of your thought process>\n\nGuess: <mostlikely guess,as short as_possible; not a complete sentence,just the guess!>\n\nThequestion is:${THE_QUESTION}Provide the probability that your guess is correct. Give ONLY the probability,noother words or explanation.\n\nFor example:\n\nProbability:<the probability between0.0 and 1.0 that your guess is correct,without any extra commentary whatsoever;just the probability!>\n</td></tr><tr><td rowspan=1 colspan=8>Verb. 2S top-1 Provide your best guess for the following question.Give ONLY the guess,nootherwordsor_explanation.\n\nForexample:\n\nGuess:<most likely guess,asshort as possible; not a complete sentence, just the guess!>\n\nThe questionis:${THE_QUESTION}Provide the probability that your guess is correct. Give ONLY the_probability,noother words or explanation.\n\nFor example:\n\nProbability:<the probability between0.0 and 1.0 that your guess is correct,without any extra commentary whatsoever;just the probability!>\n</td></tr><tr><td rowspan=10 colspan=8>Verb. 2S top-kProvide your ${k} best guesses for the following question. Give ONLY the guesses,no other words_or explanation. For example:\n\nG1: <first most likely guess,asshort as possible;not a complete sentence,just the guess!>\n\nP1: <the probabilitybetween 0.0 and 1.0 that G1 is correct,without any extra commentary whatsoever;just the probability!> ... G${k}:<${k}-th most likely guess,as short as possible;not a complete sentence,just the guess!>\n\nThe question is:${THE_QUESTION}Providethe_probability_that eachofyourguessesiscorrect. Give ONLYthe probabilities,no other words or explanation.\n\nFor example:\n\nP1:<theprobability between 0.0 and 1.0 that G1 is correct,without any extra commentarywhatsoever; just the probability!>\n... P${k}: <the probability between 0.0 and1.0 that G${k} is correct, without any extra commentary whatsoever; just theprobability!></td></tr><tr><td rowspan=1 colspan=1>therwords</td></tr><tr><td rowspan=1 colspan=6>sho</td><td rowspan=1 colspan=1>nortaspossibl</td><td rowspan=1 colspan=1>sible;</td></tr><tr><td rowspan=1 colspan=5></td><td rowspan=4 colspan=2>ust theproailiteat</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=2></td><td rowspan=1 colspan=2></td></tr><tr><td rowspan=2 colspan=3></td></tr><tr></tr><tr><td rowspan=1 colspan=1>oth</td></tr><tr></tr><tr><td rowspan=1 colspan=4></td></tr><tr><td rowspan=1 colspan=8>Ling. 1S Provide your best guess for the following question,and describe how likely it isthat your guess is correct as one of the following expressions: ${EXPRESsION_LIST}.Give ONLY the guess and_ your confidence, no other words or explanation.Forexample:\n\nGuess: <most likely guess,as short as possible; not a complete sentence,just the guess!>\nConfidence:<description of confidence, without any extracommentary whatsoever; just a short phrase!>\n\nThe question is:${THE_QUESTION}</td></tr></table>
|
| 164 |
+
|
| 165 |
+
Table 6: Prompt templates for each method evaluated. Methods above the double line use multiple samples in order to estimate confidence scores; methods below the double line use the verbalized confidences directly, requiring only a single sample.
|
| 166 |
+
|
| 167 |
+
Are the following two answers to my question $\mathsf Q$ semantically equivalent?\n\nQ: \${THE_QUESTION}\nA1: \${GOLD_ANSWER}\nA2: \${PRED_ANSWER}\n\nPlease answer with a single word, either “Yes." or “No.", and explain your reasoning.
|
md/dev/lq62uWRJjiY/lq62uWRJjiY.md
ADDED
|
@@ -0,0 +1,416 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ADAPTIVE BUDGET ALLOCATION FOR PARAMETEREFFICIENT FINE-TUNING
|
| 2 |
+
|
| 3 |
+
Qingru Zhang†∗, Minshuo Chen‡, Alexander Bukharin†, Pengcheng $\mathbf { H e } ^ { \diamond }$ , Yu Cheng⋄, Weizhu Chen⋄ and Tuo Zhao†
|
| 4 |
+
|
| 5 |
+
†Georgia Institute of Technology ‡Princeton University ⋄Microsoft A {qingru.zhang,abukharin3,tourzhao}@gatech.edu mc0750@princeton.edu {penhe,yu.cheng,wzchen}@microsoft.com
|
| 6 |
+
|
| 7 |
+
# ABSTRACT
|
| 8 |
+
|
| 9 |
+
Fine-tuning large pre-trained language models on downstream tasks has become an important paradigm in NLP. However, common practice fine-tunes all of the parameters in a pre-trained model, which becomes prohibitive when a large number of downstream tasks are present. Therefore, many fine-tuning methods are proposed to learn incremental updates of pre-trained weights in a parameter efficient way, e.g., low-rank increments. These methods often evenly distribute the budget of incremental updates across all pre-trained weight matrices, and overlook the varying importance of different weight parameters. As a consequence, the finetuning performance is suboptimal. To bridge this gap, we propose AdaLoRA, which adaptively allocates the parameter budget among weight matrices according to their importance score. In particular, AdaLoRA parameterizes the incremental updates in the form of singular value decomposition. Such a novel approach allows us to effectively prune the singular values of unimportant updates, which is essentially to reduce their parameter budget but circumvent intensive exact SVD computations. We conduct extensive experiments with several pre-trained models on natural language processing, question answering, and natural language generation to validate the effectiveness of AdaLoRA. Results demonstrate that AdaLoRA manifests notable improvement over baselines, especially in the low budget settings. Our code is publicly available at https://github.com/ QingruZhang/AdaLoRA.
|
| 10 |
+
|
| 11 |
+
# 1 INTRODUCTION
|
| 12 |
+
|
| 13 |
+
Pre-trained language models (PLMs) have manifested superior performance in various natural language processing tasks (Devlin et al., 2019; Liu et al., 2019; He et al., 2021b; Radford et al., 2019; Brown et al., 2020). The most common way to adapt pre-trained models to down-stream tasks is to fine-tune all the parameters (full fine-tuning, Qiu et al. (2020); Raffel et al. (2020)). However, pre-trained models typically incurs large memory footprint. For example, BERT model (Devlin et al., 2019) consists up to 300 million parameters; T5 (Raffel et al., 2020) comprises up to 11 billion parameters and GPT-3 (Brown et al., 2020) contains up to 175 billion parameters. When building a NLP system upon these pre-trained models, we usually handle multiple tasks that arrive simultaneously (Radford et al., 2019). Given a large number of down-stream tasks, full fine-tuning requires that each task maintains a separated copy of large models. The resulting memory consumption is prohibitively expensive.
|
| 14 |
+
|
| 15 |
+
To address this issue, researchers have proposed two main lines of research to reduce the fine-tuning parameters, while maintaining or even improving the performance of PLMs. Specifically, one line of research focuses on adding small neural modules to PLMs and fine-tune only these modules for each task – the base model is kept frozen and shared across tasks. In this way, only a small number of task-specific parameters are introduced and updated, greatly enhancing the practicality of large models. For example, adapter tuning (Houlsby et al., 2019; Rebuffi et al., 2017; Pfeiffer et al., 2020;
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
Figure 1: Given the total trainable parameters as 0.28M, we apply LoRA only to selected weight matrices (left) or selected layers (right) of DeBERTaV3-base and compare the fine-tuning performance on MNLI-m. Figure 1a: we only fine-tune a selected type of weight matrix of every transformer layer, including query/key/value projection $( W _ { q } , W _ { k } , W _ { v } )$ , output projection $( W _ { o } )$ in the self-attention, and two weight matrices $( W _ { f _ { 1 } } , W _ { f _ { 2 } } )$ in two-layer FFNs. In Figure 1b, we apply LoRA to every weight matrix of the selected layers.
|
| 19 |
+
|
| 20 |
+
He et al., 2022) inserts small neural modules called adapters between the layers of the base model. Prefix tuning (Li & Liang, 2021) and prompt tuning (Lester et al., 2021) attach additional trainable prefix tokens to the input or hidden layers of the base model. These methods have shown to achieve comparable performance to full fine-tuning, while only updating less than $1 \%$ of the original model parameters, significantly releasing the memory consumption.
|
| 21 |
+
|
| 22 |
+
Another line of research proposes to model the incremental update of the pre-trained weights in a parameter-efficient way, without modifying the model architecture (Zaken et al., 2021; Guo et al., 2020; Hu et al., 2022). Given a pre-trained weight matrix1 $W ^ { ( 0 ) }$ , for example, diff pruning (Guo et al., 2020) models its incremental update $\Delta$ as a sparse matrix. Diff pruning initializes $\Delta$ as the same dimension as $W ^ { ( 0 ) }$ and then prunes $\Delta$ element-wise based on the magnitude of the entries. As such, diff pruning can increase the parameter efficiency substantially by adaptively retaining important updates and pruning unimportant ones. Nonetheless, diff pruning has several limitations. First, it relies on low-level implementation to speed up the computation of unstructured sparse matrices, which is not well supported by existing deep learning frameworks. Therefore, we have to store $\Delta$ as a dense matrix during training. Second, it needs to update every entry of $\Delta$ with their gradients and then prune them. This results in similar computational cost as full fine-tuning (Guo et al., 2020).
|
| 23 |
+
|
| 24 |
+
To overcome these drawbacks, Hu et al. (2022) propose a method named LoRA, which parameterizes $\Delta$ as a low-rank matrix by the product of two much smaller matrices:
|
| 25 |
+
|
| 26 |
+
$$
|
| 27 |
+
\begin{array} { r } { W = W ^ { ( 0 ) } + \Delta = W ^ { ( 0 ) } + B A , } \end{array}
|
| 28 |
+
$$
|
| 29 |
+
|
| 30 |
+
where $W ^ { ( 0 ) } , \Delta \in \mathbb { R } ^ { d _ { 1 } \times d _ { 2 } }$ , $A \in \mathbb { R } ^ { r \times d _ { 2 } }$ and $B \in \mathbb { R } ^ { d _ { 1 } \times r }$ with $r \ll \{ d _ { 1 } , d _ { 2 } \}$ . During fine-tuning, only $A$ and $B$ are updated. The rank $r$ is chosen to be much smaller than the dimension of $W$ (e.g., $r = 8$ when $d _ { 1 } = d _ { 2 } = 1 0 2 4 )$ . With less than $0 . 5 \%$ additional trainable parameters, the training overhead can be reduced up to $7 0 \%$ , compared to full fine-tuning. However, LoRA achieves comparable or even better performance than full fine-tuning (Hu et al., 2022). Meanwhile, the product of two samll matrices is more friendly to implement and deploy than unstructured sparse matrices in diff pruning.
|
| 31 |
+
|
| 32 |
+
LoRA still has limitations as it prespecifies the rank $r$ of each incremental matrix $\Delta$ identical. This ignores the fact that the importance of weight matrices varies significantly across modules and layers when fine-tuning pre-trained models. To illustrate this point, we present an concrete example in Figure 1. We compare the performance of LoRA when fine-tuning specific modules or layers with the same number of trainable parameters. Figure 1a shows that fine-tuning feed-forward networks (FFN) achieves better performance than self-attention modules. In addition, Figure 1b demonstrates that weight matrices in top layers are more important than those in bottom layers.
|
| 33 |
+
|
| 34 |
+
Adding more trainable parameters to the critical weight matrices can lead to better model performance. In contrast, adding more parameters to those less important weight matrices yields very marginal gains or even hurt model performance. Given the parameter budget, i.e., the number of total trainable parameters, we always prefer to allocate more parameters to those important modules. Distributing the budget evenly to all weight matrices/layers, like LoRA and other methods (e.g., adapter and prefix tuning), often gives suboptimal performance. To this end, a natural question is:
|
| 35 |
+
|
| 36 |
+
# How can we allocate the parameter budget adaptively according to importance of modules to improve the performance of parameter-efficient fine-tuning?
|
| 37 |
+
|
| 38 |
+
To answer this question, we propose a new method – AdaLoRA (Adaptive Low-Rank Adaptation), which dynamically allocates the parameter budget among weight matrices during LoRA-alike finetuning. Specifically, AdaLoRA adjusts the rank of incremental matrices to control their budget. Critical incremental matrices are assigned with high rank such that they can capture more fine-grained and task-specific information. Less importance ones are pruned to have lower rank to prevent overfitting and save the computational budget. There are some methods to control the rank of matrices in the existing literature of matrix approximation (Cai et al., 2010; Koltchinskii et al., 2011; Toh & Yun, 2010). Most of them directly compute singular value decomposition (SVD) of a matrix and then truncate the smallest singular values. Such an operation can manipulate the rank explicitly and, more importantly, minimize the difference between the resulting matrix and the original matrix. However, for fine-tuning large models, it becomes prohibitively expensive to iteratively apply SVD for a large number of high-dimensional weight matrices. Therefore, instead of computing SVD exactly, we parameterize $\Delta$ as $\Delta = P \Lambda Q$ to mimic SVD. The diagonal matrix $\Lambda$ contains singular values while the orthogonal matrices $P$ and $Q$ represent left/right singular vectors of $\Delta$ . To regularize the orthogonality of $P$ and $Q$ , an additional penalty is added to training loss. Such a parameterization avoids the intensive computations of SVD. Besides, another advantage is that we only need to drop the unimportant singular values while the singular vectors are maintained. This preserves the possibility of future recovery and stabilizes the training. See a detailed comparison to LoRA in Section 3.
|
| 39 |
+
|
| 40 |
+
Based on our SVD parameterization, AdaLoRA dynamically adjusts the rank of $\Delta = P V Q$ by importance scoring. Specifically, we divide the incremental matrix $P \Lambda Q$ into triplets, where each triplet $\mathcal { G } _ { i }$ contains the $i$ -th singular value and the corresponding singular vectors. To quantify the importance of triplets, we propose a novel importance metric, which takes account of the contribution of every entry in $\mathcal { G } _ { i }$ to the model performance (Sanh et al., 2020; Liang et al., 2021; Zhang et al., 2022). Triplets with low importance scores are granted low priority and hence the singular values are zeroed out. Triplets with high importance are retained for fine-tuning. Moreover, we also propose a global budget scheduler to facilitate the training. In particular, we start from an initial parameter budget, which is slightly higher than the final budget, and then gradually reduce it until matching the target. Such a scheduler can improve the training stability and model performance. Please see Section 3 for a detailed description of our importance metric and budget scheduler.
|
| 41 |
+
|
| 42 |
+
We conduct extensive experiments on a wide range of tasks and models to demonstrate the effectiveness of AdaLoRA. Specifically, we evaluate the performance using DeBERTaV3-base (He et al., 2021a) on natural language understanding (GLUE, Wang et al. (2019)) and question answering (SQuADv1, Rajpurkar et al. (2016) and SQuADv2, Rajpurkar et al. (2018)) datasets. We also apply our methods to BART-large (Lewis et al., 2019) and evaluate the performance on natural language generation (XSum, Narayan et al. (2018) and CNN/DailyMail, Hermann et al. (2015)) tasks. We show AdaLoRA consistently outperforms the baseline, especially under low budget settings. For example, with less than $0 . 1 \%$ trainable parameters of full fine-tuning, AdaLoRA achieves a $1 . 2 \%$ F1 improvement on the SQuAD2.0 dataset compared with state-of-the-art approaches.
|
| 43 |
+
|
| 44 |
+
# 2 BACKGROUND
|
| 45 |
+
|
| 46 |
+
Transformer-based Models. A typical transformer model consists of $L$ stacked blocks, where each block contains two submodules: a multi-head attention (MHA) and a fully connected FFN. Given the input sequence $\ b { X } \in \mathbb { R } ^ { n \times d }$ , MHA performs the attention function in parallel $h$ heads:
|
| 47 |
+
|
| 48 |
+
$$
|
| 49 |
+
\mathbf { M H A } \left( { X } \right) = \mathrm { C o n c a t } ( \mathrm { h e a d } _ { 1 } , . . . , \mathrm { h e a d } _ { h } ) W _ { o } , \quad \mathbf { h e a d } _ { i } = \mathrm { S o f t m a x } \left( { X W _ { q _ { i } } ( X W _ { k _ { i } } ) } ^ { \top } / \sqrt { d _ { h } } \right) X W _ { v _ { i } } ,
|
| 50 |
+
$$
|
| 51 |
+
|
| 52 |
+
where $W _ { o } \in \mathbb { R } ^ { d \times d }$ is an output projection and $W _ { q _ { i } } , W _ { k _ { i } } , W _ { v _ { i } } \in \mathbb { R } ^ { d \times d _ { h } }$ are query, key and value projections of head $i$ . $d _ { h }$ is typically set to $d / h$ . The other important module is a FFN which consists of two linear transformations with a ReLU activation in between: $\mathrm { F F N } ( X ) \ : = \ : \mathrm { R e L U } ( X W _ { f _ { 1 } } \ : +$ $b _ { 1 } ) W _ { f _ { 2 } } + b _ { 2 }$ , where $W _ { f _ { 1 } } \in \mathbb { R } ^ { d \times d _ { m } }$ and $W _ { f _ { 2 } } \in \mathbb { R } ^ { d _ { m } \times d }$ . Finally, a residual connection is used followed by a layer normalization (Ba et al., 2016).
|
| 53 |
+
|
| 54 |
+
Low Rank Adaptation. LoRA (Hu et al., 2022) models the incremental update of the pre-trained weights by the product of two small matrices. For $\pmb { h } = W ^ { ( 0 ) } \pmb { x }$ , the modified forward pass is:
|
| 55 |
+
|
| 56 |
+
$$
|
| 57 |
+
\pmb { h } = W ^ { ( 0 ) } \pmb { x } + \Delta \pmb { x } = W ^ { ( 0 ) } \pmb { x } + B A \pmb { x } ,
|
| 58 |
+
$$
|
| 59 |
+
|
| 60 |
+
where $W ^ { ( 0 ) } , \Delta \in \mathbb { R } ^ { d _ { 1 } \times d _ { 2 } }$ , $A \in \mathbb { R } ^ { r \times d _ { 2 } }$ and $B \in \mathbb { R } ^ { d _ { 1 } \times r }$ with $r \ll \{ d _ { 1 } , d _ { 2 } \}$ . $A$ typically adopts a random Gaussion initialization while $B$ is initialized with zero to have $\Delta = 0$ at the beginning of training. We further denote $A _ { i * }$ as the $i$ -th row of $A$ , $B _ { * i }$ as the $i$ -th column of $B$ , and $\mathcal { G } _ { i } = \{ A _ { i * } , B _ { * i } \}$ as the $i$ -th doublet. Hu et al. (2022) only apply LoRA to query and value projections (i.e, $W _ { q }$ and $W _ { v }$ ) in the MHAs. He et al. (2022) extend it to weight matrices of FFNs (i.e, $W _ { f _ { 1 } }$ and $W _ { f _ { 2 } }$ ), leading to the performance improvement . Meanwhile, they propose a unified view of various efficient tuning methods including adapter tuning, prefix tuning and LoRA.
|
| 61 |
+
|
| 62 |
+
# 3 ADALORA METHOD
|
| 63 |
+
|
| 64 |
+
Our method contains two important components: (i) SVD-based adaptation, which formulates the incremental matrices in the form of singular value decomposition; (ii) Importance-aware rank allocation, which prunes redundant singular values based on our newly-designed importance metric.
|
| 65 |
+
|
| 66 |
+
# 3.1 SVD-BASED ADAPTATION
|
| 67 |
+
|
| 68 |
+
As mentioned in Section 1, we propose to parameterize the incremental updates of the pre-trained weight matrices in the form of singular value decomposition:
|
| 69 |
+
|
| 70 |
+
$$
|
| 71 |
+
\begin{array} { r } { W = W ^ { ( 0 ) } + \Delta = W ^ { ( 0 ) } + P \Lambda Q , } \end{array}
|
| 72 |
+
$$
|
| 73 |
+
|
| 74 |
+
where $P \in \mathbb { R } ^ { d _ { 1 } \times r }$ and $Q \in \mathbb { R } ^ { r \times d _ { 2 } }$ represent the left/right singular vectors of $\Delta$ and the diagonal matrix $\boldsymbol { \Lambda } \in \mathbb { R } ^ { r \times r }$ contains the singular values $\{ \lambda _ { i } \} _ { 1 \leq i \leq r }$ with $r \ll \operatorname* { m i n } ( d _ { 1 } , d _ { 2 } )$ . We further denote $\mathcal { G } _ { i } = \{ P _ { * i } , \lambda _ { i } , Q _ { i * } \}$ as the triplet containing the $i$ -th singular value and vectors. In practice, since $\Lambda$ is diagonal, we only need to save it as a vector in $\mathbb { R } ^ { r }$ . $\Lambda$ is initialized with zero while $P$ and $Q$ adopt a random Gaussian initialization to ensure $\Delta = 0$ at the beginning of training. To enforce the orthogonality of $P$ and $Q$ , i.e., $P ^ { \top } P = Q Q ^ { \top } = I$ , we utilize the following regularizer2:
|
| 75 |
+
|
| 76 |
+
$$
|
| 77 |
+
R ( P , Q ) = \| P ^ { \top } P - I \| _ { \mathsf { F } } ^ { 2 } + \| Q Q ^ { \top } - I \| _ { \mathsf { F } } ^ { 2 } .
|
| 78 |
+
$$
|
| 79 |
+
|
| 80 |
+
In our method, $\Lambda$ is iteratively pruned to adjust the rank after each gradient decent step. As mentioned in Section 1, one can directly compute SVD for every $\Delta$ to manipulate singular values. The computational complexity, however, is $O ( \operatorname* { m i n } ( d _ { 1 } , d _ { 2 } ) \dot { d } _ { 1 } d _ { 2 } )$ . It becomes extremely expensive to iteratively apply SVD for a large number of high-dimensional incremental matrices. In contrast, our parameterization avoids intensive SVD computation, greatly releasing the computational overhead.
|
| 81 |
+
|
| 82 |
+
We remark that one can also apply structured pruning to LoRA to control the rank (i.e., prune $B A$ doublet-wise in (1)), whereas it has the following disadvantages. First, when a doublet is measured as unimportant, we have to prune all of its elements. It makes scarcely possible to reactivate the pruned doublets as their entries are all zeroed out and not trained. In contrast, AdaLoRA only masks out the singular values based on (3) while the singular vectors are always maintained. It preserves the potential of future recovery for the triplets dropped by mistake. Second, $A$ and $B$ of LoRA are not orthogonal, meaning the doublets can be dependent with each other. Discarding the doublets can incur larger variation from the original matrix than truncating the smallest singular values. Therefore, the incremental matrices are often altered dramatically after each step of rank allocation, which causes training instability and even hurts generalization. To demonstrate this point, we present an ablation study in Section 4.4, which compares AdaLoRA with structured pruning for LoRA.
|
| 83 |
+
|
| 84 |
+
# 3.2 IMPORTANCE-AWARE RANK ALLOCATION
|
| 85 |
+
|
| 86 |
+
We apply the SVD-based adaptation (3) to every weight matrix including $W _ { q }$ , $W _ { k }$ , $W _ { v }$ , $W _ { f _ { 1 } }$ and $W _ { f _ { 2 } }$ of each transformer layer. In order to control the budget, we iteratively prune singular values in correspondence to their importance score during the training. For clear reference, we use $k$ to index the incremental matrix, i.e., $\Delta _ { k } = P _ { k } \Lambda _ { k } Q _ { k }$ for $k = 1 , \ldots , n$ , where $n$ is the number of adapted weight matrimportance score as We denote the . We further de $i$ -th triplet of ote the para $\Delta _ { k }$ as r s $\mathcal { G } _ { k , i } = \{ P _ { k , * i } , \lambda _ { k , i } , Q _ { k , i * } \}$ s, $S _ { k , i }$ $\mathcal { P } = \{ P _ { k } \} _ { k = 1 } ^ { n }$ $\mathcal { E } \stackrel { } { = } \{ \Lambda _ { k } \} _ { k = 1 } ^ { n }$ $\mathcal { Q } = \{ Q _ { k } \} _ { k = 1 } ^ { n }$ and training cost as $\mathcal { C } ( \mathcal { P } , \mathcal { E } , \mathcal { Q } )$ . With the regularization (4), the training objective is given by $\begin{array} { r } { \overline { { \mathcal { L } } } ( \mathcal { P } , \mathcal { E } , \mathcal { Q } ) = \overline { { \mathcal { C } ( \mathcal { P } , \mathcal { E } , \mathcal { Q } ) + \gamma \sum _ { k = 1 } ^ { n } R ( P _ { k } , Q _ { k } ) } } } \end{array}$ , where $\gamma > 0$ is the regularization coefficient. At the t-th step, we first take a stochastic gradient step to update P (t)k , $P _ { k } ^ { ( t ) } , \Lambda _ { k } ^ { ( t ) }$ and $Q _ { k } ^ { ( t ) }$ for $k = 1 , \dots , n$ . Specifically, for ${ \Lambda } _ { k } ^ { \left( t \right) }$
|
| 87 |
+
|
| 88 |
+
$$
|
| 89 |
+
\tilde { \Lambda } _ { k } ^ { ( t ) } = \Lambda _ { k } ^ { ( t ) } - \eta \nabla _ { \Lambda _ { k } } \mathcal { L } ( \mathcal { P } ^ { ( t ) } , \mathcal { E } ^ { ( t ) } , \mathcal { Q } ^ { ( t ) } ) ,
|
| 90 |
+
$$
|
| 91 |
+
|
| 92 |
+
where $\eta > 0$ is learning rate. Then, given importance score $S _ { k } ^ { ( t ) }$ , the singular values are pruned following
|
| 93 |
+
|
| 94 |
+
$$
|
| 95 |
+
\begin{array} { r } { \Lambda _ { k } ^ { ( t + 1 ) } = \mathcal { T } ( \tilde { \Lambda } _ { k } ^ { ( t ) } , S _ { k } ^ { ( t ) } ) , \mathrm { ~ w i t h ~ } \mathcal { T } ( \tilde { \Lambda } _ { k } ^ { ( t ) } , S _ { k } ^ { ( t ) } ) _ { i i } = \left\{ \begin{array} { l l } { \tilde { \Lambda } _ { k , i i } ^ { ( t ) } } & { S _ { k , i } ^ { ( t ) } \mathrm { ~ i s ~ i n ~ t h e ~ t o p } - b ^ { ( t ) } \mathrm { ~ o f ~ } S ^ { ( t ) } , } \\ { 0 } & { \mathrm { o t h e r w i s e } , } \end{array} \right. } \end{array}
|
| 96 |
+
$$
|
| 97 |
+
|
| 98 |
+
where $S ^ { ( t ) } = \{ S _ { k , i } ^ { ( t ) } \} _ { 1 \leq k \leq n , 1 \leq i \leq r }$ contains the importance score of all triplets. Here $b ^ { ( t ) }$ is the budget of remaining singular values at the $t$ -th step, which we explain more in Section 3.3. In this way, we leave more budget to the incremental matrices of higher priority by pruning the singular values of less important ones. In the sequel, we introduce several options to design the importance score.
|
| 99 |
+
|
| 100 |
+
Magnitude of singular values is the most straightforward way to quantify the importance of every triplet, i.e., $S _ { k , i } = | \lambda _ { k , i } |$ . In this way, only the least significant singular values are discarded. It minimizes the deviation from the original matrix and further stabilizes the training. Many existing methods use this criterion to control the rank of matrix (Cai et al., 2010; Koltchinskii et al., 2011; Toh & Yun, 2010). However, we remark that such a simple metric cannot properly quantify the contribution of parameters to model performance.
|
| 101 |
+
|
| 102 |
+
Sensitivity-based importance is another option for importance scoring, which quantifies the sensitivity of parameters to the training loss (Molchanov et al., 2019; Sanh et al., 2020; Liang et al., 2021; Zhang et al., 2022). The prior work, however, leverages the sensitivity to quantify the importance of single entries and applies it for unstructured pruning that prunes weights element-wise. When it turns to our case, we have to design a new metric as the triplets are discarded group-wise. Every entry’s sensitivity ought to be considered and properly combined to quantify the overall contribution of the triplet to model performance. Therefore, we propose a newly-designed importance metric in account of both the singular value and vectors in triplet $\mathcal { G } _ { k , i }$ :
|
| 103 |
+
|
| 104 |
+
$$
|
| 105 |
+
S _ { k , i } = s ( \lambda _ { k , i } ) + \frac { 1 } { d _ { 1 } } \sum _ { j = 1 } ^ { d _ { 1 } } s ( P _ { k , j i } ) + \frac { 1 } { d _ { 2 } } \sum _ { j = 1 } ^ { d _ { 2 } } s ( Q _ { k , i j } ) ,
|
| 106 |
+
$$
|
| 107 |
+
|
| 108 |
+
where we calculate the mean importance of $P _ { k , * i }$ and $Q _ { k , i * }$ such that $S _ { k , i }$ does not scale with the number of parameters in $\mathcal { G } _ { k , i }$ . Here $s ( \cdot )$ is a specific importance function for single entries. We can adopt the sensitivity for $s ( \cdot )$ , which is defined as the magnitude of the gradient-weight product:
|
| 109 |
+
|
| 110 |
+
$$
|
| 111 |
+
I ( w _ { i j } ) = | w _ { i j } \nabla _ { w _ { i j } } \mathcal { L } | ,
|
| 112 |
+
$$
|
| 113 |
+
|
| 114 |
+
where $w _ { i j }$ is any trainable parameter. (8) essentially approximates the change in loss when a parameter is zeroed out. If the removal of a parameter has a large influence, then the model is sensitive to it and we should retain it (Molchanov et al., 2019; Liang et al., 2021; Zhang et al., 2022).
|
| 115 |
+
|
| 116 |
+
However, Zhang et al. (2022) point out that the sensitivity in (8) is not yet a reliable importance indicator. Such a score is estimated on the sampled mini batch. The stochastic sampling and complicated training dynamics incur high variability and large uncertainty for estimating the sensitivity with (8). Therefore, Zhang et al. (2022) propose to resolve this issue by sensitivity smoothing and uncertainty quantification:
|
| 117 |
+
|
| 118 |
+
$$
|
| 119 |
+
\begin{array} { r l } & { \overline { { I } } ^ { ( t ) } ( w _ { i j } ) = \beta _ { 1 } \overline { { I } } ^ { ( t - 1 ) } ( w _ { i j } ) + ( 1 - \beta _ { 1 } ) I ^ { ( t ) } ( w _ { i j } ) } \\ & { \overline { { U } } ^ { ( t ) } ( w _ { i j } ) = \beta _ { 2 } \overline { { U } } ^ { ( t - 1 ) } ( w _ { i j } ) + ( 1 - \beta _ { 2 } ) \Big | I ^ { ( t ) } ( w _ { i j } ) - \overline { { I } } ^ { ( t ) } ( w _ { i j } ) \Big | , } \end{array}
|
| 120 |
+
$$
|
| 121 |
+
|
| 122 |
+
where $0 < \beta _ { 1 } , \beta _ { 2 } < 1$ . $\overline { { I } } ^ { ( t ) }$ is the smoothed sensitivity by exponential moving average and $\overline { { U } } ^ { ( t ) }$ is the uncertainty term quantified by the local variation between $I ^ { ( t ) }$ and $\overline { { I } } ^ { ( t ) }$ . Then they define the importance as the product between I(t) and $\overline { { U } } ^ { ( t ) }$ , which can be another option for $s ( \cdot )$ :
|
| 123 |
+
|
| 124 |
+
$$
|
| 125 |
+
\begin{array} { r } { s ^ { ( t ) } ( w _ { i j } ) = \overline { { I } } ^ { ( t ) } ( w _ { i j } ) \cdot \overline { { U } } ^ { ( t ) } ( w _ { i j } ) . } \end{array}
|
| 126 |
+
$$
|
| 127 |
+
|
| 128 |
+
We present a detailed ablation study in Section 4.4 to compare the performance of different importance metrics. We find the proposed metric (7) based on the sensitivity variant (11) generally performs best. We summarize the detailed algorithm in Algorithm 1 presented in Appendix A.
|
| 129 |
+
|
| 130 |
+
# 3.3 GLOBAL BUDGET SCHEDULER
|
| 131 |
+
|
| 132 |
+
As mentioned in Section 1, adjusting the rank is naturally to control the parameter budget in the context of low-rank adaptation. Hence we define the budget $b ^ { ( t ) }$ as the total rank of all incremental matrices, i.e., the number of total singular values. Recall that the budget allocation is iteratively conducted during the fine-tuning. To facilitate the training, we propose a global budget scheduler. Specifically, we start from an initial budget $b ^ { ( 0 ) }$ that is slightly higher than the target budget $b ^ { ( T ) }$ (e.g., 1.5 times of $b ^ { ( T ) }$ ). We set the initial rank of each incremental matrix as $r = \bar { b ^ { ( 0 ) } } / n$ . We warm up the training for $t _ { i }$ steps, and then follow a cubic schedule to decrease the budget $b ^ { ( t ) }$ until it reaches $b ^ { ( T ) }$ . Finally, we fix the resulting budget distribution and fine-tune the model for $t _ { f }$ steps. The exact equation for the budget schedule is presented in Appendix B. This allows AdaLoRA to explore the parameter space first and then focus on the most important weights later.
|
| 133 |
+
|
| 134 |
+
# 4 EXPERIMENTS
|
| 135 |
+
|
| 136 |
+
We implement AdaLoRA for fine-tuning DeBERTaV3-base (He et al., 2021a) and BART-large (Lewis et al., 2019). We evaluate the effectiveness of the proposed algorithm on natural language understanding (GLUE, Wang et al. (2019)), question answering (SQuADv1, Rajpurkar et al. (2016) and SQuADv2, Rajpurkar et al. (2018)), and natural language generation (XSum, Narayan et al. (2018) and CNN/DailyMail Hermann et al. (2015)). All the gains have passed significant tests with $p < 0 . 0 5$ .
|
| 137 |
+
|
| 138 |
+
Implementation Details. We use PyTorch (Paszke et al., 2019) to implement all the algorithms. Our implementation is based on the publicly available Huggingface Transformers3 (Wolf et al., 2019) code-base. All the experiments are conducted on NVIDIA V100 GPUs.
|
| 139 |
+
|
| 140 |
+
LoRA scales $\Delta { } x$ by $\alpha / r$ where $\alpha$ is a constant in $r$ . As a result, the magnitude of output can be consistent given different $r$ . It reduces the efforts of retuning learning rate when varying $r$ . Typically $\alpha$ is set as 16 or 32 and never tuned (Hu et al., 2022; Yang & Hu, 2020). Following LoRA, we add the same scaling for (3) and fix $\alpha$ as LoRA. Besides, in Algorithm 1, we prune singular values every $\Delta _ { T }$ steps (e.g., $\Delta _ { T } = 1 0 0 _ { , } ^ { \cdot }$ ) such that the pruned triplets can still get updated within these intervals and possibly reactivated in future iterations.
|
| 141 |
+
|
| 142 |
+
Baselines. We compare AdaLoRA with the following methods:
|
| 143 |
+
|
| 144 |
+
• Full fine-tuning is the most common approach for adaptation. During fine-tuning, the model is initialized with pre-trained weights and biases, and all model parameters undergo gradient updates.
|
| 145 |
+
|
| 146 |
+
• Bitfit (Zaken et al., 2021) is an effective parameter-efficient fine-tuning method. The method only fine-tunes bias vectors in the pre-trained model.
|
| 147 |
+
|
| 148 |
+
• Adapter tuning (Houlsby et al., 2019; Pfeiffer et al., 2020) inserts two-layer adapters between transformer blocks. We compare with two types of adapter. Houlsby adapter as proposed in Houlsby et al. (2019) is inserted between the self-attention module and the FFN module followed by a subsequent residual connection. Recently, Pfeiffer et al. (2020) propose a more efficient design with adapters only applied after FFN modules and LayerNorm modules (Ba et al., 2016), which we call Pfeiffer adapter. The number of trainable parameters is determined by the number of layers, the hidden dimension of adapters and the dimension of their inputs.
|
| 149 |
+
|
| 150 |
+
LoRA (Hu et al., 2022) is a state-of-the-art method for parameter-efficient fine-tuning. The method parameterizes incremental updates by two small matrices and only fine-tune them. The number of trainable parameter is controlled by the rank $r$ and the number of adapted weight matrices $n$ . Hu et al. (2022) apply LoRA to query and value projections only. In empirical, we find that applying LoRA to all weight matrices, i.e., $W _ { q } , W _ { k } , W _ { v } , W _ { f _ { 1 } }$ and $W _ { f _ { 2 } }$ , can further improve its performance (Please see Appendix H). Hence, we compare with this generalized LoRA to maximize its performance. We use publicly available implementation 4 to run all the baselines. Please refer to Hu et al. (2022) and reference therein for details.
|
| 151 |
+
|
| 152 |
+
Table 1: Results with DeBERTaV3-base on GLUE development set. The best results on each dataset are shown in bold. We report the average correlation for STS-B. Full FT, HAdapter and PAdapter represent full fine-tuning, Houlsby adapter, and Pfeiffer adapter respectively. We report mean of 5 runs using different random seeds.
|
| 153 |
+
|
| 154 |
+
<table><tr><td>Method</td><td># Params</td><td>MNLI m/mm</td><td>SST-2 Acc</td><td>CoLA Mcc</td><td>QQP Acc/F1</td><td>QNLI Acc</td><td>RTE Acc</td><td>MRPC Acc</td><td>STS-B Corr</td><td>All Ave.</td></tr><tr><td>Full FT</td><td>184M</td><td>89.90/90.12</td><td>95.63</td><td>69.19</td><td>92.40/89.80</td><td>94.03</td><td>83.75</td><td>89.46</td><td>91.60</td><td>88.09</td></tr><tr><td>BitFit</td><td>0.1M</td><td>89.37/89.91</td><td>94.84</td><td>66.96</td><td>88.41/84.95</td><td>92.24</td><td>78.70</td><td>87.75</td><td>91.35</td><td>86.02</td></tr><tr><td>HAdapter</td><td>1.22M</td><td>90.13/90.17</td><td>95.53</td><td>68.64</td><td>91.91/89.27</td><td>94.11</td><td>84.48</td><td>89.95</td><td>91.48</td><td>88.12</td></tr><tr><td>PAdapter</td><td>1.18M</td><td>90.33/90.39</td><td>95.61</td><td>68.77</td><td>92.04/89.40</td><td>94.29</td><td>85.20</td><td>89.46</td><td>91.54</td><td>88.24</td></tr><tr><td>LoRAr=8</td><td>1.33M</td><td>90.65/90.69</td><td>94.95</td><td>69.82</td><td>91.99/89.38</td><td>93.87</td><td>85.20</td><td>89.95</td><td>91.60</td><td>88.34</td></tr><tr><td>AdaLoRA</td><td>1.27M</td><td>90.76/90.79</td><td>96.10</td><td>71.45</td><td>92.23/89.74</td><td>94.55</td><td>88.09</td><td>90.69</td><td>91.84</td><td>89.31</td></tr><tr><td>HAdapter</td><td>0.61M</td><td>90.12/90.23</td><td>95.30</td><td>67.87</td><td>91.65/88.95</td><td>93.76</td><td>85.56</td><td>89.22</td><td>91.30</td><td>87.93</td></tr><tr><td>PAdapter</td><td>0.60M</td><td>90.15/90.28</td><td>95.53</td><td>69.48</td><td>91.62/88.86</td><td>93.98</td><td>84.12</td><td>89.22</td><td>91.52</td><td>88.04</td></tr><tr><td>HAdapter</td><td>0.31M</td><td>90.10/90.02</td><td>95.41</td><td>67.65</td><td>91.54/88.81</td><td>93.52</td><td>83.39</td><td>89.25</td><td>91.31</td><td>87.60</td></tr><tr><td>PAdapter</td><td>0.30M</td><td>89.89/90.06</td><td>94.72</td><td>69.06</td><td>91.40/88.62</td><td>93.87</td><td>84.48</td><td>89.71</td><td>91.38</td><td>87.90</td></tr><tr><td>LoRAr=2</td><td>0.33M</td><td>90.30/90.38</td><td>94.95</td><td>68.71</td><td>91.61/88.91</td><td>94.03</td><td>85.56</td><td>89.71</td><td>91.68</td><td>88.15</td></tr><tr><td>AdaLoRA</td><td>0.32M</td><td>90.66/90.70</td><td>95.80</td><td>70.04</td><td>91.78/89.16</td><td>94.49</td><td>87.36</td><td>90.44</td><td>91.63</td><td>88.86</td></tr></table>
|
| 155 |
+
|
| 156 |
+
# 4.1 NATURAL LANGUAGE UNDERSTANDING
|
| 157 |
+
|
| 158 |
+
Models and Datasets. We evaluate the fine-tuning performance of DeBERTaV3-base (He et al., 2021a) using the proposed algorithm. We conduct experiments on the General Language Understanding Evaluation (GLUE, Wang et al. 2019) benchmark. The benchmark includes two single-sentence classification tasks, three similarity and paraphrase tasks and four natural language inference tasks. Dataset details are summarized in Appendix D.
|
| 159 |
+
|
| 160 |
+
Implementation Details. DeBERTaV3-base consists of 183 millions parameters. We compare AdaLoRA with the baselines under different budget levels, for example, given the total trainable parameters as $0 . 3 / 0 . 6 / 1 . 2$ million. In order to match the parameter budget, we select the hidden dimensions of adapters from $\{ 8 , 1 6 , 3 2 , 6 4 \}$ , set the rank $r$ of LoRA as $\ \bar { \{ 2 , 4 , 8 \} }$ , and choose the final budget $b ^ { ( T ) }$ of AdaLoRA from $\{ 1 4 4 , 2 8 8 , 5 7 6 \}$ . Then we set $b ^ { ( 0 ) }$ as 1.5 times of $b ^ { ( T ) }$ for AdaLoRA and select the regularization coefficient $\gamma$ from $\{ 0 . 1 , 0 . 3 , 0 . 5 \}$ . We set the exponential moving average parameters $\beta _ { 1 }$ and $\beta _ { 2 }$ as their default value 0.85. We select the learning rate from $\{ 5 \times \bar { 1 0 } ^ { - 5 } , 8 \times \bar { 1 0 } ^ { - 5 } , 1 \times 1 0 ^ { - 4 } , 2 \times 1 0 ^ { - 4 } \}$ . More details are presented in Appendix E.
|
| 161 |
+
|
| 162 |
+
Main results. We compare AdaLoRA with the baseline methods under different budget settings. Table 1 shows experimental results on the GLUE development set. We see that AdaLoRA achieves better or on par performance compared with existing approaches on all datasets under all budget levels. For example, when the parameter budget is $0 . 3 { \bf M }$ , AdaLoRA achieves $8 7 . 3 6 \%$ accuracy on RTE, which is $1 . 8 \%$ higher than the best-performing baseline. Besides, AdaLoRA with extreme low budget can often perform better than the baselines with higher budget. For example, AdaLoRA achieve $7 0 . 0 4 \%$ Mcc. score on CoLA with 0.3M fine-tuning parameters, which is higher than all baseline methods with lager budget (e.g., 0.6M and 1.2M).
|
| 163 |
+
|
| 164 |
+
# 4.2 QUESTION ANSWERING
|
| 165 |
+
|
| 166 |
+
Models and Datasets. We evaluate performance of the proposed algorithm on two question answering (QA) datasets: SQuAD v1.1 (Rajpurkar et al., 2016) and SQuADv2.0 (Rajpurkar et al., 2018), where we use AdaLoRA to fine-tune DeBERTaV3-base. These tasks are treated as a sequence labeling problem, where we predict the probability of each token being the start and end of the answer span. Dataset details can be found in Appendix F.
|
| 167 |
+
|
| 168 |
+
Implementation Details. We compare AdaLoRA with the baseline methods under different parameter budgets. That is we have the number of trainable parameters as $0 . 0 8 \% / 0 . 1 6 \% / 0 . 3 2 \% / 0 . 6 5 \%$ of total pre-trained parameters. To match the budget requirements, we select the hidden dimensions of adapters from $\{ 4 , 8 , 1 6 , 3 2 , 6 4 \}$ , set the rank $r$ of LoRA as $\{ 1 , 2 , 4 , 8 \}$ and choose the final total rank $b ^ { ( T ) }$ of AdaLoRA from $\{ 7 2 , 1 4 4 , 2 8 8 , 5 7 6 \}$ . We set the batch size as 16. We use AdamW (Loshchilov & Hutter, 2019) as the optimizer and we set the learning rate as $1 \times 1 0 ^ { - 3 }$ for AdaLoRA. Please refer to Appendix F for more details.
|
| 169 |
+
|
| 170 |
+
Main Results. Table 2 summarizes experimental results when we fine-tune DeBERTaV3-base under 4 different budget settings: $0 . 0 8 \%$ , $0 . 1 6 \%$ , $0 . 3 2 \%$ and $0 . 6 5 \%$ of total pre-trained parameters. From the result, we see that AdaLoRA consistently outperforms existing approaches under all the budget levels in term of two evaluation metrics: exact match (EM) and F1. Notice that the performance of Houlsby adapter and Pfeiffer adapter are notably decreased when we reduce the parameter budget. In contrast, our method shows the consistent performance under different budget levels. For example, AdaLoRA achieves $8 8 . 7 \%$ F1 on $\mathrm { S Q u A D v } 2 . 0$ with the smallest budget $0 . 0 8 \%$ . It is close to its performance under the high budget and it is also $1 . 2 \%$ higher than the best-performing baseline.
|
| 171 |
+
|
| 172 |
+
Table 2: Results with DeBERTaV3-base on SQuAD v1.1 and SQuADv2.0. Here # Params is the number of trainable parameters relative to that in full fine-tuning. We report EM/F1. The best results in each setting are shown in bold.
|
| 173 |
+
|
| 174 |
+
<table><tr><td>一</td><td colspan="4">SQuADv1.1</td><td colspan="4"> SQuADv2.0</td></tr><tr><td>Full FT</td><td colspan="4">86.0 /92.7</td><td colspan="4">85.4 / 88.4</td></tr><tr><td># Params</td><td>0.08%</td><td>0.16%</td><td>0.32%</td><td>0.65%</td><td>0.08%</td><td>0.16%</td><td>0.32%</td><td>0.65%</td></tr><tr><td>HAdapter</td><td>84.4/91.5</td><td>85.3/92.1</td><td>86.1/92.7</td><td>86.7/92.9</td><td>83.4/86.6</td><td>84.3/87.3</td><td>84.9/87.9</td><td>85.4/88.3</td></tr><tr><td>PAdapter</td><td>84.4/91.7 8</td><td>85.9/92.5</td><td>86.2/92.8</td><td>86.6/93.0</td><td>84.2/87.2</td><td>84.5/87.6</td><td>84.9/87.8</td><td>84.5/87.5</td></tr><tr><td>LoRA</td><td>86.4/92.8</td><td>86.6/92.9</td><td>86.7/93.1</td><td>86.7/93.1</td><td>84.7/87.5</td><td>83.6/86.7</td><td>84.5/87.4</td><td>85.0/88.0</td></tr><tr><td>AdaLoRA</td><td>87.2/93.4</td><td>87.5/93.6</td><td>87.5/93.7 87.6/93.7</td><td></td><td>85.6/88.7</td><td>85.7/88.8 85.5/88.6 86.0/88.9</td><td></td><td></td></tr></table>
|
| 175 |
+
|
| 176 |
+
# 4.3 NATURAL LANGUAGE GENERATION
|
| 177 |
+
|
| 178 |
+
Table 3: Results with BART-large on XSum and CNN/DailyMail. Here # Params is the number of trainable parameters relative to that in full fine-tuning. We report R-1/2/L. The best results are shown in bold.
|
| 179 |
+
|
| 180 |
+
<table><tr><td> # Params</td><td>Method</td><td>XSum</td><td>CNN/DailyMail</td></tr><tr><td>100%</td><td>Full FT</td><td>45.49 / 22.33 / 37.26</td><td>44.16 /21.28 / 40.90</td></tr><tr><td rowspan="2">2.20%</td><td>LoRA</td><td>43.95 / 20.72 / 35.68</td><td>45.03 / 21.84 / 42.15</td></tr><tr><td>AdaLoRA</td><td>44.72 / 21.46 / 36.46</td><td>45.00 / 21.89 / 42.16</td></tr><tr><td rowspan="2">1.10%</td><td>LoRA</td><td>43.40 /20.20 / 35.20</td><td>44.72 /21.58 /41.84</td></tr><tr><td>AdaLoRA</td><td>44.35 / 21.13 / 36.13</td><td>44.96 / 21.77 / 42.09</td></tr><tr><td rowspan="2">0.26%</td><td>LoRA</td><td>43.18 / 19.89 / 34.92</td><td>43.95 / 20.91 / 40.98</td></tr><tr><td>AdaLoRA</td><td>43.55 / 20.17 / 35.20</td><td>44.39 / 21.28 / 41.50</td></tr><tr><td rowspan="2">0.13%</td><td>LoRA</td><td>42.81 / 19.68 / 34.73</td><td>43.68 / 20.63 / 40.71</td></tr><tr><td>AdaLoRA</td><td>43.29 /19.95 /35.04</td><td>43.94 /20.83 /40.96</td></tr></table>
|
| 181 |
+
|
| 182 |
+
Models and Datasets. To provide a comparison with the state-of-the-art in natural language generation (NLG) tasks, we apply AdaLoRA to fine-tune a BART-large model (Lewis et al., 2019). We evaluate model performance on two datasets: XSum (Narayan et al., 2018) and CNN/DailyMail (Hermann et al., 2015).
|
| 183 |
+
|
| 184 |
+
Implementation Details. Similarly as DeBERTav3-base, we apply low-rank/SVD-based adaptation to every weight matrix of both encoder and decoder layers. We report ROUGE 1/2/L scores (R-1/2/L, Lin (2004)). We set the training epochs as 15. For XSum, we set the beam length as 8 and batch size as 64. For CNN/DailyMail, we set the beam length as 4 and batch size as 32. Please see Appendix G for the detailed configuration.
|
| 185 |
+
|
| 186 |
+
Main Results. Experimental results are summarized in Table 3, where we compare the fine-tuning performance under four budget levels: the number of trainable parameters is $0 . 1 3 \%$ , $0 . 2 6 \%$ , $1 . 1 0 \%$ and $2 . 2 0 \%$ of total pre-trained parameters. We see that AdaLoRA achieves better or on par performance compared with the baseline on both datasets (XSum and CNN/DailyMail) under all the budget levels. For example, AdaLoRA achieves $2 1 . 1 3 \mathrm { R } \mathrm { - } 2 $ score when budget level is $1 . 1 0 \%$ , compared with 19.89 for LoRA.
|
| 187 |
+
|
| 188 |
+
# 4.4 ANALYSIS
|
| 189 |
+
|
| 190 |
+
Different budget levels. Figure 2 illustrates experimental results of fine-tuning DeBERTaV3-base under different budget levels. We see that on all the three datasets (MNLI-m, SQuADv2.0 and XSum), AdaLoRA achieves consistent performance improvement under all the budget levels compared with the baseline. The performance gain is more significant when increasing the budget for the XSum task, suggesting a high budget can help NLG tasks. Note that on the MNLI and $\mathrm { S Q u A D v } 2 . 0$ datasets, the performance of AdaLoRA under low budget levels $( \leq 1 \% )$ can match the results of high budget settings. For example, AdaLoRA achieves $8 8 . 7 8 \%$ F1 on SQuADv2.0 when the budget is $0 . 1 6 \%$ . It is close to the performance $8 8 . 8 9 \%$ F1) of the highest budget $( 4 . 6 5 \% )$ ) with a more significant gain over the baseline.
|
| 191 |
+
|
| 192 |
+

|
| 193 |
+
Figure 2: Fine-tuning performance under different budget levels. We compare AdaLoRA with the generalized LoRA that applies to every weight matrix.
|
| 194 |
+
|
| 195 |
+
Comparison to low-rank parameterization. As mentioned in Section 3.1, one can alternatively prune LoRA doublet-wise to conduct the rank allocation. In this case, the doublets are zeroed out entirely, raising the barrier to reactivate them. It can cause training instability and hurt the generalization when some crucial doublets are pruned by mistake. In Table 4, we compare AdaLoRA with pruning LoRA on three datasets (SST-2, RTE, and CoLA) to illustrate this point. We apply the same importance score, budget scheduler and training setups as Section 4.1 for pruning LoRA. We can see that AdaLoRA outperforms pruning LoRA on all the datasets under all the budget levels.
|
| 196 |
+
|
| 197 |
+
Table 4: We present two ablation studies in this table: (i) Comparison between AdaLoRA and structured pruning on LoRA. (ii) Comparison of different importance metrics for AdaLoRA.
|
| 198 |
+
|
| 199 |
+
<table><tr><td>1</td><td colspan="3">SST-2</td><td colspan="3">RTE</td><td colspan="3">CoLA</td></tr><tr><td># Params</td><td>0.08%</td><td>0.16%</td><td>0.65%</td><td>0.08%</td><td>0.16%</td><td>0.65%</td><td>0.08%</td><td>0.16%</td><td>0.65%</td></tr><tr><td>Prune LoRA</td><td>94.84</td><td>94.50</td><td>94.95</td><td>86.28</td><td>86.15</td><td>87.00</td><td>66.71</td><td>69.29</td><td>69.57</td></tr><tr><td>AdaLoRA</td><td>95.52</td><td>95.80</td><td>96.10</td><td>87.36</td><td>87.73</td><td>88.09</td><td>70.21</td><td>70.04</td><td>71.45</td></tr><tr><td>s()= I()</td><td>94.61</td><td>95.30</td><td>95.64</td><td>87.36</td><td>87.71</td><td>88.10</td><td>66.71</td><td>68.83</td><td>70.19</td></tr><tr><td>Si=Xl</td><td>95.41</td><td>95.41</td><td>95.87</td><td>87.00</td><td>86.28</td><td>88.00</td><td>67.67</td><td>68.44</td><td>70.38</td></tr></table>
|
| 200 |
+
|
| 201 |
+
Variants of the importance score. Recall that in AdaLoRA, the importance score is defined by the sensitivity and uncertainty of every entry in the triplet (7). In Table 4, we examine two variants of the importance score: (i) changing $s ( \cdot )$ in (7) to sensitivity-only; (ii) directly defining $S _ { i }$ as $| \lambda _ { i } |$ . From the results, we can see that the proposed importance score generally performs best. The other two variants can degenerate the model performance up to $0 . 9 \%$ .
|
| 202 |
+
|
| 203 |
+
The resulting budget distribution. Figure 3 in Appendix C shows the resulting rank of each incremental matrix of DeBERTaV3-base fine-tuned with AdaLoRA. We find that AdaLoRA always prefers to allocating more budget to FFNs and top layers. Such behavior aligns with our empirical conclusions presented in Figure 1 that weight matrices of FFN moduels and top layers are more important for model performance. Hence, it validates that our proposed importance metric can guide AdaLoRA to focus on crucial modules. Meanwhile, the rank distribution generated by AdaLoRA is consistent across different budget levels, tasks and models. It means the number of remaining parameters is linearly scaled with $b ^ { ( T ) }$ and hence we can tune $b ^ { ( T ) }$ to control the remaining parameters.
|
| 204 |
+
|
| 205 |
+
# 5 CONCLUSION
|
| 206 |
+
|
| 207 |
+
We propose a parameter-efficient fine-tuning method – AdaLoRA that adaptively allocates the parameter budget according to importance scoring. In AdaLoRA, we parameterize the incremental updates of weight matrices in the form of singular value decomposition. Then, we dynamically allocate the parameter budget among incremental matrices by manipulating the singular values based on a new importance measurement. Such an a pproach effectively improves the model performance and parameter efficiency. We conduct extensive experiments on natural language processing, question answering and natural language generation tasks. Results show that AdaLoRA outperforms existing approaches.
|
| 208 |
+
|
| 209 |
+
# REFERENCES
|
| 210 |
+
|
| 211 |
+
Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016.
|
| 212 |
+
|
| 213 |
+
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 Hugo Larochelle, Marc’Aurelio Ranzato, Raia Hadsell, Maria-Florina 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.
|
| 214 |
+
|
| 215 |
+
Jian-Feng Cai, Emmanuel J Candes, and Zuowei Shen. A singular value thresholding algorithm for \` matrix completion. SIAM Journal on optimization, 20(4):1956–1982, 2010.
|
| 216 |
+
|
| 217 |
+
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 4171–4186, Minneapolis, Minnesota, 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-1423.
|
| 218 |
+
|
| 219 |
+
Demi Guo, Alexander M Rush, and Yoon Kim. Parameter-efficient transfer learning with diff pruning. arXiv preprint arXiv:2012.07463, 2020.
|
| 220 |
+
|
| 221 |
+
Junxian He, Chunting Zhou, Xuezhe Ma, Taylor Berg-Kirkpatrick, and Graham Neubig. Towards a unified view of parameter-efficient transfer learning. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id $\equiv$ 0RDcd5Axok.
|
| 222 |
+
|
| 223 |
+
Pengcheng He, Jianfeng Gao, and Weizhu Chen. Debertav3: Improving deberta using electra-style pre-training with gradient-disentangled embedding sharing. arXiv preprint arXiv:2111.09543, 2021a.
|
| 224 |
+
|
| 225 |
+
Pengcheng He, Xiaodong Liu, Jianfeng Gao, and Weizhu Chen. Deberta: Decoding-enhanced bert with disentangled attention. In International Conference on Learning Representations, 2021b.
|
| 226 |
+
|
| 227 |
+
Karl Moritz Hermann, Tomas Kocisky, Edward Grefenstette, Lasse Espeholt, Will Kay, Mustafa Suleyman, and Phil Blunsom. Teaching machines to read and comprehend. Advances in neural information processing systems, 28, 2015.
|
| 228 |
+
|
| 229 |
+
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, pp. 2790–2799. PMLR, 2019.
|
| 230 |
+
|
| 231 |
+
Edward J Hu, yelong shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. LoRA: Low-rank adaptation of large language models. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum? id $=$ nZeVKeeFYf9.
|
| 232 |
+
|
| 233 |
+
Vladimir Koltchinskii, Karim Lounici, and Alexandre B Tsybakov. Nuclear-norm penalization and optimal rates for noisy low-rank matrix completion. The Annals of Statistics, 39(5):2302–2329, 2011.
|
| 234 |
+
|
| 235 |
+
Brian Lester, Rami Al-Rfou, and Noah Constant. The power of scale for parameter-efficient prompt tuning. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pp. 3045–3059, Online and Punta Cana, Dominican Republic, November 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.emnlp-main.243. URL https: //aclanthology.org/2021.emnlp-main.243.
|
| 236 |
+
|
| 237 |
+
Mike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad, Abdelrahman Mohamed, Omer Levy, Ves Stoyanov, and Luke Zettlemoyer. Bart: Denoising sequence-to-sequence pre-training for natural language generation, translation, and comprehension. arXiv preprint arXiv:1910.13461, 2019.
|
| 238 |
+
|
| 239 |
+
Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. In Chengqing Zong, Fei Xia, Wenjie Li, and Roberto Navigli (eds.), Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing, ACL/IJCNLP 2021, (Volume 1: Long Papers), Virtual Event, August 1-6, 2021, pp. 4582–4597. Association for Computational Linguistics, 2021. doi: 10.18653/v1/2021.acl-long.353. URL https://doi.org/10.18653/v1/2021. acl-long.353.
|
| 240 |
+
|
| 241 |
+
Chen Liang, Simiao Zuo, Minshuo Chen, Haoming Jiang, Xiaodong Liu, Pengcheng He, Tuo Zhao, and Weizhu Chen. Super tickets in pre-trained language models: From model compression to improving generalization. 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), pp. 6524–6538, Online, 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-long.510.
|
| 242 |
+
|
| 243 |
+
Chin-Yew Lin. Rouge: A package for automatic evaluation of summaries. In Text summarization branches out, pp. 74–81, 2004.
|
| 244 |
+
|
| 245 |
+
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.
|
| 246 |
+
|
| 247 |
+
Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In 7th International Conference on Learning Representations, ICLR 2019, New Orleans, LA, USA, May 6-9, 2019. OpenReview.net, 2019.
|
| 248 |
+
|
| 249 |
+
Pavlo Molchanov, Arun Mallya, Stephen Tyree, Iuri Frosio, and Jan Kautz. Importance estimation for neural network pruning. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2019, Long Beach, CA, USA, June 16-20, 2019, pp. 11264–11272. Computer Vision Foundation / IEEE, 2019. doi: 10.1109/CVPR.2019.01152.
|
| 250 |
+
|
| 251 |
+
Shashi Narayan, Shay B Cohen, and Mirella Lapata. Don’t give me the details, just the summary! topic-aware convolutional neural networks for extreme summarization. arXiv preprint arXiv:1808.08745, 2018.
|
| 252 |
+
|
| 253 |
+
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 Hanna M. Wallach, Hugo Larochelle, Alina Beygelzimer, Florence d’Alche-´ Buc, Emily B. Fox, and Roman Garnett (eds.), Advances in Neural Information Processing Systems 32: Annual Conference on Neural Information Processing Systems 2019, NeurIPS 2019, December 8-14, 2019, Vancouver, BC, Canada, pp. 8024–8035, 2019.
|
| 254 |
+
|
| 255 |
+
Jonas Pfeiffer, Aishwarya Kamath, Andreas Ruckl ¨ e, Kyunghyun Cho, and Iryna Gurevych. Adapter- ´ fusion: Non-destructive task composition for transfer learning. arXiv preprint arXiv:2005.00247, 2020.
|
| 256 |
+
|
| 257 |
+
Xipeng Qiu, Tianxiang Sun, Yige Xu, Yunfan Shao, Ning Dai, and Xuanjing Huang. Pre-trained models for natural language processing: A survey. Science China Technological Sciences, 63(10): 1872–1897, 2020.
|
| 258 |
+
|
| 259 |
+
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.
|
| 260 |
+
|
| 261 |
+
Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, Peter J Liu, et al. Exploring the limits of transfer learning with a unified text-to-text transformer. J. Mach. Learn. Res., 21(140):1–67, 2020.
|
| 262 |
+
|
| 263 |
+
Pranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and Percy Liang. SQuAD: $^ { 1 0 0 , 0 0 0 + }$ questions for machine comprehension of text. In Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing, pp. 2383–2392, Austin, Texas, 2016. Association for Computational Linguistics. doi: 10.18653/v1/D16-1264.
|
| 264 |
+
|
| 265 |
+
Pranav Rajpurkar, Robin Jia, and Percy Liang. Know what you don’t know: Unanswerable questions for SQuAD. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 2: Short Papers), pp. 784–789, Melbourne, Australia, 2018. Association for Computational Linguistics. doi: 10.18653/v1/P18-2124.
|
| 266 |
+
|
| 267 |
+
Sylvestre-Alvise Rebuffi, Hakan Bilen, and Andrea Vedaldi. Learning multiple visual domains with residual adapters. Advances in neural information processing systems, 30, 2017.
|
| 268 |
+
|
| 269 |
+
Victor Sanh, Thomas Wolf, and Alexander M. Rush. Movement pruning: Adaptive sparsity by fine-tuning. 2020.
|
| 270 |
+
|
| 271 |
+
Kim-Chuan Toh and Sangwoon Yun. An accelerated proximal gradient algorithm for nuclear norm regularized linear least squares problems. Pacific Journal of optimization, 6(615-640):15, 2010.
|
| 272 |
+
|
| 273 |
+
Alex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R. Bowman. GLUE: A multi-task benchmark and analysis platform for natural language understanding. In 7th International Conference on Learning Representations, ICLR 2019, New Orleans, LA, USA, May 6-9, 2019. OpenReview.net, 2019.
|
| 274 |
+
|
| 275 |
+
Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Remi Louf, Morgan Funtowicz, et al. Huggingface’s transformers: ´ State-of-the-art natural language processing. ArXiv preprint, abs/1910.03771, 2019.
|
| 276 |
+
|
| 277 |
+
Greg Yang and Edward J Hu. Feature learning in infinite-width neural networks. arXiv preprint arXiv:2011.14522, 2020.
|
| 278 |
+
|
| 279 |
+
Elad Ben Zaken, Shauli Ravfogel, and Yoav Goldberg. Bitfit: Simple parameter-efficient fine-tuning for transformer-based masked language-models. arXiv preprint arXiv:2106.10199, 2021.
|
| 280 |
+
|
| 281 |
+
Qingru Zhang, Simiao Zuo, Chen Liang, Alexander Bukharin, Pengcheng He, Weizhu Chen, and Tuo Zhao. Platon: Pruning large transformer models with upper confidence bound of weight importance. In International Conference on Machine Learning, pp. 26809–26823. PMLR, 2022.
|
| 282 |
+
|
| 283 |
+
A THE DETAILED ALGORITHM
|
| 284 |
+
|
| 285 |
+
# Algorithm 1 AdaLoRA
|
| 286 |
+
|
| 287 |
+
1: Input: Dataset $\mathcal { D }$ ; total iterations $T$ ; budget schedule $\{ b ^ { ( t ) } \} _ { t = 0 } ^ { T }$ ; hyperparameters $\eta , \gamma , \beta _ { 1 } , \beta _ { 2 }$ .
|
| 288 |
+
2: for $t = 1 , \dots , T$ do
|
| 289 |
+
3: Sample a mini-batch from $\mathcal { D }$ and compute the gradient $\nabla \mathcal { L } ( \mathcal { P } , \mathcal { E } , \mathcal { Q } )$ ;
|
| 290 |
+
4: Compute the sensitivity $I ^ { ( t ) }$ in (8) for every parameter in $\{ \mathcal { P } , \mathcal { E } , \mathcal { Q } \}$ ;
|
| 291 |
+
5: Update $\overline { { I } } ^ { ( t ) }$ as (9) and $\overline { { U } } ^ { ( t ) }$ as (10) for every parameter in $\{ \mathcal { P } , \mathcal { E } , \mathcal { Q } \}$ ;
|
| 292 |
+
6: Compute $S _ { k , i } ^ { ( t ) }$ by (7), for $k = 1 , \dots , n$ and $i = 1 , \dots , r$ ;
|
| 293 |
+
7: Update P (t+1)k $P _ { k } ^ { ( t + 1 ) } = P _ { k } ^ { ( t ) } - \eta \nabla _ { P _ { k } } \mathcal { L } ( \mathcal { P } , \mathcal { E } , \mathcal { Q } )$ and $Q _ { k } ^ { ( t + 1 ) } = Q _ { k } ^ { ( t ) } - \eta \nabla _ { Q _ { k } } \mathcal { L } ( \mathcal { P } , \mathcal { E } , \mathcal { Q } ) ;$
|
| 294 |
+
8: Update $\Lambda _ { k } ^ { ( t + 1 ) } = \mathcal { T } ( \Lambda _ { k } ^ { ( t ) } - \eta \nabla _ { \Lambda _ { k } } \mathcal { L } ( \mathcal { P } , \mathcal { E } , \mathcal { Q } ) , S _ { k } ^ { ( t ) } )$ given the budget $b ^ { ( t ) }$ .
|
| 295 |
+
9: end for
|
| 296 |
+
10: Output:
|
| 297 |
+
|
| 298 |
+
# B GLOBAL BUDGET SCHEDULE
|
| 299 |
+
|
| 300 |
+
As mentioned in Section 3.3, we propose a global budget scheduler to gradually decrease the budget $b ^ { ( t ) }$ following a cubic schedule. The detailed equation is given as follows:
|
| 301 |
+
|
| 302 |
+
$$
|
| 303 |
+
\begin{array} { r } { b ^ { ( t ) } = \left\{ \begin{array} { l l } { b ^ { ( 0 ) } } & { 0 \leq t < t _ { i } } \\ { b ^ { ( T ) } + \left( b ^ { ( 0 ) } - b ^ { ( T ) } \right) \left( 1 - \frac { t - t _ { i } - t _ { f } } { T - t _ { i } - t _ { f } } \right) ^ { 3 } } & { t _ { i } \leq t < T - t _ { f } \ . } \\ { b ^ { ( T ) } } & { \mathrm { o . w . } } \end{array} \right. } \end{array}
|
| 304 |
+
$$
|
| 305 |
+
|
| 306 |
+
# C THE BUDGET DISTRIBUTION
|
| 307 |
+
|
| 308 |
+

|
| 309 |
+
Figure 3: The resulting rank of each incremental matrix when fine-tuning DeBERTaV3-base on MNLI with AdaLoRA. Here the $x$ -axis is the layer and the $y$ -axis represents different types of adapted weight matrices.
|
| 310 |
+
|
| 311 |
+
Figure 3 shows the resulting rank of each incremenal matrix when fine-tuning DeBERTaV3-base on MNLI with AdaLoRA. We can see that AdaLoRA allocates more parameter budget to weight matrices of 8, 9, 10, and 11 layers, especially for $W _ { f _ { 1 } }$ and $W _ { v }$ . Such behavior aligns with our conclusions presented in Figure 1.
|
| 312 |
+
|
| 313 |
+
# D GLUE DATASET STATISTICS
|
| 314 |
+
|
| 315 |
+
We present the dataset statistics of GLUE (Wang et al., 2019) in the following table.
|
| 316 |
+
|
| 317 |
+
Table 5: Summary of the GLUE benchmark.
|
| 318 |
+
|
| 319 |
+
<table><tr><td rowspan=1 colspan=1>Corpus</td><td rowspan=1 colspan=1>Task</td><td rowspan=1 colspan=2>#Train #Dev</td><td rowspan=1 colspan=2>#Test #Label</td><td rowspan=1 colspan=1>Metrics</td></tr><tr><td rowspan=1 colspan=7>Single-Sentence Classification (GLUE)</td></tr><tr><td rowspan=1 colspan=1>CoLA</td><td rowspan=1 colspan=1>Acceptability</td><td rowspan=1 colspan=1>8.5k</td><td rowspan=1 colspan=1>1k</td><td rowspan=1 colspan=1>1k</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>Matthews corr</td></tr><tr><td rowspan=1 colspan=1>SST</td><td rowspan=1 colspan=1>Sentiment</td><td rowspan=1 colspan=1>67k</td><td rowspan=1 colspan=1>872</td><td rowspan=1 colspan=1>1.8k</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>Accuracy</td></tr><tr><td rowspan=1 colspan=7>Pairwise Text Classification (GLUE)</td></tr><tr><td rowspan=1 colspan=1>MNLI</td><td rowspan=1 colspan=1>NLI</td><td rowspan=1 colspan=1>393k</td><td rowspan=1 colspan=1>20k</td><td rowspan=1 colspan=1>20k</td><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1>Accuracy</td></tr><tr><td rowspan=1 colspan=1>RTE</td><td rowspan=1 colspan=1>NLI</td><td rowspan=1 colspan=1>2.5k</td><td rowspan=1 colspan=1>276</td><td rowspan=1 colspan=1>3k</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>Accuracy</td></tr><tr><td rowspan=1 colspan=1>QQP</td><td rowspan=1 colspan=1>Paraphrase</td><td rowspan=1 colspan=1>364k</td><td rowspan=1 colspan=1>40k</td><td rowspan=1 colspan=1>391k</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>Accuracy/F1</td></tr><tr><td rowspan=1 colspan=1>MRPC</td><td rowspan=1 colspan=1>Paraphrase</td><td rowspan=1 colspan=1>3.7k</td><td rowspan=1 colspan=1>408</td><td rowspan=1 colspan=1>1.7k</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>Accuracy/F1</td></tr><tr><td rowspan=1 colspan=1>QNLI</td><td rowspan=1 colspan=1>QA/NLI</td><td rowspan=1 colspan=1>108k</td><td rowspan=1 colspan=1>5.7k</td><td rowspan=1 colspan=1>5.7k</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>Accuracy</td></tr><tr><td rowspan=1 colspan=7>Text Similarity(GLUE)</td></tr><tr><td rowspan=1 colspan=1>STS-B</td><td rowspan=1 colspan=1>Similarity</td><td rowspan=1 colspan=1>7k</td><td rowspan=1 colspan=1>1.5k</td><td rowspan=1 colspan=1>1.4k</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>Pearson/Spearman corr</td></tr></table>
|
| 320 |
+
|
| 321 |
+
E NATURAL LANGUAGE UNDERSTANDING
|
| 322 |
+
|
| 323 |
+
# E.1 BUDGET CONFIGURATION
|
| 324 |
+
|
| 325 |
+
For each budget level, we tune the final budget $b ^ { ( T ) }$ for AdaLoRA, the rank $r$ for LoRA, the hidden dimension $d$ for two adapters to match the budget requirements.
|
| 326 |
+
|
| 327 |
+
Table 6: Detailed budget setup for GLUE benchmark.
|
| 328 |
+
|
| 329 |
+
<table><tr><td>#Params</td><td>Houlsby Adapter (d)</td><td>Pfeiffer Adapter (d)</td><td>LoRA (r)</td><td>AdaLoRA (6(T))</td></tr><tr><td>1.2M</td><td>32</td><td>64</td><td>8</td><td>576</td></tr><tr><td>0.6M</td><td>16</td><td>32</td><td>4</td><td>288</td></tr><tr><td>0.3M</td><td>8</td><td>16</td><td>2</td><td>144</td></tr></table>
|
| 330 |
+
|
| 331 |
+
Alternatively, we can also set the final average rank $\bar { r } ^ { ( T ) } = b ^ { ( T ) } / n$ for AdaLoRA to control the budget, which is set as 2, 4, and 8 given the final budget as 144, 288, and 576 respectively. Then we select the initial rank $r$ from $\{ 4 , 6 , \bar { 1 2 } \}$ for the final average rank $\{ 2 , 4 , 8 \}$ respectively.
|
| 332 |
+
|
| 333 |
+
# E.2 TRAINING DETAILS
|
| 334 |
+
|
| 335 |
+
We tune the learning rate from $\{ 8 \times 1 0 ^ { - 5 } , 5 \times 1 0 ^ { - 5 } , 3 \times 1 0 ^ { - 5 } , 1 \times 1 0 ^ { - 4 } , 3 \times 1 0 ^ { - 4 } , 5 \times 1 0 ^ { - 4 } , 8 \times 1 0 ^ { - 5 } \}$ $1 0 ^ { - 4 } , 1 \times 1 0 ^ { - 3 } \}$ and pick the best learning rate for every method. For each dataset, the batch size is set as identical for every method.
|
| 336 |
+
|
| 337 |
+
Table 7: Hyper-parameter setup of AdaLoRA for GLUE benchmark.
|
| 338 |
+
|
| 339 |
+
<table><tr><td>Dataset</td><td>learning rate</td><td>batch size</td><td># epochs</td><td>2</td><td>ti</td><td>△T</td><td>tf</td></tr><tr><td>MNLI</td><td>5×10-4</td><td>32</td><td>7</td><td>0.1</td><td>8000</td><td>100</td><td>50000</td></tr><tr><td>RTE</td><td>1.2 ×10-3</td><td>32</td><td>50</td><td>0.3</td><td>600</td><td>1</td><td>1800</td></tr><tr><td>QNLI</td><td>1.2 ×10-3</td><td>32</td><td>5</td><td>0.1</td><td>2000</td><td>100</td><td>8000</td></tr><tr><td>MRPC</td><td>1×10-3</td><td>32</td><td>30</td><td>0.1</td><td>600</td><td>1</td><td>1800</td></tr><tr><td>QQP</td><td>5×10-4</td><td>32</td><td>5</td><td>0.1</td><td>8000</td><td>100</td><td>25000</td></tr><tr><td>SST-2</td><td>8×10-4</td><td>32</td><td>24</td><td>0.1</td><td>6000</td><td>100</td><td>22000</td></tr><tr><td>CoLA</td><td>5×10-4</td><td>32</td><td>25</td><td>0.5</td><td>800</td><td>10</td><td>3500</td></tr><tr><td>STS-B</td><td>2.2 ×10-3</td><td>32</td><td>25</td><td>0.1</td><td>800</td><td>10</td><td>2000</td></tr></table>
|
| 340 |
+
|
| 341 |
+
# F QUESTION ANSWERING
|
| 342 |
+
|
| 343 |
+
# F.1 BUDGET CONFIGURATION
|
| 344 |
+
|
| 345 |
+
Given the budget, we control the trainable parameters for each method as the following table.
|
| 346 |
+
|
| 347 |
+
Table 8: Detailed budget setup for question answering.
|
| 348 |
+
|
| 349 |
+
<table><tr><td># Params</td><td>Houlsby Adapter d</td><td>Pfeiffer Adapter d</td><td>LoRA r</td><td>AdaLoRA bT/()/r</td></tr><tr><td>0.65%</td><td>32</td><td>64</td><td>8</td><td>576/8/12</td></tr><tr><td>0.32%</td><td>16</td><td>32</td><td>4</td><td>288/4/6</td></tr><tr><td>0.16%</td><td>8</td><td>16</td><td>2</td><td>144/2/4</td></tr><tr><td>0.08%</td><td>4</td><td>8</td><td>1</td><td>72/1/2</td></tr></table>
|
| 350 |
+
|
| 351 |
+
# F.2 TRAINING DETAILS
|
| 352 |
+
|
| 353 |
+
We set the batch size as 16. We select the learning rate from $\{ 8 \times 1 0 ^ { - 5 } , 5 \times 1 0 ^ { - 5 } , 3 \times 1 0 ^ { - 5 } , 1 \times$ $1 0 ^ { - 4 } , 3 \times 1 0 ^ { - 4 } , 5 \times 1 0 ^ { - 4 } , 8 \times 1 0 ^ { - 4 } , 1 \times 1 0 ^ { - 3 } \}$ and pick the best-performing learning rate for every method. The configuration of AdaLoRA is listed in the following table.
|
| 354 |
+
|
| 355 |
+
Table 9: Hyper-parameter setup of AdaLoRA for question answering tasks.
|
| 356 |
+
|
| 357 |
+
<table><tr><td>Dataset</td><td>learning rate</td><td>batch size</td><td># epochs</td><td>2</td><td>ti</td><td>△T</td><td>tf</td></tr><tr><td> SQuADv1.1</td><td>1×10-3</td><td>16</td><td>10</td><td>0.1</td><td>5000</td><td>100</td><td>25000</td></tr><tr><td>SQuADv2.0</td><td>1×10-3</td><td>16</td><td>12</td><td>0.1</td><td>5000</td><td>100</td><td>50000</td></tr></table>
|
| 358 |
+
|
| 359 |
+
# F.3 DATASET
|
| 360 |
+
|
| 361 |
+
The statistics of question answering datasets are summarized in Table 10.
|
| 362 |
+
|
| 363 |
+
Table 10: Statistics of the SQuAD dataset.
|
| 364 |
+
|
| 365 |
+
<table><tr><td></td><td>#Train</td><td># Validation</td></tr><tr><td>SQuAD v1.1</td><td>87,599</td><td>10,570</td></tr><tr><td>SQuAD v2.0</td><td>130,319</td><td>11,873</td></tr></table>
|
| 366 |
+
|
| 367 |
+
# G NATURAL LANGUAGE GENERATION
|
| 368 |
+
|
| 369 |
+
# G.1 BUDGET CONFIGURATION
|
| 370 |
+
|
| 371 |
+
Given the budget, we control the trainable parameters for each method as the following table.
|
| 372 |
+
|
| 373 |
+
Table 11: Detailed budget setup for summarization tasks.
|
| 374 |
+
|
| 375 |
+
<table><tr><td># Params</td><td>Houlsby Adapter d</td><td>Pfeiffer Adapter d</td><td>LoRA r</td><td>AdaLoRA b(T)/()/r</td></tr><tr><td>0.65%</td><td>32</td><td>64</td><td>8</td><td>576/8/12</td></tr><tr><td>0.32%</td><td>16</td><td>32</td><td>4</td><td>288/4/6</td></tr><tr><td>0.16%</td><td>8</td><td>16</td><td>2</td><td>144/2/4</td></tr><tr><td>0.08%</td><td>4</td><td>8</td><td>1</td><td>72/1/2</td></tr></table>
|
| 376 |
+
|
| 377 |
+
# G.2 TRAINING DETAILS
|
| 378 |
+
|
| 379 |
+
We set the batch size as 16. We select the learning rate from $\{ 8 \times 1 0 ^ { - 5 } , 5 \times 1 0 ^ { - 5 } , 3 \times 1 0 ^ { - 5 } , 1 \times$ $1 0 ^ { - 4 } , 3 \times 1 0 ^ { - 4 } , 5 \times 1 0 ^ { - 4 } , 8 \times 1 0 ^ { - 4 } , 1 \times 1 0 ^ { - 3 } \}$ and pick the best-performing learning rate for every method. The configuration of AdaLoRA is listed in the following table.
|
| 380 |
+
|
| 381 |
+
Table 12: Hyper-parameter setup of AdaLoRA for summarization tasks.
|
| 382 |
+
|
| 383 |
+
<table><tr><td>Dataset</td><td> learning rate</td><td>batch size</td><td># epochs</td><td>Y</td><td>ti</td><td>△T</td><td>tf</td></tr><tr><td>XSum</td><td>5×10-4</td><td>64</td><td>25</td><td>0.1</td><td>6000</td><td>100</td><td>50000</td></tr><tr><td>CNN/DailyMail</td><td>5×10-4</td><td>32</td><td>15</td><td>0.1</td><td>5000</td><td>100</td><td>85000</td></tr></table>
|
| 384 |
+
|
| 385 |
+
# H ABLATION STUDY FOR LORA
|
| 386 |
+
|
| 387 |
+
As mentioned in Section 4, we find that the performance of LoRA can be further improved when applying it to every weight matrix, compared to fine-tuning $W _ { q }$ and $W _ { v }$ only (Hu et al., 2022). This observation aligns with the empirical results of He et al. (2022). In Table 13, we follow the same training configuration as Section 4.1 and present an ablation study to illustrate this point.
|
| 388 |
+
|
| 389 |
+
Table 13: We compare the fine-tuning performance when apply LoRA to every weight matrix or $W _ { q } , W _ { v }$ only. The parameter budget is fixed as $0 . 3 { \bf M }$ . We report accuracy for QQP and MRPC, accuracy $\mathrm { ( m ) }$ for MNLI, and average correlation for STS-B.
|
| 390 |
+
|
| 391 |
+
<table><tr><td></td><td>MNLI</td><td>QQP</td><td>CoLA</td><td>RTE</td><td>QNLI</td><td>SST-2</td><td>MRPC</td><td>STS-B</td></tr><tr><td>LoRA (Wq,Wk)</td><td>89.80</td><td>90.48</td><td>67.04</td><td>83.75</td><td>93.69</td><td>94.84</td><td>90.20</td><td>91.05</td></tr><tr><td>LoRA (all)</td><td>90.30</td><td>91.61</td><td>68.71</td><td>85.56</td><td>94.31</td><td>94.95</td><td>90.44</td><td>91.68</td></tr></table>
|
| 392 |
+
|
| 393 |
+
# I ORTHOGONAL REGULARIZATION
|
| 394 |
+
|
| 395 |
+

|
| 396 |
+
Figure 4: We plot the $\| P ^ { \top } P - I \| _ { \mathsf { F } } ^ { 2 }$ and $\| Q Q ^ { \top } - I \| _ { \mathsf F } ^ { 2 }$ when fine-tuning DeBERTaV3-base on SST-2.
|
| 397 |
+
|
| 398 |
+
To verify the effectiveness of (4), we plot $\| P ^ { \top } P - I \| _ { \mathsf { F } } ^ { 2 }$ and $\| Q Q ^ { \top } - I \| _ { \mathsf F } ^ { 2 }$ to show whether $P$ and $Q$ are regularized to be orthogonal. We fine-tune a DeBERTaV3-base model on SST-2 with AdaLoRA and follow the same training configuration as Section 4.1. We set $\gamma$ as 0.1 and plot the two terms along the training horizon. From Figure 4, we can see that two regularization terms can be optimized to a very small value (e.g., 0.001) at the beginning of training. Therefore, both $P$ and $Q$ can be enforced to be orthogonal quickly during the initial warm-up of AdaLoRA. It ensures that the triplets are not dependent with each other.
|
| 399 |
+
|
| 400 |
+
# J THE ROLE OF TWO COMPONENTS
|
| 401 |
+
|
| 402 |
+
We remark that both two components of our method - SVD adaptation and adaptive budget allocation, play vital roles for the performance gain. To demonstrate it, we compare AdaLoRA with the following variants: (i) SVD-LoRA: fine-tuning only with the proposed SVD-based adaptation in (3) and (4); (ii) $\mathrm { L o R A } _ { \mathrm { r e g u } }$ : LoRA with orthogonal regularization (4) on $A$ and $B$ ; (iii) $\mathbf { A d a L o R A } _ { \gamma } = 0$ : AdaLoRA without orthogonal regularization (4). Table 14 present the results when fine-tuning DeBERTaVe-base on SST-2 and MNLI. We can see that fine-tuning only with SVD adaptation shows an improvement over LoRA but cannot match the performance of AdaLoRA. Meanwhile, without SVD orthogonal regularization, the performance of AdaLoRA can degenerate. These results validate that both components contribute to the model performance.
|
| 403 |
+
|
| 404 |
+
Table 14: We present ablation studies about SVD-based adaptation, orthogonal regularization, and budget allocation in this table. For MNLI, we report the average score of ${ \mathrm { m / m m ~ a c c } }$ .
|
| 405 |
+
|
| 406 |
+
<table><tr><td></td><td colspan="4">SST-2</td><td colspan="4">MNLI</td></tr><tr><td># Params</td><td>0.08%</td><td>0.16%</td><td>0.32%</td><td>0.65%</td><td>0.08%</td><td>0.16%</td><td>0.32%</td><td>0.65%</td></tr><tr><td>LoRA</td><td>94.38</td><td>94.95</td><td>1</td><td>94.95</td><td>90.19</td><td>90.34</td><td>1</td><td>90.57</td></tr><tr><td>LoRAregu</td><td>1</td><td>94.61</td><td>94.72</td><td>94.61</td><td>1</td><td>90.30</td><td>90.40</td><td>90.66</td></tr><tr><td>SVD-LoRA</td><td>95.33</td><td>95.18</td><td>95.07</td><td>95.53</td><td>90.28</td><td>90.25</td><td>90.52</td><td>90.62</td></tr><tr><td>AdaLoRAq = 0</td><td>95.41</td><td>95.10</td><td>95.30</td><td>95.10</td><td>90.37</td><td>90.34</td><td>90.56</td><td>90.43</td></tr><tr><td>AdaLoRA</td><td>95.64</td><td>95.80</td><td>96.10</td><td>96.10</td><td>90.65</td><td>90.68</td><td>90.66</td><td>90.77</td></tr></table>
|
| 407 |
+
|
| 408 |
+
# K COMPARISON OF TRAINING COST
|
| 409 |
+
|
| 410 |
+
We compare the training cost between AdaLoRA and LoRA in the following table. We use two methods to fine-tune DeBERTaV3-base on a single NVIDIA V100 GPU. We do training only and set hyperparameters, e.g., batch size and training epochs, the same as in Section 4.
|
| 411 |
+
|
| 412 |
+
Table 15: Comparison of practical training cost between AdaLoRA and LoRA.
|
| 413 |
+
|
| 414 |
+
<table><tr><td>Dataset</td><td># Param</td><td>Method</td><td>GPU Mem</td><td>Time/epoch</td></tr><tr><td rowspan="5">MNLI</td><td>0.08%</td><td>LoRA</td><td>11.094 GB</td><td>105 min</td></tr><tr><td></td><td>AdaLoRA</td><td>11.104 GB</td><td>116 min</td></tr><tr><td>0.16%</td><td>LoRA</td><td>11.098 GB</td><td>105 min</td></tr><tr><td></td><td>AdaLoRA</td><td>11.110 GB</td><td>117 min</td></tr><tr><td>0.65%</td><td>LoRA AdaLoRA</td><td>11.128 GB 11.188 GB</td><td>105 min</td></tr><tr><td rowspan="5">SST-2</td><td>0.08%</td><td>LoRA</td><td>13.138 3GB</td><td>117 min 60 min</td></tr><tr><td></td><td>AdaLoRA</td><td>13.148 GB</td><td>71 min</td></tr><tr><td>0.16%</td><td>LoRA</td><td>13.142 2GB</td><td>61 min</td></tr><tr><td></td><td>AdaLoRA</td><td>13.164 GB</td><td>71 min</td></tr><tr><td></td><td>LoRA</td><td>13.170 GB</td><td>61 min</td></tr><tr><td rowspan="4"></td><td>0.65 %</td><td></td><td></td><td></td></tr><tr><td></td><td>AdaLoRA</td><td>13.226 GB</td><td>71 min</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td></tr></table>
|
| 415 |
+
|
| 416 |
+
Table 15 shows that MARVEL incurs $11 \%$ additional training time on MNLI and $16 \%$ on SQuADv2 under different budgets. The memory footprint of two methods are quite close. Such results demonstrate that MARVEL does not incur significant training overheads. The reason behind is that we only evaluate the importance score for small incremental matrices $P \Lambda Q$ . Their total number of parameters is usually less than $1 \%$ of pre-trained weights. Therefore, it does not lead to significant computational cost to update the importance scores of these well-structured small matrices, compared to forward-backward pass of full model.
|
md/dev/oMI9PjOb9Jl/oMI9PjOb9Jl.md
ADDED
|
@@ -0,0 +1,360 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# DAB-DETR: DYNAMIC ANCHOR BOXES ARE BETTER QUERIES FOR DETR
|
| 2 |
+
|
| 3 |
+
Shilong $\mathbf { L i u ^ { 1 , 2 * } }$ ∗, Feng $\mathbf { L i ^ { 2 , 3 } }$ , Hao Zhang2,3, Xiao Yang1,
|
| 4 |
+
Xianbiao $\mathbf { Q } \mathbf { i } ^ { 2 }$ , Hang $\mathbf { S u } ^ { 1 , 4 }$ , Jun $\mathbf { Z } \mathbf { h } \mathbf { u } ^ { 1 , 4 \dagger }$ , Lei Zhang2†
|
| 5 |
+
1Dept. of Comp. Sci. and Tech., BNRist Center, State Key Lab for Intell. Tech. & Sys., Institute for AI, Tsinghua-Bosch Joint Center for ML, Tsinghua University. 2International Digital Economy Academy (IDEA).
|
| 6 |
+
3Hong Kong University of Science and Technology.
|
| 7 |
+
4Peng Cheng Laboratory, Shenzhen, Guangdong, China.
|
| 8 |
+
{liusl20,yangxiao19}@mails.tsinghua.edu.cn
|
| 9 |
+
{fliay,hzhangcx}@connect.ust.hk
|
| 10 |
+
{qixianbiao,leizhang}@idea.edu.cn
|
| 11 |
+
{suhangss,dcszj}@mail.tsinghua.edu.cn
|
| 12 |
+
|
| 13 |
+
# ABSTRACT
|
| 14 |
+
|
| 15 |
+
We present in this paper a novel query formulation using dynamic anchor boxes for DETR (DEtection TRansformer) and offer a deeper understanding of the role of queries in DETR. This new formulation directly uses box coordinates as queries in Transformer decoders and dynamically updates them layer by layer. Using box coordinates not only helps using explicit positional priors to improve the queryto-feature similarity and eliminate the slow training convergence issue in DETR, but also allows us to modulate the positional attention map using the box width and height information. Such a design makes it clear that queries in DETR can be implemented as performing soft ROI pooling layer by layer in a cascade manner. As a result, it leads to the best performance on MS-COCO benchmark among the DETR-like detection models under the same setting, e.g., AP $4 5 . 7 \%$ using ResNet50-DC5 as backbone trained in 50 epochs. We also conducted extensive experiments to confirm our analysis and verify the effectiveness of our methods. Code is available at https://github.com/IDEA-opensource/ DAB-DETR.
|
| 16 |
+
|
| 17 |
+
# 1 INTRODUCTION
|
| 18 |
+
|
| 19 |
+
Object detection is a fundamental task in computer vision of wide applications. Most classical detectors are based on convolutional architectures which have made remarkable progress in the last decade (Ren et al., 2017; Girshick, 2015; Redmon et al., 2016; Bochkovskiy et al., 2020; Ge et al., 2021). Recently, Carion et al. (2020) proposed a Transformer-based end-to-end detector named DETR (DEtection TRansformer), which eliminates the need for hand-designed components, e.g., anchors, and shows promising performance compared with modern anchor-based detectors such as Faster RCNN (Ren et al., 2017).
|
| 20 |
+
|
| 21 |
+
In contrast to anchor-based detectors, DETR models object detection as a set prediction problem and uses 100 learnable queries to probe and pool features from images, which makes predictions without the need of using non-maximum suppression. However, due to its ineffective design and use of queries, DETR suffers from significantly slow training convergence, usually requiring 500 epochs to achieve a good performance. To address this issue, many follow-up works attempted to improve the design of DETR queries for both faster training convergence and better performance (Zhu et al., 2021; Gao et al., 2021; Meng et al., 2021; Wang et al., 2021).
|
| 22 |
+
|
| 23 |
+

|
| 24 |
+
Figure 1: Comparison of DETR, Conditional DETR, and our proposed DAB-DETR. For clarity, we only show the cross-attention part in the Transformer decoder. (a) DETR uses the learnable queries for all the layers without any adaptation, which accounts for its slow training convergence. (b) Conditional DETR adapts the learnable queries for each layer mainly to provide a better reference query point to pool features from the image feature map. In contrast, (c) DAB-DETR directly uses dynamically updated anchor boxes to provide both a reference query point $( x , y )$ and a reference anchor size $( w , h )$ to improve the cross-attention computation. We marked the modules with difference in purple.
|
| 25 |
+
|
| 26 |
+
Despite all the progress, the role of the learned queries in DETR is still not fully understood or utilized. While most previous attempts make each query in DETR more explicitly associated with one specific spatial position rather than multiple positions , the technical solutions are largely different. For example, Conditional DETR learns a conditional spatial query by adapting a query based on its content feature for better matching with image features (Meng et al., 2021). Efficient DETR introduces a dense prediction module to select top-K object queries (Yao et al., 2021) and Anchor DETR formulates queries as 2D anchor points (Wang et al., 2021), both associating each query with a specific spatial position. Similarly, Deformable DETR directly treats 2D reference points as queries and performs deformable cross-attention operation at each reference points (Zhu et al., 2021). But all the above works only leverage 2D positions as anchor points without considering the object scales.
|
| 27 |
+
|
| 28 |
+
Motivated by these studies, we take a closer look at the cross-attention module in Transformer decoder and propose to use anchor boxes, i.e., 4D box coordinates $( x , y , w , h )$ , as queries in DETR and update them layer by layer. This new query formulation introduce better spatial priors for the cross-attention module by considering both the position and size of each anchor box, which also leads to a much simpler implementation and a deeper understanding of the role of queries in DETR.
|
| 29 |
+
|
| 30 |
+
The key insight behind this formulation is that each query in DETR is formed by two parts: a content part (decoder self-attention output) and a positional part (e.g., learnable queries in DETR) 1. The cross-attention weights are computed by comparing a query with a set of keys which consists of two parts as a content part (encoded image feature) and a positional part (positional embedding). Thus, queries in Transformer decoder can be interpreted as pooling features from a feature map based on the query-to-feature similarity measure, which considers both the content and positional information. While the content similarity is for pooling semantically related features, the positional similarity is to provide a positional constraint for pooling features around the query position. This attention computing mechanism motivates us to formulate queries as anchor boxes as illustrated in Fig. 1 (c), allowing us to use the center position $( x , y )$ of an anchor box to pool features around the center and use the anchor box size $( w , h )$ to modulate the cross-attention map, adapting it to anchor box size. In addition, because of the use of coordinates as queries, anchor boxes can be updated layer by layer dynamically. In this way, queries in DETR can be implemented as performing soft ROI pooling layer by layer in a cascade way.
|
| 31 |
+
|
| 32 |
+
We provide a better positional prior for pooling features by using anchor box size to modulate the cross-attention. Because the cross-attention can pool features from the whole feature map, it is crucial to provide a proper positional prior for each query to let the cross-attention module focus on a local region corresponding to a target object. It can also facilitate to speed up the training convergence of DETR. Most prior works improve DETR by associating each query with a specific location, but they assume an isotropic Gaussian positional prior of a fixed size(Fig. 4 (b)), which is inappropriate for objects of different scales. With the size information $( w , h )$ available in each query anchor box, we can modulate the Gaussian positional prior as an oval shape. More specifically, we divide the width and height from the cross-attention weight (before softmax) for its $x$ part and $y$ part separately, which helps the Gaussian prior to better match with objects of different scales(Fig. 4 (c)). To further improve the positional prior, we also introduce a temperature parameter to tune the flatness of positional attention, which has been overlooked in all prior works.
|
| 33 |
+
|
| 34 |
+
In summary, our proposed DAB-DETR (Dynamic Anchor Box DETR) presents a novel query formulation by directly learning anchors as queries. This formulation offers a deeper understanding of the role of queries, allowing us to use anchor size to modulate the positional cross-attention map in Transformer decoders and perform dynamic anchor update layer by layer. Our results demonstrate that DAB-DETR attains the best performance among DETR-like architectures under the same setting on the COCO object detection benchmark. The proposed method can achieve $4 5 . 7 \%$ AP when using a single ResNet-50 (He et al., 2016) model as backbone for training 50 epochs. We also conducted extensive experiments to confirm our analysis and verify the effectiveness of our methods.
|
| 35 |
+
|
| 36 |
+
# 2 RELATED WORK
|
| 37 |
+
|
| 38 |
+
Most classical detectors are anchor-based, using either anchor boxes (Ren et al., 2017; Girshick, 2015; Sun et al., 2021) or anchor points (Tian et al., 2019; Zhou et al., 2019). In contrast, DETR (Carion et al., 2020) is a fully anchor-free detector using a set of learnable vectors as queries. Many follow-up works attempted to solve the slow convergence of DETR from different perspectives. Sun et al. (2020) pointed out that the cause of slow training of DETR is due to the crossattention in decoders and hence proposed an encoder-only model. Gao et al. (2021) instead introduced a Gaussian prior to regulate the cross-attention. Despite their improved performance, they did not give a proper explanation of the slow training and the roles of queries in DETR.
|
| 39 |
+
|
| 40 |
+
Another direction to improve DETR, which is more relevant to our work, is towards a deeper understanding of the role of queries in DETR. As the learnable queries in DETR are used to provide positional constraints for feature pooling, most related works attempted to make each query in DETR more explicitly related to a specific spatial position rather than multiple position modes in the vanilla DETR. For example, Deformable DETR (Zhu et al., 2021) directly treats 2D reference points as queries and predicts deformable sampling points for each reference point to perform the deformable cross-attention operation. Conditional DETR (Meng et al., 2021) decouples the attention formulation and generates positional queries based on reference coordinates. Efficient DETR (Yao et al., 2021) introduces a dense prediction module to select top-K positions as object queries. Although these works connect queries with positional information, they do not have an explicit formulation to use anchors.
|
| 41 |
+
|
| 42 |
+
Different from the hypothesis in prior works that the learnable query vectors contain box coordinate information, our approach is based on a new perspective that all information contained in queries are box coordinates. That is, anchor boxes are better queries for DETR. A concurrent work Anchor DETR (Wang et al., 2021) also suggests learning anchor points directly, while it ignores the anchor width and height information as in other prior works. Besides DETR, Sun et al. (2021) proposed a sparse detector by learning boxes directly, which shares a similar anchor formulation with us, but it discards the Transformer structure and leverages hard ROI align for feature extraction. Table 1 summarizes the key differences between related works and our proposed DAB-DETR. We compare our model with related works on five dimensions: if the model directly learns anchors, if the model predicts reference coordinates (in its intermediate stage), if the model updates the reference anchors layer by layer, if the model uses the standard dense cross-attention, if the attention is modulated to better match with objects of different scales, and if the model updates the learned queries layer by layer. A more detailed comparison of DETR-like models is available in Sec. B of Appendix. We recommend this section for readers who have confusions about the table.
|
| 43 |
+
|
| 44 |
+
<table><tr><td>Models</td><td>Learn Anchors?</td><td>Reference Anchors</td><td>Dynamic Anchors</td><td>Standard Attention</td><td>Size-Modulated Attention</td><td>Update Learned Spatial Queries?</td></tr><tr><td>DETR</td><td>No</td><td>No</td><td></td><td>√</td><td></td><td></td></tr><tr><td>Deformable DETR</td><td>No</td><td>4D</td><td>√</td><td></td><td>√</td><td></td></tr><tr><td>SMCA</td><td>No</td><td>4D</td><td></td><td>√</td><td>√</td><td></td></tr><tr><td>Conditional DETR</td><td>No</td><td>2D</td><td></td><td>√</td><td></td><td></td></tr><tr><td>Anchor DETR</td><td>2D</td><td>2D</td><td>√</td><td></td><td></td><td></td></tr><tr><td>Sparse RCNN</td><td>4D</td><td>4D</td><td>√</td><td></td><td></td><td></td></tr><tr><td>DAB-DETR</td><td>4D</td><td>4D</td><td>√</td><td>√</td><td></td><td></td></tr></table>
|
| 45 |
+
|
| 46 |
+
Table 1: Comparison of representative related models and our DAB-DETR. The term “Learn Anchors?” asks if the model learns 2D points or 4D anchors as learnable parameters directly. The term ”Reference Anchors” means if the model predicts relative coordinates with respect to a reference points/anchors. The term “Dynamic Anchors” indicates if the model updates its anchors layer-by-layer. The term “Standard Attention” shows whether the model leverages the standard dense attention in cross-attention modules. The term “Object Scale-Modulated Attention” means if the attention is modulated to better match with object scales. The term “Size-Modulated Attention” means if the attention is modulated to better match with object scales. The term “Update Spatial Learned Queries?” means if the learned queries are updated layer by layer. Note that Sparse RCNN is not a DETR-like architecture. we list it here for their similar anchor formulation with us. See Sec. B of Appendix for a more detailed comparison of these models.
|
| 47 |
+
|
| 48 |
+
# 3 WHY A POSITIONAL PRIOR COULD SPEEDUP TRAINING?
|
| 49 |
+
|
| 50 |
+

|
| 51 |
+
Figure 2: Comparison of self-attention in encoders and cross-attention in decoders of DETR. As they have the same key and value components, the only difference comes from the queries. Each query in an encoder is composed of an image feature (content information) and a positional embedding (positional information), whereas each query in a decoder is composed of a decoder embedding (content information) and a learnable query (postional information). The differences between two modules are marked in purple.
|
| 52 |
+
|
| 53 |
+
Much work has been done to accelerate the training convergence speed of DETR, while lacking a unified understanding of why their methods work. Sun et al. (2020) showed that the cross-attention module is mainly responsible for the slow convergence, but they simply removed the decoders for faster training. We follow their analysis to find which sub-module in the cross-attention affects the performance. Comparing the self-attention module in encoders with the cross-attention module in decoders, we find the key difference between their inputs comes from the queries, as shown in Fig. 2. As the decoder embeddings are initialized as 0, they are projected to the same space as the image features after the first cross-attention module. After that, they will go through a similar process in decoder layers as the image features in encoder layers. Hence the root cause is likely due to the learnable queries.
|
| 54 |
+
|
| 55 |
+
Two possible reasons in cross-attention account for the model’s slow training convergence: 1) it is hard to learn the queries due to the optimization challenge, and 2) the positional information in the learned queries is not encoded in the same way as the sinusoidal positional encoding used for image features. To see if it is the first reason, we reuse the well-learned queries from DETR (keep them fixed) and only train the other modules. The training curves in Fig. 3(a) show that the fixed queries only slightly improve the convergence in very early epochs, e.g., the first 25 epochs. Hence the query learning (or optimization) is likely not the key concern.
|
| 56 |
+
|
| 57 |
+
Then we turn to the second possibility and try to find out if the learned queries have some undesirable properties. As the learned queries are used to filter objects in certain regions, we visualize a few positional attention maps between the learned queries and the positional embeddings of image features in Fig. 4(a). Each query can be regarded as a positional prior to let decoders focus on a region of interest. Although they serve as a positional constraint, they also carry undesirable properties: multiple modes and nearly uniform attention weights. For example, the two attention maps at the top of Fig. 4(a) have two or more concentration centers, making it hard to locate objects when multiple objects exist in an image. The bottom maps of Fig. 4(a) focus on areas that are either too large or too small, and hence cannot inject useful positional information into the procedure of feature extraction. We conjecture that the multiple mode property of queries in DETR is likely the root cause for its slow training and we believe introducing explicit positional priors to constrain queries on a local region is desirable for training. To verify this assumption, we replace the query formulation in DETR with dynamic anchor boxes, which can enforce each query to focus on a specific area, and name this model DETR $+$ DAB. The training curves in Fig. 3(b) show that DETR $+$ DAB leads to much better performance compared with DETR, in terms of both detection AP and training/testing loss. Note that the only difference between DETR and DETR $^ +$ DAB is the formulation of queries and no other techniques like 300 queries or focal loss are introduced. It shows that after addressing the multi-mode issue of DETR queries, we can achieve both a faster training convergence and a higher detection accuracy.
|
| 58 |
+
|
| 59 |
+

|
| 60 |
+
Figure 3: a): Training curves of the original DETR and DETR with fixed queries. b): Training curves of the original DETR and DETR $^ +$ DAB. We run each experiment 3 times and plot the mean value and the $9 5 \%$ confidence interval of each item.
|
| 61 |
+
|
| 62 |
+

|
| 63 |
+
Figure 4: We visualize the positional attention between positional queries and positional keys for DETR, Conditional DETR, and our proposed DAB-DETR. Four attention maps in (a) are randomly sampled, and we select figures with similar query positions as in (a) for (b) and (c). The darker the color, the greater the attention weight, and vice versa. (a) Each attention map in DETR is calculated by performing dot product between a learned query and positional embeddings from a feature map, and can have multiple modes and unconcentrated attentions. (b) The positional queries in Conditional DETR are encoded in the same way as the image positional embeddings, resulting in Gaussian-like attention maps. However, it cannot adapt to objects of different scales. (c) DABDETR explicitly modulates the attention map using the width and height information of an anchor, making it more adaptive to object size and shape. The modulated attentions can be regarded as helping perform soft ROI pooling.
|
| 64 |
+
|
| 65 |
+
Some previous works also have similar analyses and confirmed this. For example, SMCA (Gao et al., 2021) speeds up the training by applying pre-defined Gaussian maps around reference points. Conditional DETR (Meng et al., 2021) uses explicit positional embedding as positional queries for training, yielding attention maps similar to Gaussian kernels as shown in Fig. 4(b). Although explicit positional priors lead to good performance in training, they ignore the scale information of an object. In contrast, our proposed DAB-DETR explicitly takes into account the object scale information to adaptively adjust attention weights, as shown in Fig. 4(c).
|
| 66 |
+
|
| 67 |
+
# 4 DAB-DETR
|
| 68 |
+
|
| 69 |
+

|
| 70 |
+
Figure 5: Framework of our proposed DAB-DETR.
|
| 71 |
+
|
| 72 |
+
# 4.1 OVERVIEW
|
| 73 |
+
|
| 74 |
+
Following DETR (Carion et al., 2020), our model is an end-to-end object detector which includes a CNN backbone, Transformer (Vaswani et al., 2017) encoders and decoders, and prediction heads for boxes and labels. We mainly improve the decoder part, as shown in Fig. 5.
|
| 75 |
+
|
| 76 |
+
Given an image, we extract image spatial features using a CNN backbone followed with Transformer encoders to refine the CNN features. Then dual queries, including positional queries (anchor boxes) and content queries (decoder embeddings), are fed into the decoder to probe the objects which correspond to the anchors and have similar patterns with the content queries. The dual queries are updated layer by layer to get close to the target ground-truth objects gradually. The outputs of the final decoder layer are used to predict the objects with labels and boxes by prediction heads, and then a bipartite graph matching is conducted to calculate loss as in DETR.
|
| 77 |
+
|
| 78 |
+
To illustrate the generality of our dynamic anchor boxes, we also design a stronger DABDeformable-DETR, which is available in Appendix.
|
| 79 |
+
|
| 80 |
+
# 4.2 LEARNING ANCHOR BOXES DIRECTLY
|
| 81 |
+
|
| 82 |
+
As discussed in Sec. 1 regarding the role of queries in DETR, we propose to directly learn query boxes or say anchor boxes and derive positional queries from these anchors. There are two attention modules in each decoder layer, including a self-attention module and a cross-attention module, which are used for query updating and feature probing, respectively. Each module needs queries, keys, and values to perform attention-based value aggregation, yet the inputs of these triplets differ.
|
| 83 |
+
|
| 84 |
+
We denote $A _ { q } = ( x _ { q } , y _ { q } , w _ { q } , h _ { q } )$ as the $q$ -th anchor, $x _ { q } , y _ { q } , w _ { q } , h _ { q } \in \mathbb { R }$ , and $C _ { q } \in \mathbb { R } ^ { D }$ and $P _ { q } \in$ $\mathbb { R } ^ { D }$ as its corresponding content query and positional query, where $D$ is the dimension of decoder embeddings and positional queries.
|
| 85 |
+
|
| 86 |
+
Given an anchor $A _ { q }$ , its positional query $P _ { q }$ is generated by:
|
| 87 |
+
|
| 88 |
+
$$
|
| 89 |
+
P _ { q } = \mathbf { M L P } ( \mathbf { P E } ( A _ { q } ) ) ,
|
| 90 |
+
$$
|
| 91 |
+
|
| 92 |
+
where PE means positional encoding to generate sinusoidal embeddings from float numbers and the parameters of MLP are shared across all layers. As $A _ { q }$ is a quaternion, we overload the PE operator here:
|
| 93 |
+
|
| 94 |
+
$$
|
| 95 |
+
\mathrm { P E } ( A _ { q } ) = \mathrm { P E } ( x _ { q } , y _ { q } , w _ { q } , h _ { q } ) = \mathrm { C a t } ( \mathrm { P E } ( x _ { q } ) , \mathrm { P E } ( y _ { q } ) , \mathrm { P E } ( w _ { q } ) , \mathrm { P E } ( h _ { q } ) ) .
|
| 96 |
+
$$
|
| 97 |
+
|
| 98 |
+
The notion Cat means concatenation function. In our implementations, the positional encoding function PE maps a float to a vector with $D / 2$ dimensions as: PE: $\mathbb { R } \mathbb { R } ^ { D / 2 }$ . Hence the function MLP projects a $2 D$ dimensional vector into $D$ dimensions: MLP: $\mathbb { R } ^ { 2 D } \to \mathbb { R } ^ { D }$ . The MLP module has two submodules, each of which is composed of a linear layer and a ReLU activation, and the feature reduction is conducted at the first linear layer.
|
| 99 |
+
|
| 100 |
+
In the self-attention module, all three of queries, keys, and values have the same content items, while the queries and keys contain extra position items:
|
| 101 |
+
|
| 102 |
+
$$
|
| 103 |
+
\mathrm { S e l f - A t t n : } \quad Q _ { q } = C _ { q } + P _ { q } , \quad K _ { q } = C _ { q } + P _ { q } , \quad V _ { q } = C _ { q } ,
|
| 104 |
+
$$
|
| 105 |
+
|
| 106 |
+
Inspired by Conditional DETR (Meng et al., 2021), we concatenate the position and content information together as queries and keys in the cross-attention module, so that we can decouple the content and position contributions to the query-to-feature similarity computed as the dot product between a query and a key. To rescale the positional embeddings, we leverage the conditional spatial query (Meng et al., 2021) as well. More specifically, we learn a $\mathbf { M L P } ^ { ( \mathrm { c s q } ) } : \mathbb { R } ^ { D } \mathbb { R } ^ { D }$ to obtain a scale vector conditional on the content information and use it perform element-wise multiplication with the positional embeddings:
|
| 107 |
+
|
| 108 |
+
$$
|
| 109 |
+
\begin{array} { r l } { \mathrm { C r o s s \mathrm { - } A t t n : } \quad } & { Q _ { q } = \mathrm { C a t } ( C _ { q } , \mathrm { P E } ( x _ { q } , y _ { q } ) \cdot \mathrm { M L P } ^ { ( \mathrm { c s q } ) } ( C _ { q } ) ) , } \\ & { K _ { x , y } = \mathrm { C a t } ( F _ { x , y } , \mathrm { P E } ( x , y ) ) , \quad V _ { x , y } = F _ { x , y } , } \end{array}
|
| 110 |
+
$$
|
| 111 |
+
|
| 112 |
+
where $F _ { x , y } \in \mathbb { R } ^ { D }$ is the image feature at position $( x , y )$ and $\cdot$ is an element-wise multiplication. Both the positional embeddings in queries and keys are generated based on 2D coordinates, making it more consistent to compare the positional similarity, as in previous works (Meng et al., 2021; Wang et al., 2021).
|
| 113 |
+
|
| 114 |
+
# 4.3 ANCHOR UPDATE
|
| 115 |
+
|
| 116 |
+
Using coordinates as queries for learning makes it possible to update them layer by layer. In contrast, for queries of high dimensional embeddings, such as in DETR (Carion et al., 2020) and Conditional DETR (Meng et al., 2021), it is hard to perform layer-by-layer query refinement, because it is unclear how to convert an updated anchor back to a high-dimensional query embedding.
|
| 117 |
+
|
| 118 |
+
Following the previous practice (Zhu et al., 2021; Wang et al., 2021), we update anchors in each layer after predicting relative positions $( \Delta x , \Delta y , \Delta w , \Delta h )$ by a prediction head, as shown in Fig. 5. Note that all prediction heads in different layers share the same parameters.
|
| 119 |
+
|
| 120 |
+
# 4.4 WIDTH & HEIGHT-MODULATED GAUSSIAN KERNEL
|
| 121 |
+
|
| 122 |
+

|
| 123 |
+
Figure 6: Positional attention maps modulated by width and height.
|
| 124 |
+
|
| 125 |
+

|
| 126 |
+
Figure 7: Positional attention maps with different temperatures.
|
| 127 |
+
|
| 128 |
+
Traditional positional attention maps are used as a Gaussian-like prior, as shown in Fig. 6 left. But the prior is simply assumed isotropic and fixed size for all objects, leaving their scale information (width and height) ignored. To improve the positional prior, we propose to inject the scale information into the attention maps.
|
| 129 |
+
|
| 130 |
+
The query-to-key similarity in the original positional attention map is computed as the sum of dot products of two coordinate encodings:
|
| 131 |
+
|
| 132 |
+
$$
|
| 133 |
+
{ \mathrm { A t t n } } ( ( x , y ) , ( x _ { \mathrm { r e f } } , y _ { \mathrm { r e f } } ) ) = ( { \mathrm { P E } } ( x ) \cdot { \mathrm { P E } } ( x _ { \mathrm { r e f } } ) + { \mathrm { P E } } ( y ) \cdot { \mathrm { P E } } ( y _ { \mathrm { r e f } } ) ) / { \sqrt { D } } ,
|
| 134 |
+
$$
|
| 135 |
+
|
| 136 |
+
where $1 / \sqrt { D }$ is used to rescale the value as suggested in Vaswani et al. (2017). We modulate the positional attention maps (before softmax) by dividing the relative anchor width and height from its $x$ part and $y$ part separately to smooth the Gaussian prior to better match with objects of different scales:
|
| 137 |
+
|
| 138 |
+
$$
|
| 139 |
+
{ \bf M o d u l a t e A t t m } ( ( x , y ) , ( x _ { \mathrm { r e f } } , y _ { \mathrm { r e f } } ) ) = ( { \bf P E } ( x ) \cdot { \bf P E } ( x _ { \mathrm { r e f } } ) \frac { w _ { q , \mathrm { r e f } } } { w _ { q } } + { \bf P E } ( y ) \cdot { \bf P E } ( y _ { \mathrm { r e f } } ) \frac { h _ { q , \mathrm { r e f } } } { h _ { q } } ) / \sqrt { D } ,
|
| 140 |
+
$$
|
| 141 |
+
|
| 142 |
+
where $w _ { q }$ and $h _ { q }$ are the width and height of the anchor $A _ { q }$ , and $w _ { q , \mathrm { r e f } }$ and $h _ { q , \mathrm { r e f } }$ are the reference width and height that are calculated by:
|
| 143 |
+
|
| 144 |
+
$$
|
| 145 |
+
w _ { q , \mathrm { r e f } } , h _ { q , \mathrm { r e f } } = \sigma ( \mathbf { M L P } ( C _ { q } ) ) .
|
| 146 |
+
$$
|
| 147 |
+
|
| 148 |
+
This modulated positional attention helps us extract features of objects with different widths and heights, and the visualizations of modulated attentions are shown in Fig. 6.
|
| 149 |
+
|
| 150 |
+
# 4.5 TEMPERATURE TUNING
|
| 151 |
+
|
| 152 |
+
For position encoding, we use the sinusoidal function (Vaswani et al., 2017), which is defined as:
|
| 153 |
+
|
| 154 |
+
$$
|
| 155 |
+
\mathrm { P E } ( x ) _ { 2 i } = \sin ( \frac { x } { T ^ { 2 i / D } } ) , \quad \mathrm { P E } ( x ) _ { 2 i + 1 } = \cos ( \frac { x } { T ^ { 2 i / D } } ) ,
|
| 156 |
+
$$
|
| 157 |
+
|
| 158 |
+
where $T$ is a hand-design temperature, and the superscript $2 i$ and $2 i + 1$ denote the indices in the encoded vectors. The temperature $T$ in Eq. (8) influences the size of positional priors, as shown in Fig. 7. A larger $T$ results in a more flattened attention map, and vice versa. Note that the temperature $T$ is hard-coded in (Vaswani et al., 2017) as 10000 for natural language processing, in which the values of $x$ are integers representing each word’s position in a sentence. However, in DETR, the values of $x$ are floats between 0 and 1 representing bounding box coordinates. Hence a different temperature is highly desired for vision tasks. In this work, we empirically choose $T = 2 0$ in all our models.
|
| 159 |
+
|
| 160 |
+
# 5 EXPERIMENTS
|
| 161 |
+
|
| 162 |
+
We provide the training details in Appendix A.
|
| 163 |
+
|
| 164 |
+
# 5.1 MAIN RESULTS
|
| 165 |
+
|
| 166 |
+
Table 2 shows our main results on the COCO 2017 validation set. We compare our proposed DABDETR with DETR (Carion et al., 2020), Faster RCNN (Ren et al., 2017), Anchor DETR (Wang et al., 2021), SMCA (Gao et al., 2021), Deformable DETR (Zhu et al., 2021), TSP (Sun et al., 2020), and Conditional DETR (Meng et al., 2021). We showed two variations of our model: standard models and models marked with superscript ∗ that have 3 pattern embeddings (Wang et al., 2021). Our standard models outperform Conditional DETR with a large margin. We notice that our model introduces a slight increase of GFLOPs. GFLOPs may differ depending on the calculation scripts and we use the results reported by the authors in Table 2. Actually, we find in our tests that the GFLOPs of our standard models are nearly the same as the corresponding Conditional DETR models based on our GFLOPs calculation scripts, hence our model still has advantages over previous work under the same settings. When using pattern embeddings, our DAB-DETR with ∗ outperforms previous DETR-like methods on all four backbones with a large margin, even better than multiscale architectures. It verifies the correctness of our analysis and the effectiveness of our design.
|
| 167 |
+
|
| 168 |
+
# 5.2 ABLATIONS
|
| 169 |
+
|
| 170 |
+
Table 3 shows the effectiveness of each component in our model. We find that all modules we proposed contribute remarkably to our final results. The anchor box formulation improves the performance from $4 4 . 0 \%$ AP to $4 \dot { 5 } . 0 \%$ AP compared with the anchor point formulation (compare Row
|
| 171 |
+
|
| 172 |
+
Table 2: Results for our DAB-DETR and other detection models. All DETR-like models except DETR use 300 queries, while DETR uses 100. The models with superscript ∗ use 3 pattern embeddings as in Anchor DETR (Wang et al., 2021). We also provide stronger results of our DAB-DETR in Appendix G and Appendix C.
|
| 173 |
+
|
| 174 |
+
<table><tr><td>Model</td><td>MultiScale</td><td>#epochs</td><td>AP</td><td>AP50</td><td>AP75</td><td>APs</td><td>APM</td><td>APL</td><td>GFLOPs</td><td>Params</td></tr><tr><td>DETR-R50</td><td></td><td>500</td><td>42.0</td><td>62.4</td><td>44.2</td><td>20.5</td><td>45.8</td><td>61.1</td><td>86</td><td>41M</td></tr><tr><td>Faster RCNN-FPN-R50</td><td></td><td>108</td><td>42.0</td><td>62.1</td><td>45.5</td><td>26.6</td><td>45.5</td><td>53.4</td><td>180</td><td>42M</td></tr><tr><td>Anchor DETR-R50*</td><td></td><td>50</td><td>42.1</td><td>63.1</td><td>44.9</td><td>22.3</td><td>46.2</td><td>60.0</td><td>1</td><td>39M</td></tr><tr><td>Conditional DETR-R50</td><td></td><td>50</td><td>40.9</td><td>61.8</td><td>43.3</td><td>20.8</td><td>44.6</td><td>59.2</td><td>90</td><td>44M</td></tr><tr><td>DAB-DETR-R50</td><td></td><td>50</td><td>42.2</td><td>63.1</td><td>44.7</td><td>21.5</td><td>45.7</td><td>60.3</td><td>94</td><td>44M</td></tr><tr><td>DAB-DETR-R50*</td><td></td><td>50</td><td>42.6</td><td>63.2</td><td>45.6</td><td>21.8</td><td>46.2</td><td>61.1</td><td>100</td><td>44M</td></tr><tr><td>DETR-DC5-R50</td><td></td><td>500</td><td>43.3</td><td>63.1</td><td>45.9</td><td>22.5</td><td>47.3</td><td>61.1</td><td>187</td><td>41M</td></tr><tr><td>Deformable DETR-R50</td><td>√</td><td>50</td><td>43.8</td><td>62.6</td><td>47.7</td><td>26.4</td><td>47.1</td><td>58.0</td><td>173</td><td>40M</td></tr><tr><td>SMCA-R50</td><td>√</td><td>50</td><td>43.7</td><td>63.6</td><td>47.2</td><td>24.2</td><td>47.0</td><td>60.4</td><td>152</td><td>40M</td></tr><tr><td>TSP-RCNN-R50</td><td>√</td><td>96</td><td>45.0</td><td>64.5</td><td>49.6</td><td>29.7</td><td>47.7</td><td>58.0</td><td>188</td><td>1</td></tr><tr><td>Anchor DETR-DC5-R50*</td><td></td><td>50</td><td>44.2</td><td>64.7</td><td>47.5</td><td>24.7</td><td>48.2</td><td>60.6</td><td>151</td><td>39M</td></tr><tr><td>Conditional DETR-DC5-R50</td><td></td><td>50</td><td>43.8</td><td>64.4</td><td>46.7</td><td>24.0</td><td>47.6</td><td>60.7</td><td>195</td><td>44M</td></tr><tr><td>DAB-DETR-DC5-R50</td><td></td><td>50</td><td>44.5</td><td>65.1</td><td>47.7</td><td>25.3</td><td>48.2</td><td>62.3</td><td>202</td><td>44M</td></tr><tr><td>DAB-DETR-DC5-R50*</td><td></td><td>50</td><td>45.7</td><td>66.2</td><td>49.0</td><td>26.1</td><td>49.4</td><td>63.1</td><td>216</td><td>44M</td></tr><tr><td>DETR-R101</td><td></td><td>500</td><td>43.5</td><td>63.8</td><td>46.4</td><td>21.9</td><td>48.0</td><td>61.8</td><td>152</td><td>60M</td></tr><tr><td>Faster RCNN-FPN-R101</td><td></td><td>108</td><td>44.0</td><td>63.9</td><td>47.8</td><td>27.2</td><td>48.1</td><td>56.0</td><td>246</td><td>60M</td></tr><tr><td>Anchor DETR-R101*</td><td></td><td>50</td><td>43.5</td><td>64.3</td><td>46.6</td><td>23.2</td><td>47.7</td><td>61.4</td><td>1</td><td>58M</td></tr><tr><td>Conditional DETR-R101</td><td></td><td>50</td><td>42.8</td><td>63.7</td><td>46.0</td><td>21.7</td><td>46.6</td><td>60.9</td><td>156</td><td>63M</td></tr><tr><td>DAB-DETR-R101</td><td></td><td>50</td><td>43.5</td><td>63.9</td><td>46.6</td><td>23.6</td><td>47.3</td><td>61.5</td><td>174</td><td>63M</td></tr><tr><td>DAB-DETR-R101*</td><td></td><td>50</td><td>44.1</td><td>64.7</td><td>47.2</td><td>24.1</td><td>48.2</td><td>62.9</td><td>179</td><td>63M</td></tr><tr><td>DETR-DC5-R101</td><td></td><td>500</td><td>44.9</td><td>64.7</td><td>47.7</td><td>23.7</td><td>49.5</td><td>62.3</td><td>253</td><td>60M</td></tr><tr><td>TSP-RCNN-R101</td><td>√</td><td>96</td><td>46.5</td><td>66.0</td><td>51.2</td><td>29.9</td><td>49.7</td><td>59.2</td><td>254</td><td>1</td></tr><tr><td>SMCA-R101</td><td>√</td><td>50</td><td>44.4</td><td>65.2</td><td>48.0</td><td>24.3</td><td>48.5</td><td>61.0</td><td>218</td><td>50M</td></tr><tr><td>Anchor DETR-R101*</td><td></td><td>50</td><td>45.1</td><td>65.7</td><td>48.8</td><td>25.8</td><td>49.4</td><td>61.6</td><td>1</td><td>58M</td></tr><tr><td>Conditional DETR-DC5-R101</td><td></td><td>50</td><td>45.0</td><td>65.5</td><td>48.4</td><td>26.1</td><td>48.9</td><td>62.8</td><td>262</td><td>63M</td></tr><tr><td>DAB-DETR-DC5-R101</td><td></td><td>50</td><td>45.8</td><td>65.9</td><td>49.3</td><td>27.0</td><td>49.8</td><td>63.8</td><td>282</td><td>63M</td></tr><tr><td>DAB-DETR-DC5-R101*</td><td></td><td>50</td><td>46.6</td><td>67.0</td><td>50.2</td><td>28.1</td><td>50.5</td><td>64.1</td><td>296</td><td>63M</td></tr></table>
|
| 175 |
+
|
| 176 |
+
Table 3: Ablation results for our DAB-DETR. All models are tested over ResNet-50-DC5 backbone and the other parameters are the same as our default settings.
|
| 177 |
+
|
| 178 |
+
<table><tr><td>#RoW</td><td>Anchor Box (4D) vs.Point (2D)Anchor Updatewh-Modulated AttentionTemperature Tuning</td><td></td><td></td><td></td><td>AP</td></tr><tr><td>1</td><td>4D</td><td>√</td><td>√</td><td>√</td><td>45.7</td></tr><tr><td>2</td><td>4D</td><td></td><td>√</td><td>√</td><td>44.0</td></tr><tr><td>3</td><td>4D</td><td>√</td><td></td><td>√</td><td>45.0</td></tr><tr><td>4</td><td>2D</td><td>√</td><td></td><td>√</td><td>44.0</td></tr><tr><td>5</td><td>4D</td><td>√</td><td>√</td><td></td><td>44.4</td></tr></table>
|
| 179 |
+
|
| 180 |
+
3 and Row 4) and the anchor update introduces $1 . 7 \%$ AP improvement (compare Row 1 and Row
|
| 181 |
+
2), which demonstrates the effectiveness of dynamic anchor box design.
|
| 182 |
+
|
| 183 |
+
After removing modulated attention and temperature tuning, the model performance drops to $4 5 . 0 \%$ (compare Row 1 and Row 3) and $4 4 . 4 \%$ (compare Row 1 and Row 5), respectively. Hence finegrained tuning of positional attentions is of great importance for improving the detection performance as well.
|
| 184 |
+
|
| 185 |
+
# 6 CONCLUSION
|
| 186 |
+
|
| 187 |
+
We have presented in this paper a novel query formulation using dynamic anchor boxes for DETR and offered a deeper understanding of the role of queries in DETR. Using anchor boxes as queries leads to several advantages, including a better positional prior with temperature tuning, sizemodulated attention to account for objects of different scales, and iterative anchor update for improving anchor estimate gradually. Such a design makes it clear that queries in DETR can be implemented as performing soft ROI pooling layer by layer in a cascade manner. Extensive experiments were conducted and effectively confirmed our analysis and verified our algorithm design.
|
| 188 |
+
|
| 189 |
+
# ACKNOWLEDGEMENTS
|
| 190 |
+
|
| 191 |
+
This work was supported by the National Key Research and Development Program of China (2020AAA0104304, 2020AAA0106000, 2020AAA0106302), NSFC Projects (Nos. 61620106010, 62061136001, 61621136008, 62076147, U19B2034, U1811461, U19A2081), Beijing NSF Project (No. JQ19016), Beijing Academy of Artificial Intelligence (BAAI), Tsinghua-Alibaba Joint Research Program, Tsinghua Institute for Guo Qiang, Tsinghua-OPPO Joint Research Center for Future Terminal Technology.
|
| 192 |
+
|
| 193 |
+
We thank all anonymous reviewers for their valuable comments and suggestions, especially the instructive questions from Reviewer 3.
|
| 194 |
+
|
| 195 |
+
# ETHICS STATEMENT
|
| 196 |
+
|
| 197 |
+
Object detection is a fundamental task in computer vision with wide applications. Hence any improvement of this field will yield lots of impacts. To visually perceive and interact with the environment, autonomous vehicles highly depend on this technique and will benefit from any of its improvement. It has also led to advances in medical imaging, word recognition, instance segmentation on natural images, and so on. Therefore a failure in this model could affect many tasks. Our study provides a deeper understanding of the roles of queries in DETR and improves the interpretability of this important submodule in the end-to-end Transformer-based detection framework.
|
| 198 |
+
|
| 199 |
+
As our model relies on deep neural networks, it can be attacked by adversarial examples. Similarly, as it relies on training data, it may produce biased results induced from training samples. These are common problems in deep learning and our community is working together to improve them. Finally, it is worth noting that detection models, especially face or human detection models, might pose a threat to people’s privacy and security if used by someone up to no good.
|
| 200 |
+
|
| 201 |
+
# REPRODUCIBILITY STATEMENT
|
| 202 |
+
|
| 203 |
+
We confirm the reproducibility of the results. We have released the source code on Github at https://github.com/IDEA-opensource/DAB-DETR with all materials that are needed to reproduce our results.
|
| 204 |
+
|
| 205 |
+
# REFERENCES
|
| 206 |
+
|
| 207 |
+
Alexey Bochkovskiy, Chien-Yao Wang, and Hong-Yuan Mark Liao. Yolov4: Optimal speed and accuracy of object detection. arXiv preprint arXiv:2004.10934, 2020.
|
| 208 |
+
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, pp. 213–229. Springer, 2020.
|
| 209 |
+
Xiyang Dai, Yinpeng Chen, Jianwei Yang, Pengchuan Zhang, Lu Yuan, and Lei Zhang. Dynamic detr: End-to-end object detection with dynamic attention. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pp. 2988–2997, October 2021.
|
| 210 |
+
Peng Gao, Minghang Zheng, Xiaogang Wang, Jifeng Dai, and Hongsheng Li. Fast convergence of detr with spatially modulated co-attention. arXiv preprint arXiv:2101.07448, 2021.
|
| 211 |
+
Zheng Ge, Songtao Liu, Feng Wang, Zeming Li, and Jian Sun. Yolox: Exceeding yolo series in 2021. arXiv preprint arXiv:2107.08430, 2021.
|
| 212 |
+
Ross Girshick. Fast r-cnn. In 2015 IEEE International Conference on Computer Vision (ICCV), pp. 1440–1448, 2015.
|
| 213 |
+
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Delving deep into rectifiers: Surpassing human-level performance on imagenet classification. In 2015 IEEE International Conference on Computer Vision (ICCV), pp. 1026–1034, 2015.
|
| 214 |
+
|
| 215 |
+
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 770–778, 2016.
|
| 216 |
+
|
| 217 |
+
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 ´ European conference on computer vision, pp. 740–755. Springer, 2014.
|
| 218 |
+
|
| 219 |
+
Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollar. Focal loss for dense object detection. IEEE Transactions on Pattern Analysis and Machine Intelligence, 42(2):318– 327, 2020.
|
| 220 |
+
|
| 221 |
+
Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations, 2018.
|
| 222 |
+
|
| 223 |
+
Depu Meng, Xiaokang Chen, Zejia Fan, Gang Zeng, Houqiang Li, Yuhui Yuan, Lei Sun, and Jingdong Wang. Conditional detr for fast training convergence. arXiv preprint arXiv:2108.06152, 2021.
|
| 224 |
+
|
| 225 |
+
Joseph Redmon, Santosh Divvala, Ross Girshick, and Ali Farhadi. You only look once: Unified, real-time object detection. In 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 779–788, 2016.
|
| 226 |
+
|
| 227 |
+
Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. IEEE Transactions on Pattern Analysis and Machine Intelligence, 39(6):1137–1149, 2017.
|
| 228 |
+
|
| 229 |
+
Hamid Rezatofighi, Nathan Tsoi, JunYoung Gwak, Amir Sadeghian, Ian Reid, and Silvio Savarese. Generalized intersection over union: A metric and a loss for bounding box regression. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 658–666, 2019.
|
| 230 |
+
|
| 231 |
+
Peize Sun, Rufeng Zhang, Yi Jiang, Tao Kong, Chenfeng Xu, Wei Zhan, Masayoshi Tomizuka, Lei Li, Zehuan Yuan, Changhu Wang, and Ping Luo. Sparse r-cnn: End-to-end object detection with learnable proposals. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 14454–14463, 2021.
|
| 232 |
+
|
| 233 |
+
Zhiqing Sun, Shengcao Cao, Yiming Yang, and Kris Kitani. Rethinking transformer-based set prediction for object detection. arXiv preprint arXiv:2011.10881, 2020.
|
| 234 |
+
|
| 235 |
+
Zhi Tian, Chunhua Shen, Hao Chen, and Tong He. Fcos: Fully convolutional one-stage object detection. In 2019 IEEE/CVF International Conference on Computer Vision (ICCV), pp. 9627– 9636, 2019.
|
| 236 |
+
|
| 237 |
+
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.
|
| 238 |
+
|
| 239 |
+
Yingming Wang, Xiangyu Zhang, Tong Yang, and Jian Sun. Anchor detr: Query design for transformer-based detector. arXiv preprint arXiv:2109.07107, 2021.
|
| 240 |
+
|
| 241 |
+
Zhuyu Yao, Jiangbo Ai, Boxun Li, and Chi Zhang. Efficient detr: Improving end-to-end object detector with dense prior. arXiv preprint arXiv:2104.01318, 2021.
|
| 242 |
+
|
| 243 |
+
Xingyi Zhou, Dequan Wang, and Philipp Krahenb ¨ uhl. Objects as points. ¨ arXiv preprint arXiv:1904.07850, 2019.
|
| 244 |
+
|
| 245 |
+
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: The Ninth International Conference on Learning Representations, 2021.
|
| 246 |
+
|
| 247 |
+
# Appendix for DAB-DETR
|
| 248 |
+
|
| 249 |
+
# A TRAINING DETAILS
|
| 250 |
+
|
| 251 |
+
Architecture. Our model is almost the same as DETR which includes a CNN backbone, multiple Transformer (Vaswani et al., 2017) encoders and decoders, and two prediction heads for boxes and labels. We use ImageNet-pretrained ResNet (He et al., 2016) as our backbones, and 6 Transformer encoders and 6 Transformer decoders in our implementations. We follow previous works to report results over four backbones: ResNet-50, ResNet-101, and their $1 6 \times$ -resolution extensions ResNet50-DC5 and ResNet-101-DC5. As we need to predict boxes and labels in each decoder layer, the MLP networks for box and label predictions share the same parameters across different decoder layers. As inspired by Anchor DETR, we also leverage multiple pattern embeddings to perform multiple predictions at one position and the number of patterns is set as 3 which is the same as Anchor DETR. We also leverage PReLU (He et al., 2015) as our activations.
|
| 252 |
+
|
| 253 |
+
Following Deformable DETR and Conditional DETR, we use 300 anchors as queries. We select 300 predicted boxes and labels with the largest classification logits for evaluation as well. We also use focal loss (Lin et al., 2020) with $\alpha = 0 . 2 5$ , $\gamma = 2$ for classification. The same loss terms are used in bipartite matching and final loss calculating, but with different coefficients. Classification loss with coefficient 2.0 is used in bipartite matching but 1.0 in the final loss. L1 loss with coefficient 5.0 and GIOU loss (Rezatofighi et al., 2019) with coefficient 2.0 are consistent in both the matching and the final loss calculation procedures. All models are trained on 16 GPUs with 1 image per GPU and AdamW (Loshchilov & Hutter, 2018) is used for training with weight decay $1 0 ^ { - 4 }$ . The learning rates for backbone and other modules are set to $1 0 ^ { - 5 }$ and $1 0 ^ { - 4 }$ , respectively. We train our models for 50 epochs and drop the learning rate by 0.1 after 40 epochs. All models are trained on Nvidia A100 GPU. We search hyperparameters with batch size 64 and all results in our paper are reported with batch size 16. For better reproducing our results, we provide the memory needed and batch size/GPU in Table 4.
|
| 254 |
+
|
| 255 |
+
Dataset. We conduct the experiments on the COCO (Lin et al., 2014) object detection dataset. All models are trained on the train2017 split and evaluated on the val2017 split.
|
| 256 |
+
|
| 257 |
+
Table 4: GPU memory usage of each model.
|
| 258 |
+
|
| 259 |
+
<table><tr><td>Model</td><td>Batch Size/GPU</td><td>GPUMemory (MB)</td></tr><tr><td>DAB-DETR-R50</td><td>2</td><td>6527</td></tr><tr><td>DAB-DETR-R50*</td><td>1</td><td>3573</td></tr><tr><td>DAB-DETR-R50-DC5</td><td>1</td><td>13745</td></tr><tr><td>DAB-DETR-R50-DC5*</td><td>1</td><td>15475</td></tr><tr><td>DAB-DETR-R101</td><td>2</td><td>6913</td></tr><tr><td>DAB-DETR-R101*</td><td>1</td><td>4369</td></tr><tr><td>DAB-DETR-R101-DC5</td><td>1</td><td>13148</td></tr><tr><td>DAB-DETR-R101-DC5*</td><td>1</td><td>16744</td></tr></table>
|
| 260 |
+
|
| 261 |
+
# B COMPARISON OF DETR-LIKE MODELS
|
| 262 |
+
|
| 263 |
+
In this section, we provide a more detailed comparison of DETR-like models, including DETR (Carion et al., 2020), Conditional DETR (Meng et al., 2021), Anchor DETR (Wang et al., 2021), Deformable DETR (Zhu et al., 2021), our proposed DAB-DETR, and DAB-Deformable-DETR. Their model designs are illustrated in Fig. 8. We will discuss the difference between previous models and our models.
|
| 264 |
+
|
| 265 |
+
Anchor DETR (Wang et al., 2021) improves DETR by introducing 2D anchor points, which are updated layer by layer. It shares a similar motivation with our work. But it leaves the object scale information unconsidered and thus cannot modulate the cross-attention to make it adapt to objects of different scales. Moreover, the positional queries in its framework are of high dimension and passed to the self-attention modules in all layers without any adaptation. See the brown-colored part in Fig. 8 (d) for details. This design might be sub-optimal as the self-attention modules cannot leverage the refined anchor points in different layers.
|
| 266 |
+
|
| 267 |
+
Deformable DETR (Zhu et al., 2021) introduces 4D anchor boxes and updates them layer by layer, which is called iterative bounding box refinement in its paper. Its algorithm is mainly developed based on deformable attention, which requires reference points to sample attention points and meanwhile utilizes box width and height to modulate attention areas. However, as iterative bounding box refinement is closely coupled with the special design of deformable attention, it is nontrivial to apply it to general Transformer decoder-based DETR models. This is probably the reason why few works after Deformable DETR adopt this idea. Moreover, the position queries in Deformable DETR are passed to both the self-attention modules and the cross-attention modules in all layers without any adaptation. See the brown-colored part in Fig. 8 (e) for details. As a result, both its self-attention modules and cross-attention modules cannot fully leverage the refined anchor boxes in different layers.
|
| 268 |
+
|
| 269 |
+
To verify our analysis, we develop a variant of Deformable-DETR by formulating its queries as dynamic anchor boxes as in DAB-DETR. We call this variant as DAB-Deformable-DETR, which is illustrated in Fig. 8 (f). Under exactly the same setting using R50 as the backbone, DABDeformable-DETR improves Deformable-DETR by 0.5 AP (46.3 to 46.8) on COCO. See Table 5 for the performance comparison and Sec. C for more implementation details.
|
| 270 |
+
|
| 271 |
+
Dynamic DETR (Dai et al., 2021) is another interesting improvement of DETR. It also leverages anchor boxes to pool features, but it uses ROI pooling for feature extraction, which makes it less general to DETR-like models compared with our dynamic anchor boxes. Moreover, compared with cross-attention in Transformer decoders, which performs global feature pooling in a soft manner (based on attention maps), the ROI pooling operation only performs local feature pooling within a ROI window. In our opinion, the ROI pooling operation can help faster convergence as it enforces each query to associate with a specific spatial position. But it may lead to a sub-optimal result due to its ignorance of the global context outside a ROI window.
|
| 272 |
+
|
| 273 |
+
# C DAB-DEFORMABLE-DETR
|
| 274 |
+
|
| 275 |
+
To further demonstrate the effectiveness of our dynamic anchor boxes, we develop DABDeformable-DETR by adding our dynamic anchor boxes design to Deformable DETR (Zhu et al., 2021) 2. The difference between Deformable DETR and DAB-Deformable-DETR is shown in Fig. 8 (e) and (f). The results of Deformable DETR and DAB-Deformable-DETR are shown in Table 5. With no more than 10 lines of code modified, our DAB-Deformable-DETR (row 4) results in a significant performance improvement $( + 0 . 5$ AP) compared with the original Deformable DETR (row 3). All other settings except the query formulation are exactly the same in this experiment.
|
| 276 |
+
|
| 277 |
+
We also compare the speed of convergence in Fig. 9. It shows that our proposed dynamic anchor boxes speed up the training as well (left in Fig. 9). We believe one of the reasons for better performance is the update of learned queries. We plot the change of total loss, which is the sum-up of losses of all decoder layers, during training in the middle figure of Fig. 9. Interestingly, it shows that the total loss of DAB-Deformable-DETR is larger than Deformable DETR. However, the loss of the final layer of DAB-Deformable-DETR is lower than that in Deformable DETR (right in Fig. 9), which is a good indicator of the better performance of DAB-Deformable-DETR as the inference result only takes from the last layer.
|
| 278 |
+
|
| 279 |
+
# D ANCHORS VISUALIZATION
|
| 280 |
+
|
| 281 |
+
We visualize the learned anchor boxes in Fig. 10. When learning anchor points as queries, the learned points are distributed evenly around the image, while the centers seem to distribute randomly when learning anchor boxes directly. This might be because the centers are coupled with anchor sizes. The right-most figure shows the visualization of the learned anchor boxes. We only show a partial set for visualization clarity. Most boxes are of medium size and no particular pattern is found in the distribution of boxes.
|
| 282 |
+
|
| 283 |
+

|
| 284 |
+
Figure 8: Comparison of DETR-like models. For clarity, we only show two layers of Transformer decoder and omit the FFN blocks. We mark the modules with difference in purple and marked the learned high-dimensional queries in brown. DAB-DETR (c) is proposed in our paper, and DABDeformable-DETR (f) is a variant of Deformable DETR modified by introducing our dynamic anchors boxes. All previous models (a,b,d,e) leverage high-dimensional queries (shaded in brown) to pass positional information to each layers, which are semantic ambiguous and are not updated layer by layer. In contrast, DAB-DETR (c) directly uses dynamically updated anchor boxes to provide both a reference query point $( x , y )$ and a reference anchor size $( w , h )$ to improve the cross-attention computation. DAB-Deformable-DETR (f) uses dynamically updated anchor boxes to formulate its queries as well.
|
| 285 |
+
|
| 286 |
+
<table><tr><td># row</td><td>Model</td><td>AP</td><td>AP50</td><td>AP75</td><td>APs</td><td>APM</td><td>APL</td><td>Params</td></tr><tr><td>1</td><td>Deformable DETR</td><td>43.8</td><td>62.6</td><td>47.7</td><td>26.4</td><td>47.1</td><td>58.0</td><td>40M</td></tr><tr><td>2</td><td>Deformable DETR+</td><td>45.4</td><td>64.7</td><td>49.0</td><td>26.8</td><td>48.3</td><td>61.7</td><td>40M</td></tr><tr><td>3</td><td>Deformable DETR+ (open source)</td><td>46.3</td><td>65.3</td><td>50.2</td><td>28.6</td><td>49.3</td><td>62.1</td><td>47M</td></tr><tr><td>4</td><td>DAB-Deformable-DETR(Ours)</td><td>46.8</td><td>66.0</td><td>50.4</td><td>29.1</td><td>49.8</td><td>62.3</td><td>47M</td></tr></table>
|
| 287 |
+
|
| 288 |
+
Table 5: Comparison of the results of Deformable DETR and DAB-Deformable-DETR. The models in row 1 and row 2 are copied from the original paper, and the models in row 3 and row 4 are tested under the same standard R50 multi-scale setting. Deformable ${ \mathrm { D E T R } } +$ means the Deformable DETR model with iterative bounding box refinement and the result of Deformable ${ \mathrm { D E T R } } +$ (open source) is reported by us using the open-source code. The only difference between row 3 and row 4 is the formulation of queries.
|
| 289 |
+
|
| 290 |
+

|
| 291 |
+
Figure 9: Comparison of the training of Deformable DETR and DAB-Deformable-DETR models. We plot the change of AP (left), the loss of all layers (middle), and the loss of the last layer (right) during training, respectively. With no more than 10 lines of code modified, DAB-Deformable-DETR results in a better performance compared with the original Deformable DETR model (see the left figure). While the loss of all layers of DAB-Deformable-DETR is larger than that in Deformable DETR (see the middle figure), our models have a lower loss of the last layer (see the right figure), which is the most important as the inference result only takes from the last layer. The two models are tested under the same standard R50 multi-scale setting.
|
| 292 |
+
|
| 293 |
+

|
| 294 |
+
Figure 10: Learned anchor points when learning 2D coordinates only (left), and anchor center points (middle) and partial anchor boxes (right) when learning anchor boxes directly.
|
| 295 |
+
|
| 296 |
+
# E RESULTS WITH DIFFERENT TEMPERATURES
|
| 297 |
+
|
| 298 |
+
Table 6 shows the results of models using different temperatures in the positional encoding function. As larger temperature generates more flattened attention maps, it leads to better performances for larger objects. For example, the model with $T = 2$ and the model with $T = 1 0 0 0 0$ have similar AP results, but the former has better performances on $\mathsf { A P } _ { S }$ and $\mathsf { A P } _ { M }$ , while the latter works better on $\mathsf { A P } _ { L }$ , which also validates the role of positional priors in DETR.
|
| 299 |
+
|
| 300 |
+
<table><tr><td>Temperature</td><td>AP</td><td>AP50</td><td>AP75</td><td>APs</td><td>APM</td><td>APL</td></tr><tr><td>2</td><td>39.6</td><td>60.7</td><td>41.9</td><td>19.3</td><td>43.3</td><td>58.0</td></tr><tr><td>5</td><td>40.0</td><td>61.1</td><td>42.1</td><td>19.5</td><td>43.4</td><td>58.9</td></tr><tr><td>10</td><td>40.0</td><td>61.1</td><td>42.3</td><td>19.7</td><td>43.5</td><td>59.3</td></tr><tr><td>20</td><td>40.1</td><td>61.1</td><td>42.8</td><td>19.8</td><td>43.7</td><td>58.6</td></tr><tr><td>50</td><td>39.8</td><td>61.0</td><td>42.2</td><td>19.7</td><td>43.2</td><td>58.8</td></tr><tr><td>100</td><td>39.8</td><td>60.8</td><td>42.1</td><td>19.3</td><td>43.3</td><td>58.4</td></tr><tr><td>10000</td><td>39.5</td><td>60.7</td><td>41.7</td><td>18.9</td><td>42.6</td><td>58.9</td></tr></table>
|
| 301 |
+
|
| 302 |
+
Table 6: Comparison of models with different temperatures. All models are trained with the ResNet50 backbone, batch size 64, no multiple pattern embeddings, and no modulated attentions. Default Settings are used for the rest of the parameters.
|
| 303 |
+
|
| 304 |
+
# F RESULTS WITH LESS DECODER LAYERS
|
| 305 |
+
|
| 306 |
+
Table 7 shows the results of models with different decoder layers. All models are trained under our standard ResNet-50-DC setting except the number of decoder layers.
|
| 307 |
+
Table 7: Comparison of models with different number of decoder layers. All models are trained under our standard ResNet-50-DC setting except the number of decoder layers.
|
| 308 |
+
|
| 309 |
+
<table><tr><td>decoder layers</td><td>GFLOPs</td><td>Parmas</td><td>AP</td><td>AP50</td><td>AP75</td><td>APs</td><td>APM</td><td>APL</td></tr><tr><td>2</td><td>202</td><td>36M</td><td>40.2</td><td>59.0</td><td>42.9</td><td>22.2</td><td>43.5</td><td>55.4</td></tr><tr><td>3</td><td>206</td><td>38M</td><td>43.9</td><td>63.4</td><td>47.4</td><td>24.6</td><td>47.8</td><td>60.5</td></tr><tr><td>4</td><td>210</td><td>40M</td><td>44.9</td><td>64.5</td><td>48.2</td><td>25.9</td><td>48.5</td><td>61.0</td></tr><tr><td>5</td><td>213</td><td>42M</td><td>45.2</td><td>65.5</td><td>48.6</td><td>26.6</td><td>48.9</td><td>62.3</td></tr><tr><td>6</td><td>216</td><td>44M</td><td>45.7</td><td>66.2</td><td>49.0</td><td>26.1</td><td>49.4</td><td>63.1</td></tr></table>
|
| 310 |
+
|
| 311 |
+
# G FIXED $x , y$ FOR BETTER PERFORMANCE
|
| 312 |
+
|
| 313 |
+
We provide in this section an interesting experiment. As we all know, all box coordinates $x , y , h , w$ are learned from data. When we fix $x , y$ of the anchor boxes with the random initialization, the model’s performance increases consistently. The comparison of standard DAB-DETR and DABDETR with fixed $x , y$ coordinates is shown in Table 8. Note that we only fix $x , y$ at the first layer to prevent them from learning information from data. But $x , y$ will be updated in other layers. We conjecture that the randomly initialized and fixed $x , y$ coordinates can help to avoid overfitting, which may account for this phenomenon.
|
| 314 |
+
|
| 315 |
+
# H COMPARISON OF BOX UPDATE
|
| 316 |
+
|
| 317 |
+
To further demonstrate the effectiveness of our dynamic anchor box design, we plot the layer-bylayer update result of boxes of DAB-DETR and Conditional DETR in Fig. 11. All DETR-like models have a stacked layers structure. Hence the outputs of each layer can be viewed as a refining procedure. However, due to the high-dimensional queries that are shared across all layers, the update of queries between layers is not stable. As shaded in yellow in Fig. 11 (b), some boxes predicted in the latter layers are worse than their previous layers.
|
| 318 |
+
|
| 319 |
+
# I ANALYSIS OF FAILURE CASES
|
| 320 |
+
|
| 321 |
+
Fig. 12 presents some samples where our model does not predict well. We find our model may have some troubles when facing dense objects, very small objects, or very large objects in an image. To
|
| 322 |
+
|
| 323 |
+
<table><tr><td>Model</td><td>AP</td><td>AP50</td><td>AP75</td><td>APs</td><td>APM</td><td>APL</td></tr><tr><td>DAB-DETR-R50*</td><td>42.6</td><td>63.2</td><td>45.6</td><td>21.8</td><td>46.2</td><td>61.1</td></tr><tr><td>DAB-DETR-R50*-fixedx&y</td><td>42.9(+0.3)</td><td>63.7</td><td>45.3</td><td>22.0</td><td>46.8</td><td>60.9</td></tr><tr><td>DAB-DETR-DC5-R50</td><td>44.5</td><td>65.1</td><td>47.7</td><td>25.3</td><td>48.2</td><td>62.3</td></tr><tr><td>DAB-DETR-DC5-R50-fixedx&y</td><td>44.7(+0.2)</td><td>65.3</td><td>47.9</td><td>24.9</td><td>48.2</td><td>62.0</td></tr><tr><td>DAB-DETR-DC5-R50*</td><td>45.7</td><td>66.2</td><td>49.0</td><td>26.1</td><td>49.4</td><td>63.1</td></tr><tr><td>DAB-DETR-DC5-R50*-fixedx&y</td><td>45.8(+0.1)</td><td>66.5</td><td>48.9</td><td>26.4</td><td>49.6</td><td>62.7</td></tr><tr><td>DAB-DETR-R101*</td><td>44.1</td><td>64.7</td><td>47.2</td><td>24.1</td><td>48.2</td><td>62.9</td></tr><tr><td>DAB-DETR-R101*-fixedx&y</td><td>44.8(+0.7)</td><td>65.4</td><td>48.2</td><td>25.1</td><td>48.9</td><td>63.1</td></tr><tr><td>DAB-DETR-DC5-R101*</td><td>46.6</td><td>67.0</td><td>50.2</td><td>28.1</td><td>50.5</td><td>64.1</td></tr><tr><td>DAB-DETR-DC5-R101*-fixedx&y</td><td>46.7(+0.1)</td><td>67.3</td><td>50.7</td><td>27.3</td><td>50.9</td><td>64.1</td></tr></table>
|
| 324 |
+
|
| 325 |
+
Table 8: Comparison of DAB-DETR and DAB-DETR with fixed anchor centers $x , y$ . When fixing $x , y$ of queries with random values, the performance of the models is improved consistently. The models with superscript ∗ use 3 pattern embeddings as in Anchor DETR.
|
| 326 |
+
|
| 327 |
+

|
| 328 |
+
Figure 11: We compare the layer-by-layer update of boxes of DAB-DETR (a) and Conditional DETR (b). The green boxes are ground truth annotations while the red boxes are model predictions. The boxes of Conditional DETR have larger variances and we mark some boundaries of boxes with a large change in yellow.
|
| 329 |
+
|
| 330 |
+
improve the performance of our model, we will introduce a multi-scale technique into our model to improve the detection performance on small and large objects.
|
| 331 |
+
|
| 332 |
+
# J COMPARISON OF RUNTIME
|
| 333 |
+
|
| 334 |
+
We compare the runtime of DETR, Conditional DETR, and our proposed DAB-DETR in Table 9. Their runtime speeds are reported on a single Nvidia A100 GPU. Our DAB-DETR has a similar inference speed but better performance compared with Conditional DETR, which is our direct competitor.
|
| 335 |
+
|
| 336 |
+

|
| 337 |
+
Figure 12: We visualize some images where our model does not predict well, including dense objects (a,b,c), very small objects (d), and very large objects (e,f). The green boxes are ground truth annotations while red boxes are predictions of models.
|
| 338 |
+
|
| 339 |
+
<table><tr><td>Model</td><td>time(s/img)</td><td>epoches</td><td>AP</td><td>AP50</td><td>AP75</td><td>APs</td><td>APM</td><td>APL</td><td>Parmas</td></tr><tr><td>DETR-R50</td><td>0.048</td><td>500</td><td>42.0</td><td>62.4</td><td>44.2</td><td>20.5</td><td>45.8</td><td>61.1</td><td>41M</td></tr><tr><td>Conditional DETR-R50</td><td>0.057</td><td>50</td><td>40.9</td><td>61.8</td><td>43.3</td><td>20.8</td><td>44.6</td><td>59.2</td><td>44M</td></tr><tr><td>DAB-DETR-R50</td><td>0.059</td><td>50</td><td>42.2</td><td>63.1</td><td>44.7</td><td>21.5</td><td>45.7</td><td>60.3</td><td>44M</td></tr><tr><td>DETR-R101</td><td>0.074</td><td>500</td><td>43.5</td><td>63.8</td><td>46.4</td><td>21.9</td><td>48.0</td><td>61.8</td><td>60M</td></tr><tr><td>Conditional DETR-R101</td><td>0.082</td><td>50</td><td>42.8</td><td>63.7</td><td>46.0</td><td>21.7</td><td>46.6</td><td>60.9</td><td>63M</td></tr><tr><td>DAB-DETR-R101</td><td>0.085</td><td>50</td><td>43.5</td><td>63.9</td><td>46.6</td><td>23.6</td><td>47.3</td><td>61.5</td><td>63M</td></tr></table>
|
| 340 |
+
|
| 341 |
+
Table 9: Comparison of the runtime of DETR, Conditional DETR, and our proposed DAB-DETR. All speeds are reported on a single Nvidia A100 GPU.
|
| 342 |
+
|
| 343 |
+
# K COMPARISON OF MODEL CONVERGENCE
|
| 344 |
+
|
| 345 |
+
We present convergence curves of DETR, Conditional DETR, and our DAB-DETR in Fig. 13. All models are trained under the standard R50 (DC5) setting. The results demonstrate the effectiveness of our model. Our DAB-DETR is trained with our f ix x&y variants. see Appendix G for more details about the f ix x&y results. Both Conditional DETR and DAB-DETR use 300 queries, while DETR leverages 100 queries.
|
| 346 |
+
|
| 347 |
+
Our DAB-DETR converges faster than Conditional DETR, especially in early epochs, as shown in Fig. 13.
|
| 348 |
+
|
| 349 |
+
# L VISUALIZATION RESULTS OF ITERATIVE BOX UPDATE
|
| 350 |
+
|
| 351 |
+
We present more visualization results of iterative box update in Fig. 14 and Fig. 15. The initial anchors, anchors updated after the first decoder layer, and the anchors predicted from the last decoder layer are plotted in the first, the second, and the third columns, respectively.
|
| 352 |
+
|
| 353 |
+

|
| 354 |
+
Figure 13: Convergence curves of DETR, Conditional DETR, and our DAB-DETR. All models are trained under the R50 (DC5) setting.
|
| 355 |
+
|
| 356 |
+

|
| 357 |
+
Figure 14: Visualizations for layer-by-layer anchor box update. We plot the initial anchor boxes (left), anchor boxes after the first decoder layer (middle), and the output of the last decoder layer (right), respectively. The green boxes are ground truth annotations, while the red boxes are predictions of our model. The results are obtained using the ResNet-50 backbone. More visualizations are available in Fig. 15.
|
| 358 |
+
|
| 359 |
+

|
| 360 |
+
Figure 15: More visualizations for layer-by-layer anchor box update. We plot the initial anchor boxes (left), anchor boxes after the first decoder layer (middle), and the output of the last decoder layer (right), respectively. The green boxes are ground truth annotations, while the red boxes are predictions of our model. The results are obtained using the ResNet-50 backbone.
|
md/dev/r9b6T088_75/r9b6T088_75.md
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Degradation-Aware Unfolding Half-Shuffle Transformer for Spectral Compressive Imaging
|
| 2 |
+
|
| 3 |
+
Yuanhao Cai $^ { 1 , 2 , * }$ , Jing Lin $^ { 1 , 2 , * }$ , Haoqian Wang 1,2,†, Xin Yuan 3, Henghui Ding 4, Yulun Zhang 4, Radu Timofte 4,5, Luc Van Gool 4
|
| 4 |
+
|
| 5 |
+
1 Shenzhen International Graduate School, Tsinghua University, 2 Shenzhen Institute of Future Media Technology, 3 Westlake University, 4 ETH Zürich, 5 University of Würzburg
|
| 6 |
+
|
| 7 |
+
# Abstract
|
| 8 |
+
|
| 9 |
+
In coded aperture snapshot spectral compressive imaging (CASSI) systems, hyperspectral image (HSI) reconstruction methods are employed to recover the spatialspectral signal from a compressed measurement. Among these algorithms, deep unfolding methods demonstrate promising performance but suffer from two issues. Firstly, they do not estimate the degradation patterns and ill-posedness degree from CASSI to guide the iterative learning. Secondly, they are mainly CNN-based, showing limitations in capturing long-range dependencies. In this paper, we propose a principled Degradation-Aware Unfolding Framework (DAUF) that estimates parameters from the compressed image and physical mask, and then uses these parameters to control each iteration. Moreover, we customize a novel Half-Shuffle Transformer (HST) that simultaneously captures local contents and non-local dependencies. By plugging HST into DAUF, we establish the first Transformer-based deep unfolding method, Degradation-Aware Unfolding Half-Shuffle Transformer (DAUHST), for HSI reconstruction. Experiments show that DAUHST surpasses state-of-the-art methods while requiring cheaper computational and memory costs. Code and models are publicly available at https://github.com/caiyuanhao1998/MST
|
| 10 |
+
|
| 11 |
+
# 1 Introduction
|
| 12 |
+
|
| 13 |
+
Hyperspectral images (HSIs) have more spectral bands than normal RGB images to store more detailed information. Thus, HSIs are widely applied in image recognition [1, 2, 3], object detection [4, 5, 6], tracking [7, 8, 9], medical image processing [10, 11, 12], remote sensing [13, 14, 15, 16], etc. To obtain HSIs, traditional imaging systems use spectrometers to scan the scenes along the spectral or spatial dimensions, usually requiring a long time. These imaging systems fail to capture dynamic objects. Recently, snapshot compressive imaging (SCI) systems [17, 18, 19] have been developed to capture HSIs at video rate. Among these SCI systems, coded aperture snapshot spectral imaging (CASSI) [17, 20, 21] stands out for its impressive performance. CASSI uses a coded aperture and a disperser to modulate the HSI signal at different wavelengths, and then mixes all modulated signal to generate a 2D compressed measurement. Subsequently, HSI restoration methods are employed to solve the CASSI inverse problem, i.e., restore the HSIs from the measurement. These methods are divided into four categories.
|
| 14 |
+
|
| 15 |
+

|
| 16 |
+
Figure 1: PSNR-FLOPS comparisons of DAUHST and SOTA unfolding methods.
|
| 17 |
+
|
| 18 |
+
properties and can be interpreted. Yet, these methods need manual parameter tweaking, which slows down reconstruction. Also, they suffer from limited representation capacity and generalization ability.
|
| 19 |
+
|
| 20 |
+
(ii) Plug-and-play $( \mathrm { P n P } )$ algorithms [29, 30, 31] plug pre-trained denoising networks into traditional model-based methods to solve the HSI reconstruction problem. Nonetheless, the pre-trained networks in $\mathrm { P n P }$ methods are fixed without re-training, therefore limiting the performance.
|
| 21 |
+
|
| 22 |
+
(iii) End-to-end (E2E) algorithms employ a powerful model, usually a convolutional neural network (CNN) [12, 20, 32, 33], to learn the E2E mapping function from a measurement to the desired HSIs. E2E methods enjoy the power of deep learning. However, they learn a brute-force mapping from the compressed measurement to the underlying spectral images, thereby ignoring the working principles of CASSI systems. They come without theoretically proven properties, interpretability, and flexibility because the imaging models widely differ from each other for various hardware systems.
|
| 23 |
+
|
| 24 |
+
(iv) Deep unfolding methods [34, 35, 36, 37, 38, 39] adopt a multi-stage network to map the measurement into the HSI cube. Each stage usually includes two phases, i.e., linear projection followed by passing the signal through a single-stage network that learns the underlying denoiser prior. In deep unfolding methods, the network architecture is intuitively interpretable by explicitly characterizing the image priors and the system imaging model. Besides, these methods also enjoy the power of deep learning and thus have great potential. Yet, this potential has not been fully explored.
|
| 25 |
+
|
| 26 |
+
Existing deep unfolding algorithms suffer from two issues. (a) The iterative learning is highly related to the CASSI system. However, current unfolding methods do not estimate CASSI degradation patterns and ill-posedness degree to adjust the linear projection and denoising network in each iteration. (b) Existing deep unfolding methods are mainly CNN-based, therefore showing limitations in capturing non-local self-similarity and long-range dependencies, both critical for HSI reconstruction.
|
| 27 |
+
|
| 28 |
+
Recently, the emerging Transformer [40] has provided a solution to tackle the drawbacks of CNN. Due to its strong capability in modeling the interactions of non-local spatial regions, Transformer has been widely applied in image classification [41, 42, 43], object detection [44, 45, 46], semantic segmentation [47, 48, 49], human pose estimation [50, 51, 52], image restoration [53, 54, 55], etc. Yet, the use of Transformer is confronted with two main issues. (a) The computational complexity of global Transformer [42] is quadratic to the spatial dimensions. This cost is sometimes unaffordable. (b) The receptive fields of local Transformer [41] are limited within position-specific windows. Thus, some tokens with highly-related contents can not match each other when computing self-attention.
|
| 29 |
+
|
| 30 |
+
To address the above problems, in this paper, we firstly formulate a principled Degradation-Aware Unfolding Framework (DAUF) based on maximum a posteriori (MAP) theory for HSI reconstruction. Different from previous deep unfolding methods, our DAUF implicitly estimates informative parameters from the degraded compressed measurement and the physical mask used in the modulation. Then DAUF feeds the parameters, which capture key cues of CASSI degradation patterns and ill-posedness degree, into each iteration to adaptively scale the linear projection and provide the noise level information for the denoising network. Secondly, we design a novel Half-Shuffle Transformer (HST) as the denoiser prior in each iteration. Our HST can jointly extract local contextual information and model non-local dependencies, while requiring much cheaper computational costs than global Transformer. We achieve this by customizing a Half-Shuffle Multi-head Self-Attention (HS-MSA) mechanism that composes the basic unit of HST. More specifically, our HS-MSA has two branches, i.e., local branch and non-local branch. The local branch calculates the self-attention within the local window while the non-local branch shuffles the tokens and captures cross-window interactions. We plug HST into DAUF to establish an iterative architecture, Degradation-Aware Unfolding Half-Shuffle Transformer (DAUHST). With the proposed techniques, DAUHST models dramatically outperform state-of-the-art (SOTA) deep unfolding methods with the same number of stages by over 4 dB, as shown in Fig. 1.
|
| 31 |
+
|
| 32 |
+
In a nutshell, our contributions can be summarized as follows:
|
| 33 |
+
|
| 34 |
+
(i) We formulate a principled MAP-based unfolding framework DAUF for HSI reconstruction.
|
| 35 |
+
|
| 36 |
+
(ii) We propose a novel Transformer HST and plug it into DAUF to establish DAUHST. To the best of our knowledge, DAUHST is the first Transformer-based deep unfolding method for HSI restoration.
|
| 37 |
+
|
| 38 |
+
(iii) DAUHST outperforms SOTA methods by a large margin while requiring cheaper computational and memory costs. Besides, DAUHST yields more visually pleasant results in real HSI reconstruction.
|
| 39 |
+
|
| 40 |
+

|
| 41 |
+
Figure 2: The architecture of our DAUF with $K$ stages (iterations). $\varepsilon$ estimates informative parameters from the compressed measurement $\mathbf { y }$ and sensing matrix $\Phi$ . The estimated parameters $_ { \pmb { \alpha } }$ and $\beta$ are fed into each stage of subsequent iterative learning. $\mathcal { P }$ and $\mathcal { D }$ denote the linear projection and denoising network in each stage.
|
| 42 |
+
|
| 43 |
+
# 2 Proposed Method
|
| 44 |
+
|
| 45 |
+
# 2.1 Degradation Model of CASSI
|
| 46 |
+
|
| 47 |
+
In CASSI, we denote the vectorized measurement as $\mathbf { y } \in \mathbb { R } ^ { n }$ , where $\begin{array} { r } { n = H ( W + d ( N _ { \lambda } - 1 ) ) . ~ H , W , } \end{array}$ , $d$ , and $N _ { \lambda }$ denote the HSI’s height, width, shifting step in dispersion, and total number of wavelengths. Given the vectorized shifted HSI signal $\mathbf { x } \in \mathbb { R } ^ { n N _ { \lambda } ^ { \mathbf { * } } }$ and the sensing matrix $\Phi \in \mathbb { R } ^ { n \times n N _ { \lambda } }$ that is determined by the physical mask, the degradation model of CASSI can be formulated as
|
| 48 |
+
|
| 49 |
+
$$
|
| 50 |
+
\mathbf { y } = \Phi \mathbf { x } + \mathbf { n } ,
|
| 51 |
+
$$
|
| 52 |
+
|
| 53 |
+
where $\mathbf { n } \in \mathbb { R } ^ { n }$ represents the vectorized imaging noise on the measurement. As analyzed in [56, 57, 58], $\Phi$ is a fat, sparse, and highly structured matrix that is hard to handle. Please refer to the supplementary material for details about the mathematical model of CASSI. Then the task of HSI reconstruction is given y (captured by the camera) and $\Phi$ (calibrated based on pre-design), solving $\mathbf { x }$ .
|
| 54 |
+
|
| 55 |
+
# 2.2 Degradation-Aware Unfolding Framework
|
| 56 |
+
|
| 57 |
+
Previous unfolding frameworks [34, 35, 36, 37] do not estimate the CASSI degradation patterns to adjust the iterative learning. To alleviate this limitation, we formulate a principled Degradation-Aware Unfolding Framework (DAUF) as depicted in Fig. 2. DAUF starts from the MAP theory. In particular, the original HSI signal could be estimated by minimizing the following energy function as
|
| 58 |
+
|
| 59 |
+
$$
|
| 60 |
+
\hat { \mathbf { x } } = \arg \operatorname* { m i n } _ { \mathbf { x } } \frac { 1 } { 2 } | | \mathbf { y } - \boldsymbol { \Phi } \mathbf { x } | | ^ { 2 } + \tau R ( \mathbf { x } ) ,
|
| 61 |
+
$$
|
| 62 |
+
|
| 63 |
+
where $\frac { 1 } { 2 } | | \mathbf { y } - \Phi \mathbf { x } | | ^ { 2 }$ is the data fidelity term, $R ( \mathbf { x } )$ is the image prior term, and $\tau$ is a hyperparameter balancing the importance. By introducing an auxiliary variable $\mathbf { z }$ , Eq. (2) can be reformulated as
|
| 64 |
+
|
| 65 |
+
$$
|
| 66 |
+
\hat { \mathbf { x } } = \arg \operatorname* { m i n } _ { \mathbf { x } } ~ \frac { 1 } { 2 } | | \mathbf { y } - \boldsymbol { \Phi } \mathbf { x } | | ^ { 2 } + \tau R ( \mathbf { z } ) , \quad s . t . ~ \mathbf { z } = \mathbf { x } .
|
| 67 |
+
$$
|
| 68 |
+
|
| 69 |
+
This is a constrained optimization problem. To obtain an unfolding inference, we adopt half-quadratic splitting (HQS) algorithm for its simplicity and fast convergence. Then Eq. (3) is solved by minimizing
|
| 70 |
+
|
| 71 |
+
$$
|
| 72 |
+
\mathcal { L } _ { \mu } ( \mathbf { x } , \mathbf { z } ) = \frac { 1 } { 2 } | | \mathbf { y } - \boldsymbol { \Phi } \mathbf { x } | | ^ { 2 } + \tau R ( \mathbf { z } ) + \frac { \mu } { 2 } | | \mathbf { z } - \mathbf { x } | | ^ { 2 } ,
|
| 73 |
+
$$
|
| 74 |
+
|
| 75 |
+
where $\mu$ is a penalty parameter that forces $\mathbf { x }$ and $\mathbf { z }$ to approach the same fixed point. Subsequently, Eq. (4) can be solved by decoupling $\mathbf { x }$ and $\mathbf { z }$ into the following two iterative sub-problems as
|
| 76 |
+
|
| 77 |
+
$$
|
| 78 |
+
\mathbf { x } _ { k + 1 } = \arg \operatorname* { m i n } _ { \mathbf { x } } ~ | | \mathbf { y } - \Phi \mathbf { x } | | ^ { 2 } + \mu | | \mathbf { x } - \mathbf { z } _ { k } | | ^ { 2 } , ~ \mathbf { z } _ { k + 1 } = \arg \operatorname* { m i n } _ { \mathbf { z } } \frac { \mu } { 2 } | | \mathbf { z } - \mathbf { x } _ { k + 1 } | | ^ { 2 } + \tau R ( \mathbf { z } ) ,
|
| 79 |
+
$$
|
| 80 |
+
|
| 81 |
+
where $k = 0 , 1 , \ \dots , K - 1$ indexes the iteration. Note that the data fidelity term is associated with a quadratic regularized least-squares problem, i.e., $\mathbf { x } _ { k + 1 }$ in Eq. (5). It has a closed-form solution as
|
| 82 |
+
|
| 83 |
+
$$
|
| 84 |
+
\mathbf { x } _ { k + 1 } = ( \Phi ^ { \mathsf { T } } \Phi + \mu \mathbf { I } ) ^ { - 1 } ( \Phi ^ { \mathsf { T } } \mathbf { y } + \mu \mathbf { z } _ { k } ) ,
|
| 85 |
+
$$
|
| 86 |
+
|
| 87 |
+
where $\mathbf { I }$ is an identity matrix. Since $\Phi$ is a fat matrix, $( \Phi ^ { \mathsf { T } } \Phi + \mu \mathbf { I } )$ will be large and thus we simplify the computation of the inverse problem $( \Phi ^ { \mathsf { T } } \Phi + \mu \mathbf { I } ) ^ { - 1 }$ by the matrix inversion formula as
|
| 88 |
+
|
| 89 |
+
$$
|
| 90 |
+
( \Phi ^ { \mathsf { T } } \Phi + \mu \mathbf { I } ) ^ { - 1 } = \mu ^ { - 1 } \mathbf { I } - \mu ^ { - 1 } \Phi ^ { \mathsf { T } } ( \mathbf { I } + \Phi \mu ^ { - 1 } \Phi ^ { \mathsf { T } } ) ^ { - 1 } \Phi \mu ^ { - 1 } .
|
| 91 |
+
$$
|
| 92 |
+
|
| 93 |
+
By plugging Eq. (7) into Eq. (6), we can reformulate Eq. (6) as
|
| 94 |
+
|
| 95 |
+
$$
|
| 96 |
+
\mathbf { x } _ { k + 1 } = { \frac { \Phi ^ { \mathsf { T } } \mathbf { y } + \mu \mathbf { z } _ { k } } { \mu } } - { \frac { \Phi ^ { \mathsf { T } } ( \mathbf { I } + \Phi \mu ^ { - 1 } \Phi ^ { \mathsf { T } } ) ^ { - 1 } \Phi \Phi ^ { \mathsf { T } } \mathbf { y } } { \mu ^ { 2 } } } - { \frac { \Phi ^ { \mathsf { T } } ( \mathbf { I } + \Phi \mu ^ { - 1 } \Phi ^ { \mathsf { T } } ) ^ { - 1 } \Phi \mathbf { z } _ { k } } { \mu } } ~ .
|
| 97 |
+
$$
|
| 98 |
+
|
| 99 |
+
In CASSI systems, $\Phi \Phi ^ { \mathsf { T } }$ is a diagonal matrix which can be defined as $\Phi \Phi ^ { \mathsf { T } } \stackrel { \mathrm { d e f } } { = } \mathrm { d i a g } \{ \psi _ { 1 } , \hdots , \psi _ { n } \}$ . By plugging $\Phi \Phi ^ { \mathsf { T } }$ into $( \mathbf { I } + \pmb { \Phi } \pmb { \mu } ^ { - 1 } \pmb { \Phi } ^ { \mathsf { T } } ) ^ { - 1 }$ and $( \mathbf { I } + \pmb { \Phi } \pmb { \mu } ^ { - 1 } \pmb { \Phi } ^ { \mathsf { T } } ) ^ { - 1 } \pmb { \Phi } \pmb { \Phi } ^ { \mathsf { T } }$ , we obtain:
|
| 100 |
+
|
| 101 |
+
$$
|
| 102 |
+
\begin{array} { r l r } & { } & { ( { \bf I } + \Phi \mu ^ { - 1 } \Phi ^ { \mathsf { T } } ) ^ { - 1 } = \mathsf { d i a g } \Big \{ \displaystyle \frac { \mu } { \mu + \psi _ { 1 } } , \ldots , \displaystyle \frac { \mu } { \mu + \psi _ { n } } \Big \} , } \\ & { } & { ( { \bf I } + \Phi \mu ^ { - 1 } \Phi ^ { \mathsf { T } } ) ^ { - 1 } \Phi \Phi ^ { \mathsf { T } } = \mathsf { d i a g } \Big \{ \displaystyle \frac { \mu \psi _ { 1 } } { \mu + \psi _ { 1 } } , \ldots , \displaystyle \frac { \mu \psi _ { n } } { \mu + \psi _ { n } } \Big \} . } \end{array}
|
| 103 |
+
$$
|
| 104 |
+
|
| 105 |
+
Let $\mathbf { y } \ { \stackrel { \mathrm { d e f } } { = } } \ [ y _ { 1 } , \dots , y _ { n } ] ^ { \mathsf { T } }$ and $[ \Phi \mathbf { z } _ { k } ] _ { i }$ denotes the $i$ -th element of $\Phi \mathbf { z } _ { k }$ . We plug Eq. (9) into Eq. (8) as
|
| 106 |
+
|
| 107 |
+
$$
|
| 108 |
+
\begin{array} { l } { { \displaystyle { \bf x } _ { k + 1 } = \frac { { \bf \Phi } { \bf \Phi } ^ { \mathsf { T } } { \bf y } } { \mu } + { \bf z } _ { k } - \frac { 1 } { \mu } { \bf \Phi } ^ { \mathsf { T } } \Big [ \frac { y _ { 1 } \psi _ { 1 } + \mu [ { \bf \Phi } { \bf z } _ { k } ] _ { 1 } } { \mu + \psi _ { 1 } } , \ldots , \frac { y _ { n } \psi _ { n } + \mu [ { \bf \Phi } { \bf z } _ { k } ] _ { n } } { \mu + \psi _ { n } } \Big ] ^ { \mathsf { T } } } } \\ { { \displaystyle ~ = { \bf z } _ { k } + { \bf \Phi } ^ { \mathsf { T } } \Big [ \frac { y _ { 1 } - [ { \bf \Phi } { \bf z } _ { k } ] _ { 1 } } { \mu + \psi _ { 1 } } , \ldots , \frac { y _ { n } - [ { \bf \Phi } { \bf z } _ { k } ] _ { n } } { \mu + \psi _ { n } } \Big ] ^ { \mathsf { T } } } . } \end{array}
|
| 109 |
+
$$
|
| 110 |
+
|
| 111 |
+
Note that $\{ y _ { i } - [ \Phi \mathbf { z } _ { k } ] _ { i } \} _ { i = 1 } ^ { n }$ can be directly updated by $\mathbf { y } - \Phi \mathbf { z } _ { k }$ , and $\{ \psi _ { i } \} _ { i = 1 } ^ { n }$ is pre-calculated and stored in $\Phi \Phi ^ { \mathsf { T } }$ . Thus, by element-wise computation in Eq. (10), $\mathbf { x } _ { k + 1 }$ can be updated very efficiently. According to Eq. (5), the penalty parameter $\mu$ should be large enough so that $\mathbf { x }$ and $\mathbf { z }$ can approach approximately the same fixed point. This indicates that $\mu$ controls the convergence and output of each iteration. Thus, instead of manually tweaking $\mu$ , we set $\mu$ as a series of iteration-specific parameters to be automatically estimated from the CASSI system. We denote $\mu$ in the $k$ -th iteration as $\mu _ { k }$ .
|
| 112 |
+
|
| 113 |
+
Returning to Eq. (5), we also set $\tau$ as iteration-specific parameters and ${ \mathbf z } _ { k + 1 }$ can be reformulated as
|
| 114 |
+
|
| 115 |
+
$$
|
| 116 |
+
\mathbf { z } _ { k + 1 } = \arg \operatorname* { m i n } _ { \mathbf { z } } \ { \frac { 1 } { 2 ( { \sqrt { \tau _ { k + 1 } / \mu _ { k + 1 } } } ) ^ { 2 } } } \left| | \mathbf { z } - \mathbf { x } _ { k + 1 } | \right| ^ { 2 } + R ( \mathbf { z } ) .
|
| 117 |
+
$$
|
| 118 |
+
|
| 119 |
+
From the perspective of Bayesian probability, Eq. (11) is equivalent to denoising image $\mathbf { x } _ { k + 1 }$ with a Gaussian noise at level pτk+1/µk+1 [29]. To conveniently solve Eq. (11), we set $\begin{array} { r } { \frac { 1 } { ( \sqrt { \tau _ { k + 1 } / \mu _ { k + 1 } } ) ^ { 2 } } = } \end{array}$ $\mu _ { k + 1 } / \tau _ { k + 1 }$ as parameters to be estimated from CASSI. Let $\alpha _ { k } \ { \stackrel { \mathrm { d e f } } { = } } \ \mu _ { k }$ , ${ \pmb { \alpha } } \ { \stackrel { \mathrm { d e f } } { = } } \ [ \alpha _ { 1 } , . . . , \alpha _ { K } ]$ , βk def = $\mu _ { k } / \tau _ { k }$ , and $\beta \stackrel { \mathrm { d e f } } { = } [ \beta _ { 1 } , . . . , \beta _ { K } ]$ . Then we can formulate our DAUF as an iterative scheme:
|
| 120 |
+
|
| 121 |
+
$$
|
| 122 |
+
\begin{array} { r } { ( \alpha , \beta ) = \mathcal { E } ( \mathbf { y } , \Phi ) , \quad \mathbf { x } _ { k + 1 } = \mathcal { P } ( \mathbf { y } , \mathbf { z } _ { k } , \alpha _ { k + 1 } , \Phi ) , \quad \mathbf { z } _ { k + 1 } = \mathcal { D } ( \mathbf { x } _ { k + 1 } , \beta _ { k + 1 } ) , } \end{array}
|
| 123 |
+
$$
|
| 124 |
+
|
| 125 |
+
where $\mathcal { E }$ denotes the parameter estimator that takes the compressed measurement $\mathbf { y }$ and the sensing matrix $\Phi$ of the CASSI system as inputs, $\mathcal { P }$ equivalent to Eq. (10) denotes the linear projection, and $\mathcal { D }$ represents the Gaussian denoiser solving Eq. (11). $\mathbf { z } _ { 0 }$ is initialized by passing the shifted $\mathbf { y }$ concatenated with $\Phi$ through a $c o n v 1 \times 1$ (convolution with $1 \times 1$ kernel). Fig. 2 shows the architecture of $\mathcal { E }$ . It consists of a $c o n v 1 \times 1 .$ , a strided $c o n v 3 \times 3$ , a global average pooling, and three fully connected layers. Through $\mathcal { E }$ , DAUF captures critical cues from CASSI by learning the degradation patterns and ill-posedness degree caused by the mask-modulation and dispersionintegration. Parameters $_ { \pmb { \alpha } }$ and $\beta$ estimated by $\mathcal { E }$ direct the iterative learning by adaptively scaling the linear projection in Eq. (10) and providing noise level information for the denoiser prior in Eq. (11).
|
| 126 |
+
|
| 127 |
+
# 2.3 Half-Shuffle Transformer
|
| 128 |
+
|
| 129 |
+
When designing the denoiser prior, previous deep unfolding methods [34, 35, 36, 37] mainly adopt CNNs, showing limitations in capturing long-range dependencies. Directly applying local and global Transformers will encounter two problems, i.e., limited receptive fields and nontrivial computational costs. To address these challenges, we propose Half-Shuffle Transformer (HST) to play the role of $\mathcal { D }$ .
|
| 130 |
+
|
| 131 |
+
Network Architecture. As shown in Fig. 3 (a), HST adopts a three-level U-shaped structure built by the basic unit Half-Shuffle Attention Block (HSAB). Firstly, HST uses a $c o n v 3 \times 3$ to map reshaped $\mathbf { x } _ { k }$ concatenated with stretched $\beta _ { k }$ into feature $\mathbf { X } _ { 0 } \in \mathbb { R } ^ { H \times \hat { W } \times C }$ , where $\hat { W } = W + d ( N _ { \lambda } - 1 )$ Secondly, $\mathbf { X } _ { 0 }$ passes through the encoder, bottleneck, and decoder to be embedded into deep feature $\mathbf { X } _ { d } \in \mathbb { R } ^ { H \times \hat { W } \times C }$ . Each level of the encoder or decoder contains an HSAB and a resizing module.
|
| 132 |
+
|
| 133 |
+

|
| 134 |
+
Figure 3: Diagram of HST. (a) HST adopts a U-shaped structure. (b) HSAB consists of an FFN, an HS-MSA, and two layer normalization. (c) Components of FFN. (d) HS-MSA contains local branch and non-local branch.
|
| 135 |
+
|
| 136 |
+
In Fig. 3 (b), HSAB consists of two layer normalization (LN), an HS-MSA, and a Feed-Forward Network (FFN) that is detailed in Fig. 3 (c). The downsampling and upsampling modules are strided $c o n v 4 \times 4$ and deconv $2 \times 2$ . Finally, a conv $3 \times 3$ operates on $\mathbf { X } _ { d }$ to generate a residual image $\mathbf { R } \in \mathbb { R } ^ { H \times \hat { W } \times N _ { \lambda } }$ . The output denoised image $\mathbf { z } _ { k }$ is obtained by the sum of $\mathbf { x } _ { k }$ and reshaped $\mathbf { R }$ .
|
| 137 |
+
|
| 138 |
+
Half-Shuffle Multi-head Self-Attention. The most important element of HSAB is the proposed Half-Shuffle Multi-head Self-Attention (HS-MSA) module. Fig. 3 (d) depicts the HS-MSA used in the first level. The input tokens of HS-MSA are denoted as $\mathbf { X } _ { i n } \in \mathbb { R } ^ { H \times \hat { W } \times C }$ . Subsequently, ${ \bf X } _ { i n }$ is linearly projected into query $\mathbf { Q } \in \mathbb { R } ^ { H \times \hat { W } \times C }$ , key $\mathbf { K } \in \mathbb { R } ^ { H \times \hat { W } \times C }$ , and value $\mathbf { V } \in \mathbb { R } ^ { H \times \hat { W } \times C }$ as
|
| 139 |
+
|
| 140 |
+
$$
|
| 141 |
+
\mathbf { Q } = \mathbf { X } _ { i n } \mathbf { W ^ { Q } } , \mathbf { K } = \mathbf { X } _ { i n } \mathbf { W ^ { K } } , \mathbf { V } = \mathbf { X } _ { i n } \mathbf { W ^ { V } } ,
|
| 142 |
+
$$
|
| 143 |
+
|
| 144 |
+
where $\mathbf { W ^ { Q } } , \mathbf { W ^ { K } } , \mathbf { W ^ { V } } \in \mathbb { R } ^ { C \times C }$ are learnable parameters and biases are omitted for simplification. Our HS-MSA combines the advantages of global MSA [42] and local window-based MSA [41], i.e., HS-MSA can jointly capture local contextual information through the local branch and model long-range dependencies through the non-local branch, all while being computationally cheaper than global MSA. Specifically, $\mathbf { Q } , \mathbf { K } , \mathbf { V }$ are split into two equal parts along the channel dimension as
|
| 145 |
+
|
| 146 |
+
$$
|
| 147 |
+
\mathbf { Q } = [ \mathbf { Q } _ { l } , \mathbf { Q } _ { n l } ] , ~ \mathbf { K } = [ \mathbf { K } _ { l } , \mathbf { K } _ { n l } ] , ~ \mathbf { V } = [ \mathbf { V } _ { l } , \mathbf { V } _ { n l } ] ,
|
| 148 |
+
$$
|
| 149 |
+
|
| 150 |
+
where $\mathbf { Q } _ { l } , \mathbf { K } _ { l } , \mathbf { V } _ { l } \ \in \ \mathbb { R } ^ { H \times \hat { W } \times \frac { C } { 2 } }$ are fed into the local branch to capture local contents, while ${ \bf Q } _ { n l } , { \bf K } _ { n l } , { \bf V } _ { n l } \in \mathbb { R } ^ { H \times { \hat { W } } \times \frac { C } { 2 } }$ pass through the non-local branch to model non-local dependencies.
|
| 151 |
+
|
| 152 |
+
Local Branch. The local branch computes MSA within position-specific windows. As shown in the upper path of Fig. 3 (d), $\mathbf { Q } _ { l } , \mathbf { K } _ { l } , \mathbf { V } _ { l }$ are partitioned into non-overlapping windows of size $M \times M$ . Then they are reshaped into $\begin{array} { r } { \mathbb { R } ^ { \frac { H \hat { W } } { M ^ { 2 } } \times M ^ { 2 } \times \frac { C } { 2 } } } \end{array}$ . Subsequently, $\mathbf { Q } _ { l } , \mathbf { K } _ { l } , \mathbf { V } _ { l }$ are split along the channel wise into $h$ heads: $\mathbf { \bar { Q } } _ { l } = [ \mathbf { Q } _ { l } ^ { 1 } , \dots , \mathbf { Q } _ { l } ^ { h } \ ]$ ], $\mathbf { K } _ { l } = [ \dot { \mathbf { K } } _ { l } ^ { 1 } , \dot { \mathbf { \Omega } } . \dot { \mathbf { \Omega } } . \mathbf { K } _ { l } ^ { h } ]$ , and $\mathbf { V } _ { l } = \left[ \mathbf { V } _ { l } ^ { 1 } , \ldots , \mathbf { V } _ { l } ^ { h } \right]$ . The dimension of each head is $\begin{array} { r } { d _ { h } = \frac { C } { 2 h } } \end{array}$ l l l l. Note that Fig. 3 (d) depicts the situation with $h = 1$ l and some details are omitted for simplification. The local self-attention $\mathbf { A } _ { l } ^ { i }$ is calculated inside each head as
|
| 153 |
+
|
| 154 |
+
$$
|
| 155 |
+
\mathbf { A } _ { l } ^ { i } = \operatorname { s o f t m a x } ( \frac { \mathbf { Q } _ { l } ^ { i } \mathbf { \mathbf { K } } _ { l } ^ { i ^ { \top } } } { \sqrt { d _ { h } } } + \mathbf { P } _ { l } ^ { i } ) \mathbf { V } _ { l } ^ { i } , i = 1 , \ldots , h ,
|
| 156 |
+
$$
|
| 157 |
+
|
| 158 |
+
where $\mathbf { P } _ { l } ^ { i } \in \mathbb { R } ^ { M ^ { 2 } \times M ^ { 2 } }$ are learnable parameters embedding the position information.
|
| 159 |
+
|
| 160 |
+
Non-local Branch. The non-local branch computes cross-window interactions through shuffle operations inspired by ShuffleNet [59]. In particular, ${ \bf Q } _ { n l } , { \bf K } _ { n l } , { \bf V } _ { n l } \in \mathbb { R } ^ { H \times \hat { W } \times \frac { C } { 2 } }$ are firstly partitioned into non-overlapping windows with size $M \times M$ . Then their shapes are transposed from $\begin{array} { r } { \mathbb { R } ^ { \frac { H \hat { W } } { M ^ { 2 } } \times M ^ { 2 } \times \frac { C } { 2 } } } \end{array}$ to $\begin{array} { r } { \mathbb { R } ^ { M ^ { 2 } \times \frac { H \hat { W } } { M ^ { 2 } } \times \frac { C } { 2 } } } \end{array}$ to shuffle the positions of tokens and establish inter-window dependencies. $\mathbf { Q } _ { n l } , \mathbf { K } _ { n l } , \mathbf { V } _ { n l }$ are split into $h$ heads: $\mathbf { Q } _ { n l } = [ \mathbf { Q } _ { n l } ^ { 1 } , \ldots , \mathbf { Q } _ { n l } ^ { h } ]$ , ${ \bf K } _ { n l } = [ { \bf K } _ { n l } ^ { 1 } , \ldots , { \bf K } _ { n l } ^ { \hat { h } } ]$ , and ${ { \bf { V } } _ { n l } } = [ { \bf { V } } _ { n l } ^ { 1 } , . . . , { \bf { V } } _ { n l } ^ { h } ]$ . Then the non-local self-attention $\mathbf { A } _ { n l } ^ { i }$ is computed in each head as
|
| 161 |
+
|
| 162 |
+
<table><tr><td>Algorithms</td><td>Params</td><td>GFLOPS</td><td>S1</td><td>S2</td><td>S3</td><td>S4</td><td>S5</td><td>S6</td><td>S7</td><td>S8</td><td>S9</td><td>S10</td><td>Avg</td></tr><tr><td>TwIST [60]</td><td>-</td><td>-</td><td>25.16 0.700</td><td>23.02 0.604</td><td>21.40 0.711</td><td>30.19 0.851</td><td>21.41 0.635</td><td>20.95 0.644</td><td>22.20 0.643</td><td>21.82 0.650</td><td>22.42 0.690</td><td>22.67 0.569</td><td>23.12 0.669</td></tr><tr><td>GAP-TV [26]</td><td>-</td><td>-</td><td>26.82 0.754</td><td>22.89 0.610</td><td>26.31 0.802</td><td>30.65 0.852</td><td>23.64 0.703</td><td>21.85 0.663</td><td>23.76 0.688</td><td>21.98 0.655</td><td>22.63 0.682</td><td>23.10 0.584</td><td>24.36 0.669</td></tr><tr><td>DeSCI [23]</td><td></td><td></td><td>27.13 0.748</td><td>23.04 0.620</td><td>26.62 0.818</td><td>34.96 0.897</td><td>23.94 0.706</td><td>22.38 0.683</td><td>24.45 0.743</td><td>22.03 0.673</td><td>24.56 0.732</td><td>23.59 0.587</td><td>25.27 0.721</td></tr><tr><td>λ-Net [33]</td><td>62.64M</td><td>117.98</td><td>30.10 0.849</td><td>28.49 0.805 31.09</td><td>27.73 0.870</td><td>37.01 0.934</td><td>26.19 0.817</td><td>28.64 0.853</td><td>26.47 0.806</td><td>26.09 0.831</td><td>27.50 0.826</td><td>27.13 0.816</td><td>28.53 0.841</td></tr><tr><td>HSSP [35]</td><td>-</td><td>-</td><td>31.48 0.858 31.72</td><td>0.842 31.13</td><td>28.96 0.823 29.99</td><td>34.56 0.902</td><td>28.53 0.808</td><td>30.83 0.877</td><td>28.71 0.824</td><td>30.09 0.881</td><td>30.43 0.868</td><td>28.78 0.842</td><td>30.35 0.852</td></tr><tr><td>DNU [34]</td><td>1.19M</td><td>163.48</td><td>0.863 32.68</td><td>0.846 27.26</td><td>0.845 31.30</td><td>35.34 0.908</td><td>29.03 0.833</td><td>30.87 0.887</td><td>28.99 0.839</td><td>30.13 0.885</td><td>31.03 0.876</td><td>29.14 0.849</td><td>30.74 0.863</td></tr><tr><td>DIP-HSI [30]</td><td>33.85M</td><td>64.42</td><td>0.890 32.03</td><td>0.833 31.00</td><td>0.914 32.25</td><td>40.54 0.962 39.19</td><td>29.79 0.900</td><td>30.39 0.877</td><td>28.18 0.913 30.32</td><td>29.44 0.874</td><td>34.51 0.927 30.01</td><td>28.51 0.851</td><td>31.26 0.894</td></tr><tr><td>TSA-Net [20]</td><td>44.25M</td><td>110.06</td><td>0.892 33.26</td><td>0.858 32.09</td><td>0.915</td><td>0.953</td><td>29.39 0.884</td><td>31.44 0.908</td><td>0.878</td><td>29.35 0.888</td><td>0.890</td><td>29.59 0.874</td><td>31.46 0.894</td></tr><tr><td>DGSMP [38]</td><td>3.76M</td><td>646.65</td><td>0.915</td><td>0.898 33.26</td><td>33.06 0.925 34.28</td><td>40.54 0.964</td><td>28.86 0.882</td><td>33.08 0.937</td><td>30.74 0.886</td><td>31.55 0.923</td><td>31.66 0.911</td><td>31.44 0.925</td><td>32.63 0.917</td></tr><tr><td>GAP-Net [36]</td><td>4.27M</td><td>78.58</td><td>33.74 0.911 34.12</td><td>0.900 33.62</td><td>0.929 35.04</td><td>41.03 0.967</td><td>31.44 0.919</td><td>32.40 0.925</td><td>32.27 0.902</td><td>30.46 0.905</td><td>33.51 0.915</td><td>30.24 0.895</td><td>33.26 0.917</td></tr><tr><td>ADMM-Net [37]</td><td>4.27M</td><td>78.58</td><td>0.918 35.14</td><td>0.902 35.67</td><td>0.931 36.03</td><td>41.15 0.966 42.30</td><td>31.82 0.922</td><td>32.54 0.924 34.46</td><td>32.42 0.896 33.67</td><td>30.74 0.907</td><td>33.75 0.915 34.89</td><td>30.68 0.895</td><td>33.58 0.918</td></tr><tr><td>HDNet [32]</td><td>2.37M</td><td>154.76</td><td>0.935 35.40</td><td>0.940 35.87</td><td>0.943 36.51</td><td>0.969 42.27</td><td>32.69 0.946</td><td>0.952</td><td>0.926</td><td>32.48 0.941</td><td>0.942 35.39</td><td>32.38 0.937</td><td>34.97 0.943</td></tr><tr><td>MST-L [61]</td><td>2.03M</td><td>28.15</td><td>0.941 35.80</td><td>0.944 36.23</td><td>0.953 37.34</td><td>0.973 42.63</td><td>32.77 0.947</td><td>34.80 0.955</td><td>33.66 0.925 34.35</td><td>32.67 0.948 33.71</td><td>0.949 36.67</td><td>32.50 0.941</td><td>35.18 0.948</td></tr><tr><td>MST++ [62]</td><td>1.33M</td><td>19.42</td><td>0.943 35.96</td><td>0.947 36.84</td><td>0.957 38.16</td><td>0.973 42.44</td><td>33.38 0.952</td><td>35.38 0.957 35.72</td><td>0.934 34.86</td><td>0.953 34.34</td><td>0.953 36.51</td><td>33.38 0.945 33.09</td><td>35.99 0.951</td></tr><tr><td>CST-L [62]</td><td>3.00M</td><td>40.01</td><td>0.949 36.79</td><td>0.955 37.89</td><td>0.962 40.61</td><td>0.975 46.94</td><td>33.25 0.955</td><td>0.963 35.30</td><td>0.944 36.58</td><td>0.961 33.96</td><td>0.957 39.47</td><td>0.945 32.80</td><td>36.12 0.957 37.58</td></tr><tr><td>BIRNAT [63]</td><td>4.40M</td><td>2122.66</td><td>0.951 35.93</td><td>0.957 36.70</td><td>0.971 37.96</td><td>0.985</td><td>35.42 0.964</td><td>0.959</td><td>0.955 34.78</td><td>0.956 33.65</td><td>0.970 37.42</td><td>0.938</td><td>0.960</td></tr><tr><td> DAUHST-2stg</td><td>1.40M</td><td>18.44</td><td>0.943 36.59</td><td>0.946 37.93</td><td>0.959 39.32</td><td>44.38 0.978</td><td>34.13 0.954</td><td>35.43 0.957</td><td>0.940</td><td>0.950</td><td>0.955 38.54</td><td>33.07 0.941</td><td>36.34 0.952</td></tr><tr><td>DAUHST-3stg</td><td>2.08M</td><td>27.17</td><td>0.949 36.92</td><td>0.958 38.52</td><td>0.964 40.51</td><td>44.77 0.980</td><td>34.82 0.961</td><td>36.19 0.963</td><td>36.02 0.950</td><td>34.28 0.956 34.74</td><td>0.963 38.71</td><td>33.67 0.947</td><td>37.21 0.959</td></tr><tr><td>DAUHST-5stg</td><td>3.44M</td><td>44.61</td><td>0.955</td><td>0.962</td><td>0.967</td><td>45.09 0.980</td><td>35.33 0.964</td><td>36.56 0.965</td><td>36.82 0.958</td><td>0.959</td><td>0.963</td><td>34.27 0.952</td><td>37.75 0.962</td></tr><tr><td>DAUHST-9stg</td><td>6.15M</td><td>79.50</td><td>37.25 0.958</td><td>39.02 0.967</td><td>41.05 0.971</td><td>46.15 0.983</td><td>35.80 0.969</td><td>37.08 0.970</td><td>37.57 0.963</td><td>35.10 0.966</td><td>40.02 0.970</td><td>34.59 0.956</td><td>38.36 0.967</td></tr></table>
|
| 163 |
+
|
| 164 |
+
Table 1: Comparisons between DAUHST and SOTA methods on 10 simulation scenes $( \mathbf { S } 1 { \sim } \mathbf { S } 1 0 )$ . Params, FLOPS, PSNR (upper entry in each cell), and SSIM (lower entry in each cell) are reported.
|
| 165 |
+
|
| 166 |
+
$$
|
| 167 |
+
\mathbf { A } _ { n l } ^ { i } = \mathrm { s o f t m a x } ( \frac { \mathbf { Q } _ { n l } ^ { i } \mathbf { K } _ { n l } ^ { i } \mathsf { T } } { \sqrt { d _ { h } } } + \mathbf { P } _ { n l } ^ { i } ) \mathbf { V } _ { n l } ^ { i } , i = 1 , \ldots , h ,
|
| 168 |
+
$$
|
| 169 |
+
|
| 170 |
+
$\mathbf { A } _ { n l } ^ { i } \in \mathbb { R } ^ { M ^ { 2 } \times \frac { H \hat { W } } { M ^ { 2 } } \times d _ { h } }$ $\mathbf { P } _ { n l } ^ { i } \in \mathbb { R } ^ { \frac { H \hat { W } } { M ^ { 2 } } \times \frac { H \hat { W } } { M ^ { 2 } } }$ are learnable parameters representing thunshuffled by being transposed to shape $\mathbb { R } ^ { \frac { H \hat { W } } { M ^ { 2 } } \times M ^ { 2 } \times d _ { h } }$ edding. Subsequently,. Then the outputs of local branch in Eq. (15) and non-local branch in Eq. (16) are aggregated by a linear projection as
|
| 171 |
+
|
| 172 |
+
$$
|
| 173 |
+
\mathrm { H S - M S A } ( \mathbf { X } _ { i n } ) = \sum _ { i = 1 } ^ { h } \mathbf { A } _ { l } ^ { i } \mathbf { W } _ { l } ^ { i } + \sum _ { i = 1 } ^ { h } \mathbf { A } _ { n l } ^ { i } \mathbf { W } _ { n l } ^ { i } ,
|
| 174 |
+
$$
|
| 175 |
+
|
| 176 |
+
where $\mathbf { W } _ { l } ^ { i } , \mathbf { W } _ { n l } ^ { i } \in \mathbb { R } ^ { d _ { h } \times C }$ refer to learnable parameters. We reshape the result of Eq. (17) to obtain the output $\mathbf { X } _ { o u t } \in \mathbb { R } ^ { H \times \hat { W } \times C }$ . Instead of globally sampling all tokens, HS-MSA builds inter-window correlations by shuffle operations. The self-attention is calculated in the local window but with tokens from non-local regions. Therefore, HS-MSA is much computationally cheaper than global MSA.
|
| 177 |
+
|
| 178 |
+
# 3 Experiment
|
| 179 |
+
|
| 180 |
+
# 3.1 Experiment Setup
|
| 181 |
+
|
| 182 |
+
Similar to [20, 32, 36, 38, 61], 28 wavelengths are selected from $4 5 0 \mathrm { n m }$ to $6 5 0 \mathrm { n m }$ and derived by spectral interpolation manipulation for the HSI data. Simulation and real experiments are conducted.
|
| 183 |
+
|
| 184 |
+
Simulation Dataset. We adopt two datasets, i.e., CAVE [64] and KAIST [65] for simulation experiments. The CAVE dataset consists of 32 HSIs with spatial size $5 1 2 \times 5 1 2$ . The KAIST dataset contains 30 HSIs of spatial size $2 7 0 4 \times 3 3 7 6$ . Following the settings of [20, 32, 36, 38, 61], the CAVE dataset is adopted as the training set while 10 scenes from the KAIST dataset are selected for testing.
|
| 185 |
+
|
| 186 |
+
Real Dataset. Five real HSIs collected by the CASSI system developed in [20] are used for testing.
|
| 187 |
+
|
| 188 |
+

|
| 189 |
+
Figure 4: Simulation HSI reconstruction comparisons of Scene 2 with 4 (out of 28) spectral channels. The top-middle shows the spectral curves corresponding to the two green boxes of the RGB image. The top-right depicts the enlarged patches corresponding to the yellow boxes in the bottom HSIs. Zoom in for a better view.
|
| 190 |
+
|
| 191 |
+
Implementation Details. We implement DAUHST by Pytorch. All DAUHST models are trained with Adam [66] optimizer ( $\beta _ { 1 } = 0 . 9$ and $\beta _ { 2 } = 0 . 9 9 9 )$ ) using Cosine Annealing scheme [67] for 300 epochs on an RTX 3090 GPU. The initial learning rate is $4 \times 1 0 ^ { - 4 }$ . Patches with spatial sizes $2 5 6 \times 2 5 6$ and $6 6 0 \times 6 6 0$ are randomly cropped from the 3D HSI cubes with 28 channels as training samples for the simulation and real experiments. The shifting step $d$ in the dispersion is set to 2. The batch size is 5. We set the basic channel $C = N _ { \lambda } = 2 8$ to store HSI information. The weights of $\mathcal { D }$ in different stages are unshared. Data augmentation includes random rotation and flipping. The training objective is to minimize the Root Mean Square Error (RMSE) between reconstructed and ground-truth HSIs.
|
| 192 |
+
|
| 193 |
+
# 3.2 Quantitative Comparisons with State-of-the-Art Methods
|
| 194 |
+
|
| 195 |
+
Tab. 1 compares the results of DAUHST and 16 SOTA methods including three model-based methods (TwIST [60], GAP-TV [26], and DeSCI [23]), one $\mathrm { P n P }$ method (DIP-HSI [30]), seven E2E methods $\lambda$ -Net [33], TSA-Net [20], HDNet [32], MST [61], ${ \mathrm { M S T } } { + + }$ [62], CST [68], and BIRNAT [63]), and five deep unfolding methods (HSSP [35], DNU [34], DGSMP [38], GAP-Net [36], and ADMMNet [37]) on 10 simulation scenes. All algorithms are tested with the same settings as [38, 61].
|
| 196 |
+
|
| 197 |
+
(i) Our best model DAUHST-9stg (9-stage DAUHST) yields very impressive results, i.e., 38.36 dB in PSNR and 0.967 in SSIM. DAUHST-9stg significantly outperforms two recent SOTA methods BIRNAT [63] and MST-L [61] by 0.78 and 3.18 dB, suggesting the effectiveness of our method.
|
| 198 |
+
|
| 199 |
+
(ii) Our DAUHST models dramatically surpass SOTA methods while requiring cheaper computational and memory costs. For instance, when compared with the only one Transformer-based E2E method MST, our DAUHST-2stg outperforms MST-L by $1 . 1 6 \mathrm { d B }$ but only costs $6 8 . 9 \%$ $\left( 1 . 4 0 / 2 . 0 3 \right)$ Params and $6 5 . 5 \%$ (18.44 / 28.15) FLOPS. When compared with CNN-based E2E methods, DAUHST-3stg surpasses HDNet, TSA-Net, and $\lambda$ -Net by 2.24, 5.75, and 8.68 dB while only requiring $8 7 . 8 \%$ , $4 . 7 \%$ , $3 . 3 \%$ Params and $1 7 . 6 \%$ , $2 4 . 7 \%$ , $2 3 . 0 \%$ FLOPS. When compared with RNN-based E2E method BIRNAT, our DAUHST-5stg is 0.17 dB higher but only costs $2 . 1 \%$ FLOPS and $7 8 . 2 \%$ Params. Fig. 1 plots the PSNR-FLOPS comparisons of DAUHST and SOTA unfolding methods. DAUHST outperforms other competitors with the same number of stages by very large margins, over 4 dB.
|
| 200 |
+
|
| 201 |
+
# 3.3 Qualitative Comparisons with State-of-the-Art Methods
|
| 202 |
+
|
| 203 |
+
Simulation HSI Reconstruction. Fig. 4 depicts the simulation HSI reconstruction comparisons between our DAUHST and other SOTA methods on Scene 2 with 4 (out of 28) spectral channels. The top-right part shows the zoomed-in patches of the yellow boxes in the entire HSIs (bottom). As can be observed that our DAUHST-9stg is more favorable to reconstruct visually pleasant HSIs with more detailed contents, cleaner textures, and fewer artifacts while preserving the spatial smoothness of homogeneous regions. In contrast, previous methods either yield over-smooth results compromising fine-grained structures, or introduce undesired chromatic artifacts and blotchy textures that are absent in the ground truth (GT). The top-middle part illustrates the density-wavelength spectral curves corresponding to the green boxes identified as $a$ and $^ b$ in the RGB image (top-left). The spectral curves of DAUHST-9stg achieve the highest correlation and coincidence with the reference curves, showing the advantage of our proposed DAUHST in spectral-dimension consistency reconstruction.
|
| 204 |
+
|
| 205 |
+

|
| 206 |
+
Figure 5: Real HSI reconstruction results of DAUHST-3stg and 9 SOTA methods on Scene 1 with 4 (out of 28) spectra. Only our method can clearly reconstruct the picked flower at all wavelengths. Zoom in for a better view.
|
| 207 |
+
|
| 208 |
+
Real HSI Reconstruction. We further evaluate the effectiveness of DAUHST in real HSI reconstruction. Following the same settings as [20, 38, 61] for a fair comparison, we re-train DAUHST-3stg with the real mask on the CAVE and KAIST datasets jointly. To simulate the real imaging situations, the training samples are also injected with 11-bit shot noise. Fig. 5 shows the visual comparisons between our DAUHST-3stg and nine SOTA methods. In the top three rows, only our DAUHST-3stg can reconstruct the flower patch corresponding to the yellow box at all wavelengths while other methods all fail to recover the entire patch. In the bottom row, DAUHST-3stg restores more HSI structural details and clearer contents with fewer artifacts. In contrast, other methods recover blurry images, generate incomplete responses, and are susceptible to the noise corruption. This evidence suggests that DAUHST is more robust to the noise distortion and more effective in real HSI reconstruction.
|
| 209 |
+
|
| 210 |
+
# 3.4 Ablation Study
|
| 211 |
+
|
| 212 |
+
Break-down Ablation. We adopt baseline-1 that is derived by removing HS-MSA and DAUF from DAUHST-3stg to conduct the break-down ablation. Our goal is to study the effect of each component towards higher performance. Baseline-1 is cascaded end to end by three single-stage networks. As shown in Tab. 2a, baseline-1 achieves 33.05 dB. When we respectively apply DAUF and HS-MSA, the model achieves 2.32 and $2 . 4 4 \ : \mathrm { d B }$ improvements. When we exploit DAUF and HS-MSA jointly, the model gains by 4.16 dB. These results demonstrate the effectiveness of our DAUF and HS-MSA.
|
| 213 |
+
|
| 214 |
+
Self-Attention Mechanism. To compare HS-MSA with other MSAs, we adopt baseline-2 that is obtained by removing HS-MSA from DAUHST-1stg to conduct the ablation in Tab. 2b. We remove different position embedding schemes to avoid their impacts and only compare MSAs. For fairness, we keep the Params of MSAs the same by fixing the number of channels and heads. Baseline-2 yields 32.79 dB. We apply global MSA (G-MSA) [42], Swin MSA (SW-MSA) [41], Spectral-wise MSA (S-MSA) [61], and HS-MSA. Note that we downsample the input feature maps of G-MSA to avoid memory bottlenecks. As shown in Tab. 2b, HS-MSA yields the most significant improvement of 1.26 dB, which is 0.42, 0.30, and $0 . 2 3 \mathrm { d B }$ higher than G-MSA, SW-MSA, and S-MSA. This superiority is mainly derived from HS-MSA’s ability to jointly capture local contents and non-local dependencies.
|
| 215 |
+
|
| 216 |
+
Unfolding Framework. We compare our DAUF with previous unfolding frameworks including DNU [34], ADMM-Net [37], and GAP-Net [36]. For a fair comparison, we replace each single-stage network of DNU, ADMM-Net, and GAP-Net by our HST. 3-stage architecture is adopted to conduct ablations. The results are shown in Tab. 2c. Our DAUF significantly outperforms DNU, ADMM, and GAP by 2.59, 1.69, and 1.63 dB while adding only 0.05M Params and 0.94G FLOPS. This is mainly because DAUF uses the parameters estimated from the compressed measurement and physical mask in the CASSI system to direct the iterative learning. These parameters capture critical information of CASSI degradation patterns and ill-posedness degree, providing key cues for HSI reconstruction.
|
| 217 |
+
|
| 218 |
+
Figure 6: Visualization of $\mathbf { z } _ { k }$ and $\mathbf { x } _ { k }$ with 4 (out of 28) spectral channels on Scene 1 in different iterations. The bottom-left corner plots the curves of $_ { \pmb { \alpha } }$ and $\beta$ changing with the iteration. Please zoom in for a better view.
|
| 219 |
+
|
| 220 |
+
<table><tr><td>Baseline-1</td><td>DAUF</td><td>HS-MSA</td><td>PSNR</td><td>SSIM</td><td>Params (M)</td><td>FLOPS (G)</td></tr><tr><td>√</td><td></td><td></td><td>33.05</td><td>0.912</td><td>1.06</td><td>17.62</td></tr><tr><td>√</td><td>√</td><td></td><td>35.37</td><td>0.938</td><td>1.11</td><td>18.55</td></tr><tr><td>√</td><td></td><td>√</td><td>35.49</td><td>0.941</td><td>2.03</td><td>26.23</td></tr><tr><td>√</td><td>√</td><td>√</td><td>37.21</td><td>0.959</td><td>2.08</td><td>27.17</td></tr></table>
|
| 221 |
+
|
| 222 |
+
(b) Ablation of various self-attention mechanisms.
|
| 223 |
+
|
| 224 |
+
<table><tr><td>Method</td><td>Baseline-2</td><td>G-MSA</td><td>SW-MSA</td><td>S-MSA</td><td>HS-MSA</td></tr><tr><td>PSNR</td><td>32.79</td><td>33.63</td><td>33.75</td><td>33.82</td><td>34.05</td></tr><tr><td>SSIM</td><td>0.904</td><td>0.920</td><td>0.924</td><td>0.926</td><td>0.930</td></tr><tr><td>Params (M)</td><td>0.40</td><td>0.48</td><td>0.48</td><td>0.48</td><td>0.48</td></tr><tr><td>FLOPS (G)</td><td>6.85</td><td>10.30</td><td>9.41</td><td>8.89</td><td>9.72</td></tr></table>
|
| 225 |
+
|
| 226 |
+

|
| 227 |
+
(c) Ablation of different unfolding frameworks. (d) Ablation to study the effect of parameters $_ { \pmb { \alpha } }$ and $\beta$ . Table 2: Ablation studies on simulation datasets [64, 65]. PSNR, SSIM, Params, and FLOPS are reported.
|
| 228 |
+
|
| 229 |
+
(a) Break-down ablation towards higher performance.
|
| 230 |
+
|
| 231 |
+
<table><tr><td>Framework</td><td>DNU [34]</td><td>ADMM[37]</td><td>GAP [36]</td><td>DAUF</td></tr><tr><td>PSNR</td><td>34.62</td><td>35.52</td><td>35.58</td><td>37.21</td></tr><tr><td>SSIM</td><td>0.930</td><td>0.942</td><td>0.943</td><td>0.959</td></tr><tr><td>Params (M)</td><td>2.03</td><td>2.03</td><td>2.03</td><td>2.08</td></tr><tr><td>FLOPS (G)</td><td>26.23</td><td>26.23</td><td>26.23</td><td>27.17</td></tr></table>
|
| 232 |
+
|
| 233 |
+
<table><tr><td>Baseline-3</td><td>α</td><td>β</td><td>PSNR</td><td>SSIM</td><td>Params (M)</td><td>FLOPS (G)</td></tr><tr><td>√</td><td></td><td></td><td>36.49</td><td>0.952</td><td>2.03</td><td>26.23</td></tr><tr><td>√</td><td>√</td><td></td><td>36.94</td><td>0.957</td><td>2.08</td><td>27.10</td></tr><tr><td>广</td><td></td><td>√</td><td>36.83</td><td>0.956</td><td>2.08</td><td>27.17</td></tr><tr><td></td><td>√</td><td>√</td><td>37.21</td><td>0.959</td><td>2.08</td><td>27.17</td></tr></table>
|
| 234 |
+
|
| 235 |
+
To study the effect of the estimated parameters $_ { \pmb { \alpha } }$ and $\beta$ , we perform a break-down ablation of DAUF. We adopt DAUHST-3stg as baseline-3 but $_ { \pmb { \alpha } }$ is set as learnable parameters instead of being estimated by $\mathcal { E }$ in Eq. (12) and $\beta$ is not fed into $\mathcal { D }$ . The results are shown in Tab. 2d. Baseline-3 yields 36.49 dB. When $_ \alpha$ is set to be estimated by $\mathcal { E }$ , baseline-3 is improved by 0.45 dB. When $\beta$ is fed into $\mathcal { D }$ , baseline-3 gains by $0 . 3 4 \mathrm { d B }$ . When $_ { \pmb { \alpha } }$ and $\beta$ are exploited jointly in the iterative learning, baseline-3 achieves a significant improvement of 0.72 dB. These results verify that the estimated parameters $_ \alpha$ and $\beta$ are beneficial for the linear projection and denoising network of deep unfolding methods.
|
| 236 |
+
|
| 237 |
+
To further analyze the roles of the estimated parameters, we visualize $\mathbf { z } _ { k }$ and $\mathbf { x } _ { k }$ of Eq. (12), and plot the curves of $_ \alpha$ and $\beta$ as they change with the iteration in Fig. 6. We observe: (i) $\mathbf { z } _ { 0 }$ and $\mathbf { x } _ { 1 }$ yield either blurry or noisy images. There is a significant gap between them. Since $\alpha _ { k } = \mu _ { k }$ in Eq. (5) penalizes the differences between $\mathbf { z }$ and x, $\alpha _ { 1 }$ is estimated to be a large value. From the linear projection of the second iteration $( \mathbf { z } _ { 1 } \mathbf { x } _ { 2 } ,$ ) on, the gap between $\mathbf { z }$ and $\mathbf { x }$ decreases substantially. Therefore, $\alpha _ { k }$ are estimated to be small values when $k \geq 2$ . This indicates that $_ { \pmb { \alpha } }$ can adaptively scale the linear projection $\mathcal { P }$ . (ii) The noise corruption is severe in the first iteration. Thus, $\beta _ { 1 } =$ $\mu _ { 1 } / \tau _ { 1 } = 1 / ( \sqrt { \tau _ { 1 } / \mu _ { 1 } } ) ^ { 2 }$ , which is inversely proportional to the noise level, is estimated to be a small value. With further iterations, the noise level decreases, and thus the estimated $\beta _ { k }$ increases. These results demonstrate that $\beta$ can provide the information about noise level for the denoising network $\mathcal { D }$ .
|
| 238 |
+
|
| 239 |
+
# 4 Conclusion
|
| 240 |
+
|
| 241 |
+
In this paper, we remedy two issues of previous deep unfolding methods, i.e., they do not estimate informative parameters from the CASSI system to direct the iterative learning and they are mainly CNN-based showing limitations in capturing long-range dependencies. To cope with these challenges, we firstly formulate a principled MAP-based unfolding framework DAUF that estimates parameters from the compressed measurement and physical mask. Then the parameters, which capture critical cues of CASSI degradation patterns and ill-posedness degree, are fed into each iteration to contextually scale the linear projection and provide noise level information for the denoising network. Secondly, we propose a novel Transformer HST that can jointly extract local contents and model non-local dependencies. By plugging HST into DAUF, we derive the first Transformer-based unfolding method DAUHST for HSI reconstruction. Comprehensive experiments show that our DAUHST outperforms SOTA methods by a large margin while requiring much cheaper memory and computational costs.
|
| 242 |
+
|
| 243 |
+
# Limitation and Social Impact
|
| 244 |
+
|
| 245 |
+
The main limitation of our work is that the performance improvement of our method comes with lowering down the inference speed and increasing the model complexity. Until now, spectral snapshot compressive imaging reconstruction techniques have no negative social impact yet. Our proposed DAUHST does not present any negative foreseeable societal consequence, either.
|
| 246 |
+
|
| 247 |
+
# Acknowledgement
|
| 248 |
+
|
| 249 |
+
This work is partially supported by the NSFC fund (61831014), the Shenzhen Science and Technology Project under Grant (JSGG20210802153150005, CJGJZD20200617102601004). Xin Yuan acknowledges the support of NSFC (62271414), Westlake Foundation (2021B1501-2) and the Research Center for Industries of the Future (RCIF) at Westlake University.
|
| 250 |
+
|
| 251 |
+
# References
|
| 252 |
+
|
| 253 |
+
[1] M. Fauvel, Y. Tarabalka, J. A. Benediktsson, J. Chanussot, and J. C. Tilton, “Advances in spectral-spatial classification of hyperspectral images,” Proceedings of the IEEE, 2012. [2] E. Maggiori, G. Charpiat, Y. Tarabalka, and P. Alliez, “Recurrent neural networks to correct satellite image classification maps,” Transactions on Geoscience and Remote Sensing, 2017. [3] F. Zhang, B. Du, and L. Zhang, “Scene classification via a gradient boosting random convolutional network framework,” Transactions on Geoscience and Remote Sensing, 2015. [4] M. H. Kim, T. A. Harvey, D. S. Kittle, H. Rushmeier, R. O. P. J. Dorsey, and D. J. Brady, “3d imaging spectroscopy for measuring hyperspectral patterns on solid objects,” ACM Transactions on on Graphics, 2012. [5] Z. Pan, G. Healey, M. Prasad, and B. Tromberg, “Face recognition in hyperspectral images,” TPAMI, 2003. [6] H. V. Nguyen, A. Banerjee, and R. Chellappa, “Tracking via object reflectance using a hyperspectral video camera,” in CVPRW, 2010. [7] Y. Fu, Y. Zheng, I. Sato, and Y. Sato, “Exploiting spectral-spatial correlation for coded hyperspectral image restoration,” in CVPR, 2016.
|
| 254 |
+
[8] B. Uzkent, M. J. Hoffman, and A. Vodacek, “Real-time vehicle tracking in aerial video using hyperspectral features,” in CVPRW, 2016. [9] B. Uzkent, A. Rangnekar, and M. Hoffman, “Aerial vehicle tracking by adaptive fusion of hyperspectral likelihood maps,” in CVPRW, 2017.
|
| 255 |
+
[10] V. Backman, M. B. Wallace, L. Perelman, J. Arendt, R. Gurjar, M. Muller, Q. Zhang, G. Zonios, E. Kline, and T. McGillican, “Detection of preinvasive cancer cells,” Nature, 2000.
|
| 256 |
+
[11] G. Lu and B. Fei, “Medical hyperspectral imaging: a review,” Journal of Biomedical Optics, 2014.
|
| 257 |
+
[12] Z. Meng, M. Qiao, J. Ma, Z. Yu, K. Xu, and X. Yuan, “Snapshot multispectral endomicroscopy,” Optics Letters, 2020.
|
| 258 |
+
[13] M. Borengasser, W. S. Hungate, and R. Watkins, “Hyperspectral remote sensing: principles and applications,” CRC press, 2007.
|
| 259 |
+
[14] F. Melgani and L. Bruzzone, “Classification of hyperspectral remote sensing images with support vector machines,” IEEE Transactions on Geoscience and Remote Sensing, 2004.
|
| 260 |
+
[15] Y. Yuan, X. Zheng, and X. Lu, “Hyperspectral image superresolution by transfer learning,” IEEE Journal of Selected Topics in Applied Earth Observations and Remote Sensing, 2017.
|
| 261 |
+
[16] J. Solomon and B. Rock, “Imaging spectrometry for earth remote sensing,” Science, 1985.
|
| 262 |
+
[17] A. Wagadarikar, R. John, R. Willett, and D. Brady, “Single disperser design for coded aperture snapshot spectral imaging,” Applied Optics, 2008.
|
| 263 |
+
[18] A. A. Wagadarikar, N. P. Pitsianis, X. Sun, and D. J. Brady, “Video rate spectral imaging using a coded aperture snapshot spectral imager,” Optics Express, 2009.
|
| 264 |
+
[19] H. Du, X. Tong, X. Cao, and S. Lin, “A prism-based system for multispectral video acquisition,” in ICCV, 2009.
|
| 265 |
+
[20] Z. Meng, J. Ma, and X. Yuan, “End-to-end low cost compressive spectral imaging with spatialspectral self-attention,” in ECCV, 2020.
|
| 266 |
+
[21] M. E. Gehm, R. John, D. J. Brady, R. M. Willett, and T. J. Schulz, “Single-shot compressive spectral imaging with a dual-disperser architecture,” Optics express, 2007.
|
| 267 |
+
[22] D. Kittle, K. Choi, A. Wagadarikar, and D. J. Brady, “Multiframe image estimation for coded aperture snapshot spectral imagers,” Applied optics, 2010.
|
| 268 |
+
[23] Y. Liu, X. Yuan, J. Suo, D. Brady, and Q. Dai, “Rank minimization for snapshot compressive imaging,” TPAMI, 2019.
|
| 269 |
+
[24] L. Wang, Z. Xiong, G. Shi, F. Wu, and W. Zeng, “Adaptive nonlocal sparse representation for dual-camera compressive hyperspectral imaging,” TPAMI, 2016.
|
| 270 |
+
[25] S. Zhang, L. Wang, Y. Fu, X. Zhong, and H. Huang, “Computational hyperspectral imaging based on dimension-discriminative low-rank tensor recovery,” in ICCV, 2019.
|
| 271 |
+
[26] X. Yuan, “Generalized alternating projection based total variation minimization for compressive sensing,” in ICIP, 2016.
|
| 272 |
+
[27] J. Tan, Y. Ma, H. Rueda, D. Baron, and G. R. Arce, “Compressive hyperspectral imaging via approximate message passing,” IEEE Journal of Selected Topics in Signal Processing, 2016.
|
| 273 |
+
[28] M. A. Figueiredo, R. D. Nowak, and S. J. Wright, “Gradient projection for sparse reconstruction: Application to compressed sensing and other inverse problems,” IEEE Journal of selected topics in signal processing, 2007.
|
| 274 |
+
[29] S. H. Chan, X. Wang, and O. A. Elgendy, “Plug-and-play admm for image restoration: Fixedpoint convergence and applications,” Transactions on Computational Imaging, 2016.
|
| 275 |
+
[30] Z. Meng, Z. Yu, K. Xu, and X. Yuan, “Self-supervised neural networks for spectral snapshot compressive imaging,” in ICCV, 2021.
|
| 276 |
+
[31] S. Zheng, Y. Liu, Z. Meng, M. Qiao, Z. Tong, X. Yang, S. Han, and X. Yuan, “Deep plug-andplay priors for spectral snapshot compressive imaging,” Photonics Research, 2021.
|
| 277 |
+
[32] X. Hu, Y. Cai, J. Lin, H. Wang, X. Yuan, Y. Zhang, R. Timofte, and L. V. Gool, “Hdnet: High-resolution dual-domain learning for spectral compressive imaging,” in CVPR, 2022.
|
| 278 |
+
[33] X. Miao, X. Yuan, Y. Pu, and V. Athitsos, “l-net: Reconstruct hyperspectral images from a snapshot measurement,” in ICCV, 2019.
|
| 279 |
+
[34] L. Wang, C. Sun, M. Zhang, Y. Fu, and H. Huang, “Dnu: Deep non-local unrolling for computational spectral imaging,” in CVPR, 2020.
|
| 280 |
+
[35] L. Wang, C. Sun, Y. Fu, M. H. Kim, and H. Huang, “Hyperspectral image reconstruction using a deep spatial-spectral prior,” in CVPR, 2019.
|
| 281 |
+
[36] Z. Meng, S. Jalali, and X. Yuan, “Gap-net for snapshot compressive imaging,” arXiv preprint arXiv:2012.08364, 2020.
|
| 282 |
+
[37] J. Ma, X.-Y. Liu, Z. Shou, and X. Yuan, “Deep tensor admm-net for snapshot compressive imaging,” in ICCV, 2019.
|
| 283 |
+
[38] T. Huang, W. Dong, X. Yuan, J. Wu, and G. Shi, “Deep gaussian scale mixture prior for spectral compressive imaging,” in CVPR, 2021.
|
| 284 |
+
[39] X. Zhang, Y. Zhang, R. Xiong, Q. Sun, and J. Zhang, “Herosnet: Hyperspectral explicable reconstruction and optimal sampling deep network for snapshot compressive imaging,” in CVPR, 2022.
|
| 285 |
+
[40] 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.
|
| 286 |
+
[41] 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, 2021.
|
| 287 |
+
[42] 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 ICLR, 2021.
|
| 288 |
+
[43] A. El-Nouby, H. Touvron, M. Caron, P. Bojanowski, M. Douze, A. Joulin, I. Laptev, N. Neverova, G. Synnaeve, J. Verbeek, et al., “Xcit: Cross-covariance image transformers,” arXiv preprint arXiv:2106.09681, 2021.
|
| 289 |
+
[44] X. Zhu, W. Su, L. Lu, B. Li, X. Wang, and J. Dai, “Deformable detr: Deformable transformers for end-to-end object detection,” in ICLR, 2021.
|
| 290 |
+
[45] N. Carion, F. Massa, G. Synnaeve, N. Usunier, A. Kirillov, and S. Zagoruyko, “End-to-end object detection with transformers,” in ECCV, 2020.
|
| 291 |
+
[46] X. Dai, Y. Chen, J. Yang, P. Zhang, L. Yuan, and L. Zhang, “Dynamic detr: End-to-end object detection with dynamic attention,” in ICCV, 2021.
|
| 292 |
+
[47] O. Petit, N. Thome, C. Rambour, L. Themyr, T. Collins, and L. Soler, “U-net transformer: Self and cross attention for medical image segmentation,” in International Workshop on Machine Learning in Medical Imaging, 2021.
|
| 293 |
+
[48] E. Xie, W. Wang, Z. Yu, A. Anandkumar, J. M. Alvarez, and P. Luo, “Segformer: Simple and efficient design for semantic segmentation with transformers,” in NeurIPS, 2021.
|
| 294 |
+
[49] R. Strudel, R. Garcia, I. Laptev, and C. Schmid, “Segmenter: Transformer for semantic segmentation,” in ICCV, 2021.
|
| 295 |
+
[50] Y. Li, S. Zhang, Z. Wang, S. Yang, W. Yang, S.-T. Xia, and E. Zhou, “Tokenpose: Learning keypoint tokens for human pose estimation,” in ICCV, 2021.
|
| 296 |
+
[51] S. Yang, Z. Quan, M. Nie, and W. Yang, “Transpose: Keypoint localization via transformer,” in ICCV, 2021.
|
| 297 |
+
[52] K. Li, S. Wang, X. Zhang, Y. Xu, W. Xu, and Z. Tu, “Pose recognition with cascade transformers,” in CVPR, 2021.
|
| 298 |
+
[53] H. Chen, Y. Wang, T. Guo, C. Xu, Y. Deng, Z. Liu, S. Ma, C. Xu, C. Xu, and W. Gao, “Pre-trained image processing transformer,” in CVPR, 2021.
|
| 299 |
+
[54] J. Liang, J. Cao, G. Sun, K. Zhang, L. Van Gool, and R. Timofte, “Swinir: Image restoration using swin transformer,” in ICCVW, 2021.
|
| 300 |
+
[55] Z. Wang, X. Cun, J. Bao, W. Zhou, J. Liu, and H. Li, “Uformer: A general u-shaped transformer for image restoration,” in CVPR, 2022.
|
| 301 |
+
[56] J. A. Tropp and A. C. Gilbert, “Signal recovery from random measurements via orthogonal matching pursuit,” IEEE Transactions on Information Theory, 2007.
|
| 302 |
+
[57] D. L. Donoho, “Compressed sensing,” IEEE Transactions on Information Theory, 2006.
|
| 303 |
+
[58] S. Jalali and X. Yuan, “Snapshot compressed sensing: Performance bounds and algorithms,” Transactions on Information Theory, 2019.
|
| 304 |
+
[59] X. Zhang, X. Zhou, M. Lin, and J. Sun, “Shufflenet: An extremely efficient convolutional neural network for mobile devices,” in CVPR, 2018.
|
| 305 |
+
[60] J. Bioucas-Dias and M. Figueiredo., “A new twist: Two-step iterative shrinkage/thresholding algorithms for image restoration.,” TIP, 2007.
|
| 306 |
+
[61] Y. Cai, J. Lin, X. Hu, H. Wang, X. Yuan, Y. Zhang, R. Timofte, and L. V. Gool, “Mask-guided spectral-wise transformer for efficient hyperspectral image reconstruction,” in CVPR, 2022.
|
| 307 |
+
[62] Y. Cai, J. Lin, Z. Lin, H. Wang, Y. Zhang, H. Pfister, R. Timofte, and L. V. Gool, “Mst $^ { + + }$ : Multi-stage spectral-wise transformer for efficient spectral reconstruction,” in CVPRW, 2022.
|
| 308 |
+
[63] Z. Cheng, B. Chen, R. Lu, Z. Wang, H. Zhang, Z. Meng, and X. Yuan, “Recurrent neural networks for snapshot compressive imaging,” TPAMI, 2022.
|
| 309 |
+
[64] J.-I. Park, M.-H. Lee, M. D. Grossberg, and S. K. Nayar, “Multispectral imaging using multiplexed illumination,” in ICCV, 2007.
|
| 310 |
+
[65] I. Choi, M. Kim, D. Gutierrez, D. Jeon, and G. Nam, “High-quality hyperspectral reconstruction using a spectral prior,” in Technical report, 2017.
|
| 311 |
+
[66] D. P. Kingma and J. L. Ba, “Adam: A method for stochastic optimization,” in ICLR, 2015.
|
| 312 |
+
[67] I. Loshchilov and F. Hutter, “Sgdr: Stochastic gradient descent with warm restarts,” in ICLR, 2017.
|
| 313 |
+
[68] Y. Cai, J. Lin, X. Hu, H. Wang, X. Yuan, Y. Zhang, R. Timofte, and L. V. Gool, “Coarse-to-fine sparse transformer for hyperspectral image reconstruction,” in ECCV, 2022.
|
| 314 |
+
|
| 315 |
+
# Checklist
|
| 316 |
+
|
| 317 |
+
1. For all authors...
|
| 318 |
+
|
| 319 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
|
| 320 |
+
(b) Did you describe the limitations of your work? [Yes]
|
| 321 |
+
(c) Did you discuss any potential negative societal impacts of your work? [Yes]
|
| 322 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 323 |
+
|
| 324 |
+
2. If you are including theoretical results...
|
| 325 |
+
|
| 326 |
+
(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]
|
| 327 |
+
|
| 328 |
+
3. If you ran experiments...
|
| 329 |
+
|
| 330 |
+
(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]
|
| 331 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
|
| 332 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
|
| 333 |
+
(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]
|
| 334 |
+
|
| 335 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 336 |
+
|
| 337 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes]
|
| 338 |
+
(b) Did you mention the license of the assets? [Yes]
|
| 339 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [Yes] We provide our code and models in the supplementary material
|
| 340 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [Yes]
|
| 341 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes]
|
| 342 |
+
|
| 343 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 344 |
+
|
| 345 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 346 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 347 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
md/dev/sc7bBHAmcN/sc7bBHAmcN.md
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Understanding and Extending Subgraph GNNs by Rethinking Their Symmetries
|
| 2 |
+
|
| 3 |
+
Fabrizio Frasca∗ Imperial College London & Twitter ffrasca@twitter.com
|
| 4 |
+
|
| 5 |
+
Beatrice Bevilacqua∗ Purdue University bbevilac@purdue.edu
|
| 6 |
+
|
| 7 |
+
Michael M. Bronstein University of Oxford & Twitter mbronstein@twitter.com
|
| 8 |
+
|
| 9 |
+
Haggai Maron NVIDIA Research hmaron@nvidia.com
|
| 10 |
+
|
| 11 |
+
# Abstract
|
| 12 |
+
|
| 13 |
+
Subgraph GNNs are a recent class of expressive Graph Neural Networks (GNNs) which model graphs as collections of subgraphs. So far, the design space of possible Subgraph GNN architectures as well as their basic theoretical properties are still largely unexplored. In this paper, we study the most prominent form of subgraph methods, which employs node-based subgraph selection policies such as ego-networks or node marking and deletion. We address two central questions: (1) What is the upper-bound of the expressive power of these methods? and (2) What is the family of equivariant message passing layers on these sets of subgraphs?. Our first step in answering these questions is a novel symmetry analysis which shows that modelling the symmetries of node-based subgraph collections requires a significantly smaller symmetry group than the one adopted in previous works. This analysis is then used to establish a link between Subgraph GNNs and Invariant Graph Networks (IGNs). We answer the questions above by first bounding the expressive power of subgraph methods by 3-WL, and then proposing a general family of message-passing layers for subgraph methods that generalises all previous node-based Subgraph GNNs. Finally, we design a novel Subgraph GNN dubbed SUN, which theoretically unifies previous architectures while providing better empirical performance on multiple benchmarks.
|
| 14 |
+
|
| 15 |
+
# 1 Introduction
|
| 16 |
+
|
| 17 |
+
Message Passing Neural Networks (MPNNs) are arguably the most commonly used version of Graph Neural Networks (GNNs). The limited expressive power of MPNNs [36, 55] has led to a plethora of works aimed at designing expressive GNNs while maintaining the simplicity and scalability of MPNNs [11, 39, 49, 30]. Several recent studies have proposed a new class of such architectures [14, 59, 7, 61, 43, 42], dubbed Subgraph GNNs, which apply MPNNs to collections (‘bags’) of subgraphs extracted from the original input graph and then aggregate the resulting representations. Subgraphs are selected according to a predefined policy; in the most popular ones, each subgraph is tied to a specific node in the original graph, for example by deleting it or extracting its local ego-network. Subgraph GNNs have demonstrated outstanding empirical performance, with state-of-the-art results on popular benchmarks like the ZINC molecular property prediction [61, 7].
|
| 18 |
+
|
| 19 |
+
While offering great promise, it is fair to say that we still lack a full understanding of Subgraph GNNs. Firstly, on the theoretical side, it is known that subgraph methods are strictly stronger than the Weisfeiler-Leman (WL) test [54, 39], but an upper-bound on their expressive power is generally unknown. Secondly, on a more practical level, Subgraph GNN architectures differ considerably in the way information is aggregated and shared across the subgraphs, and an understanding of the possible aggregation and sharing rules is missing. Both aspects are important: an understanding of the former can highlight the limitations of emerging architectures, a study of the latter paves the way for improved Subgraph GNNs.
|
| 20 |
+
|
| 21 |
+
Main contributions. The goal of this paper is to provide a deeper understanding of node-based Subgraph GNNs in light of the two aforementioned aspects. The main theoretical tool underpinning our contributions is a novel analysis of the symmetry group that acts on the sets of subgraphs. While several previous approaches [43, 14, 7] have (often implicitly) assumed that a subgraph architecture should be equivariant to independent node and subgraph permutations, we leverage the fact that nodebased policies induce an inherent bijection between the subgraphs and the nodes. This observation allows us to align the two groups and model the symmetry with a single (smaller) permutation group that acts on nodes and subgraphs jointly. Other works [61, 56, 59] have (again, implicitly) recognised such node-subgraph correspondence but without studying the implications on the symmetry group, and resorting, as a result, to a partial and heuristic choice of equivariant operations.
|
| 22 |
+
|
| 23 |
+
The use of this stricter symmetry group raises a fruitful connection with $k$ -order Invariant Graph Networks (k-IGNs) [33, 32], a well studied family of architectures for processing graphs and hypergraphs designed to be equivariant to the same symmetry group. This connection allows us to transfer and reinterpret previous results on IGNs to our Subgraph GNN setup. As our first contribution we show that the expressive power of Subgraph GNNs with node-based policies is bounded by that of the 3-WL test. This is shown by proving that all previous Subgraph GNNs can be implemented by a 3-IGN and by leveraging the fact that the expressive power of these models is bounded by 3-WL [21, 5].
|
| 24 |
+
|
| 25 |
+
Our second contribution is the proposal of a general layer formulation for Subgraph GNNs, based on the observation that these methods maintain an $n \times n$ representation of $n$ subgraphs with $n$ nodes, following the same symmetry structure of 2-IGNs (same permutation applied to both rows and columns of this representation). We propose a novel extension of 2-IGNs capturing both local (message-passing-like) and global operations. This extension easily recovers previous methods facilitating their comparison. Also, we present a number of new operations that previous methods did not implement. We build upon these observations to devise a new Subgraph GNN dubbed SUN, (Subgraph Union Network). We prove that SUN generalises all previous node-based Subgraph GNNs and we empirically compare it to these methods, showing it can outperform them.
|
| 26 |
+
|
| 27 |
+
# 2 Previous and related work
|
| 28 |
+
|
| 29 |
+
Expressive power of GNNs. The expressive power of GNNs is a central research focus since it was realised that message-passing type GNNs are constrained by the expressivity of the WL isomorphism test [36, 55]. Other than the aforementioned subgraph-based methods, numerous approaches for more powerful GNNs have been proposed, including positional and structural encodings [1, 45, 11, 17, 28, 31], higher-order message-passing schemes [36, 38, 10, 9], equivariant models [24, 33, 32, 53, 15, 51, 40]. We refer readers to the recent survey by Morris et al. [39] for additional details. Finally we note that, in a related and concurrent work, Qian et al. [46] propose a theoretical framework to study the expressive power of subgraph-based GNNs by relating them to the $\mathtt { k - W L }$ hierarchy, and explore how to sample subgraphs in a data-driven fashion.
|
| 30 |
+
|
| 31 |
+
Invariant graph networks. IGNs were recently introduced in a series of works by Maron et al. [33, 32, 34] as an alternative to MPNNs for processing graph and hyper-graph data. For $k \geq 2$ , $\mathtt { k }$ -IGNs represent hyper-graphs with hyper-edges up to size $k$ with $k$ -order tensor $\bar { \boldsymbol { y } } \in \mathbb { R } ^ { n ^ { k } }$ , where each entry holds information about a specific hyper-edge. On these they apply linear $S _ { n }$ -equivariant layers interspersed with pointwise nonlinearities. These models have been thoroughly studied in terms of: (i) their expressive power; (ii) the space of their equivariant linear layers. As for (i), IGNs were shown to have exactly the same graph separation power as the $\mathtt { k - W L }$ graph isomorphism test [32, 5, 21] and, for sufficiently large $k$ , to have a universal approximation property w.r.t. $S _ { n }$ -invariant and equivariant functions [34, 26, 47]. Concerning (ii), the work in [33] completely characterised the space of linear layers equivariant to $S _ { n }$ from $\mathbb { R } ^ { n ^ { k } }$ to $\mathbb { R } ^ { n ^ { k ^ { \prime } } }$ : the authors derived a basis of bel $1 ( k + k ^ { \prime } )$ linear operators consisting of indicator tensors of equality patterns over the multi-index set $\{ 1 , . . . , n \} ^ { k + k ^ { \prime } } = [ n ] ^ { k + k ^ { \prime } }$ . Albooyeh et al. [2] showed these layers can be (re-)written as sums of pooling-broadcasting operations between elements of $\mathcal { V }$ indexed by the orbits 2 of the action of $S _ { n }$ on $[ n ] ^ { k }$ and $[ n ] ^ { k ^ { \prime } }$ . Take, e.g., $k = k ^ { \prime } = 2$ . In this case there are only two orbits: $\{ i , i \} , i \in [ n ]$ corresponding to on-diagonal terms, and $\{ i , j \} , i \neq j \in [ n ] ,$ , off-diagonal terms. According to Albooyeh et al. [2] any equivariant linear layer $L : \mathbb { R } ^ { n ^ { 2 } } \to \mathbb { R } ^ { n ^ { 2 } }$ can be represented as a composition of pooling and broadcasting operations on the elements indexed by these orbits. One example is the linear map that sums the on-diagonal elements and broadcasts the result to the off-diagonal ones: $\begin{array} { r } { L ( \mathcal { Y } ) _ { i j } = \sum _ { k } \mathcal { Y } _ { k k } } \end{array}$ for $i \neq j$ , 0 otherwise. See Appendix B, for additional details. These results particularly important as they underpin most of our theoretical derivations. Lastly, a more comprehensive coverage of IGNs can be found in [39].
|
| 32 |
+
|
| 33 |
+
Subgraph GNNs. Despite motivated by diverse premises, a collection of concurrent methods share the overarching design whereby graphs are modelled through the application of a GNN to their subgraphs. Bevilacqua et al. [7] first explicitly formulated the concept of bags of subgraphs generated by a predefined policy and studied layers to process them in an equivariant manner: the same GNN can encode each subgraph independently (DS-GNN), or information can be shared between these computations in view of the alignment of nodes across the bag [35] (DSS-GNN). Building upon the Reconstruction Conjecture [25, 52], Reconstruction GNNs [14] obtain node-deleted subgraphs, process them with a GNN and then aggregate the resulting representations by means of a set model. Nested GNNs [59] and GNN-As-Kernel models (GNN-AK) [61] shift their computation from rooted subtrees to rooted subgraphs, effectively representing nodes by means of GNNs applied to their enclosing ego-networks. Similarly to DSS-GNNs [7], GNN-AK models may feature information sharing modules aggregating node representations across subgraphs. ID-GNNs [56] also process ego-network subgraphs, but their roots are ‘marked’ so to specifically alter the exchange of messages involving them. Intuitively, the use of subgraphs implicitly breaks those local symmetries which determine the notorious expressiveness bottleneck of MPNNs. We note that other works can be interpreted as Subgraph GNNs, including those by Papp et al. [43], Papp and Wattenhofer [42].
|
| 34 |
+
|
| 35 |
+
# 3 Node-based Subgraph GNNs
|
| 36 |
+
|
| 37 |
+
Notation. Let $G = ( A , X )$ be a member of the family $\mathcal { G }$ of node-attributed, undirected, finite, simple graphs3. The adjacency matrix $A \in \mathbb { R } ^ { n \times n }$ represents $G$ ’s edge set $E$ over its set of $n$ nodes $V$ . The feature matrix $\dot { X } \in \mathbb { R } ^ { \dot { n } \times d }$ gathers the node features; we denote by $x _ { j } \in \mathbb { R } ^ { d \times 1 }$ the features of node $j$ corresponding to the $j$ -th row of $X$ . $B _ { G }$ is used to denote a multiset (bag) of $m$ subgraphs of $G$ . Adjacency and feature matrices for subgraphs in $B _ { G }$ are arranged in tensors $\mathcal { A } \in \mathbb { R } ^ { m \times n \times n }$ and $\mathcal { X } \in \mathbb { R } ^ { m \times n \times d }$ . Superscript $i , ( t )$ refers to representations on subgraph $i$ at the $t$ -th layer of a stacking, as in xi,j $x _ { j } ^ { i , ( t ) }$ . Finally, we denote $[ n ] = \{ 1 , \dots , n \}$ . All proofs are deferred to Appendices $\mathbf { B }$ and D.
|
| 38 |
+
|
| 39 |
+
Formalising Subgraph GNNs. Subgraph GNNs compute a representation of $G \in { \mathcal { G } }$ as
|
| 40 |
+
|
| 41 |
+
$$
|
| 42 |
+
( A , X ) \mapsto \left( \mu \circ \rho \circ S \circ \pi \right) ( A , X ) .
|
| 43 |
+
$$
|
| 44 |
+
|
| 45 |
+
Here, $\pi : G \mapsto \{ G ^ { 1 } , . . . , G ^ { m } \} = \{ ( A ^ { 1 } , X ^ { 1 } ) , . . . , ( A ^ { m } , X ^ { m } ) \} = B _ { G } ^ { ( 0 ) }$ is a selection policy generating a bag of subgraphs from $G$ ; $\begin{array} { r } { S = L _ { T } \circ \dots \circ L _ { 1 } : B _ { G } ^ { ( 0 ) } \mapsto B _ { G } ^ { ( T ) } } \end{array}$ is a stacking of (node- and subgraph-) permutation equivariant layers; $\rho : ( G , B _ { G } ^ { ( T ) } ) \mapsto x _ { G }$ is a permutation invariant pooling function, $\mu$ is an MLP. The layers in $s$ comprise a base-encoder in the form of a GNN applied to subgraphs; throughout this paper, we assume it to be a $1 - \mathrm { { W L } }$ maximally expressive MPNN such as the one in Morris et al. [36]. Subgraph GNNs differ in the implementation of $\pi$ , $s$ and, in some cases, $\rho$ . For example, in (n-1)-Reconstruction GNNs [14], $\pi$ selects node-deleted subgraphs and $s$ applies a Siamese MPNN to each subgraph independently. To exemplify the variability in $s$ , DSS-GNN [7] extends this method with cross-subgraph node and connectivity aggregation. More details are on how currently known Subgraph GNNs are captured by Equation (1) can be found in Appendix A.
|
| 46 |
+
|
| 47 |
+
Node-based selection policies. In this work, we focus on a specific family of node-based subgraph selection policies, wherein every subgraph is associated with a unique node in the graph. Formally, we call a subgraph selection policy node-based if it is of the form $\bar { \pi ( G ) } = \{ f ( G , v ) \} _ { v \in V }$ , for some selection function $f ( G , v )$ that takes a graph $G$ and a node $v$ as inputs and outputs a subgraph $G ^ { v }$ . In the following, we refer to $v$ as the root of subgraph $G ^ { v }$ . We require $f$ to be a bijection and we note that such policies produce $m = n$ different subgraphs. Amongst the most common examples are node-deletion (ND), node-marking (NM), and ego-networks (EGO) policies. For input graph $G$ , $f _ { \mathrm { N D } } ( G , v )$ removes node $v$ and the associated connectivity; $f _ { \mathrm { N M } } ( G , v )$ adds a special ‘mark’ attribute to $v$ ’s features (with no connectivity alterations), and $f _ { \mathrm { E G O } ( h ) } ( G , v )$ returns the subgraph induced by the $h$ -hop-neighbourhood around the root $v$ . EGO policies can be ‘marked’: $f _ { \mathrm { E G O + } ( h ) } ( G , v )$ extracts the $h$ -hop ego-net around $v$ and marks this node as done by $f _ { \mathrm { N M } }$ . For convenience, we denote the class of such node-based selection policies by $\Pi$ :
|
| 48 |
+
|
| 49 |
+

|
| 50 |
+
Figure 1: Symmetries of bags of subgraphs (left) and corresponding function space diagrams (right). In ESAN [7] symmetries are modelled as a direct product of node and subgraph permutation groups; however, node-based policies enable the use of one single permutation group, the same as in 3-IGNs. 3-IGNs are less constrained, thus more expressive than ESAN and other Subgraph GNNs. See diagram on the right and formal statement in Section 5.
|
| 51 |
+
|
| 52 |
+
Definition 1 (Known node-based selection policies $\Pi$ ). Let $\Sigma$ be the set of all node-based subgraph selection policies operating on $\mathcal { G }$ . Class $\Pi \subset \Sigma$ collects the node-based policies node-deletion $( N D )$ , node-marking (NM), ego-nets $( E G O )$ and marked ego-nets $( E G O + )$ of any depth: $\Pi =$ $\{ \pi _ { \mathrm { N D } } , \pi _ { \mathrm { N M } } , \pi _ { \mathrm { E G O } ( h ) } , \pi _ { \mathrm { E G O } + ( h ) } \mid h > 0 \}$ .
|
| 53 |
+
|
| 54 |
+
Node-based Subgraph GNNs are those Subgraph GNNs which, implicitly or explicitly, process bags generated by node-based policies. We group known formulations in the following family:
|
| 55 |
+
|
| 56 |
+
Definition 2 (Known node-based Subgraph GNNs $\Upsilon$ ). Let Ξ be the set of all node-based Subgraph GNNs. Class $\Upsilon \subset \Xi$ collects known Subgraph GNNs when equipped with 1-WL base-encoders: $\Upsilon = \lbrace ( \mathtt { n - l } )$ -Reconstr.GNN, GNN-AK, GNN-AK-ctx, NGNN, ID-GNN, DS- $\mathrm { G N N } _ { \Pi }$ , $\mathrm { D S S - G N N _ { \Pi } } \big \}$ $\mathrm { D S - G N N _ { \Pi } }$ , DSS-GNNΠ refer to DS- and DSS-GNN models equipped with any $\pi \in \Pi$ .
|
| 57 |
+
|
| 58 |
+
Importantly, all these methods apply MPNNs to subgraphs of the original graph, but differ in the way information is shared between subgraphs/nodes. In all cases, their expressive power is strictly larger than 1-WL, but an upper-bound is currently unknown.
|
| 59 |
+
|
| 60 |
+
# 4 Symmetries of node-based subgraph selection policies
|
| 61 |
+
|
| 62 |
+
In an effort to characterise the representational power of node-based Subgraph GNNs, we first study the symmetry group of the objects they process: ‘bags of subgraphs’ represented as tensors $( { \mathcal { A } } , { \mathcal { X } } ) \in$ $\mathbb { R } ^ { m \times n \times n } \times \mathbb { R } ^ { m \times n \times d }$ , assuming $n$ nodes across $m$ subgraphs. Previous approaches [14, 7, 43] used two permutation groups: one copy of the symmetric group $S _ { n }$ models node permutations, while another copy $S _ { m }$ models subgraph permutations in the bag. These two were combined by a group product4 acting independently on the nodes and subgraphs in $( { \mathcal { A } } , { \mathcal { X } } )$ . For example, Bevilacqua et al. [7] model the symmetry as:
|
| 63 |
+
|
| 64 |
+
$$
|
| 65 |
+
\begin{array} { r } { ( ( \tau , \mathbf { \mu } ) \cdot \mathcal { A } ) _ { i j k } = \mathcal { A } _ { \tau ^ { - 1 } ( i ) } \cdot \mathbf { \mu } ^ { - 1 } ( j ) \cdot \mathbf { \mu } ^ { - 1 } ( k ) , \left( ( \tau , \mathbf { \mu } ) \cdot \mathcal { X } \right) _ { i j l } = \mathcal { X } _ { \tau ^ { - 1 } ( i ) } \cdot \mathbf { \mu } ^ { - 1 } ( j ) l , \left( \tau , \mathbf { \mu } \right) \in S _ { m } \times S _ { m } } \end{array}
|
| 66 |
+
$$
|
| 67 |
+
|
| 68 |
+
Our contributions stem from the following crucial observation: When using node-based policies, the subgraphs in $( { \mathcal { A } } , { \mathcal { X } } )$ can be ordered consistently with the nodes by leveraging the bijection $f : v \mapsto G _ { v }$ characterising this policy class. In other words, $f$ suggests a node-subgraph alignment inducing a new structure on $( { \mathcal { A } } , { \mathcal { X } } )$ , whereby the subgraph order is not independent of that of nodes anymore. Importantly, this new structure is preserved only by those permutations operating identically on both nodes and subgraphs. Following this observation, the symmetry of a node-based bag of subgraphs is modelled more accurately using only one single permutation group $S _ { n }$ jointly acting on both nodes and subgraphs:
|
| 69 |
+
|
| 70 |
+

|
| 71 |
+
Figure 2: Depiction of cubed tensor $\mathcal { V }$ , its orbit-induced partitioning and the related semantics when $\mathcal { V }$ is interpreted as a bag of node-based subgraphs, $n = 5$ . Elements in the same partition are depicted with the same colour. Left: the whole tensor. Middle and right: sections; elements in purple and green constitute sub-tensor $\mathcal { X }$ , the remaining ones sub-tensor $\mathcal { A }$ .
|
| 72 |
+
|
| 73 |
+
$$
|
| 74 |
+
( \mathbf { \partial } \cdot \mathbf { \partial } \cdot \mathbf { \partial } \cdot \mathbf { \partial } \cdot \mathbf { \partial } \cdot \mathbf { \partial } ^ { - 1 } ( i ) \mathbf { \partial } \cdot \mathbf { \partial } ^ { - 1 } ( k ) , \mathbf { \partial } \cdot \mathbf { \partial } \cdot \mathbf { \partial } \cdot \mathbf { \partial } \cdot \mathbf { \partial } \cdot \mathbf { \partial } \cdot \mathbf { \partial } \cdot \mathbf { \partial } \cdot \mathbf { \partial } \cdot \mathbf { \partial } \cdot \mathbf { \partial } \cdot \mathbf { \partial } \cdot \mathbf { \partial } \cdot \mathbf { \partial } \cdot \mathbf { \partial } \cdot \mathbf { \partial } \cdot \mathbf { \partial } \cdot \mathbf { \partial } \cdot \mathbf { \partial }
|
| 75 |
+
$$
|
| 76 |
+
|
| 77 |
+
It should be noted that $S _ { n }$ is significantly smaller than $S _ { n } \times S _ { n } ^ { \phantom { \dagger } 5 }$ . Informally, the latter group contains many permutations which are not in the former: those acting differently on nodes and subgraphs and, thus, not preserving the new structure of $( { \mathcal { A } } , { \mathcal { X } } )$ . Since they are restricted by a smaller set of equivariance constraints, we expect GNNs designed to be equivariant to $S _ { n }$ to be be more expressive than those equivariant to the larger groups considered by previous works [34] (see Figure 1).
|
| 78 |
+
|
| 79 |
+
The insight we obtain from Equation (3) is profound: it reveals that the symmetry structure of $\mathcal { A }$ exactly matches the symmetries of third-order tensors used by 3-IGNs, and similarly, that the symmetry structure for $\mathcal { X }$ matches the symmetries of second-order tensors used by 2-IGNs. In the following, we will make use of this insight and the fact that IGNs are well-studied objects to prove an upper-bound on the expressive power of Subgraph GNNs and to design principled extensions to these models. We remark that bags of node-based subgraphs can also be represented as tensors $\mathcal { V } \in \mathbb { R } ^ { n ^ { 3 } \times d }$ , the same objects on which 3-IGNs operate. Here, $\mathcal { X }$ is embedded in the main diagonal plane of $\mathcal { V }$ , $\mathcal { A }$ in its remaining entries. Within this context, it is informative to study the semantics of the 5 orbits induced by the action of $S _ { n }$ on $\mathcal { V }$ ’s multi-index set $[ n ] ^ { 3 }$ : each of these uniquely identify root nodes, non-root nodes, edges to and from root nodes as well as edges between non-root nodes (see Figure 2 and additional details in Appendix B.1.1). We build upon this observation, along with the layer construction by Albooyeh et al. [2], to prove many of the results presented in the following.
|
| 80 |
+
|
| 81 |
+
# 5 A representational bound for Subgraph GNNs
|
| 82 |
+
|
| 83 |
+
In this section we prove that the expressive power of known node-based Subgraph GNNs is bounded by $3 - \mathrm { { W L } }$ by showing that they can be implemented by 3-IGNs, which have the same expressive power as $3 - \mathbb { W } \mathbb { L }$ . Underpinning the possibility of IGNs to upper-bound a certain Subgraph GNN $\mathcal { N }$ in its expressive power is the ability of IGNs to (i) implement $\mathcal { N }$ ’s subgraph selection policy $( \pi )$ and (ii) implement $\mathcal { N }$ ’s (generalised) message-passing and pooling equations $( \mu \circ \rho \circ S )$ . This would ensure that whenever $\mathcal { N }$ assigns distinct representations to two non-isomorphic graphs, an IGN implementing $\mathcal { N }$ would do the same. We start by introducing a recurring, useful concept.
|
| 84 |
+
|
| 85 |
+
Definition 3 (“implements”). Let $f : D _ { f } \to C _ { f }$ , $g : D _ { g } \to C _ { g }$ be two functions and such that $D _ { g } \subseteq D _ { f } , C _ { g } \subseteq C _ { f }$ . We say $f$ implements $g$ (and write $f \cong g ,$ ) when $\forall x \in D _ { g } , f ( x ) = g ( x )$ .
|
| 86 |
+
|
| 87 |
+
Our first result shows that 3-IGNs can implement the selection policies in class $\Pi$ (Definition 1), which, to the best of our knowledge, represent all known node-based policies utilised by previously proposed Subgraph GNNs.
|
| 88 |
+
|
| 89 |
+
Lemma 4 (3-IGNs implement known node-based selection policies). For any $\pi \in \Pi$ there exists a stacking of 3-IGN layers $\mathcal { M } _ { \pi }$ s.t. $\mathcal { M } _ { \pi } \cong \pi$ .
|
| 90 |
+
|
| 91 |
+
Intuitively, 3-IGNs start from a $\mathbb { R } ^ { n ^ { 2 } }$ representation of $G$ and, first, move to a $\mathbb { R } ^ { n ^ { 3 } }$ tensor ‘copying’ this latter along its first (subgraph) dimension. This is realised via an appropriate broadcast operation. Then, they proceed by adding a ‘mark’ to the features of some nodes and/or by nullifying elements corresponding to some edges. We refer readers to Figure 2 and Appendix B.1.2 for additional details on how nodes in each subgraph are represented in 3-IGNs. Next, we show 3-IGNs can implement layers of any model $\in \Upsilon$ .
|
| 92 |
+
|
| 93 |
+
Lemma 5 (3-IGNs implement Subgraph GNN layers). Let $G _ { 1 } , G _ { 2 }$ be two graphs in $\mathcal { G }$ and $\mathcal { N }$ a model in family be bags of subg $\Upsilon$ equipped with Morris et al. [36] messagehs in the input of some intermediate layer asin g base-encoders. Let . Then there exists a $B _ { 1 } ^ { ( t ) } , B _ { 2 } ^ { ( t ) }$ $L$ $\mathcal { N }$ 3-IGN layers $\mathcal { M } _ { L }$ for which $\begin{array} { r } { \dot { \mathcal { M } } _ { L } ( { B } _ { i } ^ { ( t ) } ) = { B } _ { i } ^ { ( t + 1 ) } = { L } ( { B } _ { i } ^ { ( t ) } ) } \end{array}$ for $i = 1 , 2$ .
|
| 94 |
+
|
| 95 |
+
Lemmas 4 and 5 allow us to upper-bound the expressive power of all known instances of node-based Subgraph GNNs by that of 3-IGNs:
|
| 96 |
+
|
| 97 |
+
Theorem 6 (3-IGNs upper-bound node-based Subgraph GNNs). For any pair of non-isomorphic graphs $G _ { 1 } , G _ { 2 }$ in family $\mathcal { G }$ and Subgraph GNN model $\mathcal { N } \in \Upsilon$ equipped with Morris et al. [36] message-passing base-encoders, if there exists weights $\Theta$ such that $G _ { 1 }$ , $G _ { 2 }$ are distinguished by instance $\mathcal { N } _ { \Theta }$ , then there exist weights Ω for a 3-IGN instance $\mathcal { M } _ { \Omega }$ such that $G _ { 1 } , G _ { 2 }$ are distinguished by $\mathcal { M } _ { \Omega }$ as well.
|
| 98 |
+
|
| 99 |
+
Theorem 6 has profound consequences in the characterisation of the expressive power of node-based Subgraph GNNs, as we show in the following
|
| 100 |
+
|
| 101 |
+
Corollary 7 (3-WL upper-bounds node-based Subgraph GNNs). Let $G _ { 1 } , G _ { 2 } \ \in \ { \mathcal { G } }$ be two nonisomorphic graphs and $\mathcal { N } _ { \Theta } \in \Upsilon$ one instance of model $\mathcal { N }$ with weights $\Theta$ . If $\mathcal { N } _ { \Theta }$ distinguishes $G _ { 1 } , G _ { 2 }$ , then the 3-WL algorithm does so as well.
|
| 102 |
+
|
| 103 |
+
Proof idea: If there is a pair of graphs undistinguishable by 3-WL, but for which there exists a Subgraph GNN separating them, there must exists a 3-IGN separating these (Theorem 6). This is in contradiction with the result by Geerts [21], Azizian and Lelarge $[ 5 ] ^ { 6 }$ .
|
| 104 |
+
|
| 105 |
+
# 6 A design space for Subgraph GNNs
|
| 106 |
+
|
| 107 |
+
As discussed, different formulations of Subgraph GNNs differ primarily in the specific rules for updating node representations across subgraphs. However, until now it is not clear whether existing rules exhaust all the possible equivariant options. We devote this section to a systematic characterisation of the ‘layer space’ of Subgraph GNNs.
|
| 108 |
+
|
| 109 |
+
In the spirit of the previous Section 5, where we “embedded” Subgraph GNNs in 3-IGNs, one option would be to consider all $\mathsf { b e l l } ( 6 ) = 2 0 3$ linear equivariant operations prescribed by this formalism. However, this choice would be problematic for three main reasons: (i) This layer space is too vast to be conveniently explored; (ii) It includes operations involving $\mathcal { O } ( n ^ { 3 } )$ space complexity, impractical in most applications; (iii) The linear IGN basis does not directly support local message passing, a key operation in subgraph methods. Following previous Subgraph GNN variants, which use $\mathcal { O } ( { \bar { n } } ^ { 2 } )$ storage for the representation of $n$ nodes in $n$ subgraphs, we set the desideratum of $\mathcal { O } ( n ^ { 2 } )$ memory complexity as our main constraint, and use this restriction to reduce the design space. Precisely, we are interested in modelling $S _ { n }$ -equivariant transformations on the subgraph-node tensor $\mathcal { X }$ .
|
| 110 |
+
|
| 111 |
+
# 6.1 Extended 2-IGNs
|
| 112 |
+
|
| 113 |
+
As we have already observed in Equation 3 in Section 4, such a second order tensor $\mathcal { X }$ abides by the same symmetry structure of 2-IGNs. We therefore gain intuition from the characterisation of linear equivariant mappings as introduced by Maron et al. [33], and propose an extension of this formalism.
|
| 114 |
+
|
| 115 |
+

|
| 116 |
+
Figure 3: Comparison of aggregation and update rules in Subgraph GNNs, illustrated on an $n \times n$ matrix ( $\scriptstyle { n }$ subgraphs with $n$ nodes). Top row: off-diagonal updates; bottom row: diagonal (root node) updates. Each colour represents a different parameter. Full squares: global sum pooling; triangles: local pooling; two triangles: both local and global pooling. See Appendix C for more details.
|
| 117 |
+
|
| 118 |
+
2-IGN layer space. A 2-IGN layer $L _ { \Theta }$ updates $\mathcal { X } \in \mathbb { R } ^ { n \times n \times d }$ as $\mathcal { X } ^ { ( t + 1 ) } = L _ { \Theta } \big ( \mathcal { X } ^ { ( t ) } \big )$ by applying a specific transformation to on- $( x _ { i } ^ { i } )$ and off-diagonal terms $( x _ { j } ^ { i } , i \neq j )$ :
|
| 119 |
+
|
| 120 |
+
$$
|
| 121 |
+
\begin{array} { r l } & { x _ { i } ^ { i , ( t + 1 ) } { = } v _ { \theta _ { 1 } } \big ( x _ { i } ^ { i , ( t ) } , \underset { j } { \sum } x _ { j } ^ { j , ( t ) } , \underset { j \neq i } { \prod } x _ { j } ^ { i , ( t ) } , \underset { h \neq i } { \prod } x _ { i } ^ { h , ( t ) } , \underset { h \neq j } { \prod } x _ { j } ^ { h , ( t ) } \big ) } \\ & { x _ { i } ^ { k , ( t + 1 ) } { = } v _ { \theta _ { 2 } } \big ( x _ { i } ^ { k , ( t ) } , x _ { k } ^ { i , ( t ) } , \underset { h \neq j } { \prod } x _ { j } ^ { h , ( t ) } , \underset { h \neq i } { \prod } x _ { i } ^ { h , ( t ) } , \underset { j \neq k } { \prod } x _ { j } ^ { k , ( t ) } , \underset { j \neq i } { \prod } x _ { j } ^ { i , ( t ) } , \underset { h \neq k } { \prod } x _ { k } ^ { h , ( t ) } , x _ { k } ^ { k , ( t ) } , x _ { k } ^ { i , ( t ) } , x _ { i } ^ { i , ( t ) } , \underset { j } { \prod } x _ { j } ^ { j , ( t ) } \big ) } \end{array}
|
| 122 |
+
$$
|
| 123 |
+
|
| 124 |
+
Here, $\boxed { \begin{array} { r l } \end{array} }$ indicates a permutation invariant aggregation function, $v _ { \theta _ { 1 } } , v _ { \theta _ { 2 } }$ apply a specific $d \times d ^ { \prime }$ linear transformation to each input term and sum the outputs including bias terms.
|
| 125 |
+
|
| 126 |
+
ReIGN(2) layer space. As 2-IGN layers are linear, the authors advocate setting $\sqcap \equiv \Sigma$ , performing pooling as global summation. Here, we extend this formulation to additionally include different local aggregation schemes. In this new extended formalism, entry $x _ { i } ^ { k }$ represents node $i$ in subgraph $k$ ; accordingly, each aggregation in Equation 4 can be also performed locally, i.e. extending only over $\ddot { \iota }$ ’s neighbours, as prescribed by the connectivity of subgraph $k$ or of the original input graph. As an example, when updating entry $x _ { i } ^ { k , ( t ) }$ , term □j̸=k xk,j is expanded as $\begin{array} { r } { \Big ( \bigtriangledown _ { j \neq k } x _ { j } ^ { k , ( t ) } , \bigtriangledown _ { j \sim _ { k } i } x _ { j } ^ { k , ( t ) } , \bigtriangledown _ { j \sim i } x _ { j } ^ { k , ( t ) } . } \end{array}$ , with $\sim _ { k }$ denoting adjacency in subgraph $k$ , and $\sim$ that in the original graph connectivity. Each term in the expansion is associated with a specific learnable linear transformation. We report a full list of pooling operations in Appendix D, Table 3. These local pooling operations allow to readily recover sparse message passing, which constitutes the main computational primitive of all popular (Subgraph) GNNs. Other characteristic Subgraph GNN operations are also recovered by this formalism: for example, $\textstyle \prod _ { h \neq i } x _ { i } ^ { h , ( t ) }$ operates global pooling of node $i$ ’s representations across subgraphs, as previously introduced in Bevilacqua et al. [7], Zhao et al. [61]. We also note that additional, novel, operations are supported, e.g. the transpose $x _ { k } ^ { i , ( t ) }$ . We generally refer to this framework as ReIGN(2) (“Rethought 2-IGN”).
|
| 127 |
+
|
| 128 |
+
ReIGN(2) architectures. ReIGN(2) induces (linear) layers in the same form of Equation 4, but where $\boxed { \begin{array} { r l } \end{array} }$ terms are expanded to both local and global operations, as explained. These layers can operate on any bag generated by a node-based selection policy $\bar { \pi }$ , and can be combined together in ReIGN(2) stacks of the form $\mathcal S _ { \mathcal R } = L ^ { ( T ) } \circ \sigma \circ L ^ { ( T - 1 ) } \circ \sigma \circ . . . \circ \sigma \circ L ^ { ( 1 ) } ,$ , where $\sigma$ ’s are pointwise nonlinearities and $L$ ’s are ReIGN(2) layers. This allows us to define ReIGN(2) models as Subgraph GNNs in the form of Equation 1, where $s$ is a ReIGN(2) layer stacking and $\pi$ is node-based: $\mathcal { R } _ { \bar { \pi } } = \mu \circ \rho \circ S _ { \mathcal { R } } \circ \bar { \pi }$ .
|
| 129 |
+
|
| 130 |
+
More generally, ReIGN(2) induces a ‘layer space’ for node-based Subgraph GNNs: the expanded terms in its update equations represent a pool of atomic operations that can be selected and combined to define new equivariant layers. Compared to that of 3-IGNs, this space is of tractable size, yet it recovers previously proposed Subgraph GNNs and allows to define novel interesting variants.
|
| 131 |
+
|
| 132 |
+
Recovering previous Subgraph GNNs. The following result states that the ReIGN(2) generalises all known subgraph methods in $\Upsilon$ , as their layers are captured by a ReIGN(2) stacking.
|
| 133 |
+
|
| 134 |
+
Theorem 8 (ReIGN(2) implements node-based Subgraph GNNs). Let N be a model in family $\Upsilon$ equipped with Morris et al. [36] message-passing base-encoders. For any instance $\mathcal { N } _ { \Theta }$ , there exists ReIGN(2) instance $\mathcal { R } _ { \Omega }$ such that $\mathcal { R } _ { \Omega } \cong \mathcal { N } _ { \Theta }$ .
|
| 135 |
+
|
| 136 |
+
This shows that known methods are generalised without resorting to the $\mathcal { O } ( n ^ { 3 } )$ computational complexity of 3-IGNs. Figure 3 illustrates the aggregation and sharing rules used by previous Subgraph GNNs to update root and non-root nodes, and compare them with those of ReIGN(2) and 2-IGNs. We visualise these on the subgraph-node sub-tensor gathering node representations across subgraphs; here, root nodes occupy the main diagonal, non-root nodes all the remaining off-diagonal entries. As for to the 2-IGN Equations 4, the elements in these two partitions may be updated differently, so we depict them separately in, respectively, the bottom and top rows. In each depiction we colour elements depending on the set of weights parameterising their contribution in the update process, with two main specifications: (i) Elements sharing the same colour are pooled together; (ii) Triangles indicate such pooling is performed locally based on the subgraph connectivity at hand (two triangles indicate both local and global pooling ops are performed). E.g., note how DS-GNN equivalently updates the representations of root and non-root nodes via the same (local) messagepassing layer (triangles, yellow, leftmost picture). By illustrating how ReIGN(2) generalises previous node-based methods, this figure is to be interpreted as visual support for the Proof of Theorem 8 (see Appendix D). Additional details and discussions on Figure 3 are found in Appendix C.
|
| 137 |
+
|
| 138 |
+
Notably, as methods in $\Upsilon$ have been shown to be strictly stronger than 2-WL [7, 14, 61, 59, 56], Theorem 8 implies the same lower bound for ReIGN(2). Nevertheless, when employing policies in $\Pi$ and 3-IGN-computable invariant pooling functions $\rho$ (as those used by models in $\Upsilon$ ), ReIGN(2)s are upper-bounded by 3-IGNs:
|
| 139 |
+
|
| 140 |
+
Proposition 9 (3-IGNs implement ReIGN(2)). For any pair of non-isomorphic graphs $G _ { 1 } , G _ { 2 }$ in family $\mathcal { G }$ , if there exist policy $\bar { \pi } \in \Pi$ , parameters $\Theta$ and 3-IGN-computable invariant pooling function $\rho$ such that the ReIGN(2) instance $\mathcal { R } _ { \rho , \Theta , \bar { \pi } }$ distinguishes $G _ { 1 }$ , $G _ { 2 }$ , then there exist weights $\Omega$ for $a$ 3-IGN instance $\mathcal { M } _ { \Omega }$ such that $G _ { 1 } , G _ { 2 }$ are distinguished by $\mathcal { M } _ { \Omega }$ as well.
|
| 141 |
+
|
| 142 |
+
This proposition entails an upper-bound on the expressive power of ReIGN(2).
|
| 143 |
+
|
| 144 |
+
Corollary 10 (3-WL upper-bounds ReIGN(2)). The expressive power of a ReIGN(2) model with policy $\pi \in \Pi$ and 3-IGN-computable invariant pooling function $\rho$ is upper-bounded by 3-WL.
|
| 145 |
+
|
| 146 |
+
We note that there may be layers equivariant to $S _ { n }$ over $\mathbb { R } ^ { n ^ { 2 } }$ not captured by ReIGN(2). Yet, previously proposed Subgraph GNN layers do not exhaust the ReIGN(2) design space, which remains largely unexplored. One, amongst possible novel constructions, is introduced next.
|
| 147 |
+
|
| 148 |
+
# 6.2 A unifying architecture: Subgraph Union Networks
|
| 149 |
+
|
| 150 |
+
We now show how the ReIGN(2) layer space can guide the design of novel, expressive, Subgraph GNNs. Our present endeavour is to conceive a computationally tractable architecture subsuming known node-based models: in virtue of this latter desideratum, we will dub this architecture “Subgraph Union Network” (SUN). To design the base equivariant layer for SUN, we select and combine specific aggregation terms suggested by the ReIGN(2) framework:
|
| 151 |
+
|
| 152 |
+
$$
|
| 153 |
+
\begin{array} { l } { { \displaystyle x _ { i } ^ { i , ( t + 1 ) } = \sigma \Big ( v _ { \theta _ { 1 } } \big ( x _ { i } ^ { i , ( t ) } , \sum _ { j \sim i } x _ { j } ^ { i , ( t ) } , \sum _ { j } x _ { j } ^ { i , ( t ) } , \sum _ { h } x _ { i } ^ { h , ( t ) } , \sum _ { j \sim i } \sum _ { h } x _ { j } ^ { h , ( t ) } \big ) \Big ) } } \\ { { \displaystyle x _ { i } ^ { k , ( t + 1 ) } = \sigma \Big ( v _ { \theta _ { 2 } } \big ( x _ { i } ^ { k , ( t ) } , \sum _ { j \sim k i } x _ { j } ^ { k , ( t ) } , x _ { i } ^ { i , ( t ) } , x _ { k } ^ { k , ( t ) } , \sum _ { j } x _ { j } ^ { k , ( t ) } , \sum _ { h } x _ { i } ^ { h , ( t ) } , \sum _ { j \sim i } \sum _ { h } x _ { j } ^ { h , ( t ) } \big ) \Big ) } } \end{array}
|
| 154 |
+
$$
|
| 155 |
+
|
| 156 |
+
where $\upsilon$ ’s sum their inputs after applying a specific linear transformations to each term. One of the novel features of SUN is that roots are transformed by a different set of parameters $( \theta _ { 1 } )$ than the other nodes 7 ( $\ \theta _ { 2 }$ , see Figure 2). In practice, the first and last two terms in each one of Equations (5) and (6) can be processed by maximally expressive MPNNs [36, 55], the remaining terms by MLPs. We test these variants in our experiments, with their formulations in Appendix G. SUN remains an instantiation of the ReIGN(2) framework:
|
| 157 |
+
|
| 158 |
+
Proposition 11 (A ReIGN(2) stacking implements SUN layers). For any SUN layer $L$ defined according to Equations 5 and 6, there exists a ReIGN(2) layer stacking $ { \boldsymbol { S } } _ { L }$ , such that $S _ { L } \cong L$ .
|
| 159 |
+
|
| 160 |
+
Table 1: Test mean MAE on the Counting Substructures and ZINC-12k datasets. All Subgraph GNNs employ a GIN base-encoder. †This version of GNN-AK $^ +$ does not follow the standard evaluation procedure.
|
| 161 |
+
|
| 162 |
+
<table><tr><td>Method</td><td>ZINC (MAE ↓)</td></tr><tr><td>GCN[27]</td><td>0.321 ± 0.009</td></tr><tr><td>GIN [55]</td><td>0.163 ± 0.004</td></tr><tr><td>PNA[13]</td><td>0.133 ± 0.011</td></tr><tr><td>GSN[11] CIN [9]</td><td>0.101 ± 0.010</td></tr><tr><td></td><td>0.079 ± 0.006</td></tr><tr><td>NGNN [59] DS-GNN (EGO) [7]</td><td>0.111 ± 0.003</td></tr><tr><td>DS-GNN (EGO+) [7]</td><td>0.115 ± 0.004</td></tr><tr><td></td><td>0.105 ±0.003</td></tr><tr><td>DSS-GNN (EGO) [7]</td><td>0.099 ±0.003</td></tr><tr><td>DSS-GNN (EGO+) [7]</td><td>0.097 ± 0.006</td></tr><tr><td>GNN-AK[61]</td><td>0.105 ± 0.010</td></tr><tr><td>GNN-AK-CTX [61]</td><td>0.093±0.002</td></tr><tr><td>GNN-AK+ [61]†</td><td>0.086± ???</td></tr><tr><td>GNN-AK+ [61]</td><td>0.091 ± 0.011</td></tr><tr><td>SUN (EGO)</td><td>0.083 ±0.003</td></tr><tr><td>SUN (EGO+)</td><td>0.084 ±0.002</td></tr></table>
|
| 163 |
+
|
| 164 |
+
<table><tr><td rowspan="2">Method</td><td colspan="4">Counting Substructures (MAE ↓)</td></tr><tr><td>Triangle</td><td>Tailed Tri.</td><td>Star</td><td>4-Cycle</td></tr><tr><td>GCN [27]</td><td>0.4186</td><td>0.3248</td><td>0.1798</td><td>0.2822</td></tr><tr><td>GIN [55]</td><td>0.3569</td><td>0.2373</td><td>0.0224</td><td>0.2185</td></tr><tr><td>PNA [13]</td><td>0.3532</td><td>0.2648</td><td>0.1278</td><td>0.2430</td></tr><tr><td>PPGN [32]</td><td>0.0089</td><td>0.0096</td><td>0.0148</td><td>0.0090</td></tr><tr><td>GNN-AK [61]</td><td>0.0934</td><td>0.0751</td><td>0.0168</td><td>0.0726</td></tr><tr><td>GNN-AK-CTX [61]</td><td>0.0885</td><td>0.0696</td><td>0.0162</td><td>0.0668</td></tr><tr><td>GNN-AK+[61]</td><td>0.0123</td><td>0.0112</td><td>0.0150</td><td>0.0126</td></tr><tr><td>SUN (EGO)</td><td>0.0092</td><td>0.0105</td><td>0.0064</td><td>0.0140</td></tr><tr><td>SUN (EGO+)</td><td>0.0079</td><td>0.0080</td><td>0.0064</td><td>0.0105</td></tr></table>
|
| 165 |
+
|
| 166 |
+
Finally, we show that a stacking of SUN layers can implement any layer of known node-based Subgraph Networks, making this model a principled generalisation thereof.
|
| 167 |
+
|
| 168 |
+
Proposition 12 (A SUN stacking implements known Subgraph GNN layers). Let N be a model in family $\Upsilon$ employing Morris et al. [36] as a message-passing base-encoder. Then, for any layer L in $\mathcal { N }$ , there exists a stacking of SUN layers $S _ { L }$ such that $S _ { L } \cong L$ .
|
| 169 |
+
|
| 170 |
+
Beyond SUN. As it can be seen in Figure 3, SUN does not use all possible operations in the ReIGN(2) framework. Notably, two interesting operations that are not a part of SUN are: (i) The ‘transpose’: $x _ { i } ^ { k } = v _ { \theta } ( x _ { k } ^ { i } )$ , which shares information between the $i$ -th node in the $k$ -th subgraph and the $k$ -th node in the $i$ -th subgraph; (ii) Local vertical pooling $\begin{array} { r } { x _ { i } ^ { k } = v _ { \theta } ( \sum _ { h \sim i } x _ { i } ^ { h } ) } \end{array}$ . The exploration of these and other operations is left to future work.
|
| 171 |
+
|
| 172 |
+
# 7 Experiments
|
| 173 |
+
|
| 174 |
+
We experimentally validate the effectiveness of one ReIGN(2) instantiation, comparing SUN to previously proposed Subgraph $\mathrm { G N N s } ^ { 8 }$ . We seek to verify whether its theoretical representational power practically enables superior accuracy in expressiveness tasks and real-world benchmarks. Concurrently, we pay attention to the generalisation ability of models in comparison. SUN layers are less constrained in their weight sharing pattern, resulting in a more complex model. As this is traditionally associated with inferior generalisation abilities in low data regimes, we deem it important to additionally assess this aspect. Our code is also available.9
|
| 175 |
+
|
| 176 |
+
Synthetic. Counting substructures and regressing graph topological features are notoriously hard tasks for GNNs [12, 17, 13]. We test the representational ability of SUN on common benchmarks of this kind [12, 13]. Table 1 reports results on the substructure counting suite, on which SUN attains state-of-the-art results in 3 out of 4 tasks. Additional results on the regression of global, structural properties are reported in Appendix G.
|
| 177 |
+
|
| 178 |
+
Real-world. On the molecular ZINC-12k benchmark (constrained solubility regression) [50, 22, 16], SUN exhibits best performance amongst all domain-agnostic GNNs under the $5 0 0 \mathrm { k }$ parameter budget, including other Subgraph GNNs (see Table 1). A similar trend is observed on the large-scale Molhiv dataset from the OGB [23] (inhibition of HIV replication). Results are in Table 2. Remarkably, on both datasets, SUN either outperforms or approaches HIMP [19], GSN [11] and CIN [9], GNNs which explicitly model rings. We experiment on smaller-scale TUDatasets [37] in Appendix G, where we also compare selection policies.
|
| 179 |
+
|
| 180 |
+

|
| 181 |
+
Figure 4: Generalisation capabilities of Subgraph GNNs in the counting prediction task (Figures 4a and 4b) and in the ZINC-12k dataset (Figure 4c).
|
| 182 |
+
|
| 183 |
+
Table 2: Test results for OGB dataset. GIN base-encoder for each Subgraph GNN.
|
| 184 |
+
|
| 185 |
+
<table><tr><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>0GBG-MOLHIVROC-AUC(%)</td></tr><tr><td rowspan=1 colspan=1>GCN [27]GIN [55]PNA [13]DGN [6]HIMP [19]GSN[11]CIN [9]</td><td rowspan=1 colspan=1>76.06±0.9775.58±1.4079.05±1.3279.70±0.9778.80±0.8280.39±0.9080.94±0.57</td></tr><tr><td rowspan=1 colspan=1>RECONSTR.GNN[14]DS-GNN (EGO+) [7]DSS-GNN (EGO+) [7]GNN-AK+ [61]</td><td rowspan=1 colspan=1>76.32±1.4077.40±2.1976.78±1.6679.61±1.19</td></tr><tr><td rowspan=1 colspan=1>SUN (EGO+)</td><td rowspan=1 colspan=1>80.03±0.55</td></tr></table>
|
| 186 |
+
|
| 187 |
+
Generalisation from limited data. In this set of experiments we compare the test performance of Subgraph GNNs when trained on increasing fractions of the available training data. Each architecture is selected by tuning the hyperparameters with the entire training and validation sets. We run this experiment on the 4-cycle counting task and the real-world ZINC-12k. We illustrate results in Figures 4a to 4c. Except for a short initial phase in the EGO policy, SUN generalises better than other Subgraph GNNs on cycle-counting. On ZINC-12k, SUN outruns DSS-, DS-GNN and GNN-AK variants from, respectively, 20, 30 and $4 0 \%$ of the samples. These results demonstrate that SUN’s expressiveness is not at the expense of sample efficiency, suggesting that its modelled symmetries guarantee strong representational power while retaining important inductive biases for learning on graphs.
|
| 188 |
+
|
| 189 |
+
# 8 Conclusions
|
| 190 |
+
|
| 191 |
+
Our work unifies, extends, and analyses the emerging class of Subgraph GNNs. Notably, we demonstrated that the expressive power of these methods is bounded by 3-WL. Towards a systematic study of models whose expressivity lies between 1- and 3-WL, we proposed a new family of layers for the class of Subgraph GNNs and, unlike most previous works on the expressive power of GNNs, we also investigated the generalisation abilities of these models, for which SUN shows considerable improvement. Appendix E lists several directions for future work, including an extension of our work to higher-order node-based policies.
|
| 192 |
+
|
| 193 |
+
Societal impact. We do not envision any negative, immediate societal impact originating from our theoretical results, which represent most of our contribution. Experimentally, our model has shown promising results on molecular property prediction tasks and strong generalisation ability in low-data regimes. This leads us to believe our work may contribute to positively impactful pharmaceutical research, such as drug discovery [20, 3].
|
| 194 |
+
|
| 195 |
+
# Acknowledgments and Disclosure of Funding
|
| 196 |
+
|
| 197 |
+
The authors are grateful to Joshua Southern, Davide Eynard, Maria Gorinova, Guadalupe Gonzalez, Katarzyna Janocha for valuable feedback on early versions of the manuscript. They would like to thank Bruno Ribeiro and Or Litany for helpful discussions, Giorgos Bouritsas for constructive conversations about the generalisation experiments and, in particular, Marco Ciccone for the precious exchange on sharpness-aware optimisation and Neapolitan pizza. MB is supported in part by ERC Consolidator grant no 724228 (LEMAN). No competing interests are declared.
|
| 198 |
+
|
| 199 |
+
References
|
| 200 |
+
[1] Ralph Abboud, ˙Ismail ˙Ilkan Ceylan, Martin Grohe, and Thomas Lukasiewicz. The surprising power of graph neural networks with random node initialization. In Proceedings of the Thirtieth International Joint Conference on Artificial Intelligence (IJCAI), 2020.
|
| 201 |
+
[2] Marjan Albooyeh, Daniele Bertolini, and Siamak Ravanbakhsh. Incidence networks for geometric deep learning. arXiv preprint arXiv:1905.11460, 2019.
|
| 202 |
+
[3] Han Altae-Tran, Bharath Ramsundar, Aneesh S Pappu, and Vijay Pande. Low data drug discovery with one-shot learning. ACS Central Science, 3(4):283–293, 2017.
|
| 203 |
+
[4] James Atwood and Don Towsley. Diffusion-convolutional neural networks. In Advances in Neural Information Processing Systems, volume 29, 2016.
|
| 204 |
+
[5] Waïss Azizian and Marc Lelarge. Expressive power of invariant and equivariant graph neural networks. In International Conference on Learning Representations, 2021.
|
| 205 |
+
[6] Dominique Beaini, Saro Passaro, Vincent Létourneau, William L. Hamilton, Gabriele Corso, and Pietro Liò. Directional graph networks. In International Conference on Machine Learning, 2021.
|
| 206 |
+
[7] Beatrice Bevilacqua, Fabrizio Frasca, Derek Lim, Balasubramaniam Srinivasan, Chen Cai, Gopinath Balamurugan, Michael M Bronstein, and Haggai Maron. Equivariant subgraph aggregation networks. In International Conference on Learning Representations, 2022.
|
| 207 |
+
[8] Lukas Biewald. Experiment tracking with weights and biases, 2020. Software available from wandb.com.
|
| 208 |
+
[9] Cristian Bodnar, Fabrizio Frasca, Nina Otter, Yuguang Wang, Pietro Liò, Guido F Montúfar, and Michael Bronstein. Weisfeiler and lehman go cellular: Cw networks. In Advances in Neural Information Processing Systems, volume 34, 2021.
|
| 209 |
+
[10] Cristian Bodnar, Fabrizio Frasca, Yuguang Wang, Nina Otter, Guido F Montúfar, Pietro Liò, and Michael Bronstein. Weisfeiler and lehman go topological: Message passing simplicial networks. In International Conference on Machine Learning, 2021.
|
| 210 |
+
[11] Giorgos Bouritsas, Fabrizio Frasca, Stefanos P Zafeiriou, and Michael Bronstein. Improving graph neural network expressivity via subgraph isomorphism counting. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2022.
|
| 211 |
+
[12] Zhengdao Chen, Lei Chen, Soledad Villar, and Joan Bruna. Can graph neural networks count substructures? In Advances in Neural Information Processing Systems, volume 33, 2020.
|
| 212 |
+
[13] Gabriele Corso, Luca Cavalleri, Dominique Beaini, Pietro Liò, and Petar Velickovi ˇ c. Principal ´ neighbourhood aggregation for graph nets. In Advances in Neural Information Processing Systems, volume 33, 2020.
|
| 213 |
+
[14] Leonardo Cotta, Christopher Morris, and Bruno Ribeiro. Reconstruction for powerful graph representations. In Advances in Neural Information Processing Systems, volume 34, 2021.
|
| 214 |
+
[15] Pim de Haan, Taco S Cohen, and Max Welling. Natural graph networks. In Advances in Neural Information Processing Systems, volume 33, 2020.
|
| 215 |
+
[16] Vijay Prakash Dwivedi, Chaitanya K Joshi, Thomas Laurent, Yoshua Bengio, and Xavier Bresson. Benchmarking graph neural networks. arXiv preprint arXiv:2003.00982, 2020.
|
| 216 |
+
[17] Vijay Prakash Dwivedi, Anh Tuan Luu, Thomas Laurent, Yoshua Bengio, and Xavier Bresson. Graph neural networks with learnable structural and positional representations. In International Conference on Learning Representations, 2022.
|
| 217 |
+
[18] Matthias Fey and Jan Eric Lenssen. Fast graph representation learning with pytorch geometric. arXiv preprint arXiv:1903.02428, 2019.
|
| 218 |
+
|
| 219 |
+
[19] Matthias Fey, Jan-Gin Yuen, and Frank Weichert. Hierarchical inter-message passing for learning on molecular graphs. In ICML Graph Representation Learning and Beyond $( G R L + ,$ Workhop, 2020.
|
| 220 |
+
|
| 221 |
+
[20] Thomas Gaudelet, Ben Day, Arian R Jamasb, Jyothish Soman, Cristian Regep, Gertrude Liu, Jeremy B R Hayter, Richard Vickers, Charles Roberts, Jian Tang, David Roblin, Tom L Blundell, Michael M Bronstein, and Jake P Taylor-King. Utilizing graph machine learning within drug discovery and development. Briefings in Bioinformatics, 05 2021. ISSN 1477-4054.
|
| 222 |
+
|
| 223 |
+
[21] Floris Geerts. The expressive power of kth-order invariant graph networks. arXiv preprint arXiv:2007.12035, 2020.
|
| 224 |
+
|
| 225 |
+
[22] Rafael Gómez-Bombarelli, Jennifer N. Wei, David Duvenaud, José Miguel Hernández-Lobato, Benjamín Sánchez-Lengeling, Dennis Sheberla, Jorge Aguilera-Iparraguirre, Timothy D. Hirzel, Ryan P. Adams, and Alán Aspuru-Guzik. Automatic chemical design using a data-driven continuous representation of molecules. ACS Central Science, 4(2):268–276, Jan 2018. ISSN 2374-7951. doi: 10.1021/acscentsci.7b00572.
|
| 226 |
+
|
| 227 |
+
[23] 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 Advances in Neural Information Processing Systems, volume 33, 2020.
|
| 228 |
+
|
| 229 |
+
[24] Truong Son Hy, Shubhendu Trivedi, Horace Pan, Brandon M Anderson, and Risi Kondor. Covariant compositional networks for learning graphs. Anchorage ’19: 15th International Workshop on Mining and Learning with Graphs, 2019.
|
| 230 |
+
|
| 231 |
+
[25] Paul J. Kelly. A congruence theorem for trees. Pacific Journal of Mathematics, 7(1):961–968, 1957.
|
| 232 |
+
|
| 233 |
+
[26] Nicolas Keriven and Gabriel Peyré. Universal invariant and equivariant graph neural networks. In Advances in Neural Information Processing Systems, volume 32, 2019.
|
| 234 |
+
|
| 235 |
+
[27] Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. In International Conference on Learning Representations, 2017.
|
| 236 |
+
|
| 237 |
+
[28] Devin Kreuzer, Dominique Beaini, Will Hamilton, Vincent Létourneau, and Prudencio Tossou. Rethinking graph transformers with spectral attention. In Advances in Neural Information Processing Systems, volume 34, 2021.
|
| 238 |
+
|
| 239 |
+
[29] Jungmin Kwon, Jeongseop Kim, Hyunseo Park, and In Kwon Choi. Asam: Adaptive sharpnessaware minimization for scale-invariant learning of deep neural networks. In International Conference on Machine Learning, 2021.
|
| 240 |
+
|
| 241 |
+
[30] Pan Li and Jure Leskovec. The expressive power of graph neural networks. In Lingfei Wu, Peng Cui, Jian Pei, and Liang Zhao, editors, Graph Neural Networks: Foundations, Frontiers, and Applications, pages 63–98. Springer Singapore, Singapore, 2022.
|
| 242 |
+
|
| 243 |
+
[31] Derek Lim, Joshua David Robinson, Lingxiao Zhao, Tess Smidt, Suvrit Sra, Haggai Maron, and Stefanie Jegelka. Sign and basis invariant networks for spectral graph representation learning. In ICLR 2022 Workshop on Geometrical and Topological Representation Learning, 2022.
|
| 244 |
+
|
| 245 |
+
[32] Haggai Maron, Heli Ben-Hamu, Hadar Serviansky, and Yaron Lipman. Provably powerful graph networks. In Advances in Neural Information Processing Systems, volume 32, 2019.
|
| 246 |
+
|
| 247 |
+
[33] Haggai Maron, Heli Ben-Hamu, Nadav Shamir, and Yaron Lipman. Invariant and equivariant graph networks. In International Conference on Learning Representations, 2019.
|
| 248 |
+
|
| 249 |
+
[34] Haggai Maron, Ethan Fetaya, Nimrod Segol, and Yaron Lipman. On the universality of invariant networks. In International Conference on Machine Learning, 2019.
|
| 250 |
+
|
| 251 |
+
[35] Haggai Maron, Or Litany, Gal Chechik, and Ethan Fetaya. On learning sets of symmetric elements. In International Conference on Machine Learning, 2020.
|
| 252 |
+
|
| 253 |
+
[36] Christopher Morris, Martin Ritzert, Matthias Fey, William L Hamilton, Jan Eric Lenssen, Gaurav Rattan, and Martin Grohe. Weisfeiler and leman go neural: Higher-order graph neural networks. In Proceedings of the AAAI conference on artificial intelligence, volume 33, 2019.
|
| 254 |
+
|
| 255 |
+
[37] Christopher Morris, Nils M Kriege, Franka Bause, Kristian Kersting, Petra Mutzel, and Marion Neumann. TUDataset: A collection of benchmark datasets for learning with graphs. In ICML Graph Representation Learning and Beyond $( G R L + ,$ ) Workhop, 2020.
|
| 256 |
+
|
| 257 |
+
[38] Christopher Morris, Gaurav Rattan, and Petra Mutzel. Weisfeiler and leman go sparse: Towards scalable higher-order graph embeddings. In Advances in Neural Information Processing Systems, volume 33, 2020.
|
| 258 |
+
|
| 259 |
+
[39] Christopher Morris, Yaron Lipman, Haggai Maron, Bastian Rieck, Nils M Kriege, Martin Grohe, Matthias Fey, and Karsten Borgwardt. Weisfeiler and leman go machine learning: The story so far. arXiv preprint arXiv:2112.09992, 2021.
|
| 260 |
+
|
| 261 |
+
[40] Christopher Morris, Gaurav Rattan, Sandra Kiefer, and Siamak Ravanbakhsh. Speqnets: Sparsity-aware permutation-equivariant graph networks. In ICLR 2022 Workshop on Geometrical and Topological Representation Learning, 2022.
|
| 262 |
+
|
| 263 |
+
[41] Mathias Niepert, Pasquale Minervini, and Luca Franceschi. Implicit mle: Backpropagating through discrete exponential family distributions. In Advances in Neural Information Processing Systems, volume 34, 2021.
|
| 264 |
+
|
| 265 |
+
[42] Pál András Papp and Roger Wattenhofer. A theoretical comparison of graph neural network extensions. arXiv preprint arXiv:2201.12884, 2022.
|
| 266 |
+
|
| 267 |
+
[43] Pál András Papp, Karolis Martinkus, Lukas Faber, and Roger Wattenhofer. Dropgnn: Random dropouts increase the expressiveness of graph neural networks. In Advances in Neural Information Processing Systems, 2021.
|
| 268 |
+
|
| 269 |
+
[44] 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, volume 32, 2019.
|
| 270 |
+
|
| 271 |
+
[45] Omri Puny, Heli Ben-Hamu, and Yaron Lipman. Global attention improves graph networks generalization. arXiv preprint arXiv:2006.07846, 2020.
|
| 272 |
+
|
| 273 |
+
[46] Chendi Qian, Gaurav Rattan, Floris Geerts, Christopher Morris, and Mathias Niepert. Ordered subgraph aggregation networks. In Advances in Neural Information Processing Systems, volume 35, 2022.
|
| 274 |
+
|
| 275 |
+
[47] Siamak Ravanbakhsh. Universal equivariant multilayer perceptrons. In International Conference on Machine Learning, 2020.
|
| 276 |
+
|
| 277 |
+
[48] Yu Rong, Wenbing Huang, Tingyang Xu, and Junzhou Huang. Dropedge: Towards deep graph convolutional networks on node classification. In International Conference on Learning Representations, 2019.
|
| 278 |
+
|
| 279 |
+
[49] Ryoma Sato. A survey on the expressive power of graph neural networks. arXiv preprint arXiv:2003.04078, 2020.
|
| 280 |
+
|
| 281 |
+
[50] Teague Sterling and John J. Irwin. ZINC 15 – ligand discovery for everyone. Journal of Chemical Information and Modeling, 55(11):2324–2337, 11 2015. doi: 10.1021/acs.jcim.5b00559.
|
| 282 |
+
|
| 283 |
+
[51] Erik Thiede, Wenda Zhou, and Risi Kondor. Autobahn: Automorphism-based graph neural nets. In Advances in Neural Information Processing Systems, volume 34, 2021.
|
| 284 |
+
|
| 285 |
+
[52] Stanislaw M. Ulam. A collection of mathematical problems, volume 8. Interscience Publishers, 1960.
|
| 286 |
+
|
| 287 |
+
[53] Clément Vignac, Andreas Loukas, and Pascal Frossard. Building powerful and equivariant graph neural networks with structural message-passing. In Advances in Neural Information Processing Systems, volume 33, 2020.
|
| 288 |
+
[54] Boris Weisfeiler and Andrei Leman. The reduction of a graph to canonical form and the algebra which appears therein. NTI, Series, 2(9):12–16, 1968.
|
| 289 |
+
[55] Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural networks? In International Conference on Learning Representations, 2019.
|
| 290 |
+
[56] Jiaxuan You, Jonathan Gomes-Selman, Rex Ying, and Jure Leskovec. Identity-aware graph neural networks. AAAI Conference on Artificial Intelligence (AAAI), 2021.
|
| 291 |
+
[57] Chulhee Yun, Suvrit Sra, and Ali Jadbabaie. Small relu networks are powerful memorizers: a tight analysis of memorization capacity. In Advances in Neural Information Processing Systems, volume 32, 2019.
|
| 292 |
+
[58] Manzil Zaheer, Satwik Kottur, Siamak Ravanbakhsh, Barnabas Poczos, Russ R Salakhutdinov, and Alexander J Smola. Deep sets. In Advances in Neural Information Processing Systems, volume 30, 2017.
|
| 293 |
+
[59] Muhan Zhang and Pan Li. Nested graph neural networks. In Advances in Neural Information Processing Systems, volume 34, 2021.
|
| 294 |
+
[60] Muhan Zhang, Zhicheng Cui, Marion Neumann, and Yixin Chen. An end-to-end deep learning architecture for graph classification. Proceedings of the AAAI Conference on Artificial Intelligence, 2018.
|
| 295 |
+
[61] Lingxiao Zhao, Wei Jin, Leman Akoglu, and Neil Shah. From stars to subgraphs: Uplifting any GNN with local structure awareness. In International Conference on Learning Representations, 2022.
|
| 296 |
+
|
| 297 |
+
# Checklist
|
| 298 |
+
|
| 299 |
+
1. For all authors...
|
| 300 |
+
|
| 301 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
|
| 302 |
+
(b) Did you describe the limitations of your work? [Yes] We discussed limitations of several previous works, as well as our own model, throughout the paper as our main contribution.
|
| 303 |
+
(c) Did you discuss any potential negative societal impacts of your work? [Yes] See Section 8.
|
| 304 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 305 |
+
|
| 306 |
+
2. If you are including theoretical results...
|
| 307 |
+
|
| 308 |
+
(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] See Appendices B and D.
|
| 309 |
+
|
| 310 |
+
3. If you ran experiments...
|
| 311 |
+
|
| 312 |
+
(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 Section 7 and Appendix G.
|
| 313 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Appendix G.
|
| 314 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] We report the standard deviation computed over multiple seeds for experiments on ZINC12k (Table 1), ogbg-molhiv (Table 2) and on all generalisation experiments (Figures 4a to 4c). We report the standard deviation for the “Counting Substructures” experiments (Table 1) in Appendix G.
|
| 315 |
+
(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 G.
|
| 316 |
+
|
| 317 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 318 |
+
|
| 319 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes]
|
| 320 |
+
(b) Did you mention the license of the assets? [Yes] See Appendix G.
|
| 321 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
|
| 322 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
|
| 323 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
|
| 324 |
+
|
| 325 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 326 |
+
|
| 327 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 328 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 329 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
md/dev/tZXaHWfsXB/tZXaHWfsXB.md
ADDED
|
@@ -0,0 +1,376 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Transcending Scaling Laws with $0 . 1 \%$ Extra Compute
|
| 2 |
+
|
| 3 |
+
Yi Tay† Jason Wei† Hyung Won Chung† Vinh Q. Tran David R. $\mathbf { S _ { 0 } } _ { } ^ { \dagger }$ Siamak Shakeri Xavier Garcia Huaixiu Steven Zheng Jinfeng Rao† Aakanksha Chowdhery Denny Zhou Donald Metzler Slav Petrov Neil Houlsby Quoc V. Le Mostafa Dehghani Google {vqtran,dehghani}@google.com
|
| 4 |
+
|
| 5 |
+
# Abstract
|
| 6 |
+
|
| 7 |
+
Scaling language models improves performance but comes with significant computational costs. This paper proposes UL2R, a method that substantially improves existing language models and their scaling curves with a relatively tiny amount of extra compute. The key idea is to continue training a state-of-theart large language model on a few more steps with UL2’s mixture-of-denoiser objective. We show that, with almost negligible extra computational costs and no new sources of data, we are able to substantially improve the scaling properties of large language models on downstream metrics. In this paper, we continue training a baseline language model, PaLM, with UL2R, introducing a new set of models at 8B, 62B, and 540B scale which we call UPaLM. Impressively, at 540B scale, we show an approximately 2x computational savings rate where U-PaLM achieves the same performance as the final PaLM 540B model at around half its computational budget (i.e., saving ${ \sim } 4 . 4$ million TPUv4 hours). We further show that this improved scaling curve leads to “emergent abilities” on challenging BIG-Bench tasks—for instance, U-PaLM does much better on some tasks or demonstrates better quality at much smaller scale (62B as opposed to 540B). Overall, we show that U-PaLM outperforms PaLM on many few-shot setups, including reasoning tasks with chain-of-thought (e.g., GSM8K), multilingual tasks (MGSM, TydiQA), MMLU and challenging BIG-Bench tasks.
|
| 8 |
+
|
| 9 |
+
# 1 Introduction
|
| 10 |
+
|
| 11 |
+
There has been significant interest in scaling of language models [Rae et al., 2021, Chowdhery et al., 2022, Brown et al., 2020]. Scaling has inspired new research across multiple fronts, e.g., scaling laws [Kaplan et al., 2020, Hoffmann et al., 2022, Tay et al., 2022a], emergent abilities [Wei et al., 2022a, Ganguli et al., 2022], reasoning capabilities [Wei et al., 2022b, Lewkowycz et al., 2022], inter alia. Generally, scaling laws predict a continued improvement in language model quality as we continue to scale up the computational budget (e.g., bigger models or more data). To date, most large language models that form the basis of scaling law research are trained almost exclusively as left-to-right causal language models [Kaplan et al., 2020, Hoffmann et al., 2022].
|
| 12 |
+
|
| 13 |
+

|
| 14 |
+
Figure 1: Compute (training flops) versus Quality (average of $^ { 2 0 + }$ NLP zero and few-shot tasks listed in Appendix 11.2). The black dotted line shows the path from initialization from a PaLM checkpoint and training further with UL2R.
|
| 15 |
+
|
| 16 |
+
This paper proposes a new method to dramatically improve the scaling curves of large language models on downstream performance with a relatively tiny amount of additional computation cost. The key idea is to continue training an existing causal language model [Chowdhery et al., 2022] with a mixture of new objectives—specifically, the UL2 training objective mixture [Tay et al., 2022b]. This restoration is expected to only cost roughly $0 . 1 \%$ to $1 \%$ of the original training FLOPs and requires no new data sources, making it highly efficient and convenient. We call this approach UL2R or UL2Restore.
|
| 17 |
+
|
| 18 |
+
The UL2 objective combines prefix language modeling and long-short span corruption (e.g., infilling) tasks [Raffel et al., 2019] that can be controlled at inference time using a mode switching prompt. Training a large language model with UL2 can be interpreted as teaching it to leverage bidirectional attention (i.e., PrefixLM) or leverage infilling-style pretraining that have been the foundation of language understanding (e.g., T5 [Raffel et al., 2019]). To this end, we postulate that imbuing a state-of-theart large language model such as PaLM [Chowdhery et al., 2022] with these diverse pretraining schemes as a complement to the original language model objective, enables the model to perform significantly better. Moreover, the UL2 objective enables new prompting capabilities in PaLM which allows it to perform infilling based prompting.
|
| 19 |
+
|
| 20 |
+
We show that adapting PaLM with UL2R not only results in significantly better scaling laws on well-established few-shot NLP tasks, but also, in our scaling experiments on downstream few-shot tasks, we show that UL2R is two times more efficient (computation savings of approximately 2x) at 540B scale - reaching the performance of the final PaLM 540B model with only half the computation, saving up to 4.4 million TPUv4 hours.
|
| 21 |
+
|
| 22 |
+
In addition to competitive performance across a range of well-established NLP [Wang et al., 2019], multilingual [Clark et al., 2020a, Shi et al., 2022], and reasoning [Cobbe et al., 2021] benchmarks, we also study the impact of UL2R on a suite of challenging BigBench tasks from Wei et al. [2022a]. Notably, a subset of tasks are described as ‘emergent‘ because PaLM’s performance remains flat up to model scale of 62B and only becomes better than non-random at 540B scale. On these set of tasks, we find that UL2R enables (1) doing significantly better at tasks that PaLM struggles at (e.g., navigate, geometric shapes, hyperbaton) and (2) elicits emergent behavior at a smaller scale such as 62B or 8B (e.g., crass ai, vitaminc fact verification). On top of that, U-PaLM strongly outperforms PaLM on some challenging BigBench tasks.
|
| 23 |
+
|
| 24 |
+
Emergence within the context of large language models is a nascent research area. As the Nobel prize-winning physicist Philip Anderson put it, ‘More is different.‘ [Anderson, 1972] which describes unpredictable phenomena at different scales. In our context and with mixture-of-denoisers in UL2, we would like to think of this phenomena as ‘More is different, but different can also more’ since different pretraining objectives can improve language model quality or elicit new emergent abilities. This work shows that diversity and richer training paradigms can be key to learning new capabilities that were previously hard to acquire with only causal language modeling.
|
| 25 |
+
|
| 26 |
+
Finally, in addition to emergent task performance and overall improved scaling curves, we show that U-PaLM is also practically more useful since it is equipped with a secondary mode of prompting, i.e., bidirectional infilling. Specifically, UL2R enables a secondary capability for prompting U-PaLM which can be used to fill in more than one blanks in the input prompt. Interestingly, we find that only a small amount of UL2R (e.g., $0 . 1 \%$ tokens or FLOPs) is sufficient to imbue the model with this new capability.
|
| 27 |
+
|
| 28 |
+
# 2 U-PaLM
|
| 29 |
+
|
| 30 |
+
This section introduces the technical details of UPaLM (i.e., $\mathbf { P a L M + U L 2 R }$ ). U-PaLM is initialized from PaLM and leverages the same architecture. This section describes the training procedures of UL2R and how they are applied to continue training PaLM. We refer the reader to Section 10 in the Appendix for a comprehensive review of related work.
|
| 31 |
+
|
| 32 |
+
# 2.1 Training Data
|
| 33 |
+
|
| 34 |
+
To keep things consistent, we train this model with the same data mixture as PaLM and do not rely on additional sources of data (labeled or unlabeled).
|
| 35 |
+
|
| 36 |
+
There are three main reasons for this choice. Firstly, we did not want to introduce new tokens to our training process which could conflate findings. Secondly, we did not want to over-index on scaling studies that only measure impact on upstream cross entropy [Hernandez et al., 2022] which claims that repeating data in small quantities could be dis-proportionally harmful. Since the empirical results we obtained are strong, we postulate that repeating tokens could perhaps be not harmful at smaller quantities after all. This is also backed by the continued training of PaLM 62B in [Chowdhery et al., 2022] which showed that repeated data could result in small gains, albeit not as strong as fresh tokens. Thirdly, we consider our data transformation (via UL2) on the training data sufficiently unique and therefore prevents us from explicitly training on the same data with the exact objective or suffering from any memorization issues.
|
| 37 |
+
|
| 38 |
+
# 2.2 Prefix Language Model Architecture
|
| 39 |
+
|
| 40 |
+
We train U-PaLM using the prefix language model (PrefixLM) architecture, also sometimes known as a non-causal decoder-only model. The PrefixLM architecture keeps a non-causal mask in its prefix (or inputs) and applies bidirectional attention to input tokens.
|
| 41 |
+
|
| 42 |
+
In this architecture, we use a total combined sequence length of 2048 (e.g., PaLM’s sequence length) which is then split to 1024 inputs and 1024 targets. In the original UL2 paper and infrastructure, an artifact of its preprocessing pipeline applies padding tokens first before combining inputs and targets. For decoder-only language models, this is inefficient since we would end up with a concatenation of [prefix] [prefix’s padding] [target].
|
| 43 |
+
|
| 44 |
+
In this work, we optimize the Prefix padding by forcing the model to concatenate prefix and target before applying any additional padding. Packing, trimming and padding is then subsequently applied later after the prefix has been concatenated with the targets. Through this prefix optimization, we are able to improve example-level sample efficiency of the model.
|
| 45 |
+
|
| 46 |
+
# 2.3 Loss Objectives
|
| 47 |
+
|
| 48 |
+
This section describes the setting for the UL2 mixture-of-denoisers that we use in UL2R. The UL2 mixture-of-denoiser objective comprises of three types of denoisers.
|
| 49 |
+
|
| 50 |
+
• Regular denoising whereby the noise is sampled as spans, replaced with sentinel tokens. This is also the standard span corruption task used in Raffel et al. [2019]. Spans are typically uniformly sampled with a mean of 3 and a corruption rate of $1 5 \%$ .
|
| 51 |
+
|
| 52 |
+
• Extreme denoising whereby the noise is increased to relatively ‘extreme‘ amounts in either a huge percentage of the original text or being very long in nature. Spans are typically uniformly sampled with a mean length of $\mathbf { 3 2 0 R }$ a corruption rate of up to $5 0 \%$ .
|
| 53 |
+
|
| 54 |
+
• Sequential denoising whereby the noise is always sampled from the start of the text to a randomly sampled point in the text. This is also known as the PrefixLM objective (not to be confused with the architecture).
|
| 55 |
+
|
| 56 |
+
We kept this simple since many ablations were already explored in Tay et al. [2022b]. We kept the original 7 denoisers as the initial version but later found that a mixture of only three tasks, e.g., $5 0 \%$ PrefixLM, $2 5 \%$ Long (extreme) span corruption, and $2 5 \%$ regular span corruption to be quite simple and efficient for the setup of continued training. We kept the original mode prompting tokens in the original UL2 design. We used [S2S] for S-denoisers (PrefixLM), [NLU] for R-denosiers and [NLG] for X-denoisers. The 540B U-PaLM model was mainly trained with $50 \%$ S-denoiser (PrefixLM), $25 \%$ R-denoisers, and $2 5 \%$ X-denoisers.
|
| 57 |
+
|
| 58 |
+
# 2.4 Training
|
| 59 |
+
|
| 60 |
+
We train the 540B model for a total of $2 0 \mathrm { k }$ steps with a batch size of 32. We mildly ablate these settings in early experiments with 62B and 8B models but keep them capped within a certain ballpark (e.g., 128 batch size for 50k steps). As a result, this is more similar to ‘finetuning’ as compared to full pretraining. The number of additional tokens is therefore very negligible compared to the original pretraining run often coming in at around or less than $0 . 1 \%$ additional compute. The total number of extra tokens we train on for the 540B model is approximately 1.3 billion which constitutes $0 . 1 6 \%$ extra computation, as the original PaLM model was pretrained on 780B tokens. We use a cosine learning rate decay schedule that anneals the learning rate from $1 0 ^ { - 4 }$ to $1 0 ^ { - 6 }$ . Notably, we also tried a low constant learning rate and found them to perform quite identically. Our U-PaLM 8B and 62B models are trained using 64 TPUv4 chips. Training an U-PaLM 540B model only consumes 512 TPUv4 chips and finishes in about 5 days which is considered to be lightweight.
|
| 61 |
+
|
| 62 |
+
# 3 Experiments
|
| 63 |
+
|
| 64 |
+
# 3.1 Improved Scaling Properties on Few-shot Learning
|
| 65 |
+
|
| 66 |
+
In this experiment, we show improved scaling curves from small amounts of UL2R training on top of both PaLM 8B and PaLM 540B. We use downstream metrics and few-shot evaluation since (1) this is closer to usability of these models and (2) loss with UL2 and causal language modeling is not comparable. We initialized and trained multiple U-PaLM models using different PaLM intermediate checkpoints. On the 8B model, we repeated this 7 times at different intervals. Given that the 540B model was more computationally demanding, we only managed to fit 3 points. For evaluation, we use the average score of NLU and NLG tasks from the GPT-3 suite [Brown et al., 2020]. In total we use 26 tasks (e.g., TriviaQA, NaturalQuestions, SuperGLUE, PIQA, OpenbookQA, ANLI etc). Detailed scores for Figure 2 can be found in the Appendix.
|
| 67 |
+
|
| 68 |
+

|
| 69 |
+
Figure 2: Computation cost (training flops) [Dehghani et al., 2021] versus Quality (average of $2 0 { + } \mathrm { N L P }$ zero and few-shot tasks). The dotted line shows the path from initialization from a PaLM checkpoint and training further with UL2R. These plots also present pairs of PaLM and U-PaLM models with comparable/similar performance along with the ratio of PaLM computation cost vs the corresponding U-PaLM computation cost. For example, PaLM 540B trained for $\sim 2 5 0 0$ zFLOPs (right most point) took $\sim 2 . 3 5$ times of the computation cost of U-PaLM 540B trained for $\sim 1 0 7 5$ zFLOPs, while both models are comparable in terms of performance on zero/few shot on NLP tasks.
|
| 70 |
+
|
| 71 |
+

|
| 72 |
+
Figure 3: Break down scores of individual zero-shot and one-shot NLP tasks for PaLM and U-PaLM 540B trained for 780B tokens. U-PaLM outperforms PaLM 540B and achieves SOTA on 21 out of 26 tasks.
|
| 73 |
+
|
| 74 |
+
Figure 2 shows that U-PaLM substantially outperforms the original PaLM models both at 8B scale and 540B scale. Note that the dotted lines represent a pathway before and after UL2R training, we show that UL2R training improves the scaling curve of PaLM substantially, i.e., UL2R provides a more compute-efficient performance improvement compared to training the original PaLM models for longer with the standard causal language modeling objective.
|
| 75 |
+
|
| 76 |
+
8B versus 540B Generally, UL2R consistently improves the underlying PaLM models. Nevertheless, we observe different behaviors on the 8B and 540B models. The gap seems to narrow as the performance of PaLM 8B starts to plateau, i.e., the largest gains are near to the middle of training. As for 540B, the gain continues to grow even at 780B tokens. We believe that this is due to the fact that PaLM 540B still has significant headroom beyond 780B tokens.
|
| 77 |
+
|
| 78 |
+
Savings Rate At a certain stage of training, we have an option to continue training for K more steps using the standard causal language modeling objective OR applying UL2R for a small amount of steps. Here we discuss the counterfactual savings rate of choosing UL2R as opposed to continue training with caussal language modeling. For the 540B model, the saving rates at the middle checkpoint is approximately $2 \mathbf { x }$ . This is equivalent to about 4.4 million TPUv4 hours for the 540B model. For the 8B model, the saving rate tend to be lowest at both the start and convergence of the model. It seems to be higher at middle stages of training (relative to convergence) which shows that the utility of UL2R changes with respect to the amount of causal language modeling training already done. For the 540B model, since the PaLM model was not trained to convergence and the number of tokens to parameters ratio is relatively low, the savings rate could still be increasing even beyond $2 . 3 5 \mathrm { x }$ . Overall, the amount of savings is quite proportionate to the point of training and stage of convergence of the model and can probably be predicted by standard scaling laws [Kaplan et al., 2020, Hoffmann et al., 2022].
|
| 79 |
+
|
| 80 |
+
Table 1: List of challenging tasks in the BigBench emergent suite (BBES) and corresponding scores of PaLM 540B and U-PaLM 540B. All results are reported with standard 5-shot prompting.
|
| 81 |
+
|
| 82 |
+
<table><tr><td>task</td><td>task /reasoning type</td><td>PaLM540B</td><td>U-PaLM540B</td></tr><tr><td>navigate</td><td>arithmetic,logical</td><td>55.3</td><td>67.0 (+21.2%)</td></tr><tr><td>strategyqa</td><td>multi-step</td><td>73.9</td><td>78.3 (+6.0%)</td></tr><tr><td>crass_ai</td><td>commonsense</td><td>97.7</td><td>100 (+2.4%)</td></tr><tr><td>logical_sequence</td><td>commonsense</td><td>92.3</td><td>86.5 (-6.7%)</td></tr><tr><td>vitaminc_fact_verification</td><td>contextual, commonsense</td><td>70.2</td><td>73.9 (+5.3%)</td></tr><tr><td>understanding_fables</td><td>commonsense</td><td>75.7</td><td>78.4 (+3.6%)</td></tr><tr><td>identify_odd_metaphor</td><td>analogical</td><td>87.2</td><td>87.5 (+0.3%)</td></tr><tr><td>hyperbaton</td><td>contextual QA</td><td>54.2</td><td>59.9 (+10.5%)</td></tr><tr><td>causal_judgment</td><td>causal and commonsense</td><td>65.3</td><td>68.4 (+4.7 %)</td></tr><tr><td>english_proverbs</td><td>commonsense,contextual QA</td><td>91.2</td><td>87.5 (-4.2%)</td></tr><tr><td>geometric_shapes</td><td>algorithmic,visual</td><td>44.0</td><td>49.3 (+12.0%)</td></tr><tr><td>physics_questions</td><td>logical, physics,math</td><td>7.6</td><td>12.5 (+64.5%)</td></tr><tr><td>snarks</td><td>commmonsense</td><td>69.1</td><td>86.1 (+24.6%)</td></tr><tr><td>analogical_similarity</td><td>analogical</td><td>36.5</td><td>37.5 (+2.7%)</td></tr><tr><td>international_phonetic_alphabet_nli</td><td>reading comprehension</td><td>65.9</td><td>68.0 (+3.2%)</td></tr><tr><td>movie_dialog_same_or_different</td><td>commonsense,reading compre.</td><td>64.8</td><td>68.8 (+6.2%)</td></tr><tr><td>timedial</td><td>commonsense,logical</td><td>78.3</td><td>81.2 (+3.7%)</td></tr><tr><td>question_selection</td><td>reading comprehension</td><td>54.8</td><td>59.8 (+9.1%)</td></tr><tr><td>logical_fallacy_detection</td><td>logical reasoning</td><td>80.3</td><td>81.4 (+1.4%)</td></tr><tr><td>unit_interpretation</td><td>arithmetic,logical</td><td>47.0</td><td>51.0 (+8.5%)</td></tr><tr><td>language_identification</td><td>multilingual</td><td>36.0</td><td>38.9 (+8.1%)</td></tr><tr><td>average (21 tasks)</td><td></td><td>64.3</td><td>67.7 (+5.3%)</td></tr></table>
|
| 83 |
+
|
| 84 |
+

|
| 85 |
+
Figure 4: Scaling plots on BIG-Bench emergent suite (BBES) for different sizes of PaLM, U-PaLM, Gopher, and GPT-3 as a function of training FLOPs. Scores are normalized scores where zero denotes more or less random performance. X-axis is in log-scale.
|
| 86 |
+
|
| 87 |
+
Breakdown on individual tasks Figure 3 reports the individual scores on each zero and one-shot task in the mixture. We show that U-PaLM 540B outperforms PaLM 540B on 21 out of 26 tasks. Given that PaLM is the SOTA language model on these tasks, this makes U-PaLM the new state-of-the-art on these tasks.
|
| 88 |
+
|
| 89 |
+
# 3.2 BigBench Emergent Suite
|
| 90 |
+
|
| 91 |
+
We select a suite of challenging tasks from BigBench based on a criterion that performance on PaLM on these tasks remain relatively flat-lined at 8B and 62B scale but suddenly unlocks at 540B. We also consider tasks that are difficult for PaLM 540B to solve (near random performance). We call these suite of tasks EMERGENT suite of BigBench tasks (BBES) as inspired by the criterion set by Wei et al. [2022a]. Note that while these set of tasks overlap but are not entirely identical to BBH [Suzgun et al., 2022]. Moreover, BBES uses the default prompting and templates as BIG-Bench and do not use chain-of-thought prompting. Hence, they are not entirely comparable. BBH results can be found later in section 11.1.3.
|
| 92 |
+
|
| 93 |
+
Table 2: Results on finetuning on SuperGLUE and TydiQA dev sets.
|
| 94 |
+
|
| 95 |
+
<table><tr><td></td><td>PaLM 8B</td><td>U-PaLM8B</td><td>PaLM 62B</td><td>U-PaLM 62B</td></tr><tr><td>SuperGLUE (Avg)</td><td>83.4</td><td>86.1(+3.2%)</td><td>89.5</td><td>91.4 (+2.1%)</td></tr><tr><td>TydiQA (EM/F1)</td><td>75.7/85.2</td><td>77.5 (+2.3%)/86.7(+1.7%)</td><td>78.3/87.3</td><td>78.4 (+0.1%)/88.5 (+2.1%)</td></tr></table>
|
| 96 |
+
|
| 97 |
+
Table 3: Results on Massively Multi-Task Language Understanding (MMLU) test set.
|
| 98 |
+
|
| 99 |
+
<table><tr><td>Method</td><td>Accuracy</td></tr><tr><td>Random</td><td>25.0%</td></tr><tr><td>Average Human Rater</td><td>34.5%</td></tr><tr><td>GPT-3 5-shot</td><td>43.9%</td></tr><tr><td>Gopher 5-shot</td><td>60.0%</td></tr><tr><td>Chinchilla 5-shot</td><td>67.6%</td></tr><tr><td>PaLM540B 5shot U-PaLM540B 5-shot</td><td>69.3 % 70.7 % (+2.0%)</td></tr></table>
|
| 100 |
+
|
| 101 |
+
# 3.2.1 BIG-Bench Results
|
| 102 |
+
|
| 103 |
+
Table 1 reports the results of PaLM 540B and U-PaLM 540B on the BigBench emergent suite. We also describe the task and reasoning task for each task. Note that some tasks require a conjunction of various ‘skills’ to excel at. For example, the navigate task is a combination of spatial reasoning and arithmetic (counting).
|
| 104 |
+
|
| 105 |
+
Overall results and Scaling Plots We observe that U-PaLM outperforms PaLM on 19 out of the 21 tasks at 540B scale. Moreover, the gains on certain tasks are substantial (e.g., $5 5 . 3 \% \to 6 7 . 0 \%$ ) on navigate and $6 9 . 1 \% \to 8 6 . 1 \%$ on snarks). On average, there is a $+ 5 . 4 \%$ relative quality gain on the un-normalized aggregated average across all 21 tasks which we consider to be pretty strong results. Figure 4 which shows the scaling plots of U-PaLM relative to other models. Whenever possible, we also include baselines such as GPT-3 or Gopher from the official BIG-Bench repository.
|
| 106 |
+
|
| 107 |
+
UL2R unlocks emergent task performance at smaller scales Scale (e.g., scaling to 540B) is known to be one factor that results in emergent task performance [Wei et al., 2022a]. We show that UL2R is able to elicit emergent abilities at smaller scales. For example, the quality on certain tasks such as crass_ai, vitaminc, identify_odd_metaphors are tasks where performance starts to spike at 62B scale (as opposed to only at 540B with the PaLM model. In rarer occasions, the performance of U-PaLM 8B is even higher than PaLM 62B (e.g., snarks, understanding_fables). Overall, these results show that there are strong evidence that inductive bias (e.g., combinations of prefix language modeling, span corruption based pretraining in UL2) could be crucial when it comes to unraveling new abilities in large language models.
|
| 108 |
+
|
| 109 |
+
# 3.2.2 MMLU Results
|
| 110 |
+
|
| 111 |
+
We compare PaLM and U-PaLM on the Massively Multi-Task Language Understanding (MMLU) benchmark [Hendrycks et al., 2020]. Table 3 reports our results on MMLU’s test set. Prior results are reported from [Hoffmann et al., 2022]. Our results show that U-PaLM outperforms PaLM on this task in the 5-shot setup by $2 . 0 \%$ relative gain.
|
| 112 |
+
|
| 113 |
+
# 3.3 Finetuning
|
| 114 |
+
|
| 115 |
+
We conduct experiments on SuperGLUE [Wang et al., 2019] and TydiQA [Clark et al., 2020a] finetuning. We conduct experiments at 8B and 62B scale1. Fine-tuning is conducted with a constant learning rate for $1 0 0 k$ steps with a batch size of 32. Table 2 reports finetuning results. We observe that there is substantial improvement in fine-tuning especially at the 8B scale. The gains diminish slightly at 62B scale but are still modest in general. We note that PaLM’s fine-tuning performance can be generally considered weaker than expected. For instance, PaLM 8B is generally outperformed by a T5.1.1 large model on the SuperGLUE dev average. We postulate that training PaLM on UL2 and span corruption tasks in complement to causal language modeling can ameliorate some of its flaws. Our results ascertains this by showing that U-PaLM strongly improves quality especially at smaller (8B) scales.
|
| 116 |
+
|
| 117 |
+

|
| 118 |
+
Figure 5: An example of a prompt that is improved by rephrasing to use U-PaLM’s infilling capabilities.
|
| 119 |
+
|
| 120 |
+
# 3.4 Additional Results & Analysis
|
| 121 |
+
|
| 122 |
+
We conduct additional, extensive, evaluation and analysis of our approach. Due to space constraints we refer the reader to Section 11 in the Appendix. There we provide results for zero-shot and few-shot NLP tasks including commonsense reasoning, closed book QA & reading comprehension, reasoning & chain-of-thought, and few-shot multilingual tasks. We find that the improvements from U-PaLM over PaLM generally hold across these additional tasks, with major improvements on certain tasks such as GSM8K $( + 6 . 6 \% )$ [Cobbe et al., 2021], BIG-Bench Hard $( + 1 0 . 7 \% )$ [Suzgun et al., 2022], and MGSM $( + 8 . 7 \% )$ [Shi et al., 2022]. We also include analysis of BBES performance, scaling curves for few-shot experiments, and additional discussion of our methods.
|
| 123 |
+
|
| 124 |
+
in. Notably, with U-PaLM it is possible to query both the infill style and the traditional style via the usage of extra ID tokens (as it is used in denoising) or without, respectively.
|
| 125 |
+
|
| 126 |
+
In Figure 5, we include example outputs for PaLM, U-PaLM with traditional prompting, as well as U-PaLM with infill prompting. We phrase this particular prompt in two ways: one as a question that is suitable for traditional prompting via PaLM and one leveraging U-PaLM’s infill capabilities. In the traditional phrasing, both PaLM and U-PaLM do not produce the correct answer. With the infill phrasing, PaLM ignores the infill token (extra ID token) as PaLM has not seen it during training, and instead produces the rest of the steps after step 4. U-PaLM correctly infills the second step in this example. Finally, a third example is included to demonstrate U-PaLM’s ability to infill multiple slots. These examples demonstrate that, with only a small amount of additional training, we are able to expand the functionality of PaLM to serve an entirely new class of queries.
|
| 127 |
+
|
| 128 |
+
# 4 Qualitative Analysis: New Prompting Capabilities
|
| 129 |
+
|
| 130 |
+
# 4.1 Infilling Ability
|
| 131 |
+
|
| 132 |
+
Left-to-right casual language model pretraining has typically allowed models to provide meaningful continuations of prompts. With U-PaLM we observe that, by extending pretraining with a small amount of UL2 denoising steps, the model is also able to pick up infilling abilities – where the model is given a location in the middle of a prompt to fill
|
| 133 |
+
|
| 134 |
+
# 4.2 Leveraging Specific Pretraining Modes
|
| 135 |
+
|
| 136 |
+
Recall that via the UL2 objective, R-, X-, and S-denoisers are associated with the [NLU], [NLG], and [S2S] mode tokens respectively. S-denoisers are essentially the PrefixLM objective, while R- and X-denoisers are variations of span corruption, and thus are also associated with extra ID tokens which we can use during prompting for infill (as shown above.) Given this unique setup, we can control the mode token during inference to gain access to specific knowledge that might have been acquired in one mode but not another. This effectively provides us with more options in how to answer prompts, without the need to make any changes to the learned model or its inference algorithm.
|
| 137 |
+
|
| 138 |
+

|
| 139 |
+
Figure 6: An example of a prompt that works only when querying a specific pretraining mode.
|
| 140 |
+
|
| 141 |
+

|
| 142 |
+
Figure 7: Querying U-PaLM for diverse outputs by using different prompt mode token and LM/infill combinations.
|
| 143 |
+
|
| 144 |
+
In Figure 6, we include a challenging example where we ask the model to do zero-shot cross-lingual question answering from an English question into a Vietnamese answer. For PaLM and U-PaLM default, we pass the input as-is to the model. For the rest, we prepend one of [S2S], [NLU], or [NLG] to the beginning of the input, and in the case of [NLU] and [NLG], we add the infill token at the end of the input, as typical for these modes. Interestingly, U-PaLM in [S2S] mode is the only variant that returns the correct answer in Vietnamese. Regular PaLM produces the correct answer, but ignores the Vietnamese request, while U-PaLM with default prompting (no mode, no infill) produces a roughly correct answer but could be more specific (’xanh’ encompasses both greens and blues). This example shows how accessing specific mode tokens may work well for some prompts more so than others, giving us a powerful technique to serve a larger variety of prompts.
|
| 145 |
+
|
| 146 |
+
Even though [NLU] and [NLG] modes typically coincide during pretraining with span corruption (involving extra ID tokens, infilling), we can still use [NLU] and [NLG] mode tokens with no infilling at all. Similarly we can use infilling but with no mode tokens. The variety of ways to prompt U-PaLM results in a useful technique to increase the diversity of the outputs we can get from the model, without resorting to alternative decoding techniques (e.g. sampling). This is particularly useful for more open-ended prompts.
|
| 147 |
+
|
| 148 |
+
In Figure 7, we ask PaLM and all variants of querying U-PaLM to write a haiku about "a cat baking a cake on a lake" - a very random prompt that the model is unlikely to see during training, yet requires very structured output. All outputs use greedy decoding here, and surprisingly all models generate reasonable haikus about the topic, although not all follow a strict 5-7-5 syllable structure. PaLM’s haiku repeats the first and last line, which is somewhat less interesting. We can see that the different combinations of querying U-PaLM results in pleasantly varying poems.
|
| 149 |
+
|
| 150 |
+
# 4.3 Improved Diversity for Open-ended Generation
|
| 151 |
+
|
| 152 |
+
Beyond improving the scaling behavior of PaLM, we find that the small amount of continued training applied in UL2R is sufficient to imbue PaLM with new prompting abilities introduced by the UL2 objective. Namely, the use of denoising in UL2 allows PaLM to acquire infilling abilities. Infilling allows U-PaLM to have a second approach to tackling prompts, which we observe to be very useful. In addition, with U-PaLM we can also supply mode tokens to gain access to specific pretraining objectives. This gives us a powerful tool to control the model without making any updates to the model or its inference. In this section we provide some examples of situations where U-PaLM’s expanded prompting capabilities prove to be useful.
|
| 153 |
+
|
| 154 |
+
# 8 Acknowledgements
|
| 155 |
+
|
| 156 |
+
We thank Le Hou and Oliver Bousquet for their advice and feedback on the paper. We thank Barret Zoph and William Fedus for early discussions about this paper. We thank Adam Roberts for feedback on prior work.
|
| 157 |
+
|
| 158 |
+
# 5 Conclusion
|
| 159 |
+
|
| 160 |
+
We proposed UL2R for continued training of PaLM. We show that with only ${ \approx } 0 . 1 \%$ additional FLOPs (or compute), we are able to improve the scaling curve and properties of PaLM on many downstream tasks and metrics. Notably, UL2R enables a 4.4 million TPUv4 savings at 540B scale. The resulting model which we call U-PaLM outperforms PaLM on English NLP tasks (e.g., commonsense reasoning and closed-book question answering), reasoning tasks with chain-of-thought, multilingual reasoning, MMLU and a suite of challenging BIG-Bench tasks.
|
| 161 |
+
|
| 162 |
+
# 6 Limitations
|
| 163 |
+
|
| 164 |
+
In this work we show the effectiveness of continued training of a 540B PaLM model with UL2R over conditional language modeling alone. We only demonstrate this for the PaLM model and pretraining corpus. Our study is only a demonstration of what is possible with an example near state-of-the-art system, and we do not provide results on what would happen if the underlying model and pretraining corpus were to differ from the one studied here. For example, what would happen if we applied ULR2 to a model that was trained to saturation on a corpus already? Would we observe similar improvements? What would happen if we use a weaker underlying model? This paper also only studies models with $^ { 8 \mathrm { B + } }$ parameters, and does not provide insight on how UL2R would perform on smaller models and compute regions. We leave these investigations for future work, and this work should not be interpreted as a comprehensive study of continued pretraining or model reuse.
|
| 165 |
+
|
| 166 |
+
# References
|
| 167 |
+
|
| 168 |
+
Armen Aghajanyan, Anchit Gupta, Akshat Shrivastava, Xilun Chen, Luke Zettlemoyer, and Sonal Gupta. Muppet: Massive multi-task representations with prefinetuning. arXiv preprint arXiv:2101.11038, 2021.
|
| 169 |
+
|
| 170 |
+
Philip W Anderson. More is different: broken symmetry and the nature of the hierarchical structure of science. Science, 177(4047):393–396, 1972.
|
| 171 |
+
|
| 172 |
+
Vamsi Aribandi, Yi Tay, Tal Schuster, Jinfeng Rao, Huaixiu Steven Zheng, Sanket Vaibhav Mehta, Honglei Zhuang, Vinh Q. Tran, Dara Bahri, Jianmo Ni, Jai Prakash Gupta, Kai Hui, Sebastian Ruder, and Donald Metzler. Ext5: Towards extreme multi-task scaling for transfer learning. ICLR, 2022. URL https://arxiv.org/abs/2111.10952.
|
| 173 |
+
|
| 174 |
+
Yonatan Bisk, Rowan Zellers, Jianfeng Gao, Yejin Choi, et al. Piqa: Reasoning about physical commonsense in natural language. In Proceedings of the AAAI conference on artificial intelligence, volume 34, pages 7432–7439, 2020.
|
| 175 |
+
|
| 176 |
+
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.
|
| 177 |
+
|
| 178 |
+
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.
|
| 179 |
+
|
| 180 |
+
Hyung Won Chung, Longpre Shayne Hou, Le and, Barret Zoph, Yi Tay, William Fedus, and et al. Scaling instruction-finetuned language models. arXiv preprint, 2022.
|
| 181 |
+
|
| 182 |
+
# 7 Ethics Statement
|
| 183 |
+
|
| 184 |
+
As this work continues training PaLM, we defer discussion of ethical considerations with respect to large language models to the original PaLM paper [Chowdhery et al., 2022]. We do note though that this work presents a way of improving large language models without training from scratch, and all the different types of cost (e.g. environmental) that that might entail.
|
| 185 |
+
|
| 186 |
+
Christopher Clark, Kenton Lee, Ming-Wei Chang, Tom Kwiatkowski, Michael Collins, and Kristina Toutanova. Boolq: Exploring the surprising difficulty of natural yes/no questions. In NAACL, 2019.
|
| 187 |
+
|
| 188 |
+
Jonathan H Clark, Eunsol Choi, Michael Collins, Dan Garrette, Tom Kwiatkowski, Vitaly Nikolaev, and Jennimaria Palomaki. Tydi qa: A benchmark for information-seeking question answering in typologically diverse languages. Transactions of the Association for Computational Linguistics, 8: 454–470, 2020a.
|
| 189 |
+
|
| 190 |
+
Kevin Clark, Minh-Thang Luong, Quoc V Le, and Christopher D Manning. Electra: Pre-training text encoders as discriminators rather than generators. arXiv preprint arXiv:2003.10555, 2020b.
|
| 191 |
+
|
| 192 |
+
Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Jacob Hilton, Reiichiro Nakano, Christopher Hesse, and John Schulman. Training verifiers to solve math word problems. arXiv preprint arXiv:2110.14168, 2021.
|
| 193 |
+
|
| 194 |
+
Mostafa Dehghani, Yi Tay, Anurag Arnab, Lucas Beyer, and Ashish Vaswani. The efficiency misnomer. In International Conference on Learning Representations, 2021.
|
| 195 |
+
|
| 196 |
+
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.
|
| 197 |
+
|
| 198 |
+
Andrew Drozdov, Nathanael Schärli, Ekin Akyürek, Nathan Scales, Xinying Song, Xinyun Chen, Olivier Bousquet, and Denny Zhou. Compositional semantic parsing with large language models. arXiv preprint arXiv:2209.15003, 2022.
|
| 199 |
+
|
| 200 |
+
Deep Ganguli, Danny Hernandez, Liane Lovitt, Nova DasSarma, Tom Henighan, Andy Jones, Nicholas Joseph, Jackson Kernion, Ben Mann, Amanda Askell, et al. Predictability and surprise in large generative models. arXiv preprint arXiv:2202.07785, 2022. URL https://arxiv.org/abs/2202.07785.
|
| 201 |
+
|
| 202 |
+
Mor Geva, Daniel Khashabi, Elad Segal, Tushar Khot, Dan Roth, and Jonathan Berant. Did aristotle use a laptop? a question answering benchmark with implicit reasoning strategies. Transactions of the Association for Computational Linguistics, 9: 346–361, 2021.
|
| 203 |
+
|
| 204 |
+
Dan Hendrycks, Collin Burns, Steven Basart, Andy Zou, Mantas Mazeika, Dawn Song, and Jacob Steinhardt. Measuring massive multitask language understanding. arXiv preprint arXiv:2009.03300, 2020.
|
| 205 |
+
|
| 206 |
+
Danny Hernandez, Tom Brown, Tom Conerly, Nova DasSarma, Dawn Drain, Sheer El-Showk, Nelson Elhage, Zac Hatfield-Dodds, Tom Henighan, Tristan Hume, et al. Scaling laws and interpretability of learning from repeated data. arXiv preprint arXiv:2205.10487, 2022.
|
| 207 |
+
|
| 208 |
+
Jordan Hoffmann, Sebastian Borgeaud, Arthur Mensch, Elena Buchatskaya, Trevor Cai, Eliza Rutherford, Diego de Las Casas, Lisa Anne Hendricks, Johannes Welbl, Aidan Clark, et al. Training computeoptimal large language models. arXiv preprint arXiv:2203.15556, 2022.
|
| 209 |
+
|
| 210 |
+
Mandar Joshi, Eunsol Choi, Daniel S Weld, and Luke Zettlemoyer. Triviaqa: A large scale distantly supervised challenge dataset for reading comprehension. arXiv preprint arXiv:1705.03551, 2017.
|
| 211 |
+
|
| 212 |
+
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.
|
| 213 |
+
|
| 214 |
+
Tom Kwiatkowski, Jennimaria Palomaki, Olivia Redfield, Michael Collins, Ankur Parikh, Chris Alberti, Danielle Epstein, Illia Polosukhin, Matthew Kelcey, Jacob Devlin, Kenton Lee, Kristina N. Toutanova, Llion Jones, Ming-Wei Chang, Andrew Dai, Jakob Uszkoreit, Quoc Le, and Slav Petrov. Natural questions: a benchmark for question answering research. Transactions of the Association of Computational Linguistics, 2019.
|
| 215 |
+
|
| 216 |
+
Brian Lester, Rami Al-Rfou, and Noah Constant. The power of scale for parameter-efficient prompt tuning. arXiv preprint arXiv:2104.08691, 2021.
|
| 217 |
+
|
| 218 |
+
Aitor Lewkowycz, Anders Andreassen, David Dohan, Ethan Dyer, Henryk Michalewski, Vinay Ramasesh, Ambrose Slone, Cem Anil, Imanol Schlag, Theo Gutman-Solo, et al. Solving quantitative reasoning problems with language models. arXiv preprint arXiv:2206.14858, 2022.
|
| 219 |
+
|
| 220 |
+
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. URL https://arxiv.org/abs/2203.02155.
|
| 221 |
+
|
| 222 |
+
Denis Paperno, Germ’an Kruszewski, Angeliki Lazaridou, Ngoc Quan Pham, Raffaella Bernardi, Sandro Pezzelle, Marco Baroni, Gemma Boleda, and Raquel Fern’andez. The LAMBADA dataset: Word prediction requiring a broad discourse context. In Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 1525–1534, Berlin, Germany, August 2016. Association for Computational Linguistics. doi: 10.18653/v1/P16-1144. URL https://www.aclweb.org/anthology/P16-1144.
|
| 223 |
+
|
| 224 |
+
Jack W Rae, Sebastian Borgeaud, Trevor Cai, Katie Millican, Jordan Hoffmann, Francis Song, John Aslanides, Sarah Henderson, Roman Ring, Susannah Young, et al. Scaling language models: Methods, analysis & insights from training gopher. arXiv preprint arXiv:2112.11446, 2021.
|
| 225 |
+
|
| 226 |
+
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.
|
| 227 |
+
|
| 228 |
+
Adam Roberts, Colin Raffel, and Noam Shazeer. How much knowledge can you pack into the parameters of a language model? arXiv preprint arXiv:2002.08910, 2020.
|
| 229 |
+
|
| 230 |
+
Keisuke Sakaguchi, Ronan Le Bras, Chandra Bhagavatula, and Yejin Choi. Winogrande: An adversarial winograd schema challenge at scale. arXiv preprint arXiv:1907.10641, 2019.
|
| 231 |
+
|
| 232 |
+
Victor Sanh, Albert Webson, Colin Raffel, Stephen Bach, Lintang Sutawika, Zaid Alyafeai, Antoine Chaffin, Arnaud Stiegler, Teven Le Scao, Arun Raja, et al. Multitask prompted training enables zero-shot task generalization. ICLR, 2022. URL https: //openreview.net/forum?id=9Vrb9D0WI4.
|
| 233 |
+
|
| 234 |
+
Freda Shi, Mirac Suzgun, Markus Freitag, Xuezhi Wang, Suraj Srivats, Soroush Vosoughi, Hyung Won Chung, Yi Tay, Sebastian Ruder, Denny Zhou, et al. Language models are multilingual chain-of-thought reasoners. arXiv preprint arXiv:2210.03057, 2022.
|
| 235 |
+
|
| 236 |
+
Aarohi Srivastava, Abhinav Rastogi, Abhishek Rao, Abu Awal Md Shoeb, Abubakar Abid, Adam Fisch, Adam R Brown, Adam Santoro, Aditya Gupta, Adrià Garriga-Alonso, et al. Beyond the imitation game: Quantifying and extrapolating the capabilities of language models. arXiv preprint arXiv:2206.04615, 2022.
|
| 237 |
+
|
| 238 |
+
Jacob Steinhardt. Future ml systems will be qualitatively different, 2022. Accessed May 20, 2022.
|
| 239 |
+
|
| 240 |
+
Mirac Suzgun, Nathan Scales, Nathanael Scharli, Sebastian Gehrmann, Yi Tay, Hyung Won Chung, Aakanksha Chowdhery, Quoc V. Le, Ed H. Chi, Denny Zhou, and Jason Wei. Challenging big-bench tasks and whether chain-of-thought can solve them. arXiv preprint, 2022.
|
| 241 |
+
|
| 242 |
+
Alon Talmor, Jonathan Herzig, Nicholas Lourie, and Jonathan Berant. CommonsenseQA: A question answering challenge targeting commonsense knowledge. 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 4149–4158, Minneapolis, Minnesota, June 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-1421. URL https://aclanthology.org/N19-1421.
|
| 243 |
+
|
| 244 |
+
Yi Tay, Mostafa Dehghani, Jinfeng Rao, William Fedus, Samira Abnar, Hyung Won Chung, Sharan Narang, Dani Yogatama, Ashish Vaswani, and Donald Metzler. Scale efficiently: Insights from pre-training and fine-tuning transformers. arXiv preprint arXiv:2109.10686, 2021.
|
| 245 |
+
|
| 246 |
+
Yi Tay, Mostafa Dehghani, Samira Abnar, Hyung Won Chung, William Fedus, Jinfeng Rao, Sharan Narang, Vinh Q Tran, Dani Yogatama, and Donald Metzler. Scaling laws vs model architectures: How does inductive bias influence scaling? arXiv preprint arXiv:2207.10551, 2022a.
|
| 247 |
+
|
| 248 |
+
Yi Tay, Mostafa Dehghani, Vinh Q Tran, Xavier Garcia, Dara Bahri, Tal Schuster, Huaixiu Steven
|
| 249 |
+
|
| 250 |
+
Zheng, Neil Houlsby, and Donald Metzler. Unifying language learning paradigms. arXiv preprint arXiv:2205.05131, 2022b.
|
| 251 |
+
|
| 252 |
+
Yi Tay, Vinh Q Tran, Mostafa Dehghani, Jianmo Ni, Dara Bahri, Harsh Mehta, Zhen Qin, Kai Hui, Zhe Zhao, Jai Gupta, et al. Transformer memory as a differentiable search index. arXiv preprint arXiv:2202.06991, 2022c.
|
| 253 |
+
|
| 254 |
+
Romal Thoppilan, Daniel De Freitas, Jamie Hall, Noam Shazeer, Apoorv Kulshreshtha, Heng-Tze Cheng, Alicia Jin, Taylor Bos, Leslie Baker, Yu Du, et al. Lamda: Language models for dialog applications. arXiv preprint arXiv:2201.08239, 2022.
|
| 255 |
+
|
| 256 |
+
Alex Wang, Yada Pruksachatkun, Nikita Nangia, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R Bowman. Superglue: A stickier benchmark for general-purpose language understanding systems. arXiv preprint arXiv:1905.00537, 2019.
|
| 257 |
+
|
| 258 |
+
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 preprint arXiv:2204.05832, 2022a.
|
| 259 |
+
|
| 260 |
+
Xuezhi Wang, Jason Wei, Dale Schuurmans, Quoc Le, Ed Chi, and Denny Zhou. Self-consistency improves chain of thought reasoning in language models. arXiv preprint arXiv:2203.11171, 2022b.
|
| 261 |
+
|
| 262 |
+
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 preprint arXiv:2109.01652, 2021.
|
| 263 |
+
|
| 264 |
+
Jason Wei, Yi Tay, Rishi Bommasani, Colin Raffel, Barret Zoph, Sebastian Borgeaud, Dani Yogatama, Maarten Bosma, Denny Zhou, Donald Metzler, et al. Emergent abilities of large language models. Transactions on Machine Learning Research (TMLR), 2022a.
|
| 265 |
+
|
| 266 |
+
Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Brian Ichter, Fei Xia, Ed Chi, Quoc Le, and Denny Zhou. Chain of thought prompting elicits reasoning in large language models. Conference on Neural Information Processing Systems (NeurIPS), 2022b.
|
| 267 |
+
|
| 268 |
+
Zhilin Yang, Zihang Dai, Yiming Yang, Jaime Carbonell, Russ R Salakhutdinov, and Quoc V Le. Xlnet: Generalized autoregressive pretraining for language understanding. Advances in neural information processing systems, 32, 2019.
|
| 269 |
+
|
| 270 |
+
Jiahui Yu, Yuanzhong Xu, Jing Yu Koh, Thang Luong, Gunjan Baid, Zirui Wang, Vijay Vasudevan, Alexander Ku, Yinfei Yang, Burcu Karagol Ayan, et al. Scaling autoregressive models for contentrich text-to-image generation. arXiv preprint arXiv:2206.10789, 2022.
|
| 271 |
+
|
| 272 |
+
Rowan Zellers, Ari Holtzman, Yonatan Bisk, Ali Farhadi, and Yejin Choi. Hellaswag: Can a machine really finish your sentence? arXiv preprint arXiv:1905.07830, 2019.
|
| 273 |
+
|
| 274 |
+
Denny Zhou, Nathanael Schärli, Le Hou, Jason Wei, Nathan Scales, Xuezhi Wang, Dale Schuurmans, Olivier Bousquet, Quoc Le, and Ed Chi. Least-tomost prompting enables complex reasoning in large language models. arXiv preprint arXiv:2205.10625, 2022.
|
| 275 |
+
|
| 276 |
+
Barret Zoph, Irwan Bello, Sameer Kumar, Nan Du, Yanping Huang, Jeff Dean, Noam Shazeer, and William Fedus. St-moe: Designing stable and transferable sparse expert models, 2022. URL https://arxiv.org/abs/2202.08906.
|
| 277 |
+
|
| 278 |
+
# 9 Appendix
|
| 279 |
+
|
| 280 |
+
# 10 Related Work
|
| 281 |
+
|
| 282 |
+
Large language models Scaling and improving large language models is one of the most impactful research areas in modern artificial intelligence [Chowdhery et al., 2022]. To this end, large language models not only continue to improve as we scale in terms of data or computational budget [Hoffmann et al., 2022, Kaplan et al., 2020] but also acquire new abilities [Wei et al., 2022a]. The impact of large language models has been ubiquitous and pervasive, unlocking breakthroughs across many fields, e.g., reasoning [Wei et al., 2022b, Wang et al., 2022b, Zhou et al., 2022, Drozdov et al., 2022], math [Lewkowycz et al., 2022], dialog [Thoppilan et al., 2022], multimodal applications [Yu et al., 2022], retrieval [Tay et al., 2022c] inter alia.
|
| 283 |
+
|
| 284 |
+
While there have been many paradigms and self-supervision methods proposed to train these models [Devlin et al., 2018, Clark et al., 2020b, Yang et al., 2019, Raffel et al., 2019], to this date most large language models (i.e., more than 100B parameters) are trained as decoder-only casual language models. For example, flagship large language models such as GPT-3 [Brown et al., 2020], Gopher [Rae et al., 2021] and PaLM [Chowdhery et al., 2022] are all trained as causal language models. Meanwhile, bidirectional models (e.g., BERT [Devlin et al., 2018], T5 [Raffel et al., 2019], ST-MoE [Zoph et al., 2022]) have also been very popular as the goto model of choice, especially in smaller computational regimes (e.g., less than 30B parameters and often times in the ranges of hundred of millions of parameters).
|
| 285 |
+
|
| 286 |
+
Scaling laws of large language models Kaplan et al. [2020] investigated scaling laws of Transformer language models and first showed the scaling laws are predictive of future performance. The authors found that model size (and not shape) correlates strongly with model quality, i.e., upstream cross entropy. Tay et al. [2021] studied the scaling properties of encoder-decoder models and their impact on upstream and downstream finetuning tasks. Generally, Tay et al. [2021] found that upstream perplexity and downstream quality does not always correlate. As a follow up, Tay et al. [2022a] studied the scaling laws of different model architectures and found that inductive bias does significantly impact the scaling behavior of the model. Finally, Hoffmann et al. [2022] proposed compute-optimal models that popularized the ‘chinchilla’ scaling laws - an approach that aims to be predictive of the optimal amount of data given the number of model parameters. In this work, we mainly consider scaling laws over downstream performance largely because this is more reflective of a language model’s usability. Since downstream performance is more important than upstream cross entropy, we advocate for future scaling studies to always incorporate downstream evaluation (and metrics) as opposed to only using cross entropy loss.
|
| 287 |
+
|
| 288 |
+
Emergent Abilities New behaviors that arise due to scaling language models have been increasingly referred to as emergent abilities [Steinhardt, 2022, Ganguli et al., 2022, Wei et al., 2022a]. For instance, Wei et al. [2022a] define emergent abilities as “abilities that are not present in smaller models but as present in larger models.” For a few-shot prompted task, this would look like a flat scaling curve (random performance) until a certain critical threshold, during which performance increases to substantially above random. This type of phenomena has been observed across dozens of tasks in the BIG-Bench benchmark [Srivastava et al., 2022]. Although such emergent abilities are typically observed as a function of scale, increasing model scale to induce emergent abilities is computationally expensive. In this paper we show how UL2R unlocks emergence without increasing the number of model parameters.
|
| 289 |
+
|
| 290 |
+
Continued Training of Language Models The paradigm of continue to train (or finetune) a language model on more data or tasks is commonly known as adaptation. A range of prior work has shown that finetuning language models on a collection of NLP tasks can improve downstream performance on a broad range of downstream tasks [Aghajanyan et al., 2021, Aribandi et al., 2022, Wei et al., 2021, Sanh et al., 2022, Ouyang et al., 2022, inter alia]. The majority of this prior work, however, requires additional data such as aggregating dozens or hundreds of NLP datasets [Raffel et al., 2019, Aghajanyan et al., 2021, Aribandi et al., 2022], writing additional templates of instructions [Wei et al., 2021, Sanh et al., 2022], or finetuning on human-labeled annotations [Ouyang et al., 2022]. UL2R does not require new data since it simply re-uses the pre-training data, which makes it orthogonal to continued training methods that leverage large collections of NLP datasets. Adapting a pretrained language model with a new self-supervised objective has been explored. For example, a model trained with a language modeling objective can be adapted by further training with the masked language modeling objective [Wang et al., 2022a]. The other direction is also possible; a model trained with a masked language objective can be adapted with the causal language modeling objective [Wang et al., 2022a, Lester et al., 2021]. UL2R follows a similar idea but uptrains a language model with a set of diverse and new preordaining tasks from mixture-of-denoisers, even after a vast amounts of standard pretraining and demonstrates a very rapid improvement on variety of setups and tasks.
|
| 291 |
+
|
| 292 |
+
Unified language learner (UL2) The UL2 [Tay et al., 2022b] model is a state-of-the-art model that bridges both generative causal language models and bidirectional language models. UL2 proposes a mixture-of-denoiser objective that mixes prefix (non-causal) language modeling and infilling (span corruption) within the same model and leverages mode prompts to switch between modes during downstream tasks. UL2 is architecture agnostic in which the authors argue that the choice of decoderonly versus encoder-decoder models is largely an efficiency trade-off. In [Tay et al., 2022b], the final UL2 model was trained as a 20B encoder-decoder model, which achieves very compelling performance on both finetuning and in-context learning.
|
| 293 |
+
|
| 294 |
+
# 11 Additional Results & Analysis
|
| 295 |
+
|
| 296 |
+
# 11.0.1 Analyzing individual task performance on BIG-Bench
|
| 297 |
+
|
| 298 |
+
This section dives into individual task performance and attempts to understand quality on different types of BIG-Bench tasks.
|
| 299 |
+
|
| 300 |
+
Spatial or Visual Reasoning Tasks The first category of tasks that U-PaLM does extremely well on are tasks that require some form of spatial or visual reasoning (e.g., navigate or geometric_shapes). In both of these tasks, U-PaLM 8B outperforms PaLM 540B. We postulate that this is due to the prefix language model architecture and additional PrefixLM training that U-PaLM undergoes. To give a better illustration, consider the following examples from these tasks.
|
| 301 |
+
|
| 302 |
+
• In the navigate task, an example is as follows: ‘Turn right. Take 1 step. Turn right. Take 6 steps. Turn right. Take 1 step. Turn right. Take 2 steps. Take 4 steps.‘ and the task is a binary classification task that determines if the agent returns to the starting point.
|
| 303 |
+
|
| 304 |
+
• In the geometric_shapes task, the goal is to predict the shape given an SVG path, e.g., given ‘M $3 I , 2 9 L 3 4 , 7 6 L 8 2 , I 6 L 3 I , 2 9 ^ { \circ }$ the model should predict triangle.
|
| 305 |
+
|
| 306 |
+
Here, it is worth noting that both tasks can be improved intuitively by having bidirectional attention and being trained using a PrefixLM like objective. This could explain why U-PaLM could outperform PaLM 540B even at 8B because it was given the right inductive bias.
|
| 307 |
+
|
| 308 |
+
Commonsense and Knowledge Tasks A reasonable portion out of the 21 tasks require some form of commonsense or language-based knowledge in order to do well. It is worth noting that U-PaLM does not train on any new unique tokens (or new data) and therefore, has no access to no new ‘knowledge’ compared to vanilla PaLM. Hence, gains here are expected to be milder compared to tasks that rely more on algorithmic or other types of reasoning. However, we observe some relatively smaller gains in certain tasks (e.g., understanding_fables or movie_dialog_same_or_different). Amongst the tasks in this category, one exception is the snarks task which involves detecting sarcasm in natural language. It is worth noting that the only 2 out of 21 tasks where U-PaLM underperforms PaLM belongs to this category (e.g., logical_sequence and english_proverbs). We think this is reasonable since we do not completely expect UL2R to always improve upon this category of tasks given that it does not actually process new data tokens.
|
| 309 |
+
|
| 310 |
+
Context Reasoning or Reading Comprehension Tasks Some tasks require some understanding of context and then requires the language model to answer questions based on this context. An example of this is the vitaminc_fact_verficiation task which tries to determine the veracity of a claim given external evidence (context). Another example is the understanding_fables task where the goal is to determine the ‘morale of the story’ given context (passage or story). It is worth noting that U-PaLM exhibits emergence at 62B scale on these two tasks even though the final 540B model performance is relatively similar. We postulate that this is due to the architectural (and pretraining) advantage of PrefixLM which aids the model in performing much better even at smaller scales. Intuitively, being able to bidirectionally reason with context (prefix) could be important in context reasoning tasks.
|
| 311 |
+
|
| 312 |
+
Table 4: Results on zero-shot commonsense reasoning.
|
| 313 |
+
|
| 314 |
+
<table><tr><td>Task /Model Size FLOPS (ZFLOPS)</td><td>PaLM 62B 295.7</td><td>U-PaLM 62B 298.7</td><td>Chinchilla 70B</td><td>Gopher 280B</td><td>PaLM 540B 2527.2</td><td>U-PaLM 540B</td></tr><tr><td>BoolQ 0-shot</td><td>84.8</td><td>85.4</td><td>588 83.7</td><td>504 81.8</td><td>88.0</td><td>2529.7 88.8(+0.9%)</td></tr><tr><td>PIQA 0-shot</td><td>80.5</td><td>81.4</td><td>81.8</td><td>81.8</td><td>82.3</td><td>84.1(+2.2%)</td></tr><tr><td>HellaSwag 0-shot</td><td>79.7</td><td>79.7</td><td>80.8</td><td>79.7</td><td>83.4</td><td>84.1(+0.8%)</td></tr><tr><td>Winogrande 0-shot</td><td>77.0</td><td>76.2</td><td>74.9</td><td>70.1</td><td>81.1</td><td>82.6 (+1.8%)</td></tr><tr><td>Avg. Commonsense</td><td>80.5</td><td>80.7</td><td>80.3</td><td>78.2</td><td>83.7</td><td>84.9 (+1.4%)</td></tr></table>
|
| 315 |
+
|
| 316 |
+
Multi-step Reasoning, Analogical Reasoning and Arithmetic tasks We observe that there are some performance improvements on analogical reasoning task (e.g., analogical_similarity) or multi-step reasoning tasks (strategyqa) at 540B scale. However, unlike context reasoning tasks, the performance on these class of tasks tend to follow similar scaling patterns albeit with slightly better performance. For example, based on Figure 4, we note that strategyqa follows relatively similar scaling curves to PaLM.
|
| 317 |
+
|
| 318 |
+
# 11.1 Zero-shot and Few-shot NLP
|
| 319 |
+
|
| 320 |
+
In this section, we evaluate our models on various well-established NLP tasks. These tasks test a spectrum of zero and few-shot abilities of U-PaLM.
|
| 321 |
+
|
| 322 |
+
# 11.1.1 Commonsense Reasoning
|
| 323 |
+
|
| 324 |
+
We conduct experiments on four zero-shot commonsense reasoning benchmarks. Specifically, following [Hoffmann et al., 2022], we use BoolQ [Clark et al., 2019], PIQA [Bisk et al., 2020], HellaSWAG [Zellers et al., 2019] and Winogrande [Sakaguchi et al., 2019]. Aside from PaLM 62B and PaLM 540B which we use for direct comparisons with U-PaLM, we also compare with Chinchilla 70B [Hoffmann et al., 2022] and Gopher 280B [Rae et al., 2021]. Table 4 reports the results on zero-shot commonsense reasoning.
|
| 325 |
+
|
| 326 |
+
We show that U-PaLM 540B outperforms PaLM 540B on all four tasks with an average of $( + 1 . 4 \% )$ relative improvement and attains the best performance across all models.
|
| 327 |
+
|
| 328 |
+
# 11.1.2 Question Answering and Reading Comprehension
|
| 329 |
+
|
| 330 |
+
We evaluate zero-shot and few-shot closed book question answering (CBQA) tasks [Kwiatkowski et al., 2019, Joshi et al., 2017, Roberts et al., 2020] along with the zero-shot Lambada reading comprehension task [Paperno et al., 2016]. Table 5 reports the results of our experiments. We compare with PaLM 62B, PaLM 540B, Chinchilla 70B and
|
| 331 |
+
|
| 332 |
+
Table 5: Results on closed book QA and reading comprehension.
|
| 333 |
+
|
| 334 |
+
<table><tr><td>Task/Model Size FLOPS (ZFLOPS)</td><td>PaLM 62B 295.7</td><td>U-PaLM 62B 298.7</td><td>Chinchilla 70B 588</td><td>Gopher 280B 504</td><td>PaLM 540B 2527.2</td><td>U-PaLM 540B 2529.7</td></tr><tr><td>TriviaQA 0-shot</td><td>67.3</td><td>68.3</td><td>67.0</td><td>52.8</td><td>76.9</td><td>76.4 (-0.7%)</td></tr><tr><td>TriviaQA few-shot</td><td>72.7</td><td>73.6</td><td>73.2</td><td>63.6</td><td>81.4</td><td>82.0 (+0.7%)</td></tr><tr><td>Natural Questions 0-shot</td><td>18.1</td><td>18.7</td><td>16.6</td><td>10.1</td><td>21.2</td><td>21.7 (+2.4%)</td></tr><tr><td>Natural Questions few-shot</td><td>27.6</td><td>30.5</td><td>31.5</td><td>24.5</td><td>36.0</td><td>40.1 (+11.4%)</td></tr><tr><td>Lambada 0-shot</td><td>75.4</td><td>79.7</td><td>77.2</td><td>74.5</td><td>77.9</td><td>80.5 (+3.3%)</td></tr><tr><td>Avg. QA/RC</td><td>52.2</td><td>54.3</td><td>53.0</td><td>45.1</td><td>58.7</td><td>60.1(+2.3%)</td></tr></table>
|
| 335 |
+
|
| 336 |
+
Table 6: Experiment results on reasoning and chain-ofthought reasoning experiments.
|
| 337 |
+
|
| 338 |
+
<table><tr><td>Task /Model</td><td>Minerva 540B</td><td>PaLM540B</td><td>U-PaLM540B</td></tr><tr><td>GSM8K</td><td>57.8</td><td>54.9</td><td>58.5 (+6.6%)</td></tr><tr><td>BBH</td><td>37.2</td><td>44.8</td><td>49.6 (+10.7%)</td></tr><tr><td>StrategyQA</td><td>61.9</td><td>76.4</td><td>76.6(+0.2%)</td></tr><tr><td>CSQA</td><td>72.2</td><td>76.9</td><td>80.1(+4.2%)</td></tr></table>
|
| 339 |
+
|
| 340 |
+
Gopher 280B. Overall, on few-shot CBQA and reading comprehension, we observe that U-PaLM 540B outperforms PaLM 540B by $+ 2 . 3 \%$ on average and up to $+ 1 1 . 4 \%$ on few-shot natural questions. Meanwhile, the gain at 62B scale is also strong (i.e., $+ 2 . 1 \%$ on average).
|
| 341 |
+
|
| 342 |
+
# 11.1.3 Reasoning and Chain-of-thought Experiments
|
| 343 |
+
|
| 344 |
+
We conduct experiments on reasoning and CoT and compare U-PaLM 540B with PaLM 540B and Minerva 540B. We use the GSM8K [Cobbe et al., 2021], BBH [Suzgun et al., 2022], StrategyQA [Geva et al., 2021] and CommonsenseQA [Talmor et al., 2019] benchmarks. All tasks are run with chain-of-thought (CoT) prompting. Table 6 reports results on reasoning and CoT benchmarks. U-PaLM 540B outperforms both PaLM 540B and Minverva 540B. Notably, the gains on GSM8K and BBH are relatively strong. This shows that U-PaLM does well on reasoning and is well-suited for chain-of-thought reasoning.
|
| 345 |
+
|
| 346 |
+
# 11.1.4 Multilingual Few-shot Reasoning and Question Answering Tasks
|
| 347 |
+
|
| 348 |
+
We conduct experiments on few-shot multilingual reasoning and question answering tasks. We use the MGSM (multilingual grade school math) benchmark proposed in [Shi et al., 2022]. For multilingual question answering, we use the well-established TydiQA [Clark et al., 2020a] benchmark. In our experiments, both PaLM 540B and U-PaLM 540B uses chain-of-thought prompting [Wei et al., 2022b]. Table 7 reports our results on MGSM and TydiQA. Our results show that U-PaLM outperform PaLM by a considerable margin $( + 3 . 2 \%$ on TydiQA and $+ 8 . 7 \%$ on MGSM).
|
| 349 |
+
|
| 350 |
+
Table 7: Experiments on Multilingual GSM (MGSM) [Shi et al., 2022] and TydiQA [Clark et al., 2020a]
|
| 351 |
+
|
| 352 |
+
<table><tr><td>Task /Model</td><td>PaLM540B</td><td>U-PaLM540B</td></tr><tr><td>TydiQA</td><td>52.9</td><td>54.6(+3.2%)</td></tr><tr><td>MGSM</td><td>45.9</td><td>49.9 (+8.7%)</td></tr></table>
|
| 353 |
+
|
| 354 |
+
Table 8: Results of PaLM vs U-PaLM at different FLOPs (# tokens) at 540B scale.
|
| 355 |
+
|
| 356 |
+
<table><tr><td rowspan="2">Model Task/#Tokens</td><td colspan="3">PaLM540B</td><td colspan="3">U-PaLM540B</td></tr><tr><td>182B</td><td>329B</td><td>780B</td><td>182B+</td><td>329B+</td><td>780B+</td></tr><tr><td>TriviaQA 1shot</td><td>73.4</td><td>74.4</td><td>81.4</td><td>73.3</td><td>75.6</td><td>82.0</td></tr><tr><td>NQA 1shot</td><td>23.2</td><td>25.6</td><td>29.3</td><td>24.4</td><td>28.1</td><td>30.7</td></tr><tr><td>WebQA 1shot</td><td>21.6</td><td>19.9</td><td>22.6</td><td>21.0</td><td>21.7</td><td>23.4</td></tr><tr><td>BoolQ</td><td>82.4</td><td>85.6</td><td>88.0</td><td>85.8</td><td>88.2</td><td>88.8</td></tr><tr><td>ReCORD</td><td>91.5</td><td>92.7</td><td>92.9</td><td>91.5</td><td>92.6</td><td>93.0</td></tr><tr><td>COPA</td><td>92.0</td><td>93.0</td><td>93.0</td><td>94.0</td><td>93.0</td><td>96.0</td></tr><tr><td>RTE</td><td>68.6</td><td>67.2</td><td>72.9</td><td>73.7</td><td>71.5</td><td>75.5</td></tr><tr><td>WIC</td><td>50.8</td><td>53.8</td><td>59.1</td><td>52.2</td><td>58.0</td><td>62.2</td></tr><tr><td>WSC</td><td>88.1</td><td>86.7</td><td>89.1</td><td>87.0</td><td>88.1</td><td>87.4</td></tr><tr><td>CB</td><td>57.1</td><td>48.2</td><td>51.8</td><td>69.6</td><td>71.4</td><td>69.6</td></tr><tr><td>MultiRC</td><td>76.7</td><td>81.1</td><td>83.5</td><td>78.4</td><td>81.7</td><td>83.8</td></tr><tr><td>Winogrande</td><td>89.4</td><td>88.3</td><td>90.1</td><td>87.9</td><td>89.7</td><td>88.3</td></tr><tr><td>Winograd</td><td>76.9</td><td>79.6</td><td>81.1</td><td>78.2</td><td>79.3</td><td>82.6</td></tr><tr><td>ANLIR1</td><td>44.3</td><td>49.4</td><td>48.4</td><td>50.3</td><td>50.6</td><td>55.3</td></tr><tr><td>ANLIR2</td><td>41.3</td><td>42.7</td><td>44.2</td><td>43.5</td><td>45.2</td><td>47.8</td></tr><tr><td>ANLIR3</td><td>43.8</td><td>42.8</td><td>45.7</td><td>46.7</td><td>49.3</td><td>57.0</td></tr><tr><td>PIQA</td><td>81.0</td><td>81.9</td><td>82.3</td><td>80.8</td><td>82.0</td><td>84.1</td></tr><tr><td>StoryCloze</td><td>82.7</td><td>83.9</td><td>84.6</td><td>83.7</td><td>84.2</td><td>87.0</td></tr><tr><td>HellaSwag</td><td>79.1</td><td>81.8</td><td>83.4</td><td>79.5</td><td>82.3</td><td>84.1</td></tr><tr><td>ArcE</td><td>74.8</td><td>72.8</td><td>76.6</td><td>74.6</td><td>76.3</td><td>85.9</td></tr><tr><td>ArcC</td><td>48.0</td><td>46.9</td><td>53.0</td><td>48.6</td><td>50.4</td><td>60.3</td></tr><tr><td>RaceM</td><td>63.6</td><td>67.3</td><td>68.1</td><td>63.2</td><td>67.1</td><td>67.2</td></tr><tr><td>OpenbookQA</td><td>50.2</td><td>51.2</td><td>53.4</td><td>50.2</td><td>51.2</td><td>53.6</td></tr><tr><td>RaceH</td><td>45.3</td><td>48.5</td><td>49.1</td><td>45.5</td><td>48.5</td><td>51.3</td></tr><tr><td>Lambada 1shot</td><td>75.4</td><td>77.5</td><td>81.8</td><td>74.3</td><td>79.9</td><td>80.0</td></tr><tr><td>SquadV2 1shot</td><td>70.5</td><td>71.3</td><td>78.7</td><td>71.8</td><td>70.3</td><td>78.2</td></tr><tr><td>Average</td><td>62.7</td><td>63.8</td><td>66.5</td><td>64.1</td><td>66.2</td><td>69.4</td></tr></table>
|
| 357 |
+
|
| 358 |
+
# 11.2 Details of Scaling Curves for Few-shot Experiments
|
| 359 |
+
|
| 360 |
+
We compute a mean aggregated score of the following tasks. We use 21 zero-shot rank classification tasks, i.e., BoolQ, Record, COPA, RTE, WiC, WSC, CB, MultiRC, Winograd, Winogrande, ANLI R1, ANLI R2, ANLI R3, PIQA, StoryCloze, HellaSwag, Arc-E, Arc-C, RaceM, RaceH, OpenbookQA. We use 5 one-shot generative tasks, i.e., TriviaQA, NaturalQuestions, WebQuestions,SQuaDV2 and Lambada. All tasks use the accuracy (or exact match) metric except MultiRC which reports f1a following [Brown et al., 2020]. In total, the aggregated metric is a mean over all 26 tasks. We list the scores that correspond to Figure 2’s 540B scaling plot below.
|
| 361 |
+
|
| 362 |
+
# 11.3 Details of Vocab and Sentinel Tokens
|
| 363 |
+
|
| 364 |
+
For U-PaLM, we had to train on span corruption or infilling task. We use the same setup as UL2 and T5 where we inject sentinel tokens, e.g., <extra_id_ $\smash { { O > } }$ into the masked positions. In T5, sentinel ids are added as 100 additional vocab tokens at the end of the sentencepiece (vocab). In PaLM, since we restart from an existing PaLM checkpoints, it was quite cumbersome to initialize 100 new embeddings in the vocab. Hence, we opt to simply use the last 100 subwords as sentinel tokens. Finally, we also use eos symbols in the vocab when training the model.
|
| 365 |
+
|
| 366 |
+
# 11.4 Details of Prompt Templates
|
| 367 |
+
|
| 368 |
+
As stated in Section 3.2, BBES uses the default prompting and templates a BIG-Bench and do not use chain-of-thought prompting. For full BBH and MMLU results, we use the same set of prompts as [Chung et al., 2022], which we refer the reader to for more details. However, our 5-shot MMLU prompts do not use chain-of-thought, only directly stating the answer option, e.g. "Answer: (C)". Prompts for our zero-shot and few-shot NLP evaluations in Section 10.1 use the same basic templates as [Brown et al., 2020].
|
| 369 |
+
|
| 370 |
+
# 11.5 Additional Discussion
|
| 371 |
+
|
| 372 |
+
In this section, we delve into some additional topics and discussions.
|
| 373 |
+
|
| 374 |
+
# 11.5.1 What about training from scratch?
|
| 375 |
+
|
| 376 |
+
We address the elephant in the room. There are multiple perspectives to this question. The first is that UL2R can be thought as a form of ‘UL2 schedule‘ that sets a single causal language model objective from 0 to $N$ steps and then doing the UL2 mixture from $N$ to $N + \epsilon$ . In this sense, if we wanted to train from scratch, this would require modifying the mixture to have significantly more causal language modeling. The second perspective is that UL2R introduces a natural curriculum where the model spents a large fraction of training acquiring basic language modeling before moving on to tasks like infilling or learning how to leverage bidirectional receptive fields. Whether there is a taxonomy or hierarchical of pretraining tasks is still an open question which we hope to answer in future work. The third perspective is simply the practical aspect of U-PaLM. Training a PaLM 540B model from scratch is incredibly costly and we would like to reuse our existing models (or components) as much as possible to design new models for new tasks. U-PaLM is an instance of this type of research. Finally, given that many language models are trained as causal language models, we believe that UL2R presents great opportunity for improving existing models with only a small amount of compute.
|
md/dev/tZmqS73_07/tZmqS73_07.md
ADDED
|
@@ -0,0 +1,574 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 3D MOLECULAR GENERATION BY VIRTUAL DYNAMICS
|
| 2 |
+
|
| 3 |
+
Anonymous authors Paper under double-blind review
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
Structure-based drug design, i.e., finding molecules with high affinities to the target protein pocket, is one of the most critical tasks in drug discovery. Traditional solutions, like virtual screening, require exhaustively searching on a large molecular database, which are inefficient and cannot get novel molecules beyond the database. The pocket-based 3D molecular generation model, i.e., directly generating a molecule with a 3D structure and binding position in the pocket, is a new promising way to address this issue. However, the method is very challenging due to the complexity brought by the huge continuous 3D space in the pocket cavity. Herein, inspired by Molecular Dynamics, we propose a novel pocket-based 3D molecular generation framework VD-Gen. VD-Gen consists of a Virtual Dynamics mechanism and several carefully designed stages to generate fine-grained 3D molecules with binding positions in the pocket cavity end-to-end. Rather than directly generating or sampling atoms with 3D positions in the pocket like in early attempts, in VD-Gen, we first randomly scatter many virtual particles in the pocket; then with the proposed Virtual Dynamics mechanism, a deep model, acting like a "force field", iteratively moves these virtual particles to positions that are highly possible to contain real atoms. After virtual particles are stabilized in 3D space, we extract the atoms from them. Finally, we further refine the 3D positions of atoms by Virtual Dynamics again, to get a fine-grained 3D molecule. Extensive experiment results on pocket-based molecular generation demonstrate that VD-Gen can generate novel 3D molecules to fill the target pocket cavity with high binding affinities, significantly outperforming previous baselines.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Structure-based (pocket-based) drug design, i.e., finding a molecule to fill the cavity of the protein pocket with a high binding affinity [1; 2; 3; 4], is one of the most critical tasks in drug discovery. The most widely used method is virtual screening [5; 6; 7]. Virtual screening iteratively places molecules from a molecular database into the target pocket cavity and evaluates molecules with good binding based on rules such as energy estimation [8; 9; 10; 11]. However, virtual screening is inefficient for the exhaustive search and is infeasible to generate new molecules that are not in the database. Recently, molecular generative models have become a potential solution to address the problem as they could generate novel molecules in an efficient way. The early attempts focused on ligand-based molecular generation[12; 13; 14], which trains models to learn the underlying distribution of the molecules in training data and generate similar molecules. However, those methods didn’t consider conditional information, such as the shape of the pocket. Therefore, the generated molecules could hardly fit well with a given pocket in practice. Later, more efforts were paid to studying how to leverage the information of protein pockets for molecular generation. Some pocket-based generative models simply generate molecules in the form of SMILES or graphs [15; 16], without considering the 3D geometric position of the molecule and pocket, which is closely related to binding affinity.
|
| 12 |
+
|
| 13 |
+
However, directly generating pocket-based molecules in the 3D space is not trivial. Given the 3D structure of a pocket, the ultimate goal of the task is to generate 3D molecules which contain a set of atoms, each with an atom type and the corresponding 3D position. The biggest challenge here is the large space of continuous 3D positions. In most existing generative models (in images/texts), the space of position is usually small and discrete, like an image with $2 2 4 \times 2 2 4$ pixels. To address that, there are some early attempts, which can be roughly categorized into two classes, molecular 3D density grid generation [17] and auto-regressive 3D generation [18; 19; 20]. In 3D density grid generation, similar to images, pockets and molecules are converted to 3D density grids with coarse-grained positions. 3D convolutional models could be used here. But it compresses the information of the pocket structure and is hard to generate accurate (fine-grained) molecules due to the coarse-grained grid positions. In auto-regressive 3D generation, an atom (with a 3D position and an atom type) is sampled (or generated) at each time step. But it is very inefficient due to the large sampling space of 3D positions. Besides, using sequential generation for 3D molecules is not reasonable since we do not know which atoms should be generated first.
|
| 14 |
+
|
| 15 |
+

|
| 16 |
+
Figure 1: The framework of VD-Gen, which consists of 4 stages, for generating fine-grained 3D molecules with binding positions in the pocket end-to-end. In Equilibrium and Refinement, the proposed Virtual Dynamics is used to iteratively move the virtual particles.
|
| 17 |
+
|
| 18 |
+
In short, existing models did not fully tackle the challenges in pocket-based 3D molecular generation. The ideal models should be able to generate fine-grained 3D molecules efficiently, in a one-shot (non-auto-regressive) fashion. To achieve that, we proposed a novel 3D molecular generation framework, VD-Gen, based on a Virtual Dynamics (VD) mechanism. Inspired by the Molecular Dynamics [21; 22], VD contains a deep model, which acts like a "force field", iteratively moving the random scattered "virtual particles" (VPs) to positions that are highly possible to contain real atoms. Based on VD , as illustrated in Fig. 1, VD-Gen framework contains 4 stages to directly generate 3D molecules in the pocket end-to-end. 1) Equilibrium. To cover the pocket cavity space as much as possible, many VPs are first randomly placed. Then the VPs are iteratively moved by VD until equilibrium. Ideally, the VPs will be moved into several clusters, each representing a possible atom. 2) Extraction. We want to extract atoms from equilibrious VPs in this stage. First, a success rate will be predicted for each VP, a higher success rate means that VP is more close to its target, and the VPs with low success rates will be filtered. Then, a model is used to predict the clustering of VPs, by a pair-wise fashion, and the VPs in the same cluster will be merged into one atom. With the merged atoms, we can get a molecule with a 3D structure. 3) Refinement. Although a 3D molecule could be generated in Extraction stage, it may be inaccurate due to the error in merging multiple VPs. To get a more accurate 3D molecule, the atoms are iteratively moved by VD again in this step. 4) Confidence. A confidence score for the generated 3D molecule will be provided by the model in this stage. The confidence score is instrumental when selecting or ranking from multiple generated results.
|
| 19 |
+
|
| 20 |
+
# Our contributions can be summarized as follows:
|
| 21 |
+
|
| 22 |
+
• We propose Virtual Dynamics (VD) mechanism, which implicitly simulates Molecular Dynamics by a deep model, iteratively moving the particles to positions that highly possibly contain atoms. We design several strategies, like least-action target assignment and iterative movement, to make the training of VD feasible. • Although VD can generate rough shapes (densities of particles) of 3D molecules, it is hard to extract molecules from the shapes. To address the problem, we further propose a novel pocket-based 3D molecular generation framework VD-Gen, which end-to-end extracts a 3D molecule from many particles, then refines it by VD again, and predicts a confidence score used for selecting or ranking. • Under VD-Gen, to tackle the limited data in pocket-based 3D molecular generation, we design a self-partial-generation pretraining task and successfully use it to further improve performance. • Multiple evaluation metrics, such as Vina [23], MM-PBSA [24], 3D Similarity [25], are used to benchmark VD-Gen thoroughly. Experiments results demonstrate that VD-Gen can generate diverse drug-like molecules with high binding affinities, significantly outperforming all baselines. Ablation studies and case studies are designed to further demonstrate the effectiveness of VD-Gen.
|
| 23 |
+
|
| 24 |
+
# 2 METHOD
|
| 25 |
+
|
| 26 |
+
The problem of pocket-based 3D molecular generation could be denoted as $\mathbf { M } = h ( \mathbf { P } ; \pmb { \theta } )$ , where $h ( \cdot ; \theta )$ is the model with learnable parameter $\pmb { \theta }$ , $\mathbf { P } = \{ ( \pmb { x } _ { i } ^ { p } , \pmb { y } _ { i } ^ { p } ) \} _ { i = 1 } ^ { u }$ is the set of $u$ atoms in the pocket, $\pmb { x } _ { i } ^ { p } \in \mathbb { R } ^ { t }$ and $\pmb { y } _ { i } ^ { p } \in \mathbb { R } ^ { 3 }$ are the $i$ -th pocket atom’s type (one-hot) and coordinate, respectively, $t$ is the number of atom types, and $\mathbf { M } = \{ ( \pmb { x } _ { i } , \pmb { y } _ { i } ) \} _ { i = 1 } ^ { m }$ is the set of $m$ atoms of the generated molecule.
|
| 27 |
+
|
| 28 |
+

|
| 29 |
+
Figure 2: The backbone model used in VD-Gen. Details are in Appendix A.1.1 and Alg. 2.
|
| 30 |
+
|
| 31 |
+
# 2.1 VIRTUAL DYNAMICS
|
| 32 |
+
|
| 33 |
+
As aforementioned, directly generating M is challenging due to the large space of 3D positions. Therefore, inspired by Molecular dynamics (MD), we propose Virtual Dynamics (VD), which iteratively refines the particles from a random state, rather than direct generation. MD is a Newtonian Mechanics based computational simulation to move atoms or other microscopic particles. In MD, what determines how atoms move is the molecular force field, a physical model that defines the interactions between atoms. The potential energy surface (PES) [26; 27], a function of energy based on atomic positions, is used to describe the energy landscape of the system. Each minimal energy on PES corresponds to a physical stable state, in which the atoms prefer to stay in particular positions.
|
| 34 |
+
|
| 35 |
+
Virtual Dynamics (VD) contains a deep model, acting like a "force field", implicitly predicting the preferred positions of ligand molecular atoms in the pocket cavity by moving the "virtual particles"(VPs) toward those positions. Formally, VD could be denoted as ${ \bf V } _ { r } = h ( { \bf V } _ { 0 } , { \bf P } , r ; \theta )$ , where $r$ is the number of rounds, $\mathbf { V } _ { r } = \{ ( \boldsymbol { { \mathbf { \mathit { x } } } } _ { i } ^ { r } , \boldsymbol { { \mathbf { \mathit { y } } } } _ { i } ^ { r } ) \} _ { i = 1 } ^ { n }$ is the set of $n$ VPs that are generated at the $r$ -th round. Here we define the VPs as particles without fixed atom types. Besides, VD can generate more VPs than the real atoms, i.e., $n = | \mathbf { V } _ { r } ^ { n } |$ can be larger than $m = | M |$ , and VPs can overlap with each other. To train a model to achieve effective movement of VPs, VD consists of 4 parts: 1) Backbone Model, a SE(3) model takes $\mathbf { V } _ { r }$ as input and outputs the refined $\mathbf { V } _ { r + 1 }$ ; 2) Target Assignment, a method to assign targets for VPs during training; 3) Iterative Movement, a strategy to update positions of VPs iteratively like MD; 4) Training Objectives, effective objective functions to train VD .
|
| 36 |
+
|
| 37 |
+
Backbone Model We can denote the model as $\mathbf { V } _ { r + 1 } = f ( \mathbf { V } _ { r } , \mathbf { P } ; \theta )$ . To predict the coordinates effectively, the model $f$ should be SE(3)-equivariance. We mainly follow the design of the efficient SE(3)-equivariance Transformer proposed in Uni-Mol [28] and Graphormer-3D [29]. However, they did not consider the interaction between pocket and molecule. Therefore, as illustrated in Fig. 2, we extend the model by adding an additional pocket encoder, and a particle-pocket attention layer to capture the interactions between pocket atoms and VPs. In particular, the key/value in the particle-pocket attention is from the node representation of the last layer in the pocket encoder. Besides, to encode the 3D spatial interactions between the pocket and VPs, the pair distance between pocket atoms and VPs is used for particle-pocket spatial position encoding. For efficiency purposes, particle-pocket attention is only used in every 4-layer, not in all layers.
|
| 38 |
+
|
| 39 |
+
To encode 3D positions, we follow Uni-Mol and use SE(3)-invariant Gaussian kernel to encode the pair-wise Euclidean distances, as shown in Fig. 2. To predict 3D positions directly, the SE(3)- equivariance coordinate head in Uni-Mol [28] is used. Besides, to predict the atom types of particles after movement, an atom type prediction head is introduced. Due to space restrictions, we leave the details of the above components in Appendix A.1.1.
|
| 40 |
+
|
| 41 |
+
Target Assignment The goal of model $f$ is to move the VPs to the preferred positions of ligand molecular atoms. To achieve this, we can directly assign a real atom as the training target for each VP. Formally, given the ground-truth atoms $\mathbf { G } = \{ ( \boldsymbol { { \mathbf { x } } } _ { i } ^ { g } , \boldsymbol { { \mathbf { y } } } _ { i } ^ { g } ) \} _ { i = 1 } ^ { m }$ and the random initialized VPs $\mathbf { V } _ { 0 }$
|
| 42 |
+
|
| 43 |
+
# Algorithm 1 Iterative Movement
|
| 44 |
+
|
| 45 |
+
Require: R: max rounds, P: pocket atoms, $\mathbf { V } _ { 0 }$ : random initialized virtual particles
|
| 46 |
+
1: $r \gets \mathrm { u n i f o r m } ( 1 , R )$ if training else $R$ ▷ Sampling is only enabled at training
|
| 47 |
+
2: disable_gradient() ▷ Disable gradient calculation globally
|
| 48 |
+
3: for $k \in [ 1 , . . . , r - 1 )$ do ▷ Iterative updates without gradients
|
| 49 |
+
4: $\mathbf { V } _ { k } f ( \mathbf { V } _ { k - 1 } , \mathbf { P } ; \boldsymbol { \theta } )$ ▷ backbone model $f$ predict the types and positions
|
| 50 |
+
5: enable_gradient() ▷ Enable gradient calculation globally
|
| 51 |
+
6: $\mathbf { V } _ { r } \gets f ( \mathbf { V } _ { r - 1 } , \mathbf { P } ; \theta )$ $\triangleright$ update with gradients
|
| 52 |
+
7: return $\mathbf { V } _ { r }$ ▷ Return the positions and types of particles
|
| 53 |
+
|
| 54 |
+
there are $n ^ { m }$ possible assignments. Following the principle of least action [30], the assignment with minimal moving distance is favored. That is to optimize $\begin{array} { r } { \mathbf { M i n } \sum _ { i = 1 } ^ { n } \| \pmb { y } _ { i } ^ { 0 } - \pmb { y } _ { a _ { i } } ^ { g } \| _ { 2 } } \end{array}$ , where $\mathbf { \boldsymbol { x } } _ { i } ^ { 0 }$ is the initial position and $a _ { i } \in \mathbb { N }$ is the assigned target for $i$ -th VP. This optimization problem is easy to solve: for each VP, assign its nearest real atom as the training target, i.e., $a _ { i } = \arg \operatorname* { m i n } _ { \mathbf { \mu } _ { - } , \mathbf { \bar { \mu } } _ { - } = 1 } ^ { m } \| \pmb { y } _ { i } ^ { 0 } - \pmb { y } _ { j } ^ { g } \| _ { 2 }$ However, by this method, some real atoms may not be assigned as targets when VPs are closer to other real atoms. To increase the coverage, there are two methods. The first is taking the coverage as a constraint in the above optimization problem; the second is using more VPs to cover the pocket cavity as possible. Although the former is more favorable from the algorithm perspective, it increases the learning difficulty of VP movement since the constrained assignment breaks the principle of least action 1. Therefore, in VD , we take the latter one, using more VPs to ensure coverage. Besides, we propose an algorithm to determine the pocket cavity, and VPs are only initialized inside the detected cavity. In particular, we use a breadth-first search algorithm, from a given position in the cavity, to detect the cavity space. Details are in Appendix A.1.2.
|
| 55 |
+
|
| 56 |
+
Iterative Movement Since VPs are scattered randomly in the pocket cavity, there is a wide range of distances between each VP and its target. As a result, it is not realistic that every VP can be moved to the right target position in one step. Therefore, VD takes a strategy that iteratively moves the VPs and predicts their types with multiple rounds. In particular, at each round, the model will take the VPs’ positions and types from the previous round as inputs, and output the new positions and types for them. In the first few rounds, the VPs that are close to the target positions will soonly approach their target positions. But for the VPs that are far away from the target positions, it may take more rounds to approach. In short, with iterative movement, more VPs could reach their target positions.
|
| 57 |
+
|
| 58 |
+
However, training the model with multiple rounds is not efficient in both speed and memory consumption. To reduce the training cost, we adopt the stochastic iteration in AlphaFold2 [31]. In particular, during training, the number of rounds $r$ is uniformly sampled between 1 and $R$ , where $R$ is the max round. Then, the model is run on the forward-only mode in the first $r - 1$ rounds, without loss calculation and gradient backward. Finally, the gradient and backward are enabled at the $r$ -th round. During inference, the sampling on rounds is not used. The above algorithm is shown in Alg. 1.
|
| 59 |
+
|
| 60 |
+
In addition, we propose two technologies to improve training stability. First, the SE(3) coordinate head is initialized to predict the zero delta positions; thus, the predicted movements of VPs are nearly zeros at the beginning of training, and gradually increase. Second, to avoid moving too fast in each round, a regularization of the delta distance between the input and output positions is used during training.
|
| 61 |
+
|
| 62 |
+
Training Objectives With assigned targets $( a _ { i } = \arg \operatorname* { m i n } _ { j = 1 } ^ { m } \| y _ { i } ^ { 0 } - y _ { j } ^ { g } \| _ { 2 } )$ , the training of VD is straightforward. First, a clip L2 loss is used for the coordinate prediction, clipping is for the training stability. Second, as aforementioned, a regularization of the moving distance of iterative movement is introduced to avoid moving too fast and improve training stability. Third, a negative log likelihood loss is used for the particle type prediction. Finally, two auxiliary L1 losses are used for the particle-particle pair distance prediction and particle-pocket pair distance prediction, respectively. The final training objective loss function could be denoted as:
|
| 63 |
+
|
| 64 |
+
$$
|
| 65 |
+
\begin{array} { l } { \displaystyle \mathcal { L } _ { \mathcal { V D } } = \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \big ( \mathrm { c l i p } ( | | \boldsymbol { y } _ { i } ^ { r } - \boldsymbol { y } _ { a _ { i } } ^ { g } | | _ { 2 } , \boldsymbol { \tau } ) + \operatorname* { m a x } ( | | \boldsymbol { y } _ { i } ^ { r } - \boldsymbol { y } _ { i } ^ { r - 1 } | | _ { 2 } - \delta , 0 ) + \mathrm { N L } ( \bar { \boldsymbol { x } } _ { i } ^ { r } , \boldsymbol { x } _ { a _ { i } } ^ { g } ) } \\ { \displaystyle \qquad + \frac { 1 } { n } \sum _ { j = 1 } ^ { n } | | d _ { i j } ^ { r } - d _ { a _ { i } , a _ { j } } ^ { g } | | _ { 1 } + \frac { 1 } { u } \sum _ { j = 1 } ^ { u } | | c _ { i j } ^ { r } - c _ { a _ { i } , j } ^ { g } | | _ { 1 } \bigg ) , } \end{array}
|
| 66 |
+
$$
|
| 67 |
+
|
| 68 |
+
where $r$ is the number of rounds, $\bar { \pmb x } _ { i } ^ { r }$ is the predicted atom type distribution of $i$ -th particle, $d _ { i j } ^ { r }$ $( d _ { a _ { i } , a _ { j } } ^ { g } )$ is the predicted (ground-truth) distance of the $i$ -th and $j$ -th particle pair, $c _ { i j } ^ { r } \ ( c _ { a _ { i } , j } ^ { g } )$ is the predicted (ground-truth) distance of the $i$ -th particle and the $j$ -th pocket atom.
|
| 69 |
+
|
| 70 |
+
# 2.2 VD-GEN FRAMEWORK
|
| 71 |
+
|
| 72 |
+
With VD , a rough shape (density of VPs) of the 3D molecule could be formed by the VPs after iterative movement. We may use some rule-based solutions, like clustering by distances, to extract 3D molecules from the VPs. However, rule-based solutions are not end-to-end and could fail in various scenarios. Therefore, to better leverage VD , we further develop an end-to-end pocket-based 3D molecular generation framework, called VD-Gen, with the following 4 stages, illustrated in Fig 1.
|
| 73 |
+
|
| 74 |
+
Equilibrium This stage is exactly the same as the VD . Many VPs are first uniformly scattered in the pocket. Then, VPs iteratively move toward their target positions. Finally, VPs will reach a stable state.
|
| 75 |
+
|
| 76 |
+
Extraction With the equilibrious VPs, a rough shape of the 3D molecule could be got, and we want to extract a 3D molecule from it. For the end-to-end purpose, we propose a deep model based solution to extract atoms. Formally, the model can be denoted as ${ \bf W } _ { 0 } = h _ { e x } ( { \bf V } _ { r } , { \bf P } ; \theta _ { e x } )$ , where $\theta _ { e x }$ is learnable parameters, $\mathbf { W } _ { 0 } = \{ ( \hat { \pmb { x } } _ { i } ^ { 0 } , \hat { \pmb { y } } _ { i } ^ { 0 } ) \} _ { i = 1 } ^ { m }$ is the set of $m$ VPs after extraction. The model reduces VPs from $n$ to $m$ by two steps, filter and merge. First, as some VPs may fail to approach their target positions, we want to filter out them. A binary classification head is used to predict the success rates of VPs, and the training targets are "success" if the distances between VPs and their target positions after Equilibrium are smaller than a threshold. And we filter out the VPs based on the predicted success rate.
|
| 77 |
+
|
| 78 |
+
Second, we want to merge the remaining VPs into atoms. Based on the pair representation of VPs, we use another binary classification head to predict whether a VP pair should be merged or not. Ideally, the VPs with the same target atom should be merged, thus training label for a VP pair with the same atom target is set to "true". When there are $n$ VPs and $m$ real atoms, the ratio of "true" class is about m×(n/m)2 $\begin{array} { r } { { \frac { m \times ( n / m ) ^ { 2 } } { n ^ { 2 } } } = { \frac { 1 } { m } } } \end{array}$ . As $m$ ranges from dozens to hundreds, the binary classification task here is very unbalanced. Thus, we introduce a focal loss [32] to balance the classes. With the predicted pair-wise merge probability matrix, we can use a threshold to get a binary merge matrix and merge VPs into clusters according to the matrix. However, it is hard to decide a threshold since the training of pair-wise merge is unbalanced. To tackle that, we further introduce a prediction task for the number of ligand molecular atoms, based on pocket atom representation. During inference, we use binary search to find a merging threshold that satisfies the predicted atom number, details are in Appendix A. There will be several (ideally $m$ ) merge clusters, and we denote ${ \pmb w } _ { i }$ as the set of the indices of $i$ -th cluster’s VPs. Then, to initialize $\mathbf { W } _ { 0 }$ , we use $\hat { \pmb { x } } _ { i } ^ { 0 } = \mathrm { U n i f o r m } ( \{ \pmb { x } _ { j } ^ { r } | j \in \pmb { w } _ { i } \} )$ ) and $\hat { \pmb { y } } _ { i } ^ { 0 } = \mathrm { M e a n } ( \{ \pmb { y } _ { j } ^ { r } | j \in \pmb { w } _ { i } \} )$ , to sample an atom type and get an average coordinate respectively.
|
| 79 |
+
|
| 80 |
+
Refinement After Extraction, a 3D molecule with a set of VPs $( \mathbf { W } _ { 0 } )$ ) could be formed. However, due to the possible error in Extraction, the predicted 3D molecule may not be very accurate. To get a more accurate 3D molecule $( \mathbf { W } _ { r } )$ , we use VD again, with different model weights, to iteratively move these VPs to their target positions. Different with Equilibrium, the training target assignment of the $i$ -th VP is the most frequent target atom in the cluster ${ \pmb w } _ { i }$ , not its nearest atom.
|
| 81 |
+
|
| 82 |
+
Confidence Abundant molecules are usually generated in real-world tasks. We want to select or rank the molecules according to binding affinities. Although we can use computational simulations or wet experiments to examine the generated molecules, they are too costly, especially for a large number of molecules. To further improve the usability of ${ \tt V D - G e n }$ and reduce the extra cost of selecting good molecules, we explicitly train a task to learn the confidence scores for the generated molecules. In particular, following AlphaFold [31], we compute the LDDT score [33] of the generated molecule and ground-truth molecule, and a pLDDT(predict LDDT) head is used to learn the LDDT score. During inference, the output of pLDDT head is used as the confidence score of the generated molecule.
|
| 83 |
+
|
| 84 |
+
The loss functions in the above 4 stages are combined, and the entire VD-Gen framework is trained end-to-end. Due to space restrictions, we leave the details of the above loss functions in Appendix A.
|
| 85 |
+
|
| 86 |
+
# 2.3 PRE-TRAINING FOR VD-GEN
|
| 87 |
+
|
| 88 |
+
Due to the limited protein-ligand binding data for the supervised training, VD-Gen may fail to train or overfit the small training data. Therefore, to improve the model ability, we pretrain the pocket encoder and the VP encoder by large-scale unlabeled data, respectively. The pretrained pocket encoder is directly taken from the pretrained one from Uni-Mol [28]. For the VP encoder, the pretraining is mostly the same as the VD-Gen framework, except that pocket is not involved. In particular, the pocket related components, like particle-pocket attention, are all removed. Nevertheless, without pocket as a condition, the training of VD-Gen is infeasible. So we design a self-partial-generation pretraining task, by using a part of the molecule as the known condition and generating the unknown part. To be more consistent with finetuning, only a few atoms, about $20 \%$ to $30 \%$ , are kept as a condition. To have a continuous 3D space for VPs to generate, we randomly remove the atoms in the continuous region. We use a greedy recursive algorithm to find a cluster of atoms to remove, and then, the VPs are randomly scattered in the continuous region of these removed atoms.
|
| 89 |
+
|
| 90 |
+
During finetuning, the backbone model in VD-Gen loads the weights from two pretrained models. For the VP encoder, the weights in the particle-pocket attention layers are not pretrained and are randomly initialized. Gated layers, initialized as zeros, are used in the residual connections of particle-pocket attention layers. Therefore, the outputs of random initialized particle-pocket attention layers will not affect the pretrained encoders at the beginning of finetuning.
|
| 91 |
+
|
| 92 |
+
# 2.4 EXTENDING VD-GEN TO POCKET-BASED 3D MOLECULAR OPTIMIZATION
|
| 93 |
+
|
| 94 |
+
Molecular optimization is also an important task in real-world drug design. In molecular optimization, rather than generating from scratch, the goal is to replace a part of the given molecule, like a fragment, and to get a molecule with better binding affinity. Here, we extend VD-Gen to the pocket-based 3D molecular optimization. In particular, as illustrated in Fig. 8, we first randomly remove a fragment of the given molecule, and the model is learned to generate it, with the pocket and the remaining atoms in the molecule as conditions. In this way, although it is not trained to optimize molecules directly, the model learns how to remove-then-fill a fragment of a molecule, and thus could be used in molecular optimization tasks. The benchmark results of molecular optimization are left to Appendix B.8.
|
| 95 |
+
|
| 96 |
+
# 3 EXPERIMENTS
|
| 97 |
+
|
| 98 |
+
# 3.1 SETTINGS
|
| 99 |
+
|
| 100 |
+
Evaluation metrics There is not a golden metric to evaluate the generated molecules, so we use multiple metrics to have a comprehensive evaluation. 1) 3D Similarity. As the pocket-based 3D generation models are trained by the 3D structures of the pockets and molecules, the most direct metric to examine the models’ generative ability is to evaluate the 3D similarity between the generated molecule and the ground-truth one. Here we use LIGSIFT [25] to calculate the overlapping ratio in 3D space between two molecules. 2) Vina. Docking scores, like Vina [23], are widely used in previous pocket-based generation works, for they are easy to compute. To be consistent with previous works, we also use Vina as a metric. However, previous works usually relied on Vina’s re-docking, in which the molecular conformation and binding pose may be largely changed by docking tools. Thus, to directly evaluate the 3D molecules generated by model, we add an additional Vina\* score that does not use re-docking. 3) MM-PBSA. Although docking scores are easy and fast to compute, they are proposed to recall the possible hits in the large-scale virtual screening, not for ranking. Thus, docking scores are not good metrics to compare the binding affinities for different models [34], and we further use the slower but more accurate MM-PBSA (Molecular Mechanics Poisson–Boltzmann Surface Area) [35] as a metric. Based on MM-PBSA, we add two additional metrics. MM-PBSA B.T. (MM-PBSA Better than Target), which computes the percentage of generated molecules with better MM-PBSA scores than ground-truth. MM-PBSA Rank, which computes the average rankings of different models among different complexes. Due to MM-PBSA scores varying largely in different complexes, MM-PBSA Rank can better compare different models. The details of the above metrics are described in Appendix B.2.
|
| 101 |
+
|
| 102 |
+
Data We use 3D molecular conformations from Uni-Mol [28] to pretrain VP encoder. PDBBind 2020 dataset [36; 37], containing 19,443 protein-ligand complexes crystal structures, are used to finetune the VD-Gen. Although the cross-docked data [38] used in the previous works is much larger, it is built by docking tools and thus is not accurate as PDBBind, so we do not use it. For the test set, we use 100 protein-ligand complex crystal structures from [24], on which MM-PBSA was validated to be effective. To avoid leakage, we remove the training data’s complexes whose protein sequences are similar to the ones in the test set. In particular, two protein sequences are identified as similar if their e-value from BLAST [39] search results is larger than 0.4. There are 18,413 training complexes after filtering.
|
| 103 |
+
|
| 104 |
+
Training We leave the detailed hyper-parameters used in training to Appendix B.1.
|
| 105 |
+
|
| 106 |
+
# 3.2 MOLECULE GENERATION PERFORMANCE
|
| 107 |
+
|
| 108 |
+
Baselines We compare VD-Gen with several previous 3D pocket-base molecular generation models: the 3D density generation model LiGAN [17], and the auto-regressive 3D generation models
|
| 109 |
+
|
| 110 |
+
Table 1: Performance on pocket-based 3D molecular generation.
|
| 111 |
+
|
| 112 |
+
<table><tr><td>Model</td><td>3D Sim(↑)</td><td>Vina(↓)</td><td>Vina*(↓)</td><td>MM-PBSA(↓)</td><td>MM-PBSA- Rank(↓)</td><td>MM-PBSA- B.T.(%↑)</td></tr><tr><td>LiGAN[17]</td><td>0.356</td><td>-6.724</td><td>-5.372</td><td>-17.865</td><td>2.57</td><td>0.3</td></tr><tr><td>3DSBDD[18]</td><td>0.365</td><td>-8.662</td><td>-7.227</td><td>-30.221</td><td>2.26</td><td>3.2</td></tr><tr><td>GraphBP[19]</td><td>0.333</td><td>-8.710</td><td>-3.689</td><td>-5.130</td><td>3.98</td><td>0</td></tr><tr><td>Pocket2Mol[20]</td><td>0.352</td><td>-8.332</td><td>-6.525</td><td>-7.823</td><td>3.49</td><td>0</td></tr><tr><td>VD-Gen</td><td>0.414</td><td>-9.047</td><td>-7.444</td><td>-51.258</td><td>1.18</td><td>13.5</td></tr></table>
|
| 113 |
+
|
| 114 |
+
Table 2: Ablation study on pretraining.
|
| 115 |
+
|
| 116 |
+
<table><tr><td>Setting</td><td></td><td>|no pretrain|pretrain pocket encoder only|pretrain VP encoder only |pretrain</td><td></td><td></td></tr><tr><td>3D Similarity (↑) |</td><td>0.361</td><td>0.379</td><td>0.402</td><td>0.414</td></tr></table>
|
| 117 |
+
|
| 118 |
+
GraphBP [19], 3DSBDD [18], and Pocket2Mol [20]. For all models, we generate 500 results for each pocket, and then select 100 from them. For 3DSBDD and Pocket2Mol, beam search is used and the top 100 results are selected. For VD-Gen, the selection is based on the confidence score. For LiGAN and GraphBP, random 100 results are selected due to they did not implement beam search.
|
| 119 |
+
|
| 120 |
+
Results As we pay more attention to the generated molecules with high binding affinities, we report the top 5-th percentile result for Vina, Vina\*, and MM-PBSA. MM-PBSA-Rank is calculated based on the top 5-th percentile MM-PBSA result. The 10-th, 25-th, and 50-th percentile results are in Appendix B.3.
|
| 121 |
+
|
| 122 |
+
From the results in Table 1, it is easy to conclude: 1) VD-Gen significantly outperforms all other baselines in all metrics, with top-1 MM-PBSA Rank, demonstrating the superior performance of the proposed VD-Gen. 2) MM-PBSA B.T shows that VD-Gen can generate more molecules with better MM-PBSA scores than the ground-truth ones, while baseline hardly can. 3) In 3D Similarity results, VD-Gen also largely outperforms baselines, indicating that VD-Gen effectively learned the pocket-based 3D molecular generation and can generalize to unseen pockets. 4) Although some baselines achieve good performance on Vina scores, like GraphBP and Pocket2Mol, their Vina\* and MM-PBSA scores are very poor. We believe the re-docking in Vina fixes their generated 3D structures and then a good Vina score could be obtained. This result indicates that the previously widely used Vina score is not a good metric for pocket-based 3D molecular generation.
|
| 123 |
+
|
| 124 |
+
# 3.3 ABLATION STUDY
|
| 125 |
+
|
| 126 |
+
Pocket coverage As discussed in Sec. 2.1, Virtual Dynamics requires many VPs to cover the pocket cavity as much as possible. And we study how the number of VPs affects the final performance, the results are shown in Fig. 3(a). From the result, it is clear that the number of VPs will affect the performance, and the results with more VPs are better.
|
| 127 |
+
|
| 128 |
+
Effectiveness of Refinement stage The Refinement stage is used to further refine the 3D molecule after Extraction. To examine how Refinement affects the final performance, we benchmarked different movement iterations in Refinement. As shown in Fig. 3(c), we can find the results with more iterations are better. The result indicates the necessity of the Refinement stage.
|
| 129 |
+
|
| 130 |
+
Iterative Movement ronuds Iterative Movement is critical in the Virtual Dynamics. From the result in Fig. 3(c), we can find the results with more rounds are better. We also benchmark the effectiveness of Iterative Movement in Equilibrium stage. And we reduce the movement iterations to $2 5 \%$ in Refinement stage, to better show the impact brought by Equilibrium stage. As shown in Fig. 3(b), we can find more iteration rounds in Equilibrium also improves the final performance.
|
| 131 |
+
|
| 132 |
+
Effectiveness of Confidence stage The pLDDT score is outputted at Confidence stage, and used for selecting or ranking molecules, and we want to check its effectiveness. In particular, we calculate the correlation between 3D similarity and the pLDDT for the generated molecules on a pocket (PDBID 1I7Z), and the result is shown in Fig. 3(d). It is clear that with a larger pLDDT score, the corresponding 3D Similarity is better. This result indicates that the confidence score provided by VD-Gen is effective to select or rank the generated molecules.
|
| 133 |
+
|
| 134 |
+
Effectiveness of pretraining We also benchmark the performance brought by pretraining. In particular, we add three additional models, one without any pretraining, one only with pocket pretraining, and one only with particle pretraining. From the results shown in Table 2, we can easily conclude that pretraining indeed boosts the performance of VD-Gen.
|
| 135 |
+
|
| 136 |
+

|
| 137 |
+
|
| 138 |
+

|
| 139 |
+
Figure 3: Ablation studies for VD-Gen.
|
| 140 |
+
|
| 141 |
+

|
| 142 |
+
Figure 4: Generated molecules with high 3D similarity to the reference molecular and high PBSA scores for three protein pockets. Gray surfaces are the protein pockets. Green molecules are the ground truth molecules. Purple molecules are the molecules generated by ${ \tt V D - G e n }$ . Lower Vina score, lower PBSA score and higher 3D similarity indicate higher binding affinity.
|
| 143 |
+
|
| 144 |
+
# 3.4 CASE STUDY
|
| 145 |
+
|
| 146 |
+
Here, we selected three protein pockets from the test set to visualize the generated results of VD-Gen on pocket-based generation tasks. As shown in Fig 4, for each pocket, 3 molecules (purple molecules in the middle column) with the top MM-PBSA scores are selected for display. These molecules are shown as they as, without any structural post-processing. Green molecules are the ground truth molecules, and the rightmost column is the spatial overlapping of the generated molecules and the original molecule.
|
| 147 |
+
|
| 148 |
+
In the first case (PDBID: 2XBW), the protein pocket has a pit deep inside the protein (bottom left of the image), the volume of which can accommodate about one benzene ring. It is a challenging task due to the small size of the pit and the long distance from the center of the whole pocket. We can see that the molecules generated by VD-Gen have successfully grown fragments within the pit. On the other hand, the three generated molecules have good 3D similarity with the original molecules, and the MM-PBSA score is good, the Vina scores of the original molecule are much better than those of the three generated molecules. If we only use Vina to pick molecules, It may lead to not picking good molecules.
|
| 149 |
+
|
| 150 |
+
In the second case (PDBID: 1BHX), the protein pocket is bulky, which requires the generation of protein-interacting fragments at both ends of the protein pocket, and connecting the two ends together by a molecular backbone, we can see the original molecule is long and distorted, making it a challenging prediction task. We see that the molecules generated by VD-Gen replicate the shape of the original molecules well, filling the uneven protein pockets well. All three molecules have good 3D similarity and MM-PBSA scores.
|
| 151 |
+
|
| 152 |
+
In the third case (PDBID: 2BRM), the protein pocket is flat, which requires that the molecular backbone of the ligand bound to it should be close to a planar structure, such as composed of conjugated aromatic rings. We can see that the molecules generated by VD-Gen are the same as the original molecular structures, whose molecular backbone is a planar structure composed of conjugated aromatic rings, and the part toward the outside of the pocket is flexible. We can see that in this case, Vina scoring, MM-PBSA scoring, and 3D similarity all show good agreements.
|
| 153 |
+
|
| 154 |
+
From these three cases in Fig 4, we can see that VD-Gen has demonstrated good generation capabilities on different types of challenging molecular generation tasks. For example, the generated molecules can fill deep pockets, follow the trend of large pockets, or match the special structure of the pockets, and the 3D similarity between the generated molecule and the molecule in the original crystal structure is high. On the other hand, we can see that the MM-PBSA score and 3D similarity maintain good consistency in evaluating the quality of generated molecules, while the Vina score fails in some cases, which indicates that it is unreasonable to select molecules based on the Vina score alone.
|
| 155 |
+
|
| 156 |
+
# 4 RELATED WORK
|
| 157 |
+
|
| 158 |
+
Ligand-Based Molecular Generation Early works focused on ligand-based molecular generation, took a set of molecules as training data, and generated molecules based on the learned distribution of training data. And these methods mainly represented molecules as 1D SMILES strings and 2D molecular graphs, and used VAEs [12; 13; 14; 40; 41; 42], GANs [43; 44], flow models [45] for oneshot generation, RNNs [46; 47; 48; 49], reinforcement learning approaches[50; 51] for step-by-step generation. And some works [52; 53; 54] tried to preserve structural features like molecular scaffolds, or physicochemical properties like QED, to gain better generated molecules compared to randomly generation. However, those methods did not take the binding affinity against a specific protein pocket as a target directly thus the generated molecules hardly worked well in real-world tasks. Some recent works [55; 56; 57; 58] also tried the ligand-based 3D molecular generation.
|
| 159 |
+
|
| 160 |
+
Pocket-Based Molecular Generation Due to the importance of binding affinity in drug design, recent works involved the information of protein pockets for molecular generation. Early attempts [15; 16] encoded pocket information and took it as a condition to generate molecules in SMILES strings or molecular graphs. However, since the binding affinity depends on the spatial positions of pocket and molecule, the latter works paid more effort in generating molecules with 3D spatial structures. Some works [17], recognized as molecular 3D density grid generation, converted pockets and molecules into 3D density grids, and applied 3D convolutional models like processing images. But as the pocket cavity is large, the positions of pockets and molecules are coarse-grained in 3D density grids and it leads to information loss and hard to generate fine-grained molecules. Besides, it is not end-to-end since the conversion from 3D density to 3D coordinates is required and usually causes additional accuracy loss. Some other works [18; 19; 20], recognized as auto-regressive 3D molecular generation, sampled/generated atoms in 3D space one by one to form a molecule. Suffering from the large space of continuous 3D positions, it is quite inefficient. Besides, unlike the sequential nature in text, the atoms in a molecule do not have a sequential order. That is, we do not know which atoms should be generated first, and thus, using auto-regressive generation for 3D molecules is not reasonable.
|
| 161 |
+
|
| 162 |
+
# 5 CONCLUSION
|
| 163 |
+
|
| 164 |
+
In this paper, we propose VD-Gen, a novel pocket-based 3D molecular generation framework, which consists of a Virtual Dynamics mechanism and several stages, to generate fine-grained 3D molecules with good binding affinities against the pocket end-to-end. In particular, with Virtual Dynamics, many virtual particles are first randomly scattered in the pocket cavity, and are iteratively moved to positions that are highly possible to contain real atoms. Then, a coarse-grained 3D molecule could be extracted by deep models from these particles. Next, the 3D molecule is continued refined by Virtual Dynamics again, and a fine-grained 3D molecule could be obtained. Finally, a confidence score will be calculated for the generated molecule for the need of selecting or ranking. Several strategies are proposed to make the training of VD-Gen feasible. Experiment results demonstrate that VD-Gen can generate molecules with higher binding affinities to protein pockets and more accurate 3D binding structures than other baselines. Several case studies also demonstrate the effectiveness of VD-Gen.
|
| 165 |
+
|
| 166 |
+
REFERENCES
|
| 167 |
+
[1] Hugo Kubinyi. 3D QSAR in drug design: volume 1: theory methods and applications, volume 1. Springer Science & Business Media, 1993.
|
| 168 |
+
[2] Renee L DesJarlais, Robert P Sheridan, George L Seibel, J Scott Dixon, Irwin D Kuntz, and R Venkataraghavan. Using shape complementarity as an initial screen in designing ligands for a receptor binding site of known three-dimensional structure. Journal of medicinal chemistry, 31(4):722–729, 1988.
|
| 169 |
+
[3] Robert S DeWitte, Alexey V Ishchenko, and Eugene I Shakhnovich. Smog: de novo design method based on simple, fast, and accurate free energy estimates. 2. case studies in molecular design. Journal of the American Chemical Society, 119(20):4608–4617, 1997.
|
| 170 |
+
[4] Robert S DeWitte and Eugene I Shakhnovich. Smog: de novo design method based on simple, fast, and accurate free energy estimates. 1. methodology and supporting evidence. Journal of the American Chemical Society, 118(47):11733–11744, 1996.
|
| 171 |
+
[5] W Patrick Walters, Matthew T Stahl, and Mark A Murcko. Virtual screening—an overview. Drug discovery today, 3(4):160–178, 1998.
|
| 172 |
+
[6] Brian K Shoichet. Screening in a spirit haunted world. Drug discovery today, 11(13-14):607– 615, 2006.
|
| 173 |
+
[7] Brian K Shoichet. Virtual screening of chemical libraries. Nature, 432(7019):862–865, 2004.
|
| 174 |
+
[8] Anita de Ruiter and Chris Oostenbrink. Free energy calculations of protein–ligand interactions. Current opinion in chemical biology, 15(4):547–552, 2011.
|
| 175 |
+
[9] Christophe Chipot and Andrew Pohorille. Free energy calculations, volume 86. Springer, 2007.
|
| 176 |
+
[10] Clara D Christ, Alan E Mark, and Wilfred F Van Gunsteren. Basic ingredients of free energy calculations: a review. Journal of computational chemistry, 31(8):1569–1582, 2010.
|
| 177 |
+
[11] Julien Michel and Jonathan W Essex. Prediction of protein–ligand binding affinity by free energy simulations: assumptions, pitfalls and expectations. Journal of computer-aided molecular design, 24(8):639–658, 2010.
|
| 178 |
+
[12] Matt J Kusner, Brooks Paige, and José Miguel Hernández-Lobato. Grammar variational autoencoder. In International conference on machine learning, pages 1945–1954. PMLR, 2017.
|
| 179 |
+
[13] Hanjun Dai, Yingtao Tian, Bo Dai, Steven Skiena, and Le Song. Syntax-directed variational autoencoder for structured data. arXiv preprint arXiv:1802.08786, 2018.
|
| 180 |
+
[14] Robin Winter, Floriane Montanari, Andreas Steffen, Hans Briem, Frank Noé, and Djork-Arné Clevert. Efficient multi-objective molecular optimization in a continuous latent space. Chemical science, 10(34):8016–8024, 2019.
|
| 181 |
+
[15] Miha Skalic, Davide Sabbadin, Boris Sattarov, Simone Sciabola, and Gianni De Fabritiis. From target to drug: generative modeling for the multimodal structure-based ligand design. Molecular pharmaceutics, 16(10):4282–4291, 2019.
|
| 182 |
+
[16] Mingyuan Xu, Ting Ran, and Hongming Chen. De novo molecule design through the molecular generative model conditioned by 3d information of protein binding sites. Journal of Chemical Information and Modeling, 61(7):3240–3254, 2021.
|
| 183 |
+
[17] Matthew Ragoza, Tomohide Masuda, and David Ryan Koes. Generating 3d molecules conditional on receptor binding sites with deep generative models. Chemical science, 13(9):2701– 2713, 2022.
|
| 184 |
+
[18] Shitong Luo, Jiaqi Guan, Jianzhu Ma, and Jian Peng. A 3d molecule generative model for structure-based drug design. arXiv preprint arXiv:2203.10446, 2022.
|
| 185 |
+
[19] Meng Liu, Youzhi Luo, Kanji Uchino, Koji Maruhashi, and Shuiwang Ji. Generating 3d molecules for target protein binding. arXiv preprint arXiv:2204.09410, 2022.
|
| 186 |
+
|
| 187 |
+
[20] Xingang Peng, Shitong Luo, Jiaqi Guan, Qi Xie, Jian Peng, and Jianzhu Ma. Pocket2mol: Efficient molecular sampling based on 3d protein pockets. arXiv preprint arXiv:2205.07249, 2022.
|
| 188 |
+
|
| 189 |
+
[21] Berni J Alder and Thomas Everett Wainwright. Studies in molecular dynamics. i. general method. The Journal of Chemical Physics, 31(2):459–466, 1959.
|
| 190 |
+
|
| 191 |
+
[22] Berni Julian Alder and Thomas Everett Wainwright. Studies in molecular dynamics. ii. behavior of a small number of elastic spheres. The Journal of Chemical Physics, 33(5):1439–1451, 1960.
|
| 192 |
+
|
| 193 |
+
[23] Oleg Trott and Arthur J Olson. Autodock vina: improving the speed and accuracy of docking with a new scoring function, efficient optimization, and multithreading. Journal of computational chemistry, 31(2):455–461, 2010.
|
| 194 |
+
|
| 195 |
+
[24] Maohua Yang, Dongdong Wang, and Hang Zheng. Uni-gbsa: An automatic workflow to perform $\mathrm { { m m / g b ( p b ) s a } }$ calculations for virtual screening. ChemRxiv, 2022.
|
| 196 |
+
|
| 197 |
+
[25] Ambrish Roy and Jeffrey Skolnick. Ligsift: an open-source tool for ligand structural alignment and virtual screening. Bioinformatics, 31(4):539–544, 2015.
|
| 198 |
+
|
| 199 |
+
[26] Alan D McNaught, Andrew Wilkinson, et al. Compendium of chemical terminology, volume 1669. Blackwell Science Oxford, 1997.
|
| 200 |
+
|
| 201 |
+
[27] Shin Sato. On a new method of drawing the potential energy surface. The Journal of chemical physics, 23(3):592–593, 1955.
|
| 202 |
+
|
| 203 |
+
[28] Gengmo Zhou, Zhifeng Gao, Qiankun Ding, Hang Zheng, Hongteng Xu, Zhewei Wei, Linfeng Zhang, and Guolin Ke. Uni-mol: A universal 3d molecular representation learning framework. 2022.
|
| 204 |
+
|
| 205 |
+
[29] Yu Shi, Shuxin Zheng, Guolin Ke, Yifei Shen, Jiacheng You, Jiyan He, Shengjie Luo, Chang Liu, Di He, and Tie-Yan Liu. Benchmarking graphormer on large-scale molecular modeling datasets. arXiv preprint arXiv:2203.04810, 2022.
|
| 206 |
+
|
| 207 |
+
[30] Richard Feynman. The Character of Physical Law, with new foreword. MIT press, 2017.
|
| 208 |
+
|
| 209 |
+
[31] John Jumper, Richard Evans, Alexander Pritzel, Tim Green, Michael Figurnov, Olaf Ronneberger, Kathryn Tunyasuvunakool, Russ Bates, Augustin Žídek, Anna Potapenko, et al. Highly accurate protein structure prediction with alphafold. Nature, 596(7873):583–589, 2021.
|
| 210 |
+
|
| 211 |
+
[32] Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollár. Focal loss for dense object detection. In Proceedings of the IEEE international conference on computer vision, pages 2980–2988, 2017.
|
| 212 |
+
|
| 213 |
+
[33] Valerio Mariani, Marco Biasini, Alessandro Barbato, and Torsten Schwede. lddt: a local superposition-free score for comparing protein structures and models using distance difference tests. Bioinformatics, 29(21):2722–2728, 2013.
|
| 214 |
+
|
| 215 |
+
[34] Tiejun Cheng, Xun Li, Yan Li, Zhihai Liu, and Renxiao Wang. Comparative assessment of scoring functions on a diverse test set. Journal of chemical information and modeling, 49(4):1079–1093, 2009.
|
| 216 |
+
|
| 217 |
+
[35] Samuel Genheden and Ulf Ryde. The mm/pbsa and mm/gbsa methods to estimate ligand-binding affinities. Expert opinion on drug discovery, 10(5):449–461, 2015.
|
| 218 |
+
|
| 219 |
+
[36] Renxiao Wang, Xueliang Fang, Yipin Lu, and Shaomeng Wang. The pdbbind database: Collection of binding affinities for protein- ligand complexes with known three-dimensional structures. Journal of medicinal chemistry, 47(12):2977–2980, 2004.
|
| 220 |
+
|
| 221 |
+
[37] Renxiao Wang, Xueliang Fang, Yipin Lu, Chao-Yie Yang, and Shaomeng Wang. The pdbbind database: methodologies and updates. Journal of medicinal chemistry, 48(12):4111–4119, 2005.
|
| 222 |
+
|
| 223 |
+
[38] Paul G Francoeur, Tomohide Masuda, Jocelyn Sunseri, Andrew Jia, Richard B Iovanisci, Ian Snyder, and David R Koes. Three-dimensional convolutional neural networks and a crossdocked data set for structure-based drug design. Journal of Chemical Information and Modeling, 60(9):4200–4215, 2020.
|
| 224 |
+
|
| 225 |
+
[39] Christiam Camacho, George Coulouris, Vahram Avagyan, Ning Ma, Jason Papadopoulos, Kevin Bealer, and Thomas L Madden. Blast+: architecture and applications. BMC bioinformatics, 10(1):1–9, 2009.
|
| 226 |
+
|
| 227 |
+
[40] Ryan-Rhys Griffiths and José Miguel Hernández-Lobato. Constrained bayesian optimization for automatic chemical design using variational autoencoders. Chemical science, 11(2):577–586, 2020.
|
| 228 |
+
|
| 229 |
+
[41] Orion Dollar, Nisarg Joshi, David AC Beck, and Jim Pfaendtner. Attention-based generative models for de novo molecular design. Chemical Science, 12(24):8362–8372, 2021.
|
| 230 |
+
|
| 231 |
+
[42] André F Oliveira, Juarez LF Da Silva, and Marcos G Quiles. Molecular property prediction and molecular design using a supervised grammar variational autoencoder. Journal of Chemical Information and Modeling, 62(4):817–828, 2022.
|
| 232 |
+
|
| 233 |
+
[43] Gabriel Lima Guimaraes, Benjamin Sanchez-Lengeling, Carlos Outeiral, Pedro Luis Cunha Farias, and Alán Aspuru-Guzik. Objective-reinforced generative adversarial networks (organ) for sequence generation models. arXiv preprint arXiv:1705.10843, 2017.
|
| 234 |
+
|
| 235 |
+
[44] Benjamin Sanchez-Lengeling, Carlos Outeiral, Gabriel L Guimaraes, and Alan Aspuru-Guzik. Optimizing distributions over molecular space. an objective-reinforced generative adversarial network for inverse-design chemistry (organic). 2017.
|
| 236 |
+
|
| 237 |
+
[45] Chence Shi, Minkai Xu, Zhaocheng Zhu, Weinan Zhang, Ming Zhang, and Jian Tang. Graphaf: a flow-based autoregressive model for molecular graph generation. arXiv preprint arXiv:2001.09382, 2020.
|
| 238 |
+
|
| 239 |
+
[46] Marcus Olivecrona, Thomas Blaschke, Ola Engkvist, and Hongming Chen. Molecular de-novo design through deep reinforcement learning. Journal of cheminformatics, 9(1):1–14, 2017.
|
| 240 |
+
|
| 241 |
+
[47] Esben Jannik Bjerrum and Richard Threlfall. Molecular generation with recurrent neural networks (rnns). arXiv preprint arXiv:1705.04612, 2017.
|
| 242 |
+
|
| 243 |
+
[48] Marwin HS Segler, Thierry Kogej, Christian Tyrchan, and Mark P Waller. Generating focused molecule libraries for drug discovery with recurrent neural networks. ACS central science, 4(1):120–131, 2018.
|
| 244 |
+
|
| 245 |
+
[49] Daniel Flam-Shepherd, Kevin Zhu, and Alán Aspuru-Guzik. Keeping it simple: Language models can learn complex molecular distributions. arXiv preprint arXiv:2112.03041, 2021.
|
| 246 |
+
|
| 247 |
+
[50] Jiaxuan You, Bowen Liu, Zhitao Ying, Vijay Pande, and Jure Leskovec. Graph convolutional policy network for goal-directed molecular graph generation. Advances in neural information processing systems, 31, 2018.
|
| 248 |
+
|
| 249 |
+
[51] Wengong Jin, Regina Barzilay, and Tommi Jaakkola. Multi-objective molecule generation using interpretable substructures. In International conference on machine learning, pages 4849–4859. PMLR, 2020.
|
| 250 |
+
|
| 251 |
+
[52] Yibo Li, Jianxing Hu, Yanxing Wang, Jielong Zhou, Liangren Zhang, and Zhenming Liu. Deepscaffold: a comprehensive tool for scaffold-based de novo drug discovery using deep learning. Journal of chemical information and modeling, 60(1):77–91, 2019.
|
| 252 |
+
|
| 253 |
+
[53] Jaechang Lim, Sang-Yeon Hwang, Seokhyun Moon, Seungsu Kim, and Woo Youn Kim. Scaffold-based molecular design with a graph generative model. Chemical science, 11(4):1153– 1164, 2020.
|
| 254 |
+
|
| 255 |
+
[54] Rafael Gómez-Bombarelli, Jennifer N Wei, David Duvenaud, José Miguel Hernández-Lobato, Benjamín Sánchez-Lengeling, Dennis Sheberla, Jorge Aguilera-Iparraguirre, Timothy D Hirzel, Ryan P Adams, and Alán Aspuru-Guzik. Automatic chemical design using a data-driven continuous representation of molecules. ACS central science, 4(2):268–276, 2018.
|
| 256 |
+
|
| 257 |
+
[55] Vitali Nesterov, Mario Wieser, and Volker Roth. 3dmolnet: a generative network for molecular structures. arXiv preprint arXiv:2010.06477, 2020.
|
| 258 |
+
[56] Gregor Simm, Robert Pinsler, and José Miguel Hernández-Lobato. Reinforcement learning for molecular design guided by quantum mechanics. In International Conference on Machine Learning, pages 8959–8969. PMLR, 2020.
|
| 259 |
+
[57] Emiel Hoogeboom, Victor Garcia Satorras, Clément Vignac, and Max Welling. Equivariant diffusion for molecule generation in 3d. In International Conference on Machine Learning, pages 8867–8887. PMLR, 2022.
|
| 260 |
+
[58] Lemeng Wu, Chengyue Gong, Xingchao Liu, Mao Ye, and Qiang Liu. Diffusion-based molecule generation with informative prior bridges. arXiv preprint arXiv:2209.00865, 2022.
|
| 261 |
+
[59] Muhammed Shuaibi, Adeesh Kolluru, Abhishek Das, Aditya Grover, Anuroop Sriram, Zachary Ulissi, and C Lawrence Zitnick. Rotation invariant graph neural networks using spin convolutions. arXiv preprint arXiv:2106.09575, 2021.
|
| 262 |
+
[60] Chia-Tche Chang, Bastien Gorissen, and Samuel Melchior. Fast oriented bounding box optimization on the rotation group so (3, r). ACM Transactions on Graphics (TOG), 30(5):1–16, 2011.
|
| 263 |
+
[61] Jerome Eberhardt, Diogo Santos-Martins, Andreas F Tillack, and Stefano Forli. Autodock vina 1.2. 0: New docking methods, expanded force field, and python bindings. Journal of Chemical Information and Modeling, 61(8):3891–3898, 2021.
|
| 264 |
+
[62] Alexey Onufriev, Donald Bashford, and David A Case. Exploring protein native states and large-scale conformational changes with a modified generalized born model. Proteins: Structure, Function, and Bioinformatics, 55(2):383–394, 2004.
|
| 265 |
+
[63] Yong Duan, Chun Wu, Shibasish Chowdhury, Mathew C Lee, Guoming Xiong, Wei Zhang, Rong Yang, Piotr Cieplak, Ray Luo, Taisung Lee, et al. A point-charge force field for molecular mechanics simulations of proteins based on condensed-phase quantum mechanical calculations. Journal of computational chemistry, 24(16):1999–2012, 2003.
|
| 266 |
+
[64] Araz Jakalian, Bruce L Bush, David B Jack, and Christopher I Bayly. Fast, efficient generation of high-quality atomic charges. am1-bcc model: I. method. Journal of computational chemistry, 21(2):132–146, 2000.
|
| 267 |
+
[65] Harrison Green and Jacob D Durrant. Deepfrag: An open-source browser app for deep-learning lead optimization. Journal of chemical information and modeling, 61(6):2523–2529, 2021.
|
| 268 |
+
|
| 269 |
+
A VD-GEN DETAILS
|
| 270 |
+
|
| 271 |
+
Table 3: Symbol in VD-Gen.
|
| 272 |
+
|
| 273 |
+
<table><tr><td>Symbol</td><td>Meaning</td></tr><tr><td>P</td><td>the set of atoms in the pocket</td></tr><tr><td>Vr</td><td>the set of virtual particles (VPs) that are generated at the r-th round in Equilibrium</td></tr><tr><td>Wr</td><td>the set of virtual particles (VPs) that are generated at the r-th round in Refinement</td></tr><tr><td>G</td><td>the set of ground-truth atoms</td></tr><tr><td></td><td>the i-th pocket atom's type (one-hot)</td></tr><tr><td></td><td>the i-th pocket atom's coordinate</td></tr><tr><td></td><td>the i-th ground-truth atom's type (one-hot)</td></tr><tr><td></td><td>the i-th ground-truth atom's coordinate</td></tr><tr><td></td><td>the i-th VP's type (one-hot) at the r-th round in Equilibrium</td></tr><tr><td></td><td>the i-th VP's coordinate at the r-th round in Equilibrium</td></tr><tr><td></td><td>predicted atom type distribution of i-th VP at the r-th round</td></tr><tr><td>ai</td><td>The index of assigned target atom for the i-th VP</td></tr><tr><td>di</td><td>the predicted distance of the i-th and j-th VP pair at the r-th round</td></tr><tr><td></td><td>the ground-truth distance of the i-th and j-th VP pair</td></tr><tr><td></td><td>the predicted (ground-truth) distance of the i-th VP and the j-th pocket atom at the r-th round</td></tr><tr><td></td><td>the ground-truth distance of the i-th VP and the j-th pocket atom.</td></tr><tr><td>xr</td><td>the i-th VP's type (one-hot) at the r-th round in Refinement</td></tr><tr><td>yi</td><td>the i-th VP's coordinate at the r-th round in in Refinement</td></tr><tr><td></td><td>the pair representation of VP pair</td></tr><tr><td></td><td>the pair representation of VP pair at l-th layer</td></tr><tr><td></td><td>the pair representation of pocket atom pair</td></tr><tr><td></td><td>the pair representation of VP and pocket pair</td></tr><tr><td></td><td>the predicted probability distribution of "success or" not for VP</td></tr><tr><td>r</td><td>predicted probability of merging type of VP pair</td></tr><tr><td>n</td><td>the predicted atom number</td></tr><tr><td>Wi</td><td>The indices of VPs in the i-th cluster in Extraction</td></tr><tr><td>h</td><td>the node representation of VP</td></tr><tr><td>h</td><td>the node representation of VP at l-th layer</td></tr><tr><td>hV</td><td>the node representation of VP in Equilibrium</td></tr><tr><td>qV</td><td>the pair representation of VP pair in Equilibrium</td></tr><tr><td>hW</td><td>the node representation of VP in Refinement</td></tr><tr><td>94</td><td>the pair representation of VP pair in Refinement</td></tr><tr><td>hP</td><td>the node representation of pocket atom</td></tr><tr><td>0eq</td><td>the model parameter in Equilibrium</td></tr><tr><td>0ex</td><td>the model parameter in Extraction</td></tr><tr><td>0re</td><td>the model parameter in Refinement</td></tr><tr><td>0co</td><td>the model parameter in Confidence</td></tr><tr><td>f</td><td>the SE(3) backbone model, return VP types and coordinates</td></tr><tr><td>L</td><td>the number of layers</td></tr></table>
|
| 274 |
+
|
| 275 |
+
# A.1 VIRTUAL DYNAMICS
|
| 276 |
+
|
| 277 |
+
# A.1.1 DETAILS OF THE BACKBONE MODEL
|
| 278 |
+
|
| 279 |
+
In Fig 2 we show the structure of our backbone model, "Repr.", "Attn." and "Dist." are the abbreviations of "Representation", "Attention" and "Distance", respectively. On the left is the pocket encoder, which first uses an atom-type embedding to encode the pocket atom type and a Gaussian kernel to encode the pair-wise distances between pocket atom pairs. In each layer of the pocket encoder, a self-attention layer is used. On the right is the VP encoder, which also uses an atom-type embedding and a Gaussian kernel to encode the particle type and the pair-wise distances between VPs. To interact with the pocket encoder, another Gaussian kernel is used to encode the pair-wise distances between VPs and pocket atoms. In each layer of the VP encoder, before the self-attention layer, a particle-pocket attention layer is used to interact with the pocket encoder.
|
| 280 |
+
|
| 281 |
+
We describe the components in the backbone model in the following paragraphs. Besides, we also describe the overall pipeline of the backbone model in the Alg. 2. For simplicity, layer normalization is not shown in the equations and algorithms.
|
| 282 |
+
|
| 283 |
+
Gaussian kernel The pair-type aware Gaussian kernel [59; 28] is denoted as:
|
| 284 |
+
|
| 285 |
+
$$
|
| 286 |
+
p _ { i j } = \{ \mathcal { G } ( A ( d _ { i j } , t _ { i j } ; a , b ) , \mu ^ { k } , \sigma ^ { k } ) | k \in [ 1 , D ] \} , \quad \mathcal { A } ( d , r ; a , b ) = a _ { r } d + b _ { r } ,
|
| 287 |
+
$$
|
| 288 |
+
|
| 289 |
+
where $\begin{array} { r } { \mathcal { G } ( d , \mu , \sigma ) = \frac { 1 } { \sigma \sqrt { 2 \pi } } e ^ { - \frac { ( d - \mu ) ^ { 2 } } { 2 \sigma ^ { 2 } } } } \end{array}$ is a Gaussian density function with parameters $\mu$ and $\sigma , d _ { i j }$ is the Euclidean distance of atom pair $i j$ , and $t _ { i j }$ is the pair-type of atom pair $i j$ . $\mathcal { A } ( d _ { i j } , t _ { i j } ; \pmb { a } , \pmb { b } )$ is the affine transformation with parameters $\textbf { \em a }$ and $^ { b }$ , it affines $d _ { i j }$ corresponding to its pair-type $t _ { i j }$ .
|
| 290 |
+
|
| 291 |
+
Pair representation Pair representation [28] is used to further enhance the 3D spatial encoding.
|
| 292 |
+
The update of pair representation is via the multi-head Query-Key product results in self-attention.
|
| 293 |
+
|
| 294 |
+
$$
|
| 295 |
+
{ \pmb q } _ { i j } ^ { l + 1 } = { \pmb q } _ { i j } ^ { l } + \{ \frac { { \pmb h } _ { i } ^ { l } { \pmb W } _ { l , h } ^ { Q } ( { \pmb h } _ { j } ^ { l } { \pmb W } _ { l , h } ^ { K } ) ^ { T } } { \sqrt { d } } | h \in [ 1 , H ] \} ,
|
| 296 |
+
$$
|
| 297 |
+
|
| 298 |
+
where $h _ { i } ^ { l }$ is the atom/node representation of the $i$ -th atom at $l$ -th layer, $\pmb { q } _ { i j } ^ { l }$ is the pair representation of atom pair $i j$ in $l$ -th layer, $H$ is the number of attention heads, $d$ is the dimension of hidden representations, and $W _ { l , h } ^ { Q } ( W _ { l , h } ^ { K } )$ is the projection for Query (Key) of the $l$ -th layer $h$ -th head.
|
| 299 |
+
|
| 300 |
+
To leverage 3D information in the atom representation, pair representation is used in self-attention.
|
| 301 |
+
|
| 302 |
+
$$
|
| 303 |
+
\begin{array} { r l } & { \pmb { h } _ { i } ^ { l + 1 , h } = \mathrm { s o f t m a x } ( \frac { h _ { i } ^ { l } W _ { l , h } ^ { Q } ( h _ { j } ^ { l } W _ { l , h } ^ { K } ) ^ { T } } { \sqrt { d } } + \pmb { q } _ { i j } ^ { l , h } ) \pmb { h } _ { j } ^ { l } W _ { l , h } ^ { V } , } \\ & { \quad \pmb { h } _ { i } ^ { l + 1 } = \mathrm { c o n c a t } _ { h } ( \pmb { h } _ { i } ^ { l + 1 , h } ) , } \end{array}
|
| 304 |
+
$$
|
| 305 |
+
|
| 306 |
+
where ${ W } _ { l , h } ^ { V }$ is the projection of Value of the $l$ -th layer $h$ -th head.
|
| 307 |
+
|
| 308 |
+
Particle-Pocket Attention The Particle-Pocket Attention can be denoted as the following:
|
| 309 |
+
|
| 310 |
+
$$
|
| 311 |
+
\begin{array} { r l } & { { \pmb h } _ { i } ^ { l + 1 , h } = \mathrm { s o f t m a x } ( \frac { h _ { i } ^ { l } { \pmb W } _ { l , h } ^ { P , Q } ( { \pmb h } _ { j } ^ { P } { \pmb W } _ { l , h } ^ { P , K } ) ^ { T } } { \sqrt { d } } + { \pmb q } _ { i j } ^ { C , l , h } ) { \pmb h } _ { j } ^ { P } { \pmb W } _ { l , h } ^ { P , V } , } \\ & { { \pmb h } _ { i } ^ { l + 1 } = \mathrm { c o n c a t } _ { h } ( { \pmb h } _ { i } ^ { l + 1 , h } ) , } \\ & { { \pmb h } _ { i } ^ { l + 1 } = { \pmb h } _ { i } ^ { l } + g _ { 1 } \cdot { \pmb h } _ { i } ^ { l + 1 } + g _ { 2 } \cdot \mathrm { { M L P } } ( { \pmb h } _ { i } ^ { l + 1 } ) , } \end{array}
|
| 312 |
+
$$
|
| 313 |
+
|
| 314 |
+
where $g _ { 1 }$ and $g _ { 2 }$ are learned parameters with initialized value 0, $h _ { j } ^ { P }$ is the representation of the $j$ -th pocket atom, qC,ij $\mathbf { \mathfrak { q } } _ { i j } ^ { C , l , h }$ is the pair representation of particle-pocket pair $i j$ in $l$ -th layer $h$ -th head, MLP is a full-connected network with one hidden layer. W P,Ql,h , W P,Kl,h , and W P,Vl,h are learnable projections for Query, Key and Value.
|
| 315 |
+
|
| 316 |
+
SE(3)-equivariance coordinate Following [28], the head could be denoted as:
|
| 317 |
+
|
| 318 |
+
$$
|
| 319 |
+
\pmb { y } _ { i } ^ { r + 1 } = \pmb { y } _ { i } ^ { r } + \sum _ { j = 1 } ^ { n } \frac { ( \pmb { y } _ { i } ^ { r } - \pmb { y } _ { j } ^ { r } ) z _ { i j } } { n } , \quad z _ { i j } = \mathrm { R e L U } ( ( \pmb { q } _ { i j } ^ { L } - \pmb { q } _ { i j } ^ { 0 } ) U _ { 1 } ) U _ { 2 } ,
|
| 320 |
+
$$
|
| 321 |
+
|
| 322 |
+
where $n$ is the number of total atoms, $L$ is the number of layers in model, $\pmb { y } _ { i } ^ { r } \in \mathbb { R } ^ { 3 }$ is the input coordinate of $i$ -th atom, and $\pmb { y } _ { i } ^ { r + 1 } \in \mathbb { R } ^ { 3 }$ is the output coordinate of $i$ -th atom, $U _ { 1 } \in \mathbb { R } ^ { H \times H }$ and $U _ { 2 } \in \mathbb { R } ^ { H \times 1 }$ are the projection matrices to convert pair representation to scalar.
|
| 323 |
+
|
| 324 |
+
Atom Type Prediction Head We use a non-linear head with two layers to predict the atom type based on the atom representation in the last layer of the particle encoder:
|
| 325 |
+
|
| 326 |
+
$$
|
| 327 |
+
\bar { \mathbf { x } } _ { i } = \mathbf { M L P } ( h _ { i } ^ { L } )
|
| 328 |
+
$$
|
| 329 |
+
|
| 330 |
+
where $ { \boldsymbol { h } } _ { i } ^ { L }$ is the atom representation, $L$ is the number of layers of the particle encoder,
|
| 331 |
+
|
| 332 |
+
# Algorithm 2 Backbone_Update
|
| 333 |
+
|
| 334 |
+
Require: P: pocket atoms, ${ \mathbf V } _ { r }$ : virtual particles
|
| 335 |
+
1: ${ \boldsymbol { h } } ^ { P , 0 } \gets$ rAtom_Type_Embedding $( \mathbf { P } )$ a ▷ Embeddings from atom types
|
| 336 |
+
2: $\pmb q ^ { P , 0 } \gets$ Gaussian_Kernel(Dist_Matrix(P, P)) ▷ Get invariant spatial positional embedding
|
| 337 |
+
3: for $l \in [ 1 , . . . , L )$ do ▷ Update Pocket Encoder
|
| 338 |
+
4: $\pmb { h } ^ { P , l } , \pmb { q } ^ { P , l } \gets \mathrm { S e l f \_ A t t n } ( \pmb { h } ^ { P , l - 1 } , \pmb { q } ^ { P , l - 1 } ) )$ ▷ Update by self attention
|
| 339 |
+
5: $\boldsymbol { h } ^ { P , l } \gets \mathrm { M L P } ( \boldsymbol { h } ^ { P , l } )$ ▷ Update by Feed-Forward-Network
|
| 340 |
+
6: ${ h ^ { P } h ^ { P , L } }$
|
| 341 |
+
7: ${ \mathbf { } } h ^ { 0 } $ Atom_Type_Embedding $\left( \mathbf { V } _ { r } \right)$ ▷ Embeddings from atom types
|
| 342 |
+
8: $q ^ { 0 } \gets$ Gaussian_Kernel(Dist_Matrix(V0, V0)) $\triangleright$ Get invariant spatial positional embedding
|
| 343 |
+
9: $\pmb q ^ { C , 0 } \gets$ Gaussian_Kernel(Dist_Matrix $( \mathbf { V } _ { 0 } , \mathbf { P } ) )$ ▷ Get invariant spatial positional embedding of
|
| 344 |
+
particle-pocket pairs
|
| 345 |
+
10: for $l \in [ 1 , . . . , L )$ do ▷ Update Particle Encoder
|
| 346 |
+
11: $\pmb { h } ^ { l } , \pmb { q } ^ { l } \gets \mathrm { S e l f \_ A t t n } ( \pmb { h } ^ { l - 1 } , \pmb { q } ^ { l - 1 } ) )$ ▷ Update by self attention
|
| 347 |
+
12: $\pmb { h } ^ { l } \gets \mathrm { M L P } ( \pmb { h } ^ { l } )$ ▷ Update by Feed-Forward-Network
|
| 348 |
+
13: if l mod $4 = = 0$ then ▷ Only enabled at every 4-layer
|
| 349 |
+
14: h l , $\pmb q ^ { C , l } \gets$ Particle_Pocket_Attn(hl, hP , qC,l−1)) ▷ Update by Particle-Pocket Attention
|
| 350 |
+
15: $\bar { \pmb { x } } ^ { r + 1 } \mathrm { A t o m \_ T y p e \_ H e a d } ( \pmb { h } ^ { L } )$ $\triangleright$ Atom Type Prediction
|
| 351 |
+
16: $\pmb { x } ^ { r + 1 } \mathrm { s a m p l e } ( \bar { \pmb { x } } ^ { r + 1 } )$ ▷ Sample an atom type based on predicted probability
|
| 352 |
+
17: $\pmb { y } ^ { r + 1 } \gets \mathrm { S E } ( 3 ) \_ \mathrm { H e a d } ( \pmb { y } ^ { r } , \pmb { q } ^ { L } )$ $\triangleright$ Coordinate update
|
| 353 |
+
18: return $\mathbf { V } _ { r + 1 } = \{ \pmb { x } ^ { r + 1 } , \pmb { y } ^ { r + 1 } \} , \pmb { h } ^ { L } , \pmb { q } ^ { L } , \pmb { h } ^ { P }$
|
| 354 |
+
|
| 355 |
+

|
| 356 |
+
Figure 5: A case to show the detected pocket cavity.
|
| 357 |
+
|
| 358 |
+
# A.1.2 POCKET CAVITY DISCOVERY
|
| 359 |
+
|
| 360 |
+
Pocket cavity discovery is an essential component in ${ \tt V D - G e n }$ , as VPs need to scatter into the cavity. To find the pocket cavity, we first use OBB (oriented bounding box) [60] to determine a cubic box, denote as $\boldsymbol { B }$ , based on the pocket’s residue atoms. Then, we enlarge the box a little bit, increased by $4 \mathring \mathrm { A }$ . Then, we make the 3D grids with resolution $2 \textup { \AA }$ , for the whole protein, including the pocket, and mark the grids that contain protein atoms as "used". Then, starting from a given grid inside the cavity, a breadth-first search is used to find the grids inside the cavity. In particular, the grids marked as "used" or are not in $\boldsymbol { B }$ are not considered. We show an example in Fig 5, where the purple region indicates the pocket cavity we find.
|
| 361 |
+
|
| 362 |
+
# A.2 EXTRACTION
|
| 363 |
+
|
| 364 |
+
# Filtering Loss
|
| 365 |
+
|
| 366 |
+
$$
|
| 367 |
+
{ \mathcal { L } } _ { F i l t e r } = { \frac { 1 } { n } } \sum _ { i = 1 } ^ { n } { \mathrm { N L L } } ( { \bar { s } } _ { i } , s _ { i } )
|
| 368 |
+
$$
|
| 369 |
+
|
| 370 |
+
where $n$ is the number of virtual particles, $\bar { s } _ { i }$ is the predicted probability distribution of success or not, $\mathbf { \boldsymbol { s } } _ { i }$ is the target label. The target label is marked as "success" if the distances between VPs and their target positions after Equilibrium are smaller than $2 . 5 \mathring \mathrm { \ A }$ .
|
| 371 |
+
|
| 372 |
+
# Merging Loss
|
| 373 |
+
|
| 374 |
+
$$
|
| 375 |
+
\mathcal { L } _ { M e r g e } = \frac { 1 } { l ^ { 2 } } \sum _ { i = 1 } ^ { l } \sum _ { j = 1 } ^ { l } \sum _ { k = 1 } ^ { 2 } - { r } _ { i j } ^ { k } \log \bar { { r } } _ { i j } ^ { k } \alpha _ { k } ( 1 - \bar { { r } } _ { i j } ^ { k } ) ^ { \gamma } ,
|
| 376 |
+
$$
|
| 377 |
+
|
| 378 |
+
where $l$ is the number of virtual particles predicted to be "success", $\boldsymbol { r } _ { i j }$ is the target merging type, $\bar { r } _ { i j }$ is the predicted probability of merging type, the blue part is from focal loss [32], and $\alpha _ { k }$ and $\gamma$ are
|
| 379 |
+
|
| 380 |
+
hyper-parameters to balance classes. Here $\gamma$ is set to 2, the subscript 1 of $\alpha$ represents the True type and $\alpha _ { 1 }$ is set 10 while $\alpha _ { 0 }$ is set to 1.
|
| 381 |
+
|
| 382 |
+
Atom number loss For atom number prediction, we bucket the number of atoms into different bins and transform the numerical problem into a classification problem to make the training more stable.
|
| 383 |
+
|
| 384 |
+
$$
|
| 385 |
+
\mathcal { L } _ { a t o m \_ n u m } = \mathrm { N L L } ( \bar { o } , o )
|
| 386 |
+
$$
|
| 387 |
+
|
| 388 |
+
where $\bar { \bf o }$ is the predicted probability distribution of bins, and $^ o$ represents the one-hot vector of the target bin.
|
| 389 |
+
|
| 390 |
+
During inference, the predicted atomic number can be calculated from the predicted distribution over bins.
|
| 391 |
+
|
| 392 |
+
$$
|
| 393 |
+
\sum _ { k = 1 } ^ { n _ { b i n } } ( b i n _ { - } v a l _ { k } ) \bar { \pmb { o } } _ { k } ,
|
| 394 |
+
$$
|
| 395 |
+
|
| 396 |
+
where $b i n \_ v a l _ { k }$ is the bin value of the $k$ -th bin, $n _ { \mathrm { b i n } }$ is the number of bins, $l$ is the size of each bin and $\bar { o } _ { k }$ is the predicted probability of the $k$ -th bin. Notably, the bin value is not the bin boundary value, it is the average of left and right boundaries.
|
| 397 |
+
|
| 398 |
+
Merge algorithm The detail of merging VPs into atoms are shown in Alg 3. In particular, a binary search is used to find a merging threshold. During training, teacher-forcing merging is used for reducing the training cost (without binary search). This is, rather than predicting pair-wise merge probabilities and the atom number, we directly used their ground truth values. During inference, the binary search is used. Besides, considering the error in atom number prediction, we try a range $( \pm 1 0 )$ of atom numbers, and select from them based on their confidence scores.
|
| 399 |
+
|
| 400 |
+
# A.3 CONFIDENCE
|
| 401 |
+
|
| 402 |
+
The confidence score is based on LDDT metric [33]:
|
| 403 |
+
|
| 404 |
+
$$
|
| 405 |
+
\begin{array} { l } { { \displaystyle { \mathrm { L D D T } } = \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \sum _ { j \neq i } \frac { 1 } { 4 } ( ( \operatorname { e r r } _ { i j } < 0 . 5 ) + ( \operatorname { e r r } _ { i j } < 1 . 0 ) + ( \operatorname { e r r } _ { i j } < 2 . 0 ) + ( \operatorname { e r r } _ { i j } ) < 4 . 0 ) , } } \\ { { \displaystyle \operatorname { e r r } _ { i j } = \mathrm { L } 1 ( \| \hat { y } _ { i } ^ { r } - \hat { y } _ { j } ^ { r } \| _ { 2 } , \| \hat { y } _ { i } ^ { g } - \hat { y } _ { j } ^ { g } \| _ { 2 } ) , } } \end{array}
|
| 406 |
+
$$
|
| 407 |
+
|
| 408 |
+
where $\hat { \mathbf { \pmb { y } } } _ { i } ^ { r }$ is the predicted coordinate of $i$ -th particle after Refinement, and $\hat { \pmb y } _ { i } ^ { g }$ is its ground truth coordinate. Then, a task is trained to predict the LDDT score. Here, we use the binning trick for training stability, bucketing the error of each VP into different bins, and using cross-entropy loss to train the task:
|
| 409 |
+
|
| 410 |
+
$$
|
| 411 |
+
{ \mathcal { L } } _ { C o n f i d e n c e } = { \frac { 1 } { n } } \sum _ { i = 1 } ^ { n } { \mathrm { N L L } } ( { \bar { e } } _ { i } , e _ { i } )
|
| 412 |
+
$$
|
| 413 |
+
|
| 414 |
+
where $\bar { e } _ { i }$ is the predicted error’s probability distribution of $i$ -th VP and $e _ { i }$ represents the one-hot vector of the real error.
|
| 415 |
+
|
| 416 |
+
# A.4 PRETRAIN
|
| 417 |
+
|
| 418 |
+
During pretraining, we remove atoms in a continuous spatial region, and VPs are initialized in the region. To find the atoms in a continuous region, we design a greedy algorithm. First, we initialize an empty atom set, then we randomly select an atom in the molecular to join the set. Starting from the atom set, we choose an atom closest to the atoms in the set and join it to the set. We repeat the process until the number of atoms in the set meets the requirements. And we use OBB (oriented bounding box) [60] to determine a cubic box by the removed atoms, and VPs are initialized inside the cubic box.
|
| 419 |
+
|
| 420 |
+
# A.5 VD-GEN OVERALL ALGORITHM
|
| 421 |
+
|
| 422 |
+
We also summarize the overall inference pipeline of VD-Gen in the Alg. 4. The algorithm mainly relies on the function "VD", which iteratively moves the VPs. Both Equilibrium and Refinement use
|
| 423 |
+
|
| 424 |
+
# Algorithm 3 Filter_Merge_VPs
|
| 425 |
+
|
| 426 |
+
<table><tr><td>ability</td><td></td><td>Require: VR = {(xR,y)}ε=1: virtual particles at R-th rounds, n: the predicted atom num, r =</td><td></td></tr><tr><td>1: for iin [.,..,n] do 2:</td><td></td><td> Set the merge type between particles with the particle to be filtered to O</td><td></td></tr><tr><td>Si←argmax(si)</td><td></td><td></td><td>Get the filtering type</td></tr><tr><td>3:</td><td>if si=Othen</td><td></td><td>If the i-th particle should be filtered</td></tr><tr><td>4:</td><td>r[:,i]←0</td><td></td><td>Set{ri,j=1 to0 n</td></tr><tr><td>5:</td><td>r[i,:]←0</td><td></td><td>Set{rj=1to0 n</td></tr><tr><td>6:</td><td>high←max({((rij)}1,j=1) nxn</td><td></td><td></td></tr><tr><td></td><td>7: low ←min({(Tij)}²=i,j=1) nxn</td><td></td><td></td></tr><tr><td>8:mid ←low+high</td><td></td><td></td><td></td></tr><tr><td>9:</td><td>2 while low high do</td><td></td><td>>using the binary search to find the threshold</td></tr><tr><td>10:</td><td>Tij←rij >mid</td><td></td><td></td></tr><tr><td>11:</td><td>Wo↑,ω←[,m←0</td><td></td><td></td></tr><tr><td>12:</td><td>foriin random_perm(1,n) do</td><td></td><td>Greedy merge based a random order</td></tr><tr><td>13:</td><td>W←,</td><td></td><td></td></tr><tr><td>14:</td><td>for j in[1,..,n] do</td><td></td><td></td></tr><tr><td>15:</td><td>if rij= True then</td><td></td><td> the j-th particle should be merged</td></tr><tr><td>16:</td><td>r[:,j]←False</td><td></td><td> the merged particle will not be merged again</td></tr><tr><td>17:</td><td>Wi.add(j)</td><td></td><td>add the particle indices into the i-th cluster</td></tr><tr><td>18:</td><td>if len(wi)>O then</td><td></td><td></td></tr><tr><td>19:</td><td></td><td></td><td>> Sample atom type from the merging list</td></tr><tr><td>20:</td><td>m←Mean({ylk∈wi})</td><td>> the average position is atom position after merging</td><td></td></tr><tr><td>21:</td><td>Wo.add((xm,ym))</td><td></td><td>add the atom to the set</td></tr><tr><td>22:</td><td>m←m+1</td><td></td><td>Count the number of clusters</td></tr><tr><td>23:</td><td>if m=n then</td><td></td><td> find the threshold</td></tr><tr><td>24:</td><td>break</td><td></td><td></td></tr><tr><td>25:</td><td>else</td><td></td><td></td></tr><tr><td>26:</td><td>ifm<nthen</td><td>V too many particles are merged, the threshold needs to be increased</td><td></td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td>27:</td><td>low←mid</td><td></td><td></td></tr><tr><td>28:</td><td>else</td><td></td><td></td></tr><tr><td>29: return Wo</td><td>high ←mid</td><td>>Too few particles are merged, the threshold needs to be lowered</td><td>Return particle set after merging</td></tr></table>
|
| 427 |
+
|
| 428 |
+
"VD". In Extraction, several heads are used to predict the filtered probability, the pair merge probability, and the number of atoms of the ligand molecule. Based on these predictions, "Filter_Merge_VPs" is used to extract the merged VPs.
|
| 429 |
+
|
| 430 |
+
The training pipeline is very similar, except for the following differences:
|
| 431 |
+
|
| 432 |
+
• For efficiency purposes, $R _ { 1 }$ and $R _ { 2 }$ are sampled during training, and the gradient backward is only enabled in the last round.
|
| 433 |
+
• For efficiency purposes, in "Filter_Merge_VPs", teacher-forcing merging (without binary search) is used during training. This is, rather than predicting pair-wise merge probabilities and the atom number, we directly used their ground truth values.
|
| 434 |
+
• The loss functions are enabled to get gradients to train models.
|
| 435 |
+
|
| 436 |
+
# B EXPERIMENT DETAILS AND MORE RESULTS
|
| 437 |
+
|
| 438 |
+
# B.1 TRAINING DETAILS
|
| 439 |
+
|
| 440 |
+
The detailed configurations of VD-Gen are listed in Table 4. We did not tune these hyper-parameters for now, a better performance could be achieved with well-tuned hyper-parameters.
|
| 441 |
+
|
| 442 |
+
# B.2 EVALUATION MERTIC
|
| 443 |
+
|
| 444 |
+
• $3 D$ similarity. We use LIGSIFT [25] to calculate 3D similarity. However, by default, LIGSIFT will align the input molecules before calculating 3D similarity. But we want to evaluate the generated
|
| 445 |
+
|
| 446 |
+
# Algorithm 4 VD-Gen Framework during Inference
|
| 447 |
+
|
| 448 |
+
Require: $R _ { 1 }$ , $R _ { 2 }$ : max rounds in Equilibrium and Refinement, P: pocket atoms with types and positions, $_ n$ :
|
| 449 |
+
number of VPs, $\pmb { \theta } _ { e q }$ , $\pmb { \theta } _ { e x }$ , $\pmb { \theta } _ { r e }$ , $\pmb { \theta } _ { c o }$ : model parameters in different stages
|
| 450 |
+
1:
|
| 451 |
+
2: # Virtual dynamics mechanism
|
| 452 |
+
3: def $\mathrm { V D } ( R , { \bf V } _ { 0 } , { \bf P } , \theta )$ : ▷ Virtual dynamics mechanism
|
| 453 |
+
4: for $k \in [ 1 , . . . , R ]$ do $\triangleright$ Iterative updates without gradients
|
| 454 |
+
5: $\mathbf { V } _ { k } , h ^ { L } , q ^ { L } , h ^ { P } \longleftarrow \mathrm { B a c k b o n e \underline { { \mathbf { U } } } p d a t e } ( \mathbf { V } _ { k - 1 } , \mathbf { P } ; \theta )$ ▷ backbone model update as in Alg. 2
|
| 455 |
+
return ${ \mathbf V } _ { R } , { \hbar } ^ { L } , { q } ^ { L } , { \hbar } ^ { P }$
|
| 456 |
+
6:
|
| 457 |
+
7: # Initialize VPs
|
| 458 |
+
8: $\tilde { P } = \mathrm { C a v i t y \_ D i s c o v e r y } ( { \bf P } )$ ▷ Get the pocket cavity as in Appendix A.1.2
|
| 459 |
+
9: for $i$ in [1,...,n] do
|
| 460 |
+
10: $\pmb { x } _ { i } ^ { 0 } \gets \mathrm { o n e \_ h o t ( \mathrm { I M A S K } ] ) }$ ▷ The types of VPs are initialized as a meaningless [MASK] type
|
| 461 |
+
11: ${ \pmb y } _ { i } ^ { 0 } \gets \mathrm { U n i f o r m } ( \tilde { P } )$ ▷ The initial coordinates of VPs are uniformly sampled from the cavity
|
| 462 |
+
12: $\mathbf { V } _ { 0 } = \{ ( { \mathbf { x } } _ { i } ^ { 0 } , { \mathbf { y } } _ { i } ^ { 0 } ) \} _ { i = 1 } ^ { n }$
|
| 463 |
+
13:
|
| 464 |
+
14: # Equilibrium stage
|
| 465 |
+
15: ${ \bf V } _ { R } \dot { \bf \Delta } _ { } h ^ { V } , \pmb { q } ^ { V } , \pmb { h } ^ { P ^ { \angle } } \nabla \mathrm { D } ( R _ { 1 } , { \bf V } _ { 0 } , { \bf P } , \pmb { \theta } _ { e q } )$ ▷ Predict coordinates and types with VD
|
| 466 |
+
16:
|
| 467 |
+
17: # Extraction stage
|
| 468 |
+
18: $\bar { 3 } \mathrm { F i l t e r \_ H e a d } ( h ^ { V } ; \pmb \theta _ { e x } )$ ▷ Predict to filter the "not success" particles
|
| 469 |
+
19: $\bar { r } \gets \mathsf { M e r g e \_ H e a d } ( \pmb { q } ^ { V } ; \pmb { \theta } _ { e x } )$ ▷ Predict merging matrix
|
| 470 |
+
20: $\bar { n } \mathrm { A t o m \_ N u m \_ H e a d } ( h ^ { P } ; \pmb \theta _ { e x } )$ ▷ Predict the atom number
|
| 471 |
+
21: ${ \bf W } _ { 0 } \gets \mathrm { F i l t e r \_ M e r g e \_ V P s } ( { \bf V } _ { R } , \bar { n } , \bar { r } , \bar { s } )$
|
| 472 |
+
22: ▷ Filter and Merge VPs as in Alg. 3 using predicted merging matrix, atom number and filtering type
|
| 473 |
+
23:
|
| 474 |
+
24: # Refinement stage
|
| 475 |
+
25: $\mathbf { W } _ { R } ^ { \check { \mathbf { \alpha } } } , \mathbf { \Phi } _ { } \mathbf { \Phi } _ { } \mathbf { \Phi } _ { } \mathbf { q } ^ { W } , \check { \mathbf { \alpha } } \check { h } ^ { P } \gets \mathrm { V D } ( R _ { 2 } , \mathbf { W } _ { 0 } , \mathbf { P } ; \mathbf { \theta } _ { r e } )$ ▷ Refine the coordinates and types
|
| 476 |
+
26: # Confidence stage
|
| 477 |
+
27: Pred_LDDT Confidence_Head(hW , θco) ▷ Predict LDDT
|
| 478 |
+
28:
|
| 479 |
+
29: return $\mathbf { W } _ { R }$ , Pred_LDDT ▷ Return the final positions and types, and the confidence score
|
| 480 |
+
|
| 481 |
+
3D structure directly, to examine the end-to-end performance. Therefore, we remove the alignment in LIGSIFT.
|
| 482 |
+
|
| 483 |
+
• Vina. We use AutoDock Vina1.2 [61] to get Vina score. In particular, the re-docking will be applied. That is, the binding pose and the conformation of the ligand molecule generated by the model will be ignored, and a new binding pose and a new molecular conformation will be re-calculated by AutoDock Vina1.2. We believe the re-docking in Vina cannot reflect the actual performance of the pocket-based 3D molecular generation. But to be consistent with previous works, we still use it as one of the metrics.
|
| 484 |
+
|
| 485 |
+
• Vina\*. Vina\* is Vina without re-docking. In particular, we use the built-in energy optimization process based on Vina scoring function in AutoDock Vina1.2 [61] to minimize the energy of the binding pose of generated molecules, and then use the Vina scoring function to score the energy-minimized binding pose to get Vina\* score.
|
| 486 |
+
|
| 487 |
+
• MM-PBSA. We take the default settings of parameters (i.e., solvation mode: GB-2[62], protein forcefield: amber03[63], ligand charge method: bcc[64], dielectric constant: 4.0) and workflow (i.e., force field building, structure optimization by energy minimization, MM/GB(PB)SA calculation) of [24] to calculate MM-PBSA score. Since the crystal structure indicates the preferred binding pose against a specific target, we filtered the generated molecules by 3D similarity to the molecule in crystal structure and take the molecules whose 3D similarity score is over 0.4 as effective molecules, and we only calculate the MM-PBSA score for the effective molecules. In Table 6 we show MM-PBSA S.R. (success rate), which calculates the proportion of effective MM-PBSA of the generated molecules. For MM-PBSA B.T. and MM-PBSA Rank we have:
|
| 488 |
+
|
| 489 |
+
$$
|
| 490 |
+
\begin{array} { r l } & { \displaystyle \mathbf { M M } \mathbf { \mathrm { \mathrm { - } P B S A } } \mathbf { \mathrm { B . T } } _ { - } = \frac { 1 } { n _ { p } } \displaystyle \sum _ { i = 1 } ^ { n _ { p } } \frac { \left| \left\{ g \in \mathcal { G } \big | \mathbf { M M } \mathbf { \mathrm { - } P B S A } ( g ) < \mathbf { M M } \mathbf { \mathrm { - } P B S A } ( \overline { { m } } _ { i } ) \right\} \right| } { | \mathcal { G } | } , } \\ & { \displaystyle \mathbf { M M } \mathbf { \mathrm { \mathrm { - } P B S A } } \mathbf { \mathrm { R a n k } } = \frac { 1 } { n _ { p } } \displaystyle \sum _ { i = 1 } ^ { n _ { p } } \mathbf { \mathrm { r a n k } } _ { i } , } \end{array}
|
| 491 |
+
$$
|
| 492 |
+
|
| 493 |
+
where $n _ { p }$ is the number of proteins in the test set, $\mathcal { G }$ represents the generated molecular set, $\overline { { m } } _ { i }$ represents the molecular in the crystal structure of the $i$ -th protein and $\mathrm { r a n k } _ { i }$ represents the ranking index of the current model among all of the compared models under the $i$ -th protein which is ranked by MM-PBSA.
|
| 494 |
+
|
| 495 |
+
• Metric for ablation studies. We use 3D similarity between the generated molecules and the ground truth as the metric in ablation studies since it reflects the generative ability based on the pocket structure and there is a strong correlation between 3D similarity and binding affinity according to Table 1.
|
| 496 |
+
|
| 497 |
+
Table 4: Settings for VD-Gen.
|
| 498 |
+
|
| 499 |
+
<table><tr><td colspan="2">Pretrain</td></tr><tr><td>VP encoder layers Peak learning rate</td><td>12 1e-4</td></tr><tr><td>Batch size</td><td>128</td></tr><tr><td>Max training steps</td><td>1M</td></tr><tr><td>Warmup steps Attention heads</td><td>10K</td></tr><tr><td>FFN dropout</td><td>64</td></tr><tr><td>Attention dropout</td><td>0.1</td></tr><tr><td>Embedding dropout</td><td>0.1 0.1</td></tr><tr><td>Weight decay</td><td>1e-4</td></tr><tr><td>Embedding dim</td><td>512</td></tr><tr><td>FFN hidden dim Gaussian kernel channels</td><td>2048</td></tr><tr><td>Activation function</td><td>128</td></tr><tr><td>Learning rate decay</td><td>GELU Linear</td></tr><tr><td>Adams ∈</td><td>1e-6</td></tr><tr><td>Adams(βi, β2)</td><td>(0.9,0.99)</td></tr><tr><td>Gradient clip norm</td><td>1.0</td></tr><tr><td>Particle type prediction weight</td><td>1.0</td></tr><tr><td>Loss Weight forLvD of Equilibrium</td><td>1.0</td></tr><tr><td>Loss weight for LvD of Refinement</td><td>1.0</td></tr><tr><td>Loss weight for LFilter</td><td>1.0</td></tr><tr><td>Loss weight for LMerge Loss weight for Latom_num</td><td>5.0</td></tr><tr><td>Loss weight for Confidence</td><td>1.0</td></tr><tr><td>R,max round of iterative movement of Equilibrium and Refinement</td><td>1.0</td></tr><tr><td>numbers of virtual particles</td><td>4</td></tr><tr><td>T,the clip value for coordinate loss</td><td>8 ~ 9 times of the number of real atoms</td></tr><tr><td>δ,the threshold for coordinate regularization</td><td>2</td></tr><tr><td>Finetune</td><td>1</td></tr><tr><td>Batch size</td><td></td></tr><tr><td>Max training steps</td><td>64</td></tr><tr><td>R1,max round of iterative movement of Equilibrium</td><td>100K</td></tr><tr><td></td><td>4</td></tr><tr><td>R2,max round of iterative movement of Refinement</td><td>4</td></tr><tr><td>numbers of virtual particles Inference</td><td>16 ~18 times of the number of real atoms</td></tr><tr><td colspan="2">R1,max round of iterativemovement of Equilibrium 4</td></tr><tr><td>R2,max round of iterative movement of Refinement</td><td>16</td></tr><tr><td>n,numbers of VPs</td><td>512</td></tr><tr><td></td><td></td></tr></table>
|
| 500 |
+
|
| 501 |
+
# B.3 MORE RESULTS
|
| 502 |
+
|
| 503 |
+
In Table 5, we report more percentile results for Vina, Vina\*. In Table 6, we report more percentile MM-PBSA results and MM-PBSA S.R. scores. The MM-PBSA S.R. scores in many baselines are very low. Thus, there are not enough effective MM-PBSA results to calculate percentile results in some baselines. Therefore, in each pocket, we replace the failed MM-PBSA result with the worst one generated by that baseline. And we calculated the percentile results after the replacement.
|
| 504 |
+
|
| 505 |
+
Table 5: More results on Vina and Vina\*.
|
| 506 |
+
|
| 507 |
+
<table><tr><td>Model</td><td colspan="2">5-th</td><td colspan="2">10-th</td><td colspan="2">25-th</td><td colspan="2">50-th</td></tr><tr><td></td><td>Vina(↓)</td><td>Vina*(↓)</td><td>Vina(↓)</td><td>Vina*(↓)</td><td>Vina(↓)</td><td>Vina*(↓)</td><td>Vina(↓)</td><td>Vina*(↓)</td></tr><tr><td>LiGAN[17]</td><td>-6.724</td><td>-5.372</td><td>-6.324</td><td>-4.922</td><td>-5.740</td><td>-4.215</td><td>-5.065</td><td>-3.49</td></tr><tr><td>3DSBDD[18]</td><td>-8.662</td><td>-7.227</td><td>-8.296</td><td>-6.664</td><td>-7.557</td><td>-5.633</td><td>-6.474</td><td>-4.078</td></tr><tr><td>GraphBP[19]</td><td>-8.710</td><td>-3.689</td><td>-7.832</td><td>-2.774</td><td>-6.765</td><td>-1.169</td><td>-5.625</td><td>-1.2</td></tr><tr><td>Pocket2Mol[20]</td><td>-8.332</td><td>-6.525</td><td>-8.015</td><td>-5.399</td><td>-7.467</td><td>-3.513</td><td>-6.837</td><td>-1.808</td></tr><tr><td>VD-Gen</td><td>-9.047</td><td>-7.444</td><td>-8.652</td><td>-6.848</td><td>-7.958</td><td>-5.825</td><td>-7.146</td><td>-4.621</td></tr></table>
|
| 508 |
+
|
| 509 |
+
Table 6: More MM-PBSA results.
|
| 510 |
+
B.4 COMPARED WITH IMAGE GENERATION AND SOME EARLY ATTEMPTS
|
| 511 |
+
|
| 512 |
+
<table><tr><td>Model</td><td>5-th MM-PBSA(↓)</td><td>10-th MM-PBSA(↓)</td><td>25-th MM-PBSA(↓)</td><td>50-th MM-PBSA (↓)</td><td>MM-PBSA- S.R.(%↑)</td></tr><tr><td>LiGAN[17]</td><td>-17.865</td><td>-13.374</td><td>-8.775</td><td>-7.418</td><td>11.9</td></tr><tr><td>3DSBDD[18]</td><td>-30.221</td><td>-23.623</td><td>-13.544</td><td>-7.739</td><td>12.9</td></tr><tr><td>GraphBP[19]</td><td>-5.130</td><td>-4.894</td><td>-4.894</td><td>-4.894</td><td>0.2</td></tr><tr><td>Pocket2Mol[20]</td><td>-7.823</td><td>-5.945</td><td>-5.398</td><td>-5.398</td><td>1.8</td></tr><tr><td>VD-Gen</td><td>-51.258</td><td>-47.247</td><td>-39.984</td><td>-21.140</td><td>42.7</td></tr></table>
|
| 513 |
+
|
| 514 |
+

|
| 515 |
+
Figure 6: Comparison for different training frameworks. "1:1 VD" is our early attempt, which is directly based on Virtual Dynamics, with 1:1 particle-atom assignment, and without the 4 stages in VD-Gen. The result indicates the effectiveness of the proposed VD-Gen framework.
|
| 516 |
+
|
| 517 |
+
During inference, VD iteratively moves particles to more precious positions from random initialized positions. A similar idea of "coarse-to-fine" generation is widely used in image generative models, and images could be iteratively refined from noises.
|
| 518 |
+
|
| 519 |
+
From this view, VD looks similar to the "coarse-to-fine" image generation. However, the training of VD is more challenging and very different from "coarse-to-fine" image generation.
|
| 520 |
+
|
| 521 |
+
• In image generation, the training target for each pixel is straightforward to assign, since input pixels’ positions are the same as the ground-truth pixels’ position, i.e. there is a 1-to-1 mapping between input and ground-truth. For example, in an image with $3 2 \mathrm { x } 3 2 $ pixels, for an input pixel located at position $i , j$ , we can directly use the ground-truth pixel located at position $i , j$ as its training target. With the 1-to-1 assignment, the training of image generation is straightforward. • However, in the 3D molecular generation, the 1-to-1 assignment cannot simply be used, as the randomly initialized 3D positions of input particles are far different from the ground-truth atoms’ positions, so it is hard to have 1-to-1 mapping. Besides, the number of ground-truth atoms is unknown, which further increases the difficulty of 3D molecular generation.
|
| 522 |
+
|
| 523 |
+
Table 7: Inference Efficiency.
|
| 524 |
+
|
| 525 |
+
<table><tr><td>Model</td><td>3DSBDD</td><td>GraphBP</td><td>Pocket2Mol</td><td>VD-Gen</td></tr><tr><td>Time(s)(↓)</td><td>14.153</td><td>1.660</td><td>3.476</td><td>3.678</td></tr></table>
|
| 526 |
+
|
| 527 |
+
• In our early attempts, we also tried some 1-to-1 assignment methods (assuming the ground truth of the number of atoms is given). We first tried the random assignment, and found model training is hard to converge. We then optimized it by considering the total moving distance of all input particles in the target assignment. We call this method "1:1 VD", details are in the following paragraph. In particular, we assign each particle a unique target atom, by sub-optimal assignment (optimal assignment is NP-hard) to minimize the total moving distance. It is much better than random assignment, but the performance is still not good, and we think the reason is due to the large difficulty of the training task.
|
| 528 |
+
|
| 529 |
+
• To further reduce the difficulty of the training task, we propose to use the many-to-1 assignment. That is, we first use many random-scattered particles to the pocket cavity, then for each particle, assign its nearest ground-truth atom as the training target. With this solution, the learning of movement is much easier, since particles only consider their nearest atoms. Besides, the unknown atom number is not a problem.
|
| 530 |
+
|
| 531 |
+
• Besides, VD-Gen is not just VD. Simply using VD, we can only get a 3D density-like shape (formed by the positions of particles) of a 3D molecule. We may use some rule-based solutions, like clustering by distances, to extract 3D molecules from the shape. However, rule-based solutions are not end-to-end and could fail in various scenarios. To address this, we further propose VD-Gen, a more reliable framework with additional Extraction, Refinement and Confidence stages.
|
| 532 |
+
|
| 533 |
+
1:1 VD In our early attempt, we tried a simple solution: use the same number of VPs as real atoms, and randomly scatter them; then, make an assignment so that each atom has a paired VP, and each VP has a paired atom. The optimal assignment with minimal moving distance is NP-hard, and we use a greedy algorithm to find a sub-optimal assignment. With the 1-to-1 assignment, the Extraction stage is not needed, since the number of VPs is the same as real atoms. We called this method "1:1 VD". For a fair comparison, pretraining is also used in "1:1 VD". We conduct the experiment to compare VD-Gen with "1:1 VD", the results are shown in Fig. 6. From the result, we find that VD-Gen largely outperforms "1:1 VD". Although its simplicity, the learning of "1:1 VD" is challenging, due to the ambiguous target assignment which violates the least action principle. As for VD-Gen, although it looks complicated with multiple stages, these stages are necessary for generating accurate 3D molecules end-to-end.
|
| 534 |
+
|
| 535 |
+
# B.5 INFERENCE EFFICIENCY
|
| 536 |
+
|
| 537 |
+
Experiment results have demonstrated the effectiveness of the proposed ${ \tt V D - G e n }$ , and we also check its efficiency here. In particular, we benchmark the inference speed of generating one molecule for 3DSDBB, GraphBP, Pocket2Mol, and our VD-Gen. The results are summarized the Table 7. 3DSBDD is the slowest one, due to the inefficient MCMC sampling. Although GraphBP is the fastest one, its generated molecules are the worst. VD-Gen and Pocket2Mol are similar in efficiency. But VD-Gen significantly outperforms Pocket2Mol in effectiveness. Due to the large number of VPs and several movement rounds, it is expected that VD-Gen is not the fastest one. We leave the efficiency improvement to future work.
|
| 538 |
+
|
| 539 |
+
# B.6 ILLUSTRATION OF VPS’ MOVEMENT
|
| 540 |
+
|
| 541 |
+
We show an example of VPs’ spatial position during the inference of VD-Gen in Fig 7. In the initial stage, the coordinates of VPs are randomly initialized. In Equilibrium stage, with the increase of movement rounds $\mathrm { { . 1 \sim 4 } }$ , VPs gradually gather together. Then in Extraction stage, after clustering, fewer VPs are extracted from gathered VPs. Then in Refinement stage, the extracted VPs continue the iterative movement, toward positions with better pLDDT scores.
|
| 542 |
+
|
| 543 |
+

|
| 544 |
+
Figure 7: An example to show how the VPs moves at each iteration in Equilibrium and Refinement, r indicates the moving iterations and pLDDT can reflect the change of coordinates.
|
| 545 |
+
|
| 546 |
+
Table 8: Training on CrossDocked Dataset.
|
| 547 |
+
|
| 548 |
+
<table><tr><td>Model</td><td>LiGAN</td><td>3DSBDD</td><td>GraphBP</td><td>Pocket2Mol</td><td>VD-Gen</td></tr><tr><td>3D Similarity(↑)</td><td>0.356</td><td>0.365</td><td>0.333</td><td>0.352</td><td>0.39</td></tr></table>
|
| 549 |
+
|
| 550 |
+
# B.7 TRAINING ON THE CROSSDOCKED DATASET
|
| 551 |
+
|
| 552 |
+
Since the baselines use the cross-docked dataset as training data, to analyze our model effect without pretrain, we conduct experiments on the cross-docked dataset. Results are shown in Table 8. We can see VD-Gen achieves 3D similarity with 0.39, outperforming other baselines. Besides, compared to VD-Gen with particle encoder pertaining in Table 2, the performance of using the cross-docked dataset is worse (0.39 v.s. 0.402). This result also indicates that pretraining is better than data augmentation in the cross-docked dataset.
|
| 553 |
+
|
| 554 |
+
# B.8 MOLECULAR OPTIMIZATION TASK
|
| 555 |
+
|
| 556 |
+

|
| 557 |
+
Figure 8: Extending VD-Gen to molecular optimization.
|
| 558 |
+
|
| 559 |
+
Difference in training molecular optimization models To train the molecular optimization model, we make the following changes.
|
| 560 |
+
|
| 561 |
+
• The remove ratio in pretraining is much smaller, only $2 5 \%$ to $40 \%$ are removed.
|
| 562 |
+
• Rather than removing the whole molecule, during finetuning, only $2 5 \%$ to $40 \%$ of atoms are removed, like the pretraining.
|
| 563 |
+
• During training, the number of VPs is also much smaller, only 8 times of the real atoms.
|
| 564 |
+
• The VPs are not scattered in the whole pocket cavity, but scattered around the removed atoms.
|
| 565 |
+
|
| 566 |
+
Experiment We compare our model with a traditional molecular fragments optimization model DeepFrag [65]. DeepFrag can replace molecular fragments based on SMILES, which is a 1D model without pocket information. The results are shown in Table 9 and Table 10. From them, it is clear that VD-Gen can outperform the baseline in molecular optimization.
|
| 567 |
+
|
| 568 |
+
Table 9: Full percentile results on Vina and Vina\*, in molecular optimization tasks.
|
| 569 |
+
|
| 570 |
+
<table><tr><td>Model</td><td colspan="2">5-th</td><td colspan="2">10-th</td><td colspan="2">25-th</td><td colspan="2">50-th</td></tr><tr><td></td><td>Vina(↓)</td><td>Vina*(↓)</td><td>Vina(↓)</td><td>Vina*(↓)</td><td>Vina(↓)</td><td>Vina*(↓)</td><td>Vina(↓)</td><td>Vina*(↓)</td></tr><tr><td>DeepFrag[65]</td><td>-8.357</td><td>1</td><td>-8.132</td><td>-</td><td>-7.775</td><td>-</td><td>-7.372</td><td>1</td></tr><tr><td>VD-Gen</td><td>-9.040</td><td>-8.30</td><td>-8.775</td><td>-8.020</td><td>-8.333</td><td>-7.507</td><td>-7.880</td><td>-6.946</td></tr></table>
|
| 571 |
+
|
| 572 |
+
Table 10: Full percentile results on MM-PBSA, in molecular optimization tasks.
|
| 573 |
+
|
| 574 |
+
<table><tr><td>Model</td><td>5-th MM-PBSA(↓)</td><td>10-th MM-PBSA(↓)</td><td>25-th MM-PBSA(↓)</td><td>50-th MM-PBSA (↓)</td><td>MM-PBSA B.T.(↑)</td></tr><tr><td>DeepFrag[65]</td><td>-51.783</td><td>-48.959</td><td>-39.786</td><td>-34.485</td><td>23.9</td></tr><tr><td>VD-Gen</td><td>-53.799</td><td>-52.120</td><td>-46.707</td><td>-41.788</td><td>38.3</td></tr></table>
|
md/dev/tjFaqsSK2I3/tjFaqsSK2I3.md
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# A Unified Sequence Interface for Vision Tasks
|
| 2 |
+
|
| 3 |
+
Ting Chen† Saurabh Saxena† Lala Li† Tsung-Yi Lin∗ David J. Fleet Geoffrey Hinton Google Research, Brain Team {iamtingchen,srbs,lala}@google.com
|
| 4 |
+
|
| 5 |
+
# Abstract
|
| 6 |
+
|
| 7 |
+
While language tasks are naturally expressed in a single, unified, modeling framework, i.e., generating sequences of tokens, this has not been the case in computer vision. As a result, there is a proliferation of distinct architectures and loss functions for different vision tasks. In this work we show that a diverse set of “core” computer vision tasks can also be unified if formulated in terms of a shared pixelto-sequence interface. We focus on four tasks, namely, object detection, instance segmentation, keypoint detection, and image captioning, all with diverse types of outputs, e.g., bounding boxes or dense masks. Despite that, by formulating the output of each task as a sequence of discrete tokens with a unified interface, we show that one can train a neural network with a single model architecture and loss function on all these tasks, with no task-specific customization. To solve a specific task, we use a short prompt as task description, and the sequence output adapts to the prompt so it can produce task-specific output. We show that such a model can achieve competitive performance compared to well-established task-specific models.
|
| 8 |
+
|
| 9 |
+
# 1 Introduction
|
| 10 |
+
|
| 11 |
+
Training a single neural network model capable of performing myriad tasks is a major step towards artificial general intelligence. In recent years, with the rise of big language models [34, 35, 2] using Transformers [41], many different language and related tasks are unified under a single modeling framework, where a language model is trained to predict the solution (in text tokens) given a prompt of a task description (also in text tokens). This is only possible because these tasks (both task description and solution) can be expressed in the same, rich language interface.
|
| 12 |
+
|
| 13 |
+
This can be naturally extended to some vision tasks such as image captioning or visual question answering where the solution is given in natural language, but the majority of “core” computer vision tasks have diverse outputs that are not readily expressed in terms of natural language. The object detection task produces a set of bounding boxes and their corresponding class labels, often associated with scores for ranking. The output for instance segmentation is a set of segmentation masks corresponding to image regions. The output of keypoint detection is a set of keypoints in an image. As such, existing methods [13, 37, 15, 28, 4, 15] have developed specialized architectures and sophisticated loss functions for each of these complex tasks.
|
| 14 |
+
|
| 15 |
+
An ambitious goal, in the pursuit of artificial general intelligence, is a simple interface that allows one to express seemingly disparate vision tasks in a unified framework. This would simplify the design of architectures and loss functions for new tasks. It would enable greater degrees of feature/representation sharing across many different tasks, thereby avoiding the need for a sophisticated output head for each task. It would also facilitate adapting of existing models to new tasks, and potentially unlock new capabilities with zero or few demonstrations.
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
Figure 1: An illustration of the proposed framework. An image and a sequence of task prompt is given, the model produce a sequence of discrete tokens corresponding to the desired output.
|
| 19 |
+
|
| 20 |
+
To this end, we propose an approach to unify four seemingly different vision tasks in a single pixel-to-sequence interface. In effect, this is an extension of Pix2Seq [7] for object detection to a broader set of tasks. As a proof of concept, we focus on four core vision tasks, namely, object detection, instance segmentation, human keypoint detection, and image captioning. We first show how to unify these tasks into a single shared interface, and then train a neural network with a shared architecture and objective function. To solve a specific task, instead of using a specific head for that task, we use a prompt to specify the task, and the sequence output adapts to the prompt so it can produce task-specific output given the task description. This makes multi-task learning more efficient and scalable. We conduct experiments on the challenging COCO dataset, and show that it can simultaneously solve all four tasks well, without specialized architectures or loss functions.
|
| 21 |
+
|
| 22 |
+
# 2 Approach
|
| 23 |
+
|
| 24 |
+
In our approach, we cast computer vision tasks as one of translating pixel inputs (along with some descriptions of the task) into sequences of discrete tokens (see Figure 1). As a proof of concept, we focus on four core vision tasks: object detection, instance segmentation, keypoint detection, and image captioning; but we believe it is relatively straightforward to include many more tasks.
|
| 25 |
+
|
| 26 |
+
# 2.1 A unified interface with tokenization
|
| 27 |
+
|
| 28 |
+
The vision tasks we consider are diverse, and traditionally have been formulated quite differently. Object detection requires the model to produce bounding boxes for all objects without duplication. Instance segmentation requires the model to produce a dense pixel-wise mask for each identified object instance. Human keypoint detection requires the model to generate points corresponding to specific positions of landmarks on body parts for person instances (e.g., head, eyes). Image captioning requires the model to produce a sequence of words corresponding to a natural language description of the image. Given the significant differences in the form of the outputs, customized models with specialized architectures and loss functions are designed for each task.
|
| 29 |
+
|
| 30 |
+
To solve these tasks using a single model, we advocate the transformation/tokenization of task inputs and outputs into a unified interface. In this work, we propose a sequence interface for the purpose, where both task descriptions and outputs are expressed as sequences of discrete tokens:
|
| 31 |
+
|
| 32 |
+

|
| 33 |
+
Figure 2: An illustration of sequence interface for four tasks. The model takes input image, task prompt tokens and produce task output tokens, which can be decoded/detokenized into required task output for visualization.
|
| 34 |
+
|
| 35 |
+
- For object detection, we follow [7] and convert bounding boxes and object descriptions into a sequence of discrete tokens by quantizing the continuous image coordinates. Specifically, an object is represented as a sequence of five discrete tokens, i.e. $[ y _ { \mathrm { m i n } } , x _ { \mathrm { m i n } } , y _ { \mathrm { m a x } } , x _ { \mathrm { m a x } } , c ]$ , and multiple objects are randomly ordered each time a training image is sampled and serialized into a single sequence.
|
| 36 |
+
|
| 37 |
+
- For instance segmentation, instead of per-pixel masks, we predict the polygon [5] corresponding to the instance masks as a sequence of image coordinates conditioned on a given object instance. Again, we quantize the coordinates into discrete tokens. And to turn polygon into a sequence, we randomly select a starting point for the start token each time a training image is sampled. If there are multiple polygons for the same instance, we concatenate sequences of individual polygons with a separator token in between, so that every instance has a single corresponding sequence.
|
| 38 |
+
|
| 39 |
+
- For keypoint prediction, we predict a set of keypoints as a sequence of quantized image coordinates conditioned on a given person instance. Specifically, the sequence of keypoints can be encoded as [ykeypoint 1, xkeypoint 1, ykeypoint 2, $x _ { \mathrm { k e y p o i n t } 2 } , \cdot \cdot \cdot ]$ . One may also use a keypoint label (e.g., nose, let eye, right eye) before each $( y , x )$ -coordinates so their ordering does not need to be fixed but we opt for simplicity given that there are only a small fixed set of 14 person keypoints in the COCO dataset we consider. When certain keypoints are occluded, their coordinate tokens are replaced with a special occlusion token.
|
| 40 |
+
|
| 41 |
+
- For captioning, we directly predict text tokens given a caption is a sequence of discrete tokens.
|
| 42 |
+
|
| 43 |
+
It is worth noting that all four tasks share a single vocabulary. The specific prompts and output sequences are illustrated in Figure 2.
|
| 44 |
+
|
| 45 |
+
# 2.2 Unified architecture and objective function
|
| 46 |
+
|
| 47 |
+
We need a flexible and expressive architecture that can deal with image input and sequence output with complex semantics. Thus we follow [7] and use an encoder-decoder architecture, with an image encoder and sequence decoder. The image encoder perceives pixels and maps them into hidden representations, which can be instantiated as a ConvNet [23, 22, 14], Transformer [41, 11], or their combination [4]. The Transformers-based sequence decoder, widely used in modern language modeling [41, 33, 35], generates one token at a time, conditioned on the preceding tokens and the encoded image representation. This removes the complexity and customization in architectures of modern neural networks for these vision tasks (such as per-task specific heads or necks [15, 19, 30]).
|
| 48 |
+
|
| 49 |
+

|
| 50 |
+
Figure 3: An illustration of our architecture and training objective. Note that Yconstructed seq encapsulates both task prompt tokens and task output tokens. Token weights are set to zero if the target token is within the prompt so the model is only trained to predict desired output tokens.
|
| 51 |
+
|
| 52 |
+
Unlike [7] where the decoder produces the output tokens directly for the single object detection task, here it also conditions on a task prompt so that the model can produce outputs adapted to the task of interest. During training, we concatenate both prompt and desired output into a single sequence, but leverage a token weighting scheme to ensure that the decoder is only trained to predict the desired output but not the prompt tokens. During inference, the prompt is given and fixed, so the decoder only needs to produce the rest of the sequence. Similar to [7], the training objective is to maximize the likelihood of tokens conditioned on an image and preceding tokens, i.e.,
|
| 53 |
+
|
| 54 |
+
$$
|
| 55 |
+
\mathrm { m a x i m i z e } \sum _ { j = 1 } ^ { L } { \pmb w } _ { j } \log P ( { \pmb y } _ { j } | { \pmb x } , { \pmb y } _ { 1 : j - 1 } ) ~ ,
|
| 56 |
+
$$
|
| 57 |
+
|
| 58 |
+
where $_ { \textbf { \em x } }$ is the input image, $\textbf { { y } }$ is a length- $L$ sequence associated with $_ { \textbf { \em x } }$ . As mentioned, the initial part of the sequence $\textbf { { y } }$ is a prompt, for which we set the weight ${ \pmb w } _ { j }$ to zero so it is not included in the loss.
|
| 59 |
+
|
| 60 |
+
# 2.3 Training
|
| 61 |
+
|
| 62 |
+
Each task has its own paired image-sequence training data. There are two ways one can combine tasks and perform the joint training.
|
| 63 |
+
|
| 64 |
+
Data mixing. We can create a dataset with mixed image-sequence pairs drawn from different tasks, balanced to account for different dataset sizes and task difficulties. This construction is extremely simple conceptually, but image augmentations can be difficult to incorporate as they may also require a change to their associated sequences in non-trivial ways.
|
| 65 |
+
|
| 66 |
+
Batch mixing. For each batch, we can sample images with annotations for a single task, perform image augmentations appropriate for this task, and convert the augmented data into image-sequence pairs. The model computes the loss and gradient for each task separately, and we can combine gradients from task-specific batches with an appropriate weighting.
|
| 67 |
+
|
| 68 |
+
# Algorithm 1 Training based on data mixing
|
| 69 |
+
|
| 70 |
+
# Algorithm 2 Training based on batch mixing
|
| 71 |
+
|
| 72 |
+
1: Tokenize annotation into sequences of tokens, 2: Mixing images and sequences from all tasks, 3: Sample a batch, compute the loss, and update the model.
|
| 73 |
+
|
| 74 |
+
1: Sample batches of data from all tasks, 2: Tokenize annotation into sequences of tokens, 3: Compute the loss for each task, aggregate their gradients, and update the model.
|
| 75 |
+
|
| 76 |
+
can be employed in the future to further simplify the pipeline and allow more tasks to be added straightforwardly.
|
| 77 |
+
|
| 78 |
+
Both data mixing and batch mixing require that we specify the portion or weighting for each task. This is an empirical matter, and we use a greedy strategy by adding one task at a time. Every time when we add a task, we adjust the weighting of the new task while keeping the relative weighting among the existing task fixed. We fix the sum of the weights across all tasks to be one.
|
| 79 |
+
|
| 80 |
+
# 2.4 Inference and de-tokenization
|
| 81 |
+
|
| 82 |
+
At inference time, we sample tokens from the model likelihood, given a prompt at the start of the sequence, i.e., $P ( \pmb { y } _ { j } | \pmb { x } , \pmb { y } _ { 1 : j - 1 } )$ . We currently use nucleus sampling [16] but other techniques such as beam search could also be used. Once the tokens are generated, they can be decoded for each task. In the same way that different tasks require specific tokenization schemes to generate token sequences, the decoding (de-tokenization) process is also specific to each task. A more detailed description of inference decoding for each task is given below.
|
| 83 |
+
|
| 84 |
+
- For bounding boxes, following [7], we split predicted sequences into tuples of 5 tokens to get coordinate tokens and a class token, and dequantize coordinate tokens to get the bounding boxes. - For instance segmentation, we dequantize the coordinate tokens corresponding to each polygon, and then convert them into dense masks. The model is not trained with any geometry-specific regularizers per se, and as such the output polygonal masks can be somewhat noisy. To reduce the noise we find it helpful to sample multiple sequences and then average the masks, followed by a simple threshold to obtain a single binary mask. - For keypoint detection, we directly dequantize the image coordinate tokens of the keypoints. - For captioning, we directly map the predicted discrete tokens into text.
|
| 85 |
+
|
| 86 |
+
# 3 Experiments
|
| 87 |
+
|
| 88 |
+
# 3.1 Experimental settings and implementation details
|
| 89 |
+
|
| 90 |
+
We evaluate the proposed method on the widely used MS-COCO 2017 dataset [26], containing $1 1 8 \mathrm { k }$ training images and $5 \mathrm { k }$ validation images, spanning the four tasks we consider. An image in the dataset typically has annotations for object bounding boxes, segmentation masks for object instances, keypoint for person instances, and a few captions. Following [7], we use a Vision Transformer (ViT-B) encoder [11, 41], and a Transformer autoregressive decoder [41]. This model has a total of 132M parameters. To initialize the model, we use a pretrained checkpoint from [7] trained on the object detection task with the Objects365 dataset [39]; this is useful as COCO is relatively small and our model has less task-specific prior. For training on COCO, we use a batch size of 128 images, a learning rate of $1 e ^ { - 4 }$ , and we train the model for 100 epochs. We use a single vocabulary of 35K, with 32K text tokens, 1K coordinate quantization bins, and a few other class labels. We use a maximum sequence length of 512. Our backbone model is pretrained with $6 4 0 \times 6 4 0$ image size, and is fine-tuned in $6 4 0 \times 6 4 0$ or $1 0 2 4 \times 1 0 2 4$ resolutions.
|
| 91 |
+
|
| 92 |
+
Object detection. We follow [7] and use sequence augmentation during training, and use class token probability at inference time for scoring. We also use scale jittering as in [7] (scaling images randomly without changing aspect ratio, crop a fixed size region randomly, and then pad to the maximum size).
|
| 93 |
+
|
| 94 |
+
Instance segmentation. We set the maximum points of polygons to 128. We find that asking the model to generate multiple samples during the inference time and average the generated masks to be beneficial. More specifically, when multiple samples are independently drawn, we convert each of them into a semantic mask for the prompted object. We then average the masks by setting a $( 5 0 \% )$ threshold, and pixels with more than $50 \%$ times of being on will be selected for that instance. We find that 8 samples are sufficient to provide good performance ( ${ \sim } 6$ AP better than using a single sample), and beyond 12 samples we do not see performance boost. Additionally, during inference, we also evaluate on the cropped regions of the image containing the prompted object instance, by replacing the original input image with a new image only containing the cropped region. With smaller image size of $6 4 0 \times 6 4 0$ , this yields $1 . 3 \mathrm { \ A P }$ improvement, but with larger image size of $1 0 2 4 \times 1 0 2 4$ , this does not seem to help much.
|
| 95 |
+
|
| 96 |
+
Keypoint detection. We train and evaluate on cropped regions of the image containing person instances (following the common practice in the community). During training, these regions are provided by ground-truth annotations, and during inference these regions are provided by the object detection model. We choose this region to be twice the size of the provided bounding box. We find that this works better than training with a larger crop size or cropping to the exact bounding box. Using our optimal crop we get ${ \sim } 9$ AP improvement over using an extremely large crop ( ${ \sim } 2 0$ times the box size which can be considered a close approximation to using the entire image). We also use a special token to represent invisible token coordinates in the quantized sequence. At training time we use a small loss weight of 0.1 for these tokens. While using a larger weight doesn’t affect AP much (lower by 1 at weight 1.0) using a weight of 0.0 does much worse (12 AP lower). At inference time invisible tokens are replaced with the model’s best guess of the keypoints’ coordinates.
|
| 97 |
+
|
| 98 |
+
Four-tasks joint training. We use a mixed weighting of 0.1782, 0.7128, 0.099, 0.01 for object detection, instance segmentation, image captioning, and keypoint detection respectively. This set of weight is searched greedily by adding one task at a time (while keeping the weighting ratio of existing tasks unchanged). Ablations on task weighting are shown in the quantitative results below.
|
| 99 |
+
|
| 100 |
+
Baselines. We compare with a few well-known task-specific baselines. For object detection we compare with a strong 2-stage detector, Faster R-CNN [37], and a more recent Transformer-based detector, DETR [4]. Both Faster R-CNN and DETR use task-specific priors in their design, such as non-maximum suppression in Faster R-CNN and bipartite graph matching with generalized intersection-over-union in DETR. Due to their customized architectures and loss functions, extending them to a wider spectrum of tasks is non-trivial and may require a new model design. Mask RCNN [15] advocates a design to extend Faster R-CNN to incorporate segmentation masks and keypoints. While Mask R-CNN is able to perform three out of our four tasks, it still requires the same set of task-based customizations as in Faster R-CNN. We also consider an improved version of Mask R-CNN with non-local architectures [43] which incorporates an attention mechanism, similar to Transformers. The above methods cannot do image captioning, so we train a Transformer-based caption model [40, 32] which is specialized for the task. This model is similar to the proposed method trained for caption single task but it is using self-supervised pretrained visual encoder [6] with a high dropout rate.
|
| 101 |
+
|
| 102 |
+
# 3.2 Quantitative results
|
| 103 |
+
|
| 104 |
+
Table 1: COCO results for object detection, instance segmentation and keypoint detection are expressed in terms of AP. For Image Captioning we report BLEU score. Single task results for instance segmentation and keypoint detection are based on detected bounding boxes from single task detection model. - indicates the model is not able to solve the task without modifications.
|
| 105 |
+
|
| 106 |
+
<table><tr><td></td><td> Object det.</td><td>Instance seg.</td><td>Keypoint det.</td><td>Captioning</td></tr><tr><td>Faster R-CNN[37]</td><td>42.0</td><td></td><td></td><td></td></tr><tr><td>Faster R-CNN+ [37]</td><td>44.0</td><td></td><td></td><td></td></tr><tr><td>DETR[4]</td><td>44.9</td><td></td><td></td><td></td></tr><tr><td>Mask R-CNN[15]</td><td>39.8</td><td>37.1</td><td>63.1</td><td></td></tr><tr><td>Mask R-CNN (non-local) [43]</td><td>45.0</td><td>40.3</td><td>66.5</td><td>=</td></tr><tr><td>Transformer-based captioner [41,32]</td><td>1</td><td>1</td><td>-</td><td>34.3</td></tr><tr><td>Pix2Seq v2 single task (640×640)</td><td>43.8</td><td>37.3</td><td>68.0</td><td>33.9</td></tr><tr><td>Pix2Seq v2 single task (1024×1024)</td><td>45.6</td><td>38.7</td><td>67.4</td><td>34.0</td></tr><tr><td>Pix2Seq v2 multi-tasks (640×640)</td><td>44.2</td><td>36.9</td><td>65.0</td><td>34.3</td></tr><tr><td>Pix2Seq v2 multi-tasks (1024×1024)</td><td>46.5</td><td>38.2</td><td>64.8</td><td>34.9</td></tr></table>
|
| 107 |
+
|
| 108 |
+
Our main results are summarized in Table 1, where we report baselines and two variants of our model: (1) single task models where the model is trained on a single task (still with the same architecture and objective function), so each task has its own network weights; and (2) a multi-task model, where a single set of network weights is used for all four tasks. We can see that despite without task-specific priors in architecture and loss function, our model can still achieve competitive results for each individual task compared to strong specialized baselines (even with a smaller image size). When we train a single model on all tasks, our model is able to address these tasks relatively well, despite the model size being kept the same. We also observe that, with larger image sizes, the performances are generally improved. One exception is keypoint detection, which already uses a cropped region of interest for detecting key points, thus scaling up the image size is not necessarily helpful and can lead to overfitting in case of limited labeled data.
|
| 109 |
+
|
| 110 |
+

|
| 111 |
+
Figure 4: Performance with different task weighting when a new task is added into an existing task mixes.
|
| 112 |
+
|
| 113 |
+
Figure 4 shows how we select appropriate loss weighting for each task using a greedy strategy. More specifically, we first search the weight ratio between object detection and instance segmentation and results are shown in Figure 4a. We observe that for a relatively wide range of weighting ratios, the performance of both tasks are near their peak, so we simply choose the 2:8 weighting ratio for these two tasks. After that, we add image captioning task, and the performances under different weighting of the captioning task can be found in Figure 4b, where we find that the 9:1 weighting ratio for existing tasks and image captioning tasks to be appropriate. Finally, adding the keypoint detection task, in Figure 4c we find its weight can be set relatively small and we choose to use 0.01.
|
| 114 |
+
|
| 115 |
+
# 3.3 Qualitative results
|
| 116 |
+
|
| 117 |
+
To demonstrate the capability and performance of our model in a more visual and intuitive way, we show the outputs from our multi-task model on selected images from the COCO validation set, for each of the four tasks, i.e., object detection, instance segmentation, keypoint detection, and image captioning. Figure 5 shows results for the object detection task. The model successfully detects objects of different sizes in cluttered scenes with significant occlusion. Empirical results on instance segmentation and keypoint detection are shown in Figures 6 and 7. For both tasks, the multi-task model produces well localized and accurate predictions. We also demonstrate some captions generated by the model in Table 2. With these results, we note that our model has not been pre-trained using large-scale image-text datasets, which is expected to significantly improve the captioning performance of the model.
|
| 118 |
+
|
| 119 |
+
# 4 Related work
|
| 120 |
+
|
| 121 |
+
Decoding visual concepts: Image understanding involves extracting visual concepts from images. The formats of these concepts vary according to the given task. Image captioning uses a sequence of words to describe an image [9]. Object detection, on the other hand, represents objects with labels and bounding boxes. Depending on the granularity of localization, visual concepts can be expressed as boxes, pixel segmentation, or keypoints [26]. Decoding localized visual concepts often requires tailored methods. For example, image segmentation uses per-pixel classification. Object detection uses sliding window with non-maximum suppression to detect boxes. Person keypoint detection uses part models to assemble detected parts into whole body [3].
|
| 122 |
+
|
| 123 |
+
Recently, DETR [4] is proposed as an end-to-end object detection approach based on a Transformer decoding scheme (removing complexity on bounding box proposal and non-maximum suppression). MaskFormer [10] further shows that object detection and segmentation can share the same decoding scheme. Pix2seq [7] demonstrates that boxes and labels can be treated as a sequence of discrete tokens, thereby sharing the same training and decoding interface as language models [33, 35]. In our work, we push the envelope further in the unification of language and different visual localization tasks to share the same interface, architecture and training objective.
|
| 124 |
+
|
| 125 |
+

|
| 126 |
+
Figure 5: Visualization of the object detection results, with predicted bounding boxes on the input images.
|
| 127 |
+
|
| 128 |
+
Generalist vision models: Learning a generalist model capable of performing multiple tasks is widely assumed to be a path toward general intelligence. In visual recognition, multi-task learning has shown great success by sharing a backbone model, followed by multiple independent heads [15, 19, 30]. Models with a shared backbone can learn general features which are transferable across tasks when scaling up with training tasks, model capacity and data [20, 24, 12]. Nevertheless, often the task specific backbone models are designed carefully, particularly for tasks that require accurate localization [38, 27].
|
| 129 |
+
|
| 130 |
+
With the invention of Transformers [41], recently being adopted for image classification [11], the research community has seized on the opportunity to unify the backbone design for vision tasks [29, 8, 25]. Perceivers [18, 17] and OFA [42] demonstrate an architecture for multi-task and multimodal across vision and language. Notably, OFA designs a unified sequence-to-sequence decoding architecture for both language and object detection tasks. Flamingo [1] and related methods also focus on an universal API that produces a natural language output for a variety of tasks given image input. This line of work shares a common motivation to our work in this paper, however they focus on higher level tasks for which natural language is inherently the desired output. In this paper we demonstrate that one can express a variety of “core” computer vision tasks in a universal interface, and the learned model exhibits strong grounding capability of the tokens they produce to actual visual concepts. Concurrently to our work, Gato [36] unifies a series of vision and control tasks into a single sequential prediction problem, and UViM [21] and Unified-IO [31] propose using learned discrete codes for unifying a set of vision tasks.
|
| 131 |
+
|
| 132 |
+

|
| 133 |
+
Figure 6: Visualization of the instance segmentation results, with predicted semantic masks overlaid on the input images.
|
| 134 |
+
|
| 135 |
+

|
| 136 |
+
Figure 7: Visualization of the Human keypoint detection results, with predicted stick figures on the input images.
|
| 137 |
+
|
| 138 |
+
Table 2: Image captioning results.
|
| 139 |
+
|
| 140 |
+
<table><tr><td></td><td>A group of teddy bears sitting next to each other. Three teddy bears sitting on a blanket. A group of teddy bears sitting on a blanket with bowls of food.</td></tr><tr><td></td><td>A herd of elephants standing inside of a fenced in area. A group of elephants standing in a fenced area. A herd of elephants standing behind a fence.</td></tr><tr><td></td><td>A man riding a skateboard over a block of cement. A man doing a trick on a skateboard in the street. A man flying through the air while riding a skateboard.</td></tr><tr><td></td><td>A row of motorcycles parked on a grass covered field. A motorcycle with a helmet on the side of it. A motorcycle parked in a grassy area with other motorcycles.</td></tr></table>
|
| 141 |
+
|
| 142 |
+
# 5 Conclusion
|
| 143 |
+
|
| 144 |
+
In this work, we explore a unified sequence interface for tackling a diverse set of “core” vision tasks, where both the task description (prompt) and task output are expressed as discrete sequences of tokens. This is a significant departure from conventional norms of multi-task vision models in that both architecture and loss functions are shared among the tasks. We show that such a model can achieve competitive performance compared to well-established task-specific models.
|
| 145 |
+
|
| 146 |
+
Our work is not without limitations. Due to the significant departure from conventional approaches, we believe both architectures and other training techniques can be further improved to challenge the state-of-the-art of specialized systems. We also believe our model can significantly benefit from scaling up, both in pretraining on larger datasets (e.g., image-text pairs) and/or using larger model sizes. Another limitation is the inference speed can be potentially slower (for longer sequences particularly) compared to the specialized systems as our approach is based on autoregressive modeling. There are a few ways to improve the efficiency, including using non-autoregressive sequence modeling (which we leave as future work). In this work, we exploit parallel querying for speeding up our model inference. For example, predicting multi-person poses can be done independently by prompting the model with independent bounding boxes (detected by the model itself or pre-given), so the only sequential prediction is limited to a single person with a few keypoints. The same strategy can be applied to instance segmentation as well.
|
| 147 |
+
|
| 148 |
+
While the optimal implementation of a unified interface still requires more research and the sequence interface explored in this work is only one potential implementation, we believe the interface of how different tasks are formulated would play an increasing important role in general-purpose intelligent systems going forward.
|
| 149 |
+
|
| 150 |
+
# Acknowledgements
|
| 151 |
+
|
| 152 |
+
We specially thank Wei Li for their helpful feedback on the initial draft. We also thank Xiaohua Zhai, Alexander Kolesnikov, Lucas Beyer, Neil Houlsby, Simon Kornblith and Mohammad Norouzi for some early discussions.
|
| 153 |
+
|
| 154 |
+
# References
|
| 155 |
+
|
| 156 |
+
[1] Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katie Millican, Malcolm Reynolds, Roman Ring, Eliza Rutherford, Serkan Cabi, Tengda Han, Zhitao Gong, Sina Samangooei, Marianne Monteiro, Jacob Menick, Sebastian Borgeaud, Andrew Brock, Aida Nematzadeh, Sahand Sharifzadeh, Mikolaj Binkowski, Ricardo Barreira, Oriol Vinyals, Andrew Zisserman, and Karen Simonyan. Flamingo: a visual language model for few-shot learning. arXiv preprint arXiv:2204.14198, 2022.
|
| 157 |
+
[2] 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.
|
| 158 |
+
[3] Zhe Cao, Tomas Simon, Shih-En Wei, and Yaser Sheikh. Realtime multi-person 2d pose estimation using part affinity fields. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 7291–7299, 2017.
|
| 159 |
+
[4] 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, pages 213–229. Springer, 2020.
|
| 160 |
+
[5] Lluis Castrejon, Kaustav Kundu, Raquel Urtasun, and Sanja Fidler. Annotating object instances with a polygon-rnn. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 5230–5238, 2017.
|
| 161 |
+
[6] Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. In International Conference on Machine Learning, pages 1597–1607. PMLR, 2020.
|
| 162 |
+
[7] Ting Chen, Saurabh Saxena, Lala Li, David J Fleet, and Geoffrey Hinton. Pix2seq: A language modeling framework for object detection. arXiv preprint arXiv:2109.10852, 2021.
|
| 163 |
+
[8] Wuyang Chen, Xianzhi Du, Fan Yang, Lucas Beyer, Xiaohua Zhai, Tsung-Yi Lin, Huizhong Chen, Jing Li, Xiaodan Song, Zhangyang Wang, et al. A simple single-scale vision transformer for object localization and instance segmentation. arXiv preprint arXiv:2112.09747, 2021.
|
| 164 |
+
[9] 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 preprint arXiv:1504.00325, 2015.
|
| 165 |
+
[10] Bowen Cheng, Alex Schwing, and Alexander Kirillov. Per-pixel classification is not all you need for semantic segmentation. Advances in Neural Information Processing Systems, 34, 2021.
|
| 166 |
+
[11] 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, 2020.
|
| 167 |
+
[12] Golnaz Ghiasi, Barret Zoph, Ekin D Cubuk, Quoc V Le, and Tsung-Yi Lin. Multi-task self-training for learning general representations. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 8856–8865, 2021.
|
| 168 |
+
[13] Ross Girshick. Fast r-cnn. In Proceedings of the IEEE International Conference on Computer Vision, pages 1440–1448, 2015.
|
| 169 |
+
[14] 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.
|
| 170 |
+
[15] Kaiming He, Georgia Gkioxari, Piotr Dollár, and Ross Girshick. Mask r-cnn. In Proceedings of the IEEE International Conference on Computer Vision, pages 2961–2969, 2017.
|
| 171 |
+
[16] Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, and Yejin Choi. The curious case of neural text degeneration. arXiv preprint arXiv:1904.09751, 2019.
|
| 172 |
+
[17] Andrew Jaegle, Sebastian Borgeaud, Jean-Baptiste Alayrac, Carl Doersch, Catalin Ionescu, David Ding, Skanda Koppula, Daniel Zoran, Andrew Brock, Evan Shelhamer, et al. Perceiver io: A general architecture for structured inputs & outputs. arXiv preprint arXiv:2107.14795, 2021.
|
| 173 |
+
[18] 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, pages 4651–4664. PMLR, 2021.
|
| 174 |
+
[19] Iasonas Kokkinos. Ubernet: Training a universal convolutional neural network for low-, mid-, and highlevel vision using diverse datasets and limited memory. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 6129–6138, 2017.
|
| 175 |
+
[20] Alexander Kolesnikov, Lucas Beyer, Xiaohua Zhai, Joan Puigcerver, Jessica Yung, Sylvain Gelly, and Neil Houlsby. Big transfer (bit): General visual representation learning. In European conference on computer vision, pages 491–507. Springer, 2020.
|
| 176 |
+
[21] Alexander Kolesnikov, André Susano Pinto, Lucas Beyer, Xiaohua Zhai, Jeremiah Harmsen, and Neil Houlsby. Uvim: A unified modeling approach for vision with learned guiding codes. arXiv preprint arXiv:2205.10337, 2022.
|
| 177 |
+
[22] 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.
|
| 178 |
+
[23] Yann LeCun, Bernhard Boser, John S Denker, Donnie Henderson, Richard E Howard, Wayne Hubbard, and Lawrence D Jackel. Backpropagation applied to handwritten zip code recognition. Neural computation, 1 (4):541–551, 1989.
|
| 179 |
+
[24] Yanghao Li, Saining Xie, Xinlei Chen, Piotr Dollar, Kaiming He, and Ross Girshick. Benchmarking detection transfer learning with vision transformers. arXiv preprint arXiv:2111.11429, 2021.
|
| 180 |
+
[25] Yanghao Li, Hanzi Mao, Ross Girshick, and Kaiming He. Exploring plain vision transformer backbones for object detection. arXiv preprint arXiv:2203.16527, 2022.
|
| 181 |
+
[26] Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In European Conference on Computer Vision, pages 740–755. Springer, 2014.
|
| 182 |
+
[27] Tsung-Yi Lin, Piotr Dollár, Ross Girshick, Kaiming He, Bharath Hariharan, and Serge Belongie. Feature pyramid networks for object detection. In Proceedings of the IEEE Conference on Computer Vision and pattern recognition, pages 2117–2125, 2017.
|
| 183 |
+
[28] Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollár. Focal loss for dense object detection. In Proceedings of the IEEE International Conference on Computer Vision, pages 2980–2988, 2017.
|
| 184 |
+
[29] 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 Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 10012–10022, 2021.
|
| 185 |
+
[30] Jiasen Lu, Vedanuj Goswami, Marcus Rohrbach, Devi Parikh, and Stefan Lee. 12-in-1: Multi-task vision and language representation learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10437–10446, 2020.
|
| 186 |
+
[31] Jiasen Lu, Christopher Clark, Rowan Zellers, Roozbeh Mottaghi, and Aniruddha Kembhavi. Unified-io: A unified model for vision, language, and multi-modal tasks. arXiv preprint arXiv:2206.08916, 2022.
|
| 187 |
+
[32] Yingwei Pan, Ting Yao, Yehao Li, and Tao Mei. X-linear attention networks for image captioning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10971– 10980, 2020.
|
| 188 |
+
[33] Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving language understanding by generative pre-training. 2018.
|
| 189 |
+
[34] 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.
|
| 190 |
+
[35] 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.
|
| 191 |
+
[36] Scott Reed, Konrad Zolna, Emilio Parisotto, Sergio Gomez Colmenarejo, Alexander Novikov, Gabriel Barth-Maron, Mai Gimenez, Yury Sulsky, Jackie Kay, Jost Tobias Springenberg, Tom Eccles, Jake Bruce, Ali Razavi, Ashley Edwards, Nicolas Heess, Yutian Chen, Raia Hadsell, Oriol Vinyals, Mahyar Bordbar, and Nando de Freitas. A generalist agent. arXiv arXiv:2205.06175, 2022.
|
| 192 |
+
[37] Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. Advances in Neural Information Processing Systems, 28:91–99, 2015.
|
| 193 |
+
[38] Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networks for biomedical image segmentation. In International Conference on Medical image computing and computer-assisted intervention, pages 234–241. Springer, 2015.
|
| 194 |
+
[39] Shuai Shao, Zeming Li, Tianyuan Zhang, Chao Peng, Gang Yu, Xiangyu Zhang, Jing Li, and Jian Sun. Objects365: A large-scale, high-quality dataset for object detection. In Proceedings of the IEEE/CVF international conference on computer vision, pages 8430–8439, 2019.
|
| 195 |
+
[40] 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.
|
| 196 |
+
[41] 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, pages 5998–6008, 2017.
|
| 197 |
+
[42] 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-tosequence learning framework. arXiv preprint arXiv:2202.03052, 2022.
|
| 198 |
+
[43] 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, pages 7794–7803, 2018.
|
| 199 |
+
|
| 200 |
+
# Checklist
|
| 201 |
+
|
| 202 |
+
1. For all authors...
|
| 203 |
+
|
| 204 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
|
| 205 |
+
(b) Did you describe the limitations of your work? [Yes] See Conclusion section
|
| 206 |
+
(c) Did you discuss any potential negative societal impacts of your work? [No] Our work at its current form does not increase the risk of negative social impacts of those existing specialized systems.
|
| 207 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 208 |
+
|
| 209 |
+
2. If you are including theoretical results...
|
| 210 |
+
|
| 211 |
+
(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]
|
| 212 |
+
|
| 213 |
+
3. If you ran experiments...
|
| 214 |
+
|
| 215 |
+
(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 will opensource our code at https://github.com/google-research/pix2seq.
|
| 216 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
|
| 217 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] Some of the experiments are expensive to run multiple times, and the standard errors are usually pretty small.
|
| 218 |
+
|
| 219 |
+
(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] It’s trained on 32-128 Cloud TPUs. Depending on architectures, and tasks, generally takes 4-12 hours.
|
| 220 |
+
|
| 221 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 222 |
+
|
| 223 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes]
|
| 224 |
+
(b) Did you mention the license of the assets? [No] It is pretty obvious from the dataset website, and it’s a well known dataset.
|
| 225 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
|
| 226 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
|
| 227 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
|
| 228 |
+
|
| 229 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 230 |
+
|
| 231 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 232 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 233 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
md/dev/vhKaBdOOobB/vhKaBdOOobB.md
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# GhostNetV2: Enhance Cheap Operation with Long-Range Attention
|
| 2 |
+
|
| 3 |
+
Yehui Tang1,2, Kai $\mathbf { H a n } ^ { 2 }$ , Jianyuan $\mathbf { G u o } ^ { 2 , 3 }$ , Chang $\mathbf { X } \mathbf { u } ^ { 3 }$ , Chao $\mathbf { X } \mathbf { u } ^ { 1 }$ , Yunhe Wang2∗
|
| 4 |
+
|
| 5 |
+
1School of Artificial Intelligence, Peking University 2Huawei Noah’s Ark Lab 3School of Computer Science, University of Sydney yhtang@pku.edu.cn, {kai.han, yunhe.wang} $@$ huawei.com
|
| 6 |
+
|
| 7 |
+
# Abstract
|
| 8 |
+
|
| 9 |
+
Light-weight convolutional neural networks (CNNs) are specially designed for applications on mobile devices with faster inference speed. The convolutional operation can only capture local information in a window region, which prevents performance from being further improved. Introducing self-attention into convolution can capture global information well, but it will largely encumber the actual speed. In this paper, we propose a hardware-friendly attention mechanism (dubbed DFC attention) and then present a new GhostNetV2 architecture for mobile applications. The proposed DFC attention is constructed based on fully-connected layers, which can not only execute fast on common hardware but also capture the dependence between long-range pixels. We further revisit the expressiveness bottleneck in previous GhostNet and propose to enhance expanded features produced by cheap operations with DFC attention, so that a GhostNetV2 block can aggregate local and long-range information simultaneously. Extensive experiments demonstrate the superiority of GhostNetV2 over existing architectures. For example, it achieves $7 5 . 3 \%$ top-1 accuracy on ImageNet with 167M FLOPs, significantly suppressing GhostNetV1 $( 7 4 . 5 \% )$ with a similar computational cost. The source code will be available at https://github.com/huawei-noah/Efficient-AI-Backbones/ tree/master/ghostnetv2_pytorch and https://gitee.com/mindspore/ models/tree/master/research/cv/ghostnetv2.
|
| 10 |
+
|
| 11 |
+
# 1 Introduction
|
| 12 |
+
|
| 13 |
+
In computer vision, the architecture of deep neural network plays a vital role for various tasks, such as image classification [19, 10], object detection [27, 26], and video analysis [18]. In the past decade, the network architecture has been evolving rapidly, and a series of milestones including AlexNet [19], GoogleNet [29], ResNet [10] and EfficientNet [32] have been developed. These networks have pushed the performances of a wide range of visual tasks to a high level.
|
| 14 |
+
|
| 15 |
+
To deploy neural networks on edge devices like smartphone and wearable devices, we need to consider not only the performance of a model, but also its efficiency especially the actual inference speed. Matrix multiplications occupy the main part of computational cost and parameters. Developing lightweight models is a promising approach to reduce the inference latency. MobileNet [13] factorizes a standard convolution into depthwise convolution and point-wise convolution, which reduces the computational cost drastically. MobileNetV2 [28] and MobileNetV3 [12] further introduce the inverted residual block and improve the network architecture. ShuffleNet [42] utilizes the shuffle operation to encourage the information exchange between channel groups. GhostNet [8] proposes the cheap operation to reduce feature redundancy in channels. WaveMLP [33] replaces the complex
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
Figure 1: Top-1 accuracy vs.FLOPs on ImageNet Figure 2: Top-1 accuracy vs.latency on ImageNet dataset. dataset.
|
| 19 |
+
|
| 20 |
+
self-attention module with a simple Multi-Layer Perceptron (MLP) to reduce the computational cost.
|
| 21 |
+
These light-weight neural networks have been applied in many mobile applications.
|
| 22 |
+
|
| 23 |
+
Nevertheless, the convolution-based light-weight models are weak in modeling long-range dependency, which limits further performance improvement. Recently, transformer-like models are introduced to computer vision, in which the self-attention module can capture the global information. The typical self-attention module requires quadratic complexity w.r.t. the size of feature’s shape and is not computationally friendly. Moreover, plenty of feature splitting and reshaping operations are required to calculate the attention map. Though their theoretical complexity is negligible, these operations incur more memory usage and longer latency in practice. Thus, utilizing vanilla self-attention in light-weight models is not friendly for mobile deployment. For example, MobileViT with massive self-attention operations is more than $7 \times$ slower than MobileNetV2 on ARM devices [23].
|
| 24 |
+
|
| 25 |
+
In this paper, we propose a new attention mechanism (dubbed DFC attention) to capture the longrange spatial information, while keeping the implementation efficiency of light-weight convolutional neural networks. Only fully connected (FC) layers participate in generating the attention maps for simplicity. Specifically, a FC layer is decomposed into horizontal FC and vertical FC to aggregate pixels in a 2D feature map of CNN. The two FC layers involve pixels in a long range along their respective directions, and stacking them will produce a global receptive field. Moreover, starting from ate-of-the-art GhostNet, we revisit its representation bottleneck and enhance the intermediate features with the DFC attention. Then we construct a new light-weight vision backbone, GhostNetV2. Compared with the existing architectures, it can achieve a better tread-off between accuracy and inference speed (as shown in Figures 1 and 2).
|
| 26 |
+
|
| 27 |
+
# 2 Related Work
|
| 28 |
+
|
| 29 |
+
It is a challenge to design a light-weight neural architecture with fast inference speed and high performance simultaneously [16, 41, 13, 40, 35]. SqueezeNet [16] proposes three strategies to design a compact model, i.e., replacing $3 \times 3$ filters with $1 \times 1$ filers, decreasing the number of input channels to $3 x 3$ filters, and down-sampling late in the network to keep large feature maps. These principles are constructive, especially the usage of $1 \times 1$ convolution. MobileNetV1 [13] replaces almost all the $3 \times 3$ filers with $1 \times 1$ kernel and depth-wise separable convolutions, which dramatically reduces the computational cost. MobileNetV2 [28] further introduces the residual connection to the light-weight model, and constructs an inverted residual structure, where the intermediate layer of a block has more channels than its input and output. To keep representation ability, a part of non-linear functions are removed. MobileNeXt [44] rethinks the necessary of inverted bottleneck, and claims that the classic bottleneck structure can also achieve high performance. Considering the $1 \times 1$ convolution account for a substantial part of computational cost, ShuffleNet [42] replace it with group convolution. The channel shuffle operation to help the information flowing across different groups. By investigating the factors that affect the practical running speed, ShuffleNet V2 [22] proposes a hardware-friendly new block. By leveraging the feature’s redundancy, GhostNet [8] replaces half channels in $1 \times 1$ convolution with cheap operations. Until now, GhostNet has been the SOTA light-weight model with a good trade-off between accuracy and speed.
|
| 30 |
+
|
| 31 |
+
Besides manual design, a series of methods try to search for a light-weight architecture. For example, FBNet [39] designs a hardware-aware searching strategy, which can directly find a good trade-off between accuracy and speed on a specific hardware. Based on the inverted residual bottleneck, MnasNet [31], MobileNetV3 [12] search the architecture parameters,such as model width, model depth, convolutional filter’s size, etc. Though NAS based methods achieve high performance, their success is based on well-designed search spaces and architectural units. Automatic searching and manual design can be combined to find a better architecture.
|
| 32 |
+
|
| 33 |
+
# 3 Preliminary
|
| 34 |
+
|
| 35 |
+
# 3.1 A Brief Review of GhostNet
|
| 36 |
+
|
| 37 |
+
GhostNet [8] is SOTA light-weight model designed for efficient inference on mobile devices. Its main component is the Ghost module, which can replace the original convolution by generating more feature maps from cheap operations. Given input feature $X \in \mathbf { \mathbb { R } } ^ { H \times W \times C }$ with height $H$ , width $W$ and channel’s number $C$ , a typical Ghost module can replace a standard convolution by two steps. Firstly, a $1 \times 1$ convolution is used to generate the intrinsic feature, i.e.,
|
| 38 |
+
|
| 39 |
+
$$
|
| 40 |
+
Y ^ { \prime } = X * F _ { 1 \times 1 } ,
|
| 41 |
+
$$
|
| 42 |
+
|
| 43 |
+
where $^ *$ denotes the convolution operation. $F _ { 1 \times 1 }$ is the point-wise convolution, and $Y ^ { \prime } \in$ $\mathbb { R } ^ { H \times W \times C _ { o u t } ^ { \prime } }$ is the intrinsic features, whose sizes are usually smaller than the original output features, i.e., $C _ { o u t } ^ { \prime } < C _ { o u t }$ . Then cheap operations (e.g., depth-wise convolution) are used to generate more features based on the intrinsic features. The two parts of features are concatenated along the channel dimension, i.e.,
|
| 44 |
+
|
| 45 |
+
$$
|
| 46 |
+
Y = \mathrm { C o n c a t } ( [ Y ^ { \prime } , Y ^ { \prime } * F _ { d p } ] ) ,
|
| 47 |
+
$$
|
| 48 |
+
|
| 49 |
+
where $F _ { d p }$ is the depth-wise convolutional filter, and $Y \in \mathbb { R } ^ { H \times W \times C _ { o u t } }$ is the output feature. Though Ghost module can reduce the computational cost significantly, the representation ability is inevitably weakened. The relationship between spatial pixels is vital to make accurate recognition. While in GhostNet, the spatial information is only captured by the cheap operations (usually implemented by $3 \times 3$ depth-wise convolution) for half of the features. The remaining features are just produced by $1 \times 1$ point-wise convolution, without any interaction with other pixels. The weak ability to capture the spatial information may prevent performance from being further improved.
|
| 50 |
+
|
| 51 |
+
A block of GhostNet is constructed by stacking two Ghost modules (shown in Figure 4(a)). Similar to MobileNetV2 [28], it is also an inverted bottleneck, i.e., the first Ghost module acts as an expansion layer to increase the number of output channels, and the second Ghost module reduces the channels’ number to match the shortcut path.
|
| 52 |
+
|
| 53 |
+
# 3.2 Revisit Attention for Mobile Architecture
|
| 54 |
+
|
| 55 |
+
Originating from the NLP field [36], attention-based models are introduced to computer vision recently [6, 9, 34, 7]. For example, ViT [6] uses the standard transformer model stacked by self-attention modules and MLP modules. Wang et al.insert the selfattention operation into convolutional neural networks to capture the nonlocal information [37]. A typical at
|
| 56 |
+
|
| 57 |
+
Table 1: The comparison of theoretical FLOPs and practical latency.
|
| 58 |
+
|
| 59 |
+
<table><tr><td>Model</td><td>Top-1 Acc. (%)</td><td>FLOPs (M)</td><td>Latency (ms)</td></tr><tr><td>GhostNet</td><td>73.9</td><td>141</td><td>31.1</td></tr><tr><td>+ Self Attention [23]</td><td>74.4</td><td>172</td><td>72.3</td></tr><tr><td>+ DFC Attention (Ours)</td><td>75.3</td><td>167</td><td>37.5</td></tr></table>
|
| 60 |
+
|
| 61 |
+
tention module usually has a quadratic complexity w.r.t. the feature’s size, which is unscalable to high-resolution images in downstream tasks such as object detection and semantic segmentation.
|
| 62 |
+
|
| 63 |
+
A mainstream strategy to reduce attention’s complexity is splitting images into multiple windows and implementing the attention operation inside windows or crossing windows. For example, Swin Transformer [21] splits the original feature into multiple non-overlapped windows, and the selfattention is calculated within the local windows. MobileViT [23] also unfolds the feature into non-overlapping patches and calculates the attention across these patches. For the 2D feature map in CNN, implementing the feature splitting and attention calculation involves plenty of tensor reshaping and transposing operations. whose theoretical complexity is negligible. In a large model (e.g., Swin-B [21] with several billion FLOPs) with high complexity, these operations only occupy a few portions of the total inference time. While for the light-weight models, their deploying latency cannot be overlooked.
|
| 64 |
+
|
| 65 |
+

|
| 66 |
+
Figure 3: The information flow of DFC attention. The horizontal and vertical FC layers capture the long-range information along the two directions, respectively.
|
| 67 |
+
|
| 68 |
+
For an intuitive understanding, we equip the GhostNet model with the self-attention used in MobileViT [23] and measure the latency on Huawei P30 (Kirin 980 CPU) with TFLite tool. We use the standard input’s resolution of ImageNet, i.e., $2 2 4 \times 2 2 4$ , and show the results in Table 1. The attention mechanism only adds about $20 \%$ theoretical FLOPs, but requires $2 \times$ inference time on a mobile device. The large difference between theoretical and practical complexity shows that it is necessary to design a hard-ware friendly attention mechanism for fast implementation on mobile devices.
|
| 69 |
+
|
| 70 |
+
# 4 Approach
|
| 71 |
+
|
| 72 |
+
# 4.1 DFC Attention for Mobile Architecture
|
| 73 |
+
|
| 74 |
+
In this section, we will discuss how to design an attention module for mobile CNNs. A desired attention is expected to have the following properties:
|
| 75 |
+
|
| 76 |
+
• Long-range. It is vital to capture the long-range spatial information for attention to enhance the representation ability, as a light-weight CNN (e.g., MobileNet [13], GhostNet [8]) usually adopts small convolution filters (e.g., $1 \times 1$ convolution) to save computational cost. Deployment-efficient. The attention module should be extremely efficient to avoid slowing the inference down. Expensive transformations with high FLOPs or hardware-unfriendly operations are unexpected.
|
| 77 |
+
• Concept-simple. To keep the model’s generalization on diverse tasks, the attention module should be conceptually-simple with little dainty design.
|
| 78 |
+
|
| 79 |
+
Though self-attention operations [6, 24, 21] can model the long-range dependence well, they are not deployment-efficient as discussed in the above section. Compared with them, fully-connected (FC) layers with fixed weights are simpler and easier to implement, which can also be used to generate attention maps with global receptive fields. The detailed computational process is illustrated as follows.
|
| 80 |
+
|
| 81 |
+
Given a feature $Z ~ \in ~ \mathbb { R } ^ { H \times W \times C }$ , it can be seen as $H W$ tokens $z _ { i } ~ \in ~ \mathbb { R } ^ { C }$ , i.e., $Z =$ $\{ z _ { 1 1 } , z _ { 1 2 } , \cdots , z _ { H W } \}$ . A direct implementation of FC layer to generate the attention map is formulated as:
|
| 82 |
+
|
| 83 |
+
$$
|
| 84 |
+
{ \pmb a } _ { h w } = \sum _ { h ^ { \prime } , w ^ { \prime } } F _ { h w , h ^ { \prime } w ^ { \prime } } \odot { \pmb z } _ { h ^ { \prime } w ^ { \prime } } ,
|
| 85 |
+
$$
|
| 86 |
+
|
| 87 |
+
where $\odot$ is element-wise multiplication, $F$ is the learnable weights in the FC layer, and $A =$ $\{ { \pmb a } _ { 1 1 } , { \pmb a } _ { 1 2 } , \cdot \cdot \cdot , { \pmb a } _ { H W } \}$ is the generated attention map. Eq 3 can capture the global information by aggregating all the tokens together with learnable weights, which is much simpler than the typical self-attention [36] as well. However, its computational process still requires quadratic complexity $w . r . t .$ feature’s size $( i . e . , \mathcal { O } ( H ^ { 2 } W ^ { 2 } ) ) ^ { 2 }$ , which is unacceptable in practical scenarios especially when the input images are of high resolutions. For example, the 4-th layer of GhostNet has a feature map with 3136 $( 5 6 \times 5 6 )$ tokens, which incurs prohibitively high complexity to calculate the attention map. Actually, feature maps in a CNN are usually of low-rank [30, 17], it is unnecessary to connect all the input and output tokens in different spatial locations densely. The feature’s 2D shape naturally provides a perspective to reduce the computation of FC layers, i.e., decomposing Eq. 3 into two FC layers and aggregating features along the horizontal and vertical directions, respectively. It can be formulated as:
|
| 88 |
+
|
| 89 |
+

|
| 90 |
+
Figure 4: The diagrams of blocks in GhostNetV1 and GhostNetV2. Ghost block is an inverted residual bottleneck containing two Ghost modules, where DFC attention enhances the expanded features to improve expressiveness ability.
|
| 91 |
+
|
| 92 |
+
$$
|
| 93 |
+
\begin{array} { l } { { \displaystyle { \pmb a } _ { h w } ^ { \prime } = \sum _ { h ^ { \prime } = 1 } ^ { H } F _ { h , h ^ { \prime } w } ^ { H } \odot { \boldsymbol z } _ { h ^ { \prime } w } , h = 1 , 2 , \cdots , H , w = 1 , 2 , \cdots , W , } } \\ { { \displaystyle { \pmb a } _ { h w } = \sum _ { w ^ { \prime } = 1 } ^ { W } F _ { w , h w ^ { \prime } } ^ { W } \odot { \boldsymbol a } _ { h w ^ { \prime } } ^ { \prime } , h = 1 , 2 , \cdots , H , w = 1 , 2 , \cdots , W , } } \end{array}
|
| 94 |
+
$$
|
| 95 |
+
|
| 96 |
+
where $F ^ { H }$ and $F ^ { W }$ are transformation weights. Taking the original feature $Z$ as input, Eq. 4 and Eq. 5 are applied to the features sequentially, capturing the long-range dependence along the two directions, respectively. We dub this operation as decoupled fully connected (DFC) attention, whose information flow is shown in Figure 3. Owing to the decoupling of horizontal and vertical transformations, the computational complexity of the attention module can be reduced to $\mathcal { O } ( H ^ { 2 } W + H W ^ { 2 } )$ . In the full attention (Eq. 3), all the patches in a square region participate in the calculation of the focused patch directly. In DFC attention, a patch is directly aggregated by patches in its vertical/horizontal lines, while other patches participate in the generation of those patches in the vertical/horizontal lines, having an indirect relationship with the focused token. Thus the calculation of a patch also involves all the patches in the square region.
|
| 97 |
+
|
| 98 |
+
Eqs. 4 and 5 denote the general formulation of DFC attention, which aggregates pixels along horizontal and vertical directions, respectively. By sharing a part of transformation weights, it can be conveniently implemented with convolutions, leaving out the time-consuming tensor reshaping and transposing operations that affect the practical inference speed. To process input images with varying resolutions, the filter’s size can be decoupled with feature map’s size, i.e., two depth-wise convolutions with kernel sizes $1 \times K _ { H }$ and $K _ { W } \times 1$ are sequentially applied on the input feature. When implemented with convolution, the theoretical complexity of DFC attention is denoted as $\mathcal { O } ( K _ { H } H W + K _ { W } H W )$ . This strategy is well supported by tools such as TFLite and ONNX for fast inference on mobile devices.
|
| 99 |
+
|
| 100 |
+
# 4.2 GhosetNet V2
|
| 101 |
+
|
| 102 |
+
In this section, we use the DFC attention to improve the representation ability of lightweight models and then present the new vision backbone, GhostNetV2.
|
| 103 |
+
|
| 104 |
+
Enhancing Ghost module. As discussed in 3.1, only half of features in Ghost module (Eqs. 1 and 2) interact with other pixels, which damages its ability to capture spatial information. Hence we use DFC attention to enhance Ghost module’s output feature $Y$ for capturing long-range dependence among different spatial pixels.
|
| 105 |
+
|
| 106 |
+
The input feature $X \in \mathbb { R } ^ { H \times W \times C }$ is sent to two branches, i.e., one is the Ghost module to produce output feature $Y$ (Eqs. 1 and 2), and the other is the DFC module to generate attention map $A$ (Eqs. 4 and 5). Recalling that in a typical self-attention [36], linear transformation layers are used to transform input feature into query and key for calculating attention maps. Similarly, we also implement a $1 \times 1$ convolution to convert module’s input $X$ into DFC’s input $Z$ . The final output $O \in \bar { \mathbb { R } ^ { H \times W \times C } }$ of the module is the product of two branch’s output, i.e.,
|
| 107 |
+
|
| 108 |
+
$$
|
| 109 |
+
O = { \mathrm { S i g m o i d } } ( A ) \odot { \mathcal { V } } ( X ) ,
|
| 110 |
+
$$
|
| 111 |
+
|
| 112 |
+
where $\odot$ is the element-wise multiplication and Sigmoid is the scaling function to normalize the attention map $A$ into range $( 0 , 1 )$ .
|
| 113 |
+
|
| 114 |
+
The information aggregation process is shown in Figure 5. With the same input, the Ghost module and DFC attention are two parallel branches extracting information from different perspectives. The output is their element-wise product, which contains information from both features of the Ghost module and attentions of the DFC attention module. The calculation of each attention value involves patches in a large range so that the output feature can contain information from these patches.
|
| 115 |
+
|
| 116 |
+
Feature downsampling. As Ghost module (Eqs. 1 and 2) is an extremely efficient operation, directly paralleling the DFC attention with it will introduces extra computational cost. Hence we reduce the feature’s size by down-sampling it both horizontally and vertically, so that all the operations in DFC attention can be conducted on the smaller features. By default, the width and height are both scaled to half of their original lengths, which reduces $7 5 \%$ FLOPs of DFC attention. Then produced feature map is then upsampled to the original size to match the feature’s size in Ghost branch. We naively use the average pooling and bilinear interpolation for downsampling and upsampling, respectively. Noticing that directly implementing sigmoid (or hard sigmoid) function will incur longer latency, we also deploy
|
| 117 |
+
|
| 118 |
+

|
| 119 |
+
Figure 5: The information aggregation process of different patches.
|
| 120 |
+
|
| 121 |
+
the sigmoid function on the downsampled features to accelerate practical inference. Though the value of attention maps may not be limited in range (0,1) strictly, we empirically find that its impact on the final performance is negligible.
|
| 122 |
+
|
| 123 |
+
GhostV2 bottleneck. GhostNet adopts an inverted residual bottleneck containing two Ghost modules, where the first module produces expanded features with more channels, while the second one reduces channel’s number to get output features. This inverted bottleneck naturally decouples the “expressiveness” and “capacity” of a model [28]. The former is measured by the expanded features while the latter is reflected by the input/output domains of a block. The original Ghost module generates partial features via cheap operations, which damages both the expressiveness and the capacity. By investigating the performance difference of equipping DFC attention on the expanded features or output features (Table 8 in Section 5.4), we find that enhancing ‘expressiveness’ is more effective. Hence we only multiply the expanded features with DFC attention.
|
| 124 |
+
|
| 125 |
+
Figure 4(b) shows the diagram of GhostV2 bottleneck. A DFC attention branch is parallel with the first Ghost module to enhance the expanded features. Then the enhanced features are sent to the second Ghost module for producing output features. It captures the long-range dependence between pixels in different spatial locations and enhances the model’s expressiveness.
|
| 126 |
+
|
| 127 |
+
Table 2: Comparison of SOTA light-weight models over classification accuracy, the number of parameters and FLOPs on ImageNet dataset.
|
| 128 |
+
|
| 129 |
+
<table><tr><td>Model</td><td>Params (M)</td><td>FLOPs (M)</td><td>Top-1 Acc. (%)</td><td>Top-5 Acc. (%)</td></tr><tr><td>MobileNetV1 0.5× [13]</td><td>1.3</td><td>150</td><td>63.3</td><td>84.9</td></tr><tr><td>MobileNetV2 0.6× [28]</td><td>2.2</td><td>141</td><td>66.7</td><td>-</td></tr><tr><td>ShuffleNetV11.0× (g=3) [42]</td><td>1.9</td><td>138</td><td>67.8</td><td>87.7</td></tr><tr><td>ShuffleNetV21.0× [22]</td><td>2.3</td><td>146</td><td>69.4</td><td>88.9</td></tr><tr><td>MobileNetV3-L 0.75×[12]</td><td>4.0</td><td>155</td><td>73.3</td><td>1</td></tr><tr><td>GhostNetV11.0× [8]</td><td>5.2</td><td>141</td><td>73.9</td><td>91.4</td></tr><tr><td>GhostNetV1 1.1× [8]</td><td>5.9</td><td>168</td><td>74.5</td><td>92.0</td></tr><tr><td>GhostNetV2 1.0×</td><td>6.1</td><td>167</td><td>75.3</td><td>92.4</td></tr><tr><td>MobileNetV11.0×[13]</td><td>4.2</td><td>575</td><td>70.6</td><td>-</td></tr><tr><td>MobileNetV21.0× [28]</td><td>3.5</td><td>300</td><td>72.8</td><td>90.8</td></tr><tr><td>ShuffleNetV21.5× [22]</td><td>3.5</td><td>299</td><td>72.6</td><td>90.6</td></tr><tr><td>FE-Net 1.0× [3]</td><td>3.7</td><td>301</td><td>72.9</td><td></td></tr><tr><td>FBNet-B [39]</td><td>4.5</td><td>295</td><td>74.1</td><td>-</td></tr><tr><td>ProxylessNAS[1]</td><td>4.1</td><td>320</td><td>74.6</td><td>- 92.2</td></tr><tr><td>MnasNet-A1[31]</td><td>3.9</td><td>312</td><td>75.2</td><td>92.5</td></tr><tr><td>MnasNet-A2 [31]</td><td>4.8</td><td>340</td><td>75.6</td><td>92.7</td></tr><tr><td>MobileNetV3-L 1.0×[12]</td><td>5.4</td><td>219</td><td>75.2</td><td>-</td></tr><tr><td>MobileNeXt 1.0× [44]</td><td>3.4</td><td>300</td><td>74.0</td><td></td></tr><tr><td>MobileNeXt+ 1.0× [44]</td><td>3.94</td><td>330</td><td>76.1</td><td>=</td></tr><tr><td>GhostNetV1 1.3× [8]</td><td>7.3</td><td>226</td><td>75.7</td><td>=</td></tr><tr><td>GhostNetV1 1.4× [8]</td><td>8.2</td><td>264</td><td>76.1</td><td>92.7</td></tr><tr><td>GhostNetV2 1.3×</td><td>8.9</td><td>269</td><td>76.9</td><td>92.9 93.4</td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>FBNet-C[39] EfficientNet-B0[32]</td><td>5.5</td><td>375</td><td>74.9</td><td>-</td></tr><tr><td></td><td>5.3</td><td>390</td><td>77.1</td><td>93.3</td></tr><tr><td>MnasNet-A3 [31]</td><td>5.2</td><td>403</td><td>76.7</td><td>93.3</td></tr><tr><td>MobileNetV3-L 1.25×[12]</td><td>7.5</td><td>355</td><td>76.6</td><td>-</td></tr><tr><td>MobileNeXt+ 1.1× [44]</td><td>4.28</td><td>420</td><td>76.7</td><td>=</td></tr><tr><td>MobileViT-XS[23]</td><td>2.3</td><td>700</td><td>74.8</td><td>-</td></tr><tr><td>GhostNetV1 1.7× [8]</td><td>11.0</td><td>378</td><td>77.2</td><td>93.4</td></tr><tr><td>GhostNetV2 1.6×</td><td>12.3</td><td>399</td><td>77.8</td><td>93.8</td></tr></table>
|
| 130 |
+
|
| 131 |
+
# 5 Experiments
|
| 132 |
+
|
| 133 |
+
In this section, we empirically investigate the proposed GhostNetV2 model. We conduct experiments on the image classification task with the large-scale ImageNet dataset [5]. To validate its generalization, we use GhostNetV2 as backbone and embed it into a light-weight object detection scheme YOLOV3 [26]. Models with different backbone are compared on MS COCO dataset [20]. At last, we conduct extensive ablation experiments for better understanding GhostNetV2. The practical latency is measured on Huawei P30 (Kirin 980 CPU) with TFLite tool.
|
| 134 |
+
|
| 135 |
+
# 5.1 Image Classification on ImageNet
|
| 136 |
+
|
| 137 |
+
Setting. The classification experiments are conducted on the benchmark ImageNet (ILSVRC 2012) dataset, which contains 1.28M training images and 50K validation images from 1000 classes. We follow the training setting in [8] and report results with single crop on ImageNet dataset. All the experiments are conducted with PyTorch [25] and MindSpore [15].
|
| 138 |
+
|
| 139 |
+
Results. The performance comparison of different models on ImageNet is shown in Table 2, Figure 1 and Figure 2. Several light-weight models are selected as the competing methods. GhostNet [8], MobileNetV2 [28], MobileNetV3 [12], and ShuffleNet [42] are widely-used light-weight CNN models with SOTA performance. By combing CNN and Transformer, MobileViT [24] is a new backbone presented recently. Compared with them, GhostNetV2 achieves significantly higher performance with lower computational cost. For example, GhostNetV2 achieves $7 5 . 3 \%$ top-1 accuracy with only 167 FLOPs, which significantly outperform GhostNet V1 $( 7 4 . 5 \% )$ with similar computational cost (167M FLOPs).
|
| 140 |
+
|
| 141 |
+
Table 3: Results of object detection on MS COCO dataset. YOLOv3 [26] is used as the detection head.
|
| 142 |
+
|
| 143 |
+
<table><tr><td>Backbone</td><td>Resolution</td><td>Backbone FLOPs (M)</td><td>AP</td><td>AP50</td><td>AP75</td><td>APs</td><td>APM</td><td>APL</td></tr><tr><td>MobileNetV2 1.0×[28] GhostNet V1 1.1×</td><td>320× 230</td><td>613 338</td><td>22.2 21.8</td><td>41.9 41.2</td><td>21.4 20.8</td><td>6.0 5.7</td><td>23.6 22.3</td><td>35.8 37.3</td></tr><tr><td>GhostNetV2 1.0×</td><td></td><td>342</td><td>22.3</td><td>41.4</td><td>21.9</td><td>6.0</td><td>22.8</td><td>38.1</td></tr><tr><td>MobileNetV2 1.0× [28]</td><td>416 × 416</td><td>1035</td><td>23.9</td><td>45.4</td><td>22.6</td><td>10.6</td><td>25.1</td><td>34.9</td></tr><tr><td>GhostNet V1 1.1×</td><td></td><td>567</td><td>23.4</td><td>45.2</td><td>21.9</td><td>9.8</td><td>24.4</td><td>34.9</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>GhostNetV2 1.0×</td><td></td><td>571</td><td>24.1</td><td>45.7</td><td>23.0</td><td>10.4</td><td>25.0</td><td>36.1</td></tr></table>
|
| 144 |
+
|
| 145 |
+
Table 4: Effectiveness of DFC attention with MobileNetV2 on ImageNet dataset.
|
| 146 |
+
|
| 147 |
+
<table><tr><td>Model</td><td>Params (M)</td><td>FLOPs (M)</td><td>Top-1 Acc. (%)</td><td>Top-5 Acc. (%)</td></tr><tr><td>MobileNetV2 1.0 ×</td><td>3.5</td><td>300</td><td>72.8</td><td>90.8</td></tr><tr><td>MobileNetV2 1.1 ×</td><td>4.1</td><td>338</td><td>73.0</td><td>90.0</td></tr><tr><td>MobileNetV21.1 × + SE[14]</td><td>4.0</td><td>338</td><td>73.8</td><td>91.0</td></tr><tr><td>MobileNetV21.1 × +CBAM[38]</td><td>4.0</td><td>338</td><td>74.0</td><td>91.4</td></tr><tr><td>MobileNetV2 1.1 × + CA[11]</td><td>4.1</td><td>350</td><td>74.5</td><td>91.8</td></tr><tr><td>MobileNetV2 1.0 × + DFC (Ours)</td><td>4.3</td><td>344</td><td>75.4</td><td>92.4</td></tr></table>
|
| 148 |
+
|
| 149 |
+
Practical Inference Speed. Considering the light-weight model is designed for mobile applications, we practically measure the inference latency of different models on an arm-based mobile phone, using the TFLite tool [4]. Owing to the deploying efficiency of DFC attention, GhostNetV2 also achieves a good trade-off between accuracy and practical speed. For example, with similar inference latency (e.g., $3 7 ~ \mathrm { m s }$ ), GhostNetV2 achieves $7 5 . 3 \%$ top-1 accuracy, which is obviously GhostNet V1 with $7 4 . 5 \%$ top-1 accuracy.
|
| 150 |
+
|
| 151 |
+
# 5.2 Object Detection on COCO
|
| 152 |
+
|
| 153 |
+
Setting. To validate the generalization of GhostNetV2, we further conduct experiments on the object detection task. The experiments are conducted on MS COCO 2017 dataset, composing of $1 1 8 \mathrm { k }$ training images and $5 \mathrm { k }$ validation images. We embed different backbone into a widely-used detection head, YOLOv3 [26] and follow the default training strategy provided by MMDetection 3. Specifically, based on the pre-trained weights on ImageNet, the models are fine-tuned with SGD optimizer for 30 epochs. The batchsize is set to 192 and initial learning to 0.003. The experiments are conducted with input resolutions $3 2 0 \times 3 2 0$ .
|
| 154 |
+
|
| 155 |
+
Results. Table 3 compares the proposed GhostNetV2 model with GhostNet V1. With different input resolutions, GhostNetV2 shows obvious superiority to the GhostNet V1. For example, with similar computational cost (i.e., 340M FLOPs with $3 2 0 \times 3 2 0$ input resolution), GhostNetV2 achieves $2 2 . 3 \%$ mAP, which suppresses GhostNet V1 by $0 . 5 \mathrm { m A P } .$ . We conclude that capturing the long-range dependence is also vital for downstream tasks, and the proposed DFC attention can effectively endow a large receptive field to the Ghost module, and then construct a more powerful and efficient block.
|
| 156 |
+
|
| 157 |
+
# 5.3 Semantic Segmentation on ADE20K
|
| 158 |
+
|
| 159 |
+
We conduct semantic segmentation experiments on ADE20K [43], which contains $2 0 \mathrm { k }$ training, 2k validation, and 3k testing images with 150 semantic categories. We use the DeepLabV3 [2] model as the segmentation head, and follow the default training setting of MMSegmentation 4. From the pre-trained weights on ImageNet, the models are fine-tuned for 160000 iterations with crop size $5 1 2 \times 5 1 2$ . Table 5 show the results with different backbones. In the semantic tasks, GhostNetV2 also achieves significantly higher performance than GhostNetV1, which illustrates the university of GhostNetV2 over different tasks.
|
| 160 |
+
|
| 161 |
+
Table 5: Results of semantic segmentation on ADE20K dataset.
|
| 162 |
+
|
| 163 |
+
<table><tr><td rowspan=1 colspan=1>Backbone</td><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>Backbone FLOPs (M)|mIoU (%)</td><td rowspan=1 colspan=1>mIoU (%)</td></tr><tr><td rowspan=1 colspan=1>MobileNetV2 1.0× [28]GhostNet V1 1.1×GhostNetV2 1.0×</td><td rowspan=1 colspan=1>DeepLabV3</td><td rowspan=1 colspan=1>300168167</td><td rowspan=1 colspan=1>34.0834.1735.52</td></tr></table>
|
| 164 |
+
|
| 165 |
+
Table 7: The location for implementing DFC attention.
|
| 166 |
+
|
| 167 |
+
<table><tr><td>Stage</td><td>Top1-Acc. (%)</td><td>Params (M)</td><td>FLOPs (M)</td></tr><tr><td>None</td><td>73.9</td><td>5.2</td><td>141</td></tr><tr><td>1</td><td>74.8</td><td>5.3</td><td>150</td></tr><tr><td>2</td><td>75.0</td><td>5.4</td><td>152</td></tr><tr><td>3</td><td>74.7</td><td>5.8</td><td>147</td></tr><tr><td>All</td><td>75.3</td><td>5.8</td><td>168</td></tr></table>
|
| 168 |
+
|
| 169 |
+
Table 8: Enhancing expressiveness or capacity.
|
| 170 |
+
|
| 171 |
+
<table><tr><td>Model</td><td>Top1-Acc. (%)</td><td>Params (M)</td><td>FLOPs (M)</td></tr><tr><td>Baseline</td><td>73.9 (+0.0)</td><td>5.2</td><td>141</td></tr><tr><td>Expressiveness</td><td>75.3 (+1.4)</td><td>6.1</td><td>167</td></tr><tr><td>Capacity</td><td>74.8 (+0.9)</td><td>6.1</td><td>162</td></tr><tr><td>Both</td><td>75.5 (+1.6)</td><td>7.0</td><td>188</td></tr></table>
|
| 172 |
+
|
| 173 |
+
# 5.4 Ablation Studies
|
| 174 |
+
|
| 175 |
+
In this section, we conduct extensive experiments to investigate the impact of each component in GhostNetV2. The experiments are conducted with GhostNetV2 $1 \times$ on ImageNet.
|
| 176 |
+
|
| 177 |
+
Experiments with other models. As a universal module, the DFC attention can also be embedded into other architectures for enhancing their performance. The resultsof MobileNetV2 with different attention modules are shown in Table 4. SE [14] and CBAM [38] are two widely-used attention modules, and CA [11] is a SOTA method presented recently. The proposed DFC attention achieves higher performance than these existing methods. For example, the proposed DFC attention improves the top-1 accuracy of MobileNetV2 by $2 . 4 \%$ , which suppresses CA $( 1 . 5 \% )$ by a large margin.
|
| 178 |
+
|
| 179 |
+
The impact of kernel size in DFC attention. We split the GhostNetV2 architecture into 3 stages by the feature’s size, and apply
|
| 180 |
+
|
| 181 |
+
Table 6: The impact of kernel size in DFC attention.
|
| 182 |
+
|
| 183 |
+
<table><tr><td>Kernel sizes</td><td>Top1-Acc. (%)</td></tr><tr><td>(3,3,3) (7,5,5) (7,7,5) (9,7,5)</td><td>74.8 75.0 74.2</td></tr></table>
|
| 184 |
+
|
| 185 |
+
DFC attention with different kernel size (Table 6). The kernel sizes $1 \times 3$ and $3 \times 1$ cannot capture the long-range dependence well, which results in the worst performance (i.e., $7 4 . 8 \%$ ). Increasing the kernel size to capture the longer range information can significantly improve the performance.
|
| 186 |
+
|
| 187 |
+
The location for implementing DFC attention. The GhostNetV2 model can be split into 4 stages by the feature’s size, and we empirically investigate how the implementing location affects the final performance. The results are shown in Table 7, which empirically shows that the DFC attention can improve performance when implementing it on any stage. Exhaustively adjusting or searching for proper locations has the potential to further improve the trade-off between accuracy and computational cost, which exceeds the scope of this paper. By default, we deploy the DFC attention on all the layers.
|
| 188 |
+
|
| 189 |
+
Table 9: The impact of scaling function. ‘BF’ and ‘AF’ denote implementing the scaling function before or after the up-sampling operation, respectively.
|
| 190 |
+
|
| 191 |
+
<table><tr><td>Scaling function</td><td>Top1-Acc. (%)</td><td>FLOPs (M)</td><td>Latency (ms)</td></tr><tr><td>Sigmoid (BF)</td><td>75.3</td><td>167</td><td>37.5</td></tr><tr><td>Hard simoid (BF)</td><td>75.2</td><td>167</td><td>36.8</td></tr><tr><td>Clip (BF)</td><td>74.9</td><td>167</td><td>36.7</td></tr><tr><td>Sigmoid (AF)</td><td>75.3</td><td>167</td><td>40.7</td></tr><tr><td>Hard simoid (AF)</td><td>75.2</td><td>167</td><td>39.6</td></tr><tr><td>Clip (AF)</td><td>75.0</td><td>167</td><td>38.5</td></tr></table>
|
| 192 |
+
|
| 193 |
+
The impact of scaling function. For an attention model, it is necessary to scale the feature maps into range (0,1), which can stabilize the training process. Though the theoretical complexity is negligible, these element-wise operations still incur extra latency. Table 9 investigates how the scaling function affects the final performance and latency. Though sigmoid and hard sigmoid functions bring obvious performance improvement, directly implementing them on the large feature maps incur long latency.
|
| 194 |
+
|
| 195 |
+
Implementing them before up-sampling is much more efficient but results in similar accuracy. By default, we use the sigmoid function and put it before the up-sampling operation.
|
| 196 |
+
|
| 197 |
+
Enhancing expressiveness or capacity. We implement the DFC attention on two Ghost modules and show the results in Table 8. As discussed in Section 4.2, the former enhances expanded features (expressiveness) while the latter improves the block’s capacity. With similar computational costs, enhancing the expanded features brings $1 . 4 \%$ top-1 accuracy improvement, which is much higher than enhancing the output feature. Though enhancing both of the features can further improve the performance, the computational cost also increases accordingly. By default, we only enhance the expanded features in an inverse residual bottleneck.
|
| 198 |
+
|
| 199 |
+
The resizing functions for up-sampling and down-sampling. Multiple functions can conduct the up-sampling and downsampling operations, and we investigate several widely-used functions, i.e., average pooling, max pooling, bilinear interpolation for down-sampling, and bilinear, bicubic interpolations for up-sampling (Table 10). The performance of GhostNetV2 is robust to the choice of resizing functions, i.e., all of these methods achieve similar accuracies in ImageNet. Their differences mainly lie in practical deploying efficiency
|
| 200 |
+
|
| 201 |
+
Table 10: The resizing functions for down-sampling and up-sampling, denoted as $ { ^ 6 } \mathrm { D } ^ { \prime }$ and ‘U’, respectively.
|
| 202 |
+
|
| 203 |
+
<table><tr><td>Resizing function</td><td>Top1-Acc. (%)</td><td>FLOPs (M)</td><td>Latency (ms)</td></tr><tr><td>Average Pooling (D)</td><td>75.4</td><td>167</td><td>38.4</td></tr><tr><td>Max Pooling (D)</td><td>75.3</td><td>167</td><td>37.5</td></tr><tr><td>Bilinear (D)</td><td>75.3</td><td>167</td><td>38.7</td></tr><tr><td>Bilinear (U)</td><td>75.3</td><td>167</td><td>37.5</td></tr><tr><td>Bicubic (U)</td><td>75.4</td><td>167</td><td>39.9</td></tr></table>
|
| 204 |
+
|
| 205 |
+
on mobile devices. Maxing pooling is slightly more efficient than average pooling (37.5 ms vs.38.4 ms), and bilinear interpolation is faster than the bicubic one $( 3 7 . 5 \ \mathrm { m s } \ \nu s . 3 9 . 9 \ \mathrm { m s } )$ . Thus we choose the maxing pooling for down-sampling and bilinear interpolation for up-sampling by default.
|
| 206 |
+
|
| 207 |
+
Visualization of decoupled attention and full attention. We visualize the decoupled attention produced by stacking vertical and horizontal attentions and compare it with full attention. In low layers, the decoupled attention shows some cross-shaped patterns, indicating patches from the vertical/horizontal lines participate more. As the depth increases, the pattern of the attention map diffuses and becomes more similar to the full attention.
|
| 208 |
+
|
| 209 |
+

|
| 210 |
+
Figure 6: Visualization of attention maps.
|
| 211 |
+
|
| 212 |
+
# 6 Conclusion
|
| 213 |
+
|
| 214 |
+
This paper proposes a hardware-friendly DFC attention and presents a new GhostNetV2 architecture for mobile applications. The DFC attention can capture the dependence between pixels in long-range spatial locations, which significantly enhances the expressiveness ability of light-weight models. It decomposes a FC layer into horizontal FC and vertical FC, which has large receptive fields along the two directions, respectively. Equipped this computation-efficient and deployment-simple modules, GhostNetV2 can achieve a better trade-off between accuracy and speed. Extensive experiments on benchmark datasets (e.g., ImageNet, MS COCO) validate the superiority of GhostNetV2.
|
| 215 |
+
|
| 216 |
+
Acknowledgment. This work is supported by National Natural Science Foundation of China under Grant No.61876007, Australian Research Council under Project DP210101859 and the University of Sydney SOAR Prize. We gratefully acknowledge the support of MindSpore, CANN(Compute Architecture for Neural Networks) and Ascend AI Processor used for this research.
|
| 217 |
+
|
| 218 |
+
# References
|
| 219 |
+
|
| 220 |
+
[1] Han Cai, Ligeng Zhu, and Song Han. Proxylessnas: Direct neural architecture search on target task and hardware. In ICLR, 2019.
|
| 221 |
+
[2] Liang-Chieh Chen, George Papandreou, Florian Schroff, and Hartwig Adam. Rethinking atrous convolution for semantic image segmentation. arXiv preprint arXiv:1706.05587, 2017. [3] Weijie Chen, Di Xie, Yuan Zhang, and Shiliang Pu. All you need is a few shifts: Designing efficient convolutional neural networks for image classification. In CVPR, 2019. [4] Robert David, Jared Duke, Advait Jain, Vijay Janapa Reddi, Nat Jeffries, Jian Li, Nick Kreeger, Ian Nappier, Meghna Natraj, Tiezhen Wang, et al. Tensorflow lite micro: Embedded machine learning for tinyml systems. Proceedings of Machine Learning and Systems, 3:800–811, 2021. [5] 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, pages 248–255. Ieee, 2009. [6] 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. [7] Kai Han, Jianyuan Guo, Yehui Tang, and Yunhe Wang. Pyramidtnt: Improved transformer-in-transformer baselines with pyramid architecture. arXiv preprint arXiv:2201.00978, 2022. [8] Kai Han, Yunhe Wang, Qi Tian, Jianyuan Guo, Chunjing Xu, and Chang Xu. Ghostnet: More features from cheap operations. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 1580–1589, 2020. [9] Kai Han, An Xiao, Enhua Wu, Jianyuan Guo, Chunjing Xu, and Yunhe Wang. Transformer in transformer. Advances in Neural Information Processing Systems, 34:15908–15919, 2021.
|
| 222 |
+
[10] 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.
|
| 223 |
+
[11] Qibin Hou, Daquan Zhou, and Jiashi Feng. Coordinate attention for efficient mobile network design. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 13713– 13722, 2021.
|
| 224 |
+
[12] Andrew Howard, Mark Sandler, Grace Chu, Liang-Chieh Chen, Bo Chen, Mingxing Tan, Weijun Wang, Yukun Zhu, Ruoming Pang, Vijay Vasudevan, et al. Searching for mobilenetv3. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 1314–1324, 2019.
|
| 225 |
+
[13] Andrew G Howard, Menglong Zhu, Bo Chen, Dmitry Kalenichenko, Weijun Wang, Tobias Weyand, Marco Andreetto, and Hartwig Adam. Mobilenets: Efficient convolutional neural networks for mobile vision applications. arXiv preprint arXiv:1704.04861, 2017.
|
| 226 |
+
[14] Jie Hu, Li Shen, and Gang Sun. Squeeze-and-excitation networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 7132–7141, 2018.
|
| 227 |
+
[15] Huawei. Mindspore. https://www.mindspore.cn/, 2020.
|
| 228 |
+
[16] Forrest N Iandola, Song Han, Matthew W Moskewicz, Khalid Ashraf, William J Dally, and Kurt Keutzer. Squeezenet: Alexnet-level accuracy with $5 0 \mathrm { x }$ fewer parameters and $< 0 . 5 \mathrm { m b }$ model size. arXiv preprint arXiv:1602.07360, 2016.
|
| 229 |
+
[17] Max Jaderberg, Andrea Vedaldi, and Andrew Zisserman. Speeding up convolutional neural networks with low rank expansions. arXiv preprint arXiv:1405.3866, 2014.
|
| 230 |
+
[18] Andrej Karpathy, George Toderici, Sanketh Shetty, Thomas Leung, Rahul Sukthankar, and Li Fei-Fei. Large-scale video classification with convolutional neural networks. In Proceedings of the IEEE conference on Computer Vision and Pattern Recognition, pages 1725–1732, 2014.
|
| 231 |
+
[19] Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. Advances in neural information processing systems, 25, 2012.
|
| 232 |
+
[20] Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In European conference on computer vision, pages 740–755. Springer, 2014.
|
| 233 |
+
[21] 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 Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 10012–10022, 2021.
|
| 234 |
+
[22] Ningning Ma, Xiangyu Zhang, Hai-Tao Zheng, and Jian Sun. Shufflenet v2: Practical guidelines for efficient cnn architecture design. In Proceedings of the European conference on computer vision (ECCV), pages 116–131, 2018.
|
| 235 |
+
[23] Sachin Mehta and Mohammad Rastegari. Mobilevit: light-weight, general-purpose, and mobile-friendly vision transformer. arXiv preprint arXiv:2110.02178, 2021.
|
| 236 |
+
[24] Sachin Mehta and Mohammad Rastegari. Mobilevit: Light-weight, general-purpose, and mobile-friendly vision transformer. In International Conference on Learning Representations, 2022.
|
| 237 |
+
[25] 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.
|
| 238 |
+
[26] Joseph Redmon and Ali Farhadi. Yolov3: An incremental improvement. arXiv preprint arXiv:1804.02767, 2018.
|
| 239 |
+
[27] Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. Advances in neural information processing systems, 28, 2015.
|
| 240 |
+
[28] Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, and Liang-Chieh Chen. Mobilenetv2: Inverted residuals and linear bottlenecks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 4510–4520, 2018.
|
| 241 |
+
[29] Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 1–9, 2015.
|
| 242 |
+
[30] Cheng Tai, Tong Xiao, Yi Zhang, Xiaogang Wang, et al. Convolutional neural networks with low-rank regularization. arXiv preprint arXiv:1511.06067, 2015.
|
| 243 |
+
[31] Mingxing Tan, Bo Chen, Ruoming Pang, Vijay Vasudevan, Mark Sandler, Andrew Howard, and Quoc V Le. Mnasnet: Platform-aware neural architecture search for mobile. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 2820–2828, 2019.
|
| 244 |
+
[32] Mingxing Tan and Quoc Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In International conference on machine learning, pages 6105–6114. PMLR, 2019.
|
| 245 |
+
[33] Yehui Tang, Kai Han, Jianyuan Guo, Chang Xu, Yanxi Li, Chao Xu, and Yunhe Wang. An image patch is a wave: Phase-aware vision mlp. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10935–10944, 2022.
|
| 246 |
+
[34] Yehui Tang, Kai Han, Chang Xu, An Xiao, Yiping Deng, Chao Xu, and Yunhe Wang. Augmented shortcuts for vision transformers. Advances in Neural Information Processing Systems, 34:15316–15327, 2021.
|
| 247 |
+
[35] Yehui Tang, Yunhe Wang, Yixing Xu, Dacheng Tao, Chunjing Xu, Chao Xu, and Chang Xu. Scop: Scientific control for reliable neural network pruning. Advances in Neural Information Processing Systems, 33:10936–10947, 2020.
|
| 248 |
+
[36] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
|
| 249 |
+
[37] 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, pages 7794–7803, 2018.
|
| 250 |
+
[38] Sanghyun Woo, Jongchan Park, Joon-Young Lee, and In So Kweon. Cbam: Convolutional block attention module. In Proceedings of the European conference on computer vision (ECCV), pages 3–19, 2018.
|
| 251 |
+
[39] Bichen Wu, Xiaoliang Dai, Peizhao Zhang, Yanghan Wang, Fei Sun, Yiming Wu, Yuandong Tian, Peter Vajda, Yangqing Jia, and Kurt Keutzer. Fbnet: Hardware-aware efficient convnet design via differentiable neural architecture search. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10734–10742, 2019.
|
| 252 |
+
[40] Yixing Xu, Kai Han, Chang Xu, Yehui Tang, Chunjing Xu, and Yunhe Wang. Learning frequency domain approximation for binary neural networks. Advances in Neural Information Processing Systems, 34:25553–25565, 2021.
|
| 253 |
+
[41] Yixing Xu, Yunhe Wang, Hanting Chen, Kai Han, Chunjing Xu, Dacheng Tao, and Chang Xu. Positiveunlabeled compression on the cloud. Advances in Neural Information Processing Systems, 32, 2019.
|
| 254 |
+
[42] Xiangyu Zhang, Xinyu Zhou, Mengxiao Lin, and Jian Sun. Shufflenet: An extremely efficient convolutional neural network for mobile devices. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 6848–6856, 2018.
|
| 255 |
+
|
| 256 |
+
[43] Bolei Zhou, Hang Zhao, Xavier Puig, Sanja Fidler, Adela Barriuso, and Antonio Torralba. Scene parsing through ade20k dataset. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 633–641, 2017.
|
| 257 |
+
|
| 258 |
+
[44] Daquan Zhou, Qibin Hou, Yunpeng Chen, Jiashi Feng, and Shuicheng Yan. Rethinking bottleneck structure for efficient mobile network design. In European Conference on Computer Vision, pages 680–697. Springer, 2020.
|
| 259 |
+
|
| 260 |
+
# Checklist
|
| 261 |
+
|
| 262 |
+
1. For all authors...
|
| 263 |
+
|
| 264 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] See Section 1.
|
| 265 |
+
(b) Did you describe the limitations of your work? [Yes]
|
| 266 |
+
(c) Did you discuss any potential negative societal impacts of your work? [No] No potential negative societal impacts.
|
| 267 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 268 |
+
|
| 269 |
+
2. If you are including theoretical results...
|
| 270 |
+
|
| 271 |
+
(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]
|
| 272 |
+
|
| 273 |
+
3. If you ran experiments...
|
| 274 |
+
|
| 275 |
+
(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]
|
| 276 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
|
| 277 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No]
|
| 278 |
+
(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]
|
| 279 |
+
|
| 280 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 281 |
+
|
| 282 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes]
|
| 283 |
+
(b) Did you mention the license of the assets? [No]
|
| 284 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [No]
|
| 285 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [No]
|
| 286 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No]
|
| 287 |
+
|
| 288 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 289 |
+
|
| 290 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 291 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 292 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
md/dev/wiBEFdAvl8L/wiBEFdAvl8L.md
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# GLIPv2: Unifying Localization and VL Understanding
|
| 2 |
+
|
| 3 |
+
Haotian Zhang∗1†, Pengchuan Zhang $\ast 2 \dagger \spadesuit$ , Xiaowei $\mathbf { H } \mathbf { u } ^ { 3 }$ , Yen-Chun Chen3, Liunian Harold Li4† Xiyang $\mathbf { D a i } ^ { 3 }$ , Lijuan Wang3, Lu Yuan3, Jenq-Neng Hwang1, Jianfeng Gao3
|
| 4 |
+
|
| 5 |
+
1University of Washington, 2Meta AI, 3Microsoft, 4UCLA {haotiz,hwang}@uw.edu,pengchuanzhang@fb.com,liunian.harold.li@cs.ucla.edu, {Xiaowei.Hu,Yen-Chun.Chen,Xiyang.Dai,lijuanw,luyuan,jfgao}@microsoft.com
|
| 6 |
+
|
| 7 |
+
# Abstract
|
| 8 |
+
|
| 9 |
+
We present GLIPv2, a grounded VL understanding model, that serves both localization tasks (e.g., object detection, instance segmentation) and Vision-Language (VL) understanding tasks (e.g., VQA, image captioning). GLIPv2 elegantly unifies localization pre-training and Vision-Language Pre-training (VLP) with three pre-training tasks: phrase grounding as a VL reformulation of the detection task, region-word contrastive learning as a novel region-word level contrastive learning task, and the masked language modeling. This unification not only simplifies the previous multi-stage VLP procedure but also achieves mutual benefits between localization and understanding tasks. Experimental results show that a single GLIPv2 model (all model weights are shared) achieves near SoTA performance on various localization and understanding tasks. The model also shows (1) strong zero-shot and few-shot adaption performance on open-vocabulary object detection tasks and (2) superior grounding capability on VL understanding tasks. Code is released at https://github.com/microsoft/GLIP.
|
| 10 |
+
|
| 11 |
+
# 1 Introduction
|
| 12 |
+
|
| 13 |
+
Recently, a general interest arises in building general-purpose vision systems [21, 24, 56, 42], also called vision foundation models [6, 57], that solve various vision tasks simultaneously, such as image classification [30], object detection [39], and Visual-Language (VL) understanding [3, 11, 27]. Of particular interest, is the unification between localization tasks (e.g., object detection [39] and segmentation [8, 20]) and VL understanding tasks (e.g., VQA [3] and image captioning [11]). Localization pre-training benefits VL tasks [1, 59], and the “localization- $\mathrm { . > V L P ^ { \prime } }$ two-stage pretraining procedure [41, 49, 13, 48, 34, 32, 61, 37, 35] is the common practice in VL community. A long-standing challenge is the unification of localization and understanding, which aims at mutual benefit between these two kinds of tasks, simplified pre-training procedure, and reduced pre-training cost.
|
| 14 |
+
|
| 15 |
+
However, these two kinds of tasks appear to be dramatically different: localization tasks are visiononly and require fine-grained output (e.g., bounding boxes or pixel masks), while VL understanding tasks emphasize fusion between two modalities and require high-level semantic outputs (e.g., answers or captions).
|
| 16 |
+
|
| 17 |
+
[21, 24, 56] have made early attempts at unifying these tasks in a straightforward multi-task manner, where a low-level visual encoder is shared across tasks, and two separate high-level branches are designed for localization and VL understanding, respectively. The localization tasks are still vision-only and do not benefit from the rich semantics in vision-language data. As a result, such unified models see the marginal mutual benefit or even performance degradation [24] compared with task-specific models.
|
| 18 |
+
|
| 19 |
+
In this paper, we identify “VL grounding” as a “meta”-capability for localization and understanding capabilities. VL grounding involves not only understanding an input sentence but also localizing the mentioned entities in the image (see an example in Figure 1). We build a grounded VL understanding model (GLIPv2) as a unified model for localization and VL understanding tasks.
|
| 20 |
+
|
| 21 |
+

|
| 22 |
+
Figure 1: Left: GLIPv2, a pre-trained grounded VL understanding model, unifies various localization and VL understanding tasks. These two kinds of tasks mutually benefit each other, and enables new capabilities such as language-guided detection/segmentation and grounded VQA/captioning. Right: Additional examples from ODinW (detection), LVIS (segmentation), VQA, COCO Captioning.
|
| 23 |
+
|
| 24 |
+
Localization ${ \bf \Pi } + { \bf \delta V L }$ understanding $=$ grounded VL understanding. Localization tasks involve both localization and semantic classification, where classification can be cast as a VL understanding problem using the classification-to-matching trick (Section 3.1). Therefore, we reformulate localization tasks as VL grounding tasks, in which the language input is a synthesized sentence as the concatenation of category names [36]. Localization data are turned into VL grounding data, accordingly. The massive VL understanding data (image-text pairs) can be easily turned into VL grounding data in a self-training manner [36]. Therefore, GLIPv2 has a unified pre-training process: all task data are turned into grounding data and GLIPv2 is pre-trained to perform grounded VL understanding.
|
| 25 |
+
|
| 26 |
+
A stronger VL grounding task: inter-image region-word contrastive learning. GLIP [36] proposes the phrase grounding task as its pre-training task, which we argue is an easy task and does not fully utilize data information. For example, in the VL grounding task in Figure 1, the phrase grounding task only requires the model to match a given image region to one of the three phrases in the text input, i.e., “green, pink striped, or plain white umbrella?”. This 1-in-3 choice is very easy, only requires color understanding, but loses lots of information in this grounding data: the umbrellas are not any other colors, like black, yellow, etc; objects in those regions are umbrellas but not any other categories, like car, bike, etc. From a contrastive learning view, this phrase grounding task only has two negatives. More negatives can be created from this annotation and thus enable stronger contrastive learning. In GLIPv2, we introduce the novel inter-image region-word contrastive learning task, which leverages phrases from other sentences in the same batch as potential negatives, as another much stronger VL grounding task. This new region-word contrastive loss enables GLIPv2 to learn more discriminative region-word features and demonstrates improvements over all downstream tasks.
|
| 27 |
+
|
| 28 |
+
GLIPv2 achieves mutual benefit between localization and VL understanding. 1) Experimental results (Table 2) show that a single GLIPv2 model (all model weights are shared) achieves near SoTA performance on various localization and understanding tasks. 2) Thanks to semantic-rich annotations from the image-text data, GLIPv2 shows superior zero-shot and few-shot transfer learning ability to open-world object detection and instance segmentation tasks, evaluated on the LVIS dataset and the "Object Detection in the Wild (ODinW)" benchmark. 3) GLIPv2 enables language-guided detection and segmentation ability, and achieves new SoTA performance on the Flick30K-entities phrase grounding and PhraseCut referring image segmentation tasks. 4) Inherently a grounding model, GLIPv2 leads to VL understanding models with strong grounding ability, which are self-explainable and easy to debug. For example, GLIPv2, when GLIPv2 is finetuned on VQA, it can answer questions while localizing mentioned entities (see Figure 1 and Section 4.4).
|
| 29 |
+
|
| 30 |
+
# 2 Related Work
|
| 31 |
+
|
| 32 |
+
Localization models. Traditionally, localization tasks such as object detection and segmentation are single-modality and output bounding boxes or pixel masks [45, 38, 23, 14, 46, 10, 9]. One challenge of these single-modality models lies in generalization to rare and novel concepts: it is hard to collect localization data that cover many rare categories [20]. A long line of research focuses on this generalization problem, under the name of zero-shot [4, 62, 7, 63], weakly-supervised [18, 5, 52], or open-vocabulary [58, 19] localization. Built upon MDETR [25] and GLIP [36], GLIPv2 converts localization tasks into a grounded vision-language task using the classification-to-matching trick (Section 3). Thus GLIPv2 can learn from the semantic-rich vision-language data and shows strong performance on open-vocabulary localization tasks.
|
| 33 |
+
|
| 34 |
+
Vision-language understanding models. Vision-language (VL) understanding tasks such as VQA [3], image captioning [11], and image-text retrieval [26] involve understanding visual semantics and how they are expressed in natural language. Many VL models (e.g., BUTD) [2, 59] rely on a pre-trained localization model as their visual encoder; the downside is the pro-longed “localization- $\mathrm { . > V L P ^ { \prime } }$ pre-training pipeline [41, 49, 13, 48, 34, 32, 61, 37, 35]. In contrast, GLIPv2 simplifies the pre-training pipeline and enables grounded VL understanding for better interpretability (Section 4.4).
|
| 35 |
+
|
| 36 |
+
Unifying localization and understanding. [21, 24, 56] made pioneering efforts in unifying localization and understanding. However, localization tasks are still treated as single-modality tasks, while VL tasks involve two modalities. The unification is achieved via straightforward multi-tasking: a low-level visual encoder is shared across tasks and two separate branches are designed for localization and VL understanding. Such unified models do not bring evident mutual benefit and often underperform task-specific models. In contrast, GLIPv2 identifies grounded VL understanding as a meta-task for localization and understanding. The task unification brings architecture unification: the unified grounded VL understanding model empowers a localization branch with VL capacity, arriving at a unified branch that excels at both tasks.
|
| 37 |
+
|
| 38 |
+
GLIPv2 vs GLIP. 1) GLIP shows that grounded pre-training improves localization. GLIPv2 further shows grounded pre-training improves VL understanding and thus leads to a unified model for localization and VL understanding. 2) GLIPv2 introduces the inter-image region-word contrastive loss, which is another and stronger grounding task than the pre-training task in GLIP. The proposed loss can be viewed as a region-word level generalization of the prevalent image-level contrastive learning [33, 44, 55]. 3) GLIPv2 outperforms GLIP on all benchmarks with the same pre-training data.
|
| 39 |
+
|
| 40 |
+
# 3 GLIPv2: Unifying Localization and VL Understanding
|
| 41 |
+
|
| 42 |
+
Based on the reformulation of object detection as a generalized phrase grounding task in GLIP [36], we unify both localization and VL understanding tasks as grounded vision-language tasks. A grounded vision-language task takes both image and text as inputs, and outputs region-level understanding results (e.g., detection, segmentation) and/or image-level understanding results with associated grounding/localization information (e.g., VQA, image captioning). We will present the unified grounded VL formulation and architecture in Section 3.1, the pre-training losses in Section 3.2, and transfer to downstream tasks in Section 3.3.
|
| 43 |
+
|
| 44 |
+
# 3.1 A Unified VL Formulation and Architecture
|
| 45 |
+
|
| 46 |
+
At the center of GLIPv2’s unified formulation is the classification-to-matching trick, which reformulates any task-specific fixed-vocab classification problem as an task-agnostic open-vocabulary vision-language matching problem. The best example is the reformulation of image classification as image-text matching in CLIP [44], which enables the model to learn from raw image-text data directly, and achieves strong zero-shot results on open-vocabulary classification tasks. In GLIPv2, we replace every semantic classification linear layer in traditional single-modality vision models with a vision-language matching dot-product layer.
|
| 47 |
+
|
| 48 |
+
As illustrated in Figure 1, GLIPv2’s unified VL architecture is based on the generic architecture we term Architecture $\mathbf { I I }$ . It consists of a dual encoder, denoted as $\operatorname { E n c } _ { V }$ and $\mathrm { E n c } _ { L }$ , and a fusion encoder, denoted as $\mathtt { E n c } _ { V L }$ . The model takes an image-text pair (Img, Text) as input, and extract visual and text features as below:
|
| 49 |
+
|
| 50 |
+
$$
|
| 51 |
+
\begin{array} { r } { \dot { O } = \mathrm { E n c } _ { V } ( \mathrm { I m g } ) , \quad \mathring { P } = \mathrm { E n c } _ { L } ( \mathrm { T e x t } ) , \quad O , P = \mathrm { E n c } _ { V L } ( \mathring { O } , \mathring { P } ) , } \end{array}
|
| 52 |
+
$$
|
| 53 |
+
|
| 54 |
+
where $( \mathring { O } , \mathring { P } )$ and $( O , P )$ denote the image/text features before and after VL fusion, respectively.
|
| 55 |
+
|
| 56 |
+
Vision-Language understanding tasks. Arch $\mathbf { I I }$ is the most popular model architecture for VL understanding tasks. Given the cross-modality fused representations $O$ and $P$ , it is straightforward to add lightweight task-specific heads for various VL tasks. For example, GLIPv2 adds a two-layer MLP on top of text features $P$ as the masked language modeling (MLM) head, to perform the MLM pre-training. We provide model details of VQA and image captioning in Section 3.3.
|
| 57 |
+
|
| 58 |
+
(Language-guided) object detection and phrase grounding. Following GLIP [36], GLIPv2 uses the classification-to-matching trick to unify detection and grounding. More specifically, for detection, we simply replace the class logits $S _ { \mathrm { c l s } } = \dot { O } W ^ { T }$ , where $W$ is the weight matrix of the box classifier, with a task-agnostic region-word similarity logits $S _ { \mathrm { g r o u n d } } = O P ^ { T }$ , where text features $P$ are label embeddings from a task-agnostic language encoder. As shown in Figure 1, object detection and phrase grounding share the same input/output format and model architecture. See GLIP [36] for more details. Their only difference is the input text format: (1) for object detection, the text input is a string of concatenated candidate object labels; (2) for phrase grounding, the text input is a natural language sentence. We refer to GLIP [36] for more details.
|
| 59 |
+
|
| 60 |
+
(Language-guided) instance segmentation and referring image segmentation. Given the object detection results, an instance segmentation head is added to classify each pixel within the box into a semantic class. Again, GLIPv2 uses the classification-to-matching trick to produce a unified instance segmentation head for the standard instance segmentation tasks and the referring image segmentation tasks and leverage both types of data for its pre-training. This classification-to-matching trick can also apply to many other semantic classification heads in single modality CV models (e.g., semantic segmentation) and thus transfers them to language-guided CV models.
|
| 61 |
+
|
| 62 |
+
# 3.2 GLIPv2 Pre-training
|
| 63 |
+
|
| 64 |
+
The GLIPv2 is pre-trained with three pre-training losses: phrase grounding loss $\mathcal { L } _ { \mathrm { g r o u n d } }$ from a vision-language reformulation of the object detection task, region-word contrastive loss ${ \mathcal { L } } _ { \mathrm { { i n t e r } } }$ from a novel region-word level contrastive learning task, and the standard masked language modeling loss ${ \mathcal { L } } _ { \mathrm { m l m } }$ proposed in BERT [16].
|
| 65 |
+
|
| 66 |
+
$$
|
| 67 |
+
{ \mathcal { L } } _ { \mathrm { G L I P v 2 } } = \underbrace { { \mathcal { L } } _ { \mathrm { l o c } } + { \mathcal { L } } _ { \mathrm { i n t r a } } } _ { { \mathcal { L } } _ { \mathrm { g r o u n d } } } + { \mathcal { L } } _ { \mathrm { i n t e r } } + { \mathcal { L } } _ { \mathrm { m l m } }
|
| 68 |
+
$$
|
| 69 |
+
|
| 70 |
+
Similar to losses in detection tasks, the grounding loss $\mathcal { L } _ { \mathrm { g r o u n d } }$ has two parts: the localization loss $\mathcal { L } _ { \mathrm { l o c } }$ trains localization heads with bounding-box supervision, e.g., RPN loss, box regression loss and/or centerness loss [50]; the intra-image region-word alignment loss ${ \mathcal { L } } _ { \mathrm { { i n t r a } } }$ is essentially the semantic classification/retrieval loss for each region.
|
| 71 |
+
|
| 72 |
+
Intra-image region-word alignment loss. Given one image-text pair (Img, Text), we obtain the image and text features after cross-modality fusion $O$ and $P$ . The Intra-image region-word alignment loss is computed by
|
| 73 |
+
|
| 74 |
+
$$
|
| 75 |
+
\mathcal { L } _ { \mathrm { i n t r a } } = l o s s ( O P ^ { T } ; T ) ,
|
| 76 |
+
$$
|
| 77 |
+
|
| 78 |
+
where $O P ^ { T }$ is the similarity score between image regions and word tokens, and $T$ is the target affinity matrix determined by the ground-truth annotations. The loss function loss is typically a cross-entropy loss for two-stage detectors [46] and a focal loss [38] for one-stage detectors.
|
| 79 |
+
|
| 80 |
+
However, as discussed in Section 1, this intra-image region-word contrastive learning is rather weak in the sense of contrastive learning, due to the limited number of phrases that can one caption can contain. GLIP [36] alleviates this problem by appending a few negative sentences to form a longer text input with more (negative) phrases. However, constrained by the maximal length of text tokens (256 in GLIP and GLIPv2), only a few negative sentences can be added and the number of negative phrases remains in the order of $1 0 \mathrm { { ^ { \circ } s } }$ . This small-negative-example problem also exists in detection data [36] when the input text cannot include all class names in a detection dataset, e.g., Objects365.
|
| 81 |
+
|
| 82 |
+
Inter-image region-word contrastive loss. In GLIPv2, we propose using phrases from other imagetext pairs in the same batch as negative examples, which effectively increases the number of negative examples to the order of 1000’s, with nearly negligible additional computational cost.
|
| 83 |
+
|
| 84 |
+
As in (1), given a batch of image-text pairs $( \mathrm { I m } { \bf g } ^ { i } , \mathrm { T e x t } ^ { i } ) _ { i = 1 } ^ { B }$ and their ground-truth annotations $( T ^ { i } ) _ { i = 1 } ^ { B }$ , the model produces the image and text features before and after VL fusion, denoted as $( \mathring { O } ^ { i } , \mathring { P } ^ { i } ) _ { i = 1 } ^ { B }$ and $( O ^ { i } , P ^ { i } ) _ { i = 1 } ^ { B }$ , respectively. Then as illustrated in Figure 2 (Left), a batch-wise similarity matrix Sbatchground and a batch-wise target affinity matrix $T ^ { \mathrm { b a t c h } }$ are constructed by considering all the image regions and text phrases across this batch. Their $( i , j )$ ’th blocks are obtained as below:
|
| 85 |
+
|
| 86 |
+
$$
|
| 87 |
+
S _ { \mathrm { g r o u n d } } ^ { \mathrm { b a t c h } } [ i , j ] = \bar { O } ^ { i } ( \bar { P } ^ { j } ) ^ { T } , \quad T ^ { \mathrm { b a t c h } } [ i , j ] = \left\{ \begin{array} { l l } { T ^ { i } , } & { \mathrm { i f ~ } i = j } \\ { \mathrm { o b t a i n e d ~ b y ~ l a b e l ~ p r o p a g a t i o n , } } & { \mathrm { o t h e r w i s e . } } \end{array} \right.
|
| 88 |
+
$$
|
| 89 |
+
|
| 90 |
+
The inter-image region-word contrastive loss is then defined as the standard bi-directional contrastive loss applied on all image regions and phrases in this batch:
|
| 91 |
+
|
| 92 |
+
${ \mathrm { ~ \dot { \ z } _ { \mathrm { { i n t e r } } } = \ c r o s s \_ e n t r o p y \mit \mathrm { \mit \mathrm { \ l o s s } ( \cal S \mit _ { \mathrm { { g r o u n d } } } ^ { \mathrm { b a t c h } } , \mit T \mathrm { ^ { b a t c h } , \ a x i s = 0 ) + \ c r o s s \mit \mathrm { _ { - } \ e n t r o p y \mit \mathrm { \mit { \mit \mathrm { \ l o s s } ( \cal S \mit _ { \mathrm { { g r o u n d } } } ^ { \mathrm { b a t c h } } , \mathrm { T \mathrm { ^ { b a t c h } , \ a x i s = 1 ) \mit . } } } } } } } } } $ (5)
|
| 93 |
+
|
| 94 |
+
Compared with that in the inter-image contrastive loss (3), the number of negatives is multiplied by batch size $B$ in this inter-image contrastive loss (5). We elaborate two important details in (4). (1) GLIPv2 uses the image text features $( \mathring { O } ^ { i } , \mathring { P } ^ { i } ) _ { i = 1 } ^ { B }$ before VL fusion, not $( O ^ { i } , P ^ { i } ) _ { i = 1 } ^ { B }$ after VL fusion, to compute the batch-wise similarity matrix in the inter-image contrastive loss (4). Otherwise, the image and text features after VL fusion would have seen the paired information (1), and thus the model can easily rule out the negatives from misaligned images/texts. (2) We cannot simply assign all regions and texts from unpaired image-text as negative pairs, as done in the standard contrastive loss in CLIP [44]. Instead, we determine the off-diagonal blocks in the target affinity matrix $T ^ { \mathrm { b a t c h } }$ by label propagation. For example, as illustrated in Figure 2 (Left), if a region is annotated as “person”, it should be a positive pair with all “person” phrases in detection-type texts. We do not propagate positives to grounding-type texts (natural sentences) because phrases in sentences carry contexts that are unique to that image-sentence pair.
|
| 95 |
+
|
| 96 |
+
Pre-training with both detection and paired-image-text data. GLIPv2 pre-training data is in the image-text-target triplet format (Img, Text, $T$ ), where the target affinity matrix $T$ contains the box-label localization annotations. We also use massive image-text pair data (Img, Text) to pre-train GLIPv2, by generating grounding boxes $\hat { T }$ for phrases in the text with the GLIP pre-trained model from [36]. The human-annotated OD/grounding data provides high-fidelity localization supervision, while the massive image-text data greatly improves the concept diversity for GLIPv2.
|
| 97 |
+
|
| 98 |
+
Second-stage pre-training of the segmentation head. GLIPv2 performs a second-stage pre-training of the language-guided segmentation head on both instance segmentation and image referring segmentation data, while fixing all other parts of the model.
|
| 99 |
+
|
| 100 |
+
# 3.3 Transfer GLIPv2 to Localization and VL Tasks
|
| 101 |
+
|
| 102 |
+
We introduce two ways to easily transfer GLIPv2 to various downstream tasks. In addition, GLIPv2 can perform conventional VL tasks (e.g., VQA) along with localization, effectively making every task we consider a “grounded VL understanding” task.
|
| 103 |
+
|
| 104 |
+
One model architecture for all. GLIPv2 can be transferred to downstream tasks by fine-tuning the model with an (optional) task-specific head. 1) For detection and segmentation tasks, no task-specific head is needed as the pre-training architecture can inherently perform detection and segmentation. 2) For $V L$ tasks: for VQA, a classification head is added on top of the hidden representation of the start-of-sequence token; for caption generation, we train with a unidirectional language modeling loss, which maximizes the likelihood of the next word given context. We use a unidirectional attention mask and prevent the image part from attending to the text in the fusion layers.
|
| 105 |
+
|
| 106 |
+
One set of weights for all. There is a growing interest in developing models that can be transferred to various tasks while only changing the least amount of parameters to save training time and storage cost [47, 31]. Following GLIP, GLIPv2 can be transferred to localization tasks in a zero-shot or a prompt-tuning setting (Section 4.2). One single GLIPv2 model can serve various tasks, where each task only keeps few or no parameters. Of particular interest is the prompt tuning setting. For a certain localization task, the text prompt is the same for all input images; thus, we could directly tune $\mathring { P }$ , a small prompt embedding matrix, to adapt GLIPv2 to new tasks. Prompt tuning in a deep-fused model such as GLIPv2 is different from the conventional linear probing/prompt tuning setting [53, 44, 60] in shallow-interacting vision models such as CLIP. The latter can also be viewed as only tuning a small prompt/softmax embedding $P$ ; however, tuning $P$ only affects the very last layer of the model while the visual representation is still frozen. In contrast, GLIP/GLIPv2’s visual representation is conditioned on the prompt embedding $\mathring { P }$ ; tuning $\mathring { P }$ changes the text, visual, as well as fused embeddings. As a result, prompt tuning in GLIPv2 is highly effective, often matching the performance of fine-tuning (see Table 2). This is in contrast to the common observation in CV that linear probing lags behind fine-tuning by a large gap [22].
|
| 107 |
+
|
| 108 |
+

|
| 109 |
+
Figure 2: GLIPv2 pre-training losses: the intra-image alignment loss ${ \mathcal { L } } _ { \mathrm { { i n t r a } } }$ (right) takes features after VL fusion and compute loss over region-word pairs within each image-text pair; the inter-image contrastive loss (left) ${ \mathcal { L } } _ { \mathrm { { i n t e r } } }$ takes features before VL fusion and computes loss over all region-word pairs across a batch of image-text pairs. Label propagation is used to determine the off-diagonal blocks of the ${ \mathcal { L } } _ { \mathrm { { i n t e r } } }$ target matrix (4).
|
| 110 |
+
|
| 111 |
+
Grounded VL understanding. GLIPv2 also enables grounded VL understanding, where we retain the ability to perform grounding when fine-tuning the model to a downstream VL task. This increases the interpretability of the model. Specifically, we first turn the VL data of the downstream task into grounded VL data using a pre-trained GLIP model. Then we train the model with both the downstream task head and grounding head. For VQA, the model is trained to predict the answer and ground entities in the question as well as the implied entity in the answer; for captioning, the model is trained to predict the next word given the context and ground the current decoded word. By tuning localization tasks into a grounded VL task and augmenting VL tasks with grounding ability, we effectively turn every task into a grounded VL understanding task (see examples in Figure 1).
|
| 112 |
+
|
| 113 |
+
# 4 Experiments
|
| 114 |
+
|
| 115 |
+
In this section, we show that GLIPv2 serves as a performant and easy-to-deploy general-purpose vision system. 1) One Model Architecture for All (Section 4.1). GLIPv2 can be directly fine-tuned to both localization and VL understanding tasks with minimal architecture change. It achieves performance on par with SOTA models with specialized architectures. 2) One Model Weight for All (Section 4.2). GLIPv2 can be transferred to localization tasks in a zero-shot manner with zero parameter update; with prompt tuning, a single GLIPv2 model can achieve comparable performance with fully fine-tuned settings on both localization and understanding tasks.
|
| 116 |
+
|
| 117 |
+
<table><tr><td>Model</td><td>Model Type</td><td>COCO-Det (test-dev)</td><td>ODinW (test)</td><td>LVIS (minival)</td><td>COCO-Mask (test-dev)</td><td>Flickr30K PhraseCut (test)</td><td>(test)</td><td>VQA (test-dev/test-std) (Karpathy-test)</td><td>Captioning</td></tr><tr><td>Mask R-CNN [23]</td><td rowspan="4"></td><td>39.8</td><td>-</td><td>33.3/-</td><td>-/37.1</td><td>=</td><td>=</td><td></td><td></td></tr><tr><td>DETR[9]</td><td>42.0</td><td></td><td>17.8/-</td><td>=</td><td></td><td>=</td><td></td><td></td></tr><tr><td>DyHead-T[15]</td><td>49.7</td><td>60.8</td><td>=</td><td>=</td><td>=</td><td></td><td></td><td></td></tr><tr><td>DyHead-L [15]</td><td>60.3*</td><td>=</td><td>=</td><td></td><td></td><td>=</td><td></td><td></td></tr><tr><td>VisualBERT[34]</td><td rowspan="3">Understanding</td><td>=</td><td></td><td></td><td></td><td>71.33</td><td>=</td><td>70.8/71.0</td><td>=</td></tr><tr><td>UNITER[12]</td><td></td><td></td><td></td><td></td><td>=</td><td>=</td><td>73.8/74.0</td><td>=</td></tr><tr><td>VinVL[59]</td><td></td><td></td><td></td><td></td><td>=</td><td></td><td>76.5/76.6</td><td>130.8</td></tr><tr><td>GPV[21]</td><td rowspan="3">Localization &</td><td></td><td></td><td>=</td><td></td><td>·</td><td>=</td><td>62.5/-</td><td>102.3</td></tr><tr><td>UniT[24]</td><td>42.3</td><td>=</td><td></td><td></td><td></td><td></td><td>67.6/-</td><td>=</td></tr><tr><td>MDETR[25]</td><td>=</td><td>=</td><td>24.2/-</td><td>=</td><td>84.3</td><td>53.7</td><td>70.6 /70.6</td><td>■</td></tr><tr><td>Unicorn [56]</td><td rowspan="3">Understanding Localization &</td><td>=</td><td>■</td><td>=</td><td></td><td>80.4</td><td>=</td><td>69.2/69.4</td><td>119.1</td></tr><tr><td>GLIP-T[36]</td><td>55.2</td><td>64.9</td><td>=</td><td>=</td><td>85.7</td><td>-</td><td>=</td><td>-</td></tr><tr><td>GLIP-L [36]</td><td>Understanding 61.5*</td><td>68.9</td><td>=</td><td>=</td><td>87.1</td><td>-</td><td>=</td><td>-</td></tr><tr><td>GLIPv2-T(Ours)</td><td>Localization</td><td>55.5</td><td>66.5</td><td>50.6/41.4</td><td>53.5/42.0</td><td>86.5</td><td>59.4</td><td>71.6/71.8</td><td>122.1</td></tr><tr><td>GLIPv2-B (Ours)</td><td>&</td><td>58.8</td><td>69.4</td><td>57.3/46.2</td><td>59.0/45.8</td><td>87.5</td><td>61.3</td><td>73.1/73.3</td><td>128.5</td></tr><tr><td>GLIPv2-H(Ours)</td><td>Understanding</td><td>60.6 (62.4*)</td><td>70.4</td><td>59.8 / 48.8</td><td>59.8 / 48.9</td><td>87.7</td><td>61.3</td><td>74.6/74.8</td><td>131.0</td></tr></table>
|
| 118 |
+
|
| 119 |
+
Table 1: One model architecture results. For COCO-Det test-dev, \* indicates multi-scale evaluation. For LVIS, we report the numbers for both bbox and segm on minival to avoid data contamination due to the pre-training. For Flickr30K test, we report the metric under R@1. For COCO-Mask, we also report both bbox and segm on test-dev.
|
| 120 |
+
|
| 121 |
+
Following GLIP [36], we adopt Swin Transformer [40] as the image encoder $\operatorname { E n c } _ { V }$ , text transformers [51, 44] as the text encoder $\mathrm { E n c } _ { L }$ , Dynamic Head [15] with language-aware deep fusion [36] as the fusion encoder $\mathtt { E n c } _ { V L }$ , and Hourglass network [43] as instance segmentation head feature extractor. We train GLIPv2 at three scales: GLIPv2-T, GLIPv2-B, and GLIPv2-H.
|
| 122 |
+
|
| 123 |
+
GLIPv2-T has the same model config and initialization as GLIP-T: Swin-Tiny and BERT-Base as the dual encoder. The model is pre-trained on the following data: 1) O365, 2) GoldG as in GLIP-T (C), and 3) Cap4M, 4M image-text pairs collected from the web with boxes generated by GLIP-T [36]. GLIPv2-B/GLIPv2-H are based on Swin-Base/Swin-Huge and the pre-layernorm text transformer [17] as dual encoder, and are initialized from the UniCL [55] checkpoints. We observe much stabler training with GPT-type pre-layernorm transformer [17] than BERT-type post-layernorm transformer. The training data contain: 1) FiveODs (2.78M data) 1; 2) GoldG as in MDETR [25]; and 3) C $\mathrm { C 1 5 M + S B U }$ , 16M public image-text data with generated boxes by GLIP-L [36]. Segmentation heads of GLIPv2 models are pre-trained on COCO, LVIS [20] and PhraseCut [54], with all other model parameters are frozen.
|
| 124 |
+
|
| 125 |
+
Note All datasets above were collected by the creators (cited) and consent for any personally identifiable information (PII) was ascertained by the authors where necessary. Due to limited space, we refer to supplementary for details of training recipes and hyper-parameters.
|
| 126 |
+
|
| 127 |
+
# 4.1 One Model Architecture for All
|
| 128 |
+
|
| 129 |
+
We compare GLIPv2 to existing object detection and vision-language pre-training methods on a wide range of tasks. We fine-tune the model on 8 different downstream tasks and report the performance in Table 1. We make the following observations.
|
| 130 |
+
|
| 131 |
+
GLIPv2 v.s. specialized Localization methods. GLIPv2 outperforms previous localization models on generalization to both common and rare classes and domains with a single model architecture and pre-training stage. 1) OD on common categories (COCO-Det), GLIPv2-T achieves 5.8 improvement compared to the standard DyHead-T trained on O365 (55.5 v.s. 49.7). GLIPv2-H reaches $6 2 . 4 \mathrm { A P }$ on test-dev, and surpass the performance of the previous SoTA model GLIP-L. 2) OD on rare / unseen categories (LVIS), GLIPv2-T outperforms a supervised MDETR on the bbox by a great margin (59.8 v.s. 24.2). 3) Generalization to diverse real-word tasks (ODinw), GLIPv2-T (55.5) performs better than original GLIP-T (64.9) on the average of 13 public datasets; GLIPv2-B outperforms GLIP-L by 0.5 AP. 4) Instance segmentation (COCO-Mask & PhraseCut), for traditional instance segmentation (i.e., COCO-Mask), GLIPv2-H outperforms the well-known Mask R-CNN by a great margin on segm.
|
| 132 |
+
|
| 133 |
+
Table 2: One set of weights results v.s. Original GLIP. \* indicates multi-scale evaluation. Numbers in red clearly points out the difference between the prompt tuning and full fine-tuning results (see Table 1). Numbers in gray mean that they are not in zero-shot manner. $\dagger$ : these two numbers are artificially high due to some overlap between COCO-minival and VisualGenome-train.
|
| 134 |
+
|
| 135 |
+
<table><tr><td rowspan="2">Model</td><td colspan="4">Direct Evaluation</td><td colspan="5">Prompt Tuning</td></tr><tr><td>COCO-Mask (minival)</td><td>ODinW (test)</td><td>LVIS-Det (minival)</td><td>Flickr30K (minival)</td><td>COCO-Det (test-dev)</td><td>ODinW (test)</td><td>LVIS (minival)</td><td>COCO-Mask (test-dev)</td><td>PhraseCut (test)</td></tr><tr><td>GLIP-T</td><td>46.6/-</td><td>46.5</td><td>26.0</td><td>85.7</td><td>二</td><td>46.5</td><td>-</td><td>-</td><td>-</td></tr><tr><td>GLIP-L</td><td>49.8/-</td><td>52.1</td><td>37.3</td><td>87.1</td><td>58.8</td><td>67.9</td><td>=</td><td>=</td><td>-</td></tr><tr><td>GLIPv2-T</td><td>47.3/35.7</td><td>48.5</td><td>29.0</td><td>86.0</td><td>53.4 (-2.1)</td><td>64.8 (-1.7)</td><td>49.3 / 34.8 (-13/-6.6)</td><td>53.2 / 41.2 (-0.3/-0.8)</td><td>49.4</td></tr><tr><td>GLIPv2-B</td><td>61.9†/43.4</td><td>54.2</td><td>48.5</td><td>87.2</td><td>59.0 (+0.2)</td><td>67.3 (-2.1)</td><td>56.8 / 41.7 (-0.5/-4.5)</td><td>58.8 / 44.9 (-0.2/-0.9)</td><td>55.9</td></tr><tr><td>GLIPv2-H</td><td>64.1/47.4</td><td>55.5</td><td>50.1</td><td>87.7</td><td>60.2 /61.9* (-0.4 /-0.5)</td><td>69.1 (-1.3)</td><td>59.2 / 43.2 (-0.6/-5.7)</td><td>59.8 / 47.2 (-0.0/-1.7)</td><td>56.1</td></tr></table>
|
| 136 |
+
|
| 137 |
+

|
| 138 |
+
Figure 3: Data efficiency of GLIPv2 on ODinW. The $\mathbf { X }$ -axis is the amount of task-specific data, from zero-shot to all data. Y-axis is the average AP across 13 datasets.
|
| 139 |
+
|
| 140 |
+
Table 3: Zero-shot, prompt tuning, and full finetuning performance on ODinW. GLIPv2 models exhibit superior data efficiency.
|
| 141 |
+
|
| 142 |
+
<table><tr><td rowspan="2">Model</td><td rowspan="2">Zero-Shot 0</td><td colspan="5">Prompt Tuning /Fine Tuning</td></tr><tr><td>1</td><td>3</td><td>5</td><td>10</td><td>All</td></tr><tr><td rowspan="2">DyHead-T 0365 [36]</td><td rowspan="2">-</td><td>=</td><td></td><td>-</td><td>-</td><td>-</td></tr><tr><td>33.8</td><td>43.6</td><td>46.4</td><td>50.8</td><td>60.8</td></tr><tr><td rowspan="2">Lloc + Lintra (GLIP-T)</td><td rowspan="2">46.5</td><td>49.9</td><td>53.7</td><td>55.5</td><td>56.6</td><td>62.4</td></tr><tr><td>51.3</td><td>54.9</td><td>56.4</td><td>58.4</td><td>64.9</td></tr><tr><td rowspan="2">Lloc + Lintra +Linter</td><td rowspan="2">48.4</td><td>52.1</td><td>55.6</td><td>56.7</td><td>58.3</td><td>62.9</td></tr><tr><td>51.4</td><td>55.3</td><td>56.6</td><td>59.5</td><td>66.3</td></tr><tr><td rowspan="2">Lloc +Lintra +Linter +Cmm</td><td rowspan="2">48.5</td><td>52.4</td><td>55.6</td><td>57.4</td><td>58.8</td><td>64.8</td></tr><tr><td>52.8</td><td>55.6</td><td>57.4</td><td>59.7</td><td>66.5</td></tr></table>
|
| 143 |
+
|
| 144 |
+
For language-guided segmentation (i.e., PhraseCut), compared to MDETR, GLIPv2-T achieves an improvement of 5.7 mask AP.
|
| 145 |
+
|
| 146 |
+
GLIPv2 v.s. specialized VL Understanding methods. GLIPv2 rivals with SoTA specialized models for VL tasks. 1) For VQA, GLIPv2 outperforms VisualBERT and UNITER and approaches the previous SoTA model VinVL. 2) For Captioning, the best GLIPv2 even surpasses VinVL (VinVL and GLIPv2 are not trained with CIDEr optimization).
|
| 147 |
+
|
| 148 |
+
GLIPv2 v.s. localization and VL models. Prior works such GPV, UniT and Unicorn have also explored unifying localization and VL models (see a discussion in Section 2). GLIPv2 outperforms all previous systems on both localization and VL tasks. For the best GLIPv2-H, it outperforms the UniT by a great margin (18.3 AP) on COCO object detection tasks. Meanwhile, it also surpasses UniT’s performance on VQA by 6.9 points and GPV’s peformance on Image Captioning as well.
|
| 149 |
+
|
| 150 |
+
Takeaway. Most notably, GLIPv2 outperforms previous “unified” models (GPV, UniT, MDETR, Unicorn) by a large margin. This is the first time that a single model architecture could achieve near SoTA performance on both localization and understanding. In contrast, in prior work, there exists certain trade-off between localization and understanding: models that aim to achieve high understanding performance tend to have lower localization performance (e.g., UNiT’s detection performance is limited to the DETR [9] architecture), as it is not trivial to merge a SoTA localization branch and a SoTA VL branch into a single model.
|
| 151 |
+
|
| 152 |
+
# 4.2 One Set of Model Parameters for All
|
| 153 |
+
|
| 154 |
+
GLIPv2 is pre-trained to perform grounding; thus it can be transferred to various localization tasks with changing zero or few parameters. We evaluate GLIPv2 under two such settings: 1) direct evaluation, where we transfer the model “as is” without any parameter change, and 2) prompt tuning, where only the prompt embedding is tuned for specific tasks (Section 3.3).
|
| 155 |
+
|
| 156 |
+
Direct evaluation. The pre-trained GLIPv2 can be directly evaluated on any object detection task (by concatenating the object categories into a text prompt) and visual grounding task without any further tuning. We evaluate the models on four localization tasks: COCO, ODinW, LVIS, and Flickr30, and their results are presented in Table 2. Note that for GLIPv2-B and GLIPv2-H, the training sets of Flick30K and LVIS are present in the pre-training data. Thus, reported numbers on these metrics are not zero-shot evaluation (we have marked them gray). For all other evaluation results, the models are evaluated in zero-shot settings without any further tuning.
|
| 157 |
+
|
| 158 |
+
GLIPv2 can be effortlessly transferred to different localization tasks without further tuning. 1) For COCO, GLIPv2-T achieves a zero-shot performance of 47.3 without seeing any COCO training images. This surpasses well-established supervised systems (e.g., Mask R-CNN) and also outperforms GLIP-T by 0.7 AP. 2) For ODinW, GLIPv2 also shows strong zero-shot performance. GLIPv2-T (48.5) surpasses the GLIP-T (46.5). Meanwhile, the zero-shot performance of GLIPv2-B and GLIPv2- H even surpasses the 10-shot tuning performance of DyHead-T (to be introduced in Figure 3). 3) For LVIS, GLIPv2-T achieves a 3 AP improvement performance compared to the GLIP-T. 4) For Flickr30K, GLIPv2-B achieves even higher number (87.2) compared to original GLIP-L (87.1).
|
| 159 |
+
|
| 160 |
+
Prompt Tuning. Following GLIP, GLIPv2 supports efficient prompt tuning: the visual representation is heavily conditioned on the text representation due to the deep fusion block (Section 3.3); thus we could fine-tune only the prompt embedding for each task but still maintain high performance.
|
| 161 |
+
|
| 162 |
+
Prompt tuning $G L I P \nu 2$ achieves similar performance as full fine-tuning. When comparing the performance of each task in Table 1 and 2 at the same time, for GLIPv2, prompt tuning performance almost matches the one model architecture results on localization tasks, without changing any of the grounding model parameters.
|
| 163 |
+
|
| 164 |
+
# 4.3 GLIPv2 as a Strong Few-Shot Learner
|
| 165 |
+
|
| 166 |
+
We demonstrate GLIPv2’s performance on ODinW datasets with respect to different amounts of training data in Figure 3. The performance improvement between GLIPv2-T and GLIP-T exhibits more superior data efficiency for prompt tuning. We compare with the SoTA detector DyHead-T, pre-trained on Objects365 in Table 3. It can be seen that a zero-shot GLIPv2-T (48.5) outperforms a outperforms 5-shot DyHead-T (46.4) while the performance of one-shot GLIPv2-H (61.3) surpasses a all-shot fully supervised DyHead-T (60.8).
|
| 167 |
+
|
| 168 |
+
# 4.4 Analysis
|
| 169 |
+
|
| 170 |
+
Pre-training losses Table 4 shows the performance of the downstream tasks with different variants of our method. Compared to the GLIP pre-training tasks with only intra-image region-word contrastive loss (Row 3), adding inter-image word-region loss (Row 5) substantially improves the pre-trained model performance across all the object detection tasks (COCO, ODinW, and LVIS) on both zero-shot and fine-tuned manner. Consistent with common observations from most VL understanding methods, adding MLM loss (Row4) benefits for learning the representation for understanding tasks (Flick30k, VQA, and Captioning). Furthermore, using all three losses together at the 1st stage pre-training and doing the 2nd stage pre-training without MLM on OD and GoldG data, GLIPv2 (Row6) can perform well on both the localization and VL understanding tasks.
|
| 171 |
+
|
| 172 |
+
An additional stage of pre-training is applied for small models (GLIPv2-T and GLIPv2-B) due to limited model capacity. In order to achieve higher performance on both localization and understanding tasks, we find that including all data (even with some noise) and MLM loss in the first stage of pre-training will benefit the model for learning a better representation of both localization and understanding capability. Since the OD tasks require the model with more accurate localization ability, in our 2nd stage of pre-training, we decide to eliminate the MLM loss. The large model (GLIPv2-H) does not need this additional stage because it has enough capacity to learn both wordregion alignment and MLM together in a single stage.
|
| 173 |
+
|
| 174 |
+
Pre-training data Table 5 reports the last checkpoint results on GLIPv2 when we do the scaling up of pre-training data. As more weak image-text pair data (Cap) is involved in our training, it benefits both standard/in-domain (i.e., COCO, Flickr30K) and large-domain gap (i.e., ODinW, LVIS) tasks. We also show that by adding the inter-image region-word contrastive helps when we are fixing the data at the same scale. For large-domain gap tasks, adding the inter-image region-word contrastive
|
| 175 |
+
|
| 176 |
+
<table><tr><td>Row Model</td><td></td><td>COCO</td><td>ODinW</td><td>LVIS|Flickr30K VQA Captioning</td><td></td><td></td><td></td></tr><tr><td>1</td><td>No pre-train</td><td>-/50.6</td><td>-/60.8</td><td>1</td><td>1</td><td>64.6</td><td>111.5</td></tr><tr><td>2</td><td>+Lmlm</td><td>-/48.5</td><td>-/37.4</td><td>1</td><td>1</td><td>64.6</td><td>110.9</td></tr><tr><td>3</td><td>+ Lloc+Lintra</td><td></td><td>46.6/55.2 46.5/64.9</td><td>26.0</td><td>85.7</td><td>69.4</td><td>119.7</td></tr><tr><td>4</td><td>+Lloc+Lintra+Lmlm</td><td></td><td>47.0/55.2 47.6/66.2</td><td>28.5</td><td>86.5</td><td>69.8</td><td>120.7</td></tr><tr><td>5</td><td>+Lloc+Lintra+Linter</td><td></td><td>47.1/55.4 48.4/66.3</td><td>28.6</td><td>85.8</td><td>68.7</td><td>120.4</td></tr><tr><td>6</td><td>+Lloc+Lintra+Linter+Lmlm</td><td></td><td>47.3/55.5 48.5/66.5</td><td>29.0</td><td>86.3</td><td>70.7</td><td>122.1</td></tr></table>
|
| 177 |
+
|
| 178 |
+
Table 4: Pre-training losses on Tiny-scale model. Involving intra-image region-word alignment loss $\mathcal { L } _ { \mathrm { { i n t r a } } }$ , inter-image region-word contrastive loss ${ \mathcal { L } } _ { \mathrm { i n t e r } }$ and MLM loss ${ \mathcal { L } } _ { \mathrm { m l m } }$ will benefit both localization and understanding tasks.
|
| 179 |
+
|
| 180 |
+
Table 5: Pre-train data scale up on Base-scale model. Results are reported at the last checkpoint. See supplementary for results at all checkpoints.
|
| 181 |
+
|
| 182 |
+
<table><tr><td>Linter</td><td>Pre-train Data</td><td>CoCo</td><td>ODinW</td><td>LVIS</td><td>Flick30K</td></tr><tr><td>X</td><td>0365,GoldG</td><td>48.06</td><td>43.14</td><td>25.6</td><td>84.36</td></tr><tr><td></td><td>0365,GoldG</td><td>48.59</td><td>42.64</td><td>26.9</td><td>83.90</td></tr><tr><td></td><td>0365,GoldG,Cap4M</td><td>48.21</td><td>51.35</td><td>34.2</td><td>85.56</td></tr><tr><td>X</td><td>0365,GoldG,Cap4M</td><td>48.79</td><td>52.70</td><td>35.0</td><td>85.50</td></tr><tr><td>×</td><td>0365,GoldG,Cap12M</td><td>48.50</td><td>49.32</td><td>35.5</td><td>85.79</td></tr><tr><td>√</td><td>0365,GoldG,Capl2M</td><td>49.26</td><td>53.15</td><td>36.6</td><td>85.84</td></tr></table>
|
| 183 |
+
|
| 184 |
+
Table 6: GLIPv2 can perform captioning and grounding at the same time (a.k.a., grounded VL understanding).
|
| 185 |
+
|
| 186 |
+
<table><tr><td>Model</td><td>COCO Caption B4 CIDEr</td><td>SPICE</td><td>R@1 R@5</td><td>Flickr30K Grounding</td><td>R@10°</td></tr><tr><td>GLIPv2-T</td><td>36.5</td><td>119.8 21.6</td><td>80.8</td><td>94.4</td><td>96.5</td></tr><tr><td>GLIPv2-B</td><td>37.4</td><td>123.0 21.9</td><td>81.0</td><td>94.5</td><td>96.5</td></tr></table>
|
| 187 |
+
|
| 188 |
+
loss will further boost the model to learn better representation. For more detailed scaling-up effects on various tasks under all the checkpoints for GLIP and GLIPv2, refer to Appendix.
|
| 189 |
+
|
| 190 |
+
Note that the (Img, Text, $T$ ) data used in GLIPv2 pre-training can be just human-annotated data (Row1&2 in Table 5), with which GLIPv2 pre-training does not involve any pseudo data from a pre-trained grounding/localization model. In order to achieve the best performance, GLIPv2 uses image-text pair data with pseudo boxes (Cap) from a pre-trained GLIP model (Row3-6 in Table 4), which is trained with the same "grounded VL understanding" task but just with smaller data.
|
| 191 |
+
|
| 192 |
+
Grounded Vision-Language Understanding GLIPv2 can be trained to perform a VL task and grounding at the same time (Section 3.3). We denote such an ability as grounded VL understanding. In Figure 1, we showcase grounded predictions of GLIPv2 on VQA and COCO captions. We also conduct quantitative evaluations (Table 6). The model achieves strong performance for both VL understanding (on COCO Caption) and localization (on Flickr30K Grounding). Such an ability to produce high-level semantic outputs (i.e., answers and captions) and supporting localization results is another appealing trait of GLIPv2, as potential users can have a better understanding of the model behaviour. See more detailed analysis and qualitative examples in the Appendix.
|
| 193 |
+
|
| 194 |
+
# 5 Conclusion and Social Impacts
|
| 195 |
+
|
| 196 |
+
This paper proposes GLIPv2, a unified framework for VL representation learning that serves both localization tasks and VL understanding tasks. We experimentally verify the effectiveness of the unified model and the novel region-word contrastive learning. Compared to existing methods, GLIPv2 achieves competitive near SoTA performance on various localization and understanding tasks. However, additional analysis of the data and the model is necessary before deploying it in practice since large-scale web data may contain unintended private information, unsuitable images/text, or some bias leakage. Further investigation may be needed for web data due to the above issues.
|
| 197 |
+
|
| 198 |
+
# 6 Acknowledgement
|
| 199 |
+
|
| 200 |
+
We thank anonymous reviewers for their comments and suggestions. Additional thanks go to the Microsoft Research Horizontal AI Team and Microsoft Alexander Multi-modal Team for providing computer resources for large-scale training. The baseline models used in our experiments are based on the open-source code released in the GitHub repository; we acknowledge all the authors who made their code public, which tremendously accelerates our project progress.
|
| 201 |
+
|
| 202 |
+
# References
|
| 203 |
+
|
| 204 |
+
top-down attention for image captioning and visual question answering. In: Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR). pp. 6077–6086. IEEE (2018)
|
| 205 |
+
[2] Anderson, P., He, X., Buehler, C., Teney, D., Johnson, M., Gould, S., Zhang, L.: 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. pp. 6077–6086 (2018)
|
| 206 |
+
[3] Antol, S., Agrawal, A., Lu, J., Mitchell, M., Batra, D., Zitnick, C.L., Parikh, D.: VQA: Visual Question Answering. In: International Conference on Computer Vision (ICCV) (2015)
|
| 207 |
+
[4] Bansal, A., Sikka, K., Sharma, G., Chellappa, R., Divakaran, A.: Zero-shot object detection. In: Proceedings of the European Conference on Computer Vision (ECCV). pp. 384–400 (2018)
|
| 208 |
+
[5] Bilen, H., Vedaldi, A.: Weakly supervised deep detection networks. In: Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. pp. 2846–2854 (2016)
|
| 209 |
+
[6] Bommasani, R., Hudson, D.A., Adeli, E., Altman, R., Arora, S., von Arx, S., Bernstein, M.S., Bohg, J., Bosselut, A., Brunskill, E., et al.: On the opportunities and risks of foundation models. arXiv preprint arXiv:2108.07258 (2021)
|
| 210 |
+
[7] Bucher, M., Vu, T.H., Cord, M., Pérez, P.: Zero-shot semantic segmentation. Advances in Neural Information Processing Systems 32 (2019)
|
| 211 |
+
[8] Caesar, H., Uijlings, J., Ferrari, V.: Coco-stuff: Thing and stuff classes in context. In: Proceedings of the IEEE conference on computer vision and pattern recognition. pp. 1209–1218 (2018)
|
| 212 |
+
[9] Carion, N., Massa, F., Synnaeve, G., Usunier, N., Kirillov, A., Zagoruyko, S.: End-to-end object detection with transformers. In: European Conference on Computer Vision. pp. 213–229. Springer (2020)
|
| 213 |
+
[10] Chen, K., Pang, J., Wang, J., Xiong, Y., Li, X., Sun, S., Feng, W., Liu, Z., Shi, J., Ouyang, W., et al.: Hybrid task cascade for instance segmentation. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. pp. 4974–4983 (2019)
|
| 214 |
+
[11] Chen, X., Fang, H., Lin, T.Y., Vedantam, R., Gupta, S., Dollár, P., Zitnick, C.L.: Microsoft COCO captions: Data collection and evaluation server. arXiv preprint arXiv:1504.00325 (2015)
|
| 215 |
+
[12] Chen, Y.C., Li, L., Yu, L., El Kholy, A., Ahmed, F., Gan, Z., Cheng, Y., Liu, J.: UNITER: Universal image-text representation learning. In: Proceedings of the European Conference on Computer Vision (ECCV). pp. 104–120. Springer (2020)
|
| 216 |
+
[13] Chen, Y.C., Li, L., Yu, L., Kholy, A.E., Ahmed, F., Gan, Z., Cheng, Y., Liu, J.: Uniter: Learning universal image-text representations. arXiv preprint arXiv:1909.11740 (2019)
|
| 217 |
+
[14] Dai, J., Li, Y., He, K., Sun, J.: R-fcn: Object detection via region-based fully convolutional networks. In: Advances in neural information processing systems. pp. 379–387 (2016)
|
| 218 |
+
[15] Dai, X., Chen, Y., Xiao, B., Chen, D., Liu, M., Yuan, L., Zhang, L.: Dynamic head: Unifying object detection heads with attentions. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. pp. 7373–7382 (2021)
|
| 219 |
+
[16] 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)
|
| 220 |
+
[17] Gao, P., Geng, S., Zhang, R., Ma, T., Fang, R., Zhang, Y., Li, H., Qiao, Y.: Clip-adapter: Better vision-language models with feature adapters. arXiv preprint arXiv:2110.04544 (2021)
|
| 221 |
+
[18] Gokberk Cinbis, R., Verbeek, J., Schmid, C.: Multi-fold mil training for weakly supervised object localization. In: Proceedings of the IEEE conference on computer vision and pattern recognition. pp. 2409–2416 (2014)
|
| 222 |
+
[19] Gu, X., Lin, T.Y., Kuo, W., Cui, Y.: Zero-shot detection via vision and language knowledge distillation. arXiv preprint arXiv:2104.13921 (2021)
|
| 223 |
+
[20] Gupta, A., Dollar, P., Girshick, R.: Lvis: A dataset for large vocabulary instance segmentation. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. pp. 5356–5364 (2019)
|
| 224 |
+
[21] Gupta, T., Kamath, A., Kembhavi, A., Hoiem, D.: Towards general purpose vision systems. arXiv preprint arXiv:2104.00743 (2021)
|
| 225 |
+
[22] He, K., Chen, X., Xie, S., Li, Y., Dollár, P., Girshick, R.: Masked autoencoders are scalable vision learners. arXiv preprint arXiv:2111.06377 (2021)
|
| 226 |
+
[23] He, K., Gkioxari, G., Dollár, P., Girshick, R.: Mask r-cnn. In: Proceedings of the IEEE international conference on computer vision. pp. 2961–2969 (2017)
|
| 227 |
+
[24] Hu, R., Singh, A.: Unit: Multimodal multitask learning with a unified transformer. In: Proceedings of the IEEE/CVF International Conference on Computer Vision. pp. 1439–1449 (2021)
|
| 228 |
+
[25] Kamath, A., Singh, M., LeCun, Y., Synnaeve, G., Misra, I., Carion, N.: Mdetr-modulated detection for end-to-end multi-modal understanding. In: Proceedings of the IEEE/CVF International Conference on Computer Vision. pp. 1780–1790 (2021)
|
| 229 |
+
[26] Karpathy, A., Joulin, A., Fei-Fei, L.F.: Deep fragment embeddings for bidirectional image sentence mapping. Advances in neural information processing systems 27 (2014)
|
| 230 |
+
[27] Kiros, R., Salakhutdinov, R., Zemel, R.S.: Unifying visual-semantic embeddings with multimodal neural language models. arXiv preprint arXiv:1411.2539 (2014)
|
| 231 |
+
[28] Krasin, I., Duerig, T., Alldrin, N., Ferrari, V., Abu-El-Haija, S., Kuznetsova, A., Rom, H., Uijlings, J., Popov, S., Veit, A., et al.: Openimages: A public dataset for large-scale multi-label and multi-class image classification. Dataset available from https://github. com/openimages 2(3), 18 (2017)
|
| 232 |
+
[29] Krishna, R., Zhu, Y., Groth, O., Johnson, J., Hata, K., Kravitz, J., Chen, S., Kalantidis, Y., Li, L.J., Shamma, D.A., et al.: Visual Genome: Connecting language and vision using crowdsourced dense image annotations. International Journal of Computer Vision (IJCV) 123(1), 32–73 (2017)
|
| 233 |
+
[30] Krizhevsky, A., Sutskever, I., Hinton, G.E.: Imagenet classification with deep convolutional neural networks. Advances in neural information processing systems 25, 1097–1105 (2012)
|
| 234 |
+
[31] Lester, B., Al-Rfou, R., Constant, N.: The power of scale for parameter-efficient prompt tuning. arXiv preprint arXiv:2104.08691 (2021)
|
| 235 |
+
[32] Li, G., Duan, N., Fang, Y., Jiang, D., Zhou, M.: Unicoder-VL: A universal encoder for vision and language by cross-modal pre-training. arXiv preprint arXiv:1908.06066 (2019)
|
| 236 |
+
[33] Li, J., Selvaraju, R., Gotmare, A., Joty, S., Xiong, C., Hoi, S.C.H.: Align before fuse: Vision and language representation learning with momentum distillation. Advances in Neural Information Processing Systems 34 (2021)
|
| 237 |
+
[34] Li, L.H., Yatskar, M., Yin, D., Hsieh, C.J., Chang, K.W.: Visualbert: A simple and performant baseline for vision and language. arXiv preprint arXiv:1908.03557 (2019)
|
| 238 |
+
[35] Li, L.H., You, H., Wang, Z., Zareian, A., Chang, S.F., Chang, K.W.: Unsupervised vision-andlanguage pre-training without parallel images and captions. arXiv preprint arXiv:2010.12831 (2020)
|
| 239 |
+
[36] Li, L.H., Zhang, P., Zhang, H., Yang, J., Li, C., Zhong, Y., Wang, L., Yuan, L., Zhang, L., Hwang, J.N., et al.: Grounded language-image pre-training. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. pp. 10965–10975 (2022)
|
| 240 |
+
[37] Li, X., Yin, X., Li, C., Zhang, P., Hu, X., Zhang, L., Wang, L., Hu, H., Dong, L., Wei, F., et al.: Oscar: Object-semantics aligned pre-training for vision-language tasks. In: Proceedings of the European Conference on Computer Vision (ECCV). pp. 121–137. Springer (2020)
|
| 241 |
+
[38] Lin, T.Y., Goyal, P., Girshick, R., He, K., Dollár, P.: Focal loss for dense object detection. In: Proceedings of the IEEE international conference on computer vision. pp. 2980–2988 (2017)
|
| 242 |
+
[39] Lin, T.Y., Maire, M., Belongie, S., Hays, J., Perona, P., Ramanan, D., Dollár, P., Zitnick, C.L.: Microsoft coco: Common objects in context. In: European conference on computer vision. pp. 740–755. Springer (2014)
|
| 243 |
+
[40] Liu, Z., Lin, Y., Cao, Y., Hu, H., Wei, Y., Zhang, Z., Lin, S., Guo, B.: Swin transformer: Hierarchical vision transformer using shifted windows. arXiv preprint arXiv:2103.14030 (2021)
|
| 244 |
+
[41] Lu, J., Batra, D., Parikh, D., Lee, S.: ViLBERT: Pretraining task-agnostic visiolinguistic representations for vision-and-language tasks. In: Advances in Neural Information Processing Systems (NeurIPS). pp. 13–23 (2019)
|
| 245 |
+
[42] Lu, J., Clark, C., Zellers, R., Mottaghi, R., Kembhavi, A.: Unified-io: A unified model for vision, language, and multi-modal tasks. arXiv preprint arXiv:2206.08916 (2022)
|
| 246 |
+
[43] Newell, A., Yang, K., Deng, J.: Stacked hourglass networks for human pose estimation. In: European conference on computer vision. pp. 483–499. Springer (2016)
|
| 247 |
+
[44] Radford, A., Kim, J.W., Hallacy, C., Ramesh, A., Goh, G., Agarwal, S., Sastry, G., Askell, A., Mishkin, P., Clark, J., et al.: Learning transferable visual models from natural language supervision. In: International Conference on Machine Learning (ICML) (2021)
|
| 248 |
+
[45] Redmon, J., Divvala, S., Girshick, R., Farhadi, A.: You only look once: Unified, real-time object detection. In: Proceedings of the IEEE conference on computer vision and pattern recognition. pp. 779–788 (2016)
|
| 249 |
+
[46] Ren, S., He, K., Girshick, R., Sun, J.: Faster r-cnn: Towards real-time object detection with region proposal networks. Advances in neural information processing systems 28, 91–99 (2015)
|
| 250 |
+
[47] Shin, T., Razeghi, Y., Logan IV, R.L., Wallace, E., Singh, S.: Autoprompt: Eliciting knowledge from language models with automatically generated prompts. arXiv preprint arXiv:2010.15980 (2020)
|
| 251 |
+
[48] Su, W., Zhu, X., Cao, Y., Li, B., Lu, L., Wei, F., Dai, J.: VL-BERT: Pre-training of generic visual-linguistic representations. arXiv preprint arXiv:1908.08530 (2019)
|
| 252 |
+
[49] Tan, H., Bansal, M.: Lxmert: Learning cross-modality encoder representations from transformers. arXiv preprint arXiv:1908.07490 (2019)
|
| 253 |
+
[50] Tian, Z., Shen, C., Chen, H., He, T.: Fcos: Fully convolutional one-stage object detection. In: Proceedings of the IEEE/CVF international conference on computer vision. pp. 9627–9636 (2019)
|
| 254 |
+
[51] Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A.N., Kaiser, Ł., Polosukhin, I.: Attention is all you need. In: Advances in neural information processing systems. pp. 5998–6008 (2017)
|
| 255 |
+
[52] Wang, P., Cai, Z., Yang, H., Swaminathan, G., Vasconcelos, N., Schiele, B., Soatto, S.: Omnidetr: Omni-supervised object detection with transformers. arXiv preprint arXiv:2203.16089 (2022)
|
| 256 |
+
[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)
|
| 257 |
+
[54] Wu, C., Lin, Z., Cohen, S., Bui, T., Maji, S.: Phrasecut: Language-based image segmentation in the wild. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. pp. 10216–10225 (2020)
|
| 258 |
+
[55] Yang, J., Li, C., Zhang, P., Xiao, B., Liu, C., Yuan, L., Gao, J.: Unified contrastive learning in image-text-label space. arXiv preprint arXiv:2204.03610 (2022)
|
| 259 |
+
[56] Yang, Z., Gan, Z., Wang, J., Hu, X., Ahmed, F., Liu, Z., Lu, Y., Wang, L.: Crossing the format boundary of text and boxes: Towards unified vision-language modeling. arXiv preprint arXiv:2111.12085 (2021)
|
| 260 |
+
[57] Yuan, L., Chen, D., Chen, Y.L., Codella, N., Dai, X., Gao, J., Hu, H., Huang, X., Li, B., Li, C., et al.: Florence: A new foundation model for computer vision. arXiv preprint arXiv:2111.11432 (2021)
|
| 261 |
+
[58] Zareian, A., Rosa, K.D., Hu, D.H., Chang, S.F.: Open-vocabulary object detection using captions. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. pp. 14393–14402 (2021)
|
| 262 |
+
[59] Zhang, P., Li, X., Hu, X., Yang, J., Zhang, L., Wang, L., Choi, Y., Gao, J.: Vinvl: Revisiting visual representations in vision-language models. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. pp. 5579–5588 (2021)
|
| 263 |
+
[60] Zhou, K., Yang, J., Loy, C.C., Liu, Z.: Learning to prompt for vision-language models. arXiv preprint arXiv:2109.01134 (2021)
|
| 264 |
+
[61] Zhou, L., Palangi, H., Zhang, L., Hu, H., Corso, J.J., Gao, J.: Unified vision-language pretraining for image captioning and VQA. AAAI (2020)
|
| 265 |
+
[62] Zhu, P., Wang, H., Saligrama, V.: Zero shot detection. IEEE Transactions on Circuits and Systems for Video Technology 30(4), 998–1010 (2019)
|
| 266 |
+
|
| 267 |
+
[63] Zhu, P., Wang, H., Saligrama, V.: Don’t even look once: Synthesizing features for zero-shot detection. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. pp. 11693–11702 (2020)
|
| 268 |
+
|
| 269 |
+
# Checklist
|
| 270 |
+
|
| 271 |
+
The checklist follows the references. Please read the checklist guidelines carefully for information on how to answer these questions. For each question, change the default [TODO] to [Yes] , [No] , or [N/A] . You are strongly encouraged to include a justification to your answer, either by referencing the appropriate section of your paper or providing a brief inline description. For example:
|
| 272 |
+
|
| 273 |
+
• Did you include the license to the code and datasets? [Yes]
|
| 274 |
+
• Did you include the license to the code and datasets? [No] The code and the data are proprietary.
|
| 275 |
+
• Did you include the license to the code and datasets? [N/A]
|
| 276 |
+
|
| 277 |
+
Please do not modify the questions and only use the provided macros for your answers. Note that the Checklist section does not count towards the page limit. In your paper, please delete this instructions block and only keep the Checklist section heading above along with the questions/answers below.
|
| 278 |
+
|
| 279 |
+
1. For all authors...
|
| 280 |
+
|
| 281 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
|
| 282 |
+
(b) Did you describe the limitations of your work? [Yes]
|
| 283 |
+
(c) Did you discuss any potential negative societal impacts of your work? [Yes]
|
| 284 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 285 |
+
|
| 286 |
+
2. If you are including theoretical results...
|
| 287 |
+
|
| 288 |
+
(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]
|
| 289 |
+
|
| 290 |
+
3. If you ran experiments...
|
| 291 |
+
|
| 292 |
+
(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]
|
| 293 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
|
| 294 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
|
| 295 |
+
(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]
|
| 296 |
+
|
| 297 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 298 |
+
|
| 299 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes]
|
| 300 |
+
(b) Did you mention the license of the assets? [Yes]
|
| 301 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [No]
|
| 302 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
|
| 303 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
|
| 304 |
+
|
| 305 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 306 |
+
|
| 307 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 308 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 309 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
md/dev/x5mtJD2ovc/x5mtJD2ovc.md
ADDED
|
@@ -0,0 +1,430 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# KNN-DIFFUSION: IMAGE GENERATION VIA LARGESCALE RETRIEVAL
|
| 2 |
+
|
| 3 |
+
Shelly Sheynin∗, Oron Ashual∗,
|
| 4 |
+
Adam Polyak, Uriel Singer, Oran Gafni, Eliya Nachmani, Yaniv Taigman
|
| 5 |
+
∗Equal Contribution Meta AI
|
| 6 |
+
{shellysheynin,oron}@meta.com
|
| 7 |
+
|
| 8 |
+

|
| 9 |
+
Figure 1: (a) Samples of stickers generated from text inputs, (b) Semantic text-guided manipulations applied to the "Original" image without using edit masks.
|
| 10 |
+
|
| 11 |
+
# ABSTRACT
|
| 12 |
+
|
| 13 |
+
Recent text-to-image models have achieved impressive results. However, since they require large-scale datasets of text-image pairs, it is impractical to train them on new domains where data is scarce or not labeled. In this work, we propose using large-scale retrieval methods, in particular, efficient $k$ -Nearest-Neighbors (kNN), which offers novel capabilities: (1) training a substantially small and efficient text-to-image diffusion model using only pre-trained multi-modal embeddings, but without an explicit text-image dataset, (2) generating out-of-distribution images by simply swapping the retrieval database at inference time, and (3) performing text-driven local semantic manipulations while preserving object identity. To demonstrate the robustness of our method, we apply our kNN approach on two state-of-the-art diffusion backbones, and show results on several different datasets. As evaluated by human studies and automatic metrics, our method achieves stateof-the-art results compared to existing approaches that train text-to-image generation models using images-only dataset.
|
| 14 |
+
|
| 15 |
+
# 1 INTRODUCTION
|
| 16 |
+
|
| 17 |
+
Large-scale generative models have been applied successfully to image generation tasks (Gafni et al., 2022; Ramesh et al., 2021; Nichol et al., 2021; Saharia et al., 2022; Yu et al., 2022), and have shown outstanding capabilities in extending human creativity using editing and user control. However, these models face several significant challenges: (i) Large-scale paired data requirement. To achieve high-quality results, text-to-image models rely heavily on large-scale datasets of (text, image) pairs collected from the internet. Due to the requirement of paired data, these models cannot be applied to new or customized domains with only unannotated images. (ii) Computational cost and efficiency. Training these models on highly complex distributions of natural images usually requires scaling the size of the model, data, batch-size, and training time, which makes them challenging to train and less accessible to the community. Recently, several works proposed text-to-image models trained without an explicit paired text-image datasets. Liu et al. (2021) performed a direct optimization to a pre-trained model based on a CLIP loss (Radford et al., 2021). Such approaches are time-consuming, since they require optimization for each input. Zhou et al. (2021) proposed training with CLIP image embedding perturbed with Gaussian noise. However, to achieve high-quality results, an additional model needs to be trained with an annotated text-image pairs dataset.
|
| 18 |
+
|
| 19 |
+
In this work, we introduce a novel generative model, kNN-Diffusion, which tackles these issues and progresses towards more accessible models for the research community and other users. Our model leverages a large-scale retrieval method, $k$ -Nearest-Neighbors (kNN) search, in order to train the model without an explicit text-image dataset. Specifically, our diffusion model is conditioned on two inputs: (1) image embedding (at training time) or text embedding (at inference), extracted using pre-trained CLIP encoder, and (2) kNN embeddings, representing the $k$ most similar images in the CLIP latent space. During training, we assume that no paired text is available, hence condition only on CLIP image embedding and on $k$ additional image embeddings, selected using the retrieval model. At inference, only text inputs are given, so instead of image embeddings, we use the text embedding that shares a joint embedding space with the image embeddings. Here, the kNN image embeddings are retrieved using the text embeddings.
|
| 20 |
+
|
| 21 |
+
The additional kNN embeddings have three main benefits: (1) they extend the distribution of conditioning embeddings and ensure the distribution is similar in train and inference, thus helping to bridge the gap between the image and text embedding distributions (see Fig. 5); (2) they teach the model to learn to generate images from a target distribution by using samples from that distribution. This allows generalizing to different distributions at test time and generating out-of-distribution samples; (3) they hold information that does not need to be present in the model, which allows it to be substantially smaller. We demonstrate the effectiveness of our kNN approach in Sec. 4.
|
| 22 |
+
|
| 23 |
+
To assess the performance of our method, we train our model on two large-scale datasets: the Public Multimodal Dataset (Singh et al., 2021) and an image-only stickers dataset collected from the Internet. We show state-of-the-art zero-shot results on MS-COCO (Lin et al., 2014), LN-COCO (PontTuset et al., 2020) and CUB (Wah et al., 2011). To further demonstrate the advantage of retrieval methods in text-to-image generation, we train two diffusion backbones using our kNN approach: continuous (Ramesh et al., 2022) and discrete (Gu et al., 2021). In both cases we outperform the model trained without kNN. In comparison to alternative methods presented in Sec. 4, we achieve state-of-the-art results in both human evaluations and FID score, with only 400 million parameters and 7 seconds inference time.
|
| 24 |
+
|
| 25 |
+
Lastly, we introduce a new approach for local and semantic manipulations that is based on CLIP and kNN, without relying on user-provided masks. Specifically, we fine-tune our model to perform local and complex modifications that satisfies a given target text prompt. For example, given the teddy bear’s image in Fig. 4, and the target text "holds a heart", our method automatically locates the local region that should be modified and synthesizes a high-resolution manipulated image in which (1) the teddy bear’s identity is accurately preserved and (2) the manipulation is aligned with the target text. We demonstrate our qualitative advantage by comparing our results with two state-of-the-art models, Text2Live (Bar-Tal et al., 2022) and Textual Inversion (Gal et al., 2022), that perform image manipulations without masks (Fig. 4, 21 and 22).
|
| 26 |
+
|
| 27 |
+
We summarize the contributions of this paper as follows: (1) We propose kNN-Diffusion, a novel and efficient model that utilizes a large-scale retrieval method for training a text-to-image model with only pre-trained multi-modal embeddings, but without an explicit text-image dataset. (2) We demonstrate efficient out-of-distribution generation, which is achieved by substituting retrieval databases. (3) We present a new approach for local and semantic image manipulation, without utilizing masks. (4) We evaluate our method on two diffusion backbones, discrete and continuous, as well as on several datasets, and present state-of-the-art results compared to baselines.
|
| 28 |
+
|
| 29 |
+
# 2 RELATED WORK
|
| 30 |
+
|
| 31 |
+
Text-to-image models. Text-to-image generation is a well-studied task that focuses on generating images from text descriptions. While GANs (Xu et al., 2018; Zhu et al., 2019; Zhang et al., 2021) and Transformer-based methods (Ramesh et al., 2021; Gafni et al., 2022; Yu et al., 2022; Ding et al., 2021) have shown remarkable results, recently impressive results have been attained with discrete (Gu et al., 2021) and continuous (Nichol et al., 2021; Saharia et al., 2022; Ramesh et al., 2022; Rombach et al., 2022) diffusion models. Most recent works trained diffusion models conditioned on text embeddings extracted using a pre-trained text encoder (Saharia et al., 2022; Yu et al., 2022) or image embedding extracted using CLIP (Ramesh et al., 2022). While producing impressive results, all previous works described above are supervised and trained with paired text-image datasets. Several works have proposed training text-to-image models without an explicit text-image dataset. FuseDream (Liu et al., 2021) proposed a direct optimization to a pre-trained generative model based on CLIP loss. This method relies on a pre-trained GAN and requires a time-consuming optimization process for each image. LAFITE (Zhou et al., 2021) recently demonstrated text-to-image generation results without requiring paired text-image datasets. Here, the CLIP embeddings are used interchangeably at train and test to condition a GAN-based model. The joint text-image embedding enables inference given a text input, whereas in training the model is fed with the visual embedding only. However, the gap between the text and image distributions in the joint embeddings space leads to results with substantially lower quality, as we show in our experiments. To overcome this gap, LAFITE added noise to the image embeddings during training. Our remedy to this gap is to condition the model on the retrieval of an actual image embeddings, using a text-image joint space.
|
| 32 |
+
|
| 33 |
+

|
| 34 |
+
Figure 2: Qualitative comparisons with baselines. Nearest Neighbor is the first kNN of the text in PMD dataset.
|
| 35 |
+
|
| 36 |
+
Retrieval for generation. The Information Retrieval (IR) literature tackles the challenge of retrieving a small amount of information from a large database, given a user’s query. A simple, yet efficient retrieval mechanism is to retrieve the $K$ nearest neighbors (kNN) between the query and the entities in the database in some pre-calculated embedding space (Bijalwan et al., 2014). The database allows the model to leverage extensive world-knowledge for its specific task Borgeaud et al. (2021). Recently, language models were augmented with a memory component, allowing them to store representations of past inputs (Wu et al., 2022). The latter were then queried using a lookup operation, improving performance in various benchmarks and tasks. Retrieval models have been used for various tasks in learning problems, for example, language modeling (Borgeaud et al., 2021), machine translation (Gu et al., 2018), question answering (Lee et al., 2019) and image generation (Tseng et al., 2020; Qi et al., 2018). RetrieveGAN (Tseng et al., 2020) uses a differentiable retrieval module for image generation from a scene description, RetrievalFuse (Siddiqui et al., 2021) proposed a neural 3D scene reconstruction based on a retrieval system. SIMS (Qi et al., 2018) proposed generating an image using semantic layout and compatible image segments that are retrieved from image segments database, and (Iskakov, 2018) showed that the use of retrieval database in inpainting task significantly boosts visual quality. In this work we utilize the kNN retrieval mechanism over the shared text-image embedding space, CLIP (Radford et al., 2021). Using extensive ablation studies, we show the importance of the retrieval model both for training and inference, and demonstrate its large impact on performance. kNN-Diffusion significantly outperforms prior work with zero-shot FID of 12.5, including RDM (Blattmann et al., 2022)(with FID of 22.1), a concurrent work which similarly to our approach, proposes conditioning LDM (Rombach et al., 2022) on kNN.
|
| 37 |
+
|
| 38 |
+

|
| 39 |
+
Figure 3: The overall framework of our kNN-Diffusion model. In both training and inference, the decoder is conditioned on CLIP embedding, and kNN image embeddings. During training, we condition the model on image CLIP embedding, and its kNN image embeddings extracted using the retrieval method. At inference time, given an input text, the kNN image embeddings are retrieved based on the CLIP text embedding that shares a joint embedding space with the image embedding.
|
| 40 |
+
|
| 41 |
+
Multi-modal feature learning. Learning a joint and aligned feature space for several modalities is challenging, as it requires alignment between the modalities (paired datasets), whose distributions may vary. Specifically, the joint feature space of vision-and-language has been a long-standing problem. CLIP (Radford et al., 2021) successfully tackled this by leveraging contrastive learning over a large dataset of text-image pairs. BLIP (Li et al., 2022), (Mu et al., 2021) and FLAVA (Singh et al., 2021), followed this idea and further improved the joint representation. The joint representation was shown to hold a strong semantic alignment between the two modalities, enabling image generation (Liu et al., 2021; Wang et al., 2022), image manipulation (Patashnik et al., 2021; Avrahami et al., 2022b), and image captioning (Mokady et al., 2021). In this work we leverage the joint representation in two ways: (i) enabling textless training with only visual data, while using text at inference time, and (ii) creating an efficient embedding space for the use of the retrieval model.
|
| 42 |
+
|
| 43 |
+
# 3 METHOD
|
| 44 |
+
|
| 45 |
+
Our main goal is to facilitate language-guided generation of user-specified concepts while using an images-only dataset during training. A possible way to achieve this goal is to use a shared textimage encoder that will map text-image pairs into the same latent space, thus allowing training with an image embedding, and inferring from text embedding. A candidate for this encoder is CLIP, which has been trained with a contrastive loss on a large-scale dataset of text-image pairs. However, as we show quantitatively in Tab. 1, 2 and qualitatively in Fig. 15, 16, 5, CLIP embeddings alone cannot accurately bridge the gap between the text and image distributions. In order to reduce this gap, several methods have been proposed. The closest work to ours is LAFITE, which perturbs the CLIP image embedding with adaptive Gaussian noise. Under the assumption that there is a large paired text-image dataset, Ramesh et al. (2022) have proposed a prior that is used during inference, and is trained to generate possible CLIP image embeddings from a given text caption. In this regard, we propose using a large-scale and non-trainable image embedding index as an integral part of the diffusion process. Our method, kNN-Diffusion, assumes that only image data and a pre-trained multi-modal text-image encoder are provided during training. As shown in Fig. 3, our model is comprised of three main components: (1) A multi-modal text-image encoder (CLIP); (2) A retrieval model - A data structure containing image embeddings, which is indexed for a fast kNN search; (3) An image generation network - A trainable diffusion-based image generation model, conditioned on the projected retrievals. For both training and inference, the image generation network is conditioned on $K$ additional image embeddings, chosen using the retrieval model to ensure a similar distribution of the condition in training and inference. The following sections describe these components.
|
| 46 |
+
|
| 47 |
+
Retrieval model. Our retrieval model has three non-trainable modules: a pre-trained text encoder $f _ { t x t }$ (CLIP text encoder), a pre-trained image encoder $f _ { i m g }$ (CLIP image encoder) and an index $\mathcal { H }$ . The encoders map text descriptions and image samples to a joint multi-modal $d$ - dimensional feature space $\mathbb { R } ^ { d }$ . The index stores an efficient representation of the images database $\mathcal { H } : = \{ f _ { i m g } ( i ) \in \mathbf { \hat { \mathbb { R } } } ^ { d } | i \in \mathcal { I } \}$ where $\mathcal { T }$ denotes the dataset of images. During training, we use the index to efficiently extract the $k$ nearest neighbors in the feature space of the image embedding $\begin{array} { r } { f _ { i m g } ( \mathrm { I } ) \in \mathbb { R } ^ { d } \cdot \mathrm { k n n } _ { i m g } ( \mathrm { I } , k ) : = \arg \operatorname* { m i n } _ { h \in \mathcal { H } } ^ { k } \mathbf { s } ( f _ { i m g } ( \mathrm { I } ) , h ) } \end{array}$ where s is a distance function and arg $\operatorname* { m i n } ^ { k }$ output the minimal $k$ elements. The set $\{ f _ { i m g } ( \mathrm { I } ) , \mathrm { k n n } _ { i m g } ( \mathrm { I } , k ) \}$ is used as the condition to the generative model. During inference, given a query text $t$ , an embedding $f _ { t x t } ( t )$ is extracted. The generative model is conditioned on this embedding and its $k$ nearest neighbors from the database - $\begin{array} { r } { \mathbf { k n n } _ { t x t } ( t , k ) : = \arg \operatorname* { m i n } _ { h \in \mathcal { H } } ^ { k } \mathbf { s } ( f _ { t x t } ( t ) , h ) } \end{array}$ . During training, we add embeddings of real images, by applying the retrieval method to the input image embedding. The extracted kNN should have a large enough distribution to cover the potential text embedding. During inference, the kNN are retrieved using the text embedding (See Fig. 17). In all of our experiments we use the cosine similarity metric as the distance function s, $k = 1 0$ for the number of nearest neighbors and $d = 5 1 2$ . The full implementation details can be found in Sec. 6.6 in the supplement.
|
| 48 |
+
|
| 49 |
+

|
| 50 |
+
Figure 4: Results for text-guided image manipulations without using masks. The original image is shown in the left column, our manipulated images are shown in the center. The images of Bar-Tal et al. (2022); Gal et al. (2022) were generated using the authors’ official code. The full comparison is available in the supplement.
|
| 51 |
+
|
| 52 |
+
Image generation network. In order to demonstrate the robustness of our method, we apply our kNN approach on two different diffusion backbones: Discrete (Gu et al., 2021) and Continuous (Nichol et al., 2021; Sohl-Dickstein et al., 2015; Ho et al., 2020; Dhariwal & Nichol, 2021). Although very different in practice, these models share the same theoretical idea. Let $x _ { 0 } \sim q ( x _ { 0 } )$ be a sample from our images distribution. A forward diffusion process is a Markov chain that adds noise at each step $q ( x _ { n } | x _ { n - 1 } )$ . The reverse process, $p _ { \theta } ( x _ { n - 1 } | x _ { n } , x _ { 0 } )$ , is a denoising process that removes noise from an initialized noise state. At inference time, the model can generate an output, starting with noise and gradually removing it using $p _ { \theta }$ . For additional background on diffusion models please refer to Sec. 6.1 in the supplement.
|
| 53 |
+
|
| 54 |
+
In the discrete diffusion model, $\bar { q } ( x _ { n } | x _ { n - 1 } ) : = v ^ { T } ( x _ { n } ) \mathbf { Q } _ { n } v ( x _ { n - 1 } )$ where $v ( x _ { n } )$ is a one-hot vector with entry 1 at $x _ { n }$ , and $\mathbf { Q } _ { n }$ is a transition matrix, modeling the probability to move from state $x _ { n - 1 }$ to $x _ { n }$ , using uniform probability over the vocabulary and a pre-defined probability for additional special $I M A S K J$ token. We can compute the reverse transition distribution according to: $\begin{array} { r } { p _ { \theta } ( x _ { n - 1 } | x _ { n } , y ) : = \sum _ { \hat { x } _ { 0 } = 1 } ^ { k } q ( x _ { n - 1 } | x _ { n } , \hat { x _ { 0 } } ) p _ { \theta } ( \hat { x _ { 0 } } | x _ { n } , x _ { 0 } , y ) } \end{array}$ where $x _ { 0 }$ is a discrete vector, tokenized by the VQGAN (Esser et al., 2021) encoder and $y$ is the conditioning signal. For modeling $p _ { \theta }$ we have followed (Gu et al., 2021) and used a conditional Transformer (Vaswani et al., 2017).
|
| 55 |
+
|
| 56 |
+
In the continuous diffusion model, $\begin{array} { r c l } { q ( x _ { n } | x _ { n - 1 } ) } & { : = } & { \mathcal { N } ( x _ { n } ; \sqrt { \alpha _ { t } } x _ { n - 1 } , ( 1 ~ - ~ \alpha _ { n } ) x _ { 0 } ) } \end{array}$ and $p _ { \theta } ( x _ { n - 1 } | x _ { n } , \mathbf { \theta } ) : = \mathcal { N } ( \mu _ { \theta } ( x _ { n } , \mathbf { \theta } ) , \Sigma _ { \theta } ( x _ { n } , \mathbf { \theta } ) )$ . Here, the noise function is Gaussian noise. Following (Ho et al., 2020; Nichol et al., 2021) we trained a model $\epsilon _ { \theta }$ to predict the added noise using a standard mean-squared error loss: $L : = E _ { n \sim [ 1 , N ] , x _ { 0 } \sim q ( x _ { 0 } ) , \epsilon \sim { \mathcal { N } } ( 0 , \mathbf { I } ) } [ | | \epsilon - \epsilon _ { \theta } ( x _ { n } , n , y | | ^ { 2 } ]$ where $\epsilon _ { \theta }$ is a U-net model and $y$ is the conditioning signal.
|
| 57 |
+
|
| 58 |
+

|
| 59 |
+
Figure 5: tSNE visualization of 500 random text-image CLIP embeddings pairs taken from COCO validation. The leftmost figure demonstrates the gap between the text and image distributions. By gradually adding kNN to the mean CLIP embedding of the text, the gap decreases, demonstrating the importance of the kNN.
|
| 60 |
+
|
| 61 |
+

|
| 62 |
+
Figure 6: FID on MS-COCO, including models trained on image-only datasets and text-image datasets.
|
| 63 |
+
|
| 64 |
+
Table 1: Results for zero-shot Text-to-Image generation on the MS-COCO, CUB and LN-COCO test sets. Imagequality and Text-alignment report the percentage of majority human raters votes in favor of our method when comparing between a certain model and ours.
|
| 65 |
+
|
| 66 |
+
<table><tr><td rowspan=1 colspan=2>Model</td><td rowspan=1 colspan=3>MS-COCOIm.TxtFID↓qual. align.</td><td rowspan=1 colspan=4>CUBFID↓Im.Txtqual. align.</td><td rowspan=1 colspan=1>LN-COCOFID↓Im.Txtqual. align.</td></tr><tr><td rowspan=2 colspan=2>LAFITEFuseDream</td><td rowspan=1 colspan=3>26.972.1 65.3</td><td rowspan=1 colspan=4>89.7 74.059.6</td><td rowspan=3 colspan=1>42.8 68.4 61.937.5 71.1 59.065.061.4 59.835.6 - 1</td></tr><tr><td rowspan=1 colspan=1>Fuse</td><td rowspan=1 colspan=2>21.2</td><td rowspan=1 colspan=2>21.2 64.0 79.3</td><td rowspan=1 colspan=2>50.279.1</td><td rowspan=1 colspan=2>50.279.160.9</td></tr><tr><td rowspan=1 colspan=2>no-kNNOurs</td><td rowspan=1 colspan=3>32.8 70.8 68.312.5 - -</td><td rowspan=1 colspan=4>0.868.3</td><td rowspan=1 colspan=1>95.1</td></tr></table>
|
| 67 |
+
|
| 68 |
+
In both cases, we condition our model on $y = ( f _ { i m g } ( x _ { 0 } ) , \mathrm { k n n } _ { i m g } ( x _ { 0 } , k ) )$ where $f _ { i m g } ( x _ { 0 } )$ is the CLIP image embedding, $\mathrm { k m } \mathrm { n } _ { i m g } ( x _ { 0 } , k )$ is the $k$ nearest neighbors in the feature space of the image embedding. Following (Ramesh et al., 2022; Rombach et al., 2022) conditional injection, we condition our model on the image CLIP embedding, and the $\mathbf { k N N }$ clip embeddings by applying cross attention in the attention layers of the architecture. We sample both our models using Classifier Free Guidance (CFG) (Nichol et al., 2021; Ho & Salimans, 2021). Since CFG was originally proposed for continuous models, we propose a method for using it with discrete models as well. Full implementation details of the discrete and continuous models can be found in Sec. 6.7 and Sec. 6.8, respectively, in the supplement.
|
| 69 |
+
|
| 70 |
+
# 3.1 TEXT-ONLY IMAGE MANIPULATION
|
| 71 |
+
|
| 72 |
+
The majority of previous works in the task of image manipulation either rely on user-provided masks (Nichol et al., 2021; Avrahami et al., 2022b;a), or are limited to global editing (Crowson et al., 2022; Kim et al., 2022). Recently, several works (Bar-Tal et al., 2022; Hertz et al., 2022; Gal et al., 2022) have made progress with local manipulations without relying on user edited masks. Nevertheless, most of the techniques suffer from several shortcomings: (1) They enable local texture changes, yet cannot modify complex structures, (2) they struggle to preserve the identity of the object, for example, when manipulating humans, (3) they require optimization for each input.
|
| 73 |
+
|
| 74 |
+
We address these issues by extending kNN-Diffusion to perform local and semantic-aware image manipulations without any provided mask. Illustration of the approach is provided in Fig. 18 and Fig. 19 in the supplement. For this task, the model is trained to predict the original image from a manipulated version. Specifically, we create a manipulated version of the image, which differs from the original image only in some local area. Given a random local area $M$ in the image I, the manipulated image $\mathrm { I } _ { m a n i p }$ is constructed by replacing the area with the corresponding nearest neighbor: $\mathrm { I } _ { m a n i p } = \mathrm { I } \cdot ( 1 - \mathrm { \ ' } M ) + \boldsymbol { \mathrm { n n } } _ { i m g } ( \mathrm { \mathbf { I } } , 1 ) \cdot \boldsymbol { M }$ , where $\mathbf { n n } _ { i m g } ( \mathbf { I } , 1 )$ is the the nearest neighbor obtained after aligning it with I using the ECC alignment algorithm (Evangelidis & Psarakis, 2008). The model then receives as input the manipulated image, together with the CLIP embedding of the original image only in the local area: $f _ { i m g } ( \mathbf { I } \cdot M )$ . This CLIP embedding represents the required modification that should be applied to the manipulated image in order to predict the original image. During inference, instead of using the CLIP embedding of the local area, the desired modification is represented using the CLIP embedding of the user text query. We modified the model to be capable of receiving as a condition both the manipulated image and the CLIP embedding of the local area.
|
| 75 |
+
|
| 76 |
+
Table 2: Results on the stickers dataset. We report the percentage of human raters prefer our method over the baselines with respect to image quality and text alignment. Discrete no-kNN refers to VQ-diffusion, and Continuous no-kNN, to DALL·E2 decoder, both trained without an explicit text-image dataset.
|
| 77 |
+
|
| 78 |
+
<table><tr><td></td><td></td><td colspan="2">Ours Discrete</td><td colspan="2">Ours Continuous</td></tr><tr><td>Model</td><td>FID↓</td><td>Image quality</td><td>Text alignment</td><td>Image quality</td><td>Text alignment</td></tr><tr><td>DALL·E2+ClipCap</td><td>55.5</td><td>71.6</td><td>69.2</td><td>67.0</td><td>68.3</td></tr><tr><td>LAFITE</td><td>58.7</td><td>63.5</td><td>59.9</td><td>76.0</td><td>71.2</td></tr><tr><td>no-kNN</td><td>52.7</td><td>72.1</td><td>67.6</td><td>66.8</td><td>69.4</td></tr><tr><td>Ours</td><td>40.8</td><td>1</td><td>1</td><td>-</td><td>1</td></tr></table>
|
| 79 |
+
|
| 80 |
+
# 4 EXPERIMENTS
|
| 81 |
+
|
| 82 |
+
First, we conduct qualitative and quantitative comparisons on MS-COCO, LN-COCO and CUB datasets. To further demonstrate the advantage of our method, we provide comparison on an imageonly stickers dataset, where we apply our approach on two diffusion backbones. Next, we demonstrate image manipulation and out-of-distribution capabilities. Finally, to better assess the effect of each contribution, an ablation study is provided.
|
| 83 |
+
|
| 84 |
+
Datasets and Metrics. For photo-realistic experiments, our model was trained only on the images (omitting the text) of a modified version of the Public Multimodal Dataset (PMD) used by FLAVA (Singh et al., 2021). More information about the dataset is available in Sec. 6.4 of the supplement. To further demonstrate the capabilities of our method, we collected 400 million sticker images from the web, containing combinations of concepts such as objects, characters/avatars and text. The collected stickers do not have paired text, and are substantially different from photorealistic data. Furthermore, since they have no paired text, they were not part of CLIP’s training data, which makes the text-to-image generation task more challenging.
|
| 85 |
+
|
| 86 |
+
Evaluation metrics are based on objective and subjective metrics: (i) FID (Heusel et al., 2017) is an objective metric used to assess the quality of synthesized images, (ii) human evaluation - we ask human raters for their preference, comparing two methods based on image quality and text alignment. We used 600 image pairs; five raters rated each pair. The results are shown as a percentage of majority votes in favor of our method over the baselines. We report the full human evaluation protocol in the supplement. We chose to omit Inception-Score, since it is shown by Barratt & Sharma (2018) to be a misleading metric for models that were not trained on Imagenet.
|
| 87 |
+
|
| 88 |
+
# 4.1 QUALITATIVE AND QUANTITATIVE RESULTS
|
| 89 |
+
|
| 90 |
+
We begin by comparing our model, trained on the PMD dataset, with the previous works LAFITE and FuseDream, that trained on image-only datasets. To demonstrate the advantage of using a retrieval method in text-to-image generation, we trained a model variant, no-kNN . This baseline was trained solely on image embeddings (omitting the kNN), while during inference, the images were generated using the text embedding. Tab. 1 displays zero-shot results on three different datasets: MS-COCO, CUB and LN-COCO. We follow the evaluation protocol of LAFITE, reporting our results on 30,000 images from MS-COCO validation set without training, nor using it’s training partition in the kNN index. Similarly, we follow LAFITE for CUB and LN-COCO evaluation. As can be seen, our model achieves the lowest FID score in all scenarios. In addition, human evaluations rate our method as better aligned to text and with the highest images quality. In Fig. 2, 15 and 11 we present a qualitative comparison between the methods. One can observe that while the simple retrieval baseline outputs non-generated images with high-quality, the images generated by our method are more faithful to the input text. To further demonstrate the effectiveness of our method, we present in Fig. 6 a comparison of our model with the latest text-to-image models trained on paired text-image datasets: DALL·E, CogView, VQ-Diffusion, GLIDE, LDM, Make-A-Scene, DALL·E2, Parti and Imagen. As can be seen, our model achieves comparable results to recent models trained with full text-image pairs (e.g LDM, GLIDE), despite being trained on an imageonly dataset, with significantly lower computational costs. The results demonstrate that leveraging an external retrieval database allows to compensate for different trade-offs, in particular, reducing the number of parameters in the model. Additional samples are provided in Fig. 13 in the supplement.
|
| 91 |
+
|
| 92 |
+

|
| 93 |
+
Figure 7: Comparison between various indexes used by the same model. (1) Aesthetic. Images from the first quantile of an aesthetic classifier, (2) Unaesthetic. Images from the last quantile of an aesthetic classifier, (3) Image search engine. Images retrieved from Google Images, (4) The stickers index.
|
| 94 |
+
|
| 95 |
+
Text-to-sticker generation. As the sticker dataset does not have paired text, and is substantially different from photo-realistic data, it allows us to illustrate the advantage of our model on an imageonly dataset. A selection of stickers generated by our model is presented in Fig. 1 and Fig. 14, 12. To demonstrate the importance of using kNN on image-only datasets, we evaluate our approach on two diffusion backbones. To this end, we trained a continuous diffusion model (Ramesh et al., 2022) and a discrete diffusion model (Gu et al., 2021), both conditioned on the kNN image embeddings. For each backbone, we compare our method with the following baselines: (1) no-kNN - this baseline was trained using both the continuous and the discrete methods conditioned only on image CLIP embedding, without using kNN. In the discrete case, we trained a VQ-diffusion model, while in the continuous case, we trained a re-implementation of DALL·E2’s decoder (without prior). (2) $D A L L { \cdot } E 2 { + } C l i p C a p$ baseline - here, we first captioned the entire sticker dataset using ClipCap (Mokady et al., 2021), then trained DALL·E2 decoder on the captioned dataset. (3) LAFITE - we trained LAFITE language-free model on our stickers dataset using the authors’ published code. We present the results in Tab. 2. The FID is calculated over a subset of 3, 000 stickers, generated from the ClipCap captioned dataset. As can be seen, our model achieves the lowest FID score. In addition, it outperforms all baselines in human evaluation comparison, using continuous and discrete backbones. In particular, compared with the same model trained without kNN, our model achieves significantly higher favorability in both text alignment and image quality.
|
| 96 |
+
|
| 97 |
+
# 4.2 APPLICATIONS
|
| 98 |
+
|
| 99 |
+
Text-only image manipulation. We demonstrate the manipulation capabilities of our model in Fig. 1, 4 and 20. Furthermore, we qualitatively compare our model with Text2LIVE (Bar-Tal et al., 2022) and Textual Inversion (Gal et al., 2022), using the authors’ published code. Text2LIVE proposed generating an edit layer that is composed over the original input, using a generator trained for each training image. Textual Inversion utilized the pre-trained Latent Diffusion model to invert the input image into a token embedding. The embedding is then used to compose novel textual queries for the generative model. Fig. 4 shows representative results, and the rest are included in Fig. 21 and 22 in the supplement. In contrast to our model, baseline methods lack text correspondence or they do not preserve the identity of the object. Since Text2LIVE is optimized to perform local changes, it has the difficulty changing the structure of the object (e.g. the "raising his hand" example in Fig. 4). Textual Inversion baseline changes the identity of the object because it struggles reconstructing the textual representation of the source image. Our model, on the other hand, can perform challenging manipulations that are aligned with the text, while preserving the object identity.
|
| 100 |
+
|
| 101 |
+

|
| 102 |
+
Figure 8: Mean aesthetics score of the generated images as a function of the conditioned kNN mean aesthetics score.
|
| 103 |
+
|
| 104 |
+

|
| 105 |
+
Figure 9: MS-COCO test FID score on various K’s in: (1) Zero-Shot (2) Index includes MS-COCO train subset. No kNN trained with kNN, but did not employ kNN in inference.
|
| 106 |
+
|
| 107 |
+

|
| 108 |
+
Figure 10: MS-COCO test FID score for different model sizes. As can be seen, adding kNN to the model allows it to be smaller, while having better performance.
|
| 109 |
+
|
| 110 |
+
Out-of-distribution generation. Using the retrieval index as part of the generation process enables using different databases during inference, without fine-tuning. This allows generatig images from distributions that were not part of the training set, enabling out-of-distribution generation. This novel capability is demonstrated with the same model trained on PMD, using three different retrieval databases: $( i ) A$ stickers database presented in Sec. 4. (ii) Aesthetic database: This database is constructed by filtering images according to a classifier score. Let $C$ be a classifier that for each image $i \in I$ outputs a score $s = C ( i )$ . This classifier enables filtering the kNN using $L \leq s < H$ , where $L$ and $H$ are low and high thresholds, respectively. Here, we use an open source pre-trained aesthetics classifier $A$ (Christoph Schuhmann, 2022): For each text input $t \in T$ , we apply $A$ on the kNN, and then divide the kNN into five equal quantiles based on $A$ score. As can be seen in Fig. 8, using kNN with higher aesthetics score result in generated images with higher aesthetics mean score. (iii) Image search engine: Generative models are stationary in the sense that they are unable to learn new concepts after being trained, hence fine-tuning is required to represent new styles and concepts. Here, we use an online image search engine, which allows the model to adapt to new data without additional fine-tuning. A qualitative comparison of all three methods is shown in Fig.7.
|
| 111 |
+
|
| 112 |
+
# 4.3 ABLATION STUDY
|
| 113 |
+
|
| 114 |
+
We conclude our experiments with an ablation study, to quantify the contribution of our different components. We provide ablation study on index size and different kNN conditioning approaches in Sec. 6.5 of the supplement. Number of nearest neighbors. The results in Fig. 9 demonstrate the importance of applying the retrieval mechanism during training and inference. Here, we evaluate our model, trained on PMD dataset, with different numbers of kNN during inference. Furthermore, we examined the baseline no-kNN, in which during inference, the model is conditioned only on the text embedding $f _ { t x t } ( t )$ , without using kNN. Best performance is achieved using 10 neighbors. Scalability analysis. To evaluate the effectiveness of our approach at different model sizes, we trained three additional models with varying sizes for both settings - with and without kNN. As can be seen in Fig. 10, utilizing kNN consistently improves performance for all sizes. Furthermore, a performance improvement can be achieved using much smaller models with kNN. For example, the $3 5 M$ kNN model outperforms the $4 0 0 M$ model without kNN.
|
| 115 |
+
|
| 116 |
+
# 5 CONCLUSION
|
| 117 |
+
|
| 118 |
+
“We shall always find, that every idea which we examine is copied from a similar impression", Hume (1748). In this paper, we propose using a large-scale retrieval method in order to train a novel textto-image model, with only pre-trained multi-modal embeddings, but without an explicit text-image dataset. Our extensive experiments demonstrate that using an external knowledge-base alleviates much of the model’s burden of learning novel concepts, enabling the use of a relatively small model. In addition, it provides the model the capability of learning to adapt to new samples, which it only observes during test time. Lastly, we present a new technique utilizing the retrieval method for textdriven semantic manipulations without user-provided masks. As evaluated by human studies and automatic metrics, our method is significantly preferable to the baselines in terms of image quality and text alignment.
|
| 119 |
+
|
| 120 |
+
# REFERENCES
|
| 121 |
+
|
| 122 |
+
Omri Avrahami, Ohad Fried, and Dani Lischinski. Blended latent diffusion. arXiv preprint arXiv:2206.02779, 2022a.
|
| 123 |
+
|
| 124 |
+
Omri Avrahami, Dani Lischinski, and Ohad Fried. Blended diffusion for text-driven editing of natural images. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 18208–18218, 2022b.
|
| 125 |
+
|
| 126 |
+
Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016.
|
| 127 |
+
|
| 128 |
+
Artem Babenko and Victor Lempitsky. The inverted multi-index. IEEE transactions on pattern analysis and machine intelligence, 37(6):1247–1260, 2014.
|
| 129 |
+
|
| 130 |
+
Omer Bar-Tal, Dolev Ofri-Amar, Rafail Fridman, Yoni Kasten, and Tali Dekel. Text2live: Textdriven layered image and video editing. arXiv preprint arXiv:2204.02491, 2022.
|
| 131 |
+
|
| 132 |
+
Shane Barratt and Rishi Sharma. A note on the inception score. arXiv preprint arXiv:1801.01973, 2018.
|
| 133 |
+
|
| 134 |
+
Vishwanath Bijalwan, Vinay Kumar, Pinki Kumari, and Jordan Pascual. Knn based machine learning approach for text and document mining. International Journal of Database Theory and Application, 7(1):61–70, 2014.
|
| 135 |
+
|
| 136 |
+
Andreas Blattmann, Robin Rombach, Kaan Oktay, Jonas Müller, and Björn Ommer. Semiparametric neural image synthesis. In Advances in Neural Information Processing Systems, 2022.
|
| 137 |
+
|
| 138 |
+
Sebastian Borgeaud, Arthur Mensch, Jordan Hoffmann, Trevor Cai, Eliza Rutherford, Katie Millican, George van den Driessche, Jean-Baptiste Lespiau, Bogdan Damoc, Aidan Clark, et al. Improving language models by retrieving from trillions of tokens. arXiv preprint arXiv:2112.04426, 2021.
|
| 139 |
+
|
| 140 |
+
Soravit Changpinyo, Piyush Sharma, Nan Ding, and Radu Soricut. Conceptual 12M: Pushing webscale image-text pre-training to recognize long-tail visual concepts. In CVPR, 2021.
|
| 141 |
+
|
| 142 |
+
Romain Beaumont Christoph Schuhmann. Aesthetic predictor. https://github.com/ LAION-AI/aesthetic-predictor, 2022.
|
| 143 |
+
|
| 144 |
+
Katherine Crowson, Stella Biderman, Daniel Kornis, Dashiell Stander, Eric Hallahan, Louis Castricato, and Edward Raff. Vqgan-clip: Open domain image generation and editing with natural language guidance. arXiv preprint arXiv:2204.08583, 2022.
|
| 145 |
+
|
| 146 |
+
Karan Desai, Gaurav Kaul, Zubin Aysola, and Justin Johnson. RedCaps: Web-curated image-text data created by the people, for the people. In NeurIPS Datasets and Benchmarks, 2021.
|
| 147 |
+
|
| 148 |
+
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.
|
| 149 |
+
|
| 150 |
+
Prafulla Dhariwal and Alex Nichol. Diffusion models beat gans on image synthesis. arXiv preprint arXiv:2105.05233, 2021.
|
| 151 |
+
|
| 152 |
+
Ming Ding, Zhuoyi Yang, Wenyi Hong, Wendi Zheng, Chang Zhou, Da Yin, Junyang Lin, Xu Zou, Zhou Shao, Hongxia Yang, et al. Cogview: Mastering text-to-image generation via transformers. Advances in Neural Information Processing Systems, 34, 2021.
|
| 153 |
+
|
| 154 |
+
Patrick Esser, Robin Rombach, and Bjorn Ommer. Taming transformers for high-resolution image synthesis. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 12873–12883, 2021.
|
| 155 |
+
|
| 156 |
+
Georgios D Evangelidis and Emmanouil Z Psarakis. Parametric image alignment using enhanced correlation coefficient maximization. IEEE transactions on pattern analysis and machine intelligence, 30(10):1858–1865, 2008.
|
| 157 |
+
|
| 158 |
+
Oran Gafni, Adam Polyak, Oron Ashual, Shelly Sheynin, Devi Parikh, and Yaniv Taigman. Make-a-scene: Scene-based text-to-image generation with human priors. arXiv preprint arXiv:2203.13131, 2022.
|
| 159 |
+
|
| 160 |
+
Rinon Gal, Yuval Alaluf, Yuval Atzmon, Or Patashnik, Amit H Bermano, Gal Chechik, and Daniel Cohen-Or. An image is worth one word: Personalizing text-to-image generation using textual inversion. arXiv preprint arXiv:2208.01618, 2022.
|
| 161 |
+
|
| 162 |
+
Tiezheng Ge, Kaiming He, Qifa Ke, and Jian Sun. Optimized product quantization for approximate nearest neighbor search. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2013.
|
| 163 |
+
|
| 164 |
+
Jiatao Gu, Yong Wang, Kyunghyun Cho, and Victor OK Li. Search engine guided neural machine translation. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 32, 2018.
|
| 165 |
+
|
| 166 |
+
Shuyang Gu, Dong Chen, Jianmin Bao, Fang Wen, Bo Zhang, Dongdong Chen, Lu Yuan, and Baining Guo. Vector quantized diffusion model for text-to-image synthesis. ArXiv, abs/2111.14822, 2021.
|
| 167 |
+
|
| 168 |
+
Amir Hertz, Ron Mokady, Jay Tenenbaum, Kfir Aberman, Yael Pritch, and Daniel Cohen-Or. Prompt-to-prompt image editing with cross attention control. arXiv preprint arXiv:2208.01626, 2022.
|
| 169 |
+
|
| 170 |
+
Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and Sepp Hochreiter. Gans trained by a two time-scale update rule converge to a local nash equilibrium. Advances in neural information processing systems, 30, 2017.
|
| 171 |
+
|
| 172 |
+
Jonathan Ho and Tim Salimans. Classifier-free diffusion guidance. In NeurIPS 2021 Workshop on Deep Generative Models and Downstream Applications, 2021.
|
| 173 |
+
|
| 174 |
+
Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. arXiv preprint arXiv:2006.11239, 2020.
|
| 175 |
+
|
| 176 |
+
David Hume. An enquiry concerning human understanding, 1748.
|
| 177 |
+
|
| 178 |
+
Karim Iskakov. Semi-parametric image inpainting. arXiv preprint arXiv:1807.02855, 2018.
|
| 179 |
+
|
| 180 |
+
Herve Jegou, Matthijs Douze, and Cordelia Schmid. Product quantization for nearest neighbor search. IEEE transactions on pattern analysis and machine intelligence, 33(1):117–128, 2010.
|
| 181 |
+
|
| 182 |
+
Jeff Johnson, Matthijs Douze, and Hervé Jégou. Billion-scale similarity search with GPUs. IEEE Transactions on Big Data, 7(3):535–547, 2019.
|
| 183 |
+
|
| 184 |
+
Gwanghyun Kim, Taesung Kwon, and Jong Chul Ye. Diffusionclip: Text-guided diffusion models for robust image manipulation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 2426–2435, 2022.
|
| 185 |
+
|
| 186 |
+
Ivan Krasin, Tom Duerig, Neil Alldrin, Andreas Veit, Sami Abu-El-Haija, Serge Belongie, David Cai, Zheyun Feng, Vittorio Ferrari, and Victor Gomes. Openimages: A public dataset for largescale multi-label and multi-class image classification., 01 2016.
|
| 187 |
+
|
| 188 |
+
Ranjay Krishna, Yuke Zhu, Oliver Groth, Justin Johnson, Kenji Hata, Joshua Kravitz, Stephanie Chen, Yannis Kalantidis, Li-Jia Li, David A Shamma, Michael Bernstein, and Li Fei-Fei. Visual genome: Connecting language and vision using crowdsourced dense image annotations. 2016. URL https://arxiv.org/abs/1602.07332.
|
| 189 |
+
|
| 190 |
+
Kenton Lee, Ming-Wei Chang, and Kristina Toutanova. Latent retrieval for weakly supervised open domain question answering. arXiv preprint arXiv:1906.00300, 2019.
|
| 191 |
+
|
| 192 |
+
Junnan Li, Dongxu Li, Caiming Xiong, and Steven Hoi. Blip: Bootstrapping languageimage pre-training for unified vision-language understanding and generation. arXiv preprint arXiv:2201.12086, 2022.
|
| 193 |
+
|
| 194 |
+
Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In European conference on computer vision, pp. 740–755. Springer, 2014.
|
| 195 |
+
|
| 196 |
+
Xingchao Liu, Chengyue Gong, Lemeng Wu, Shujian Zhang, Hao Su, and Qiang Liu. Fusedream: Training-free text-to-image generation with improved clip $^ +$ gan space optimization. arXiv preprint arXiv:2112.01573, 2021.
|
| 197 |
+
|
| 198 |
+
Ron Mokady, Amir Hertz, and Amit H Bermano. Clipcap: Clip prefix for image captioning. arXiv preprint arXiv:2111.09734, 2021.
|
| 199 |
+
|
| 200 |
+
Norman Mu, Alexander Kirillov, David Wagner, and Saining Xie. Slip: Self-supervision meets language-image pre-training. arXiv preprint arXiv:2112.12750, 2021.
|
| 201 |
+
|
| 202 |
+
Alex Nichol, Prafulla Dhariwal, Aditya Ramesh, Pranav Shyam, Pamela Mishkin, Bob McGrew, Ilya Sutskever, and Mark Chen. Glide: Towards photorealistic image generation and editing with text-guided diffusion models. arXiv preprint arXiv:2112.10741, 2021.
|
| 203 |
+
|
| 204 |
+
Vicente Ordonez, Girish Kulkarni, and Tamara Berg. Im2text: Describing images using 1 million captioned photographs. 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/ 5dd9db5e033da9c6fb5ba83c7a7ebea9-Paper.pdf.
|
| 205 |
+
|
| 206 |
+
Or Patashnik, Zongze Wu, Eli Shechtman, Daniel Cohen-Or, and Dani Lischinski. Styleclip: Textdriven manipulation of stylegan imagery. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 2085–2094, 2021.
|
| 207 |
+
|
| 208 |
+
Jordi Pont-Tuset, Jasper Uijlings, Soravit Changpinyo, Radu Soricut, and Vittorio Ferrari. Connecting vision and language with localized narratives. In European Conference on Computer Vision, pp. 647–664. Springer, 2020.
|
| 209 |
+
|
| 210 |
+
Xiaojuan Qi, Qifeng Chen, Jiaya Jia, and Vladlen Koltun. Semi-parametric image synthesis. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 8808– 8816, 2018.
|
| 211 |
+
|
| 212 |
+
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. CoRR, abs/2103.00020, 2021. URL https://arxiv.org/abs/2103.00020.
|
| 213 |
+
|
| 214 |
+
Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-shot text-to-image generation. In International Conference on Machine Learning, pp. 8821–8831. PMLR, 2021.
|
| 215 |
+
|
| 216 |
+
Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical textconditional image generation with clip latents. arXiv preprint arXiv:2204.06125, 2022.
|
| 217 |
+
|
| 218 |
+
Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer. Highresolution image synthesis with latent diffusion models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 10684–10695, 2022.
|
| 219 |
+
|
| 220 |
+
Chitwan Saharia, William Chan, Saurabh Saxena, Lala Li, Jay Whang, Emily Denton, Seyed Kamyar Seyed Ghasemipour, Burcu Karagol Ayan, S Sara Mahdavi, Rapha Gontijo Lopes, et al. Photorealistic text-to-image diffusion models with deep language understanding. arXiv preprint arXiv:2205.11487, 2022.
|
| 221 |
+
|
| 222 |
+
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.
|
| 223 |
+
|
| 224 |
+
Yawar Siddiqui, Justus Thies, Fangchang Ma, Qi Shan, Matthias Nießner, and Angela Dai. Retrievalfuse: Neural 3d scene reconstruction with a database. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 12568–12577, 2021.
|
| 225 |
+
|
| 226 |
+
Amanpreet Singh, Ronghang Hu, Vedanuj Goswami, Guillaume Couairon, Wojciech Galuba, Marcus Rohrbach, and Douwe Kiela. Flava: A foundational language and vision alignment model. arXiv preprint arXiv:2112.04482, 2021.
|
| 227 |
+
|
| 228 |
+
Jascha Sohl-Dickstein, Eric Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. In International Conference on Machine Learning, pp. 2256–2265. PMLR, 2015.
|
| 229 |
+
|
| 230 |
+
Krishna Srinivasan, Karthik Raman, Jiecao Chen, Michael Bendersky, and Marc Najork. Wit: Wikipedia-based image text dataset for multimodal multilingual machine learning. In Proceedings of the 44th International ACM SIGIR Conference on Research and Development in Information Retrieval, pp. 2443–2449, 2021.
|
| 231 |
+
|
| 232 |
+
Bart Thomee, David A. Shamma, Gerald Friedland, Benjamin Elizalde, Karl Ni, Douglas Poland, Damian Borth, and Li-Jia Li. The new data and new challenges in multimedia research. CoRR, abs/1503.01817, 2015. URL http://arxiv.org/abs/1503.01817.
|
| 233 |
+
|
| 234 |
+
Hung-Yu Tseng, Hsin-Ying Lee, Lu Jiang, Ming-Hsuan Yang, and Weilong Yang. Retrievegan: Image synthesis via differentiable patch retrieval. In European Conference on Computer Vision, pp. 242–257. Springer, 2020.
|
| 235 |
+
|
| 236 |
+
Aaron Van Den Oord, Oriol Vinyals, et al. Neural discrete representation learning. Advances in neural information processing systems, 30, 2017.
|
| 237 |
+
|
| 238 |
+
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.
|
| 239 |
+
|
| 240 |
+
Catherine Wah, Steve Branson, Peter Welinder, Pietro Perona, and Serge Belongie. The caltech-ucsd birds-200-2011 dataset. 2011.
|
| 241 |
+
|
| 242 |
+
Xintao Wang, Liangbin Xie, Chao Dong, and Ying Shan. Real-esrgan: Training real-world blind super-resolution with pure synthetic data. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 1905–1914, 2021.
|
| 243 |
+
|
| 244 |
+
Zihao Wang, Wei Liu, Qian He, Xinglong Wu, and Zili Yi. Clip-gen: Language-free training of a text-to-image generator with clip. arXiv preprint arXiv:2203.00386, 2022.
|
| 245 |
+
|
| 246 |
+
Yuhuai Wu, Markus N Rabe, DeLesley Hutchins, and Christian Szegedy. Memorizing transformers. arXiv preprint arXiv:2203.08913, 2022.
|
| 247 |
+
|
| 248 |
+
Tao Xu, Pengchuan Zhang, Qiuyuan Huang, Han Zhang, Zhe Gan, Xiaolei Huang, and Xiaodong He. Attngan: Fine-grained text to image generation with attentional generative adversarial networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 1316–1324, 2018.
|
| 249 |
+
|
| 250 |
+
Jiahui Yu, Yuanzhong Xu, Jing Yu Koh, Thang Luong, Gunjan Baid, Zirui Wang, Vijay Vasudevan, Alexander Ku, Yinfei Yang, Burcu Karagol Ayan, et al. Scaling autoregressive models for contentrich text-to-image generation. arXiv preprint arXiv:2206.10789, 2022.
|
| 251 |
+
|
| 252 |
+
Han Zhang, Jing Yu Koh, Jason Baldridge, Honglak Lee, and Yinfei Yang. Cross-modal contrastive learning for text-to-image generation. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 833–842, 2021.
|
| 253 |
+
|
| 254 |
+
Yufan Zhou, Ruiyi Zhang, Changyou Chen, Chunyuan Li, Chris Tensmeyer, Tong Yu, Jiuxiang Gu, Jinhui Xu, and Tong Sun. LAFITE: towards language-free training for text-to-image generation. CoRR, abs/2111.13792, 2021. URL https://arxiv.org/abs/2111.13792.
|
| 255 |
+
|
| 256 |
+
Minfeng Zhu, Pingbo Pan, Wei Chen, and Yi Yang. Dm-gan: Dynamic memory generative adversarial networks for text-to-image synthesis. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 5802–5810, 2019.
|
| 257 |
+
|
| 258 |
+
# 6 APPENDIX
|
| 259 |
+
|
| 260 |
+
A neat and clean bathroom in blue and white
|
| 261 |
+
|
| 262 |
+

|
| 263 |
+
Figure 11: Samples from COCO validation set.
|
| 264 |
+
|
| 265 |
+

|
| 266 |
+
Figure 12: A selection of stickers generated using the continuous kNN-Diffusion model.
|
| 267 |
+
|
| 268 |
+

|
| 269 |
+
Figure 13: Additional samples generated from challenging text inputs using the photo-realistic model
|
| 270 |
+
|
| 271 |
+

|
| 272 |
+
Figure 14: A selection of stickers generated using the discrete kNN-Diffusion model.
|
| 273 |
+
|
| 274 |
+
# 6.1 BACKGROUND
|
| 275 |
+
|
| 276 |
+
Continuous diffusion process Diffusion models are latent variable models that aim to model a distribution $p _ { \theta } ( x _ { 0 } )$ that approximates the data distribution $q ( x _ { 0 } )$ . Specifically, they model a forward process in the space of $x _ { 0 }$ from data to noise. Given a sample from the data distribution $x _ { 0 } ~ \sim$ $q ( x _ { 0 } )$ , this process produces a Markov chain of latent variables $x _ { 1 } , \ldots , x _ { T }$ by progressively adding Gaussion noise to the sample:
|
| 277 |
+
|
| 278 |
+
$$
|
| 279 |
+
q ( x _ { t } | x _ { t - 1 } ) : = \mathcal { N } ( x _ { t } ; \sqrt { 1 - \beta _ { t } } x _ { t - 1 } , \beta _ { t } \mathbb { Z } )
|
| 280 |
+
$$
|
| 281 |
+
|
| 282 |
+
where $\beta _ { t }$ is a variance schedule. As presented previously by (Ho et al., 2020), the latent variable $x _ { t }$ can be expressed directly as a linear combination of noise and $x _ { 0 }$ :
|
| 283 |
+
|
| 284 |
+
$$
|
| 285 |
+
x _ { t } = \sqrt { \overline { { \alpha } } _ { t } } x _ { 0 } + \epsilon \sqrt { 1 - \overline { { \alpha } } _ { t } } , \quad \epsilon \sim \mathcal { N } ( 0 , \mathcal { T } )
|
| 286 |
+
$$
|
| 287 |
+
|
| 288 |
+
where $\alpha _ { t } : = \Pi _ { i = 1 } ^ { t } ( 1 - \beta _ { i } )$ . In order to sample from the data distribution $q ( x _ { 0 } )$ , we define the "reverse process" $p ( x _ { t - 1 } | x _ { t } )$ which samples first from $q ( x _ { T } )$ and then samples reverse steps $q \big ( x _ { t - 1 } | x _ { t } \big )$ until $x _ { 0 }$ .
|
| 289 |
+
|
| 290 |
+
Since the data distribution is unknown, we need to train a model to approximate it. Note that when $T$ is large enough, the noise vector $x _ { T }$ nearly follows an isotropic Gaussian distribution. This suggests learning a model $p _ { \theta } ( x _ { t - 1 } | x _ { t } )$ to predict mean $\mu _ { \theta }$ and covariance matrix $\Sigma _ { \theta }$ :
|
| 291 |
+
|
| 292 |
+
$$
|
| 293 |
+
p _ { \theta } ( x _ { t - 1 } | x _ { t } ) : = \mathcal { N } ( x _ { t - 1 } ; \mu _ { \theta } ( x _ { t } , t ) , \Sigma _ { \theta } ( x _ { t } , t ) )
|
| 294 |
+
$$
|
| 295 |
+
|
| 296 |
+
To train this model, we can replace $\mu _ { \theta } ( x _ { t } , t )$ by predicting the noise $\epsilon _ { \theta } ( x _ { t } , t )$ added to $x _ { 0 }$ using equation 2 and we get this objective function:
|
| 297 |
+
|
| 298 |
+
$$
|
| 299 |
+
L : = E _ { t \sim [ 1 , T ] , x _ { 0 } \sim q ( x _ { 0 } ) , \epsilon \sim \mathcal { N } ( 0 , \mathbf { I } ) } [ | | \epsilon - \epsilon _ { \theta } ( x _ { t } , t , y | | ^ { 2 } ]
|
| 300 |
+
$$
|
| 301 |
+
|
| 302 |
+
where $y$ is an optional conditioning signal (such as text/image embedding or a low resolution ima
|
| 303 |
+
|
| 304 |
+
Discrete diffusion process Let $x _ { n } \in \{ 1 , \ldots , V \} ^ { h \times w }$ be the indices of the allocated codebook vectors extracted by a pre-trained VQGAN (Esser et al., 2021) encoder. The forward process of a diffusion model $q ( x _ { n } | x _ { n - 1 } )$ is a Markov chain that adds noise at each step. Moreover, the reverse process $q ( x _ { n - 1 } | x _ { n } , x _ { 0 } )$ , is a denoising process that removes noise from an initialized noise state.As presented by (Gu et al., 2021), the forward diffusion process is given by:
|
| 305 |
+
|
| 306 |
+
$$
|
| 307 |
+
q ( x _ { n } | x _ { n - 1 } ) = v ^ { T } ( x _ { n } ) \mathbf { Q } _ { n } v ( x _ { n - 1 } )
|
| 308 |
+
$$
|
| 309 |
+
|
| 310 |
+
where $v ( x _ { n } )$ is a one-hot vector with entry 1 at $x _ { n }$ , and $\mathbf { Q } _ { n }$ is the probability transition matrix from state $x _ { n - 1 }$ to $x _ { n }$ .
|
| 311 |
+
|
| 312 |
+
The reverse process is given by the posterior distribution:
|
| 313 |
+
|
| 314 |
+
$$
|
| 315 |
+
\begin{array} { r } { q ( x _ { n - 1 } | x _ { n } , x _ { 0 } ) = \frac { \left( v ^ { T } ( x _ { n } ) \mathbf { Q } _ { n } v ( x _ { n - 1 } ) \right) \left( v ^ { T } ( x _ { n - 1 } ) \bar { \mathbf { Q } } _ { n - 1 } v ( x _ { 0 } ) \right) } { v ^ { T } ( x _ { n } ) \bar { \mathbf { Q } } _ { n } v ( x _ { 0 } ) } } \end{array}
|
| 316 |
+
$$
|
| 317 |
+
|
| 318 |
+
where $\bar { \mathbf Q } _ { n } = \mathbf Q _ { n } \cdot \cdot \cdot \mathbf Q _ { 1 }$
|
| 319 |
+
|
| 320 |
+
Inspired from mask language modeling (Devlin et al., 2018), they proposes corrupting the tokens by stochastically masking some of them. Specifically, an additional special token $[ \bar { M } A \bar { S } K ]$ is proposed, so for each token there are $( \mathsf { V } { + } 1 )$ discrete states. The transition matrix is formulated as, By adding a small amount of unifrom noise to the categorial distribution, the transition matrix can be formulated as,
|
| 321 |
+
|
| 322 |
+
$$
|
| 323 |
+
\mathbf { Q } _ { n } = \left[ \begin{array} { c c c c c } { \alpha _ { n } + \beta _ { n } } & { \beta _ { n } } & { \beta _ { n } } & { \cdots } & { 0 } \\ { \beta _ { n } } & { \alpha _ { n } + \beta _ { n } } & { \beta _ { n } } & { \cdots } & { 0 } \\ { \beta _ { n } } & { \beta _ { n } } & { \alpha _ { n } + \beta _ { n } } & { \cdots } & { 0 } \\ { \vdots } & { \vdots } & { \vdots } & { \ddots } & { \vdots } \\ { \gamma _ { n } } & { \gamma _ { n } } & { \gamma _ { n } } & { \cdots } & { 1 } \end{array} \right]
|
| 324 |
+
$$
|
| 325 |
+
|
| 326 |
+
where $\alpha _ { n } \in [ 0 , 1 ]$ , $\beta _ { n } = ( 1 - \alpha _ { n } - \gamma _ { n } ) / V$ and $\gamma _ { n }$ the probability of a token to be replaced with a $[ M A S K ]$ token. Each token has a probability of $\gamma _ { n }$ to be replaced by the $[ M A S K ]$ token, $V \beta _ { n }$ to be resampled uniformly and $\alpha _ { n } = ( 1 - V \beta _ { n } - \gamma _ { n } )$ to be unchanged.
|
| 327 |
+
|
| 328 |
+
# 6.2 ADDITIONAL SAMPLES
|
| 329 |
+
|
| 330 |
+
In Fig. 16 and 15 we present a visual comparison of our discrete model, trained on the stickers dataset with (1) the kNN extracted during inference, (2) the same model without using kNN in inference. As can be seen, the images generated by our model are better aligned to the corresponding text compared to the baselines. While the baselines fail with challenging prompts, our model produces high-quality images that align with the text, and composes multiple concepts correctly.
|
| 331 |
+
|
| 332 |
+
COCO Validation Set Comparison Fig. 11 presents a qualitative comparison with FuseDream (Liu et al., 2021), CogView (Ding et al., 2021) and VQ-Diffusion (Gu et al., 2021) on the COCO validation set. Note that both CogView and VQ-Diffusion have been trained on an ImageText paired dataset, whereas our model was not trained on the COCO dataset, nor used it in the retrieval model.
|
| 333 |
+
|
| 334 |
+

|
| 335 |
+
Figure 15: Comparison of our model, trained on PMD with (1) kNN extracted in inference, (2) the same model without using kNN in inference. While the kNN lack information regarding text semantics, our model considers both text semantics and the kNN, thus proving the advantage of using both the text and the kNN embeddings.
|
| 336 |
+
|
| 337 |
+

|
| 338 |
+
Figure 16: Qualitative comparison of stickers generated using the discrete kNN-Diffusion model, 10 Nearest Neighbors to the text in the CLIP embedding and a discrete model that does not use kNN.
|
| 339 |
+
|
| 340 |
+
# 6.3 HUMAN EVALUATION PROTOCOL
|
| 341 |
+
|
| 342 |
+
For all of our human evaluation experiments, we used Amazon Mechanical Turk. For each experiment, we used 600 samples, each scored by five different people. The preferred sample was determined according to majority opinion. For each baseline comparison, we asked two questions (in different experiments): "Which image is of a higher quality?" and "Which image best matches the text?".
|
| 343 |
+
|
| 344 |
+
# 6.4 DATASETS
|
| 345 |
+
|
| 346 |
+
The modified PMD dataset is composed of the following set of publicly available text-image datasets: SBU Captions (Ordonez et al., 2011), Localized Narratives (Pont-Tuset et al., 2020), Conceptual Captions (Sharma et al., 2018), Visual Genome (Krishna et al., 2016), Wikipedia Image Text (Srinivasan et al., 2021), Conceptual Captions 12M (Changpinyo et al., 2021), Red Caps (Desai et al., 2021), and a filtered version of YFCC100M (Thomee et al., 2015). In total, the dataset contains 69 million text-image pairs.
|
| 347 |
+
|
| 348 |
+
# 6.5 ABLATION STUDY
|
| 349 |
+
|
| 350 |
+
Index size As one can expect, increasing the index size at inference time improves performance. To demonstrate this hypothesis, we evaluated our model with an index containing $10 \%$ , $30 \%$ , $50 \%$ and $70 \%$ images of PMD dataset, and obtained FID scores of 13.92, 13.85, 13.72, and 13.65 respectively.
|
| 351 |
+
|
| 352 |
+
kNN conditioning We examined several different approaches to kNN input conditioning: (i) forwarding the kNN embeddings and the single image embedding through a self-attention layer before feeding the contextualized $K + 1$ embeddings to the model, (ii) feeding the model with one embedding, computed using cross-attention between the image embedding and the kNN embeddings, and, (iii) feeding the model with the image embedding concatenated with a learned linear projection of the kNN embeddings. These variants received FID scores of 18.3, 22.4, 34.1 respectively.
|
| 353 |
+
|
| 354 |
+
# 6.6 RETRIEVAL MODEL
|
| 355 |
+
|
| 356 |
+
The retrieval model is implemented using FAISS (Johnson et al., 2019). FAISS is an efficient database, capable of storing billions of elements and finding their nearest neighbors in milliseconds. In the pre-processing phase, for each image in the dataset, we store the image index and its corresponding CLIP image embedding. During training, given a training image, we extract its CLIP image embedding and search for its 10 (see Fig. 9) nearest neighbors in the dataset based on the cosine similarity distance.
|
| 357 |
+
|
| 358 |
+
For an efficient search during training and inference, we use a non-exhaustive search: For this, we use an inverted file index. As in Babenko & Lempitsky (2014), we define Voronoi cells in the $d$ - dimensional space (where $d = 5 1 2$ is the CLIP embedding dimensional space), s.t each database vector falls in one of the cells. During search time, only the embeddings contained in the cell the query falls in and a few neighboring ones are compared against the query vector. In addition, to fit the index of our large-scale datasets on a 128GB RAM server, we compress the code size from $5 1 2 \times 3 2 / 8 = 2 0 4 8$ Bytes to 256 Bytes using optimized product quantization (Ge et al., 2013; Jegou et al., 2010). In Algorithm 1 we include pseudocode of the core of the implementation of the retrieval database.
|
| 359 |
+
|
| 360 |
+
# 6.7 DISCRETE KNN MODEL
|
| 361 |
+
|
| 362 |
+
We provide additional implementation details for the discrete diffusion model. Additional training details can be found in Tab. 3.
|
| 363 |
+
|
| 364 |
+
Vector Quantization For token quantization, we use VQ-VAE and adapt the publicly available VQGAN(Esser et al., 2021) model, trained on the OpenImages(Krasin et al., 2016) dataset. The encoder downsamples images to $3 2 \times 3 2$ tokens and uses a codebook vocabulary with 2887 elements.
|
| 365 |
+
|
| 366 |
+
Image Tokenization In our discrete generative model we model images as a sequence of discrete tokens. To this end, we utilize a vector-quantized variational auto-encoder (VQ-VAE) (Van Den Oord et al., 2017) as image tokenizer. VQ-VAE consists of three components: (i) an encoder, (ii) a learned codebook, and, (iii) a decoder. Given an image, the encoder extracts a latent representation. The codebook then maps each latent vector representation to its nearest vector in the codebook. Finally, the decoder reconstructs the image from the codebook representation. VQ-VAE is trained with the objectives of reconstruction and codebook learning. VQ-GAN (Esser et al., 2021) adds an adversarial loss term that tries to determine whether the generated image is fake or real. This added term was shown to improve reconstruction quality.
|
| 367 |
+
|
| 368 |
+
Transformer We follow Gu et al. (2021) and train a decoder-only Transformer. The decoder module contains 24 transformer blocks, each containing full attention, cross-attention for the concatenated conditioner, and a feed-forward network. The timestamp $n$ is injected using Adaptive Layer Normalization (Ba et al., 2016). The decoder contains 400 million parameters.
|
| 369 |
+
|
| 370 |
+
Classifier-free guidance We sample our diffusion models using classifier-free guidance (CFG) (Ho & Salimans, 2021; Nichol et al., 2021; Ramesh et al., 2022). CFG is performed by extrapolating an unconditional sample in the direction of a conditional sample. To support unconditional sampling, previous work had to fine-tune (Nichol et al., 2021) their models with $20 \%$ of the conditional features nullified. This enabled them to sample unconditional images from the model using the null condition, $y ^ { \prime } = \overrightarrow { 0 }$ , the null vector. We found that we can generate unconditional samples from our model using null conditioning without fine-tuning it. We hypothesize that by conditioning the model on a null vector, the cross-attention component is also nullified, resulting in no contribution to the diffusion process. During inference, in each step of the diffusion process we generate two images: conditional image logits, $p _ { \theta } ( x _ { n - 1 } | x _ { n } , y )$ , conditioned on the desired multi-modal embedding $y$ , and the unconditional image logits, $p _ { \theta } ( x _ { n - 1 } | x _ { n } , y ^ { \prime } )$ , conditioned on the null embedding. Then, the final image for a diffusion step $n$ is sampled from
|
| 371 |
+
|
| 372 |
+
$$
|
| 373 |
+
\begin{array} { r l } & { p _ { \theta } ( x _ { n - 1 } | x _ { n } , y ) = p _ { \theta } ( x _ { n - 1 } | x _ { n } , y ^ { \prime } ) + } \\ & { \qquad \lambda \big ( p _ { \theta } ( x _ { n - 1 } | x _ { n } , y ) - p _ { \theta } ( x _ { n - 1 } | x _ { n } , y ^ { \prime } ) \big ) } \end{array}
|
| 374 |
+
$$
|
| 375 |
+
|
| 376 |
+
where $\lambda$ is a scale coefficient. In all of our experiments, we set $\lambda = 8$ , which was found to yield the highest FID scores on the validation set. Note that the above extrapolation occurs directly on the logits output by $p _ { \theta }$ , in contrast to GLIDE (Nichol et al., 2021), which extrapolates the pixel values.
|
| 377 |
+
|
| 378 |
+
Training Objective For completeness we are adding the training objective of the discrete model. The network is trained to minimize the variational lower bound (VLB):
|
| 379 |
+
|
| 380 |
+
$$
|
| 381 |
+
\begin{array} { r l } & { \mathcal { L } _ { \mathrm { v l b } } = \mathcal { L } _ { 0 } + \mathcal { L } _ { 1 } + \cdot \cdot \cdot + \mathcal { L } _ { N - 1 } + \mathcal { L } _ { N } , } \\ & { \quad \mathcal { L } _ { 0 } = - \log p _ { \theta } ( x _ { 0 } | x _ { 1 } , f _ { i m g } ( I ) , \mathrm { k n n } _ { i m g } ( \mathbf { I } , k ) ) , } \\ & { \mathcal { L } _ { n - 1 } = D _ { K L } ( q ( x _ { n - 1 } | x _ { n } , x _ { 0 } ) \mid \mid p _ { \theta } ( x _ { n - 1 } | x _ { n } , f _ { i m g } ( I ) , \mathrm { k n n } _ { i m g } ( \mathbf { I } , k ) ) ) , } \\ & { \quad \mathcal { L } _ { N } = D _ { K L } ( q ( x _ { N } | x _ { 0 } ) \mid \mid p ( x _ { N } ) ) } \end{array}
|
| 382 |
+
$$
|
| 383 |
+
|
| 384 |
+
Where $p ( { \pmb x } _ { N } )$ is the prior distribution of timestep $N = 1 0 0$ , $f _ { i m g } ( I )$ is the CLIP image embedding, $\mathrm { k n n } _ { i m g } ( \mathrm { I } , k )$ is the $k$ nearest neighbors in the feature space of the image embedding. The full details can be found in Gu et al. (2021).
|
| 385 |
+
|
| 386 |
+
# 6.8 CONTINUOUS KNN MODEL
|
| 387 |
+
|
| 388 |
+
We provide additional implementation details for the continuous diffusion model. Additional training details can be found in Tab. 3.
|
| 389 |
+
|
| 390 |
+
Decoder. We followed (Nichol et al., 2021; Ho et al., 2020; Ramesh et al., 2022) and re-implemented a diffusion $U _ { ☉ }$ -net model. Specifically, we modify the architecture described in (Ramesh et al., 2022) by allowing multiple CLIP embeddings as the condition to the model. Since we do not have a paired text-image dataset, we removed the text transformer, and thus the text embedding. In particular, we use 512 convolution channels, 3 residual blocks, 64 heads channels and attention resolution of 32, 16 and 8. Similarly to our discrete model, we trained two models (1)
|
| 391 |
+
|
| 392 |
+

|
| 393 |
+
Figure 17: During training, only the image I is given (red), whereas during inference only the text $t$ is given (blue). In order to bridge the gap between the two distributions during training, we leverage the K nearest neighbors that should have a large enough distribution (dashed cone) to cover the potential text embedding (i.e. $c o s ( b ) < c o s ( a ) )$ . During inference, the opposite is applied.
|
| 394 |
+
|
| 395 |
+
a no-kNN conditioned only on CLIP image embedding during training, (2) a kNN conditioned on CLIP image embedding and its kNN. Finally, we enable classifier-free guidance by randomly setting the CLIP embeddings to zero $10 \%$ of the time. As demonstrated in Tab. 2, we find that humans prefer our model over $n o \mathrm { - } k N N 6 6 . 8 \%$ of the time for image quality and $6 9 . 4 \%$ of the time for text alignment.
|
| 396 |
+
|
| 397 |
+
Super-Resolution. As the decoder generates images with $6 4 \times 6 4$ resolution, we up-sampled the images to $2 5 6 \times 2 5 6$ using the open-source super resolution of (Nichol et al., 2021). To further upsample the images to $5 1 2 \times 5 1 2$ and $1 0 2 4 \times 1 0 2 4$ we used the open-source super resolution provided by (Wang et al., 2021).
|
| 398 |
+
|
| 399 |
+
Training Objectives For completeness we are addding the training objective of our continuous model. Following Ho et al. (2020); Nichol et al. (2021) we are using mean-squared error loss to predict the noise:
|
| 400 |
+
|
| 401 |
+
$$
|
| 402 |
+
L : = E _ { n \sim [ 1 , N ] , x _ { 0 } \sim q ( x _ { 0 } ) , \epsilon \sim \mathcal { N } ( 0 , \mathbf { I } ) } [ | | \epsilon - \epsilon _ { \theta } ( x _ { n } , n , y ) | | ^ { 2 } ]
|
| 403 |
+
$$
|
| 404 |
+
|
| 405 |
+
where $\epsilon _ { \theta }$ is a $U - n e t$ model and $\boldsymbol { y } = ( f _ { i m g } ( x _ { 0 } ) , \mathrm { k n n } _ { i m g } ( x _ { 0 } , k ) )$ .
|
| 406 |
+
|
| 407 |
+
Table 3: Training details of our models
|
| 408 |
+
|
| 409 |
+
<table><tr><td></td><td>Discrete</td><td>Continuous</td></tr><tr><td>Number of nearest neighbors</td><td>10</td><td>10</td></tr><tr><td>Diffusion steps</td><td>100</td><td>1000</td></tr><tr><td>Noise schedule</td><td>=</td><td>cosine</td></tr><tr><td>Sampling steps</td><td>100</td><td>250</td></tr><tr><td>Model size</td><td>400M</td><td>1B</td></tr><tr><td>Sampling variance method</td><td>-</td><td>analytic</td></tr><tr><td>Dropout</td><td>=</td><td>0.1</td></tr><tr><td>Weight decay</td><td>4.5e-2</td><td>-</td></tr><tr><td>Batch size</td><td>512</td><td>1600</td></tr><tr><td>Iterations</td><td>150K</td><td>500K</td></tr><tr><td>Learning rate</td><td>4.05-4</td><td>1.4e-4</td></tr><tr><td>optimizer</td><td>AdamW</td><td>AdamW</td></tr><tr><td>Adam β2</td><td>0.96</td><td>0.9999</td></tr><tr><td>Adam ∈</td><td>1.0e-8</td><td>1.0e-8</td></tr><tr><td>EMA decay</td><td>0.99</td><td>0.9999</td></tr><tr><td>warmup</td><td>5000</td><td>25000</td></tr><tr><td>#GPUs</td><td>128 A100</td><td>200 A100</td></tr></table>
|
| 410 |
+
|
| 411 |
+
Algorithm 1 Pseudo-code implementation for the construction of the retrieval model, training and sampling using conditioning kNN.
|
| 412 |
+
|
| 413 |
+
<table><tr><td rowspan=1 colspan=15>Retrieval model construction</td></tr><tr><td rowspan=4 colspan=15>def training(dataset: train image dataset)://inverted index of 50k centroids, 2//with optimized product quantization to 256B 3idx_cfg = "OPQ256_IVF50000_PQ256x8" 4index = faiss.index_factory(d,idx_cfg,faiss.METRIC_INNER_PRODUCT) 5</td></tr><tr><td rowspan=1 colspan=3></td></tr><tr><td rowspan=1 colspan=3></td><td rowspan=1 colspan=2></td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=2 colspan=15>idx_cfg = "OPQ256_IVF50000_PQ256x8" 4index = faiss.index_factory(d,idx_cfg,faiss.METRIC_INNER_PRODUCT) 5ivf= faiss.extract_index_ivf(index) 6clustering_index = faiss.index_cpu_to_all_gpus(faiss.IndexFlatIP(d))7</td></tr><tr></tr><tr><td rowspan=2 colspan=15>ivf.clustering_index = clustering_index 8train_dataset =[] 9</td></tr><tr><td rowspan=1 colspan=5>train_dataset =[]</td><td rowspan=3 colspan=10>train_dataset =[] 9for image in random.sample(dataset,1oooo00): 10train_dataset.append(CLIP_image_embedding(image)) 11index.train(train_dataset) 12for image in dataset: 13index.add(CLIP_image_encoder(image)) 14return index 15Training</td></tr><tr><td rowspan=1 colspan=4>for image in random.s</td><td></td><td rowspan=1 colspan=6>1000000):</td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td rowspan=2 colspan=1>def</td><td rowspan=7 colspan=14>def training(I:FAISS index, image,k:Number of NN,t:timestamp [0, T-1])timage_encoding = CLIP_image_encoder(image) 2kNN = I.search(image_encoding,k) 3condition = concatenate([image_encoding,kNN]) 4image_T = add_noise(image,t) 5image_O = diffusion_model(image_T,t,condition) 6loss = criterion(image0,image) 7return loss 89Sampling</td></tr><tr><td rowspan=1 colspan=1>encoding</td></tr><tr><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>condi</td></tr><tr><td></td><td rowspan=1 colspan=2></td></tr><tr><td rowspan=1 colspan=15>def sampling(I:FAISS index,text,k : Number of NN):text_encoding = CLIP_text_encoder(text) 2kNN = I.search(text_encoding,k) 3condition = concatenate([text_encoding,kNN]) 4image = sample_noise(T) 5for t in [T-1,T-2,...,0]: 6image = diffusion_model(image,t,condition) 7return image 8</td></tr></table>
|
| 414 |
+
|
| 415 |
+
Our approach is illustrated in Fig. 18. Additional manipulation examples are provided in Figs. 20. The full comparison with the baselines is provided in Fig. 21 and 22. We also provide in Fig. 19 several examples for the process of the manipulated images construction.
|
| 416 |
+
|
| 417 |
+

|
| 418 |
+
Figure 18: An illustration of our manipulation approach. During training: Given a training image (1), the model extracts its first nearest neighbor (2). Next, a random local area in the training image is selected (3), and the manipulated image is constructed by replacing the area with the corresponding nearest neighbor (4). The model then receives as input the manipulated image and the clip embedding of the local area that needs to be restored (5). During inference: Given an input image and a text query "A face of a male child", the model receives as input the image (4) and the clip embedding of the modifying text (5).
|
| 419 |
+
|
| 420 |
+

|
| 421 |
+
Figure 19: Illustration of the manipulated image construction process during training. Given an original image, we select a random local area, and extract the first nearest neighbor (1-NN). Using ECC alignment, we align the nearest neighbor with the original image and replace the random local area with it’s corresponding nearest neighbor local area. The model then receives as input the manipulated image, together with the CLIP embedding of the local area, and tries to predict the original image.
|
| 422 |
+
|
| 423 |
+

|
| 424 |
+
Figure 20: Additional manipulation examples, generated using our model.
|
| 425 |
+
|
| 426 |
+

|
| 427 |
+
Figure 21: comparison to Text2LIVE (Bar-Tal et al., 2022). For each input image, the bottom row corresponds to images generated by our model, and the top row corresponds to images generated by the Text2LIVE model.
|
| 428 |
+
|
| 429 |
+

|
| 430 |
+
Figure 22: comparison to Textual Inversion (Gal et al., 2022). For each input image, the bottom row corresponds to images generated by our model, and the top row corresponds to images generated by the Textual Inversion model.
|