Datasets:
Tasks:
Question Answering
Modalities:
Image
Formats:
imagefolder
Languages:
English
Size:
100K - 1M
ArXiv:
License:
Add files using upload-large-folder tool
Browse filesFiles changed (50)
- md/train/5KWmB6JePx/5KWmB6JePx.mdAdded+357
- md/train/8PA2nX9v_r2/8PA2nX9v_r2.mdAdded+269
- md/train/9FWas6YbmB3/9FWas6YbmB3.mdAdded+390
- md/train/B1IDRdeCW/B1IDRdeCW.mdAdded+270
- md/train/B1g8VkHFPH/B1g8VkHFPH.mdAdded+343
- md/train/B1xtFpVtvB/B1xtFpVtvB.mdAdded+256
- md/train/Byg9bxrtwS/Byg9bxrtwS.mdAdded+661
- md/train/H1gDaa4YwS/H1gDaa4YwS.mdAdded+370
- md/train/H1gN6kSFwS/H1gN6kSFwS.mdAdded+382
- md/train/HJlQfnCqKX/HJlQfnCqKX.mdAdded+335
- md/train/Hk95PK9le/Hk95PK9le.mdAdded+162
- md/train/Hyx0slrFvH/Hyx0slrFvH.mdAdded+475
- md/train/IBVBtz_sRSm/IBVBtz_sRSm.mdAdded+332
- md/train/IX3Nnir2omJ/IX3Nnir2omJ.mdAdded+478
- md/train/JeweO9-QqV-/JeweO9-QqV-.mdAdded+451
- md/train/KCzRX9N8BIH/KCzRX9N8BIH.mdAdded
- md/train/PhtFY9plHk/PhtFY9plHk.mdAdded
- md/train/Re_VXFOyyO/Re_VXFOyyO.mdAdded
- md/train/Rnn8zoAkrwr/Rnn8zoAkrwr.mdAdded
- md/train/S1eZYeHFDS/S1eZYeHFDS.mdAdded
- md/train/S1lg0jAcYm/S1lg0jAcYm.mdAdded
- md/train/ShnM-rRh4T/ShnM-rRh4T.mdAdded
- md/train/SkBsEQYll/SkBsEQYll.mdAdded
- md/train/SkgKO0EtvS/SkgKO0EtvS.mdAdded
- md/train/Sy2fzU9gl/Sy2fzU9gl.mdAdded
- md/train/SyL9u-WA-/SyL9u-WA-.mdAdded
- md/train/SylO2yStDr/SylO2yStDr.mdAdded
- md/train/SysEexbRb/SysEexbRb.mdAdded
- md/train/SyxBxCNFwr/SyxBxCNFwr.mdAdded
- md/train/UfX6vkvhtl/UfX6vkvhtl.mdAdded
- md/train/WEKfdiZYZi-/WEKfdiZYZi-.mdAdded
- md/train/_TGlfdZOHY3/_TGlfdZOHY3.mdAdded
- md/train/b9PoimzZFJ/b9PoimzZFJ.mdAdded
- md/train/eedamFFTcK5/eedamFFTcK5.mdAdded
- md/train/fpJX0O5bWKJ/fpJX0O5bWKJ.mdAdded
- md/train/iaO_IH7CnGJ/iaO_IH7CnGJ.mdAdded
- md/train/j5NrN8ffXC/j5NrN8ffXC.mdAdded
- md/train/jrA5GAccy_/jrA5GAccy_.mdAdded
- md/train/lvRTC669EY_/lvRTC669EY_.mdAdded
- md/train/m7QWxKp2Xqd/m7QWxKp2Xqd.mdAdded
- md/train/r1f0YiCctm/r1f0YiCctm.mdAdded
- md/train/r1ltnp4KwS/r1ltnp4KwS.mdAdded
- md/train/r7UC-b67YkO/r7UC-b67YkO.mdAdded
- md/train/rJfUCoR5KX/rJfUCoR5KX.mdAdded
- md/train/rJlk6iRqKX/rJlk6iRqKX.mdAdded
- md/train/rkGZuJb0b/rkGZuJb0b.mdAdded
- md/train/rkgbwsAcYm/rkgbwsAcYm.mdAdded
- md/train/uxpzitPEooJ/uxpzitPEooJ.mdAdded
- md/train/wxobw18IYOxu4/wxobw18IYOxu4.mdAdded
- md/train/zzdf0CirJM4/zzdf0CirJM4.mdAdded
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357# End-to-End Training of Multi-Document Reader and Retriever for Open-Domain Question Answering
Devendra Singh Sachan1,2, Siva Reddy1,2, William Hamilton1,2, Chris Dyer3, Dani Yogatama3
1Mila - Quebec AI Institute 2School of Computer Science, McGill University 3DeepMind sachande@mila.quebec, {siva, wlh}@cs.mcgill.ca {cdyer, dyogatama}@deepmind.com
# Abstract
We present an end-to-end differentiable training method for retrieval-augmented open-domain question answering systems that combine information from multiple retrieved documents when generating answers. We model retrieval decisions as latent variables over sets of relevant documents. Since marginalizing over sets of retrieved documents is computationally hard, we approximate this using an expectation-maximization algorithm. We iteratively estimate the value of our latent variable (the set of relevant documents for a given question) and then use this estimate to update the retriever and reader parameters. We hypothesize that such end-to-end training allows training signals to flow to the reader and then to the retriever better than stage-wise training. This results in a retriever that is able to select more relevant documents for a question and a reader that is trained on more accurate documents to generate an answer. Experiments on three benchmark datasets demonstrate that our proposed method outperforms all existing approaches of comparable size by 2-3 absolute exact match points, achieving new state-of-theart results. Our results also demonstrate the feasibility of learning to retrieve to improve answer generation without explicit supervision of retrieval decisions.
# 1 Introduction
Open-domain question answering (OpenQA) is a question answering task where the goal is to train a language model to produce an answer for a given question. In contrast to many question answering tasks, an OpenQA model is only provided with the question as its input without accompanying documents that contain the answer. One of the most promising approaches to OpenQA is based on augmenting the language model with an external knowledge source such as Wikipedia (often referred to as the evidence documents). In this approach, the model consists of two core components (Chen et al., 2017): (i) an information retrieval system to identify useful pieces of text from the knowledge source (the retriever); and (ii) a system to produce the answer given the retrieved documents and the question (the reader).
We can view such a model as a latent variable model, where the latent variables represent retrieved documents that are used to produce answers given questions (Lee et al., 2019). End-to-end (joint) training of this model is challenging since we need to learn both to generate an answer given retrieved documents and what to retrieve. Previous work considers two potential solutions (see Table 1 for a high-level summary). First, they adopt a stage-wise training, where the retriever is trained while freezing the reader and vice versa (Karpukhin et al., 2020, Izacard and Grave, 2021b,a). Another alternative is to constraint the reader to condition on each retrieved document individually1 (Guu et al., 2020)—sometimes with extra supervision for the latent variables in the form of the relevant document for a question (Lewis et al., 2020b).
Table 1: Bird’s-eye view of the recent OpenQA approaches. Multi-Doc reader indicates whether the reader architecture uses multiple documents or a single document. Retriever adaptation shows whether the retriever gets feedback from the reader to update its parameters. Disjoint denotes that first the retriever is trained and then the reader is trained. End-to-end denotes that the reader and retriever are trained jointly in one cycle. Multi-step indicates that the reader and retriever are trained iteratively in multiple cycles. Unsupervised retriever indicates whether the retriever is initialized using unsupervised approaches or using supervised data.
<table><tr><td></td><td colspan="5">Reader and Retriever Training</td></tr><tr><td>Model</td><td>Multi-Doc Reader</td><td>Retriever Adaptation</td><td>Disjoint End-to-End Multi-Step Unsupervised</td><td></td><td>Retriever</td></tr><tr><td>REALM (Guu et al., 2020)</td><td></td><td>√</td><td></td><td></td><td>√</td></tr><tr><td>DPR (Karpukhin et al., 2020)</td><td></td><td></td><td>√</td><td></td><td></td></tr><tr><td>RAG (Lewis et al., 2020b)</td><td></td><td>√</td><td></td><td></td><td></td></tr><tr><td>FiD (Izacard and Grave, 2021b)</td><td></td><td></td><td>√</td><td></td><td></td></tr><tr><td>FiD-KD (Izacard and Grave, 2021a)</td><td>√</td><td>√</td><td></td><td>√</td><td></td></tr><tr><td>EMDR² (Our Approach)</td><td>√</td><td>√</td><td>√</td><td></td><td>√</td></tr></table>
In this paper, we consider a retrieval-augmented question answering model that combines information from multiple documents when generating answers. Expectation-maximization (Dempster et al., 1977) offers a principled template for learning this class of latent variable models. We present EMDR2: End-to-end training of Multi-Document Reader and Retriever (§2). EMDR2 iteratively uses feedback from the model itself as “pseudo labels” of the latent variables for optimizing the retriever and reader parameters. We use two estimates of the latent variables: (i) prior scores for updating the reader parameters and (ii) approximate posterior scores given all observed variables for the retriever parameters.
We evaluate our proposed method by experimenting on three commonly used OpenQA datasets: Natural Questions, TriviaQA, and WebQuestions (§3). EMDR2 achieves new state-of-the-art results for models of comparable size on all datasets, outperforming recent approaches by 2-3 absolute exact match points. We also show that EMDR2 is robust to retriever initialization. It achieves high accuracy with unsupervised initialization, suggesting that supervised training of the retriever may not be an essential component of the training process as suggested in prior work (Karpukhin et al., 2020).
In summary, our contributions are as follows: (i) we present an end-to-end training method $( \mathrm { E M D R } ^ { 2 } $ ) for retrieval-augmented question-answering systems; (ii) we demonstrate that $\mathrm { E M D R ^ { 2 } }$ outperforms other existing approaches of comparable size without any kind of supervision on the latent variables; (iii) we provide ablation studies for a better understanding of the contributions of different components of our proposed method; and (iv) we release our code and checkpoints to facilitate future work and for reproducibility.2
EMDR2 is a framework that can be used to train retrieval-augmented text generation models for any task. We believe that our estimation technique in EMDR2 is also useful for learning similar latent variable models in other domains.
# 2 Model
Our proposed model EMDR2 consists of two components: (i) a neural retriever and (ii) a neural reader, which we train jointly in an end-to-end setting. Figure 1 shows an illustration of our model and training procedure. We discuss each component and our training objective in detail below.
# 2.1 Neural Retriever: Dual Encoder
Let the collection of evidence documents be denoted by $\mathcal { D } = \{ d _ { 1 } , \hdots , d _ { M } \}$ . Given a question $\pmb q$ the goal of the retriever module is to select a subset of documents $\mathcal { Z } \subset \mathcal { D }$ to answer the question. We model the retriever as a dual-encoder network (Bromley et al., 1994), where one encoder $f _ { q }$ encodes the question and another $f _ { d }$ encodes the evidence document (to a vector). The retrieval score is defined as the dot product between the two resulting vectors:
$$\begin{array} { r } { \mathrm { s c o r e } ( \pmb { q } , \pmb { d } _ { i } ; \Phi ) = { f } _ { \ b { q } } ( \pmb { q } ; \Phi _ { q } ) ^ { \top } { f } _ { d } ( \pmb { d } _ { i } ; \Phi _ { d } ) , } \end{array}$$
where $\Phi = [ \Phi _ { q } , \Phi _ { d } ]$ denotes the retriever parameters. We select top- $K$ documents for the question $\pmb q$ from $\mathcal { D }$ based on the retrieval scores. We denote the set of retrieved documents by $\mathcal { Z } = \{ z _ { 1 } , \ldots , z _ { K } \}$
We use transformer encoders (Vaswani et al., 2017) as our $f _ { q }$ and $f _ { d }$ . Our transformer architecture is similar to BERT with 12 layers and 768 hidden size (Devlin et al., 2019). We use the final representation of the first token (i.e., the standard [CLS] token from BERT’s tokenization) as our question (and similarly document) embedding. Initializing $f _ { q }$ and $f _ { d }$ with BERT weights has been shown to lead to a poor retrieval accuracy (Lee et al., 2019, Sachan et al., 2021). Therefore, we initialize the retriever with an unsupervised training procedure. We discuss our initialization technique in detail in $\ S$ .
# 2.2 Neural Reader: Fusion-in-Decoder
The reader takes as input a question $\pmb q$ and a set of retrieved documents (to be read) $\mathcal { Z }$ to generate an answer. Our reader is based on the Fusion-in-Decoder (FiD; Izacard and Grave, 2021b) model, which is built on top of T5 (Raffel et al., 2020). T5 is a pretrained sequence-to-sequence transformer that consists of an encoder $g _ { e }$ and a decoder $g _ { d }$ .
In FiD, each retrieved document $z _ { k }$ is first appended with its title $( t _ { z _ { k } } )$ and the question:
$$\pmb { x } _ { k } = [ \mathbb { C } \mathrm { L S } ] \pmb { q } [ \mathrm { S E P } ] \pmb { t } _ { z _ { k } } [ \mathrm { S E P } ] \pmb { z } _ { k } [ \mathrm { S E P } ] ,$$
where [CLS] is used to indicate the start of a document and [SEP] is used as a separator for the different parts of the document as well as the final token.
Each $\scriptstyle { \mathbf { { \mathit { x } } } } _ { k }$ is then independently given as an input to the T5 encoder $g _ { e }$ . The output representations corresponding to all of the retrieved documents are concatenated as:
$${ \bf X } _ { \mathcal { Z } } = [ g _ { e } ( { \pmb x } _ { 1 } ) ; \dots ; g _ { e } ( { \pmb x } _ { K } ) ] \in \mathbb { R } ^ { ( N \times K ) \times H } ,$$
where $N$ is the number of tokens in each ${ \pmb x } _ { k } { } ^ { 3 }$ and $H$ is the hidden size of the T5 encoder $g _ { e }$ . In this work, we use the T5-base configuration with $N = 5 1 2$ and $H = 7 6 8$ .
$\mathbf { X } _ { \mathcal { Z } }$ is then given as an input to the T5 decoder $g _ { d }$ . When generating an answer token, the decoder attends to both previously generated tokens (i.e., causal attention) as well as the tokens encoded in $\mathbf { X } _ { \mathcal { Z } }$ (i.e., cross attention). Since $\mathbf { X } _ { \mathcal { Z } }$ contains information from multiple documents, the decoder has the ability to aggregate useful signals contained in multiple documents and jointly reason over them. We define the probability of the answer as:
$$p ( \pmb { a } \mid \pmb { q } , \mathcal { Z } ; \Theta ) = \prod _ { t = 1 } ^ { T } p \left( a _ { t } \mid \pmb { a } _ { < t } , \pmb { q } , \mathcal { Z } ; \Theta \right) ,$$
where $\Theta$ denotes the reader parameters (i.e., T5 encoder and decoder) and $T$ is the number of answer tokens. We keep generating answer tokens until the decoder outputs a special EOS token or a pre-specified maximum answer length is reached.
# 2.3 End-to-End Training of Reader and Retriever
In contrast to previous work on generative question answering, we train both the reader and the retriever jointly in an end-to-end differentiable fashion.
Denote our latent variable which represents a set of retrieved documents by $Z$ and let $\mathcal { Z }$ be a possible value of $Z$ . The marginal likelihood of an answer (marginalizing over all the possible values of $Z$ )
 Figure 1: An illustration of the different components of $\mathrm { E M D R } ^ { 2 }$ . Colored blocks indicate components which contain trainable parameters.
is: $\begin{array} { r } { p ( \pmb { a } \mid q ; \Theta , \Phi ) = \sum _ { Z = \mathcal { Z } } p ( \pmb { a } \mid q , \mathcal { Z } ; \Theta ) p ( \mathcal { Z } \mid q ; \Phi ) } \end{array}$ . The goal of our training procedure is to find $\Phi$ and $\Theta$ Z that would maximize the above objective. Exactly optimizing Eq. 3 is intractable as it is combinatorial in nature.4 For one particular value $\mathcal { Z }$ , the log-likelihood is simpler to compute: $\log p ( { \pmb a } \mid { \pmb q } , { \mathcal Z } ; { \Theta } ) p ( { \mathcal Z } \mid { \pmb q } ; { \Phi } ) = \log p ( { \pmb a } \mid { \pmb q } , { \mathcal Z } ; { \Theta } ) + \log p ( { \mathcal Z } \mid { \pmb q } ; { \Phi } )$
Expectation-maximization (EM) algorithm (Dempster et al., 1977) offers a solution to learning this latent variable model. In classical EM, we iteratively compute the posterior of $Z$ given all observed variables and use it to update $\Theta$ and $\Phi$ .
We propose using two estimates of $Z { - } \mathcal { Z } _ { \mathrm { r e a d e r } }$ and $\mathcal { Z } _ { \mathrm { r e t r i e v e r } }$ —for updating the two components of the model (reader parameters $\Theta$ and retriever parameters $\Phi$ ):
$$\log \underbrace { p ( a \mid q , \mathcal { Z } _ { \mathrm { r e a d e r } } ; \Theta ) } _ { \mathrm { r e a d e r } } + \log \underbrace { p ( \mathcal { Z } _ { \mathrm { r e t r i e v e r } } \mid q ; \Phi ) } _ { \mathrm { r e t r i e v e r } } .$$
In the first term, we set the value of the latent variable $Z = \mathcal { Z } _ { \mathrm { r e a d e r } }$ based on the prior scores. In the second term, we seek to maximize an approximate posterior of $Z = \mathcal { Z } _ { \mathrm { r e t r i e v e r } }$ . We discuss them in more detail below.
Reader parameters $\Theta$ . For updating $\Theta$ (the first term of Eq. 3), we use the top- $K$ documents with the highest individual scores (as computed by Eq. 1 based on the current value of $\Phi$ ) to construct Zreader. This is equivalent to relying on the prior $p ( Z \mid q ; \Phi )$ to estimate ${ \mathcal { Z } } _ { \mathrm { r e a d e r } }$ (without using information from the answer $\textbf { \em a }$ ). We choose to use the prior to train reader parameters since the prior scores are also used at evaluation time to obtain the top- $K$ documents. As a result, there is no mismatch between training and test computations when computing $p ( \pmb { a } \mid \pmb { q } , \mathcal { Z } ; \Theta )$ (i.e., $\mathcal { Z }$ that is used at test time is obtained in exactly the same way as $\mathcal { Z } _ { \mathrm { r e a d e r } } = \mathcal { Z } _ { \mathrm { t o p } - K } ,$ .
Retriever parameters $\Phi$ . For updating $\Phi$ (the second term of Eq. 3), we propose to use the posterior estimate. In other words, we use additional information from $\textbf { \em a }$ when evaluating $Z _ { \mathrm { r e t r i e v e r } }$ to train $\Phi$ . Using the posterior allows our retriever to learn from richer training signals as opposed to relying only on the prior.
We need to be able to compute $p ( \mathcal { Z } _ { \mathrm { r e t r i e v e r } } \mid q , a ; \Theta , \Phi )$ to maximize the retriever parameters. However, computing this quantity is difficult since it is a probability of a set.5 Consider a set of $K$ documents (e.g., ${ \mathcal { Z } } _ { \mathrm { t o p } - K } ,$ ), where $z _ { k }$ denotes a document in the set. We approximate the maximization of the probability of the set by assuming that its probability is maximized if the sum of the probability of each document in the set is maximized.6 With this approximation, we arrive at a simpler quantity: $\begin{array} { r } { \sum _ { k = 1 } ^ { K } p ( z _ { k } \mid q , \pmb { a } ; \Theta , \Phi ) } \end{array}$ . Note that using Bayes rule, we can rewrite:7
$$p ( z _ { k } \mid q , a ; \Theta , \Phi ) \propto p ( a \mid q , z _ { k } ; \Theta ) p ( z _ { k } \mid q ; \Phi ) .$$
The reader now only conditions on one document when computing the probability of an answer $p ( \pmb { a } \mid \pmb { q } , \pmb { z } _ { k } ; \Theta )$ . This simpler reader uses the same parameters as the more sophisticated one $\Theta$ , but it only uses one document $z _ { k }$ instead of a set of documents.
To compute Eq. 4, we first obtain $K$ documents with the highest scores as computed by Eq. 1 based on the current value of $\Phi$ . We compute the probability of document $z _ { k } \in \mathcal { Z } _ { \mathrm { t o p } - K }$ as:
$$p ( z _ { k } \mid q , \mathcal { Z } _ { \mathrm { t o p } - K } ; \Phi ) \approx \frac { \exp ( \operatorname { s c o r e } ( q , z _ { k } ) / \tau ; \Phi ) } { \sum _ { j = 1 } ^ { K } \exp ( \operatorname { s c o r e } ( q , z _ { j } ) / \tau ; \Phi ) } ,$$
where $\tau$ is a temperature hyperparameter and the approximation assumes that documents beyond the top- $K$ contributes very small scores so we do not need to sum over all evidence documents $M$ in the denominator (which is in the order of tens of millions in our experiments). We then compute $p ( \pmb { a } \mid \pmb { q } , \pmb { z } _ { k } ; \Theta )$ similarly to Eq. 2.
Overall training objective of $\mathbf { E M D R } ^ { 2 }$ . Combining the above derivations, our end-to-end training objective that we seek to maximize for a particular example becomes:
$$\mathcal { L } = \underbrace { \log p ( a \mid q , \mathcal { Z } _ { \mathrm { t o p } \cdot K } ; \Theta ) } _ { \mathrm { r e a d e r } } + \log \sum _ { k = 1 } ^ { K } \mathbb { S } \mathbb { G } \left( p ( a \mid q , z _ { k } ; \Theta ) \right) p ( z _ { k } \mid q , \mathcal { Z } _ { \mathrm { t o p } \cdot K } ; \Phi ) ,$$
where $\mathbb { S } \mathbb { G }$ is the stop-gradient operator so that the reader parameters $\Theta$ are not updated to also perform well given a single document $z _ { k }$ . The stop-gradient operator in the second term of $\mathrm { E M D R ^ { 2 } }$ has several benefits. First, the FiD reader is trained from the first term of the $\mathrm { E M D R ^ { 2 } }$ objective in which its likelihood is conditioned on all the retrieved documents, similar to how the reader is used at test time. Second, it also makes training faster since the backward pass which is computationally more expensive than the forward pass is not needed, which in turn reduces the usage of GPU RAM as intermediate activations need not be saved.
Given a training example, we update $\Theta$ and $\Phi$ by taking gradients of Eq. 6 with respect to $\Theta$ and $\Phi$ in an end-to-end fashion. Intuitively, we train the reader to generate the correct answer given $K$ highest scoring documents ${ \mathcal { Z } } _ { \mathrm { t o p } - K }$ . For the retriever, we train it to select $K$ documents which collectively has a high score of generating an answer (since the sum over $K$ is inside the log in the second term) while taking into account feedback from the reader. Algorithm 1 summarizes our training algorithm.
Algorithm 1: End-to-end training of multi-document reader and retriever.
Input: Model parameters $\Theta$ and $\Phi$ , evidence documents $\mathcal { D }$
while not converged do
• Compute ${ \mathcal { Z } } _ { \mathrm { t o p } - K }$ using the current retriever parameters $\Phi$ . // E-step • Compute $p ( \dot { \pmb { a } } \mid \pmb { q } , \pmb { z } _ { k } )$ for each $z _ { k }$ using the current reader parameters $\Theta$ . // E-step • Update model parameters $\Theta$ and $\Phi$ to maximize the log-likelihood in Eq. 6. // M-step
end
# 3 Experiments
# 3.1 Datasets
We experiment with three commonly used open-domain question answering datasets:
6 The intuition is that each element of the set contributes independently, which greatly simplifies the computation to find the maximum of the set.
• Natural Questions (NQ; Kwiatkowski et al., 2019). NQ contains questions asked by users of the Google search engine. Similar to Lee et al. (2019), we use the short answer subset.
• TriviaQA (Joshi et al., 2017). TriviaQA is a collection of trivia question-answer pairs that were collected from multiple sources on the web.
• WebQuestions (WebQ; Berant et al., 2013). WebQ questions were collected using Google Suggest API and the answers were annotated using Mechanical Turk. We use the version from Chen et al. (2017) where Freebase IDs in the answers are replaced by entity names.
Evidence documents $\mathcal { D }$ . We use the preprocessed English Wikipedia dump from December 2018 released by Karpukhin et al. (2020) as our evidence documents. Each Wikipedia article is split into non-overlapping 100 words long segments. Each segment corresponds to a document in our case. There are a total of 21,015,324 documents in total.
We provide descriptive statistics and other preprocessing details in Appendix A.
# 3.2 Implementation Details
Hardware and library. We run all of our experiments on a machine with 96 CPUs, 1.3TB physical memory, and 16 A100 GPUs. We use PyTorch (Paszke et al., 2019) to implement our proposed model and relevant baselines.
Model configurations. For both the retriever and reader, we use the base configuration that consists of 12 layers, 768 dimensional hidden size, and 12 attention heads. In all experiments, we retrieve 50 documents, unless stated otherwise. We only use the base configuration in our experiments due to GPU memory constraints. However, we believe that our results would generalize to larger configurations as well.
Retrieval. To support fast retrieval, we pre-compute evidence document embeddings and store them in a distributed fashion over all the GPUs. We refer to these document embeddings as the document index. For each question, we retrieve documents in an online (on-the-fly) manner by performing exact maximum inner product search (MIPS), implemented using asynchronous distributed matrix multiplication over the document index. These documents are converted to subwords using BERT’s tokenization and are given as input to the T5 reader. If a tokenized document is shorter than 512 tokens, it is padded using the tokens from the neighboring documents until the maximum token limit is reached. Such padding additionally helps to provide an extended context for answer generation.
Initialization and training details. We initialize the parameters of the model with unsupervised pre-training before performing supervised training using the question-answer training examples. Unsupervised pre-training is essential as it helps to warm-start the retriever so that it outputs relevant documents for a given question.
We first pre-train the retriever parameters with unsupervised Inverse Cloze Task training (Lee et al., 2019) for 100,000 steps. We then extract sentences containing named entities from the evidence documents. Next, we replace $15 \%$ of the named entity tokens with masked tokens, which are often referred to as masked salient spans (MSS; Guu et al., 2020). The masked sentence can be considered as the question and its salient spans (i.e, named entities) can be considered as the answer to train the model with Eq. 6. We train the model on these question-answer (masked sentence-named entities) pairs for 82,000 steps with a batch size of 64 using Adam (Kingma and Ba, 2015). We refer to this initialization method as unsupervised pre-training with masked salient spans. We provide further description in Appendix C.
After MSS training, we finetune the model on the dataset-specific question-answer training examples with EMDR2. We perform training for 10 epochs on NQ and TriviaQA with a batch size of 64, and for 20 epochs on WebQ with a batch size of 16. During training, we save a checkpoint every 500 steps and select the best checkpoint based on its performance on the development set.
During end-to-end training, since the parameters of the document encoder $( f _ { d } )$ are also updated at every step, the pre-computed document embeddings become stale as training progresses. We use the most recent document encoder checkpoint to compute fresh document embeddings asynchronously with which the document index is updated after every 500 training steps to prevent staleness.
Table 2: Exact match scores on three evaluation datasets. Top- $K$ denotes the number of retrieved documents that are used by the reader to produce an answer. To provide a fair comparison with our reimplementations, we show results from other papers with the base configuration, except for RAG-Sequence that uses BART-large (Lewis et al., 2020a). $\dagger$ indicates that their results on WebQ use NQ training data to pretrain the model.
<table><tr><td rowspan="2">Model</td><td rowspan="2">top-K</td><td colspan="2">NQ</td><td colspan="2">TriviaQA</td><td colspan="2">WebQ</td><td rowspan="2">#of params</td></tr><tr><td>dev</td><td>test</td><td>dev</td><td>test</td><td>dev</td><td>test</td></tr><tr><td colspan="9">Closed-Book QA Models</td></tr><tr><td>T5-base (Roberts et al., 2020)</td><td>0</td><td></td><td>25.7</td><td></td><td>24.2</td><td>=</td><td>28.2</td><td>220M</td></tr><tr><td>T5-large (Roberts et al.,2020)</td><td>0</td><td>-</td><td>27.3</td><td>=</td><td>28.5</td><td></td><td>29.5</td><td>770M</td></tr><tr><td>T5-XXL (Roberts et al., 2020)</td><td>0</td><td></td><td>32.8</td><td></td><td>42.9</td><td></td><td>35.6</td><td>11B</td></tr><tr><td>GPT-3 (Brown et al., 2020)</td><td>0</td><td>-</td><td>29.9</td><td>=</td><td>1</td><td>=</td><td>41.5</td><td>175B</td></tr><tr><td colspan="9">Open-Book QA Models</td></tr><tr><td>BM25 + BERT (Lee et al., 2019)</td><td>5</td><td>24.8</td><td>26.5</td><td>47.2</td><td>47.1</td><td>27.1</td><td>21.3</td><td>220M</td></tr><tr><td>ORQA (Lee et al., 2019)</td><td>5</td><td>31.3</td><td>33.3</td><td>45.1</td><td>45.0</td><td>36.8</td><td>30.1</td><td>330M</td></tr><tr><td>REALM (Guu et al., 2020)</td><td>5</td><td>38.2</td><td>40.4</td><td>1</td><td>1</td><td>1</td><td>40.7</td><td>330M</td></tr><tr><td>DPR (Karpukhin et al., 2020)</td><td>25</td><td>1</td><td>41.5</td><td>-</td><td>56.8</td><td>-</td><td>34.6</td><td>330M</td></tr><tr><td>RECONsIDER (Iyer et al.,2021)t</td><td>30</td><td>-</td><td>43.1</td><td>1</td><td>59.3</td><td>-</td><td>44.4</td><td>440M</td></tr><tr><td>RAG-Sequence (Lewis et al., 2020b)t</td><td>50</td><td>44.0</td><td>44.5</td><td>55.8</td><td>56.8</td><td>44.9</td><td>45.2</td><td>626M</td></tr><tr><td>Individual Top-K (Sachan et al., 2021)</td><td>-</td><td>1</td><td>45.9</td><td>1</td><td>56.3</td><td>1</td><td>1</td><td>440M</td></tr><tr><td>Joint Top-K (Sachan et al., 2021)</td><td>50</td><td>-</td><td>49.2</td><td>1</td><td>64.8</td><td>-</td><td>-</td><td>440M</td></tr><tr><td>FiD (Izacard and Grave, 2021b)</td><td>100</td><td>1</td><td>48.2</td><td>1</td><td>65.0</td><td>=</td><td>=</td><td>440M</td></tr><tr><td>FiD-KD (Izacard and Grave, 2021a)</td><td>100</td><td>48.0</td><td>49.6</td><td>68.6</td><td>68.8</td><td>=</td><td>=</td><td>440M</td></tr><tr><td colspan="9">Our Implementation (Base Configuration)</td></tr><tr><td>FiD /T5-base</td><td>0</td><td>26.0</td><td>25.1</td><td>26.7</td><td>27.8</td><td>31.0</td><td>32.4</td><td>220M</td></tr><tr><td>FiD (DPR retriever, T5 reader)</td><td>1</td><td>37.3</td><td>38.4</td><td>50.8</td><td>50.4</td><td>40.2</td><td>38.3</td><td>440M</td></tr><tr><td>FiD (DPR retriever, T5 reader)</td><td>50</td><td>47.3</td><td>48.3</td><td>65.5</td><td>66.3</td><td>46.0</td><td>45.2</td><td>440M</td></tr><tr><td>FiD (MSS+DPR retriever, T5 reader)</td><td>50</td><td>48.8</td><td>50.4</td><td>68.0</td><td>68.8</td><td>43.5</td><td>46.8</td><td>440M</td></tr><tr><td>FiD (MSS retriever, MSS reader)</td><td>50</td><td>38.5</td><td>40.1</td><td>60.0</td><td>59.8</td><td>39.1</td><td>40.2</td><td>440M</td></tr><tr><td>EMDR² (MSS retriever,MSS reader)</td><td>50</td><td>50.4</td><td>52.5</td><td>71.1</td><td>71.4</td><td>49.9</td><td>48.7</td><td>440M</td></tr></table>
Inference. We use greedy decoding for answer generation at inference time.
# 3.3 Baselines
We compare our model to other approaches for OpenQA that can be categorized under the following two classes:
• Closed-book QA models. Large-scale language models capture a lot of world knowledge in their parameters derived from the corpus they have been trained on (Petroni et al., 2019). We compare with the work of Roberts et al. (2020) who show that larger T5 models—when finetuned with question-answer pairs—can perform remarkably well. We also compare with the few-shot results of GPT-3 (Brown et al., 2020).8
• Open-book QA models. Similar to this work, these models consist of retriever and reader components and adopt the retrieve then predict approach for answering questions given a collection of evidence documents. These models mainly differ in how the retriever is initialized (ORQA; Lee et al., 2019, DPR; Karpukhin et al., 2020), whether the reader processes a single document (ORQA, DPR, RAG; Lewis et al., 2020b) or multiple documents (FiD; Izacard and Grave, 2021b), or whether the reader and retriever are trained jointly or in a multistage process (REALM; Guu et al., 2020, FiD-KD; Izacard and Grave, 2021a).
# 3.4 Results
We follow standard conventions and report exact match (EM) scores using the reference answers included in each dataset. Table 2 shows our main results. We divide the table into three main sections: closed-book QA models, open-book QA models, and our implementation. The first two sections contain results from other papers, which we include for comparisons. The last section includes results from our proposed model, as well as our reimplementation of relevant baselines to control for our experimental setup.
Our reimplementation of T5-base provides strong baselines when the number of retrieved documents is set to 0 (no retrieval) and 1. From Table 2, we see that the setting of top-1 vastly improves performance over the setting with no retrieved documents, signifying the importance of retrieval for OpenQA tasks. When further increasing the top- $k$ documents to 50, the performance of the FiD models substantially improves over the top-1 retrieval, verifying the observation from (Izacard and Grave, 2021b) about the importance of modeling the retrieved documents as a set.
Comparing EMDR2 with our reimplementation of FiD illustrates the benefit of our end-to-end training approach. The underlying model is similar in both cases, but the training method is different. FiD adopts a two-stage approach to first train the retriever and then the reader. We have three variants of FiD: (i) the reader and retriever are initialized with MSS training, (ii) the retriever is initialized with DPR training, which is the setting used in the original paper (Izacard and Grave, 2021b), and (iii) the retriever is initialized with $\mathrm { M S S + D P R }$ training from (Sachan et al., 2021), as it further improves DPR recall. EMDR2 outperforms all the variants by large margins on all the datasets.
The current best approach for training multi-document reader and retriever is FiD-KD (Izacard and Grave, 2021a). FiD-KD is a complex training procedure that requires multiple training stages and performs knowledge distillation with inter-attention scores. We take the results from the original paper when comparing our model with FiD-KD. EMDR2 outperforms the reported numbers of FiD-KD by more than 2.5 points on NQ and TriviaQA to obtain new state-of-the-art results on these benchmarks.
In addition to better performance, $\mathrm { E M D R } ^ { 2 }$ also has three other advantages compared to FiD-KD: (i) EMDR2 is more efficient since it only uses 50 evidence documents, whereas FiD-KD leverages 100 documents; (ii) FiD-KD is based on a distillation approach which requires multiple cycles of retriever and reader training, while EMDR2 only requires one cycle of end-to-end training; and (iii) FiD-KD relies on supervised initialization of the retriever to achieve its best performance. EMDR2 is more robust to the retriever initialization, as demonstrated by state-of-the-art results even with unsupervised initialization of the retriever.
For the WebQ dataset, the training set size is much smaller compared to the other datasets (Table 5). Previous approaches such as RAG rely on supervised transfer (i.e., they finetune a model pre-trained on NQ) to obtain good results. In contrast, EMDR2 improves over the results from this RAG model by 3.5 points without the supervised transfer step. This result demonstrates the applicability of our approach to the low-resource setting where we only have a limited number of training examples.
We also perform qualitative analysis of the model outputs, which is included in Appendix E.
# 3.5 Ablations
Number of retrieved documents. We investigate the performance of $\mathrm { E M D R } ^ { 2 }$ and FiD as we vary the number of retrieved documents $K$ in Figure 2. We observe that when the number of retrieved documents is increased, both $\mathrm { E M D R } ^ { 2 }$ and FiD improve in performance. When $K$ is small, the gap between EMDR2 and FiD is larger. This indicates the efficacy of $\mathrm { E M D R } ^ { 2 }$ in a more constrained setting where we can only retrieve a small number of documents (e.g., due to memory limitations).
Retriever initialization. We explore the effect of different parameter initialization strategies when training with $\mathrm { E M D R } ^ { 2 }$ : (i) unsupervised MSS pre-training, (ii) supervised retriever training (DPR), and (iii) MSS pre-training followed by supervised retriever training $( \mathbf { M S S } + \mathbf { D P R }$ ; Sachan et al. (2021)). Table 3 shows our results. We can see that on NQ, MSS pre-training being unsupervised leads to a lower initial retriever recall than DPR. After EMDR2 training, the recall improves by $20 \%$ (highlighted in yellow cells). Training with DPR initialization leads to the same final recall as obtained by MSS pre-training, suggesting that DPR initialization of the retriever may not be an essential component to obtain good performance in OpenQA tasks. Similar trends are also observed on TriviaQA and WebQ. Similarly, $\mathrm { M S S + D P R }$ initialization has a better initial recall but leads to a marginal or no improvements in answer extraction performance over MSS pre-training. Finally, we also observe that MSS pre-training also provides an improvement of 2 points in answer extraction on WebQ when compared to the T5 reader (shown in orange cells), highlighting its importance in the low-resource OpenQA tasks.

Figure 2: Performance on NQ, TriviaQA, and WebQ as we vary the number of retrieved documents.
<table><tr><td></td><td></td><td colspan="2">NQ (dev)</td><td colspan="4">TriviaQA (dev)</td><td colspan="3">WebQ (dev)</td></tr><tr><td>Retriever</td><td>Reader</td><td colspan="2">R@50</td><td>EM</td><td colspan="2">R@50</td><td>EM</td><td colspan="2">R@50</td><td>EM</td></tr><tr><td>Initialization</td><td>Initialization</td><td>B.T.A.T.</td><td></td><td></td><td>B.T.</td><td>A.T.</td><td></td><td>B.T.</td><td>A.T.</td><td></td></tr><tr><td>MSS pre-training</td><td>MSS pre-training</td><td>66.4</td><td>86.3</td><td>50.4</td><td>74.8</td><td>86.2</td><td>71.1</td><td>59.8</td><td>88.6</td><td>49.9</td></tr><tr><td>MSS pre-training</td><td>T5</td><td>66.4</td><td>86.3</td><td>50.3</td><td>74.8</td><td>86.3</td><td>70.9</td><td>59.8</td><td>88.6</td><td>47.7</td></tr><tr><td>DPR training</td><td>T5</td><td>82.3</td><td>86.3</td><td>50.0</td><td>83.2</td><td>86.2</td><td>70.5</td><td>84.2</td><td>88.6</td><td>49.0</td></tr><tr><td>MSS +DPR</td><td>MSS pre-training</td><td>84.5</td><td>86.3</td><td>50.5</td><td>85.3</td><td>86.3</td><td>71.2</td><td>85.0</td><td>88.6</td><td>49.9</td></tr></table>
Table 3: $\mathrm { R @ 5 0 }$ denotes the retrieval recall from the top-50 retrieved documents. B.T. and A.T. indicates $\mathrm { R @ 5 0 }$ score Before Training and After Training the model, respectively.
# 3.6 Alternative End-to-End Training Objectives
We compare $\mathrm { E M D R } ^ { 2 }$ objective (Eq. 6) to two alternative formulations for end-to-end training.
In the first alternative formulation, when training the retriever parameters $\Phi$ , we simply factorize $p ( \mathcal { Z } \mid \mathbf { \bar { q } } ; \Phi ) =$ $\textstyle \prod _ { k = 1 } ^ { K } p ( z _ { k } \mid q ; \Phi )$ to arrive at the following objective:
$$\mathcal { L } _ { \mathrm { a l t - 1 } } = \log p ( \boldsymbol { a } \mid \boldsymbol { q } , \mathcal { Z } ; \boldsymbol { \Theta } ) + \sum _ { k = 1 } ^ { K } \log p ( \boldsymbol { z } _ { k } \mid \boldsymbol { q } , \mathcal { Z } ; \boldsymbol { \Phi } ) .$$
The second term in this objective is maximised by a uniform retrieval, in other words, by removing any discrimination between documents in the retriever. We include it to show the impact of an adversarial objective.
<table><tr><td>Method t top-k</td><td>NQ</td><td>TriviaQA</td><td>WebQ</td></tr><tr><td>FiD EMDR²</td><td>50 47.3 50 50.4</td><td>65.5 71.1</td><td>46.0 49.9</td></tr><tr><td>Lalt-1</td><td>50 14.1</td><td>11.9</td><td>28.0</td></tr><tr><td>Lalt-2</td><td>50 49.9</td><td>69.6</td><td>28.8</td></tr></table>
Table 4: EM scores on the development set for alternative training objectives.
In the second formulation, for each retrieved document, we approximate its posterior under the assumption that we have a uniform prior over the set of retrieved documents: $\tilde { p } ( z _ { k } \mid q , \pmb { a } , \mathcal { Z } _ { \mathrm { t o p } - K } ; \Theta ) \propto$ $p ( { \pmb a } \mid { \pmb q } , z _ { k } ; \Theta ) \times \frac { 1 } { K }$ . We use this to train reader and retriever parameters as follows:
$$\mathcal { L } _ { \mathrm { a l t - 2 } } = \log p ( \boldsymbol { a } \mid \boldsymbol { q } , \mathcal { Z } ; \boldsymbol { \Theta } ) + \mathbb { K L } \big ( \mathbb { S } \mathbb { G } \left( \tilde { p } ( \boldsymbol { z } _ { k } \mid \boldsymbol { q } , \boldsymbol { a } , \mathcal { Z } _ { \mathrm { t o p } \cdot K } ; \boldsymbol { \Theta } ) \right) \mid \mid p ( \boldsymbol { z } _ { k } \mid \boldsymbol { q } , \mathcal { Z } ; \boldsymbol { \Phi } ) \big ) .$$
Intuitively, we try to match the probability of retrieving a document $z _ { k }$ with the “contribution” of that document to the generated answer $\textbf { \em a }$ , regardless of whether the retriever is relatively more or less likely to retreieve the document a priori.
Table 4 shows our results on the development set of NQ. We observe that training with the adversarial ${ \mathcal { L } } _ { \mathrm { a l t - 1 } }$ objective diverges, leading to poor performance, as expected. This shows that harming the retriever during training can significantly harm performance of the QA system. In contrast, although it disregards the estimated prior, the ${ \mathcal { L } } _ { \mathrm { a l t - 2 } }$ objective still improves over the FiD baseline for NQ and
TriviaQA. However, it still lags behind EMDR2. On WebQ, the ${ \mathcal { L } } _ { \mathrm { a l t - 2 } }$ objective diverges and leads to a poor performance. We leave further analysis on the convergence of ${ \mathcal { L } } _ { \mathrm { a l t - 2 } }$ objective as a part of future work.
# 4 Related Work
Our work is based on end-to-end training of neural readers and retrievers, which we discuss in $\ S 1 , \ S 2$ and $\ S 3$ . Here we instead focus on discussing previous work related to standalone neural retrievers, neural readers, and their application in other natural language processing tasks.
Neural retrievers. There are two broad classes of neural retrievers based on the number of embeddings computed for a document: dual encoders (Yih et al., 2011, Lee et al., 2019) and multivector encoders (Khattab and Zaharia, 2020, Luan et al., 2021). Dual encoders store one embedding for each evidence document. Multivector encoders require multiple embeddings, which can be computationally expensive for large-scale retrieval. Due to the large size of the evidence document collection in OpenQA, our work uses the more efficient dual-encoder. Sachan et al. (2021) show that the performance of supervised dual encoders in OpenQA can be improved when pre-training with the Inverse Cloze Task for the high-resource setting or masked salient spans for the low-resource setting.
Neural readers. Neural readers output an answer given retrieved documents as its input. There are also two broad classes of neural readers: extractive and generative. Extractive readers (Clark and Gardner, 2018, de Masson d’Autume et al., 2019, Wang et al., 2019, Guu et al., 2020, Karpukhin et al., 2020) extract a span from a retrieved document to produce an answer. Generative readers (Izacard and Grave, 2021b), on the other hand, generates an answer conditioned on the retrieved documents.
Other application areas. In addition to question answering, retrieval-augmented methods have been successfully applied to other natural language processing tasks. In left-to-right language modeling, retrieving similar words from an external memory has been shown to improve perplexity (Khandelwal et al., 2020, Yogatama et al., 2021). In machine translation, retrieving domain-specific target language tokens has improved performance in domain adaptation (Khandelwal et al., 2021). Finally, in dialog modeling, retrieving knowledge-informed text has helped improve factual correctness in the generated conversations (Fan et al., 2021).
We provide a detailed comparison of EMDR2 with some of the previous work in Appendix C and D.
# 5 Discussion
Summary of contributions. We presented EMDR2, an end-to-end training method for retrievalaugmented question answering systems. We showed how to arrive at our training objective using the expectation-maximization algorithm. We demonstrated that EMDR2 achieves state-of-the-art performance on three benchmark OpenQA datasets.
Technical limitations. EMDR2 shares a few limitations with other retrieval-augmented question answering models. In particular, as evidence documents are stored in an uncompressed format, maintaining them and searching for relevant documents can be expensive (both in terms of compute and memory consumption). In our experiments, we only focused on open-domain question answering. It would be interesting to see how EMDR2 performs for other text generation models as well. We also note that training is relatively resource-heavy (requiring 16 GPUs), potentially having environmental concerns.
Potential negative societal impacts. While EMDR2 has the potential to improve language models in the low-resource setting (as demonstrated by our results on WebQ in $\ S 3 . 4 )$ , it could exhibit typical biases that are associated with large language models. For example, our model does not have an explicit mechanism to generate answers that are calibrated for fairness across all spectra. As a retrieval-augmented method, it also could be more prone to generating fake answers if an attacker manages to have access and modify information in the collection of evidence documents.
# Acknowledgements
The authors would like to thank the DeepMind Language team, Mila’s students, and anonymous reviewers for providing us valuable feedback and useful suggestions about this work that helped us improve the paper.
# Funding Statement
DSS was supported by the Canada CIFAR AI Chair held by Prof. William Hamilton.
# References
Berant, J., Chou, A., Frostig, R., and Liang, P. (2013). Semantic parsing on Freebase from questionanswer pairs. In Proceedings of the 2013 Conference on Empirical Methods in Natural Language Processing. Bromley, J., Guyon, I., LeCun, Y., Säckinger, E., and Shah, R. (1994). Signature verification using a "siamese" time delay neural network. In Advances in Neural Information Processing Systems. Brown, T., Mann, B., Ryder, N., Subbiah, M., Kaplan, J. D., Dhariwal, P., Neelakantan, A., Shyam, P., Sastry, G., Askell, A., Agarwal, S., Herbert-Voss, A., Krueger, G., Henighan, T., Child, R., Ramesh, A., Ziegler, D., Wu, J., Winter, C., Hesse, C., Chen, M., Sigler, E., Litwin, M., Gray, S., Chess, B., Clark, J., Berner, C., McCandlish, S., Radford, A., Sutskever, I., and Amodei, D. (2020). Language models are few-shot learners. In Advances in Neural Information Processing Systems. Chen, D., Fisch, A., Weston, J., and Bordes, A. (2017). Reading Wikipedia to answer open-domain questions. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers). Clark, C. and Gardner, M. (2018). Simple and effective multi-paragraph reading comprehension. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers). de Masson d’Autume, C., Ruder, S., Kong, L., and Yogatama, D. (2019). Episodic memory in lifelong language learning. In Advances in Neural Information Processing Systems. Dempster, A., Laird, N., and Rubin, D. (1977). Maximum likelihood from incomplete data via the em algorithm. Journal of the Royal Statistical Society, Series B, 1(39), 1–38. Devlin, J., Chang, M.-W., Lee, K., and Toutanova, K. (2019). 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). Fan, A., Gardent, C., Braud, C., and Bordes, A. (2021). Augmenting Transformers with KNN-Based Composite Memory for Dialog. Transactions of the Association for Computational Linguistics, 9. Guu, K., Lee, K., Tung, Z., Pasupat, P., and Chang, M. (2020). Retrieval augmented language model pre-training. In Proceedings of the 37th International Conference on Machine Learning. Iyer, S., Min, S., Mehdad, Y., and Yih, W. (2021). Reconsider: Re-ranking using span-focused cross-attention for open domain question answering. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers). Izacard, G. and Grave, E. (2021a). Distilling knowledge from reader to retriever for question answering. In International Conference on Learning Representations. Izacard, G. and Grave, E. (2021b). Leveraging passage retrieval with generative models for open domain question answering. In Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: Main Volume.
Joshi, M., Choi, E., Weld, D., and Zettlemoyer, L. (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).
Karpukhin, V., Oguz, B., Min, S., Wu, L., Edunov, S., Chen, D., and Yih, W.-t. (2020). Dense ˘ passage retrieval for open-domain question answering. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP).
Khandelwal, U., Levy, O., Jurafsky, D., Zettlemoyer, L., and Lewis, M. (2020). Generalization through memorization: Nearest neighbor language models. In International Conference on Learning Representations.
Khandelwal, U., Fan, A., Jurafsky, D., Zettlemoyer, L., and Lewis, M. (2021). Nearest neighbor machine translation. In International Conference on Learning Representations.
Khattab, O. and Zaharia, M. (2020). Colbert: Efficient and effective passage search via contextualized late interaction over bert. In Proceedings of the 43rd International ACM SIGIR Conference on Research and Development in Information Retrieval.
Kingma, D. P. and Ba, J. (2015). Adam: A method for stochastic optimization. In The 2015 International Conference for Learning Representations.
Kwiatkowski, T., Palomaki, J., Redfield, O., Collins, M., Parikh, A., Alberti, C., Epstein, D., Polosukhin, I., Kelcey, M., Devlin, J., Lee, K., Toutanova, K. N., Jones, L., Chang, M.-W., Dai, A., Uszkoreit, J., Le, Q., and Petrov, S. (2019). Natural questions: a benchmark for question answering research. Transactions of the Association of Computational Linguistics.
Lee, K., Chang, M.-W., and Toutanova, K. (2019). Latent retrieval for weakly supervised open domain question answering. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics.
Lewis, M., Liu, Y., Goyal, N., Ghazvininejad, M., Mohamed, A., Levy, O., Stoyanov, V., and Zettlemoyer, L. (2020a). BART: Denoising sequence-to-sequence pre-training for natural language generation, translation, and comprehension. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics.
Lewis, P., Perez, E., Piktus, A., Petroni, F., Karpukhin, V., Goyal, N., Küttler, H., Lewis, M., Yih, W.-t., Rocktäschel, T., Riedel, S., and Kiela, D. (2020b). Retrieval-augmented generation for knowledge-intensive nlp tasks. In Advances in Neural Information Processing Systems.
Luan, Y., Eisenstein, J., Toutanova, K., and Collins, M. (2021). Sparse, Dense, and Attentional Representations for Text Retrieval. Transactions of the Association for Computational Linguistics, 9.
Min, S., Chen, D., Hajishirzi, H., and Zettlemoyer, L. (2019). A discrete hard EM approach for weakly supervised question answering. 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), Hong Kong, China. Association for Computational Linguistics.
Paszke, A., Gross, S., Massa, F., Lerer, A., Bradbury, J., Chanan, G., Killeen, T., Lin, Z., Gimelshein, N., Antiga, L., Desmaison, A., Kopf, A., Yang, E., DeVito, Z., Raison, M., Tejani, A., Chilamkurthy, S., Steiner, B., Fang, L., Bai, J., and Chintala, S. (2019). Pytorch: An imperative style, highperformance deep learning library. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alché-Buc, E. Fox, and R. Garnett, editors, Advances in Neural Information Processing Systems.
Petroni, F., Rocktäschel, T., Riedel, S., Lewis, P., Bakhtin, A., Wu, Y., and Miller, A. (2019). Language models as knowledge bases? In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP).
Qi, P., Zhang, Y., Zhang, Y., Bolton, J., and Manning, C. D. (2020). Stanza: A Python natural language processing toolkit for many human languages. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics: System Demonstrations.
Raffel, C., Shazeer, N., Roberts, A., Lee, K., Narang, S., Matena, M., Zhou, Y., Li, W., and Liu, P. J. (2020). Exploring the limits of transfer learning with a unified text-to-text transformer. Journal of Machine Learning Research, 21(140), 1–67. Roberts, A., Raffel, C., and Shazeer, N. (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). Robertson, S. and Zaragoza, H. (2009). The probabilistic relevance framework: Bm25 and beyond. Foundations and Trends in Information Retrieval. Sachan, D. S., Patwary, M., Shoeybi, M., Kant, N., Ping, W., Hamilton, W. L., and Catanzaro, B. (2021). End-to-end training of neural retrievers for open-domain question answering. In Joint Conference of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (ACL-IJCNLP). Shoeybi, M., Patwary, M., Puri, R., LeGresley, P., Casper, J., and Catanzaro, B. (2019). Megatron-lm: Training multi-billion parameter language models using gpu model parallelism. arXiv preprint arXiv:1909.08053. Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, Ł., and Polosukhin, I. (2017). Attention is all you need. In Advances in Neural Information Processing Systems. Wang, S., Yu, M., Guo, X., Wang, Z., Klinger, T., Zhang, W., Chang, S., Tesauro, G., Zhou, B., and Jiang, J. (2018). R3: Reinforced ranker-reader for open-domain question answering. In AAAI. Wang, Z., Ng, P., Ma, X., Nallapati, R., and Xiang, B. (2019). Multi-passage BERT: A globally normalized BERT model for open-domain question answering. 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). Yih, W.-t., Toutanova, K., Platt, J. C., and Meek, C. (2011). Learning discriminative projections for text similarity measures. In Proceedings of the Fifteenth Conference on Computational Natural Language Learning. Yogatama, D., de Masson d’Autume, C., and Kong, L. (2021). Adaptive Semiparametric Language Models. Transactions of the Association for Computational Linguistics, 9, 362–373.
# Checklist
1. For all authors...
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] Please see the model (§2) and result (§3) sections that solidify the claims made in the abstract and introduction sections. (b) Did you describe the limitations of your work? [Yes] Please see limitations in $\ S$ . (c) Did you discuss any potential negative societal impacts of your work? [Yes] Please see negative societal impact in $\ S 5$ . (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
2. If you are including theoretical results...
(a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
3. If you ran experiments...
(a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] We include the code, data, and instructions in the supplemental material and $\ S$ . (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] We specify these details in the appendix included in the supplementary material. (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] Our experiments are compute expensive and it is not feasible to perform multiple runs of the same experiment with different seeds. All our training runs use the same seed value (1234). As an alternative to running multiple seeds, we perform a number of ablation studies (§3.5). (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] Please see $\ S 3 . 2$ under hardware and library.
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
(a) If your work uses existing assets, did you cite the creators? [Yes] Please see $\ S 3 . 1$ for the details. (b) Did you mention the license of the assets? [Yes] Our work is based on open-source data and framework. When applicable, we describe the license information in the appendix. (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] We include our code in the supplementary material. (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
5. If you used crowdsourcing or conducted research with human subjects...
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269# Aligning Pretraining for Detection via Object-Level Contrastive Learning
Fangyun Wei∗ Yue Gao∗ Zhirong Wu Han Hu Stephen Lin
Microsoft Research Asia {fawe, yuegao, wuzhiron, hanhu, stevelin}@microsoft.com
# Abstract
Image-level contrastive representation learning has proven to be highly effective as a generic model for transfer learning. Such generality for transfer learning, however, sacrifices specificity if we are interested in a certain downstream task. We argue that this could be sub-optimal and thus advocate a design principle which encourages alignment between the self-supervised pretext task and the downstream task. In this paper, we follow this principle with a pretraining method specifically designed for the task of object detection. We attain alignment in the following three aspects: 1) object-level representations are introduced via selective search bounding boxes as object proposals; 2) the pretraining network architecture incorporates the same dedicated modules used in the detection pipeline (e.g. FPN); 3) the pretraining is equipped with object detection properties such as object-level translation invariance and scale invariance. Our method, called Selective Object COntrastive learning (SoCo), achieves state-of-the-art results for transfer performance on COCO detection using a Mask R-CNN framework. Code is available at https://github.com/hologerry/SoCo.
# 1 Introduction
Pretraining and finetuning has been the dominant paradigm of training deep neural networks in computer vision. Downstream tasks usually leverage pretrained weights learned on large labeled datasets such as ImageNet [1] for initialization. As a result, supervised ImageNet pretraining has been prevalent throughout the field. Recently, self-supervised pretraining [2, 3, 4, 5, 6, 7, 8, 9] has achieved considerable progress and alleviated the dependency on labeled data. These methods aim to learn generic visual representations for various downstream tasks by means of image-level pretext tasks, such as instance discrimination. Some recent works [10, 11, 12, 13] observe that the image-level representations are sub-optimal for dense prediction tasks such as object detection and semantic segmentation. A potential reason is that image-level pretraining may overfit to holistic representations and fail to learn properties that are important outside of image classification.
The goal of this work is to develop self-supervised pretraining that is aligned to object detection. In object detection, bounding boxes are widely adopted as the representation for objects. Translation and scale invariance for object detection are reflected by the location and size of the bounding boxes. An obvious representation gap exists between image-level pretraining and the object-level bounding boxes of object detection.
Motivated by this, we present an object-level self-supervised pretraining framework, called Selective Object COntrastive learning (SoCo), specifically for the downstream task of object detection. To introduce object-level representations into pretraining, SoCo utilizes off-the-shelf selective search [14] to generate object proposals. Different from prior image-level contrastive learning methods which treat the whole image as an instance, SoCo treats each object proposal in the image as an independent instance. This enables us to design a new pretext task for learning object-level visual representations with properties that are compatible with object detection. Specifically, SoCo constructs object-level views where the scales and locations of the same object instance are augmented. Contrastive learning follows to maximize the similarity of the object across augmented views.
The introduction of the object-level representation also allows us to further bridge the gap in network architecture between pretraining and finetuning. Object detection often involves dedicated modules, e.g., feature pyramid network (FPN) [15], and special-purpose sub-networks, e.g., R-CNN head [16, 17]. In contrast to image-level contrastive learning methods where only feature backbones are pretrained and transferred, SoCo performs pretraining over all the network modules used in detectors. As a result, all layers of the detectors can be well-initialized.
Experimentally, the proposed SoCo achieves state-of-the-art transfer performance from ImageNet to COCO. Concretely, by using Mask R-CNN with an R50-FPN backbone, it obtains $4 3 . 2 \ : \mathrm { A P ^ { \tilde { b } b } } / 3 8 . 4$ $\mathbf { A P } ^ { \mathrm { m k } }$ on COCO with a $1 \times$ schedule, which are $+ 4 . 3 \ \mathrm { A P } ^ { \mathrm { b b } }$ $/ + 3 . 0 \mathrm { \ A P ^ { m k } }$ better than the supervised pretraining baseline, and $4 4 . 3 \ : \mathrm { A P ^ { b b } } / 3 9 . 6 \ : \mathrm { A P ^ { m k } }$ on COCO with a $2 \times$ schedule, which are $+ \dot { 3 } . 0 \mathrm { A P ^ { b b } }$ $\bar { / } + 2 . 3 \ \mathrm { A P ^ { \mathrm { i n k } } }$ better than the supervised pretraining baseline. When transferred to Mask R-CNN with an R50-C4 backbone, it achieves $4 0 . 9 \ : \mathrm { \dot { A } P ^ { b b } } / 3 5 . 3 \ : \mathrm { A P ^ { m k } }$ and $4 2 . 0 \mathrm { A P ^ { b b } } / 3 6 . 3 \mathrm { A P ^ { m k } }$ on the $1 \times$ and $2 \times$ schedule, respectively.
# 2 Related Work
Unsupervised feature learning has a long history in training deep neural networks. Auto-encoders [18] and Deep Boltzmann Machines [19] learn layers of representations by reconstructing image pixels. Unsupervised pretraining is often used as a method for initialization, which is followed by supervised training on the same dataset such as handwritten digits for classification.
Recent advances in unsupervised learning, especially self-supervised learning, tend to formulate the problem in a transfer learning scenario, where pretraining and finetuning are trained on different datasets with different purposes. Pretext tasks such as colorization [20], context prediction [21], inpainting [22] and rotation prediction [23] force the network to learn semantic information in order to solve the pretext tasks. Contrastive methods based on the instance discrimination pretext task [2] learn to map augmented views of the same instance to similar embeddings. Such approaches [24, 4, 5, 9, 25, 26] have shown strong transfer ability for a number of downstream tasks, sometimes even outperforming the supervised counterpart by large margins [4].
With new technical innovations such as learning clustering assignments [7], large-scale contrastive learning has been successfully applied on non-curated data sets [27, 28]. While the linear evaluation result on ImageNet classification has improved significantly [3], the progress on transfer performance for dense prediction tasks has been limited. Due to this, a growing number of works investigate pretraining specifically for object detection and semantic segmentation. The idea is to shift imagelevel representations to pixel-level or region-level representations. VADer [29], PixPro [10] and DenseCL [11] propose to learn pixel-level representations by matching point features of the same physical location under different views. InsLoc [12] learns to match region-level features from composited imagery. DetCon [13] additionally uses the bottom-up segmentation of MCG [30] for supervising intra-segment pixel variations. UP-DETR [31] proposes a pretext task named random query patch detection to pretrain DETR detector. Self-EMD [32] explores self-supervised representation learning for object detection without using Imagenet images.
Our work is also motivated and inspired by object detection methods which advocate architectures and training schemes invariant to translation and scale transformations [15, 33]. We find that incorporating them in the pretraining stage also benefits object detection, which has largely been overlooked in previous self-supervised learning works.
# 3 Method
We introduce a new contrastive learning method which maximizes the similarity of object-level features representing different augmentations of the same object. Meanwhile, we introduce architectural alignment and important properties of object detection into pretraining when designing the objectlevel pretext task. We use an example where transfer learning is performed on Mask-RCNN with a R50-FPN backbone to illustrate the core design principles. To further demonstrate the extensibility and flexibility of our method, we also apply SoCo on a R50-C4 structure. In this section, we first present an overview of the proposed SoCo in Section 3.1. Then we describe the process of object proposal generation and view construction in Section 3.2. Finally, the object-level contrastive learning and our design principles are introduced in Section 3.3.
 Figure 1: Overview of SoCo. SoCo utilizes selective search to generate a set of object proposals for each raw image. $K$ proposals are randomly selected in each training step. We construct three views $\left\{ V _ { 1 } , V _ { 2 } , V _ { 3 } \right\}$ where the scales and locations of the same object are different. We adopt a backbone with FPN to encode image-level features and RoIAlign to extract object-level features. Object proposals are assigned to different pyramid levels according to their image areas. Contrastive learning is performed at the object level to learn translation-invariant and scale-invariant representations. The target network is updated by an exponential moving average of the online network.
# 3.1 Overview
Figure 1 displays an overview of SoCo. SoCo aims to align pretraining to object detection in two aspects: 1) network architecture alignment between pretraining and object detection; 2) introducing central properties of detection. Concretely, besides pretraining a backbone as done in existing selfsupervised contrastive learning methods, SoCo also pretrains all the network modules used in an object detector, such as FPN and the head in the Mask R-CNN framework. As a result, all layers of the detector can be well-initialized. Furthermore, SoCo strives to learn object-level representations which are not only meaningful, but also invariant to translation and scale. To achieve this, it encourages diversity of scales and locations of objects by constructing multiple augmented views and applying a scale-aware assignment strategy for different levels of a feature pyramid. Finally, object-level contrastive learning is applied to maximize the feature similarity of the same object across augmented views.
# 3.2 Data Preprocessing
Object Proposal Generation. Inspired by R-CNN [34] and Fast R-CNN [35], we use selective search [14], an unsupervised object proposal generation algorithm which takes into account color similarity, texture similarity, size of region and fit between regions, to generate a set of object proposals for each of the raw images. We represent each object proposal as a bounding box $b \overset { \cdot } { = } \{ x , y , w , h \}$ , where $( x , y )$ denotes the coordinates of the bounding box center, and $w$ and $h$ are the corresponding width and height, respectively. We keep only the proposals that satisfy the following requirements:√ √ 1) $1 / 3 \leq w / h \leq 3 ;$ 2) $0 . 3 \leq \dot { \sqrt { w h } } / \sqrt { W H } \leq 0 . 8$ , where $W$ and $H$ denote width and height of the input image. The object proposal generation step is performed offline. In each training iteration, we randomly select $K$ proposals for each input image.
View Construction. Three views, namely $V _ { 1 }$ , $V _ { 2 }$ and $V _ { 3 }$ , are used in SoCo. The input image is resized to $2 2 4 \times 2 2 4$ to obtain $V _ { 1 }$ . Then we apply a random crop with a scale range of [0.5, 1.0] on $V _ { 1 }$ in generating $V _ { 2 }$ . $V _ { 2 }$ is then resized to the same size as $V _ { 1 }$ and object proposals outside of $V _ { 2 }$ are dropped. Next, we downsample $V _ { 2 }$ to a fixed size (e.g. $1 1 2 \times 1 1 2 ,$ ) to produce $V _ { 3 }$ . In all of these cases, the bounding boxes transformed according to the cropping and resizing of the RGB images (see Figure 1, Data Preprocessing). Finally, each view is randomly and independently augmented. We adopt the augmentation pipeline of BYOL [3] but discard the random crop augmentation since spatial transformation is already applied on all three views. Notice that the scale and location of the same object proposal are different across the augmented views, which enables the model to learn translation-invariant and scale-invariant object-level representations.
Box Jitter. To further encourage variance of scales and locations of object proposals across views, we adopt a box jitter strategy on the generated proposals as an object-level data augmentation. Specifically, given an object proposal $\boldsymbol { b } = \{ x , y , w , h \}$ , we randomly generate a jittered box $\hat { b } =$ $\{ \hat { x } , \hat { y } , \hat { w } , \hat { h } \}$ as follows: 1) $\hat { x } = x + r \cdot w$ ; 2) ${ \hat { y } } = y + r \cdot h ;$ 3) $\boldsymbol { \hat { w } } = \boldsymbol { w } + \boldsymbol { r } \cdot \boldsymbol { w } ;$ 4) $\hat { h } = h + r \cdot h$ , where $r \in [ - 0 . 1 , 0 . 1 ]$ . The box jitter is randomly applied on each proposal with a probability of 0.5.
# 3.3 Object-Level Contrastive Learning
The goal of SoCo is to align pretraining to object detection. Here, we use the representative framework Mask R-CNN [17] with feature pyramid network (FPN) [15] to demonstrate our key design principles. The alignment mainly involves aligning the pretraining architecture with that of object detection and integrating important object detection properties such as object-level translation invariance and scale invariance into the pretraining.
Aligning Pretraining Architecture to Object Detection. Following Mask R-CNN, we use a backbone with FPN as the image-level feature extractor $f ^ { I }$ . We denote the output of FPN as $\{ P _ { 2 } , P _ { 3 } , P _ { 4 } , P _ { 5 } \}$ with a stride of $\{ 4 , 8 , 1 6 , 3 2 \}$ . Here, we do not use $P _ { 6 }$ due to its low resolution. With the bounding box representation $b$ , RoIAlign [17] is applied to extract the foreground feature from the corresponding scale level. For further architectural alignment, we additionally introduce an R-CNN head $f ^ { H }$ into pretraining. The object-level feature representation $h$ of bounding box $b$ is extracted from an image view $V$ as:
$$h = f ^ { H } ( \mathrm { R o I A l i g n } ( f ^ { I } ( V ) , b ) ) .$$
SoCo uses two neural networks to learn, namely an online network and a target network. The online network and the target network share the same architecture but with different sets of weights. Concretely, the target network weights $f _ { \xi } ^ { I } , f _ { \xi } ^ { H }$ are the exponential moving average (EMA) with the momentum coefficient $\tau$ of the online parameters $f _ { \theta } ^ { I }$ and $f _ { \theta } ^ { H }$ . Denote the set of object proposals $\{ b _ { i } \}$ considered in the image. Let $h _ { i }$ be the object-level representation of proposal $b _ { i }$ in view $V _ { 1 }$ , and $h _ { i } ^ { \prime } , h _ { i } ^ { \prime \prime }$ be the representation of $b _ { i }$ in view $V _ { 2 } , V _ { 3 }$ . They are extracted using the online network and the target network respectively,
$$h _ { i } = f _ { \theta } ^ { H } \big ( \mathrm { R o I A l i g n } \big ( f _ { \theta } ^ { I } ( V _ { 1 } ) , b _ { i } \big ) \big ) ,$$
$$h _ { i } ^ { \prime } = f _ { \xi } ^ { H } ( \mathrm { R o I A l i g n } ( f _ { \xi } ^ { I } ( V _ { 2 } ) , b _ { i } ) ) , \quad h _ { i } ^ { \prime \prime } = f _ { \xi } ^ { H } ( \mathrm { R o I A l i g n } ( f _ { \xi } ^ { I } ( V _ { 3 } ) , b _ { i } ) ) .$$
We follow BYOL [3] for learning contrastive representations. The online network is appended with a projector $g _ { \theta }$ , and a predictor $q _ { \theta }$ for obtaining latent embeddings. Both $g _ { \theta }$ and $q _ { \theta }$ are two-layer MLPs. The target network is only appended with the projector $g _ { \xi }$ for avoiding trivial solutions. We use $v _ { i }$ , $\boldsymbol { v } _ { i } ^ { \prime }$ and $v _ { i } ^ { \prime \prime }$ to denote the latent embeddings of object-level representations $\{ h _ { i } , h _ { i } ^ { \prime } , h _ { i } ^ { \prime \prime } \}$ , respectively:
$$v _ { i } = q _ { \theta } ( g _ { \theta } ( h _ { i } ) ) , \quad v _ { i } ^ { \prime } = g _ { \xi } ( h _ { i } ^ { \prime } ) , \quad v _ { i } ^ { \prime \prime } = g _ { \xi } ( h _ { i } ^ { \prime \prime } ) .$$
The contrastive loss for the $i$ -th object proposal is defined as:
$$\mathcal { L } _ { i } = - 2 \cdot \frac { \langle v _ { i } , v _ { i } ^ { \prime } \rangle } { \left. v _ { i } \right. _ { 2 } \cdot \left. v _ { i } ^ { \prime } \right. _ { 2 } } - 2 \cdot \frac { \langle v _ { i } , v _ { i } ^ { \prime \prime } \rangle } { \left. v _ { i } \right. _ { 2 } \cdot \left. v _ { i } ^ { \prime \prime } \right. _ { 2 } } .$$
Then we can formulate the overall loss function for each image as:
$$\mathcal { L } = \frac { 1 } { K } \sum _ { i = 1 } ^ { K } \mathcal { L } _ { i } ,$$
where $K$ is the number of object proposals. We symmetrize the loss $\mathcal { L }$ in Eq. 6 by separately feeding $V _ { 1 }$ to the target network and $\{ V _ { 2 } , V _ { 3 } \}$ to the online network to compute $\widetilde { \mathcal { L } }$ . At each training iteration, we perform a stochastic optimization step to minimize $\mathcal { L } ^ { \mathrm { S o C o } } = \mathcal { L } + \widetilde { \mathcal { L } }$ .
Scale-Aware Assignment. Mask R-CNN with FPN uses the IoU between anchors and ground-truth boxes to determine positive samples. It defines anchors to have areas of $\{ 3 2 ^ { 2 } , 6 4 ^ { 2 } , \overline { { { 1 2 8 ^ { 2 } } } } , 2 5 6 ^ { 2 } \}$ pixels on $\{ P _ { 2 } , P _ { 3 } , \bar { P } _ { 4 } , P _ { 5 } \}$ , respectively, which means ground-truth boxes of scale within a range are assigned to a specific pyramid level. Inspired by this, we propose a scale-aware assignment strategy, which greatly encourages the pretraining model to learn object-level scaleinvariant representations. Concretely, we assign object proposals of area within a range of $\left\{ 0 - 4 8 ^ { 2 } , 4 \dot { 9 } ^ { 2 } - 9 6 ^ { 2 } , 9 7 ^ { 2 } - 1 9 2 ^ { 2 } , 1 9 \dot { 3 } ^ { 2 } - 2 2 4 ^ { 2 } \right\}$ pixels to $\{ P _ { 2 } , P _ { 3 } , P _ { 4 } , P _ { 5 } \}$ , respectively. Notice that the maximum proposal size is $2 2 4 \times 2 2 4$ since all of the views are resized to a fixed resolution smaller than 224. The advantage is that the same object proposals at different scales are encouraged to learn consistent representations through contrastive learning. As a result, SoCo learns object-level scale-invariant visual representations, which is important for object detection.
Introducing Properties of Detection to Pretraining. Here, we discuss how SoCo promotes important properties of object detection in the pretraining. Object detection uses tight bounding boxes to represent objects. To introduce object-level representations, SoCo generates object proposals by selective search. Translation invariance and scale invariance at the object level are regarded as the most important properties for object detection, i.e., feature representations of objects belonging to same category should be insensitive to scale and location. Recall that $V _ { 2 }$ is a randomly cropped patch of $V _ { 1 }$ . Random cropping introduces box shift and thus contrastive learning between $V _ { 1 }$ and $V _ { 2 }$ encourages the pretraining model to learn location-invariant representations. $V _ { 3 }$ is generated by downsampling $V _ { 2 }$ , which results in a scale augmentation of object proposals. With our scale-aware assignment strategy, the contrastive loss between $V _ { 1 }$ and $V _ { 3 }$ guides the pretraining towards learning scale-invariant visual representations.
Extending to Other Object Detectors. SoCo can be easily extended to align to other detectors besides Mask R-CNN with FPN. Here, we apply SoCo to Mask R-CNN with a C4 structure, which is a popular non-FPN detection framework. The modification is three-fold: 1) for all object proposals, RoIAlign is performed on $C _ { 4 }$ ; 2) the R-CNN head is replaced by the entire 5-th residual block; 3) view $V _ { 3 }$ is discarded and the remaining $V _ { 1 }$ and $V _ { 2 }$ are kept for object-level contrastive learning. Experiments and comparisons with state-of-the-art methods in Section 4.3 demonstrate the extensibility and flexibility of SoCo.
# 4 Experiments
# 4.1 Pretraining Settings
Architecture. Through the introduction of object proposals, the architectural discrepancy is reduced between pretraining and downstream detection finetuning. Mask R-CNN [17] is a commonly adopted framework to evaluate transfer performance. To demonstrate the extensibility and flexibility of SoCo, we provide details of SoCo alignment for the detection architectures R50-FPN and R50- C4. SoCo-R50-FPN: ResNet-50 [36] with FPN [15] is used as the image-level feature encoder. RoIAlign [17] is then used to extract RoI features on feature maps $\{ P _ { 2 } , P _ { 3 } , P _ { 4 } , P _ { 5 } \}$ with a stride of $\{ 4 , 8 , 1 6 , 3 2 \}$ . According to the image areas of object proposals, each RoI feature is then transformed to an object-level representation by the head network as in Mask R-CNN. SoCo-R50-C4: on the standard ResNet-50 architecture, we insert the RoI operation on the output of the 4-th residual block. The entire 5-th residual block is treated as the head network to encode object-level features. Both the projection network and prediction network are 2-layer MLPs which consist of a linear layer with output size 4096 followed by batch normalization [37], rectified linear units (ReLU) [38], and a final linear layer with output dimension 256.
Dataset. We adopt the widely used ImageNet [1] which consists of ${ \sim } 1 . 2 8$ million images for self-supervised pretraining.
Data Augmentation. Once all views are constructed, we employ the data augmentation pipeline of BYOL [3]. Specifically, we apply random horizontal flip, color distortion, Gaussian blur, grayscaling, and the solarization operation. We remove the random crop augmentation since spatial transformations have already been applied on all views.
Optimization. We use a 100-epoch training schedule in all the ablation studies and report the results of 100-epochs and 400-epochs in the comparisons with state-of-the-art methods. We use the LARS optimizer [39] with a cosine decay learning rate schedule [40] and a warm-up period of 10 epochs.
Table 1: Comparison with state-of-the-art methods on COCO by using Mask R-CNN with R50-FPN.
<table><tr><td rowspan="2">Methods</td><td rowspan="2">Epoch</td><td colspan="5">1× Schedule</td><td rowspan="2"></td><td colspan="6">2× Schedule</td></tr><tr><td>Apbb</td><td>AP</td><td>AP</td><td>Apmk</td><td>AP</td><td>AP</td><td>Apbb</td><td>AP AP</td><td>Apmk</td><td>AP</td><td>AP</td></tr><tr><td>Scratch</td><td>-</td><td>31.0</td><td>49.5</td><td>33.2</td><td>28.5</td><td>46.8</td><td>30.4</td><td>38.4</td><td>57.5</td><td>42.0</td><td>34.7</td><td>54.8</td><td>37.2</td></tr><tr><td>Supervised</td><td>90</td><td>38.9</td><td>59.6</td><td>42.7</td><td>35.4</td><td>56.5</td><td>38.1</td><td>41.3</td><td>61.3</td><td>45.0</td><td>37.3</td><td>58.3</td><td>40.3</td></tr><tr><td>MoCo[4]</td><td>200</td><td>38.5</td><td>58.9</td><td>42.0</td><td>35.1</td><td>55.9</td><td>37.7</td><td>40.8</td><td>61.6</td><td>44.7</td><td>36.9</td><td>58.4</td><td>39.7</td></tr><tr><td>MoCo v2[5]</td><td>200</td><td>40.4</td><td>60.2</td><td>44.2</td><td>36.4</td><td>57.2</td><td>38.9</td><td>41.7</td><td>61.6</td><td>45.6</td><td>37.6</td><td>58.7</td><td>40.5</td></tr><tr><td>InfoMin [6]</td><td>200</td><td>40.6</td><td>60.6</td><td>44.6</td><td>36.7</td><td>57.7</td><td>39.4</td><td>42.5</td><td>62.7</td><td>46.8</td><td>38.4</td><td>59.7</td><td>41.4</td></tr><tr><td>BYOL[3]</td><td>300</td><td>40.4</td><td>61.6</td><td>44.1</td><td>37.2</td><td>58.8</td><td>39.8</td><td>42.3</td><td>62.6</td><td>46.2</td><td>38.3</td><td>59.6</td><td>41.1</td></tr><tr><td>SwAV[7]</td><td>400</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>42.3</td><td>62.8</td><td>46.3</td><td>38.2</td><td>60.0</td><td>41.0</td></tr><tr><td>ReSim-FPNT [45]</td><td>200</td><td>39.8</td><td>60.2</td><td>43.5</td><td>36.0</td><td>57.1</td><td>38.6</td><td>41.4</td><td>61.9</td><td>45.4</td><td>37.5</td><td>59.1</td><td>40.3</td></tr><tr><td>PixPro[10]</td><td>400</td><td>41.4</td><td>61.6</td><td>45.4</td><td>1</td><td>-</td><td>1</td><td>-</td><td>-</td><td>-</td><td>-</td><td>1</td><td>-</td></tr><tr><td>InsLoc [12]</td><td>400</td><td>42.0</td><td>62.3</td><td>45.8</td><td>37.6</td><td>59.0</td><td>40.5</td><td>43.3</td><td>63.6</td><td>47.3</td><td>38.8</td><td>60.9</td><td>41.7</td></tr><tr><td>DenseCL[11]</td><td>200</td><td>40.3</td><td>59.9</td><td>44.3</td><td>36.4</td><td>57.0</td><td>39.2</td><td>41.2</td><td>61.9</td><td>45.1</td><td>37.3</td><td>58.9</td><td>40.1</td></tr><tr><td>DetCons [13]</td><td>1000</td><td>41.8</td><td></td><td>1</td><td>37.4</td><td>-</td><td>:</td><td>42.9</td><td>1</td><td>-</td><td>38.1</td><td></td><td>:</td></tr><tr><td>DetConB [13]</td><td>1000</td><td>42.7</td><td></td><td>-</td><td>38.2</td><td>1</td><td>:</td><td>43.4</td><td>1</td><td>-</td><td>38.7</td><td>-</td><td>:</td></tr><tr><td>SoCo</td><td>100</td><td>42.3</td><td>62.5</td><td>46.5</td><td>37.6</td><td>59.1</td><td>40.5</td><td>43.2</td><td>63.3</td><td>47.3</td><td>38.8</td><td>60.6</td><td>41.9</td></tr><tr><td>SoCo</td><td>400</td><td>43.0</td><td>63.3</td><td>47.1</td><td>38.2</td><td>60.2</td><td>41.0</td><td>44.0</td><td>64.0</td><td>48.4</td><td>39.0</td><td>61.3</td><td>41.7</td></tr><tr><td>SoCo*</td><td>400</td><td>43.2</td><td>63.5</td><td>47.4</td><td>38.4</td><td>60.2</td><td>41.4</td><td>44.3</td><td>64.6</td><td>48.9</td><td>39.6</td><td>61.8</td><td>42.5</td></tr></table>
The base learning rate $l r _ { \mathrm { b a s e } }$ is set to 1.0 and is scaled linearly [41] with the batch size $\mathit { l r } = { l r } _ { \mathrm { b a s e } } \times$ BatchSize/256). The weight decay is set to $1 . 0 \times \mathrm { e } ^ { - 5 }$ . The total batch size is set to 2048 over 16 Nvidia V100 GPUs. For the update of the target network, following [3], the momentum coefficient $\tau$ starts from 0.99 and is increased to 1 during training. Synchronized batch normalization is enabled.
# 4.2 Transfer Learning Settings
COCO [42] and Pascal VOC [43] datasets are used for transfer learning. Detectron2 [44] is used as the code base.
COCO Object Detection and Instance Segmentation. We use the COCO train2017 set which contains ${ \sim } 1 1 8 \mathrm { k }$ images with bounding box and instance segmentation annotations in 80 object categories. Transfer performance is evaluated on the COCO val2017 set. We adopt the Mask R-CNN detector [17] withfor object detection, and 5, andand 50-C4 backbones. We reportfor instance segmentation. $\mathsf { A P } ^ { \mathrm { b b } }$ ,e $\mathrm { A \hat { P } _ { 5 0 } ^ { b b } }$ andhe r $\mathsf { A P } _ { 7 5 } ^ { \mathsf { b b } }$ $\mathbf { A P } ^ { \mathrm { m k } }$ $\mathbf { A P } _ { 5 0 } ^ { \mathrm { m k } }$ $\mathbf { A P } _ { 7 5 } ^ { \mathrm { m k } }$ under the COCO $1 \times$ and $2 \times$ schedules in comparisons with state-of-the-art methods. All ablation studies are conducted on the COCO $1 \times$ schedule.
Pascal VOC Object Detection. We use the Pascal VOC trainval $0 7 + 1 2$ set which contains ${ \sim } 1 6 . 5 \mathrm { k }$ images with bounding box annotations in 20 object categories as the training set. Transfer performance is evaluated on the Pascal VOC test2007 set. We report the results of $\mathsf { A P } ^ { \mathrm { b b } }$ , $\mathsf { A P } _ { 5 0 } ^ { \mathrm { b b } }$ and $\mathsf { A P } _ { 7 5 } ^ { \mathrm { b b } }$ for object detection.
Optimization. All the pretrained weights except for projection and prediction are loaded into the object detection network for transfer. Following [5], synchronized batch normalization is used across all layers including the newly initialized batch normalization layers in finetuning. For both the COCO and Pascal VOC datasets, we finetune with stochastic gradient descent and a batch size of 16 split across 8 GPUs. For COCO transfer, we use a weight decay of $2 . 5 \times \mathrm { e } ^ { - 5 }$ , and a base learning rate of 0.02 that increases linearly for the first 1000 iterations and drops twice by a factor of 10, after $\frac { 2 } { 3 }$ and $\frac { 8 } { 9 }$ of the total training time. For Pascal VOC transfer, the weight decay is $1 . 0 \times \mathrm { e } ^ { - 4 }$ , and the base learning rate is set to 0.02 and divided by 10 at $\textstyle { \frac { 3 } { 4 } }$ and $\textstyle { \frac { 1 1 } { 1 2 } }$ of the total training time.
# 4.3 Comparison with State-of-the-Art Methods
Mask R-CNN with R50-FPN on COCO. Table 1 shows the transfer results for Mask R-CNN with R50-FPN backbone. We compare SoCo with the state-of-the-art unsupervised pretraining methods on the COCO $1 \times$ and $2 \times$ schedules. We report our results under 100 epochs and 400 epochs of pretraining. On the 100-epoch training schedule, SoCo achieves $4 2 . 3 \mathrm { \ A p ^ { b b } / 3 7 . 6 \ A P ^ { m k } }$ and $4 3 . 2 \ : \dot { \mathrm { A P ^ { b b } } } / \ : 3 8 . { \bar { 8 } } \ : \mathrm { A P ^ { m k } }$ on the $1 \times$ and $2 \times$ schedules, respectively. Pretrained for 400 epochs, SoCo outperforms all previous pretraining methods designed for either image classification or object detection, achieving $4 \dot { 3 } . 0 \ : \mathrm { A P ^ { b b } } \ : \dot { / } 3 8 . 2 \ : \mathrm { A P ^ { m i } }$ for the $1 \times$ schedule and $4 4 . 0 \mathrm { A P ^ { \bar { b } b } / 3 9 . 0 \mathrm { A P ^ { m k } } }$ for the $2 \times$ schedule. Moreover, we propose an enhanced version named $S o C o ^ { * }$ , which constructs an additional view $V _ { 4 }$ for pretraining. Similar to the construction step of $V _ { 2 }$ , $V _ { 4 }$ is a randomly cropped patch of $V _ { 1 }$ . We resize $V _ { 4 }$ to $1 9 2 \times 1 9 2$ and perform the same forward process as for $V _ { 2 }$ and $V _ { 3 }$ . Compared with SoCo, $\mathrm { S o C o ^ { * } }$ further boosts the performance and obtains an improvement of $+ 0 . 2 \mathrm { \ A P ^ { b b } \ } \bar { / } + 0 . 2$ $\mathbf { A P } ^ { \mathrm { m k } }$ on the $1 \times$ schedule, achieving $\dot { 4 } 3 . 2 \ : \mathrm { A P ^ { b b } } / 3 8 . 4 \ : \mathrm { A P ^ { m k } }$ , and $+ 0 . { \dot { 3 } } \operatorname { A P } ^ { \mathrm { b b } } / + 0 . 6 \operatorname { A P } ^ { \mathrm { m k } }$ on the $2 \times$ schedule, achieving $4 4 . 3 \ : \mathrm { A P ^ { b b } } / 3 9 . \mathsf { \breve { 6 } A P ^ { m k } }$ , respectively.
Table 2: Comparison with state-of-the-art methods on COCO using Mask R-CNN with R50-C4.
<table><tr><td rowspan="2">Methods</td><td rowspan="2">Epoch</td><td colspan="6">1× Schedule</td><td colspan="6">2× Schedule</td></tr><tr><td>Apbb</td><td>AP</td><td>AP</td><td>Apmk</td><td>AP</td><td>APP</td><td>Apbb</td><td>AP8</td><td>AP</td><td>Apmk</td><td>AP</td><td>APP</td></tr><tr><td>Scratch</td><td>-</td><td>26.4</td><td>44.0</td><td>27.8</td><td>29.3</td><td>46.9</td><td>30.8</td><td>35.6</td><td>54.6</td><td>38.2</td><td>31.4</td><td>51.5</td><td>33.5</td></tr><tr><td>Supervised</td><td>90</td><td>38.2</td><td>58.2</td><td>41.2</td><td>33.3</td><td>54.7</td><td>35.2</td><td>40.0</td><td>59.9</td><td>43.1</td><td>34.7</td><td>56.5</td><td>36.9</td></tr><tr><td>MoCo [4]</td><td>200</td><td>38.5</td><td>58.3</td><td>41.6</td><td>33.6</td><td>54.8</td><td>35.6</td><td>40.7</td><td>60.5</td><td>44.1</td><td>35.4</td><td>57.3</td><td>37.6 37.1</td></tr><tr><td>SimCLR [9] MoCo v2 [5]</td><td>200 800</td><td>- 39.3</td><td>-</td><td>■</td><td>-</td><td>-</td><td>1</td><td>39.6 41.2</td><td>59.1 60.9</td><td>42.9 44.6</td><td>34.6 35.8</td><td>55.9 57.7</td><td>38.2</td></tr><tr><td>InfoMin 6]</td><td></td><td></td><td>58.9</td><td>42.5</td><td>34.3</td><td>55.7</td><td>36.5</td><td></td><td>61.2</td><td>45.0</td><td></td><td>57.9</td><td>38.3</td></tr><tr><td>BYOL[3]</td><td>200 300</td><td>39.0</td><td>58.5</td><td>42.0</td><td>34.1</td><td>55.2</td><td>36.3</td><td>41.3</td><td></td><td></td><td>36.0</td><td>56.8</td><td>37.3</td></tr><tr><td>SwAV[7]</td><td>400</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>40.3</td><td>60.5</td><td>43.9</td><td>35.1</td><td></td><td>36.6</td></tr><tr><td>SimSiam [8]</td><td>200</td><td>- 39.2</td><td>- 59.3</td><td>-</td><td>1</td><td>1</td><td>-</td><td>39.6</td><td>60.1</td><td>42.9</td><td>34.7</td><td>56.6</td><td></td></tr><tr><td>PixPro[10]</td><td>400</td><td>40.5</td><td>59.8</td><td>42.1</td><td>34.4</td><td>56.0</td><td>36.7</td><td>-</td><td>:</td><td>-</td><td>-</td><td>-</td><td>-</td></tr><tr><td>InsLoc [12]</td><td>400</td><td>39.8</td><td>59.6</td><td>44.0 42.9</td><td>-</td><td>-</td><td>-</td><td>- 41.8</td><td>- 61.6</td><td>-</td><td>-</td><td>- 58.2</td><td>- 38.8</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td>34.7</td><td>56.3</td><td>36.9</td><td></td><td></td><td>45.4</td><td>36.3</td><td></td><td></td></tr><tr><td>SoCo</td><td>100</td><td>40.4</td><td>60.4</td><td>43.7</td><td>34.9</td><td>56.8</td><td>37.0</td><td>41.1</td><td>61.0</td><td>44.4</td><td>35.6</td><td>57.5</td><td>38.0</td></tr><tr><td>SoCo</td><td>400</td><td>40.9</td><td>60.9</td><td>44.3</td><td>35.3</td><td>57.5</td><td>37.3</td><td>42.0</td><td>61.8</td><td>45.6</td><td>36.3</td><td>58.5</td><td>38.8</td></tr></table>
Table 3: Comparison with state-of-the-art methods on Pascal VOC. Faster R-CNN with R50-C4 is adopted. Table is split to two sub-tables.
<table><tr><td colspan="5">(a) Sub-table 1.</td></tr><tr><td>Methods</td><td>Epoch</td><td>APbb</td><td>AP</td><td>AP</td></tr><tr><td>Scratch Supervised</td><td>- 90</td><td>33.8 53.5</td><td>60.2 81.3</td><td>33.1 58.8</td></tr><tr><td>ReSim-C4 [45] PixPro [10] InsLoc [12] DenseCL[11]</td><td>200 400 400 200</td><td>58.7 60.2 58.4 58.7</td><td>83.1 83.8 83.0 82.8</td><td>66.3 67.7 65.3 65.2</td></tr><tr><td>SoCo SoCo</td><td>100 400</td><td>59.1 59.7</td><td>83.4 83.8</td><td>65.6 66.8</td></tr></table>
(b) Sub-table 2.
<table><tr><td>Methods</td><td>Epoch</td><td>Apbb</td><td>AP</td><td>AP</td></tr><tr><td>MoCo[4]</td><td>200</td><td>55.9</td><td>81.5</td><td>62.6</td></tr><tr><td>SimCLR [9]</td><td>1000</td><td>56.3</td><td>81.9</td><td>62.5</td></tr><tr><td>MoCo v2[5]</td><td>800</td><td>57.6</td><td>82.7</td><td>64.4</td></tr><tr><td>InfoMin [6]</td><td>200</td><td>57.6</td><td>82.7</td><td>64.6</td></tr><tr><td>BYOL[3]</td><td>300</td><td>51.9</td><td>81.0</td><td>56.5</td></tr><tr><td>SwAV[7]</td><td>400</td><td>45.1</td><td>77.4</td><td>46.5</td></tr><tr><td>SimSiam[8]</td><td>200</td><td>57.0</td><td>82.4</td><td>63.7</td></tr><tr><td>ReSim-FPN[45]</td><td>200</td><td>59.2</td><td>82.9</td><td>65.9</td></tr></table>
Mask R-CNN with R50-C4 on COCO. To demonstrate the extensibility and flexibility of SoCo, we also evaluate transfer performance using Mask R-CNN with R50-C4 backbone on the COCO benchmark. We report the results of SoCo under 100 epochs and 400 epochs. Table 2 compares the proposed method to previous state-of-the-art methods. Without bells and whistles, SoCo obtains state-of-the-art performance, achieving $4 0 . 9 ~ \mathrm { A P ^ { b b } } / 3 5 . 3 ~ \mathrm { A P ^ { m k } }$ and $4 2 . 0 ~ \mathrm { A P ^ { b b } } / 3 6 . 3 ~ \mathrm { A P ^ { m k } }$ on the COCO $1 \times$ and $2 \times$ schedules, respectively.
Faster R-CNN with R50-C4 on Pascal VOC. We also evaluate the transfer ability of SoCo on the Pascal VOC benchmark. Following [5], we adopt Faster R-CNN with R50-C4 backbone for transfer learning. Table 3 shows the comparison. SoCo obtains an improvement of $+ 6 . 2 \ \mathrm { A P } ^ { \mathrm { b b } }$ against the supervised pretraining baseline, achieving $5 9 . 7 \mathrm { A P } ^ { \mathrm { b b } }$ for VOC object detection.
# 4.4 Ablation Study
To further understand the advantages of SoCo, we conduct a series of ablation studies that examine the effectiveness of object-level contrastive learning, the effects of alignment between pretraining and detection, and different hyper-parameters. For all ablation studies, we use Mask R-CNN with R50-FPN backbone for transfer learning and adopt a 100-epoch SoCo pretraining schedule. Transfer performance is evaluated under the COCO $1 \times$ schedule. For the ablation of each hyper-parameter or component, we fix all other hyper-parameters to the following default settings: view $V _ { 3 }$ with $1 1 2 \times 1 1 2$ resolution, batch size of 2048, momentum coefficient $\tau = 0 . 9 9$ , proposal number $K = 4$ box jitter and scale-aware assignment are used, FPN and R-CNN head are pretrained and transferred, and selective search is used as the proposal generator.
Table 4: Ablation study on the effectiveness of aligning pretraining to object detection.
<table><tr><td>Whole Image</td><td>Selective Search</td><td>FPN</td><td>Head</td><td>Scale-aware Assignment</td><td>Box Jitter</td><td>Multi View</td><td>Apbb</td><td>Apmk</td></tr><tr><td>√</td><td></td><td></td><td></td><td></td><td></td><td></td><td>38.1</td><td>34.4</td></tr><tr><td>√</td><td></td><td></td><td></td><td></td><td></td><td></td><td>40.6 (+2.5)</td><td>36.8 (+2.4)</td></tr><tr><td>√</td><td></td><td></td><td></td><td></td><td></td><td></td><td>40.2 (+2.1)</td><td>36.2 (+1.8)</td></tr><tr><td>√</td><td></td><td></td><td>广</td><td></td><td></td><td></td><td>41.2 (+3.1)</td><td>37.0 (+2.6)</td></tr><tr><td>√</td><td></td><td></td><td></td><td>1</td><td></td><td></td><td>41.6 (+3.5)</td><td>37.3 (+2.9)</td></tr><tr><td>√</td><td>>>>>>></td><td>>>>>></td><td>1</td><td></td><td></td><td>4</td><td>41.7 (+3.6)</td><td>37.5 (+3.1)</td></tr><tr><td>√</td><td></td><td></td><td>厂</td><td>厂</td><td></td><td></td><td>42.3 (+4.2)</td><td>37.6 (+3.2)</td></tr></table>
Table 5: Ablation studies on hyper-parameters for the proposed SoCo method. y on image size of view $V _ { 3 }$ . (c) Study on proposal generation and proposal number $K$
<table><tr><td>Image Size</td><td>Apbb</td><td>Apmk</td></tr><tr><td>96</td><td>42.1</td><td>37.7</td></tr><tr><td>112</td><td>42.3</td><td>37.6</td></tr><tr><td>128</td><td>42.1</td><td>37.7</td></tr><tr><td>160</td><td>42.0</td><td>37.6</td></tr><tr><td>192</td><td>42.2</td><td>37.8</td></tr></table>
(b) Study on batch size.
<table><tr><td>Batch Size</td><td>APbb</td><td>Apmk</td></tr><tr><td>512</td><td>41.7</td><td>37.6</td></tr><tr><td>1024</td><td>41.9</td><td>37.6</td></tr><tr><td>2048</td><td>42.3</td><td>37.6</td></tr><tr><td>4096</td><td>41.4</td><td>37.3</td></tr></table>
(d) Study on momentum coefficient $\tau$
<table><tr><td>Selective Search</td><td>Random</td><td>K</td><td>APbb</td><td>Apmk</td></tr><tr><td><</td><td></td><td>1</td><td>41.6</td><td>37.3</td></tr><tr><td></td><td></td><td>486</td><td>42.3 41.6</td><td>37.6</td></tr><tr><td>√</td><td></td><td></td><td></td><td>37.4</td></tr><tr><td>√</td><td></td><td></td><td>41.2</td><td>37.0</td></tr><tr><td></td><td>>>></td><td>148</td><td>41.4</td><td>36.9</td></tr><tr><td></td><td></td><td></td><td>NaN NaN</td><td>NaN NaN</td></tr></table>
<table><tr><td>T</td><td>APbb</td><td>Apmk</td></tr><tr><td>0.98</td><td>35.0</td><td>31.7</td></tr><tr><td>0.99</td><td>42.3</td><td>37.6</td></tr><tr><td>0.993</td><td>41.8</td><td>37.6</td></tr></table>
Effectiveness of Aligning Pretraining to Object Detection. We ablate each component of SoCo step by step to demonstrate the the effectiveness of aligning pretraining to object detection. Table 4 reports the studies. The baseline treats the whole image as an instance, without considering any detection properties or architecture alignment. It obtains $3 8 . 1 \mathrm { \ A P ^ { b b } }$ and $3 4 . 4 \mathrm { A P ^ { m k } }$ . Selective search introduces object-level representations. By leveraging generated object proposals and conducting contrastive learning at the object level, our method obtains an improvement of $+ 2 . 5 \mathrm { \ A P ^ { b b } }$ and $+ 2 . 4$ $\mathbf { A P } ^ { \mathrm { m k } }$ . Next, we further minimize the architectural discrepancy between pretraining and object detection pipeline by introducing FPN and an R-CNN head into the pretraining architecture. We observe that only introducing FPN into pretraining slightly hurt the performance. In contrast, including both FPN and the R-CNN head improves the transfer performance to $4 1 . 2 ~ \mathrm { A P ^ { b b } } ~ / ~ 3 7 . 0$ $\mathbf { A P } ^ { \mathrm { m k } }$ , which verifies the effectiveness of architectural alignment between self-supervised pretraining and downstream tasks. On top of architectural alignment, we further leverage scale-aware assignment which encourages scale-invariant object-level visual representations, and an improvement of $+ 3 . 5$ $\mathsf { A P } ^ { \mathrm { b b } }$ / $+ 2 . 9 \mathrm { \ A P ^ { \mathrm { \bar { m k } } } }$ against the baseline is found. The box jitter strategy slightly elevates performance. Finally, multiple views $( V _ { 3 } )$ further directs SoCo towards learning scale-invariant and translationinvariant representations, and our method achieves $4 2 . 3 \mathrm { \ A P ^ { b b } }$ and $\mathsf { \bar { 3 } 7 . 6 \mathbf { A P } ^ { m k } }$ .
Ablation Study on Hyper-Parameters. Table 5 examines sensitivity to the hyper-parameters of SoCo.
Table 5(a) ablates the resolution of view $V _ { 3 }$ . SoCo is found to be insensitive to the image size of $V _ { 3 }$ We use $1 1 2 \times 1 1 2$ as the default resolution due to its slightly better transfer performance and low training computation cost.
Table 6: Transfer Learning on LVIS dataset using Mask R-CNN with R50-FPN.
<table><tr><td rowspan="2">Method</td><td rowspan="2">Epoch</td><td colspan="5">1× Schedule</td><td rowspan="2"></td><td colspan="6">2× Schedule</td></tr><tr><td>Apbb</td><td>AP</td><td>AP</td><td>APmk</td><td>AP</td><td>AP7</td><td>Apbb AP</td><td>AP</td><td>Apmk</td><td>AP</td><td>AP</td></tr><tr><td>Supervised</td><td>90</td><td>20.4</td><td>32.9</td><td>21.7</td><td>19.4</td><td>30.6</td><td>20.5</td><td>23.4</td><td>36.9</td><td>24.9</td><td>22.3</td><td>34.7</td><td>23.5</td></tr><tr><td>SoCo*</td><td>400</td><td>26.3</td><td>41.2</td><td>27.8</td><td>25.0</td><td>38.5</td><td>26.8</td><td>28.3</td><td>43.5</td><td>30.7</td><td>26.9</td><td>41.1</td><td>28.7</td></tr></table>
Table 7: Transfer learning on RetinaNet and FCOS.
<table><tr><td>Method</td><td>Epoch</td><td>Apbb</td><td>AP8</td><td>AP</td></tr><tr><td>Supervised</td><td>90</td><td>36.3</td><td>55.3</td><td>38.6</td></tr><tr><td>SoCo* 一</td><td>400</td><td>38.3</td><td>57.2</td><td>41.2</td></tr></table>
(b) Transfer to FCOS.
<table><tr><td>Method</td><td>Epoch</td><td>Apbb</td><td>AP8</td><td>AP9</td></tr><tr><td>Supervised</td><td>90</td><td>36.6</td><td>56.0</td><td>38.8</td></tr><tr><td>SoCo*</td><td>400</td><td>37.4</td><td>56.3</td><td>39.9</td></tr></table>
Table 5(b) ablates the training batch size of SoCo. It can be seen that larger or smaller batch sizes hurt the performance. We use a batch size of 2048 by default.
Table 5(c) ablates the effectiveness of object proposal generation strategies. To demonstrate the superiority of meaningful proposals generated by selective search, we randomly generate $K$ bounding boxes in each of the training images to replace the selective search proposals (namely Random in Table 5(c)). SoCo can still yield satisfactory results using a single random bounding box to learn object-level representations, which is not surprising, since the RoIAlign operation performed on the randomly generated bounding boxes also introduces object-level representation learning. This fact indirectly demonstrates that downstream object detectors can benefit from self-supervised pretraining that involves object-level representations. However, the result is still slightly worse than the case where only one object proposal generated by selective search is used in the pretraining. For the cases where we randomly generate 4 and 8 bounding boxes, the noisy and meaningless proposals cause the pretraining to diverge. From the table, we also find that applying more object proposals $K = 8$ and $K = 1 6$ ) generated by selective search can be harmful. One potential reason is that most of the images in the ImageNet dataset only contain a few objects, so a larger $K$ may create duplicated and redundant proposals.
Table 5(d) ablates the momentum coefficient $\tau$ of the exponential moving average, and $\tau = 0 . 9 9$ yields the best performance.
# 4.5 More Experiments
Transfer Learning on LVIS Dataset. In addition to COCO and PASCAL VOC object detection, we also consider the challenging LVIS v1 dataset [46] to demonstrate the effectiveness and generality of our approach. The LVIS v1 detection benchmark contains 1203 categories in a long-tailed distribution with few training samples. It is considered to be more challenging than the COCO benchmark. We use Mask R-CNN with R50-FPN backbone and follow the standard LVIS $1 \times$ and $2 \times$ training schedules. We do not use any training or post-processing tricks. Table 6 shows the results. We can see that our method achieves $+ 5 . 9 \mathrm { \ A \bar { P } ^ { b b } / + \bar { S } . 6 \mathrm { \ A P ^ { m k } } }$ and $+ 4 . 9 \mathrm { \ A P ^ { b b } / + 4 . 6 \ A P ^ { m k } }$ improvements under the LVIS $1 \times$ and $2 \times$ training schedules, respectively.
Transfer Learning on Different Object Detectors. In addition to two-stage detectors, we further conduct experiments on RetinaNet [47] and FCOS [48], which are representative works for singlestage detectors and anchor-free detectors. We transfer the weights of backbone and FPN layers learned by $\mathrm { S o C o ^ { * } }$ to RetinaNet and FCOS architectures and follow the standard COCO $1 \times$ schedule. We use MMDetection [49] as code base and default optimization configs are adopted. Table 7 shows the comparison.
Evaluation on Mini COCO. Transfer to the full COCO dataset may be of limited significance due to the extensive supervision available from its large-scale annotated training data. To further demonstrate the generalization ability of SoCo, we conduct an experiment on a mini version of the COCO dataset, named Mini COCO. Concretely, we randomly select $5 \%$ or $10 \%$ of the training data from COCO train2017 to form Mini COCO benchmarks. Mask-RCNN with R50-FPN backbone is adopted to evaluate the transfer performance on the COCO $1 \times$ schedule. COCO val2017 is still used as the evaluation set. The other settings remain unchanged. Table 8 summarizes the results. Compared with the supervised pretraining baseline which achieves $1 9 . 4 \ : \mathrm { A P ^ { b b } } / \ : 1 8 . 3 \ : \mathrm { A P ^ { m k } }$ and $2 4 . 7 \mathrm { A P } ^ { \mathrm { b b } }$ / 22.9 $\mathbf { A P } ^ { \mathrm { m k } }$ on the $5 \%$ and $10 \%$ Mini COCO benchmarks, SoCo obtains large improvements of $+ 6 . 6$ $\mathsf { A P } ^ { \mathrm { b b } }$ $^ { \mathrm { b } } / { + 4 . 6 } \mathrm { A P ^ { \mathrm { m k } } }$ and $+ 5 . 7$ $\mathsf { A P } ^ { \mathrm { b b } }$ / $+ 3 . 9 \mathrm { A P } ^ { \mathrm { m k } }$ , respectively. $\mathrm { S o C o ^ { * } }$ further boosts performance with improvements of $+ 7 . 4 \mathrm { \ A P ^ { b b } }$ $' + 5 . 5 \ : \mathrm { A P } ^ { \mathrm { m k } }$ and $+ 6 . 4 \mathrm { \ A P ^ { b b } }$ $\mathrm { ^ { \prime } { + } 4 . 7 \ A P ^ { m k } }$ over the supervised pretraining baseline.
Table 8: Results on Mini COCO $\mathbf { 1 } \times$ schedule. Mask R-CNN with R50-FPN backbone is adopted.
<table><tr><td rowspan="2">Methods</td><td rowspan="2">Epoch</td><td colspan="5">Mini COCO (5%)</td><td rowspan="2"></td><td colspan="5">Mini C0CO (10%)</td></tr><tr><td>Apbb AP8</td><td>AP9</td><td>APmk</td><td>APk</td><td>APm</td><td>Apbb</td><td>AP8</td><td>AP</td><td>Apmk</td><td>AP APP</td></tr><tr><td>Supervised</td><td>90</td><td>19.4</td><td>36.6</td><td>18.6</td><td>18.3</td><td>33.5</td><td>17.9</td><td>24.7</td><td>43.1</td><td>25.3</td><td>22.9</td><td>40.0</td><td>23.4</td></tr><tr><td>SoCo</td><td>100</td><td>24.6</td><td>42.2</td><td>25.6</td><td>22.1</td><td>38.8</td><td>22.4</td><td>29.2</td><td>47.7</td><td>31.1</td><td>26.1</td><td>44.4</td><td>27.0</td></tr><tr><td>SoCo</td><td>400</td><td>26.0</td><td>43.2</td><td>27.5</td><td>22.9</td><td>40.0</td><td>23.4</td><td>30.4</td><td>48.6</td><td>32.5</td><td>26.8</td><td>45.2</td><td>27.9</td></tr><tr><td>SoCo*</td><td>400</td><td>26.8</td><td>45.0</td><td>28.3</td><td>23.8</td><td>41.4</td><td>24.2</td><td>31.1</td><td>49.9</td><td>33.4</td><td>27.6</td><td>46.4</td><td>28.9</td></tr></table>
Table 9: Pretraining on non-object-centric dataset.
<table><tr><td>Pretraining dataset</td><td>Epoch</td><td>Apbb</td><td>AP</td><td>AP</td><td>Apmk</td><td>AP</td><td>APP</td></tr><tr><td>ImageNet</td><td>100</td><td>42.3</td><td>62.5</td><td>46.5</td><td>37.6</td><td>59.1</td><td>40.5</td></tr><tr><td>ImageNet-subset</td><td>100</td><td>36.9</td><td>56.2</td><td>40.1</td><td>33.2</td><td>53.0</td><td>35.6</td></tr><tr><td>COCO train set + unlabeled set</td><td>100</td><td>37.3</td><td>56.5</td><td>40.6</td><td>33.5</td><td>53.4</td><td>36.0</td></tr><tr><td>COCO train set + unlabeled set</td><td>530</td><td>40.6</td><td>61.1</td><td>44.4</td><td>36.4</td><td>58.1</td><td>38.7</td></tr></table>
Pretraining on Non-object-centric Dataset. We use COCO training set and unlabeled set as pretraining data. Since ImageNet is ${ \sim } 5 . 3$ times larger than COCO, we pretrain our method on COCO for 100 epochs and prolonged 530 epochs respectively. Furthermore, we also generate a dataset named ImageNet-Subset which contains the same number of images of COCO to verify the impact of different pretraining datasets. Table 9 shows the results. Compared with the ImageNet pretrained model, the COCO pretrained model under 530 epochs is lower by 1.7 AP, possibly because the scale of COCO is smaller than ImageNet. Compared with the ImageNet-Subset pretrained model, the COCO pretrained model under 100 epochs is $+ 0 . 4$ AP higher, which demonstrates the importance of domain alignment between the pretraining dataset and detection dataset.
Longer Finetuning. We transfer $\mathrm { { \bf S o C o ^ { * } } }$ to Mask R-CNN with R50-FPN under the COCO $4 \times$ schedule. Table 10 shows the results. Our model continues to improve the performance with the $4 \times$ finetuning schedule, surpassing the supervised baseline by $+ 2 . 6 \ : \mathrm { \bar { A P } ^ { b b } } / + 1 . \bar { 9 } \ : \mathrm { A P ^ { m k } }$ .
Table 10: Finetuning on COCO $4 \times$ schedule using Mask R-CNN with R50-FPN.
<table><tr><td>Method</td><td>Epoch</td><td>APbb</td><td>APb 50</td><td>AP</td><td>Apmk</td><td>AP 50</td><td>APP</td></tr><tr><td>Supervised</td><td>90</td><td>41.9</td><td>61.5</td><td>45.4</td><td>37.7</td><td>58.8</td><td>40.5</td></tr><tr><td>SoCo*</td><td>400</td><td>44.5</td><td>64.2</td><td>48.8</td><td>39.6</td><td>61.5</td><td>42.4</td></tr></table>
# 5 Conclusion
In this paper, we propose a novel object-level self-supervised pretraining method named Selective Object COntrastive learning (SoCo), which aims to align pretraining to object detection. Different from prior image-level contrastive learning methods which treat the whole image as an instance, SoCo treats each object proposal generated by the selective search algorithm as an independent instance, enabling SoCo to learn object-level visual representations. Further alignment is obtained in two ways. One is through network alignment between pretraining and downstream object detection, such that all layers of the detectors can be well-initialized. The other is by accounting for important properties of object detection such as object-level translation invariance and scale invariance. SoCo achieves state-of-the-art transfer performance on COCO detection using a Mask R-CNN detector. Experiments on two-stage and single-stage detectors demonstrate the generality and extensibility of SoCo.
# References
[1] Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A largescale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pages 248–255. Ieee, 2009. [2] Zhirong Wu, Yuanjun Xiong, X Yu Stella, and Dahua Lin. Unsupervised feature learning via non-parametric instance discrimination. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2018. [3] Jean-Bastien Grill, Florian Strub, Florent Altché, Corentin Tallec, Pierre H Richemond, Elena Buchatskaya, Carl Doersch, Bernardo Avila Pires, Zhaohan Daniel Guo, Mohammad Gheshlaghi Azar, et al. Bootstrap your own latent: A new approach to self-supervised learning. arXiv preprint arXiv:2006.07733, 2020. [4] Kaiming He, Haoqi Fan, Yuxin Wu, Saining Xie, and Ross Girshick. Momentum contrast for unsupervised visual representation learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 9729–9738, 2020. [5] Xinlei Chen, Haoqi Fan, Ross Girshick, and Kaiming He. Improved baselines with momentum contrastive learning. arXiv preprint arXiv:2003.04297, 2020. [6] Yonglong Tian, Chen Sun, Ben Poole, Dilip Krishnan, Cordelia Schmid, and Phillip Isola. What makes for good views for contrastive learning. arXiv preprint arXiv:2005.10243, 2020. [7] Mathilde Caron, Ishan Misra, Julien Mairal, Priya Goyal, Piotr Bojanowski, and Armand Joulin. Unsupervised learning of visual features by contrasting cluster assignments. arXiv preprint arXiv:2006.09882, 2020. [8] Xinlei Chen and Kaiming He. Exploring simple siamese representation learning. arXiv preprint arXiv:2011.10566, 2020. [9] 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. [10] Zhenda Xie, Yutong Lin, Zheng Zhang, Yue Cao, Stephen Lin, and Han Hu. Propagate yourself: Exploring pixel-level consistency for unsupervised visual representation learning. arXiv preprint arXiv:2011.10043, 2020. [11] Xinlong Wang, Rufeng Zhang, Chunhua Shen, Tao Kong, and Lei Li. Dense contrastive learning for self-supervised visual pre-training. arXiv preprint arXiv:2011.09157, 2020. [12] Ceyuan Yang, Zhirong Wu, Bolei Zhou, and Stephen Lin. Instance localization for selfsupervised detection pretraining. arXiv preprint arXiv:2102.08318, 2021. [13] Olivier J Hénaff, Skanda Koppula, Jean-Baptiste Alayrac, Aaron van den Oord, Oriol Vinyals, and João Carreira. Efficient visual pretraining with contrastive detection. arXiv preprint arXiv:2103.10957, 2021. [14] Jasper RR Uijlings, Koen EA Van De Sande, Theo Gevers, and Arnold WM Smeulders. Selective search for object recognition. International journal of computer vision, 104(2):154–171, 2013. [15] 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. [16] Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. arXiv preprint arXiv:1506.01497, 2015. [17] 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. [18] Pascal Vincent, Hugo Larochelle, Isabelle Lajoie, Yoshua Bengio, Pierre-Antoine Manzagol, and Léon Bottou. Stacked denoising autoencoders: Learning useful representations in a deep network with a local denoising criterion. Journal of machine learning research, 11(12), 2010. [19] Ruslan Salakhutdinov and Geoffrey Hinton. Deep boltzmann machines. In Artificial intelligence and statistics, pages 448–455. PMLR, 2009. [20] Gustav Larsson, Michael Maire, and Gregory Shakhnarovich. Colorization as a proxy task for visual understanding. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 6874–6883, 2017. [21] 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. [22] Deepak Pathak, Philipp Krahenbuhl, Jeff Donahue, Trevor Darrell, and Alexei A Efros. Context encoders: Feature learning by inpainting. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 2536–2544, 2016. [23] Spyros Gidaris, Praveer Singh, and Nikos Komodakis. Unsupervised representation learning by predicting image rotations. arXiv preprint arXiv:1803.07728, 2018. [24] Olivier Henaff. Data-efficient image recognition with contrastive predictive coding. In International Conference on Machine Learning, pages 4182–4192. PMLR, 2020. [25] Jure Zbontar, Li Jing, Ishan Misra, Yann LeCun, and Stéphane Deny. Barlow twins: Selfsupervised learning via redundancy reduction. arXiv preprint arXiv:2103.03230, 2021. [26] Mathilde Caron, Hugo Touvron, Ishan Misra, Hervé Jégou, Julien Mairal, Piotr Bojanowski, and Armand Joulin. Emerging properties in self-supervised vision transformers. arXiv preprint arXiv:2104.14294, 2021. [27] Mathilde Caron, Piotr Bojanowski, Julien Mairal, and Armand Joulin. Unsupervised pretraining of image features on non-curated data. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 2959–2968, 2019. [28] Priya Goyal, Mathilde Caron, Benjamin Lefaudeux, Min Xu, Pengchao Wang, Vivek Pai, Mannat Singh, Vitaliy Liptchinsky, Ishan Misra, Armand Joulin, et al. Self-supervised pretraining of visual features in the wild. arXiv preprint arXiv:2103.01988, 2021. [29] Pedro O Pinheiro, Amjad Almahairi, Ryan Y Benmaleck, Florian Golemo, and Aaron Courville. Unsupervised learning of dense visual representations. arXiv preprint arXiv:2011.05499, 2020. [30] Pablo Arbeláez, Jordi Pont-Tuset, Jonathan T Barron, Ferran Marques, and Jitendra Malik. Multiscale combinatorial grouping. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 328–335, 2014. [31] Zhigang Dai, Bolun Cai, Yugeng Lin, and Junying Chen. Up-detr: Unsupervised pre-training for object detection with transformers. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 1601–1610, 2021. [32] Songtao Liu, Zeming Li, and Jian Sun. Self-emd: Self-supervised object detection without imagenet. arXiv preprint arXiv:2011.13677, 2020. [33] Bharat Singh and Larry S. Davis. An analysis of scale invariance in object detection - snip, 2018. [34] Ross Girshick, Jeff Donahue, Trevor Darrell, and Jitendra Malik. Rich feature hierarchies for accurate object detection and semantic segmentation. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 580–587, 2014. [35] Ross Girshick. Fast r-cnn. In Proceedings of the IEEE international conference on computer vision, pages 1440–1448, 2015. [36] 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. [37] 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. [38] Vinod Nair and Geoffrey E Hinton. Rectified linear units improve restricted boltzmann machines. In Icml, 2010. [39] Yang You, Igor Gitman, and Boris Ginsburg. Scaling sgd batch size to 32k for imagenet training. arXiv preprint arXiv:1708.03888, 6:12, 2017. [40] Ilya Loshchilov and Frank Hutter. Sgdr: Stochastic gradient descent with warm restarts. arXiv preprint arXiv:1608.03983, 2016. [41] 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. [42] 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. [43] Mark Everingham, Luc Van Gool, Christopher KI Williams, John Winn, and Andrew Zisserman. The pascal visual object classes (voc) challenge. International journal of computer vision, 88(2):303–338, 2010. [44] Yuxin Wu, Alexander Kirillov, Francisco Massa, Wan-Yen Lo, and Ross Girshick. Detectron2. https://github.com/facebookresearch/detectron2, 2019. [45] Tete Xiao, Colorado J Reed, Xiaolong Wang, Kurt Keutzer, and Trevor Darrell. Region similarity representation learning. arXiv preprint arXiv:2103.12902, 2021. [46] Agrim Gupta, Piotr Dollar, and Ross Girshick. Lvis: A dataset for large vocabulary instance segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 5356–5364, 2019. [47] 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. [48] Zhi Tian, Chunhua Shen, Hao Chen, and Tong He. Fcos: Fully convolutional one-stage object detection. In Proceedings of the IEEE/CVF international conference on computer vision, pages 9627–9636, 2019. [49] 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, 2019.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390# DRNAS: DIRICHLET NEURAL ARCHITECTURE SEARCH
Xiangning Chen1∗ Ruochen Wang1∗ Minhao Cheng1∗ Xiaocheng Tang2 Cho-Jui Hsieh1
1Department of Computer Science, UCLA, 2DiDi AI Labs {xiangning, chohsieh}@cs.ucla.edu {ruocwang, mhcheng}@ucla.edu xiaochengtang@didiglobal.com
# ABSTRACT
This paper proposes a novel differentiable architecture search method by formulating it into a distribution learning problem. We treat the continuously relaxed architecture mixing weight as random variables, modeled by Dirichlet distribution. With recently developed pathwise derivatives, the Dirichlet parameters can be easily optimized with gradient-based optimizer in an end-to-end manner. This formulation improves the generalization ability and induces stochasticity that naturally encourages exploration in the search space. Furthermore, to alleviate the large memory consumption of differentiable NAS, we propose a simple yet effective progressive learning scheme that enables searching directly on large-scale tasks, eliminating the gap between search and evaluation phases. Extensive experiments demonstrate the effectiveness of our method. Specifically, we obtain a test error of $2 . 4 6 \%$ for CIFAR-10, $2 3 . 7 \%$ for ImageNet under the mobile setting. On NASBench-201, we also achieve state-of-the-art results on all three datasets and provide insights for the effective design of neural architecture search algorithms.
# 1 INTRODUCTION
Recently, Neural Architecture Search (NAS) has attracted lots of attentions for its potential to democratize deep learning. For a practical end-to-end deep learning platform, NAS plays a crucial role in discovering task-specific architecture depending on users’ configurations (e.g., dataset, evaluation metric, etc.). Pioneers in this field develop prototypes based on reinforcement learning (Zoph & Le, 2017), evolutionary algorithms (Real et al., 2019) and Bayesian optimization (Liu et al., 2018). These works usually incur large computation overheads, which make them impractical to use. More recent algorithms significantly reduce the search cost including one-shot methods (Pham et al., 2018; Bender et al., 2018), a continuous relaxation of the space (Liu et al., 2019) and network morphisms (Cai et al., 2018). In particular, Liu et al. (2019) proposes a differentiable NAS framework - DARTS, converting the categorical operation selection problem into learning a continuous architecture mixing weight. They formulate a bi-level optimization objective, allowing the architecture search to be efficiently performed by a gradient-based optimizer.
While current differentiable NAS methods achieve encouraging results, they still have shortcomings that hinder their real-world applications. Firstly, several works have cast doubt on the stability and generalization of these differentiable NAS methods (Chen & Hsieh, 2020; Zela et al., 2020a). They discover that directly optimizing the architecture mixing weight is prone to overfitting the validation set and often leads to distorted structures, e.g., searched architectures dominated by parameter-free operations. Secondly, there exist disparities between the search and evaluation phases, where proxy tasks are usually employed during search with smaller datasets or shallower and narrower networks, due to the large memory consumption of differentiable NAS.
In this paper, we propose an effective approach that addresses the aforementioned shortcomings named Dirichlet Neural Architecture Search (DrNAS). Inspired by the fact that directly optimizing the architecture mixing weight is equivalent to performing point estimation (MLE/MAP) from a probabilistic perspective, we formulate the differentiable NAS as a distribution learning problem instead, which naturally induces stochasticity and encourages exploration. Making use of the probability simplex property of the Dirichlet samples, DrNAS models the architecture mixing weight as random variables sampled from a parameterized Dirichlet distribution. Optimizing the Dirichlet objective can thus be done efficiently in an end-to-end fashion, by employing the pathwise derivative estimators to compute the gradient of the distribution (Martin Jankowiak, 2018). A straightforward optimization, however, turns out to be problematic due to the uncontrolled variance of the Dirichlet, i.e., too much variance leads to training instability and too little variance suffers from insufficient exploration. In light of that, we apply an additional distance regularizer directly on the Dirichlet concentration parameter to strike a balance between the exploration and the exploitation. We further derive a theoretical bound showing that the constrained distributional objective promotes stability and generalization of architecture search by implicitly controlling the Hessian of the validation error.
Furthermore, to enable a direct search on large-scale tasks, we propose a progressive learning scheme, eliminating the gap between the search and evaluation phases. Based on partial channel connection (Xu et al., 2020), we maintain a task-specific super-network of the same depth and number of channels as the evaluation phase throughout searching. To prevent loss of information and instability induced by partial connection, we divide the search phase into multiple stages and progressively increase the channel fraction via network transformation (Chen et al., 2016). Meanwhile, we prune the operation space according to the learnt distribution to maintain the memory efficiency.
We conduct extensive experiments on different datasets and search spaces to demonstrate DrNAS’s effectiveness. Based on the DARTS search space (Liu et al., 2019), we achieve an average error rate of $2 . 4 6 \%$ on CIFAR-10, which ranks top amongst NAS methods. Furthermore, DrNAS achieves superior performance on large-scale tasks such as ImageNet. It obtains a top-1/5 error of $2 3 . 7 \% / 7 . 1 \%$ , surpassing the previous state-of-the-art $( 2 4 . 0 \% / 7 . 3 \% )$ under the mobile setting. On NAS-Bench201 (Dong & Yang, 2020), we also set new state-of-the-art results on all three datasets with low variance. Our code is available at https://github.com/xiangning-chen/DrNAS.
# 2 THE PROPOSED APPROACH
In this section, we first briefly review differentiable NAS setups and generalize the formulation to motivate distribution learning. We then layout our proposed DrNAS and describe its optimization in section 2.2. In section 2.3, we provide a generalization result by showing that our method implicitly regularizes the Hessian norm over the architecture parameter. The progressive architecture learning method that enables direct search is then described in section 2.4.
# 2.1 PRELIMINARIES: DIFFERENTIABLE ARCHITECTURE SEARCH
Cell-Based Search Space The cell-based search space is constructed by replications of normal and reduction cells (Zoph et al., 2018; Liu et al., 2019). A normal cell keeps the spatial resolution while a reduction cell halves it but doubles the number of channels. Every cell is represented by a DAG with $N$ nodes and $E$ edges, where every node represents a latent representation $\mathbf { x } ^ { i }$ and every edge $( i , j )$ is associated with an operations $o ^ { ( i , j ) }$ (e.g., max pooling or convolution) selected from a predefined candidate space $\mathcal { O }$ . The output of a node is a summation of all input flows, i.e., $\begin{array} { r } { \mathbf { x } ^ { j } = \sum _ { i < j } o ^ { ( i , j ) } ( \mathbf { x } ^ { i } ) } \end{array}$ and a concatenation of intermediate node outputs, i.e., $c o n c a t ( \mathbf { x } ^ { 2 } , . . . , \mathbf { x } ^ { N - 1 } )$ , composes the cell output, where the first two input nodes $\mathbf { x } ^ { 0 }$ and ${ \hat { \mathbf { x } } } ^ { 1 }$ are fixed to be the outputs of previous two cells.
Gradient-Based Search via Continuous Relaxation To enable gradient-based optimization, Liu et al. (2019) apply a continuous relaxation to the discrete space. Concretely, the information passed from node $i$ to node $j$ is computed by a weighted sum of all operations alone the edge, forming a mixed-operation $\begin{array} { r } { \hat { o } ^ { ( i , j ) } ( x ) = \sum _ { o \in \mathcal { O } } \theta _ { o } ^ { ( i , j ) } o ( x ) } \end{array}$ . The operation mixing weight $\theta ^ { ( i , j ) }$ is defined over the probability simplex and its magnitude represents the strength of each operation. Therefore, the architecture search can be cast as selecting the operation associated with the highest mixing weight for each edge. To prevent abuse of terminology, we refer to $\theta$ as the architecture/operation mixing weight, and concentration parameter $\beta$ in DrNAS as the architecture parameter throughout the paper.
Bilevel-Optimization with Simplex Constraints With continuous relaxation, the network weight $w$ and operation mixing weight $\theta$ can be jointly optimized by solving a constraint bi-level optimization
problem:
$$\operatorname* { m i n } _ { \theta } \mathcal { L } _ { v a l } ( w ^ { * } , \theta ) \mathrm { ~ s . t . ~ } w ^ { * } = \underset { w } { \arg \operatorname* { m i n } } \mathcal { L } _ { t r a i n } ( w , \theta ) , \sum _ { o = 1 } ^ { | \mathcal { O } | } \theta _ { o } ^ { ( i , j ) } = 1 , \forall ( i , j ) , i < j ,$$
where the simplex constraint $\begin{array} { r } { \sum _ { o = 1 } ^ { | \mathcal { O } | } \theta _ { o } ^ { ( i , j ) } = 1 } \end{array}$ can be either solved explicitly via Lagrangian function (Li et al., 2020), or eliminated by substitution method (e.g., $\theta = S o f t m a x ( \alpha ) , \alpha \ \in$ $\mathcal { R } ^ { | \mathcal { O } | \times | E | } ,$ ) (Liu et al., 2019). In the next section we describe how this generalized formulation motivates our method.
# 2.2 DIFFERENTIABLE ARCHITECTURE SEARCH AS DISTRIBUTION LEARNING
Learning a Distribution over Operation Mixing Weight Previous differentiable architecture search methods view the operation mixing weight $\theta$ as learnable parameters that can be directly optimized (Liu et al., 2019; Xu et al., 2020; Li et al., 2020). This has been shown to cause $\theta$ to overfit the validation set and thus induce large generalization error (Zela et al., 2020a;b; Chen & Hsieh, 2020). We recognize that this treatment is equivalent to performing point estimation (e.g., MLE/MAP) of $\theta$ in probabilistic view, which is inherently prone to overfitting (Bishop, 2016; Gelman et al., 2004). Furthermore, directly optimizing $\theta$ lacks sufficient exploration in the search space, and thus cause the search algorithm to commit to suboptimal paths in the DAG that converges faster at the beginning but plateaus quickly (Shu et al., 2020).
Based on these insights, we formulate the differentiable architecture search as a distribution learning problem. The operation mixing weight $\theta$ is treated as random variables sampled from a learnable distribution. Formally, let $q ( \theta | \beta )$ denote the distribution of $\theta$ parameterized by $\beta$ . The bi-level objective is then given by:
$$\operatorname* { m i n } _ { \beta } E _ { q ( \theta | \beta ) } \big [ \mathcal { L } _ { v a l } ( w ^ { * } , \theta ) \big ] + \lambda d ( \beta , \hat { \beta } ) \mathrm { ~ s . t . ~ } w ^ { * } = \operatorname * { a r g m i n } _ { w } \mathcal { L } _ { t r a i n } ( w , \theta ) .$$
where $d ( \cdot , \cdot )$ is a distance function. Since $\theta$ lies on the probability simplex, we select Dirichlet distribution to model its behavior, i.e., $q ( \theta | \beta ) \sim D i r ( \beta )$ , where $\beta$ represents the Dirichlet concentration parameter. Dirichlet distribution is a widely used distribution over the probability simplex (Joo et al., 2019; David M. Blei, 2003; Lee et al., 2020; Kessler et al., 2019), and it enjoys nice properties that enables gradient-based training (Martin Jankowiak, 2018).
The concentration parameter $\beta$ controls the sampling behavior of Dirichlet distribution and is crucial in balancing exploration and exploitation during the search phase. Let $\beta _ { o }$ denote the concentration parameter assign to operation $o$ . When $\beta _ { o } \ll 1$ for most $o = 1 \sim | \mathcal { O } |$ , Dirichlet tends to produce sparse samples with high variance, reducing the training stability; when $\beta _ { o } \gg 1$ for most $o = 1 \sim | \mathcal { O } |$ , the samples will be dense with low variance, leading to insufficient exploration. Therefore, we add a penalty term in the objective (2) to regularize the distance between $\beta$ and the anchor $\hat { \beta } = 1$ , which corresponds to the symmetric Dirichlet. In section 2.3, we also derive a theoretical bound showing that our formulation additionally promotes stability and generalization of the architecture search by implicitly regularizing the Hessian of validation loss w.r.t. architecture parameters.
Learning Dirichlet Parameters via Pathwise Derivative Estimator Optimizing objective (2) with gradient-based methods requires back-propagation through stochastic nodes of Dirichlet samples. The commonly used reparameterization trick does not apply to Dirichlet distribution, therefore we approximate the gradient of Dirichlet samples via pathwise derivative estimators (Martin Jankowiak, 2018)
$$\frac { d \theta _ { i } } { d \beta _ { j } } = - \frac { \frac { \partial F _ { B e t a } } { \partial \beta _ { j } } \big ( \theta _ { j } \big | \beta _ { j } , \beta _ { t o t } - \beta _ { j } \big ) } { f _ { B e t a } \big ( \theta _ { j } \big | \beta _ { j } , \beta _ { t o t } - \beta _ { j } \big ) } \times \big ( \frac { \delta _ { i j } - \theta _ { i } } { 1 - \theta _ { j } } \big ) \quad i , j = 1 , . . . , \vert \mathcal { O } \vert ,$$
where $F _ { B e t a }$ and $f _ { B e t a }$ denote the CDF and PDF of beta distribution respectively, $\delta _ { i j }$ is the indicator function, and $\beta _ { t o t }$ is the sum of concentrations. $F _ { B e t a }$ is the iregularised incomplete beta function, for which its gradient can be computed by simple numerical approximation. We refer to (Martin Jankowiak, 2018) for the complete derivations.
Joint Optimization of Model Weight and Architecture Parameter With pathwise derivative estimator, the model weight $w$ and concentration $\beta$ can be jointly optimized with gradient descent. Concretely, we draw a sample $\theta \sim D i r ( \beta )$ for every forward pass, and the gradients can be obtained easily through backpropagation. Following DARTS (Liu et al., 2019), we approximate $w ^ { * }$ in the lower level objective of equation 2 with one step of gradient descent, and run alternative updates between $w ^ { * }$ and $\beta$ .
Selecting the Best Architecture At the end of the search phase, a learnt distribution of operation mixing weight is obtained. We then select the best operation for each edge by the most likely operation in expectation:
$$o ^ { ( i , j ) } = \arg \operatorname* { m a x } _ { o \in \mathcal { O } } E _ { q ( \theta _ { o } ^ { ( i , j ) } | \beta ^ { ( i , j ) } ) } \left[ \theta _ { o } ^ { ( i , j ) } \right] .$$
In the Dirichlet case, the expectation term is simply the Dirichlet mean P o0 β(i,j)o0 . Note that under the distribution learning framework, we are able to sample a wide range of architectures from the learnt distribution. This property alone has many potentials. For example, in practical settings where both accuracy and latency are concerned, the learnt distribution can be used to find architectures under resource restrictions in a post search phase. We leave these extensions to future work.
# 2.3 THE IMPLICIT REGULARIZATION ON HESSIAN
It has been observed that the generalization error of differentiable NAS is highly related to the dominant eigenvalue of the Hessian of validation loss w.r.t. architecture parameter. Several recent works report that the large dominant eigenvalue of $\nabla _ { \theta } ^ { 2 } \tilde { \mathcal { L } } _ { v a l } ( w , \theta )$ in DARTS results in poor generalization performance (Zela et al., 2020a; Chen & Hsieh, 2020). Our objective (2) is the Lagrangian function of the following constraint objective:
$$\operatorname* { m i n } _ { \beta } E _ { q ( \theta | \beta ) } \left[ \mathcal { L } _ { v a l } ( w ^ { * } , \theta ) \right] \mathrm { ~ s . t . ~ } w ^ { * } = \arg \operatorname* { m i n } _ { w } \mathcal { L } _ { t r a i n } ( w , \theta ) , \ d ( \beta , \hat { \beta } ) \leq \delta ,$$
Here we derive an approximated lower bound based on (5), which demonstrates that our method implicitly controls this Hessian matrix.
Proposition 1 Let $d ( { \boldsymbol { \beta } } , { \hat { \boldsymbol { \beta } } } ) = \| { \boldsymbol { \beta } } - { \hat { \boldsymbol { \beta } } } \| _ { 2 } \leq \delta$ and $\hat { \beta } = 1$ in the bi-level formulation (5). Let $\mu$ denote the mean under the Laplacian approximation of Dirichlet. If $\nabla _ { \mu } ^ { 2 } \tilde { \mathcal { L } } _ { v a l } ( w ^ { * } , \mu )$ is Positive Semi-definite, the upper-level objective can be approximated bounded by:
$$E _ { q ( \theta | \beta ) } ( \mathcal { L } _ { v a l } ( w , \theta ) ) \gtrsim \tilde { \mathcal { L } } _ { v a l } ( w ^ { * } , \mu ) + \frac { 1 } { 2 } ( \frac { 1 } { 1 + \delta } ( 1 - \frac { 2 } { | \mathcal { O } | } ) + \frac { 1 } { | \mathcal { O } | } \frac { 1 } { 1 + \delta } ) t r \big ( \nabla _ { \mu } ^ { 2 } \tilde { \mathcal { L } } _ { v a l } ( w ^ { * } , \mu ) \big )$$
with:
$$\tilde { \mathcal { L } } _ { v a l } ( w ^ { * } , \mu ) = \mathcal { L } _ { v a l } ( w ^ { * } , S o f t m a x ( \mu ) ) , \mu _ { o } = \log \beta _ { o } - \frac { 1 } { | \mathcal { O } | } \sum _ { o ^ { \prime } } \log \beta _ { o ^ { \prime } } , o = 1 , \ldots , | \mathcal { O } | .$$
This proposition is driven by the Laplacian approximation to the Dirichlet distribution (MacKay, 1998; Akash Srivastava, 2017). The lower bound (6) indicates that minimizing the expected validation loss controls the trace norm of the Hessian matrix. Empirically, we observe that DrNAS always maintains the dominant eigenvalue of Hessian at a low level (Appendix A.4). The detailed proof can be found in Appendix A.1.
# 2.4 PROGRESSIVE ARCHITECTURE LEARNING
The GPU memory consumption of differentiable NAS methods grows linearly with the size of operation candidate space. Therefore, they usually use a easier proxy task such as training with a smaller dataset, or searching with fewer layers and number of channels (Cai et al., 2019). For instance, the architecture search is performed on 8 cells and 16 initial channels in DARTS (Liu et al., 2019). But during evaluation, the network has 20 cells and 36 initial channels. Such gap makes it hard to derive an optimal architecture for the target task (Cai et al., 2019).
PC-DARTS (Xu et al., 2020) proposes a partial channel connection to reduce the memory overheads of differentiable NAS, where they only send a random subset of channels to the mixed-operation while directly bypassing the rest channels in a shortcut. However, their method causes loss of information and makes the selection of operation unstable since the sampled subsets may vary widely across iterations. This drawback is amplified when combining with the proposed method since we learn the architecture distribution from Dirichlet samples, which already injects certain stochasticity. As shown in Table 1, when directly applying partial channel connection with distribution learning, the test accuracy of the searched architecture decreases over $3 \%$ and $18 \%$ on CIFAR-10 and CIFAR-100 respectively if we send only 1/8 channels to the mixed-operation.
To alleviate such information loss and instability problem while being memory-efficient, we propose a progressive learning scheme which gradually increases the fraction of channels that are forwarded to the mixed-operation and meanwhile prunes the operation space based on the learnt distribution. We split the search process into consecutive stages and construct a task-specific super-network with the same depth and number of channels as the evaluation phase at the initial stage. Then after each stage, we increase the partial channel fraction, which means that the super-network in the next stage will be wider, i.e., have more convolution channels, and in turn preserve more information. This is achieved by enlarging every convolution weight with a random mapping function similar to Net2Net (Chen et al., 2016). The mapping function $\bar { g } : \{ 1 , 2 , \dotsc , q \} \{ \bar { 1 , 2 } , \dotsc , n \}$ with $q > n$ is defined as
$$g ( j ) = { \left\{ \begin{array} { l l } { j } & { j \leq n } \\ { \operatorname { r a n d o m } \operatorname { s a m p l e } \operatorname { f r o m } \left\{ 1 , 2 , \dots , n \right\} } & { j > n } \end{array} \right. }$$
To widen layer $l$ , we replace its convolution weight $\mathbf { W } ^ { ( l ) } \in \mathbb { R } ^ { O u t \times I n \times H \times W }$ with a new weight $\mathbf { U } ^ { ( l ) }$
$$\mathbf { U } _ { o , i , h , w } ^ { ( l ) } = \mathbf { W } _ { g ( o ) , g ( i ) , h , w } ^ { ( l ) } ,$$
where $O u t , I n , H , W$ denote the number of output and input channels, filter height and width respectively. Intuitively, we copy $\mathbf { W } ^ { ( l ) }$ directly into $\mathbf { U } ^ { ( l ) }$ and fulfill the rest part by choosing randomly as defined in $g$ . Unlike Net2Net, we do not divide $\mathbf { U } ^ { ( l ) }$ by a replication factor here because the information flow on each edge has the same scale no matter the partial fraction is. After widening the super-network, we reduce the operation space by pruning out less important operations according to the Dirichlet concentration parameter $\beta$ learnt from the previous stage, maintaining a consistent memory consumption. As illustrated in Table 1, the proposed progressive architecture learning scheme effectively discovers high accuracy architectures and retains a low GPU memory overhead.
# 3 DISCUSSIONS AND RELATIONSHIP TO PRIOR WORK
Early methods in NAS usually include a full training and evaluation procedure every iteration as the inner loop to guide the consecutive search (Zoph & Le, 2017; Zoph et al., 2018; Real et al., 2019). Consequently, their computational overheads are beyond acceptance for practical usage, especially on large-scale tasks.
Differentiable NAS Recently, many works are proposed to improve the efficiency of NAS (Pham et al., 2018; Cai et al., 2018; Liu et al., 2019; Bender et al., 2018; Yao et al., 2020b;a; Mei et al., 2020). Amongst them, DARTS (Liu et al., 2019) proposes a differentiable NAS framework, which introduces a continuous architecture parameter that relaxes the discrete search space. Despite being efficient, DARTS only optimizes a single point on the simplex every search epoch, which has no guarantee to generalize well after the discretization during evaluation. So its stability and generalization have been widely challenged (Li & Talwalkar, 2019; Zela et al., 2020a; Chen & Hsieh, 2020; Wang et al., 2021). Following DARTS, SNAS (Xie et al., 2019) and GDAS (Dong & Yang, 2019)
Table 1: Test accuracy of the derived architectures when searching on NASBench-201 with different partial channel fraction, where $1 / K$ channels are sent to the mixed-operation.
<table><tr><td>K</td><td>CIFAR-10 Test Accuracy (%)</td><td>GPU Memory (MB)</td></tr><tr><td>1</td><td>94.36±0.00</td><td>2437</td></tr><tr><td>2</td><td>93.49 ±0.28</td><td>1583</td></tr><tr><td>4</td><td>92.85 ± 0.35</td><td>1159 949</td></tr><tr><td>8 Ours</td><td>91.06 ± 0.00 94.36 ±0.00</td><td>949</td></tr><tr><td></td><td>CIFAR-100</td><td>GPU Memory</td></tr><tr><td>K</td><td>Test Accuracy (%)</td><td>(MB)</td></tr><tr><td>1 2</td><td>73.51± 0.00</td><td>2439 1583</td></tr><tr><td></td><td>68.48 ± 0.41</td><td>1161</td></tr><tr><td>4</td><td>66.68 ± 3.22</td><td>949</td></tr><tr><td>8 Ours</td><td>55.11 ± 13.78 73.51 ± 0.00</td><td>949</td></tr></table>
leverage the gumbel-softmax trick to learn the exact architecture parameter. However, their reparameterization is motivated from reinforcement learning perspective, which is an approximation with softmax rather than an architecture distribution. Besides, their methods require tuning of temperature schedule (Yan et al., 2017; Caglar Gulcehre, 2017). GDAS linearly decreases the temperature from 10 to 1 while SNAS anneals it from 1 to 0.03. In comparison, the proposed method can automatically learn the architecture distribution without the requirement of handcrafted scheduling. BayesNAS (Zhou et al., 2019) applies Bayesian Learning in NAS. Specifically, they cast NAS as model compression problem and use Bayes Neural Network as the super-network, which is difficult to optimize and requires oversimplified approximation. While our method considers the stochasticity in architecture mixing weight, as it is directly related to the generalization of differentiable NAS algorithms (Zela et al., 2020a; Chen & Hsieh, 2020).
Memory overhead When dealing with the large memory consumption of differentiable NAS, previous works mainly restrain the number of paths sampled during the search phase. For instance, ProxylessNAS (Cai et al., 2019) employs binary gates and samples two paths every search epoch. PARSEC (Casale et al., 2019) samples discrete architectures according to a categorical distribution to save memory. Similarly, GDAS (Dong & Yang, 2019) and DSNAS (Hu et al., 2020) both enforce a discrete constraint after the gumbel-softmax reparametrization. However, such discretization manifests premature convergence and cause search instability (Zela et al., 2020b; Zhang et al., 2020). Our experiments in section 4.3 also empirically demonstrate this phenomenon. As an alternative, PC-DARTS (Xu et al., 2020) proposes a partial channel connection, where only a portion of channels is sent to the mixed-operation. However, partial connection can cause loss of information as shown in section 2.4 and PC-DARTS searches on a shallower network with less channels, suffering the search and evaluation gap. Our solution, by progressively pruning the operation space and meanwhile widening the network, searches in a task-specific manner and achieves superior accuracy on challenging datasets like ImageNet $( + 2 . 8 \%$ over BayesNAS, $+ 2 . 3 \%$ over GDAS, $+ 2 . 3 \%$ over PARSEC, $+ 2 . 0 \%$ over DSNAS, $+ 1 . 2 \%$ over ProxylessNAS, and $+ 0 . 5 \%$ over PC-DARTS).
# 4 EXPERIMENTS
In this section, we evaluate our proposed DrNAS on two search spaces: the CNN search space in DARTS (Liu et al., 2019) and NAS-Bench-201 (Dong & Yang, 2020). For DARTS space, we conduct experiments on both CIFAR-10 and ImageNet in section 4.1 and 4.2 respectively. For NAS-Bench201, we test all 3 supported datasets (CIFAR-10, CIFAR-100, ImageNet-16-120 (Chrabaszcz et al., 2017)) in section 4.3. Furthermore, we empirically study the dynamics of exploration and exploitation throughout the search process in section 4.4.
# 4.1 RESULTS ON CIFAR-10
Architecture Space For both search and evaluation phases, we stack 20 cells to compose the network and set the initial channel number as 36. We place the reduction cells at the 1/3 and 2/3 of the network and each cell consists of $N = 6$ nodes.
Search Settings We equally divide the 50K training images into two parts, one is used for optimizing the network weights by momentum SGD and the other for learning the Dirichlet architecture distribution by an Adam optimizer. Since Dirichlet concentration $\beta$ must be positive, we apply the shifted exponential linear mapping $\beta = \mathrm { E L U } ( \eta ) + 1$ and optimize over $\eta$ instead. We use $l _ { 2 }$ norm to constrain the distance between $\eta$ and the anchor $\hat { \eta } = 0$ . The $\eta$ is initialized by standard Gaussian with scale 0.001, and $\lambda$ in (2) is set to 0.001. The ablation study in Appendix A.3 reveals the effectiveness of our anchor regularizer, and DrNAS is insensitive to a wide range of $\lambda$ . These settings are consistent for all experiments. For progressive architecture learning, the whole search process consists of 2 stages, each with 25 iterations. In the first stage, we set the partial channel parameter $K$ as 6 to fit the super-network into a single GTX 1080Ti GPU with 11GB memory, i.e., only 1/6 features are sampled on each edge. For the second stage, we prune half candidates and meanwhile widen the network twice, i.e., the operation space size reduces from 8 to 4 and $K$ becomes 3.
Retrain Settings The evaluation phase uses the entire 50K training set to train the network from scratch for 600 epochs. The network weight is optimized by an SGD optimizer with a cosine annealing learning rate initialized as 0.025, a momentum of 0.9, and a weight decay of $3 \times 1 0 ^ { - 4 }$ . To allow a fair comparison with previous work, we also employ cutout regularization with length 16, drop-path (Zoph et al., 2018) with probability 0.3 and an auxiliary tower of weight 0.4.
Table 2: Comparison with state-of-the-art image classifiers on CIFAR-10.
<table><tr><td>Architecture</td><td>Test Error (%)</td><td>Params (M)</td><td>Search Cost (GPU days)</td><td>Search Method</td></tr><tr><td>DenseNet-BC (Huang et al.,2017)*</td><td>3.46</td><td>25.6</td><td>1</td><td>manual</td></tr><tr><td>NASNet-A (Zoph et al.,2018)</td><td>2.65</td><td>3.3</td><td>2000</td><td>RL</td></tr><tr><td>AmoebaNet-A (Real etal.,2019)</td><td>3.34±0.06</td><td>3.2</td><td>3150</td><td>evolution</td></tr><tr><td>AmoebaNet-B (Real etal.,2019)</td><td>2.55 ± 0.05</td><td>2.8</td><td>3150</td><td>evolution</td></tr><tr><td>PNAS (Liu et al.,2018)*</td><td>3.41±0.09</td><td>3.2</td><td>225</td><td>SMBO</td></tr><tr><td>ENAS (Pham et al.,2018)</td><td>2.89</td><td>4.6</td><td>0.5</td><td>RL</td></tr><tr><td>DARTS (1st) (Liu et al.,2019)</td><td>3.00±0.14</td><td>3.3</td><td>0.4</td><td>gradient</td></tr><tr><td>DARTS (2nd) (Liu et al.,2019)</td><td>2.76 ±0.09</td><td>3.3</td><td>1.0</td><td>gradient</td></tr><tr><td>SNAS (moderate) (Xie et al.,2019)</td><td>2.85 ±0.02</td><td>2.8</td><td>1.5</td><td>gradient</td></tr><tr><td>GDAS(Dong & Yang,2019)</td><td>2.93</td><td>3.4</td><td>0.3</td><td>gradient</td></tr><tr><td>BayesNAS (Zhou et al.,2019)</td><td>2.81 ± 0.04</td><td>3.4</td><td>0.2</td><td>gradient</td></tr><tr><td>ProxylessNAS (Cai et al., 2019)†</td><td>2.08</td><td>5.7</td><td>4.0</td><td>gradient</td></tr><tr><td>PARSEC (Casale et al.,2019)</td><td>2.81 ± 0.03</td><td>3.7</td><td>1</td><td>gradient</td></tr><tr><td>P-DARTS (Chen et al.,2019)</td><td>2.50</td><td>3.4</td><td>0.3</td><td>gradient</td></tr><tr><td>PC-DARTS (Xu et al., 2020)</td><td>2.57 ±0.07</td><td>3.6</td><td>0.1</td><td>gradient</td></tr><tr><td>SDARTS-ADV (Chen & Hsieh,2020)</td><td>2.61 ±0.02</td><td>3.3</td><td>1.3</td><td>gradient</td></tr><tr><td>GAEA+PC-DARTS (Li et al.,2020)</td><td>2.50± 0.06</td><td>3.7</td><td>0.1</td><td>gradient</td></tr><tr><td>DrNAS (without progressive learning)</td><td>2.54± 0.03</td><td>4.0</td><td>0.4</td><td>gradient</td></tr><tr><td>DrNAS</td><td>2.46 ±0.03</td><td>4.1</td><td>0.6</td><td>gradient</td></tr></table>
? Obtained without cutout augmentation. † Obtained on a different space with PyramidNet (Han et al., 2017) as the backbone. ‡ Recorded on a single GTX 1080Ti GPU.
Results Table 2 summarizes the performance of DrNAS compared with other popular NAS methods, and we also visualize the searched cells in Appendix A.2. DrNAS achieves an average test error of $2 . 4 6 \%$ , ranking top amongst recent NAS results. ProxylessNAS is the only method that achieves lower test error than us, but it searches on a different space with a much longer search time and has larger model size. We also perform experiments to assign proper credit to the two parts of our proposed algorithm, i.e., Dirichlet architecture distribution and progressive learning scheme. When searching on a proxy task with 8 stacked cells and 16 initial channels as the convention (Liu et al., 2019; Xu et al., 2020), we achieve a test error of $2 . 5 4 \%$ that surpasses most baselines. Our progressive learning algorithm eliminates the gap between the proxy and target tasks, which further reduces the test error. Consequently, both of the two parts contribute a lot to our performance gains.
# 4.2 RESULTS ON IMAGENET
Architecture Space The network architecture for ImageNet is slightly different from that for CIFAR-10 in that we stack 14 cells and set the initial channel number as 48. We also first downscale the spatial resolution from $2 2 4 \times 2 2 4$ to $2 8 \times 2 8$ with three convolution layers of stride 2 following previous works (Xu et al., 2020; Chen et al., 2019). The other settings are the same with section 4.1.
Search Settings Following PC-DARTS (Xu et al., 2020), we randomly sample $10 \%$ and $2 . 5 \%$ images from the 1.3M training set to alternatively learn network weight and Dirichlet architecture distribution by a momentum SGD and an Adam optimizer respectively. We use 8 RTX 2080 Ti GPUs for both search and evaluation, and the setup of progressive pruning is the same with that on CIFAR-10, i.e., 2 stages with operation space size shrinking from 8 to 4, and the partial channel $K$ reduces from 6 to 3.
Retrain Settings For architecture evaluation, we train the network for 250 epochs by an SGD optimizer with a momentum of 0.9, a weight decay of $3 \times 1 0 ^ { - 5 }$ , and a linearly decayed learning rate initialized as 0.5. We also use label smoothing and an auxiliary tower of weight 0.4 during training. The learning rate warm-up is employed for the first 5 epochs following previous works (Chen et al., 2019; Xu et al., 2020).
Table 3: Comparison with state-of-the-art image classifiers on ImageNet in the mobile setting.
<table><tr><td rowspan="2">Architecture</td><td colspan="2">Test Error(%)</td><td rowspan="2">Params (M)</td><td rowspan="2">Search Cost (GPU days)</td><td rowspan="2">Search Method</td></tr><tr><td>top-1</td><td>top-5</td></tr><tr><td>Inception-vl (Szegedy et al., 2015)</td><td>30.1</td><td>10.1</td><td>6.6</td><td></td><td>manual</td></tr><tr><td>MobileNet (Howard et al.,2017)</td><td>29.4</td><td>10.5</td><td>4.2</td><td></td><td>manual</td></tr><tr><td>ShuffleNet 2× (v1) (Zhang et al.,2018)</td><td>26.4</td><td>10.2</td><td>~5</td><td></td><td>manual</td></tr><tr><td>ShuffleNet 2× (v2) (Ma et al.,2018)</td><td>25.1</td><td>-</td><td>~5</td><td>=</td><td>manual</td></tr><tr><td>NASNet-A (Zoph et al.,2018)</td><td>26.0</td><td>8.4</td><td>5.3</td><td>2000</td><td>RL</td></tr><tr><td>AmoebaNet-C (Real etal.,2019)</td><td>24.3</td><td>7.6</td><td>6.4</td><td>3150</td><td>evolution</td></tr><tr><td>PNAS (Liu et al., 2018)</td><td>25.8</td><td>8.1</td><td>5.1</td><td>225</td><td>SMBO</td></tr><tr><td>MnasNet-92 (Tan etal.,2019)</td><td>25.2</td><td>8.0</td><td>4.4</td><td>1</td><td>RL</td></tr><tr><td>DARTS (2nd) (Liu et al.,2019)</td><td>26.7</td><td>8.7</td><td>4.7</td><td>1.0</td><td>gradient</td></tr><tr><td>SNAS (mild) (Xie et al.,2019)</td><td>27.3</td><td>9.2</td><td>4.3</td><td>1.5</td><td>gradient</td></tr><tr><td>GDAS (Dong & Yang,2019)</td><td>26.0</td><td>8.5</td><td>5.3</td><td>0.3</td><td>gradient</td></tr><tr><td>BayesNAS (Zhou et al.,2019)</td><td>26.5</td><td>8.9</td><td>3.9</td><td>0.2</td><td>gradient</td></tr><tr><td>DSNAS (Hu et al., 2020)†</td><td>25.7</td><td>8.1</td><td>1</td><td>1</td><td>gradient</td></tr><tr><td>ProxylessNAS (GPU) (Cai et al.,2019)†</td><td>24.9</td><td>7.5</td><td>7.1</td><td>8.3</td><td>gradient</td></tr><tr><td>PARSEC (Casale et al.,2019)</td><td>26.0</td><td>8.4</td><td>5.6</td><td>1</td><td>gradient</td></tr><tr><td>P-DARTS (CIFAR-1O) (Chen et al., 2019)</td><td>24.4</td><td>7.4</td><td>4.9</td><td>0.3</td><td>gradient</td></tr><tr><td>P-DARTS (CIFAR-10O) (Chen et al.,2019)</td><td>24.7</td><td>7.5</td><td>5.1</td><td>0.3</td><td>gradient</td></tr><tr><td>PC-DARTS (CIFAR-10) (Xu et al., 2020)</td><td>25.1</td><td>7.8</td><td>5.3</td><td>0.1</td><td>gradient</td></tr><tr><td>PC-DARTS (ImageNet) (Xu et al., 2020)+</td><td>24.2</td><td>7.3</td><td>5.3</td><td>3.8</td><td>gradient</td></tr><tr><td>GAEA + PC-DARTS (Li et al., 2020)+</td><td>24.0</td><td>7.3</td><td>5.6</td><td>3.8</td><td>gradient</td></tr><tr><td>DrNAS (without progressive learning)†</td><td>24.2</td><td>7.3</td><td>5.2</td><td>3.9</td><td>gradient</td></tr><tr><td>DrNASt</td><td>23.7</td><td>7.1</td><td>5.7</td><td>4.6</td><td>gradient</td></tr></table>
† The architecture is searched on ImageNet, otherwise it is searched on CIFAR-10 or CIFAR-100.
Results As shown in Table 3, we achieve a top-1/5 test error of $2 3 . 7 \% / 7 . 1 \%$ , outperforming all compared baselines and achieving state-of-the-art performance in the ImageNet mobile setting. The searched cells are visualized in Appendix A.2. Similar to section 4.1, we also report the result achieved with 8 cells and 16 initial channels, which is a common setup for the proxy task on ImageNet (Xu et al., 2020). The obtained $2 4 . 2 \%$ top-1 accuracy is already highly competitive, which demonstrates the effectiveness of the architecture distribution learning on large-scale tasks. Then our progressive learning scheme further increases the top-1/5 accuracy for $0 . 5 \% / 0 . 2 \%$ . Therefore, learning in a task-specific manner is essential to discover better architectures.
# 4.3 RESULTS ON NAS-BENCH-201
Recently, some researchers doubt that the expert knowledge applied to the evaluation protocol plays an important role in the impressive results achieved by leading NAS methods (Yang et al., 2020; Li & Talwalkar, 2019). So to further verify the effectiveness of DrNAS, we perform experiments on NAS-Bench-201 (Dong & Yang, 2020), where architecture performance can be directly obtained by querying in the database. NAS-Bench-201 provides support for 3 dataset (CIFAR-10, CIFAR-100, ImageNet-16-120 (Chrabaszcz et al., 2017)) and has a unified cell-based search space containing 15,625 architectures. We refer to their paper (Dong & Yang, 2020) for details of the space. Our experiments are performed in a task-specific manner, i.e., the search and evaluation are based on the same dataset. The hyperparameters for all compared methods are set as their default and for DrNAS, we use the same search settings with section 4.1. We run every method 4 independent times with different random seeds and report the mean and standard deviation in Table 4.
As shown, we achieve the best accuracy on all 3 datasets. On CIFAR-100, we even achieve the global optimal. Specifically, DrNAS outperforms DARTS, GDAS, DSNAS, PC-DARTS, and SNAS by $1 0 3 . 8 \%$ , $3 5 . 9 \%$ , $3 0 . 4 \%$ , $6 . 4 \%$ , and $4 . 3 \%$ on average. We notice that the two methods (GDAS and DSNAS) that enforce a discrete constraint, i.e., only sample a single path every search iteration, perform undesirable especially on CIFAR-100. In comparison, SNAS, employing a similar Gumbelsoftmax trick but without the discretization, performs much better. Consequently, a discrete constraint during search can reduce the GPU memory consumption but empirically suffers instability. In comparison, we develop the progressive learning scheme on top of the architecture distribution learning, enjoying both memory efficiency and strong search performance.
Table 4: Comparison with state-of-the-art NAS methods on NAS-Bench-201.
<table><tr><td rowspan="2">Method</td><td colspan="2">CIFAR-10</td><td colspan="2">CIFAR-100</td><td colspan="2">ImageNet-16-120</td></tr><tr><td>validation</td><td>test</td><td>validation</td><td>test</td><td>validation</td><td>test</td></tr><tr><td>ResNet (He et al.,2016)</td><td>90.83</td><td>93.97</td><td>70.42</td><td>70.86</td><td>44.53</td><td>43.63</td></tr><tr><td>Random (baseline)</td><td>90.93±0.36</td><td>93.70±0.36</td><td>70.60±1.37</td><td>70.65 ± 1.38</td><td>42.92 ± 2.00</td><td>42.96±2.15</td></tr><tr><td>RSPS (Li& Talwalkar,2019)</td><td>84.16 ± 1.69</td><td>87.66 ± 1.69</td><td>45.78 ± 6.33</td><td>46.60 ± 6.57</td><td>31.09 ± 5.65</td><td>30.78 ±6.12</td></tr><tr><td>Reinforce (Zoph et al., 2018)</td><td>91.09 ± 0.37</td><td>93.85± 0.37</td><td>70.05 ± 1.67</td><td>70.17 ± 1.61</td><td>43.04 ± 2.18</td><td>43.16 ± 2.28</td></tr><tr><td>ENAS (Pham etal.,2018)</td><td>39.77±0.00</td><td>54.30±0.00</td><td>10.23±0.12</td><td>10.62 ± 0.27</td><td>16.43±0.00</td><td>16.32±0.00</td></tr><tr><td>DARTS(1st) (Liu et al.,2019)</td><td>39.77 ±0.00</td><td>54.30±0.00</td><td>38.57 ±0.00</td><td>38.97 ± 0.00</td><td>18.87 ± 0.00</td><td>18.41 ± 0.00</td></tr><tr><td>DARTS (2nd) (Liu et al., 2019)</td><td>39.77±0.00</td><td>54.30 ±0.00</td><td>38.57±0.00</td><td>38.97 ±0.00</td><td>18.87 ± 0.00</td><td>18.41 ± 0.00</td></tr><tr><td>GDAS (Dong & Yang,2019)</td><td>90.01±0.46</td><td>93.23±0.23</td><td>24.05 ±8.12</td><td>24.20 ±8.08</td><td>40.66 ±0.00</td><td>41.02 ± 0.00</td></tr><tr><td>SNAS (Xie et al.,2019)</td><td>90.10 ± 1.04</td><td>92.77±0.83</td><td>69.69±2.39</td><td>69.34 ± 1.98</td><td>42.84 ± 1.79</td><td>43.16 ± 2.64</td></tr><tr><td>DSNAS (Hu et al.,2020)</td><td>89.66±0.29</td><td>93.08 ± 0.13</td><td>30.87±16.40</td><td>31.01 ± 16.38</td><td>40.61 ±0.09</td><td>41.07 ± 0.09</td></tr><tr><td>PC-DARTS(Xu et al.,2020)</td><td>89.96± 0.15</td><td>93.41 ± 0.30</td><td>67.12 ± 0.39</td><td>67.48± 0.89</td><td>40.83±0.08</td><td>41.31 ± 0.22</td></tr><tr><td>DrNAS</td><td>91.55 ± 0.00</td><td>94.36±0.00</td><td>73.49 ± 0.00</td><td>73.51 ± 0.00</td><td>46.37±0.00</td><td>46.34±0.00</td></tr><tr><td>optimal</td><td>91.61</td><td>94.37</td><td>73.49</td><td>73.51</td><td>46.77</td><td>47.31</td></tr></table>
# 4.4 EMPIRICAL STUDY ON EXPLORATION V.S. EXPLOITATION
We further conduct an empirical study on the dynamics of exploration and exploitation in the search phase of DrNAS on NAS-Bench-201. After every search epoch, We sample $1 0 0 \theta \mathrm { s }$ from the learned Dirichlet distribution and take the arg max to obtain 100 discrete architectures. We then plot the range of their accuracy along with the architecture selected by Dirichlet mean (solid line in Figure 1). Note that in our algorithm, we simply derive the architecture according to the Dirichlet mean as described in Section 2.2. As shown in Figure 1, the accuracy range of the sampled architectures starts very wide but narrows gradually during the search phase. It indicates that DrNAS learns to encourage exploration in the search space at the early stages and then gradually reduces it towards the end as the algorithm becomes more and more confident of the current choice. Moreover, the performance of our architectures can consistently match the best performance of the sampled architectures, indicating the effectiveness of DrNAS.
 Figure 1: Accuracy range (min-max) of the 100 sampled architectures. Note that the solid line is our derived architecture according to the Dirichlet mean as described in Section 2.2.
# 5 CONCLUSION
In this paper, we propose Dirichlet Neural Architecture Search (DrNAS). We formulate the differentiable NAS as a constraint distribution learning problem, which explicitly models the stochasticity in the architecture mixing weight and balances exploration and exploitation in the search space. The proposed method can be optimized efficiently via gradient-based algorithm, and possesses theoretical benefit to improve the generalization ability. Furthermore, we propose a progressive learning scheme to eliminate the search and evaluation gap. DrNAS consistently achieves strong performance across several image classification tasks, which reveals its potential to play a crucial role in future end-to-end deep learning platform.
# ACKNOWLEDGEMENT
This work is supported in part by NSF under IIS-1901527, IIS-2008173, IIS-2048280 and by Army Research Laboratory under agreement number W911NF-20-2-0158.
# REFERENCES
Charles Sutton Akash Srivastava. Autoencoding variational inference for topic models. In International Conference on Learning Representations, 2017. URL https://arxiv.org/abs/ 1703.01488.
Gabriel Bender, Pieter-Jan Kindermans, Barret Zoph, Vijay Vasudevan, and Quoc Le. Understanding and simplifying one-shot architecture search. In Jennifer Dy and Andreas Krause (eds.), Proceedings of the 35th International Conference on Machine Learning, volume 80 of Proceedings of Machine Learning Research, pp. 550–559, Stockholmsmassan, Stockholm Sweden, 10–15 Jul ¨ 2018. PMLR. URL http://proceedings.mlr.press/v80/bender18a.html.
Christopher Bishop. Pattern Recognition and Machine Learning. Springer New York, 2016.
Yoshua Bengio Caglar Gulcehre, Sarath Chandar. Memory augmented neural networks with wormhole connections, 2017.
Han Cai, Tianyao Chen, Weinan Zhang, Yong Yu, and Jun Wang. Efficient architecture search by network transformation. In AAAI, 2018.
Han Cai, Ligeng Zhu, and Song Han. ProxylessNAS: Direct neural architecture search on target task and hardware. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ HylVB3AqYm.
Francesco Paolo Casale, Jonathan Gordon, and Nicolo Fusi. Probabilistic neural architecture search, 2019.
Tianqi Chen, Ian Goodfellow, and Jonathon Shlens. Net2net: Accelerating learning via knowledge transfer. In International Conference on Learning Representations, 2016. URL http://arxiv. org/abs/1511.05641.
Xiangning Chen and Cho-Jui Hsieh. Stabilizing differentiable architecture search via perturbationbased regularization. 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. 1554–1565. PMLR, 13–18 Jul 2020. URL http://proceedings.mlr.press/v119/ chen20f.html.
Xin Chen, Lingxi Xie, Jun Wu, and Qi Tian. Progressive differentiable architecture search: Bridging the depth gap between search and evaluation. In Proceedings of the IEEE International Conference on Computer Vision, pp. 1294–1303, 2019.
Patryk Chrabaszcz, Ilya Loshchilov, and Frank Hutter. A downsampled variant of imagenet as an alternative to the cifar datasets, 2017.
Jon D. McAuliffe David M. Blei, Alp Kucukelbir. Variational inference: A review for statisticians, 2016.
Michael I. Jordan David M. Blei, Andrew Y. Ng. Latent dirichlet allocation. The Journal of Machine Learning Research, Mar 2003. ISSN 1532-4435. doi: 10.1162/jmlr.2003.3.4-5.993. URL http://dx.doi.org/10.1109/CVPR.2017.243.
Xuanyi Dong and Yi Yang. Searching for a robust neural architecture in four gpu hours. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 1761–1770, 2019.
Xuanyi Dong and Yi Yang. Nas-bench-201: Extending the scope of reproducible neural architecture search. In International Conference on Learning Representations (ICLR), 2020. URL https: //openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ HJxyZkBKDr.
Andrew Gelman, John B. Carlin, Hal S. Stern, and Donald B. Rubin. Bayesian Data Analysis. Chapman and Hall/CRC, 2nd ed. edition, 2004.
Dongyoon Han, Jiwhan Kim, and Junmo Kim. Deep pyramidal residual networks. 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Jul 2017. doi: 10.1109/cvpr. 2017.668. URL http://dx.doi.org/10.1109/CVPR.2017.668.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. pp. 770–778, 06 2016. doi: 10.1109/CVPR.2016.90.
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, 2017.
Shoukang Hu, Sirui Xie, Hehui Zheng, Chunxiao Liu, Jianping Shi, Xunying Liu, and Dahua Lin. Dsnas: Direct neural architecture search without parameter retraining, 2020.
Gao Huang, Zhuang Liu, Laurens van der Maaten, and Kilian Q. Weinberger. Densely connected convolutional networks. 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Jul 2017. doi: 10.1109/cvpr.2017.243. URL http://dx.doi.org/10.1109/ CVPR.2017.243.
Weonyoung Joo, Wonsung Lee, Sungrae Park, , and Il-Chul Moon. Dirichlet variational autoencoder, 2019. URL https://openreview.net/forum?id ${ . } = { }$ rkgsvoA9K7.
Samuel Kessler, Vu Nguyen, Stefan Zohren, and Stephen Roberts. Hierarchical indian buffet neural networks for bayesian continual learning, 2019.
Soochan Lee, Junsoo Ha, Dongsu Zhang, and Gunhee Kim. A neural dirichlet process mixture model for task-free continual learning,” in international conference on learning representations. In ICLR, 2020.
Liam Li and Ameet Talwalkar. Random search and reproducibility for neural architecture search, 2019.
Liam Li, Mikhail Khodak, Maria-Florina Balcan, and Ameet Talwalkar. Geometry-aware gradient algorithms for neural architecture search, 2020.
Chenxi Liu, Barret Zoph, Maxim Neumann, Jonathon Shlens, Wei Hua, Li-Jia Li, Li Fei-Fei, Alan Yuille, Jonathan Huang, and Kevin Murphy. Progressive neural architecture search. Lecture Notes in Computer Science, pp. 19–35, 2018. ISSN 1611-3349. doi: 10.1007/978-3-030-01246-5 2. URL http://dx.doi.org/10.1007/978-3-030-01246-5_2.
Hanxiao Liu, Karen Simonyan, and Yiming Yang. DARTS: Differentiable architecture search. In International Conference on Learning Representations, 2019. URL https://openreview. net/forum?id ${ . } = { }$ S1eYHoC5FX.
Ningning Ma, Xiangyu Zhang, Hai-Tao Zheng, and Jian Sun. Shufflenet v2: Practical guidelines for efficient cnn architecture design. In The European Conference on Computer Vision (ECCV), September 2018.
David J. C. MacKay. Choice of basis for laplace approximation. Machine Language, October 1998. doi: 10.1023/A:1007558615313. URL https://link.springer.com/article/ 10.1023/A:1007558615313.
Fritz Obermeyer Martin Jankowiak. Pathwise derivatives beyond the reparameterization trick. In International Conference on Machine Learning, 2018. URL https://arxiv.org/abs/ 1806.01851.
Jieru Mei, Yingwei Li, Xiaochen Lian, Xiaojie Jin, Linjie Yang, Alan Yuille, and Jianchao Yang. Atomnas: Fine-grained end-to-end neural architecture search. In International Conference on Learning Representations, 2020. URL https://openreview.net/forum?id= BylQSxHFwr.
Hieu Pham, Melody Guan, Barret Zoph, Quoc Le, and Jeff Dean. Efficient neural architecture search via parameters sharing. In Jennifer Dy and Andreas Krause (eds.), Proceedings of the 35th International Conference on Machine Learning, volume 80 of Proceedings of Machine Learning Research, pp. 4095–4104, Stockholmsmassan, Stockholm Sweden, 10–15 Jul 2018. PMLR. URL ¨ http://proceedings.mlr.press/v80/pham18a.html.
Esteban Real, Alok Aggarwal, Yanping Huang, and Quoc V. Le. Regularized evolution for image classifier architecture search. Proceedings of the AAAI Conference on Artificial Intelligence, 33:4780–4789, Jul 2019. ISSN 2159-5399. doi: 10.1609/aaai.v33i01.33014780. URL http: //dx.doi.org/10.1609/aaai.v33i01.33014780.
Yao Shu, Wei Wang, and Shaofeng Cai. Understanding architectures learnt by cell-based neural architecture search. In International Conference on Learning Representations, 2020. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ BJxH22EKPS.
Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. In Computer Vision and Pattern Recognition (CVPR), 2015. URL http://arxiv.org/abs/1409.4842.
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 The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2019.
Ruochen Wang, Minhao Cheng, Xiangning Chen, Xiaocheng Tang, and Cho-Jui Hsieh. Rethinking architecture selection in differentiable NAS. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id $=$ PKubaeJkw3.
Sirui Xie, Hehui Zheng, Chunxiao Liu, and Liang Lin. SNAS: stochastic neural architecture search. In International Conference on Learning Representations, 2019. URL https://openreview. net/forum?id $=$ rylqooRqK7.
Yuhui Xu, Lingxi Xie, Xiaopeng Zhang, Xin Chen, Guo-Jun Qi, Qi Tian, and Hongkai Xiong. PC-DARTS: Partial channel connections for memory-efficient architecture search. In International Conference on Learning Representations, 2020. URL https://openreview.net/forum? id $=$ BJlS634tPr.
Shiyang Yan, Jeremy S. Smith, Wenjin Lu, and Bailing Zhang. Hierarchical multi-scale attention networks for action recognition, 2017.
Antoine Yang, Pedro M. Esperanc¸a, and Fabio M. Carlucci. Nas evaluation is frustratingly hard. In International Conference on Learning Representations, 2020. URL https://openreview. net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } = \underline { { \underline { { \mathbf { \delta \pi } } } } } .$ HygrdpVKvr.
Quanming Yao, Xiangning Chen, James T. Kwok, Yong Li, and Cho-Jui Hsieh. Efficient neural interaction function search for collaborative filtering. In Proceedings of The Web Conference 2020, WWW ’20, pp. 1660–1670, New York, NY, USA, 2020a. Association for Computing Machinery. ISBN 9781450370233. doi: 10.1145/3366423.3380237. URL https://doi.org/10.1145/ 3366423.3380237.
Quanming Yao, Ju Xu, Wei-Wei Tu, and Zhanxing Zhu. Efficient neural architecture search via proximal iterations. Proceedings of the AAAI Conference on Artificial Intelligence, 34(04):6664– 6671, Apr. 2020b. doi: 10.1609/aaai.v34i04.6143. URL https://ojs.aaai.org/index. php/AAAI/article/view/6143.
Arber Zela, Thomas Elsken, Tonmoy Saikia, Yassine Marrakchi, Thomas Brox, and Frank Hutter. Understanding and robustifying differentiable architecture search. In International Conference on Learning Representations, 2020a. URL https://openreview.net/forum?id $=$ H1gDNyrKDS.
Arber Zela, Julien Siems, and Frank Hutter. NAS-BENCH-1SHOT1: Benchmarking and dissecting one-shot neural architecture search. In International Conference on Learning Representations, 2020b. URL https://openreview.net/forum?id $=$ SJx9ngStPH.
M. Zhang, H. Li, S. Pan, X. Chang, and S. Su. Overcoming multi-model forgetting in one-shot nas with diversity maximization. In 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 7806–7815, 2020.
Xiangyu Zhang, Xinyu Zhou, Mengxiao Lin, and Jian Sun. Shufflenet: An extremely efficient convolutional neural network for mobile devices. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2018.
Hongpeng Zhou, Minghao Yang, Jun Wang, and Wei Pan. Bayesnas: A bayesian approach for neural architecture search. In ICML, pp. 7603–7613, 2019. URL http://proceedings. mlr.press/v97/zhou19e.html.
Barret Zoph and Quoc V. Le. Neural architecture search with reinforcement learning. 2017. URL https://arxiv.org/abs/1611.01578.
Barret Zoph, Vijay Vasudevan, Jonathon Shlens, and Quoc V. Le. Learning transferable architectures for scalable image recognition. 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, Jun 2018. doi: 10.1109/cvpr.2018.00907. URL http://dx.doi.org/10. 1109/CVPR.2018.00907.
# A APPENDIX
# A.1 PROOF OF PROPOSITION 1
Preliminaries: Before the development of Pathwise Derivative Estimator, Laplace Approximate with Softmax basis has been extensively used to approximate the Dirichlet Distribution (MacKay, 1998; Akash Srivastava, 2017). The approximated Dirichlet distribution is:
$$p ( \theta ( \mathbf { h } ) | \beta ) = \frac { \Gamma ( \sum _ { o } \beta _ { o } ) } { \prod _ { o } \Gamma ( \beta _ { o } ) } \prod _ { o } \theta _ { o } ^ { \beta _ { o } } g ( \mathbf { 1 } ^ { T } \mathbf { h } )$$
Where $\theta ( \mathbf { h } )$ is the softmax-transformed $\mathbf { h }$ , h follows multivariate normal distribution, and $g ( \cdot )$ is an arbitrary density to ensure integrability (Akash Srivastava, 2017). The mean $\mu$ and diagonal covariance matrix $\Sigma$ of $\mathbf { h }$ depends on the Dirichlet concentration parameter $\beta$ :
$$\mu _ { o } = \log \beta _ { o } - \frac { 1 } { | \mathcal O | } \sum _ { o ^ { \prime } } \log \beta _ { o ^ { \prime } } \qquad \Sigma _ { o } = \frac { 1 } { \beta _ { o } } ( 1 - \frac { 2 } { | \mathcal O | } ) + \frac { 1 } { | \mathcal O | ^ { 2 } } \sum _ { o ^ { \prime } } \frac { 1 } { \beta _ { o ^ { \prime } } }$$
It can be directly obtained from (10) that the Dirichlet mean $\begin{array} { r } { \frac { \beta _ { o } } { \sum _ { o ^ { \prime } } \beta _ { o ^ { \prime } } } = S o f t m a x ( \mu ) } \end{array}$ . Sampling from the approximated distribution can be down by first sampling from $\mathbf { h }$ and then applying Softmax function to obtain $\theta$ . We will leverage the fact that this approximation supports explicit reparameterization to derive our proof.
Proof: Apply the above Laplace Approximation to Dirichlet distribution, the unconstrained upperlevel objective in (5) can then be written as:
$$\begin{array} { r l } & { \quad E _ { \theta \sim D i r ( \beta ) } \big [ \mathcal { L } _ { v a l } ( w ^ { * } , \theta ) \big ] } \\ & { \approx E _ { \epsilon \sim \mathcal { N } ( 0 , \Sigma ) } \big [ \mathcal { L } _ { v a l } ( w ^ { * } , S o f t m a x ( \mu + \epsilon ) ) \big ] } \\ & { \equiv E _ { \epsilon \sim \mathcal { N } ( 0 , \Sigma ) } \big [ \tilde { \mathcal { L } } _ { v a l } ( w ^ { * } , \mu + \epsilon ) \big ] } \\ & { \approx E _ { \epsilon \sim \mathcal { N } ( 0 , \Sigma ) } \big [ \tilde { \mathcal { L } } _ { v a l } ( w ^ { * } , \mu ) + \epsilon ^ { T } \nabla _ { \mu } \tilde { \mathcal { L } } _ { v a l } ( w ^ { * } , \mu ) + \frac { 1 } { 2 } \epsilon ^ { T } \nabla _ { \mu } ^ { 2 } \tilde { \mathcal { L } } _ { v a l } ( w ^ { * } , \mu ) \epsilon \big ] } \\ & { = \tilde { \mathcal { L } } _ { v a l } ( w ^ { * } , \mu ) + \frac { 1 } { 2 } t r \big ( E _ { \epsilon \sim \mathcal { N } ( 0 , \Sigma ) } \big [ \epsilon \epsilon ^ { T } \big ] \nabla _ { \mu } ^ { 2 } \tilde { \mathcal { L } } _ { v a l } ( w ^ { * } , \mu ) \big ) } \\ & { = \tilde { \mathcal { L } } _ { v a l } ( w ^ { * } , \mu ) + \frac { 1 } { 2 } t r \big ( \Sigma \nabla _ { \mu } ^ { 2 } \tilde { \mathcal { L } } _ { v a l } ( w ^ { * } , \mu ) \big ) } \end{array}$$
In our full objective, we constrain the Euclidean distance between learnt Dirichlet concentration and fixed prior concentration $| | { \boldsymbol { \beta } } - \mathbf { 1 } | | _ { 2 } \leq \delta$ . The covariance matrix $\Sigma$ of approximated softmax Gaussian can be bounded as:
$$\begin{array} { r } { \Sigma _ { o } = \displaystyle \frac { 1 } { \beta _ { o } } ( 1 - \frac { 2 } { | \mathcal { O } | } ) + \frac { 1 } { | \mathcal { O } | ^ { 2 } } \sum _ { o ^ { ' } } \frac { 1 } { \beta _ { o ^ { ' } } } } \\ { \geq \displaystyle \frac { 1 } { 1 + \delta } ( 1 - \frac { 2 } { | \mathcal { O } | } ) + \frac { 1 } { | \mathcal { O } | } \frac { 1 } { 1 + \delta } } \end{array}$$
Then (11) becomes:
$$\begin{array} { r l } & { \quad E _ { \theta \sim D i r ( \beta ) } \bigl [ \mathcal { L } _ { v a l } ( w ^ { * } , \theta ) \bigr ] } \\ & { \approx \tilde { \mathcal { L } } _ { v a l } ( w ^ { * } , \mu ) + \cfrac { 1 } { 2 } t r \bigl ( \Sigma \nabla _ { \mu } ^ { 2 } \tilde { \mathcal { L } } _ { v a l } ( w ^ { * } , \mu ) \bigr ) } \\ & { \geq \tilde { \mathcal { L } } _ { v a l } ( w ^ { * } , \mu ) + \cfrac { 1 } { 2 } ( \cfrac { 1 } { 1 + \delta } ( 1 - \cfrac { 2 } { | \mathcal { O } | } ) + \cfrac { 1 } { | \mathcal { O } | } \cfrac { 1 } { 1 + \delta } ) t r \bigl ( \nabla _ { \mu } ^ { 2 } \tilde { \mathcal { L } } _ { v a l } ( w ^ { * } , \mu ) \bigr ) } \end{array}$$
The last line holds when $\nabla _ { \mu } ^ { 2 } \tilde { \mathcal { L } } _ { v a l } ( w ^ { * } , \mu )$ is positive semi-definite. In Appendix A.4 we provide an empirical justification for this implicit regularization effect of DrNAS.
# A.2 SEARCHED ARCHITECTURES
We visualize the searched normal and reduction cells in Figure 2 and 3, which is directly searched on CIFAR-10 and ImageNet respectively.
 Figure 2: Normal and Reduction cells discovered by DrNAS on CIFAR-10.
 Figure 3: Normal and Reduction cells discovered by DrNAS on ImageNet.
A.3 ABLATION STUDY ON ANCHOR REGULARIZER PARAMETER λ
Table 5 shows the accuracy of the searched architecture using different value of $\lambda$ while keeping all other settings the same. Using anchor regularizer? for a wide range of value can boost the accuracy and DrNAS performs quite stable under different λs.
Table 5: Test accuracy of the searched architecture with different $\lambda s$ on NAS-Bench-201 (CIFAR-10). $\lambda = 1 e ^ { - 3 }$ is what we used for all of our experiments.
<table><tr><td rowspan=1 colspan=1>入</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>5e-4</td><td rowspan=1 colspan=1>1e-3</td><td rowspan=1 colspan=1>5e-3</td><td rowspan=1 colspan=1>1e-2</td><td rowspan=1 colspan=1>1e-1</td><td rowspan=1 colspan=1>1</td></tr><tr><td rowspan=1 colspan=1>Accuracy</td><td rowspan=1 colspan=1>93.78</td><td rowspan=1 colspan=1>94.01</td><td rowspan=1 colspan=1>94.36</td><td rowspan=1 colspan=1>94.36</td><td rowspan=1 colspan=1>94.36</td><td rowspan=1 colspan=1>93.76</td><td rowspan=1 colspan=1>93.76</td></tr></table>
# A.4 EMPIRICAL STUDY ON THE HESSIAN REGULARIZATION EFFECT
We track the anytime Hessian norm on NAS-Bench-201 in Figure 4. The result is obtained by averaging from 4 independent runs. We observe that the largest eigenvalue expands about 10 times when searching by DARTS for 100 epochs. In comparison, DrNAS always maintains the Hessian norm at a low level, which is in agreement with our theoretical analysis in section 2.3. Figure 5 shows the regularization effect under various λs. As we can see, DrNAS can keep hessian norm at a low level for a wide range of $\lambda s$ , which is in accordance to the relatively stable performance in Table 5.
Moreover, we compare DrNAS with DARTS and R-DARTS on 4 simplified space proposed in (Zela et al., 2020a) and record the endpoint dominant eigenvalue. The first space S1 contains 2 popular operators per edge based on DARTS search result. For S2, S3, and S4, the operation sets are $\{ 3 \times 3$ separable convolution, skip connection $\}$ , $\{ 3 \times 3$ separable convolution, skip connection, $z e r o \}$ , and $\{ 3 \times 3$ separable convolution, noise $\}$ respectively. As shown in Table 6, DrNAS consistently outperforms DARTS and R-DARTS. The endpoint eigenvalues for DrNAS are 0.0392, 0.0390, 0.0286, 0.0389 respectively. Figure 5 shows the Hessian norm trajectory under various $\lambda$ .
# A.5 CONNECTION TO VARIATIONAL INFERENCE
In this section, we draw a connection between DrNAS and Variational Inference (David M. Blei, 2016). We use $w , \theta .$ , and $\beta$ to denote the model weight, operation mixing weight, and Dirichlet concentration parameters respectively, following the main text. The true posterior distribution can
 Figure 4: Trajectory of the Hessian norm on NAS-Bench-201 when searching with CIFAR-10 (best viewed in color).
 Figure 5: Trajectory of the Hessian norm under various $\lambda s$ on NAS-Bench-201 when searching with CIFAR-10 (best viewed in color).
be written as $p ( \theta | w , D )$ , where $D = \{ x _ { n } , y _ { n } \} _ { n = 1 } ^ { N }$ is the dataset. Let $q ( \theta | \beta )$ denote the variational approximation of the true posterior; and assume that $q ( \theta | \beta )$ follows Dirichlet distribution. We follow Joo et al. (2019) to assume a symmetric Dirichlet distribution for the prior $p ( \theta )$ as well,
Table 6: CIFAR-10 test error on 4 simplified spaces.
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>s1</td><td rowspan=1 colspan=1>s2</td><td rowspan=1 colspan=1>s3</td><td rowspan=1 colspan=1>s4</td></tr><tr><td rowspan=1 colspan=1>DARTS</td><td rowspan=1 colspan=1>3.84</td><td rowspan=1 colspan=1>4.85</td><td rowspan=1 colspan=1>3.34</td><td rowspan=1 colspan=1>7.20</td></tr><tr><td rowspan=1 colspan=1>R-DARTS (DP)</td><td rowspan=1 colspan=1>3.11</td><td rowspan=1 colspan=1>3.48</td><td rowspan=1 colspan=1>2.93</td><td rowspan=1 colspan=1>3.58</td></tr><tr><td rowspan=1 colspan=1>R-DARTS (L2)</td><td rowspan=1 colspan=1>2.78</td><td rowspan=1 colspan=1>3.31</td><td rowspan=1 colspan=1>2.51</td><td rowspan=1 colspan=1>3.56</td></tr><tr><td rowspan=1 colspan=1>DrNAS</td><td rowspan=1 colspan=1>2.74</td><td rowspan=1 colspan=1>2.47</td><td rowspan=1 colspan=1>2.4</td><td rowspan=1 colspan=1>2.59</td></tr></table>
i.e., $p ( \theta ) = D i r ( \mathbf { 1 } )$ . The goal is to minimize the KL divergence between the true posterior and the approximated form, i.e., $\begin{array} { r } { \operatorname* { m i n } _ { \beta } K L ( q ( \theta | \beta ) | | p ( \theta | w , D ) ) } \end{array}$ . It can be shown that this objective is equivalent to maximizing the evidence lower bound as below (David M. Blei, 2016):
$$\mathcal { L } ( \beta ) = E _ { q ( \theta | \beta ) } { \big [ } \log p ( D | \theta , w ) { \big ] } - K L ( q ( \theta | \beta ) | | p ( \theta | w ) )$$
The upper level objective of the bilevel optimization under variational inference framework is then given as:
$$\operatorname* { m i n } _ { \beta } \ E _ { q ( \theta | \beta ) } \big [ - \log p ( D _ { v a l i d } | \theta , w ^ { * } ) \big ] + K L ( q ( \theta | \beta ) | | p ( \theta ) )$$
Note that eq. (23) resembles eq. (2) if we use the negative log likelihood as the loss function and replace $d ( \cdot , \cdot )$ with KL divergence. In practice, we find that using a simple l2 distance regularization works well across datasets and search spaces.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270# THE HIGH-DIMENSIONAL GEOMETRY OF BINARY NEURAL NETWORKS
Alexander G. Anderson Redwood Center for Theoretical Neuroscience University of California, Berkeley aga@berkeley.edu
Cory P. Berg Redwood Center for Theoretical Neuroscience University of California, Berkeley cberg500@berkeley.edu
# ABSTRACT
Recent research has shown that one can train a neural network with binary weights and activations at train time by augmenting the weights with a high-precision continuous latent variable that accumulates small changes from stochastic gradient descent. However, there is a dearth of work to explain why one can effectively capture the features in data with binary weights and activations. Our main result is that the neural networks with binary weights and activations trained using the method of Courbariaux, Hubara et al. (2016) work because of the high-dimensional geometry of binary vectors. In particular, the ideal continuous vectors that extract out features in the intermediate representations of these BNNs are well-approximated by binary vectors in the sense that dot products are approximately preserved. Furthermore, the results and analysis used on BNNs are shown to generalize to neural networks with ternary weights and activations. Compared to previous research that demonstrated good classification performance with BNNs, our work explains why these BNNs work in terms of HD geometry. Our theory serves as a foundation for understanding not only BNNs but a variety of methods that seek to compress traditional neural networks. Furthermore, a better understanding of multilayer binary neural networks serves as a starting point for generalizing BNNs to other neural network architectures such as recurrent neural networks.
# 1 INTRODUCTION
The rapidly decreasing cost of computation has driven many successes in the field of deep learning in recent years. Consequently, researchers are now considering applications of deep learning in resource limited hardware such as neuromorphic chips, embedded devices and smart phones (Esser et al. (2016), Neftci et al. (2016), Andri et al. (2017)). A recent realization for both theoretical researchers and industry practitioners is that traditional neural networks can be compressed because they are highly over-parameterized. While there has been a large amount of experimental work dedicated to compressing neural networks (Sec. 2), we focus on the particular approach that replaces costly 32-bit floating point multiplications with cheap binary operations. Our analysis reveals a simple geometric picture based on the geometry of high dimensional binary vectors that allows us to understand the successes of the recent efforts to compress neural networks.
Courbariaux et al. (2016) and Hubara et al. (2016) showed that one can efficiently train neural networks with binary weights and activations that have similar performance to their continuous counterparts. Such BNNs execute 7 times faster using a dedicated GPU kernel at test time. Furthermore, they argue that such BNNs require at least a factor of 32 fewer memory accesses at test time that should result in an even larger energy savings. There are two key ideas in their papers (Fig. 1). First, a continuous weight, $w ^ { c }$ , is associated with each binary weight, $w ^ { b }$ , that accumulates small changes from stochastic gradient descent. Second, the non-differentiable binarize function $( \theta ( x ) = 1$ if $x > 0$ and $- 1$ otherwise) is replaced with a continuous one during backpropagation. These modifications allow one to train neural networks that have binary weights and activations with stochastic gradient descent. While the work showed how to train such networks, the existence of neural networks with binary weights and activations needs to be reconciled with previous work that has sought to understand weight matrices as extracting out continuous features in data (e.g. Zeiler & Fergus (2014)). Summary of contributions:
 Figure 1: Review of the Courbariaux et al. (2016) BNN Training Algorithm: (a) A binary neural network is composed of binary convolution transformers (dashed green box). Each oval corresponds to a tensor and the derivative of the cost with respect to that tensor. Rectangles correspond to transformers that specify forward and backward propagation functions. Associated with each binary weight, $w ^ { b }$ , is a continuous weight, $w ^ { c }$ , that is used to accumulate gradients. $k$ denotes the kth layer of the network. (b) Each binarize transformer has a forward function and a backward function. The forward function simply binarizes the inputs. In the backward propagation step, one normally computes the derivative of the cost with respect to the input of a transformer via the Jacobian of the forward function and the derivative of the cost with respect to the output of that transformer $( \delta u \equiv d C / d u$ where $C$ is the cost function used to train the network). Since the binarize function is non-differentiable, the straight-through estimator (Bengio et al. (2013)), which is a smoothed version of the forward function, is used for the backward function .
1. Angle Preservation Property: We demonstrate that binarization approximately preserves the direction of high-dimensional vectors. In particular, we show that the angle between a random vector (from a standard normal distribution) and its binarized version converges to arccos $\sqrt { 2 / \pi } \approx 3 7 ^ { \circ }$ as the dimension of the vector goes to infinity. This angle is an exceedingly small angle in high dimensions. Furthermore, we show that this property is present in the weight vectors of a network trained using the method of Courbariaux et al. (2016).
2. Dot Product Proportionality Property: First, we empirically show that the weight-activation dot products, an important intermediate quantity a neural network, are approximately proportional under the binarization of the weight vectors. Next, we argue that if these weight activation dot products are proportional, then the continuous weights in the Courbariaux et al. (2016) method aren’t just a learning artifact. The continuous weights obtained from the BNN training algorithm (which decouples the forward and backward propagation steps) are an approximation of the weights one would learn if the network were trained with continuous weights and regular backpropagation.
3. Generalized Binarization Transformation (GBT): We show that the computations done by the first layer of the network are fundamentally different than the computations being done in the rest of the network because correlations in the data result in high variance principal components that are not randomly oriented relative to the binarization. Thus we recommend an architecture that uses a continuous convolution for the first layer to embed the image in a high-dimensional binary space, after which it can be manipulated with cheap binary operations. Furthermore, we illustrate how a GBT (rotate, binarize, rotate back) is useful for embedding low dimensional data in a high-dimensional binary space.
4. Generalization to Ternary Neural Networks: We show that the same analysis applies to ternary neural networks. In particular, the angle between a random vector from a standard normal distribution and the ternarized version of that vector predicts the empirical distribution of such angles in a network trained on CIFAR10. Furthermore, the dot product proportionality property is shown to hold for ternary neural networks.
# 2 RELATED WORK
Neural networks that achieve good performance on tasks such as IMAGENET object recognition are highly computationally intensive. For instance, AlexNet has 61 million parameters and executes 1.5 billion operations to classify one 224 by 224 image (30 thousand operations/pixel) (Rastegari et al. (2016)). Researchers have sought to reduce this computational cost for embedded applications using a number of different approaches.
The first approach is to try and compress a pre-trained network. Kim et al. (2015) uses a Tucker decomposition of the kernel tensor and fine tunes the network afterwards. Han et al. (2015b) train a network, prune low magnitude connections, and retrain. Han et al. (2015a) extend their previous work to additionally include a weight sharing quantization step and Huffman coding of the weights. More recently, Han et al. (2017) train a dense network, sparsify it, and then retrain a dense network with the pruned weights initialized to zero. Second, researchers have sought to train networks using either low precision floating point numbers or fixed point numbers, which allow for cheaper multiplications (Courbariaux et al. (2014), Gupta et al. (2015), Judd et al. (2015), Gysel et al. (2016), Lin et al. (2016), Lai et al. (2017)).
Third, one can train networks that have quantized weights and or activations. Bengio et al. (2013) looked at estimators for the gradient through a stochastic binary unit. Courbariaux et al. (2015) train networks with binary weights, and then later with binary weights and activations (Courbariaux et al. (2016)). Rastegari et al. (2016) replace a continuous weight matrix with a scalar times a binary matrix (and have a similar approximation for weight activation dot products). Kim & Smaragdis (2016) train a network with weights restricted in the range $- 1$ to 1 and then use a noisy backpropagation scheme train a network with binary weights and activations. Alemdar et al. (2016), Li et al. (2016) and Zhu et al. (2016) focus on networks with ternary weights. Further work seeks to quantize the weights and activations in neural networks to an arbitrary number of bits (Zhou et al. (2016), Hubara et al. (2016)). Zhou et al. (2017) use weights and activations that are zero or powers of two. Lin et al. (2015) and Zhou et al. (2016) quantize backpropagation in addition to the forward propagation.
Beyond merely seeking to compress neural networks, the analysis of the internal representations of neural networks is useful for understanding how to to compress them. Agrawal et al. (2014) found that feature magnitudes in higher layers do not matter (e.g. binarizing features barely changes classification performance). Merolla et al. (2016) analyze the robustness of neural network representations to a collection of different distortions. Dosovitskiy & Brox (2016) observe that binarizing features in intermediate layers of a CNN and then using backpropagation to find an image with those features leads to relatively little distortion of the image compared to dropping out features. These papers naturally lead into our work where we are seeking to better understand the representations in neural networks based on the geometry of high-dimensional binary vectors.
# 3 THEORY AND EXPERIMENTS
We investigate the internal representations of neural networks with binary weights and activations. A binary neural network is trained on CIFAR-10 (same learning algorithm and architecture as in Courbariaux et al. (2016)). Experiments on MNIST were carried out using both fully connected and convolutional networks and produced similar results. The CIFAR-10 convolutional neural network has six layers of convolutions, all of which have a 3 by 3 spatial kernel. The number of feature maps in each layer are 128, 128, 256, 256, 512, 512. After the second, fourth, and sixth convolutions, there is a 2 by 2 max pooling operation. Then there are two fully connected layers with 1024 units each. Each layer has a batch norm layer in between. The experiments using ternary neural networks use the same network architecture. The dimensionality of the weight vectors in these networks (i.e. convolution converted to a matrix multiply) is the patch size $( = 3 * 3 = 9$ ) times the number of channels.
# 3.1 PRESERVATION OF DIRECTION DURING BINARIZATION
In this section, we analyze the angle distributions (i.e. geometry) of high-dimensional binary vectors. This is crucial for understanding binary neural networks because we can imagine that at each layer of a neural network, there are some ideal continuous weight vectors that extract out features. A binary neural network approximates these ideal continuous vectors with a binary vectors. In low dimensions, binarization strongly impacts the direction of a vector. However, we argue that binarization does not substantially change the direction of a high-dimensional continuous vector. It is often the case that the geometric properties of high-dimensional vectors are counter-intuitive. For instance, one key idea in the hyperdimensional computing theory of Kanerva (2009) is that two random, high-dimensional vectors of dimension $d$ whose entries are chosen uniformly from the set $\{ - 1 , 1 \}$ are approximately orthogonal. The result follows from the central limit theorem because the cosine angle between two√ such random vectors is normally distributed with $\mu = 0$ and $\sigma \sim 1 / \sqrt { d }$ . Then $\cos \theta \approx 0$ implies that $\theta \approx \frac { \pi } { 2 }$ . Building upon this work, we study the way in which binary vectors are distributed relative to continuous vectors. As binarizing a continuous vector gives the binary vector closest in angle to that continuous vector, we can get a sense of how binary vectors are distributed relative to continuous vectors in high dimensions by binarizing continuous vectors. The standard normal distribution, which serves as an informative null distribution because it is rotationally invariant, is used to generate random continuous vectors which are then binarized. This analysis gives a fundamental insight into understanding the recent success of binary neural networks. Binarizing a random continuous vector changes its direction by a small amount relative to the angle between two random vectors in moderately high dimensions (Fig. 2a). Binarization changes the direction of a vector by approximately $3 7 ^ { \circ }$ in high dimensions. This seems like a large change based on our low-dimensional intuition. Indeed, the angle between two randomly chosen vectors from a rotationally invariant distribution is uniform in two dimensions. However, two randomly chosen vectors are approximately orthogonal in high dimensions. Thus while it is common for two random vectors to have an angle less than $3 7 ^ { \circ }$ in low dimensions, it is exceedingly rare in high dimensions. Therefore $3 7 ^ { \circ }$ is a small angle in high dimensions.
In order to test our theory of the binarization of random vectors chosen from a rotationally invariant distribution, we train a multilayer binary CNN on CIFAR10 (using the Courbariaux et al. (2016) method) and study the weight vectors1 of that network. Remarkably, there is a close correspondence between the experimental results and the theory for the angles between the binary and continuous weights (Fig. 2b). For each layer, the distribution of the angles between the binary and continuous weights is sharply peaked near the $d \to \infty$ expectation of arccos $\scriptstyle { \sqrt { 2 / \pi } }$ . We note that there is a small but systematic deviation from the theory towards larger angles for the higher layers of the network (Fig. 6). Ternary neural networks are considered in (SI Sec. 5.5) and yield a similar result.
# 3.2 DOT PRODUCT PROPORTIONALITY AS A SUFFICIENT CONDITION FOR APPROXIMATING ANETWORK WITH CONTINUOUS WEIGHTS
Given the previous discussion, an important question to ask is: are the so-called continuous weights a learning artifact without a clear correspondence to the binary weights? While we know that $w ^ { b } = \theta ( \overline { { w } } ^ { c } )$ , there are many continuous weights that map onto a particular binary weight vector. Which one is found when using the straight-through estimator to backpropagate through the binarize function? Remarkably, there is a clear answer to this question. In numerical experiments, we see that one gets the continuous weight vector such that the dot products of the activations with the prebinarization and post-binarization weights are highly correlated (Fig. 3). In equations, $a \cdot w ^ { b } \sim a \cdot w ^ { c }$ . We call this relation the Dot Product Proportionality (DPP) property. The proportionality constant, which is subsequently normalized away by a batch norm layer, depends on the magnitudes of the continuous and binary weight vectors and the cosine angle between the binary and continuous weight vectors. The theoretical consequences of the DPP property are explored in the rest of this section.
We show that the modified gradient of the BNN training algorithm can be viewed as an estimator of the gradient that would be used to train the continuous weights in traditional backpropagation. This establishes the fundamental point that while the weights and activations are technically binary, they are operating as if the weights are continuous. For instance, one could imagine using an exhaustive search over all binary weights in the network. However, the additional structure in the problem associated with taking dot products makes the optimization simpler than that. Furthermore, we show that if the dot products of the activations with the pre-binarized and post-binarized weights are proportional then straight-through estimator gradient is proportional to the continuous weight network gradient. The key to the analysis is to focus on the transformers in the network whose forward and backward propagation functions are not related in the way that they would normally be related in typical gradient descent.
 Figure 2: Binarization of High-Dimensional Vectors Approximately Preserves their Direction in Theory and Practice: (a) Distribution of angles between two random vectors (blue), and between a vector and its binarized version (red), for a rotationally invariant distribution of dimension $d$ . The red distribution is peaked near the $d \to \infty$ limit of arccos $\sqrt { 2 / \pi } \approx 3 7 ^ { \circ }$ (SI, Sec. 1). While $3 7 ^ { \circ }$ may seem like a large angle, that angle is small as compared to the angle between two random vectors in moderately high dimensions (i.e. the blue and red curves are well-separated). (b) Angle distribution between continuous and binary weight vectors by layer for a binary CNN trained on CIFAR-10. For the higher layers, there is a close correspondence to the theory. There is a small, but systematic deviation towards large angles (SI, Fig. 6). $d$ is the dimension of the filters at each layer. (c) Standard deviations of the angle distributions from (b) by layer. We see a correspondence to the theoretical expectation that standard deviations of each of the angle distributions scales as $d ^ { - 0 . 5 }$ (SI, Sec. 1). (d) Histogram of the components of the continuous weights at each layer. The distribution is approximately Gaussian for all but the first layer. Furthermore, there is a high density of weights near zero, which is the threshold for the binarization function.
Suppose that there is a neural network where two tensors, $u$ , and $v$ and the associated derivatives of the cost with respect to those tensors, $\delta u$ , and $\delta \boldsymbol { v }$ , are allocated. Suppose that the loss as a function of $v$ is $L ( x ) | _ { x = v }$ . Further, suppose that there are two potential forward propagation functions, $f$ , and $g$ . If the network is trained under normal conditions using $g$ as the forward propagation function, then the following computations are done:
$$v g ( u ) \qquad \delta v L ^ { \prime } ( x = v = g ( u ) ) \qquad \delta u \delta v \cdot g ^ { \prime } ( u )$$
where $L ^ { \prime } ( x )$ denotes the derivative of $L$ with respect to the vector $x$ . In a modified backpropagation scheme, the following computations are done
$$v f ( u ) \qquad \delta v = L ^ { \prime } ( x = v = f ( u ) ) \qquad \delta u \delta v \cdot g ^ { \prime } ( u )$$
A sufficient condition for $\delta u$ to be the same in both cases is $L ^ { \prime } ( x = f ( u ) ) \sim L ^ { \prime } ( x = g ( u ) )$ where $a \sim b$ means that the vector $a$ is a scalar times the vector $b$ .
Now this general observation is applied to the binarize transformer of Fig. 1. Here, $u$ is the continuous weight, $w ^ { c }$ , $f ( u )$ is the pointwise binarize function, $g ( u )$ is the identity function2, and $L$ is the loss of the network as a function of the weights in a particular layer. Given the network architecture, $L ( x ) = M ( a \cdot x )$ where $a$ are the activations corresponding to that layer and $M$ is the loss as a function of the weight-activation dot products. Then $L ^ { \prime } ( x ) = M ^ { \prime } ( a \cdot x ) \odot a$ where $\odot$ denotes a pointwise multiply. Thus the sufficient condition is $M ^ { \prime } ( a \cdot w ^ { b } ) \sim M ^ { \prime } ( a \cdot w ^ { c } )$ . Since the dot products are followed by a batch normalization, $M ( k { \vec { x } } ) = M ( { \vec { x } } ) M ^ { \prime } ( { \vec { x } } ) = k M ^ { \prime } ( k { \vec { x } } )$ . Therefore, it is sufficient that $\smash { \dot { a } \cdot w ^ { b } \sim a \cdot w ^ { c } }$ , which is the DPP property. When the DPP only approximately holds, the second derivative can be used to bound the error between the two gradients of the two learning procedures. In summary, the learning dynamics where $g$ is used for the forward and backward passes (i.e. training the network with continuous weights) is approximately equivalent to the modified learning dynamics $f$ on the forward pass, and $g$ on the backward pass) when we have the DPP property.
While we demonstrated that the BNN learning dynamics approximate the dynamics that one would have by training a network with continuous weights using a mixture of empirical and theoretical arguments, the ideal result would be that the learning algorithm implies the DPP property. It should be noted that in the case of stochastic binarization where $E ( w ^ { b } ) \dot { = } w ^ { c }$ is chosen by definition, the DPP property is true by design. However, it is remarkable that the property still holds in the case of deterministic binarization, which is revealing of the fundamental nature of the representations used in neural networks.
While the main focus of this section is the binarization of the weights, the arguments presented can also be applied to the binarize block that corresponds to the non-linearity of the network. The analogue of the DPP property for this binarize block is: $w ^ { b } \cdot a ^ { c } \sim w ^ { b } \cdot a ^ { b }$ where $a ^ { c }$ denotes the pre-binarized (post-batch norm) activations and $a ^ { b } = a$ denotes the binarized activations. This property is empirically verified to hold. For the sake of completeness, the dot product histogram corresponding to $w ^ { c } \cdot \bar { a } ^ { c } \sim w ^ { b } \cdot a ^ { b }$ is also computed, although it doesn’t directly correspond to removing one instance of a binarize transformer. This property is also empirically verified to hold (SI, Fig. 5).
Impact on Classification: It is natural to ask to what extent the classification performance depends on the binarization of the weights. In experiments on CIFAR10, if the binarization of the weights on all of the convolutional layers is removed, the classification performance drops by only 3 percent relative to the original network. Looking at each layer individually, removing the weight binarization for the first layer accounts for this entire percentage, and removing the binarization of the weights for each other layer causes no degradation in performance. This result is evident by looking at the 2D dot product histograms in Fig 3. The off-diagonal quadrants show where switching the weights from binary to continuous changes the sign of the binarized weight-activation dot product. In all of the layers except the first layer, there are very few dot products in the off-diagonal quadrants. Thus we recommend the use of the dot product histograms for studying the performance of binary neural networks. Removing the binarization of the activations has a substantial impact on the classification performance because that removes the main non-linearity of the network.
# 3.3 INPUT CORRELATIONS AND THE GENERALIZED BINARIZATION TRANSFORMATION
Not surprisingly, some distributions are impacted more strongly by binarization than others. A binary neural network must adapt its internal representations in such a way to not be degraded too much by binarization at each layer. In this section we explore the idea that the principal components of the input to the binarization function should be randomly oriented relative to the binarization. While the network can adapt the higher level representations to satisfy this property, the part of the network that interfaces with the input doesn’t have that flexibility. We make the novel observation that the difficulties in training the first layer of the network are tied to the intrinsic correlations in the input data. In order to be more precise, we define the Generalized Binarization Transformation (GBT)
$$\theta _ { R } ( x ) = R ^ { T } \theta ( R x )$$
where $x$ is a column vector, $R$ is a fixed rotation matrix, and $\theta$ is the pointwise binarization function from before. The rows of $R$ are called the axes of binarization. If $R$ is the identity matrix, then $\theta _ { R } = \theta$ and the axes of binarization are the canonical basis vectors $( . . . , 0 , 1 , 0 , . . . ) .$ $R$ can either be chosen strategically or randomly.
The GBT changes the distribution being binarized through a rotation. For appropriate choices of the rotation, $R$ , the directions of the input vectors, $x$ , are changed insignificantly by binarization. The angle between a vector and its binarized version is dependent on the dot product: ${ \bf \dot { x } } \cdot \theta _ { R } ( x )$ , which is equal to $x ^ { T } \theta _ { R } ( x ) = ( R x ) ^ { T } \theta ( R x ) = y \cdot \theta ( y )$ where $y = R x$ . As a concrete example of the benefits of the GBT, consider the case where $x \sim N ( 0 , \Sigma )$ and $\Sigma _ { i , j } = \delta _ { i , j } \exp ( 2 k i )$ for $k = 0 . 1$ (therefore $y \sim N ( 0 , R \Sigma R ^ { T } ) )$ . As the dimension goes to infinity, the angle between a vector drawn from this distribution and its binarized version approaches $\pi / 2$ . Thus binarization is destructive to vectors from this distribution. However, if the GBT is applied with a fixed random matrix3, the angle between the vector and its binarized version converges to $3 7 ^ { \circ }$ (Fig. 4). Thus a random rotation can compensate for the errors incurred from directly binarizing a non-isotropic Gaussian.
 Figure 3: Binarization Preserves Dot Products: Each subplot shows a 2D histogram of the dot products between the binarized weights and the activations (horizontal axis) and the dot products between the continuous weights and the activations (vertical axis) for different layers of a network trained on CIFAR10. Surprisingly, the dot products are highly correlated ( $r$ is the Pearson correlation coefficient). Thus replacing $\boldsymbol { w ^ { b } }$ with $w ^ { c }$ changes the overall constant in front of the dot products, while still preserving whether the dot product is zero or not zero. This overall constant is divided out by the subsequent batch norm layer. The shaded quadrants correspond to dot products where the sign changes when replacing the binary weights with the continuous weights. Notice that for all but the first layer, a very small fraction of the dot products lie in these off diagonal quadrants. The top left figure (labeled as Layer 1) corresponds to the input and the first convolution. Note that the correlation is weaker in the first layer.
Moving into how this analysis applies to a binary neural network, the network weights must approximate the important directions in the activations using binary vectors. For instance, Gabor filters are intrinsic features in natural images and are often found in the first layer weights of neural networks trained on natural images (e.g. Olshausen et al. (1996); Krizhevsky et al. (2012)). While the network has flexibility in the higher layers, the first layer must interface directly with the input where the features are not necessarily randomly oriented. For instance, consider the 27 dimensional input to the first set of convolutions in our network: 3 color channels of a 3 by 3 patch of an image from CIFAR10 with the mean removed. 3 PCs capture 90 percent of the variance of this data and 4 PCs capture 94.5 percent of the variance. The first two PCs are spatially uniform colors. More generally, large images such as those in IMAGENET have the same issue. Translation invariance of the image covariance matrix implies that the principal components are the filters of the 2D Fourier transform. Scale invariance implies a $1 / f ^ { 2 }$ power spectrum, which results in the largest PCs corresponding to low frequencies (Field (1987)).
Another manifestation of this issue can be seen in our trained networks. The first layer has a much smaller dot product correlation than the other layers (Fig. 3). To study this, we randomly permute the activations in order to generate a distribution with the same marginal statistics as the original data but independent joint statistics (a different permutation for each input image). Such a transformation gives a distribution with a correlation equal to the normalized dot product of the weight vectors (SI Sec. 3). The correlations for the higher layers decrease substantially but the correlation in the first layer increases (Fig. 4, right). For the first layer, the shuffling operation randomly permutes the pixels in the image. Thus we demonstrate that the binary weight vectors in the first layer are not well-aligned with the continuous weight vectors relative to the input data. Our theoretically grounded analysis is consistent with previous work. Han et al. (2015b) find that compressing the first set of convolutional weights of a particular layer by the same fraction has the highest impact on performance if done on the first layer. Zhou et al. (2016) find that accuracy degrades by about 0.5 to 1 percent on SHVN when quantizing the first layer weights. Thus it is recommended to rotate the input data before normalization or to use continuous weights for the first layer.
 Figure 4: Left: Random Rotation Improves Angle Preservation for a Non-Isotropic Gaussian. Random vectors are drawn from a Gaussian of dimension $d$ with a diagonal covariance matrix whose entries vary exponentially. As in Fig. 2, the red curve shows the angle between a random vector and its binarized version. Since the Gaussian is no longer isotropic, the red curve no longer peaks at $\theta = \operatorname { a r c c o s } { \sqrt { 2 / \pi } } .$ . However, if the binarization is replaced with a GBT with a fixed random matrix, the direction of the vector is again approximately preserved. Right: Permuting the activations shows that the correlations observed in Fig. 3 are not merely due to correlations between the binary and continuous weight vectors. The correlations are due to these weight vectors corresponding to high variance directions in the data.
# 4 CONCLUSION
Neural networks with binary weights and activations have similar performance to their continuous counterparts with substantially reduced execution time and power usage. We provide an experimentally verified theory for understanding how one can get away with such a massive reduction in precision based on the geometry of HD vectors. First, we show that binarization of high-dimensional vectors preserves their direction in the sense that the angle between a random vector and its binarized version is much smaller than the angle between two random vectors (Angle Preservation Property). Second, we take the perspective of the network and show that binarization approximately preserves weight-activation dot products (Dot Product Proportionality Property). More generally, when using a network compression technique, we recommend looking at the weight activation dot product histograms as a heuristic to help localize the layers that are most responsible for performance degradation. Third, we discuss the impacts of the low effective dimensionality of the data on the first layer of the network. We recommend either using continuous weights for the first layer or a Generalized Binarization Transformation. Such a transformation may be useful for architectures like LSTMs where the update for the hidden state declares a particular set of axes to be important (e.g. by taking the pointwise multiply of the forget gates with the cell state). Finally, we show that neural networks with ternary weights and activations can also be understood with our approach. More broadly speaking, our theory is useful for analyzing a variety of neural network compression techniques that transform the weights, activations or both to reduce the execution cost without degrading performance.
# REFERENCES
Pulkit Agrawal, Ross Girshick, and Jitendra Malik. Analyzing the performance of multilayer neural networks for object recognition. In European Conference on Computer Vision, pp. 329–344. Springer, 2014.
Hande Alemdar, Nicholas Caldwell, Vincent Leroy, Adrien Prost-Boucle, and Frédéric Pétrot. Ternary neural networks for resource-efficient ai applications. arXiv preprint arXiv:1609.00222, 2016.
Renzo Andri, Lukas Cavigelli, Davide Rossi, and Luca Benini. Yodann: An architecture for ultra-low power binary-weight cnn acceleration. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems, 2017.
Yoshua Bengio, Nicholas Léonard, and Aaron Courville. Estimating or propagating gradients through stochastic neurons for conditional computation. arXiv preprint arXiv:1308.3432, 2013.
Matthieu Courbariaux, Yoshua Bengio, and Jean-Pierre David. Training deep neural networks with low precision multiplications. arXiv preprint arXiv:1412.7024, 2014.
Matthieu Courbariaux, Yoshua Bengio, and Jean-Pierre David. Binaryconnect: Training deep neural networks with binary weights during propagations. In Advances in Neural Information Processing Systems, pp. 3123–3131, 2015.
Matthieu Courbariaux, Itay Hubara, Daniel Soudry, Ran El-Yaniv, and Yoshua Bengio. Binarized neural networks: Training neural networks with weights and activations constrained to $+ 1$ and $^ { - 1 }$ arXiv preprint arXiv:1602.02830, 2016.
Alexey Dosovitskiy and Thomas Brox. Inverting visual representations with convolutional networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 4829– 4837, 2016.
Steven K Esser, Paul A Merolla, John V Arthur, Andrew S Cassidy, Rathinakumar Appuswamy, Alexander Andreopoulos, David J Berg, Jeffrey L McKinstry, Timothy Melano, Davis R Barch, et al. Convolutional networks for fast, energy-efficient neuromorphic computing. Proceedings of the National Academy of Sciences, pp. 201604850, 2016.
David J Field. Relations between the statistics of natural images and the response properties of cortical cells. Josa a, 4(12):2379–2394, 1987.
Suyog Gupta, Ankur Agrawal, Kailash Gopalakrishnan, and Pritish Narayanan. Deep learning with limited numerical precision. In ICML, pp. 1737–1746, 2015.
Philipp Gysel, Mohammad Motamedi, and Soheil Ghiasi. Hardware-oriented approximation of convolutional neural networks. arXiv preprint arXiv:1604.03168, 2016.
Song Han, Huizi Mao, and William J Dally. Deep compression: Compressing deep neural networks with pruning, trained quantization and huffman coding. arXiv preprint arXiv:1510.00149, 2015a.
Song Han, Jeff Pool, John Tran, and William Dally. Learning both weights and connections for efficient neural network. In Advances in Neural Information Processing Systems, pp. 1135–1143, 2015b.
Song Han, Jeff Pool, Sharan Narang, Huizi Mao, Enhao Gong, Shijian Tang, Erich Elsen, Peter Vajda, Manohar Paluri, John Tran, et al. Dsd: Dense-sparse-dense training for deep neural networks. arXiv prepring arXiv:1607.04381, 2017.
Itay Hubara, Matthieu Courbariaux, Daniel Soudry, Ran El-Yaniv, and Yoshua Bengio. Quantized neural networks: Training neural networks with low precision weights and activations. arXiv preprint arXiv:1609.07061, 2016.
Patrick Judd, Jorge Albericio, Tayler Hetherington, Tor Aamodt, Natalie Enright Jerger, Raquel Urtasun, and Andreas Moshovos. Reduced-precision strategies for bounded memory in deep neural nets. arXiv preprint arXiv:1511.05236, 2015.
Pentti Kanerva. Hyperdimensional computing: An introduction to computing in distributed representation with high-dimensional random vectors. Cognitive Computation, 1(2):139–159, 2009.
Minje Kim and Paris Smaragdis. Bitwise neural networks. arXiv preprint arXiv:1601.06071, 2016.
Yong-Deok Kim, Eunhyeok Park, Sungjoo Yoo, Taelim Choi, Lu Yang, and Dongjun Shin. Compression of deep convolutional neural networks for fast and low power mobile applications. arXiv preprint arXiv:1511.06530, 2015.
Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. In Advances in neural information processing systems, pp. 1097–1105, 2012.
Liangzhen Lai, Naveen Suda, and Vikas Chandra. Deep convolutional neural network inference with floating-point weights and fixed-point activations. arXiv preprint arXiv:1703.03073, 2017.
Fengfu Li, Bo Zhang, and Bin Liu. Ternary weight networks. arXiv preprint arXiv:1605.04711, 2016.
Darryl Lin, Sachin Talathi, and Sreekanth Annapureddy. Fixed point quantization of deep convolutional networks. In International Conference on Machine Learning, pp. 2849–2858, 2016.
Zhouhan Lin, Matthieu Courbariaux, Roland Memisevic, and Yoshua Bengio. Neural networks with few multiplications. arXiv preprint arXiv:1510.03009, 2015.
Paul Merolla, Rathinakumar Appuswamy, John Arthur, Steve K Esser, and Dharmendra Modha. Deep neural networks are robust to weight binarization and other non-linear distortions. arXiv preprint arXiv:1606.01981, 2016.
Emre Neftci, Charles Augustine, Somnath Paul, and Georgios Detorakis. Neuromorphic deep learning machines. arXiv preprint arXiv:1612.05596, 2016.
Bruno A Olshausen et al. Emergence of simple-cell receptive field properties by learning a sparse code for natural images. Nature, 381(6583):607–609, 1996.
Mohammad Rastegari, Vicente Ordonez, Joseph Redmon, and Ali Farhadi. Xnor-net: Imagenet classification using binary convolutional neural networks. arXiv preprint arXiv:1603.05279, 2016.
Gilbert W Stewart. The efficient generation of random orthogonal matrices with an application to condition estimators. SIAM Journal on Numerical Analysis, 17(3):403–409, 1980.
Matthew D Zeiler and Rob Fergus. Visualizing and understanding convolutional networks. In European conference on computer vision, pp. 818–833. Springer, 2014.
Aojun Zhou, Anbang Yao, Yiwen Guo, Lin Xu, and Yurong Chen. Incremental network quantization: Towards lossless cnns with low-precision weights. arXiv preprint arXiv:1702.03044, 2017.
Shuchang Zhou, Yuxin Wu, Zekun Ni, Xinyu Zhou, He Wen, and Yuheng Zou. Dorefa-net: Training low bitwidth convolutional neural networks with low bitwidth gradients. arXiv preprint arXiv:1606.06160, 2016.
Chenzhuo Zhu, Song Han, Huizi Mao, and William J Dally. Trained ternary quantization. arXiv preprint arXiv:1612.01064, 2016.
# 5 SUPPLEMENTARY INFORMATION
# 5.1 EXPECTED ANGLES
Random $n$ dimensional vectors are drawn from a rotationally invariant distribution. The angle between two random vectors and the angle between a vector and its binarized version are compared. A rotationally invariant distribution can be factorized into a pdf for the magnitude of the vector times a distribution on angles. In the expectations that we are calculating, the magnitude cancels out and there is only one rotationally invariant distribution on angles. Thus it suffices to compute these expectations using a Gaussian.
# Lemmas:
1. Consider a vector, $v$ , chosen from a standard normal distribution of dimension $n$ . Let $\begin{array} { r } { \rho = \frac { v _ { 1 } } { \sqrt { v _ { 1 } ^ { 2 } + \ldots + v _ { n } ^ { 2 } } } } \end{array}$ . Then $\rho$ is distributed according to: $\begin{array} { r } { g ( \rho ) = \frac { 1 } { \sqrt { \pi } } \frac { \Gamma ( n / 2 ) } { \Gamma ( ( n - 1 ) / 2 ) } ( 1 - \rho ^ { 2 } ) ^ { \frac { n - 3 } { 2 } } } \end{array}$ where $\Gamma$ is the Gamma function. Proof: Begin by considering the integral $\begin{array} { r } { G ( \rho _ { 0 } ) = p ( \rho < \rho _ { 0 } ) = \int \prod _ { i } d v _ { i } p ( v ) I ( \rho ( v ) < \rho _ { 0 } ) } \end{array}$ where $I$ is an indicator function. The desired distribution comes from taking the derivative of this cumulative distribution g(ρ0) = ddρ0 . Consider the generalized spherical coordinate transformation: $v _ { 1 } = r \cos \phi _ { 1 }$ , $\begin{array} { r } { \dot { v } _ { 2 } = r \sin \phi _ { 1 } \cos \phi _ { 2 } . } \end{array}$ , $v _ { 3 } = r \sin \phi _ { 1 } \sin \phi _ { 2 } \cos \phi _ { 3 }$ , $\begin{array} { r } { \ldots \quad v _ { n - 1 } = r \sin \phi _ { 1 } \cdot \cdot \cdot \sin \phi _ { n - 2 } \cos \phi _ { n - 1 } , } \end{array}$ $v _ { n } ~ = ~ r \sin \phi _ { 1 } \cdot \cdot \cdot \sin \phi _ { n - 2 } \sin \phi _ { n - 1 }$ where $\phi _ { 1 } , \ldots , \phi _ { n - 2 } \in [ 0 , \pi ]$ and $\phi _ { n - 1 } \in [ 0 , 2 \pi ]$ . The generalized spherical volume element is $d v = r ^ { n - 1 } \sin ^ { n - 2 } ( \phi _ { 1 } ) \sin ^ { n - 3 } ( \phi _ { 2 } ) \cdot \cdot \cdot \sin ( \phi _ { n - 2 } ) d r d \phi _ { 1 } \cdot \cdot \cdot d \phi _ { n - 1 }$ . 4 Thus we can write out the integral $\begin{array} { r } { G ( \rho _ { 0 } ) = \int I ( \cos \phi _ { 1 } < \rho _ { 0 } ) \frac { e ^ { - r ^ { 2 } / 2 } } { \sqrt { ( 2 \pi ) ^ { n } } } r ^ { n - 1 } \sin ^ { n - 2 } ( \phi _ { 1 } ) \sin ^ { n - 3 } ( \phi _ { 2 } ) \cdot \cdot \cdot \sin ( \phi _ { n - 2 } ) d r d \phi _ { 1 } \cdot \cdot \cdot d \phi _ { n - 1 } } \end{array}$ The integral factorizes and all of the terms are independent of $\rho _ { 0 }$ except the integral over $\phi _ { 1 } \equiv \phi$ . Thus $\begin{array} { r } { G ( \rho _ { 0 } ) \sim \int _ { 0 } ^ { \pi } I ( \cos \phi < \rho _ { 0 } ) \sin ^ { \hat { n } - 2 } ( \phi ) d \phi } \end{array}$ . Using the substitution $\rho = \cos \phi$ (which is also consistent with the definition of $\rho$ above), $d \rho = - \sin ( \phi ) d \phi$ , $\sin \rho ~ = ~ ( 1 - \rho ^ { 2 } ) ^ { 0 . 5 }$ , so $\begin{array} { r } { G ( \rho _ { 0 } ) ~ \sim ~ \int _ { - 1 } ^ { 1 } I ( \rho ~ < ~ \rho _ { 0 } ) ( 1 - \rho ^ { 2 } ) ^ { ( n - 3 ) / 2 } d \rho } \end{array}$ . Taking the derivative with respect to $\rho _ { 0 }$ and using the fundamental theorem of calculus gives $g ( \rho ) \sim ( 1 - \rho ^ { 2 } ) ^ { ( \bar { n - 3 } ) / 2 }$ . The normalization constant is equal to a beta function that evaluates to the desired result (substitute $t = \rho ^ { 2 }$ ).
Cases:
• Distribution of angles between two random vectors. Since a Gaussian is a rotationally invariant distribution, we can say without loss of generality that one of the vectors is $( 1 , 0 , 0 , \ldots 0 )$ . Then the cosine angle between those two vectors is $\rho$ as defined above. While the exact distribution of $\rho$ is given by Lemma 1, we note that – $E ( \rho ) = 0$ due to the symmetry of the distribution. – $\begin{array} { r } { V a r ( \rho ) = E ( \rho ^ { 2 } ) = \frac { 1 } { n } } \end{array}$ because $\begin{array} { r } { 1 = E \left( \frac { \sum _ { i } x _ { i } ^ { 2 } } { \sum _ { j } x _ { j } ^ { 2 } } \right) = \sum _ { i } E \left( \frac { x _ { i } ^ { 2 } } { \sum _ { j } x _ { j } ^ { 2 } } \right) = n * E ( \rho ^ { 2 } ) } \end{array}$
• Angles between a vector and the binarized version of that vector, η = v·θ(v)||v||·||θ(v)|| $\frac { \sum _ { i } \left| v _ { i } \right| } { \sqrt { \sum v _ { i } ^ { 2 } } * \sqrt { n } }$
$$E ( \eta ) = \frac { \sqrt { n } } { \sqrt { \pi } } * \frac { \Gamma ( n / 2 ) } { \Gamma ( ( n + 1 ) / 2 ) } \qquad \operatorname* { l i m } _ { n \to \infty } E ( \eta ) = \sqrt { \frac { 2 } { \pi } }$$
First, we note $E ( \eta ) = \sqrt { n } E ( | \rho | )$ . Then $\begin{array} { r } { E ( | \rho | ) = \int _ { 0 } ^ { 1 } d \rho \rho \frac { 2 } { \sqrt { \pi } } \frac { \Gamma ( n / 2 ) } { \Gamma ( ( n - 1 ) / 2 ) } ( 1 - \rho ^ { 2 } ) ^ { \frac { n - 3 } { 2 } } = } \end{array}$ $\frac { 2 } { \sqrt { \pi } } \ast \frac { 1 } { n - 1 } \frac { \Gamma ( n / 2 ) } { \Gamma ( ( n - 1 ) / 2 ) }$ (substitute $u \ : = \ : \rho ^ { 2 }$ and use $\Gamma ( x + 1 ) = x \Gamma ( x )$ ). Lemma
two gives the $n \infty$ limit. $\begin{array} { r l r } { \frac { 2 } { \sqrt { \pi } } \frac { \sqrt { n } } { n - 1 } \frac { \Gamma ( n / 2 ) } { \Gamma ( ( n - 1 ) / 2 ) } \ \approx \ \frac { 2 } { \sqrt { \pi } } \frac { \sqrt { n } } { n - 1 } \sqrt { \frac { n } { 2 } } \left[ 1 + \frac { 0 . 5 * 0 . 5 } { 2 ( n / 2 ) } \right] \ = } \end{array}$ q 2π 1 + 54 ∗ 1n + O(1/n2)
$${ V a r } ( \eta ) = \frac { 1 } { n } \left( 1 - \frac { 1 } { \pi } \right) + { \cal O } ( 1 / n ^ { 2 } )$$
Thus we have the normal scaling as in the central limit theorem of the large $n$ variance. We can calculate this explicitly following the approach of 5.
As $E ( \eta )$ has been calculated, it suffices to calculate $E ( \eta ^ { 2 } )$ . Expanding out $\eta ^ { 2 } , E ( \eta ^ { 2 } ) =$ $\begin{array} { r } { \frac { 1 } { n } + ( n - 1 ) * E \bigl ( \frac { | v _ { 1 } v _ { 2 } | } { v _ { 1 } ^ { 2 } + \ldots v _ { n } ^ { 2 } } \bigr ) } \end{array}$ . Below we show that $\begin{array} { r } { E ( \frac { | v _ { 1 } v _ { 2 } | } { v _ { 1 } ^ { 2 } + \ldots v _ { n } ^ { 2 } } ) = \frac { 2 } { \pi n } } \end{array}$ . Thus the variance is:
$${ \frac { 1 } { n } } * \left( 1 - { \frac { 2 } { \pi } } \right) + { \frac { 2 } { \pi } } - \left( { \frac { \sqrt { n } } { \sqrt { \pi } } } { \frac { \Gamma ( n / 2 ) } { \Gamma ( ( n + 1 ) / 2 ) } } \right) ^ { 2 }$$
Using Lemma 2 to expand out the last term, we get $[ \frac { \sqrt { n } } { \sqrt { \pi } } ( n / 2 ) ^ { - 1 / 2 } ( 1 - 1 / ( 4 n ) +$ $O ( n ^ { - 2 } ) ) ] ^ { 2 } = \frac { _ { 2 } } { \pi } ( 1 - { 1 } / ( { 2 n } ) + O ( n ^ { - 2 } ) )$ . Plugging this in gives the desired result.
Going back to the calculation of that expectation, change variables to $v _ { 1 } = r \cos \theta$ , $v _ { 2 } = r \sin { \theta }$ , $z ^ { 2 } = v _ { 3 } ^ { 2 } + \ldots + v _ { n } ^ { 2 }$ . The integration over the volume element $d v _ { 3 } \ldots d v _ { n }$ is rewritten as $d z d A _ { n - 3 }$ where $d A _ { n }$ denotes the surface element of a $n$ sphere. Since the integrand only depends on the magnitude, $z$ , $\textstyle { \int d A _ { n - 3 } = z ^ { n - 3 } * { \dot { S } } _ { n - 3 } }$ where $\begin{array} { r } { S _ { n } = \frac { 2 \pi ^ { ( n + 1 ) / 2 } } { \Gamma ( \frac { n + 1 } { 2 } ) } } \end{array}$ denotes the surface area of a unit $n$ -sphere. Then
$$E \left( \frac { | v _ { 1 } v _ { 2 } | } { v _ { 1 } ^ { 2 } + . . . v _ { n } ^ { 2 } } \right) = ( 2 \pi ) ^ { - n / 2 } S _ { n - 3 } \int _ { 0 } ^ { 2 \pi } d \theta | \cos \theta \sin \theta | * \int r d r z ^ { n - 3 } d z * \frac { r ^ { 2 } } { r ^ { 2 } + z ^ { 2 } } * e ^ { - ( z ^ { 2 } + r ^ { 2 } ) / 2 } .$$
Then substitute $r = p \cos \phi$ , $z = p \sin \phi$ where $\phi \in [ 0 , \pi / 2 ]$
$$= ( 2 \pi ) ^ { - n / 2 } \ast 2 S _ { n - 3 } \int _ { 0 } ^ { \pi / 2 } d \phi \cos \phi ^ { 3 } \ast \sin \phi ^ { n - 3 } \int _ { 0 } ^ { \infty } d p \ast p ^ { n - 1 } e ^ { - p ^ { 2 } / 2 }$$
The first integral is $\frac { 2 } { n ( n - 2 ) }$ using $u = \sin ^ { 2 } \phi$ . The second integral is $2 ^ { ( n - 2 ) / 2 } \Gamma ( n / 2 )$ using $u = p ^ { 2 } / 2$ and the definition of the gamma function. Simplifying, the result is $\frac { 2 } { \pi * n }$
Thus the angle between a vector and a binarized version of that vector converges to arccos ${ \sqrt { \frac { 2 } { \pi } } } \approx 3 7 ^ { \circ }$ , which is a very small angle in high dimensions.
# 5.2 AN EXPLICIT EXAMPLE OF LEARNING DYNAMICS
In this subsection, we look at the learning dynamics for the BNN training algorithm in a simple case and gain some insight about the learning algorithm. Consider the case of regression where the target output, $y$ , is predicted with a binary linear predictor with $x$ as the input. Using a squared error loss, ${ \cal L } \dot { = } ( y - \hat { y } ) \dot { ^ 2 } = ( y - w ^ { b } x ) ^ { 2 } = ( \bar { y } - \theta ( w ^ { c } \acute { } ) x ) ^ { 2 }$ . (In this notation, $x$ is a column vector.) Taking the derivative of this loss with respect to the continuous weights and using the rule for back propagating through the binarize function gives $\Delta w ^ { c } \sim - d L / d w ^ { c } = - d L / d w ^ { \check { b } } \cdot d w ^ { b } / d w ^ { c } = ( y ^ { \check { b } } - w ^ { \check { b } } x ) x ^ { \check { T } }$ . Finally, averaging over the training data gives
$$\Delta w ^ { c } \sim C _ { y x } - \theta ( w ^ { c } ) \cdot C _ { x x } \qquad C _ { y x } = E [ y x ^ { T } ] \qquad C _ { x x } = E ( x x ^ { T } )$$
It is worthwhile to compare this equation the corresponding equation from typical linear regression: $\Delta w ^ { c } \sim C _ { y x } - w ^ { c } \cdot C _ { x x }$ . For simplicity, consider the case where $C _ { x x }$ is the identity matrix. In this case, all of the components of $w$ become independent: $\delta w = \epsilon * ( \alpha - \theta ( w ) )$ where $\epsilon$ is the learning rate and $\alpha$ is the entry of $C _ { y x }$ corresponding to a particular element, $w$ . Compared to regular linear regression, it is clear that the stable point of these equations is when $w = \alpha$ . Since the weight is binarized, that equation cannot be satisfied. However, it can be shown $( \star )$ that in this special case of binary weight linear regression, $E ( \theta ( w ^ { c } ) ) = \alpha$ . Intuitively, if we consider a high dimensional vector and the fluctuations of each component are likely to be out of phase, then $\boldsymbol { w } ^ { b } \cdot \boldsymbol { x } \approx \boldsymbol { w } ^ { c } \cdot \boldsymbol { x }$ is going to be correct in expectation with a variance that scales as $\frac { 1 } { n }$ . During the actual learning process, we anneal the learning rate to a very small number, so the particular state of a fluctuating component of the vector is frozen in. Relatedly, the equation $C _ { y x } \approx w C _ { x x }$ is easier to satisfy in high dimensions, whereas in low dimensions, it is only satisfied in expectation.
 Figure 5: Activation Binarization Preserves Dot Products: Left: Each panel shows a 2D histogram of the dot products between the binarized weights and binarized activations (vertical axis) and post-batch norm (but pre-activation binarization) activations (horizontal axis). The binarization transformer does little to corrupt the dot products between weights and activations. Right: Dot products between the binary weights and binary activations (horizontal axis) compared against the dot products between the continuous weights and continuous activations (vertical axis). The dot products are not significantly impacted by removing binarization.
Proof for $( \star )$ : Suppose that $| \alpha | \le 1$ . The basic idea of these dynamics is that steps of size proportional to $\epsilon$ are taken whose direction depends on whether $w > 0$ or $w < 0$ . In particular, if $w > 0$ , then the step is $- \epsilon \cdot | 1 - \alpha |$ and if $w < 0$ , the step is $\epsilon \cdot \left( \alpha + 1 \right)$ . It is evident that after a sufficient burn-in period, $| w | \leq \epsilon * \operatorname* { m a x } ( | 1 - \alpha | , 1 + \alpha ) \leq 2 \epsilon$ . Suppose $w > 0$ occurs with fraction $p$ and $w < 0$ occurs with fraction $1 - p$ . In order for $w$ to be in equilibrium, oscillating about zero, these steps balance out on average: $p ( 1 - \alpha ) = ( 1 - p ) ( 1 + \alpha ) p = ( 1 + \alpha ) / 2$ . Then the expected value of $\theta ( w )$ is $1 * p + ( - 1 ) * ( 1 - p ) = \alpha$ . When $| \alpha | > 1$ , the dynamics diverge because $\alpha - \theta ( w )$ will always have the same sign. This divergence demonstrates the importance of some normalization technique such as batch normalization or attempting to represent $w$ with a constant times a binary matrix.
# 5.3 DOT PRODUCT CORRELATIONS AFTER ACTIVATION PERMUTATION
Suppose that $A = w \cdot a$ and $\boldsymbol { B } = \boldsymbol { v } \cdot \boldsymbol { a }$ where $w , v$ are weight vectors and $a$ is the vector of activations. What is the correlation, $r$ , between $A$ and $B ?$ Assuming that $E ( a ) = 0$ , $E ( A ) = E ( B ) = 0$ . Then $\begin{array} { r } { E ( A B ) = \sum _ { i , j } w _ { i } v _ { j } E ( a _ { i } a _ { j } ) = w ^ { T } C v } \end{array}$ where $C _ { i , j } = E ( a _ { i } a _ { j } )$ . Setting $v = w$ and $w = v$ gives $E ( A ^ { 2 } ) = w ^ { T } C w$ and $v ^ { T } C v$ . Thus $\begin{array} { r } { r = \frac { w ^ { T } C v } { \sqrt { ( w ^ { T } C w ) ( v ^ { T } C v ) } } } \end{array}$ .
In the case where the activations are randomly permuted, $C$ is proportional to the identity matrix, and thus the correlation between $A$ and $B$ is the cosine angle between $u$ and $v$ .
# 5.4 ANGLE PLOT
 Figure 6: Angle distribution between continuous and binary weight vectors by layer for a binary CNN trained on CIFAR-10 (same plot as in Fig. 2b except zoomed in). Notice that there is a small but systematic deviation towards larger angles relative to the theoretical expectation (vertical dotted line). As the dimension of the vectors in the layer goes up, the distribution gets sharper. The theory√ predicts that the standard deviation of these distributions scales as $1 / \sqrt { d }$ . This relationship is shown to approximately hold in Fig. 2c.
# 5.5 TERNARY NEURAL NETWORKS
Moving beyond binarization, recent work has shown how to train neural networks where the activations are quantized to three (or more) values (e.g. Hubara et al. (2016)). Indeed, ternarization may be a more natural quantization method than binarization for neural network weights because one can express a positive association $( + 1 )$ , a negative association $( - 1 )$ , or no association (0) between two features in a neural network. We show that the analysis used on BNNs holds for ternary neural networks.
The quantization function: t $\operatorname { x r } _ { a } ( x ) = 1$ if $x > a$ , 0 if $| x | < a$ , and $- 1$ if $x < - a$ is used in place of the binarize function with the same straight-through estimator for the gradient. Call $a$ the ternarization threshold. The exact value of $a$ is only important at initialization because the scaling constant of the batch normalization layer allows the network to adapt the standard deviation of the pre-nonlinearity activations to the value of $a$ . The network architecture from the previous experiments was used to classify images in CIFAR-10 and $a$ was chosen to be equal to 0.02. In practice, roughly 10 percent of the ternarized weights were zero (Fig. 7a) and 2 percent of the activations were zero. Thus the network learning process did not ignore the possibility of using zero weights. However, more work is needed to effectively use the zero value for the activations.
The empirical distribution of angles between the continuous vectors and their ternarized counterparts is highly peaked at the value predicted by the theory (Fig. 7b). Random vectors are chosen from a standard normal distribution of dimension $d$ . As in the case of binarization, the ternarized version of a vector is close in angle to the original vector in high dimensions (Fig. 7c). These vectors are quantized using $\mathrm { t e r } _ { a }$ for different values of $a$ . The peak angle varies substantially as a function of $a$ (Fig. 7d). Note that for $a = 0$ , the ternarization function collapses into the binarization function. The empirical value of $a$ is the ratio of the empirical threshold to the empirical standard deviation of the continuous weights. Thus $a \approx 0 . 0 2 / 0 . 1 8 \approx 0 . 1 1$ for the higher layers. Remarkably, the theoretical prediction for the peak angle as a function of $a$ matches closely with the empirical result (Fig. 7b).
Finally, the dot product proportionality property is also shown to hold for ternary neural networks (Fig. 7e). Thus the continuous weights found using the TNN training algorithm approximate the continuous weights that one would get if the network were trained with continuous weights and regular backpropagation.
 Figure 7: Ternarization of High-Dimensional Vectors Preserves their Direction in Theory and Practice: (a) Histogram of the components of the continuous weights at each layer for a ternary CNN trained on CIFAR-10. The distribution is approximately Gaussian for all but the first layer. The vertical lines show the ternarization thresholds and approximately 10 percent of the weights are sent to zero. (b) Angle distribution between continuous and ternary weight vectors by layer. The vertical dotted line (at $\theta \approx 3 4 ^ { \circ }$ ) indicates the theoretical prediction given the empirical ternarization threshold $( \approx 0 . 1 1 )$ . $d$ is the dimension of the filters at each layer. (c) Distribution of angles between two random vectors (blue), and between a vector and its quantized version (red), for a rotationally invariant distribution of dimension $d$ . The ternarization threshold is chosen to match the trained network. As the red and blue curves have little overlap, ternarization causes a small change in angle in high dimensions. (d) Angle between a random vector and its ternarized version as a function of ternarization threshold for $d = 1 0 0 0$ . There is a large variation in the angle over different thresholds. (e) Ternarization preserves dot products. The 2D histogram shows the dot products between the ternarized weights and the activations (horizontal axis) and the dot products between the continuous weights and the activations (vertical axis) for layer 3 of the network. The dot products are highly correlated.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343# RETHINKING THE HYPERPARAMETERS FOR FINE-TUNING
Hao $\mathbf { L i } ^ { 1 }$ , Pratik Chaudhari2∗, Hao Yang1, Michael Lam1, Avinash Ravichandran1, Rahul Bhotika1, Stefano Soatto1,3
1Amazon Web Services, 2University of Pennsylvania, 3University of California, Los Angeles {haolimax, haoyng, michlam, ravinash, bhotikar, soattos} $@$ amazon.com, pratikac@seas.upenn.edu
# ABSTRACT
Fine-tuning from pre-trained ImageNet models has become the de-facto standard for various computer vision tasks. Current practices for fine-tuning typically involve selecting an ad-hoc choice of hyperparameters and keeping them fixed to values normally used for training from scratch. This paper re-examines several common practices of setting hyperparameters for fine-tuning. Our findings are based on extensive empirical evaluation for fine-tuning on various transfer learning benchmarks. (1) While prior works have thoroughly investigated learning rate and batch size, momentum for fine-tuning is a relatively unexplored parameter. We find that the value of momentum also affects fine-tuning performance and connect it with previous theoretical findings. (2) Optimal hyperparameters for fine-tuning, in particular, the effective learning rate, are not only dataset dependent but also sensitive to the similarity between the source domain and target domain. This is in contrast to hyperparameters for training from scratch. (3) Reference-based regularization that keeps models close to the initial model does not necessarily apply for “dissimilar” datasets. Our findings challenge common practices of finetuning and encourages deep learning practitioners to rethink the hyperparameters for fine-tuning.
# 1 INTRODUCTION
Many real-world applications often have a limited number of training instances, which makes directly training deep neural networks hard and prone to overfitting. Transfer learning with the knowledge of models learned on a similar task can help to avoid overfitting. Fine-tuning is a simple and effective approach of transfer learning and has become popular for solving new tasks in which pre-trained models are fine-tuned with the target dataset. Specifically, fine-tuning on pre-trained ImageNet classification models (Simonyan & Zisserman, 2015; He et al., 2016b) has achieved impressive results for tasks such as object detection (Ren et al., 2015) and segmentation (He et al., 2017; Chen et al., 2017) and is becoming the de-facto standard of solving computer vision problems. It is believed that the weights learned on the source dataset with a large number of instances provide better initialization for the target task than random initialization. Even when there is enough training data, fine-tuning is still preferred as it often reduces training time significantly (He et al., 2019).
The common practice of fine-tuning is to adopt the default hyperparameters for training large models while using smaller initial learning rate and shorter learning rate schedule. It is believed that adhering to the original hyperparameters for fine-tuning with small learning rate prevents destroying the originally learned knowledge or features. For instance, many studies conduct fine-tuning of ResNets (He et al., 2016b) with these default hyperparameters: learning rate 0.01, momentum 0.9 and weight decay 0.0001. However, the default setting is not necessarily optimal for fine-tuning on other tasks. While few studies have performed extensive hyperparameter search for learning rate and weight decay (Mahajan et al., 2018; Kornblith et al., 2019), the momentum coefficient is rarely changed. Though the effectiveness of the hyperparameters has been studied extensively for training a model from scratch, how to set the hyperparameters for fine-tuning is not yet fully understood.
In addition to using ad-hoc hyperparameters, commonly held beliefs for fine-tuning also include:
• Fine-tuning pre-trained networks outperforms training from scratch; recent work (He et al., 2019) has already revisited this. • Fine-tuning from similar domains and tasks works better (Ge & Yu, 2017; Cui et al., 2018; Achille et al., 2019; Ngiam et al., 2018). • Explicit regularization with initial models matters for transfer learning performance (Li et al., 2018; 2019).
Are these practices or beliefs always valid? From an optimization perspective, the difference between fine-tuning and training from scratch is all about the initialization. However, the loss landscape of the pre-trained model and the fine-tuned solution could be much different, so as their optimization strategies and hyperparameters. Would the hyperparameters for training from scratch still be useful for fine-tuning? In addition, most of the hyperparameters (e.g., batch size, momentum, weight decay) are frozen; will the conclusion differ when some of them are changed?
With these questions in mind, we re-examined the common practices for fine-tuning. We conducted extensive hyperparameter search for fine-tuning on various transfer learning benchmarks with different source models. The goal of our work is not to obtain state-of-the-art performance on each fine-tuning task, but to understand the effectiveness of each hyperparameter for fine-tuning, avoiding unnecessary computation. We explain why certain hyperparameters work so well on certain datasets while fail on others, which can guide hyperparameter search for fine-tuning.
Our main findings are as follows:
• Optimal hyperparameters for fine-tuning are not only dataset dependent, but are also dependent on the similarity between the source and target domains, which is different from training from scratch. Therefore, the common practice of using optimization schedules derived from ImageNet training cannot guarantee good performance. It explains why some tasks are not achieving satisfactory results after fine-tuning because of inappropriate hyperparameter selection. Specifically, as opposed to the common practice of rarely tuning the momentum value beyond 0.9, we find that zero momentum sometimes work better for fine-tuning on tasks that are similar with the source domain, while nonzero momentum works better for target domains that are different from the source domain. Hyperparameters are coupled together and it is the effective learning rate—which encapsulates the learning rate and momentum—that matters for fine-tuning performance. While effective learning rate has been studied for training from scratch, to the best of our knowledge, no previous work investigates effective learning rate for fine-tuning and is less used in practice. Our observation of momentum can be explained as small momentum actually decreases the effective learning rate, which is more suitable for fine-tuning on similar tasks. We show that the optimal effective learning rate depends on the similarity between the source and target domains. We find regularization methods that were designed to keep models close to the initial model does not necessarily work for “dissimilar” datasets, especially for nets with Batch Normalization. Simple weight decay can result in as good performance as the referencebased regularization methods for fine-tuning with better search space.
# 2 RELATED WORK
In transfer learning for image classification, the last layer of a pre-trained network is usually replaced with a randomly initialized fully connected layer with the same size as the number of classes in the target task (Simonyan & Zisserman, 2015). It has been shown that fine-tuning the whole network usually results in better performance than using the network as a static feature extractor (Yosinski et al., 2014; Donahue et al., 2014; Huh et al., 2016; Mormont et al., 2018; Kornblith et al., 2019). Ge & Yu (2017) select images that have similar local features from source domain to jointly fine-tune pre-trained networks. Cui et al. (2018) estimate domain similarity with ImageNet and demonstrate that transfer learning benefits from pre-training on a similar source domain. Besides image classification, many object detection frameworks also rely on fine-tuning to improve over training from scratch (Girshick et al., 2014; Ren et al., 2015).
Many researchers re-examined whether fine-tuning is a necessity for obtaining good performance. Ngiam et al. (2018) find that when domains are mismatched, the effectiveness of transfer learning is negative, even when domains are intuitively similar. Kornblith et al. (2019) examine the fine-tuning performance of various ImageNet models and find a strong correlation between ImageNet top-1 accuracy and the transfer accuracy. They also find that pre-training on ImageNet provides minimal benefits for some fine-grained object classification dataset. He et al. (2019) questioned whether ImageNet pre-training is necessary for training object detectors. They find the solution of training from scratch is no worse than the fine-tuning counterpart as long as the target dataset is large enough. Raghu et al. (2019) find that transfer learning has negligible performance boost on medical imaging applications, but speed up the convergence significantly.
There are many literatures on hyperparameter selection for training neural networks from scratch, mostly on batch size, learning rate and weight decay (Goyal et al., 2017; Smith et al., 2018; Smith & Topin, 2019). There are few works on the selection of momentum (Sutskever et al., 2013). Zhang & Mitliagkas (2017) proposed an automatic tuner for momentum and learning rate in SGD. There are also studies on the correlations of the hyperparameters, such as linear scaling rule between batch size and learning (Goyal et al., 2017; Smith et al., 2018; Smith, 2017). However, most of these advances on hyperparameter tuning are designed for training from scratch and have not examined on fine-tuning tasks for computer vision problems. Most work on fine-tuning simply choose fixed hyperparameters (Cui et al., 2018) or use dataset-dependent learning rates (Li et al., 2018) in their experiments. Due to the huge computational cost for hyperparameter search, only a few works (Kornblith et al., 2019; Mahajan et al., 2018) performed large-scale grid search of learning rate and weight decay for obtaining the best performance.
# 3 TUNING HYPERPARAMETERS FOR FINE-TUNING
In this section, we first introduce the notations and experimental settings, and then present our observations on momentum, effective learning rate and regularization. The fine-tuning process is not different from learning from scratch except for the weights initialization. The goal of the process is still to minimize the objective function L = 1N PNi=1 \` $\begin{array} { r } { L = \frac { 1 } { N } \sum _ { i = 1 } ^ { N } \ell ( f ( x _ { i } , \theta ) , y _ { i } ) + \frac { \lambda } { 2 } \| \theta \| _ { 2 } ^ { 2 } } \end{array}$ , where $\ell$ is the loss function, $N$ is the number of samples, $x _ { i }$ is the input data, $y _ { i }$ is its label, $f$ is the neural network, $\theta$ is the model parameters and $\lambda$ is the regularization hyperparameter or weight decay. Momentum is widely used for accelerating and smoothing the convergence of SGD by accumulating a velocity vector in the direction of persistent loss reduction (Polyak, 1964; Sutskever et al., 2013; Goh, 2017). The commonly used Nesterov’s Accelerated Gradient (Nesterov, 1983) is given by:
$$\begin{array} { l } { { \displaystyle v _ { t + 1 } = m v _ { t } - \eta _ { t } \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \nabla \ell \big ( f \big ( x _ { i } , \theta _ { t } + m v _ { t } \big ) , y _ { i } \big ) } } \\ { { \theta _ { t + 1 } = \theta _ { t } + v _ { t + 1 } - \eta \lambda \theta _ { t } } } \end{array}$$
where $\theta _ { t }$ indicates the model parameters at iteration $t$ . The hyperparameters include the learning rate $\eta _ { t }$ , batch size $n$ , momentum coefficient $m \in [ 0 , 1 )$ , and the weight decay $\lambda$ .
# 3.1 EXPERIMENTAL SETTINGS
We evaluate fine-tuning on seven widely used image classification datasets, which covers tasks for fine-grained object recognition, scene recognition and general object recognition. Detailed statistics of each dataset can be seen in Table 1. We use ImageNet (Russakovsky et al., 2015), Places-365 (Zhou et al., 2018) and iNaturalist (Van Horn et al., 2018) as source domains for pre-trained models. We resize the input images such that the aspect ratio is preserved and the shorter side is 256 pixels. The images are normalized with mean and std values calculated over ImageNet. For data augmentation, we adopt the common practices used for training ImageNet models (Szegedy et al., 2015): random mirror, random scaled cropping with scale and aspect variations, and color jittering. The augmented images are resized to $2 2 4 \times 2 2 4$ . Note that state-of-the-art results could achieve even better performance by using higher resolution images (Cui et al., 2018) or better data augmentation (Cubuk et al., 2018).
We mainly use ResNet-101-V2 (He et al., 2016a) as our base network, which is pre-trained on ImageNet (Russakovsky et al., 2015). Similar observations are also made on DenseNets (Huang et al., 2017) and MobileNet (Howard et al., 2017). The hyperparameters to be tuned (and ranges)
Table 1: Datasets statistics. For the Caltech-256 dataset, we randomly sampled 60 images for each class following the procedure used in (Li et al., 2018). For the Aircraft and Flower dataset, we combined the original training set and validation set and evaluated on the test set. For iNat 2017, we combined the original training set and $90 \%$ of the validation set following (Cui et al., 2018).
<table><tr><td>Datasets</td><td>Task Category</td><td>Classes</td><td>Training</td><td>Test</td></tr><tr><td>Oxford Flowers (Nilsback & Zisserman, 2008)</td><td>fine-grained object recog.</td><td>102</td><td>2,040</td><td>6,149</td></tr><tr><td>CUB-Birds 200-2011 (Wah et al., 2011)</td><td>fine-grained object recog.</td><td>200</td><td>5,994</td><td>5,794</td></tr><tr><td>FGVC Aircrafts (Maji et al., 2013)</td><td>fine-grained object recog.</td><td>100</td><td>6,667</td><td>3,333</td></tr><tr><td>Stanford Cars (Krause etal., 2013)</td><td>fine-grained object recog.</td><td>196</td><td>8,144</td><td>8,041</td></tr><tr><td>Stanford Dogs (Khosla et al., 2011)</td><td>fine-grained object recog.</td><td>120</td><td>12.000</td><td>8,580</td></tr><tr><td>MIT Indoor-67 (Sharif Razavian et al., 2014)</td><td>scene classification</td><td>67</td><td>5,360</td><td>1,340</td></tr><tr><td>Caltech-256-60 (Griffin et al., 2007)</td><td>general object recog.</td><td>256</td><td>15,360</td><td>15,189</td></tr><tr><td>iNaturalist 2017 (Van Horn et al., 2018)</td><td>fine-grained object recog.</td><td>5,089</td><td>665,571</td><td>9,599</td></tr><tr><td>Place365 (Zhou et al., 2018)</td><td>scene classification</td><td>365</td><td>1,803,460</td><td>36,500</td></tr></table>
are: learning rate (0.1, 0.05, 0.01, 0.005, 0.001, 0.0001), momentum (0.9, 0.99, 0.95, 0.9, 0.8, 0.0) and weight decay (0.0, 0.0001, 0.0005, 0.001). We set the default hyperparameters to be batch size $2 5 6 ^ { 1 }$ , learning rate 0.01, momentum 0.9 and weight decay 0.0001. To avoid insufficient training and observe the complete convergence behavior, we use 300 epochs for fine-tuning and 600 epochs for scratch-training, which is long enough for the training curves to converge. The learning rate is decayed by a factor of 0.1 at epoch 150 and 250. We report the Top-1 validation (test) error at the end of training. The total computation time for the experiments is more than 10K GPU hours.
# 3.2 EFFECT OF MOMENTUM AND DOMAIN SIMILARITY
Momentum 0.9 is the most widely used value for training from scratch (Krizhevsky et al., 2012; Simonyan & Zisserman, 2015; He et al., 2016b) and is also widely adopted for fine-tuning (Kornblith et al., 2019). To the best of our knowledge, it is rarely changed, regardless of the network architectures or target tasks. To check the influence of momentum on fine-tuning, we first search for the best momentum value for fine-tuning on the Birds dataset with different weight decay and learning rate. Figure 1(a) shows the performance of fine-tuning with and without weight decays. Surprisingly, momentum zero actually outperforms the nonzero momentum. The optimal learning rate also increases when the momentum is disabled as shown in Figure 1(b).
 Figure 1: (a) Searching for the optimal momentum on Birds dataset with fixed learning rate 0.01 and different weight decays. Detailed learning curves and results of other hyperparameters can be found in Appendix A. (b) Comparison of momentum 0.9 and 0.0 with different learning rates on the Birds dataset, $\lambda$ is fixed at 0.0001.
To verify this observation, we further compare momentum 0.9 and 0.0 on other datasets. Table 2 shows the performance of 8 hyperparameter settings on 7 datasets. We observe a clear pattern that disabling momentum works better for Dogs, Caltech and Indoor, while momentum 0.9 works better for Cars, Aircrafts and Flowers.
Table 2: Top-1 validation errors on seven datasets by fine-tuning ImageNet pre-trained ResNet-101 with different hyperparmeters. Each row represents a network fine-tuned by a set of hyperparameters (left four columns). The datasets are ranked by the relative improvement by disabling momentum. The lowest error rates with the same momentum are marked as bold. Note that the performance difference for Birds is not very significant.
<table><tr><td>m</td><td>n</td><td>入</td><td>Dogs</td><td>Caltech</td><td>Indoor</td><td>Birds</td><td>Cars</td><td>Aircrafts</td><td>Flowers</td></tr><tr><td>0.9</td><td>0.01</td><td>0.0001</td><td>17.20</td><td>14.85</td><td>23.76</td><td>18.10</td><td>9.10</td><td>17.55</td><td>3.12</td></tr><tr><td>0.9</td><td>0.01</td><td>0</td><td>17.41</td><td>14.51</td><td>24.59</td><td>18.42</td><td>9.60</td><td>17.40</td><td>3.33</td></tr><tr><td>0.9</td><td>0.005</td><td>0.0001</td><td>14.14</td><td>13.42</td><td>24.59</td><td>17.24</td><td>9.08</td><td>18.21</td><td>3.50</td></tr><tr><td>0.9</td><td>0.005</td><td>0</td><td>14.80</td><td>13.67</td><td>22.79</td><td>17.54</td><td>9.31</td><td>17.82</td><td>3.53</td></tr><tr><td>0</td><td>0.01</td><td>0.0001</td><td>11.00</td><td>12.11</td><td>21.14</td><td>17.41</td><td>11.07</td><td>20.58</td><td>5.48</td></tr><tr><td>0</td><td>0.01</td><td>0</td><td>10.87</td><td>12.16</td><td>21.29</td><td>17.21</td><td>10.65</td><td>20.46</td><td>5.25</td></tr><tr><td>0</td><td>0.005</td><td>0.0001</td><td>10.21</td><td>11.86</td><td>21.96</td><td>18.24</td><td>13.22</td><td>24.39</td><td>7.03</td></tr><tr><td>0</td><td>0.005</td><td>0</td><td>10.12</td><td>11.61</td><td>20.76</td><td>18.40</td><td>13.11</td><td>23.91</td><td>6.78</td></tr></table>
Table 3: Verification of the effect of momentum on other source domains rather than ImageNet. The hyperparameters are $n = 2 5 6$ , $\eta = 0 . 0 1$ , and $\lambda = 0 . 0 0 0 1$ . Momentum 0 works better for transferring from iNat-2017 to Birds and transferring from Places-365 to Indoor comparing to momentum 0.9 counterparts.
<table><tr><td>Source domain</td><td>m</td><td>Indoor</td><td>Birds</td><td>Dogs</td><td>Caltech</td><td>Cars</td><td>Aircrafts</td></tr><tr><td rowspan="2">iNat-2017</td><td>0.9</td><td>30.73</td><td>14.69</td><td>24.74</td><td>20.12</td><td>11.16</td><td>19.86</td></tr><tr><td>0</td><td>34.11</td><td>12.29</td><td>23.87</td><td>21.47</td><td>16.89</td><td>27.21</td></tr><tr><td rowspan="2">Places-365</td><td>0.9</td><td>22.19</td><td>27.72</td><td>30.84</td><td>22.53</td><td>11.06</td><td>21.27</td></tr><tr><td>0</td><td>20.16</td><td>32.17</td><td>32.47</td><td>22.60</td><td>14.67</td><td>25.29</td></tr></table>
Interestingly, datasets such as Dogs, Caltech, Indoor and Birds are known to have high overlap with ImageNet dataset2, while Cars and Aircrafts are identified to be difficult to benefit from fine-tuning from pre-trained ImageNet models (Kornblith et al., 2019). According to Cui et al. (2018), in which the Earth Mover’s Distance (EMD) is used to calculate the similarity between ImageNet and other domains, the similarity to Dogs and Birds are 0.619 and 0.563, while the similarity to Cars, Aircrafts and Flowers are 0.560, 0.556 and $0 . 5 2 5$ . The relative order of similarities to ImageNet is
Dogs, Birds, Cars, Aircrafts and Flowers
which aligns well with the transition of optimal momentum value from 0.0 to 0.9. Following the similarity calculation, we can also verified Caltech and Indoor are more close to ImageNet than Cars/Aircrafts/Flowers (Table 3.3).
To verify the connection between momentum and domain similarity, we further fine-tune from different source domains such as Places-365 and iNaturalist, which are known to be better source domains than ImageNet for fine-tuning on Indoor and Birds dataset (Cui et al., 2018). We may expect that fine-tuning from iNaturalist works better for Birds with $m = 0$ and similarly, Places for Indoor. Indeed, as shown in Table 3, disabling momentum improves the performance when the source and target domain are similar, such as Places for Indoor and iNaturalist for Birds.
Small momentum works better for fine-tuning on domains that are close to the source domain One explanation for the above observations is that because the Dogs dataset is very close to ImageNet, the pre-trained ImageNet model is expected to be close to the fine-tuned solution on the Dogs dataset. In this case, momentum may not help much as the gradient direction around the minimum could be much random and accumulating the momentum direction could be meaningless. Whereas, for faraway target domains (e.g., Cars and Aircrafts) where the pre-trained ImageNet model could be much different with the fine-tuned solution, the fine-tuning process is more similar with training from scratch, where large momentum stabilizes the decent directions towards the minimum. An illustration of the difference can be found in Figure 2.
 Figure 2: An illustration of the effect of momentum on different fine-tuning scenarios from the loss-landscape perspective. The red point is the pre-trained model and the blue point is the fine-tuned solution. The dashed lines are loss contours. Assuming the step size is fixed, large momentum accelerates the convergence when the initialization is far from the minimum ((a) and (b)). On the contrary, large momentum may impede the convergence as shown in (c) and (d) when the initialization is close to the minimum.
Connections to early observations on decreasing momentum Early work (Sutskever et al., 2013) actually pointed out that reducing momentum during the final stage of training allows finer convergence while aggressive momentum would prevent this. They recommended reducing momentum from 0.99 to 0.9 in the last 1000 parameter updates but not disabling it completely. Recent work (Liu et al., 2018; Smith, 2018) showed that a large momentum helps escape from saddle points but can hurt the final convergence within the neighborhood of the optima, implying that momentum should be reduced at the end of training. Liu et al. (2018) find that a larger momentum introduces higher variance of noise and encourages more exploration at the beginning of optimization, and encourages more aggressive exploitation at the end of training. They suggest that at the final stage of the step size annealing, momentum SGD should use a much smaller step size than that of vanilla SGD. When applied to fine-tuning, we can interpret that if the pre-trained model lies in the neighborhood of the optimal solution on the target dataset, the momentum should be small. Our work identifies the empirical evidence of disabling momentum helps final convergence, and fine-tuning on close domains is a good exemplar.
# 3.3 COUPLED HYPERPARAMETERS AND THE VIEW OF EFFECTIVE LEARNING RATE
Now that we had discovered the effect of momentum by fixing other hyperparameters and only allowed momentum to change. But note that the two difficult scenarios shown in Figure 2 (b) and (c) might also be mitigated by increasing or decreasing learning rate. That is, hyperparameters are coupled and varying one hyperparameter can change the optimal values of the other hyperparameters that lead to the best performance. In addition, optimal values of certain hyperparameters depend on the values of other hyperparameters in systematic ways. For example, learning rate is entangled with batch size, momentum and weight decay. There is a notion of effective learning rate (ELR) (Hertz et al., 1991; Smith et al., 2018; Smith & Le, 2018) for SGD with momentum: $\eta ^ { \prime } = \eta / ( 1 - m )$ , which was shown to be more closely related with training dynamics and final performance rather than $\eta$ . The effective learning rate with $m = 0 . 9$ is $1 0 \times$ higher than the one with $m = 0 . 0$ if other hyperparameters are fixed, which is probably why we see an increase in optimal learning rate when momentum is disabled in Figure 1(b) and Appendix A.
 Figure 3: The effect of momentum w/ and w/o fixing ELR $\eta ^ { \prime }$ . When $\eta ^ { \prime }$ is the same, momentum 0 and 0.9 are almost equivalent. If $\eta ^ { \prime }$ is allowed to change, there is almost no difference between optimal performance obtained by different $m$ .
It is the effective learning rate that matters for fine-tuning performance Because hyperparameters are coupled, looking at the performance with only one hyperparameter varied may give a misleading understanding of the effect of hyperparameters. Therefore, to examine the effect of momentum, we should report the best result obtainable with and without momentum, as long as other hyperparameters explored are sufficiently explored. We re-examine previous experiments that demonstrated the importance of momentum tuning when the ELR $\eta ^ { \prime } \bar { = } \eta / ( 1 - \bar { m } )$ is held fixed instead of simply fixing learning rate $\eta$ . Figure 3 shows that when $\eta ^ { \prime }$ is constant, the best performance obtained by $m = 0 . 9$ and $m = 0$ are almost equivalent when other hyperparameters are allowed to change. However, different ELR does result in different performance, which indicates its importance for the best performance. It explains why the common practice of changing only learning rate generally works, though changing momentum may results in the same result, they both change the ELR. In fact, as long as the initial learning rate is small enough, we can always search for the optimal momentum as it is an amplifier, making the ELR larger by a factor of $1 / ( 1 - m )$ . Therefore, momentum does determine the search ranges of learning rate.
Optimal ELR depends on the similarity between source domain and target domain Now that we have shown ELR is critical for fine-tuning performance, we are interested in the factors that determine the optimal ELR for a given task. Previous work (Smith & Le, 2018) found that there is an optimum ELR which maximizes the test accuracy. However, the observations are only based on scratch training on small datasets (e.g., CIFAR-10); the relationship between ELR and domain similarity, especially for fine-tuning, is still unexplored. To examine this, we search the best ELR on each fine-tuning task and reports in Fig. 4 the best validation error obtained by each ELR while allowing other hyperparameters to change. It shows the optimal ELR depends on both source domain and target domain. As shown in Fig. 4 (a-c), the optimal ELR for Dogs/Caltech/Indoor are much smaller than these for Aircrafts/Flowers/Cars when fine-tuned from ImageNet pre-trained model. Similar observations can be made on DenseNets and MobileNet. Though the optimal ELR value is different, the relative order of domain similarity is consistent and architecture agnostic. We can also see a smaller ELR works better when source domain and target domain are similar, such as Dogs for ImageNet and Birds for iNat2017 (Fig. 4 (a, d-e)). Interestingly, the optimal ELR for training from scratch is much larger and very similar across different target datasets, which indicates the distance from a random initialization is uniformly similar to different target dataset.
 Figure 4: The best validation errors obtained by different ELRs for different source-target domains. Note that the optimal ELR for each target dataset falls in the interior of search space. Each point in (a-e) is the lowest validation error obtained with different weight decay values while ELR is fixed. The first row suggests that the connection between optimal ELR and domain similarity is architecture agnostic. The second row verifies that optimal ELR depends on the similarity between source domain and target domain.
Table 4: The connection between domain similarity and optimal ELR. The values in the second column is provided by Cui et al. (2018), in which JFT pretrained ResNet-101 was used as the feature extractor. Note that neither the pre-trained model or the dataset is released and we cannot calculate the metric for other datasets. In other columns, we calculate domain similarity using ImageNet pre-trained model as the feature extractor. The 1st, 2nd, 3rd and 4th highest scores are color coded. The optimal ELRs are also listed, which corresponds to the values in Fig 4.
<table><tr><td rowspan="3"></td><td>JFT</td><td colspan="4">ImageNet</td><td colspan="2">iNat2017</td><td colspan="2">Places365</td></tr><tr><td>ResNet-101</td><td>ResNet-101</td><td colspan="2">DenseNet-121</td><td colspan="2">MobileNet</td><td colspan="2">ResNet-101</td><td colspan="2">ResNet-101</td></tr><tr><td>sim</td><td>sim 川</td><td>sim</td><td>八</td><td>sim</td><td>八</td><td>sim</td><td>川</td><td>sim</td><td>川</td></tr><tr><td>Dogs</td><td>0.619</td><td>0.862 0.001</td><td>0.851</td><td>0.01</td><td>0.852</td><td>0.01</td><td>0.854</td><td>0.05</td><td>0.856</td><td>0.5</td></tr><tr><td>Caltech</td><td>-</td><td>0.892 0.005</td><td>0.881</td><td>0.01</td><td>0.878</td><td>0.01</td><td>0.871</td><td>0.1</td><td>0.888</td><td>0.05</td></tr><tr><td>Indoor</td><td>-</td><td>0.856 0.01</td><td>0.850</td><td>0.05</td><td>0.839</td><td>0.01</td><td>0.843</td><td>0.1</td><td>0.901</td><td>0.05</td></tr><tr><td>Birds</td><td>0.563</td><td>0.860 0.05</td><td>0.842</td><td>0.05</td><td>0.849</td><td>0.1</td><td>0.901</td><td>0.005</td><td>0.861</td><td>0.5</td></tr><tr><td>Cars</td><td>0.560</td><td>0.845 0.5</td><td>0.831</td><td>0.5</td><td>0.830</td><td>1.0</td><td>0.847</td><td>1.0</td><td>0.864</td><td>1.0</td></tr><tr><td>Aircrafts</td><td>0.556</td><td>0.840 1.0</td><td>0.817</td><td>0.1</td><td>0.831</td><td>1.0</td><td>0.846</td><td>0.5</td><td>0.853</td><td>0.5</td></tr><tr><td>Flowers</td><td>0.525</td><td>0.844 0.1</td><td>0.821</td><td>0.5</td><td></td><td>0.825 0.1</td><td>0.879</td><td>0.1</td><td>0.851</td><td>1.0</td></tr></table>
Optimal ELR selection based on domain similarity Now we have made qualitative observations about the relationship between domain similarity and optimal ELR. A quantitative characterization of the relationship could reduce the hyperparameter search ranges for HPO or even eliminate HPO by accurately predicting hyperparameters. We followed the domain similarity calculation in (Cui et al., 2018) and recalculate similarity scores for all source-target domain pairs. Note the original domain similarity calculation in (Cui et al., 2018) use pre-trained JFT (Sun et al., 2017) models as feature extractor, which are not public available. We alternatively use ImageNet pre-trained model or the source model as feature extractor. As shown in Table 4, there is a good correlation between domain similarity score and the scale of optimal ELR. Generally, the more similar the two domains, the smaller the optimal ELR. Though it is not strictly corresponding to the domain similarity score, the score provides reasonable prediction about the scale of optimal ELR, such as [0.001, 0.01], [0.01, 0.1], [0.1, 1.0] and therefore can reduce the search space for optimal ELR. Based on this correlation, a simple strategy can be developed for optimal ELR selection given a frequently used source model: one can calculate domain similarities and perform exhaustive hyperparameter searches for few reference datasets, including similar and dissimilar datasets. Then given a new dataset to fine-tune, one can calculate the domain similarity and compare with the scores of reference datasets, and choose the range of ELRs with the closest domain similarity.
Weight Decay and Learning Rate The relationship between weight decay and effective learning rate is recently well-studied (van Laarhoven, 2017; Zhang et al., 2018; Loshchilov & Hutter, 2018). It was shown that the effect of weight decay on models with BN layers is equivalent to increasing the ELR by shrinking the weights scales, i.e., $\eta ^ { \prime } \sim \eta / \| \theta \| _ { 2 } ^ { 2 }$ . And if the optimal effective learning rate exists, the optimal weight decay value $\lambda$ is inversely related with the optimal learning rate $\eta$ . The ‘effective’ weight decay is $\lambda ^ { \prime } = \lambda / \eta$ . We show in Figure 5 that the optimal effective weight decay is also correlated with domain similarity.
 Figure 5: The relationship between optimal effective weight decay and source datasets. The optimal effective weight decay is larger when the source domain is similar with the target domain.
# 3.4 THE CHOICE OF REGULARIZATION
$L _ { 2 }$ regularization or weight decay is widely used for constraining the model capacity (Hanson & Pratt, 1989; Krogh & Hertz, 1992). Recently Li et al. (2018; 2019) pointed out that standard $L _ { 2 }$ regularization, which drives the parameters towards the origin, is not adequate in transfer learning. To retain the knowledge learned by the pre-trained model, reference-based regularization was used to regularize the distance between fine-tuned weights and the pre-trained weights, so that the finetuned model is not too different from the initial model. Li et al. (2018) propose $L _ { 2 }$ -SP norm, i.e., $\begin{array} { r } { \frac { \lambda _ { 1 } } { 2 } \| \theta ^ { \prime } - \theta _ { 0 } \| _ { 2 } ^ { 2 } + \frac { \lambda _ { 2 } } { 2 } \| \theta ^ { \prime \prime } \| _ { 2 } ^ { 2 } } \end{array}$ , where $\theta ^ { \prime }$ refers to the part of network that shared with the source network, and $\theta ^ { \prime \prime }$ refers to the novel part, e.g., the last layer with different number of neurons. While the motivation is intuitive, there are several issues for adopting reference based regularization for fine-tuning:
• Many applications actually adopt fine-tuning on target domains that are quite different from source domain, such as fine-tuning ImageNet models for medical imaging (Mormont et al., 2018; Raghu et al., 2019). The fine-tuned model does not necessarily have to be close with the initial model. • The scale invariance introduced by Batch Normalization (BN) (Ioffe & Szegedy, 2015) layers enable models with different parameter scales to function the same, i.e., $\dot { f } ( \theta ) = f ( \overset { \cdot } { \alpha } \theta )$ . Therefore, when $L _ { 2 }$ regularization drives $\| \theta \| _ { 2 } ^ { 2 }$ towards zeros, it could still have the same functionality as the initial model. On the contrary, a model could still be different even when the $L _ { 2 }$ -SP norm is small. • $L _ { 2 }$ -SP regularization would constrain $\theta ^ { \prime \prime }$ to be close to $\theta _ { 0 }$ , so that $\| \theta \| _ { 2 } ^ { 2 }$ is relatively stable in comparison with $L _ { 2 }$ regularization. Given that ELR is approximately proportional to $\eta / \lVert \boldsymbol { \theta } \rVert _ { 2 } ^ { 2 }$ and a smaller ELR is beneficial for fine-tuning from similar domains, it may explain why $L _ { 2 }$ -SP provides better performance. If this is true, then by decreasing the initial ELR, $L _ { 2 }$ -norm may function the same.
To examine these conjectures, we revisited the work of (Li et al., 2018) with additional experiments. To show the effectiveness of $L _ { 2 }$ -SP norm, the authors conducted experiments on datasets such as Dogs, Caltech and Indoor, which are all close to the source domain (ImageNet or Places-365). We extend their experiments by fine-tuning on both “similar” and “dissimilar” datasets, including Birds, Cars, Aircrafts and Flowers, with both $L _ { 2 }$ and $L _ { 2 }$ -SP regularization (details in Appendix D). For fair comparison, we perform the same hyperparameter search for both methods. As expected, Table 5 shows that $L _ { 2 }$ regularization is very competitive with $L _ { 2 }$ -SP on Birds, Cars, Aircrafts and Flowers, which indicates that reference based regularization may not generalize well for fine-tuning on dissimilar domains.
Table 5: The average class error of (Li et al., 2018) and the extension of their experiments of on “dissimilar” datasets. The italic datasets and numbers are our experimental results. Note that the original Indoor result is fine-tuned from Places-365, while we fine-tune just from ImageNet pre-trained models.
<table><tr><td>Method</td><td>Dogs</td><td>Caltech</td><td>Indoor</td><td>Birds</td><td>Cars</td><td>Flowers</td><td>Aircrafts</td></tr><tr><td>L2 (Li et al., 2018)</td><td>18.6</td><td>14.7</td><td>20.4</td><td>1</td><td></td><td>-</td><td></td></tr><tr><td>L2-SP (Li et al., 2018)</td><td>14.9</td><td>13.6</td><td>15.8</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>L2 with HPO</td><td>16.79</td><td>14.98</td><td>23.00</td><td>22.51</td><td>10.10</td><td>5.70</td><td>13.03</td></tr><tr><td>L2-SP with HPO</td><td>13.86</td><td>14.45</td><td>21.77</td><td>22.32</td><td>9.59</td><td>5.28</td><td>13.31</td></tr></table>
We also check the change of regularization terms during training for both methods as well as their best hyperparameters. As shown in Figure 6, the $L _ { 2 }$ regularization usually decrease the weights norm more aggressively, depending on the value of $\lambda$ , while $L _ { 2 }$ -SP regularization keeps the norm less changed. We can see that the optimal learning rate of $L _ { 2 }$ regularization is mostly smaller than $L _ { 2 }$ -SP, which may compensate for the decreased weight norm or increased ELR. Interestingly, for Dogs dataset, both regularization terms grow much larger after a few iterations and then become stable, which means constraining the weights to be close to initialization is not necessarily the reason for $L _ { 2 }$ -SP to work even for close domains. It also seems contradicting to previous finding (Zhang et al., 2018) that weight decay functions as increasing ELR by decreasing weight norms. However, it might be reasonable as large norm actually decreases the ELR, which could be helpful due to the close domain similarity between Dogs and ImageNet.
 Figure 6: The normalized $L _ { 2 }$ norm and $L _ { 2 }$ -SP norm during training. The $_ y$ -axis is the relative change of the regularization term in comparison to the initial value, i.e., $\ \overline { { | | { \theta } _ { t } | | _ { 2 } ^ { 2 } } } / \| \overline { { { \theta } } } _ { 0 } \| _ { 2 } ^ { 2 }$ for $L _ { 2 }$ norm and $( \lambda _ { 1 } \| \theta _ { t } ^ { \prime } - \theta _ { 0 } \| _ { 2 } ^ { 2 } +$ $\lambda _ { 2 } \| \theta _ { t } ^ { \prime \prime } \| _ { 2 } ^ { 2 } ) / ( \lambda _ { 2 } \| \theta _ { 0 } ^ { \prime \prime } \| _ { 2 } ^ { 2 } )$ for $\small { \cal L } _ { 2 } { \bf - S P }$ norm. Optimal hyperparameters are also given in the legend. Note that experiment uses batch size 64 instead of 256, which results in smaller optimal learning rate comparing to previous result.
# 4 DISCUSSION
The two extreme ways for selecting hyperparameters—performing exhaustive hyperparameter search or taking ad-hoc hyperparameters from scratch training—could be either too computationally expensive or yield inferior performance. Different from training from scratch, where the default hyperparameter setting may work well for random initialization, the choice of hyperparameters for fine-tuning is not only dataset dependent but is also influenced by the similarity between the target and source domains. The rarely tuned momentum value could also improve or impede the performance when the target domain and source domain are close given insufficiently searched learning rate. These observations connect with previous theoretical works on decreasing momentum at the end of training and effective learning rate. We further identify that the optimal effective learning rate correlates with the similarity between the source and target domains. With this understanding, one can significantly reduce the hyperparameter search space. We hope these findings could be one step towards better and efficient hyperparameter selection for fine-tuning.
# ACKNOWLEDGMENTS
The authors would like to thank all anonymous reviewers for their valuable feedback.
# REFERENCES
Alessandro Achille, Michael Lam, Rahul Tewari, Avinash Ravichandran, Subhransu Maji, Charless Fowlkes, Stefano Soatto, and Pietro Perona. Task2vec: Task embedding for meta-learning. arXiv preprint arXiv:1902.03545, 2019. Liang-Chieh Chen, George Papandreou, Iasonas Kokkinos, Kevin Murphy, and Alan L Yuille. Deeplab: Semantic image segmentation with deep convolutional nets, atrous convolution, and fully connected crfs. IEEE T-PAMI, 40(4):834–848, 2017. Ekin D Cubuk, Barret Zoph, Dandelion Mane, Vijay Vasudevan, and Quoc V Le. Autoaugment: Learning augmentation policies from data. arXiv preprint arXiv:1805.09501, 2018. Yin Cui, Yang Song, Chen Sun, Andrew Howard, and Serge Belongie. Large scale fine-grained categorization and domain-specific transfer learning. In CVPR, 2018. Jia Deng, Alexander C Berg, Kai Li, and Li Fei-Fei. What does classifying more than 10,000 image categories tell us? In ECCV, 2010.
Jeff Donahue, Yangqing Jia, Oriol Vinyals, Judy Hoffman, Ning Zhang, Eric Tzeng, and Trevor Darrell. Decaf: A deep convolutional activation feature for generic visual recognition. In ICML, 2014.
Weifeng Ge and Yizhou Yu. Borrowing treasures from the wealthy: Deep transfer learning through selective joint fine-tuning. In CPVR, 2017.
Ross Girshick, Jeff Donahue, Trevor Darrell, and Jitendra Malik. Rich feature hierarchies for accurate object detection and semantic segmentation. In CVPR, 2014.
Gabriel Goh. Why momentum really works. Distill, 2(4):e6, 2017.
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.
Gregory Griffin, Alex Holub, and Pietro Perona. Caltech-256 object category dataset. 2007.
Stephen Jose Hanson and Lorien Y. Pratt. Comparing biases for minimal network construction with back-propagation. In NIPS, 1989.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Identity mappings in deep residual networks. In ECCV, 2016a.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, 2016b.
Kaiming He, Georgia Gkioxari, Piotr Dollár, and Ross Girshick. Mask R-CNN. In ICCV, 2017.
Kaiming He, Ross Girshick, and Piotr Dollár. Rethinking imagenet pre-training. In ICCV, 2019.
John Hertz, A Krogh, and Richard G Palmer. Introduction to the theory of neural computation. 1991.
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.
Gao Huang, Zhuang Liu, Laurens Van Der Maaten, and Kilian Q Weinberger. Densely connected convolutional networks. In CVPR, 2017.
Minyoung Huh, Pulkit Agrawal, and Alexei A Efros. What makes imagenet good for transfer learning? arXiv preprint arXiv:1608.08614, 2016.
Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In ICML, 2015.
Aditya Khosla, Nityananda Jayadevaprakash, Bangpeng Yao, and Li Fei-Fei. Novel dataset for fine-grained image categorization. In First Workshop on Fine-Grained Visual Categorization, CVPR, 2011.
Simon Kornblith, Jonathon Shlens, and Quoc V Le. Do better imagenet models transfer better? In CVPR, 2019.
Jonathan Krause, Michael Stark, Jia Deng, and Li Fei-Fei. 3d object representations for fine-grained categorization. In 4th International IEEE Workshop on 3D Representation and Recognition (3dRR-13), Sydney, Australia, 2013.
Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. In NIPS, 2012.
Anders Krogh and John A Hertz. A simple weight decay can improve generalization. In NIPS, 1992.
Xingjian Li, Haoyi Xiong, Hanchao Wang, Yuxuan Rao, Liping Liu, and Jun Huan. Delta: Deep learning transfer using feature map with attention for convolutional networks. In ICLR, 2019.
Xuhong Li, Yves Grandvalet, and Franck Davoine. Explicit inductive bias for transfer learning with convolutional networks. In ICML, 2018.
Tianyi Liu, Zhehui Chen, Enlu Zhou, and Tuo Zhao. Toward deeper understanding of nonconvex stochastic optimization with momentum using diffusion approximations. arXiv preprint arXiv:1802.05155, 2018.
Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In ICLR, 2018.
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 ECCV, 2018.
S. Maji, J. Kannala, E. Rahtu, M. Blaschko, and A. Vedaldi. Fine-grained visual classification of aircraft. Technical report, 2013.
Romain Mormont, Pierre Geurts, and Raphaël Marée. Comparison of deep transfer learning strategies for digital pathology. In CVPR Workshops, 2018.
Yurixi E Nesterov. A method for solving the convex programming problem with convergence rate o $( 1 / \mathrm { k } ^ { \cdot } 2 )$ ). In Dokl. akad. nauk Sssr, volume 269, pp. 543–547, 1983.
Jiquan Ngiam, Daiyi Peng, Vijay Vasudevan, Simon Kornblith, Quoc V Le, and Ruoming Pang. Domain adaptive transfer learning with specialist models. arXiv preprint arXiv:1811.07056, 2018.
Maria-Elena Nilsback and Andrew Zisserman. Automated flower classification over a large number of classes. In Indian Conference on Computer Vision, Graphics & Image Processing. IEEE, 2008.
Boris T Polyak. Some methods of speeding up the convergence of iteration methods. USSR Computational Mathematics and Mathematical Physics, 4(5):1–17, 1964.
Maithra Raghu, Chiyuan Zhang, Jon Kleinberg, and Samy Bengio. Transfusion: Understanding transfer learning with applications to medical imaging. In NIPS, 2019.
Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. In NIPS, 2015.
Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, Alexander C. Berg, and Li Fei-Fei. ImageNet Large Scale Visual Recognition Challenge. IJCV, 115(3):211–252, 2015.
Ali Sharif Razavian, Hossein Azizpour, Josephine Sullivan, and Stefan Carlsson. Cnn features off-the-shelf: an astounding baseline for recognition. In CVPR workshops, pp. 806–813, 2014.
Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. In ICLR, 2015.
Leslie N Smith. Cyclical learning rates for training neural networks. In WACV, 2017.
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.
Leslie N Smith and Nicholay Topin. Super-convergence: Very fast training of neural networks using large learning rates. In Artificial Intelligence and Machine Learning for Multi-Domain Operations Applications, volume 11006, pp. 1100612. International Society for Optics and Photonics, 2019.
Samuel L Smith and Quoc V Le. A bayesian perspective on generalization and stochastic gradient descent. In ICLR, 2018.
Samuel L Smith, Pieter-Jan Kindermans, Chris Ying, and Quoc V Le. Don’t decay the learning rate, increase the batch size. In ICLR, 2018.
Chen Sun, Abhinav Shrivastava, Saurabh Singh, and Abhinav Gupta. Revisiting unreasonable effectiveness of data in deep learning era. In CVPR, 2017.
Ilya Sutskever, James Martens, George Dahl, and Geoffrey Hinton. On the importance of initialization and momentum in deep learning. In ICML, 2013.
Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. In CVPR, 2015.
Grant Van Horn, Oisin Mac Aodha, Yang Song, Yin Cui, Chen Sun, Alex Shepard, Hartwig Adam, Pietro Perona, and Serge Belongie. The inaturalist species classification and detection dataset. In CVPR, 2018.
Twan van Laarhoven. L2 regularization versus batch and weight normalization. In NIPS, 2017.
C. Wah, S. Branson, P. Welinder, P. Perona, and S. Belongie. The Caltech-UCSD Birds-200-2011 Dataset. Technical Report CNS-TR-2011-001, California Institute of Technology, 2011.
Junyuan Xie, Tong He, Zhi Zhang, Hang Zhang, Zhongyue Zhang, and Mu Li. Bag of tricks for image classification with convolutional neural networks. arXiv preprint arXiv:1812.01187, 2018.
Jason Yosinski, Jeff Clune, Yoshua Bengio, and Hod Lipson. How transferable are features in deep neural networks? In NIPS, 2014.
Guodong Zhang, Chaoqi Wang, Bowen Xu, and Roger Grosse. Three mechanisms of weight decay regularization. arXiv preprint arXiv:1810.12281, 2018.
Jian Zhang and Ioannis Mitliagkas. Yellowfin and the art of momentum tuning. arXiv preprint arXiv:1706.03471, 2017.
Bolei Zhou, Agata Lapedriza, Aditya Khosla, Aude Oliva, and Antonio Torralba. Places: A 10 million image database for scene recognition. IEEE T-PAMI, 40(6):1452–1464, 2018.
# A THE EFFECTIVENESS OF MOMENTUM
Searching for Optimal Momentum To check the effectiveness of momentum on fine-tuning, we can search the best momentum values for fine-tuning with fixed learning rate but different weight decay and batch size. Taking Birds dataset as an example, Figure 7 provides the convergence curves for the results shown in Figure 1(a), which shows the learning curves of fine-tuning with 6 different batch sizes and weight decay combinations. Zero momentum outperforms the nonzero momentum in 5 out of 6 configurations.
 Figure 7: Searching for the optimal momentum on Birds dataset with fixed learning rate and weight decays. The solid lines are training errors and the dashed lines are validation errors.
Effective learning rate increases after disabling momentum. Figure 8 compares the performance of with and without momentum for Dogs dataset with a range of different learning rates. Note that the learning rate with similar performance generally increases $1 0 \mathrm { x }$ after changing $m$ from 0.9 to 0.0, which is coherent with the rule of effective learning rate $\eta ^ { \prime } = \eta / ( 1 - m )$ . Same observations can be made on other datasets as shown in Figure 9.
 Figure 8: The effect of momentum when learning rate is allowed to change. The learning rate for the best performance increases 10x after changing $m$ from 0.9 to 0.0, which is coherent with the rule of effective learning rate. Note that weight decay $\lambda$ is fixed at 0.0001.
 Figure 9: The effect of momentum when learning rate is allowed to change (Figure 8 continued). The learning rate for the best performance increases $1 0 \mathrm { x }$ after changing $m$ from 0.9 to 0.0, which is coherent with the rule of effective learning rate.
# B DOMAIN SIMILARITY
The domain similarity calculation based on Earth Mover Distance (EMD) is introduced in the section 4.1 of (Cui et al., 2018)4. Here we briefly introduce the steps. In (Cui et al., 2018), the authors first train ResNet-101 on the large scale JFT dataset (Sun et al., 2017) and use it as a feature extractor. They extracted features from the penultimate layer of the model for each image of the training set of the source domain and target domain. For ResNet-101, the length of the feature vector is 2048. The features of images belonging to the same category are averaged and $g ( s _ { i } )$ denotes the average feature vector of ith label in source domain $S$ , similarly, $g ( t _ { j } )$ denotes the average feature vector of $j$ th label in target domain $T$ . The distance between the averaged features of two labels is $d _ { i , j } = \lVert g ( s _ { i } ) - g ( t _ { j } ) \rVert$ . Each label is associated with a weight $w \in [ 0 , 1 ]$ corresponding to the percentage of images with this label in the dataset. So the source domain $S$ with $m$ labels and the target domain $T$ with $n$ labels can be represented as ${ \cal { S } } = \{ ( s _ { i } , w _ { s _ { i } } ) \} _ { i = 1 } ^ { m }$ and $T = \{ ( t _ { j } , w _ { t _ { j } } ) \} _ { i = 1 } ^ { n }$ . The EMD between the two domains is defined as
$$d ( S , T ) = \operatorname { E M D } ( S , T ) = { \frac { \sum _ { i = 1 , j = 1 } ^ { m , n } f _ { i , j } d _ { i , j } } { \sum _ { i = 1 , j = 1 } ^ { m , n } f _ { i , j } } }$$
where the optimal flow $f _ { i , j }$ corresponds to the least amount of total work by solving the EMD optimization problem. The domain similarity is defined as
$$\sin ( S , T ) = e ^ { - \gamma d ( S , T ) }$$
where $\gamma$ is 0.01. Note that the domain similarity value is not ranging from 0 to 1.
Due to the unavailability of the large-scale JFT dataset ( $3 0 0 \mathrm { x }$ larger than ImageNet) and its pre-trained ResNet-101 model, we cannot use it for extracting features for new datasets, such as Caltech256 and
MIT67-Indoor. Instead of using the powerful feature representation, we use our pre-trained ImageNet model (ResNet-101) as the feature extractor. Table 4 compares the domain similarities calculated by different pre-trained models and we can see some consistent patterns across different architectures: e.g., The 1st and 2nd highest similarity scores are Caltech and Dogs regardless of architectures; the 3rd and 4th highest similarity scores refers to Birds and Indoor; the most dissimilar datasets are Cars, Aircrafts and Flowers, though the relative orders for them are not exactly the same. Besides using fixed feature extractor, an alternative way is to use the source domain model directly as the feature extractor for both source domain and target domain, which may captures the transfer learning process more precisely than a uniform feature extractor.
# C THE EFFECTIVENESS OF BN MOMENTUM
Kornblith et al. (2019) conducted extensive fine-tuning experiments with different hyperparameters. One observation they made is that the momentum parameter of BN layer is essential for finetuning. They found it useful to decrease the BN momentum parameter from its ImageNet value to $\operatorname* { m a x } ( 1 - \mathrm { \tilde { 1 0 } } / s , 0 . 9 )$ where $s$ is the number of steps per epoch. This will change the default BN momentum value (0.9) when $s$ is larger than 100, but it only applies when the dataset size is larger than 25.6K with batch size 256. The maximum data size used in our experiments is Caltech-256, which is 15K, so this strategy seems not applicable.
We further validate the effect of BN momentum by performing a similar study as to ELR. The goal is to identify whether there is an optimal BN momentum for a given task. For each dataset, we fine-tune the pre-trained model using previously obtained best hyperparameters and only vary BN momentum. In addition to the default value 0.9, we also set it to 0.0, 0.95 and 0.99. The rational is that if BN mommentum is a critical hyperparameter, we should expect significant performance differences when the value is changed from the optimal value. As shown in Figure 10, we can see $m _ { b n } = 0 . 9 9$ slightly improves the performance for some datasets, however, there is no significant performance difference among values greater than 0.9. One hypothesis is that similar domains will share similar BN parameters and statistics, BN momentum may affect the parameter adaptation. More investigation is still needed to fully understand its effectiveness.
 Figure 10: Performance of different BN momentum for each dataset with existing optimal hyperparameters.
# D EXPERIMENTAL SETTINGS FOR COMPARISON OF $L _ { 2 }$ AND $L _ { 2 }$ -SP
The experiments in Section 3.4 is based the code5 provided by (Li et al., 2018). The base network is ImageNet pretrained ResNet-101-V1. The model is fine-tuned with batch size 64 for 9000 iterations, and learning rate is decayed once at iteration 6000. Following the original setting, we use momentum 0.9. We performed grid search on learning rate and weight decay, with the range of $\eta : \{ 0 . 0 2 , 0 . 0 1 , 0 . 0 0 5 , 0 . 0 0 1 , 0 . 0 \bar { 0 } 0 1 \}$ and $\lambda _ { 1 } : \{ 0 . 1 , \bar { 0 . 0 1 } , 0 . 0 0 1 , 0 . 0 \bar { 0 } 0 1 \}$ , and report the best average class error (1 - average accuracy) for both methods. For $L _ { 2 }$ -SP norm, we follow the authors’ setting to use constant $\lambda _ { 2 } = 0 . 0 1$ . Different with the original setting for $L _ { 2 }$ regularization, we set $\lambda _ { 2 } = \lambda _ { 1 }$ to simulate normal $L _ { 2 }$ -norm.
# E DATA AUGMENTATION
Data augmentation is an important way of increasing data quantity and diversity to make models more robust. It is even critical for transfer learning with few instances. The effect of data augmentation can be viewed as a regularization and the choice of data augmentation can be also viewed as a hyperparameter. Most current widely used data augmentation methods have verified their effectiveness on training ImageNet models, such as random mirror flipping, random rescaled cropping6, color jittering and etc (Szegedy et al., 2015; Xie et al., 2018).
Do these methods transfer for fine-tuning on other datasets? Here we compare three settings for data augmentation with different momentum settings: 1) random resized cropping: our default data augmentation; 2) random cropping: the same as standard data augmentation except that we use random cropping with fixed size; 3) random flip: simply random horizontal flipping. The training and validation errors of fine-tuning with different data augmentation strategies and hyperparameters are shown in Figure 11 and Figure 12.
 Figure 11: Fine-tuning with different data augmentation methods and hyperparameters. Dashed curves are the validation errors. Strong data augmentation is harder to train as it converge slowly and needs more number of epochs to observe the advanced performance on datasets such as Aircrafts. Simple data augmentation (red curves) converges much faster in training error. Strong data augmentation (blue curves) overfits the Dogs dataset with default hyperparameter but performs well with $m = 0$ .
The effect of data augmentation is dataset dependent and is also influenced by other hyperparameters The first row in Figure 11 shows that advanced data augmentation with default hyperparameters ( $m = 0 . 9$ and $\eta = 0 . 0 1 $ ) leads to overfitting for Dogs while generalize better on Aircrafts and Flowers. Similar observations can be made in Figure 12. However, when momentum is disabled, the overfitting disappears for Dogs and Caltech. This is explainable since random resized cropping adds more variance to the gradient direction, and disabling momentum will lead to a smaller ELR which will be helpful for fine-tuning from a similar domain. On the other hand, the performance of random cropping decreases when momentum is disabled. As random cropping produces training samples with less variation than random resized cropping, disabling momentum or decreasing the ELR might lead to underfitting or stucking in poor local minima. This can be mitigated as we increase the learning rate for random cropping, which adds variation to the gradients. As shown in Table 6, when learning rate increased fro 0.01 to 0.05, disabling momentum shows better performance than nonzero momentum on datasets that are close, similar to previous findings with random resized cropping.
 Figure 12: Comparison of data augmentation methods with different momentum values (Figure 11 continued). The other hyperparameters are: $n = 2 5 6$ , $\eta = 0 . 0 1$ and $\lambda = 0 . 0 0 0 1$ .
Table 6: Comparison of data augmentation methods with different momentum values. The rest of the hyperparameters are: $n = 2 5 6$ and $\lambda = 0 . 0 0 0 1$ .
<table><tr><td colspan="2">Data Augmentation</td><td>m m</td><td>Dogs</td><td>Caltech</td><td>Indoor</td><td>Birds</td><td>Cars</td><td>Flowers</td><td>Aircrafts</td></tr><tr><td rowspan="2">Rand resized crop</td><td>0.9</td><td>0.01</td><td>17.20</td><td>14.85</td><td>23.76</td><td>18.10</td><td>9.10</td><td>3.12</td><td>17.55</td></tr><tr><td>0</td><td>0.01</td><td>11.00</td><td>12.11</td><td>21.14</td><td>17.41</td><td>11.06</td><td>5.48</td><td>20.58</td></tr><tr><td rowspan="4">Rand crop</td><td>0.9</td><td>0.01</td><td>11.99</td><td>12.42</td><td>23.39</td><td>20.31</td><td>17.77</td><td>5.63</td><td>21.72</td></tr><tr><td>0</td><td>0.01</td><td>11.35</td><td>12.89</td><td>25.19</td><td>22.11</td><td>23.87</td><td>7.76</td><td>29.04</td></tr><tr><td>0.9</td><td>0.05</td><td>16.85</td><td>14.80</td><td>23.46</td><td>18.81</td><td>13.70</td><td>4.85</td><td>17.64</td></tr><tr><td>0</td><td>0.05</td><td>11.79</td><td>12.52</td><td>23.24</td><td>20.69</td><td>20.00</td><td>7.06</td><td>23.43</td></tr></table>
# F SOURCE DOMAINS
Pre-trained models For most of our experiments, we use the pre-trained ResNet-101_v2 model from the model zoo of MXNet GluonCV 7. To get the pre-trained models for iNat-2017 and Places365, we fine-tune from the ImageNet pre-trained model with the default fine-tuning hyperparameters for 60 epochs, where learning rate is decayed at epoch 45 by a factor of 10. Table 7 illustrates the Top-1 errors of each pre-trained model on their validation sets.
Table 7: The Top-1 error of ResNet-101 pre-trained on different source dataset.
<table><tr><td>Dataset</td><td>class</td><td>Top-1 error</td></tr><tr><td>ImageNet</td><td>1000</td><td>21.4</td></tr><tr><td>iNat2017</td><td>5,089</td><td>32.2</td></tr><tr><td>Places-365</td><td>365</td><td>31.5</td></tr></table>
Training from Scratch with HPO The default hyperparameters for training from scratch are $\eta = 0 . 1$ , $\lambda = 0 . 0 0 0 1$ , $m = 0 . 9$ and $n = 2 5 6$ . We train 600 epochs, and decay the learning rate at epoch 400 and 550 by a factor of 10. To perform Hyperparameter Optimization (HPO), we search hyperparameters in the following space: $\eta \in [ 0 . 1 , 0 . 2 , 0 . 5 ]$ and $\lambda \in [ 0 . 0 0 0 1 , 0 . 0 0 0 5 ]$ . Figure 13 shows the training/validation errors of training from scratch on each dataset with different learning rate and weight decay. We observe weight decay 0.0005 consistently performs better than 0.0001.
Insufficient hyperparameter search may lead to miss-leading conclusion To show the importance of hyperparameter tuning, Table 8 compares the performance with and without hyperparameter tuning for both fine-tuning and training from scratch tasks. With the default hyperparameters, some inappropriate conclusions might be made, e.g., “there is significant gap between fine-tuning and training from scratch", “fine-tuning always surpass training from scratch" or “fine-tuning from iNat cannot beat the performance of ImageNet". However, with HPO, those statements may not be valid. For example, training from scratch surpass the default fine-tuning result on Cars and Aircrafts and the gap between fine-tuning and training from scratch is much smaller. Previous studies (Kornblith et al., 2019; Cui et al., 2018) also identified that datasets like Cars and Aircrafts do not benefit too much from fine-tuning.
Table 8: Comparison of default hyperparameters and HPO for both fine-tuning (FT) and training from scratch (ST) tasks. FT Default and ST Default use their default hyperparameters, respectively. HPO refers to the finding the best hyperparameters with grid search.
<table><tr><td>Method</td><td>Source</td><td>Dogs</td><td>Caltech</td><td>Indoor</td><td>Birds</td><td>Cars</td><td>Aircrafts</td><td>Flowers</td></tr><tr><td>FT Default</td><td>ImageNet</td><td>17.20</td><td>13.42</td><td>23.76</td><td>18.10</td><td>9.10</td><td>17.55</td><td>3.12</td></tr><tr><td>FT Default</td><td>iNat2017</td><td>24.74</td><td>20.12</td><td>30.73</td><td>14.69</td><td>11.16</td><td>19.86</td><td>3.19</td></tr><tr><td>FT Default</td><td>Places-365</td><td>30.84</td><td>22.53</td><td>22.19</td><td>27.72</td><td>11.06</td><td>21.27</td><td>5.66</td></tr><tr><td>ST Default</td><td>1</td><td>38.26</td><td>36.21</td><td>45.28</td><td>43.72</td><td>16.73</td><td>26.49</td><td>22.88</td></tr><tr><td>FT HPO</td><td>ImageNet</td><td>9.83</td><td>11.61</td><td>20.54</td><td>16.34</td><td>7.61</td><td>12.33</td><td>2.91</td></tr><tr><td>FT HPO</td><td>iNat2017</td><td>23.51</td><td>18.82</td><td>28.11</td><td>12.06</td><td>9.58</td><td>15.45</td><td>2.70</td></tr><tr><td>FT HPO</td><td>Places-365</td><td>26.24</td><td>22.14</td><td>19.42</td><td>22.90</td><td>9.13</td><td>15.48</td><td>5.06</td></tr><tr><td>ST HPO</td><td>1</td><td>29.32</td><td>29.62</td><td>39.36</td><td>30.08</td><td>8.37</td><td>14.34</td><td>16.51</td></tr></table>
 Figure 13: Training from scratch with various learning rate and weight decay. The batch size is 256 and the momentum is 0.9. The solid curves are training error and the dashed lines are valdiation error.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256# IMPROVING THE GENERALIZATION OF VISUAL NAVIGATION POLICIES USING INVARIANCE REGULARIZATION
Anonymous authors Paper under double-blind review
# ABSTRACT
Training agents to operate in one environment often yields overfitted models that are unable to generalize to the changes in that environment. However, due to the numerous variations that can occur in the real-world, the agent is often required to be robust in order to be useful. This has not been the case for agents trained with reinforcement learning $( R L )$ algorithms. In this paper, we investigate the overfitting of RL agents to the training environments in visual navigation tasks. Our experiments show that deep RL agents can overfit even when trained on multiple environments simultaneously. We propose a regularization method which combines RL with supervised learning methods by adding a term to the RL objective that would encourage the invariance of a policy to variations in the observations that ought not to affect the action taken. The results of this method, called invariance regularization, show an improvement in the generalization of policies to environments not seen during training.
# 1 INTRODUCTION
Learning control policies from high-dimensional sensory input has been gaining more traction lately due to the popularity of deep reinforcement learning (DRL) Mnih et al. (2015); Levine et al. (2015); Zhang et al. (2018b); Rakelly et al. (2019), which enables learning the perception and control modules simultaneously. However, most of the work done in RL chooses to evaluate the learned policies in the same environment in which training occurred Cobbe et al. (2018).
Using the same environments to train and test agents does not give any insight into the generalization abilities of the learned policy. There could be a number of changes in the environment at test time that would degrade the agent’s performance. Variations could appear in the visual aspects that determine the agent’s observation, the physical structure that determines the agent’s state and even some aspects that are related to the agent’s goal (Figure 1). For example, different observations of the same room are encountered at different times of the day (different lighting conditions). New obstacles could be present. Levels of a game could be different, yet playing a few levels should often be enough to figure out how to play the rest. Such variations might result in a new environment where the control model that defined the training environment has changed. A robust policy should generalize from its experience and perform the same skills in the presence of these variations.
DRL agents have been notorious for overfitting to their training environments Cobbe et al. (2018). An agent could have drastically different performance on testing environments even if it manages to maximize the reward during training Zhang et al. (2018a). Supervised learning algorithms have been shown to have some generalization guarantees when adding proper regularization Mohri et al. (2018). However, these guarantees are weakened in reinforcement learning algorithms where the source of the data is not i.i.d.. In order to make use of the progress of DRL algorithms in practice we need policies that are robust to possible changes in the sensory inputs, surrounding structure and even some aspects of the task.
In this paper we study the notion of generalization that is appropriate for visual navigation control policies that are learned with DRL. We present: (1) a study of the generalization of visual control policies to certain changes in the underlying dynamical system; (2) an alternative training method that combines DRL with supervised learning, thus using DRL to learn a controller while leveraging the generalization properties of supervised learning. In our experiments we use the VizDoom platform
Kempka et al. (2016) which is easily customizable and enables the generation of numerous variants of a given environment.
# 2 PRELIMINARIES
Visual navigation for mobile robots combines the domains of vision and control. Navigation can be described as finding a suitable and safe path between a starting state and a goal state Bonin-Font et al. (2008). Classical approaches split the problem into a sequence of sub-tasks, such as map construction, localization, planning and path following Bonin-Font et al. (2008). However, each sub-task requires some handengineering that is specific to the environment and task which makes it hard to adapt it to different scenarios without performing some tuning. Deep learning approaches enable the use of highly non-linear classifiers that can adapt their inner representations to learn to robustly solve complicated tasks Goodfellow et al. (2016).
In this work, we use reinforcement learning algorithms coupled with deep learning approaches to solve the task of navigating an agent towards
 Figure 1: The figure shows how environments may differ in their visual aspects, like textures of the surfaces. The textures provide a differentiator for each environment, where without them the environments would have shared the same state space.
a goal object using only its visual observations as input. The field of view of the agent is limited, i.e., it does not observe the full environment, and we do not provide an explicit map of the environment to that agent.
# 2.1 PROBLEM STATEMENT
We model the problem of visual navigation as a partially observed Markov decision process (POMDP) (Spaan, 2012). A POMDP is given by a tuple
$$\mathcal { P } : = \langle \mathcal { S } , \mathcal { A } , \Omega , R , T , O , P _ { 0 } \rangle ,$$
where $s$ is the set of states, $\mathcal { A }$ is the set of actions and $\Omega$ is the set of observations, all which are assumed to be finite sets. The reward function is $R : S \times A \to \mathbb { R }$ . The conditional transition probability mass function is $T : \mathcal { S } \times \mathcal { A } \times \mathcal { S } [ 0 , 1 ]$ , with the interpretation that $T ( s , a , s ^ { \prime } ) =$ $\bar { p } ( s _ { t + 1 } = \cdot | s _ { t } = s , a _ { t } = a )$ is the probability that the next state is $s ^ { \prime }$ given that the current state is $s$ and that action $a$ is taken. The conditional observation probability mass function is $O : S \times A \times \Omega [ 0 , 1 ]$ , with the interpretation that $O ( s , a , o ) = p \bar { ( } o _ { t } = o | s _ { t } = s , a _ { t - 1 } = a )$ is the probability of observing $o$ in state $s$ when the last action taken was $a$ , and we allow for a special observation probability $\bar { O ( s , o ) } = p ( o _ { 0 } = o | s _ { 0 } = s )$ when in the initial state $s$ and no action has yet been taken. Finally, $P _ { 0 }$ is the initial state probability mass function, so that $P _ { 0 } ( s ) = p ( s _ { 0 } = s )$ is the probability that the initial state is $s$ .
In DRL, we work with a parameterized policy $\pi _ { \boldsymbol { \theta } } ( h , a ) \ : = \ : p _ { \boldsymbol { \theta } } ( a _ { t } \ : = \ : a | h _ { t } \ : = \ : h )$ with parameters $\theta ~ \in ~ \Theta$ , giving the probability of taking action $a$ given observation-action history $h _ { t } \ : =$ $\left( o _ { 0 } , a _ { 0 } , o _ { 1 } , a _ { 1 } , \ldots , a _ { t - 1 } , o _ { t } \right)$ . The objective is to adjust the parameters $\theta$ to attain a high value for the discounted reward
$$J _ { \mathcal { P } } ( \theta ) : = \mathbb { E } _ { \mathcal { P } } ^ { \pi _ { \theta } } \left[ \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } R ( s _ { t } , a _ { t } ) \right]$$
with discount factor $\gamma ~ \in ~ [ 0 , 1 )$ . The expectation is over state-observation-action sequences $( s _ { t } , o _ { t } , a _ { t } ) _ { t = 0 } ^ { \infty }$ where the initial state $s _ { 0 }$ is drawn from $P _ { 0 }$ and other elements of such a sequence are drawn from $T , O$ and $\pi _ { \theta }$ respectively (Sutton & Barto, 1998).
Many methods for attempting to approximate optimal policies have been proposed. For instance, policy gradient methods perform gradient ascent on estimates of the expected discounted reward. In
this work we use the proximal policy optimization (PPO) algorithm, which arguably shows relatively robust performance on a wide range of different tasks (Schulman et al., 2017).
# 2.2 FORMALIZING GENERALIZATION
As in classification, we wish to learn from a finite training set but still perform well on previouslyunseen examples from a test set. To formalize this, we have a distribution $\mathcal { D }$ over POMDPs, representing multiple environments or tasks, and we sample $n ^ { \mathrm { t r a i n } }$ POMDPs from this distribution $\mathcal { P } _ { 1 } , \mathcal { P } _ { 2 } , \ldots , \mathcal { P } _ { n ^ { \mathrm { t a i n } } }$ . In the context of navigation, these POMDPs might differ in terms of their observation distributions, perhaps representing views of the same environment at different times of day or year, in terms of their transition distributions, perhaps representing maps with different geometries, or in terms of their reward distributions, perhaps corresponding to the specification of different goal states. Given this sample, we then learn a policy $\pi _ { \theta }$ from a finite collection of state-observation-action sequences from these POMDPs. In order to have a meaningful common policy across these POMDPs, we require that they have common state, action and observation spaces $s , A$ and $\Omega$ . By analogy with the notion of generalization risk in classification (Mohri et al., 2018), we say that policy $\pi _ { \theta }$ generalizes well if it attains a high value for the expectation of the discounted reward over the full distribution of POMDPs, which we call the discounted generalization reward, so that $\mathbb { E } _ { \mathcal { P } \sim \mathcal { D } } J _ { \mathcal { P } } ( \boldsymbol { \theta } )$ is high in some sense.This is our own terminology as we did not find a semantically-equivalent term in the literature.
It is not hard to see that the discounted generalization reward is actually the discounted reward $J _ { \mathcal { P } ^ { D } } ( \theta )$ of a single larger POMDP $\mathcal { P } ^ { \mathcal { D } }$ , whose state space may however no longer be finite. To see this, let us associate a unique identifier $i ( \mathcal { P } )$ with any POMDP sampled from $\mathcal { D }$ and let ${ \boldsymbol { \mathcal { T } } } ^ { \mathcal { D } }$ be the set of all such unique identifiers. In the large POMDP $\mathcal { P } ^ { \mathcal { D } }$ , the state space is the Cartesian product $\boldsymbol { S } \times \boldsymbol { \mathcal { T } } ^ { \mathcal { D } }$ of the original states and these unique identifiers, but the action and observation spaces are just $\mathcal { A }$ and $\Omega$ . The initial state distribution is obtained by first sampling a POMDP $\mathcal { P } \sim \mathcal { D }$ and then sampling $s _ { \mathrm { e n v } } \sim P _ { 0 } ^ { \mathcal { P } }$ from that POMDP’s initial state distribution. The initial state in the large POMDP is then the concatenation $( s _ { \mathrm { e n v } } , i ( \mathcal { P } ) )$ . Thus one might succinctly state the problem of generalization in POMDPs as follows: given a distribution $\mathcal { D }$ over POMDPs with common state, action and observation spaces and access to a sample of state-observation-action sequences from a sample of POMDPs drawn from $\mathcal { D }$ , choose a policy $\pi _ { \theta }$ that obtains a high value for the discounted reward $J _ { \mathcal { P } ^ { D } } ( \theta )$ .
# 3 RELATED WORK
Training in synthetic environments enables the simulation of huge amounts of experience in a span of a few hours. Simulations are convenient to use when training reinforcement learning agents that are often highly sample inefficient Sutton & Barto (1998). There is, frequently, a gap between the synthetic world and the real-world, mainly due to the manner in which the simulators depict the real-world dynamics and visual appearances. Often, these simulated worlds capture the richness and noise of the real-world with low-fidelity Tobin et al. (2017). Many have tried to propose transfer learning techniques to bridge the reality gap in order to still make use of fast simulators for training Taylor & Stone (2009).
One popular method to bridge the reality gap is by randomizing some aspects of the training environment Sadeghi & Levine (2016). This domain randomization technique has been shown to be successful for the transfer of grasping policies from simulated training environments to the real-world Tobin et al. (2017). However, the learned models resulting from that work are not control policies, but perception modules. Previous work has showed some success in transferring the perception module learned in simulation to the real world, but not the controller.
Cobbe et al. (2018) conduct a large scale study on generalization using a new environment, that resembles an arcade game, which they call CoinRun. They experiment by training on different background images and different level structures. They test with different regularization strategies and network architectures finding that the RL agent has a surprising tendency to overfit even to large training sets. Zhang et al. (2018a) reach a similar conclusion, when learning in grid-world environments, and state that the agents have a tendency to memorize levels of the training set. Unlike Cobbe et al. (2018), however, they argue that the methods that inject stochasticity into the dynamics of the system to prevent memorization, such as sticky actions Machado et al. (2017) and random initializations Hausknecht & Stone (2015), often do not help. In our work we are interested in generalization when navigating under partial observability unlike the fully observable CoinRun or grid-world environments.
Domain adaptation methods have also been used for simulated to real transfer. They allow models trained on a source domain to generalize to a target domain. Bousmalis et al. (2017) train a generative model to adapt the synthetic images of the simulator to appear like the real environment. It was shown to successfully transfer a grasping policy trained in simulation to the real world. However, they do not discuss whether the policy generalizes when variations happen in the target domain.
Another aspect of generalization is the transfer of learned skills to solve different tasks. In other words, generalization to the goal of the trained agent $g$ . Achieving different tasks would require the agent to have the ability to maximize different reward functions. Schaul et al. (2015) consider working with value functions that contain the goal $g$ as part of the agent’s state. They call them universal value functions. The reward will then become a function of a state-action-goal tuple $( s , a , g )$ instead of a classical state-action pair. In the paper, the authors present universal value function approximators (UVFA). A method that attempts to learn a universal value function estimate $V _ { \theta } ( s , g )$ They show that UVFA’s can generalize for unseen state-goal pairs in grid-world setup.
Deep reinforcement learning has been used to train control policies. These DRL based methods generally propose to learn motor control commands from raw camera images, thus mapping pixels to commands that control the robot’s motors Levine et al. (2015). DRL algorithms have been used for various navigation tasks such as goal conditioned navigation Mirowski et al. (2016); Zhu et al. (2016) and mapless navigation Mirowski et al. (2018).
# 4 GENERALIZATION IN VISUAL CONTROL
Control policies learned from high-dimensional visual input are often brittle and lack the robustness to operate in novel situations. Our main contribution is to propose a regularization term that can be added to the RL objective to improve the robustness of the learned policy to variations in the observations, presented in Section 4.2. However, to motivate the necessity of our proposed method we study domain randomization in Section 4.1; one of the current main practices that aims at learning a policy that generalizes well.
# 4.1 DOMAIN RANDOMIZATION
Domain randomization is typically used to train policies that can generalize to variations and noise in the observations. It is done by training on several POMDP’s that share the same $s , A , \Omega$ spaces, however they could in their observation distribution. The motivation behind domain randomization is that it is assumed to be an effective technique to provide a policy that is invariant to the changes that would appear in the observations. We explore the problem of navigating the agent towards a goal object with random noise added to the agent’s observations. If the agent is able to perform the task in an environment defined by a POMDP $\mathcal { P } _ { 1 }$ then it should still be able to perform the task in another POMDP $\mathcal { P } _ { 2 }$ , if certain features $f$ of the environment that are specific to successfully achieving the task exist and are invariant to these variations, i.e., $f ( \mathcal { P } _ { 1 } ) = f ( \mathcal { P } _ { 2 } )$ .
In Section 5.1, we study domain randomization when added to RL training and the ability of resulting policies to generalize in unseen POMDPs. We want to investigate if the policy does in fact overfit to the training POMDPs and whether we mitigate that overfitting by training the policies on multiple POMDPs.
# 4.2 INVARIANCE REGULARIZATION (PROPOSED METHOD)
In the previous sections, we discussed how overfitting to the training environment can be a big problem in RL. Furthermore, we should be careful not to jump to the conclusion that training on different environments will ensure policies that generalize well to new environments. It is merely an assumption that has been shown to empirically hold up when used in a supervised learning context.
However, we show in this work that this assumption might not hold for reinforcement learning techniques. This is compatible with the findings in Cobbe et al. (2018) and Zhang et al. (2018a).
We reason that in order to generalize well, the training objective should include a term that encourages policy generalization. Therefore, putting the weight of the problem of generalizing explicitly in the objective function itself. Formally, a function $h$ of variable $x$ is invariant to a transformation $\phi$ of $x$ if $h ( x ) = h ( \phi ( x ) )$ . We can deduce the same definition for the invariance of a policy $\pi$ to changes in the observation given by some transformation $\tau$ , $\pi ( o ) = \pi ( { \mathcal T } ( o ) )$ . We add this regularization penalty term to the RL objective as shown in Equation (1):
$$\operatorname* { m a x } _ { \theta } \quad \quad L _ { p p o } ( { \cal O } ; \pi _ { \theta } ) - \frac { \lambda } { N M } \sum _ { i = 1 } ^ { N } \sum _ { j = 1 } ^ { M } d ( \pi _ { \theta } ( o _ { i } ) , \pi _ { \theta } ( \mathcal { T } _ { j } ( o _ { i } ) ) ) ,$$
where $L _ { p p o }$ is the PPO objective Schulman et al. (2017), $\theta$ is the set of parameters that define the policy $\pi _ { \theta }$ , $d$ is a distance function between the two conditional distributions, and $\lambda$ is a weighting coefficient of the penalty. $O = \{ o _ { 1 } , o _ { 2 } , . . . o _ { N } \}$ is a sequence of $N$ observations.
$\tau$ is a transformation of the observations. Given an observation $o$ and a transformation on that observation $\tau$ where the transformation still holds the semantic context of the underlying state, but with added visual variations. We can think of the difference between observing a room with observation $o$ and observing the same room with observation $\mathcal { T } ( o )$ as the color of the wall for example. Therefore, let us say that we observe $o$ in POMDP $\mathcal { P }$ and observe $\mathcal { T } ( o )$ in POMDP $\mathcal { P } ^ { \mathcal { T } }$ then ${ \dot { \boldsymbol { f } } } ( { \mathcal { P } } ) = f ( { \mathcal { P } } ^ { \tau } )$ , where $f ( \mathcal P )$ is the set of invariant features of the environment defined by the POMDP $\mathcal { P }$ . We further discuss the nature of $\tau$ in the experiments section. $M$ is the number of transformations of each observations.
The penalty $d$ in Equation 1 resembles adding a constraint on the PPO objective, where the new objective dictates that the policy should simultaneously obtain a high reward while behaving similarly for the observations $o$ and $\mathcal { T } ( o )$ . The idea is similar, in spirit, to trust region policy optimization Schulman et al. (2015) where a penalty term, resembling that which would result from imposing a trustregion constraint, is added to ensure monotonic improvement of the average return with each policy update. We call this method in Equation 1 invariance regularization (IR) since the regularization term indicates the invariance of the learned policy to a transformation of given observations.
We propose two ways to solve the RL problem in Equation 1. The first is to directly optimize the full objective by adding the penalty to the original PPO loss. The second method splits the training process to two stages of training RL first and then performing a supervised learning step to minimize $d ( \pi ( o ) , \pi ( T ( o ) ) )$ which presents an elegant form that combines reinforcement learning with supervised learning, more details of the second method is available in Appendix A.
In the next section, we will discuss experiments using both methods. Before that, we will describe a study on the effectiveness of domain randomization as a mean to reducing overfitting in DRL agents.
# 5 EXPERIMENTS
In this section we present the results of two experiments. The first is about training RL with domain randomization. We discuss the ability of the learned policies to generalize to unseen environments when trained on variations of the training environment. The next part presents the results obtained when using the invariance regularization (IR) method, proposed in Section 4.2, with domain randomization and shows that it improves the success rate considerably.
We performed these experiments because we are interested in the following questions: (1) Does training on environments with random variations (as domain randomization suggests) learn a representation of the invariant $f$ with which the policy can generalize to other environments that share the same invariant features? (2) Can we find a training algorithm that would empirically guarantee finding these invariant features $f$ ?
# 5.1 DOMAIN RANDOMIZATION
We leverage the customizability of VizDoom maps Kempka et al. (2016) with hundreds of unique textures to generate train/test scenarios. The agent is required to reach an object in order to get a
<table><tr><td rowspan=1 colspan=1>Num training envs:</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>10</td><td rowspan=1 colspan=1>50</td><td rowspan=1 colspan=1>100</td><td rowspan=1 colspan=1>500</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=5>PPO</td></tr><tr><td rowspan=1 colspan=1>RGB</td><td rowspan=1 colspan=1>0.21 ± 0.04</td><td rowspan=1 colspan=1>0.17± 0.04</td><td rowspan=1 colspan=1>0.35 ± 0.13</td><td rowspan=1 colspan=1>0.35 ± 0.16</td><td rowspan=1 colspan=1>0.34 ± 0.14</td></tr><tr><td rowspan=1 colspan=1>RGB-D</td><td rowspan=1 colspan=1>0.05±0.04</td><td rowspan=1 colspan=1>0.89 ±0.05</td><td rowspan=1 colspan=1>0.90±0.05</td><td rowspan=1 colspan=1>0.61 ±0.37</td><td rowspan=1 colspan=1>0.77 ± 0.33</td></tr><tr><td rowspan=1 colspan=1>Grayscale</td><td rowspan=1 colspan=1>0.36 ± 0.04</td><td rowspan=1 colspan=1>0.33 ± 0.13</td><td rowspan=1 colspan=1>0.37± 0.04</td><td rowspan=1 colspan=1>0.47±0.14</td><td rowspan=1 colspan=1>0.41 ± 0.22</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=5>PPO-IR (split)</td></tr><tr><td rowspan=1 colspan=1>RGB</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>0.64 ± 0.05</td><td rowspan=1 colspan=1>0.69 ±0.03</td><td rowspan=1 colspan=1>0.72 ± 0.016</td><td rowspan=1 colspan=1>0.75 ± 0.02</td></tr><tr><td rowspan=1 colspan=1>RGB-D</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>0.85 ± 0.02</td><td rowspan=1 colspan=1>0.90±0.05</td><td rowspan=1 colspan=1>0.94±0.01</td><td rowspan=1 colspan=1>0.95± 0.02</td></tr><tr><td rowspan=1 colspan=1>Grayscale</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>0.69±0.01</td><td rowspan=1 colspan=1>0.76±0.02</td><td rowspan=1 colspan=1>0.75 ±0.02</td><td rowspan=1 colspan=1>0.76±0.02</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=5>PPO-IR (full objective)</td></tr><tr><td rowspan=1 colspan=1>RGB</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>0.79± 0.05</td><td rowspan=1 colspan=1>0.79 ±0.03</td><td rowspan=1 colspan=1>0.81 ±0.03</td><td rowspan=1 colspan=1>0.81±0.02</td></tr><tr><td rowspan=1 colspan=1>RGB-D</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>0.98±0.01</td><td rowspan=1 colspan=1>0.97 ± 0.01</td><td rowspan=1 colspan=1>0.99 ± 0.01</td><td rowspan=1 colspan=1>0.99± 0.01</td></tr><tr><td rowspan=1 colspan=1>Grayscale</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>0.79± 0.03</td><td rowspan=1 colspan=1>0.79±0.01</td><td rowspan=1 colspan=1>0.79±0.02</td><td rowspan=1 colspan=1>0.80±0.02</td></tr></table>
Table 1: Average success rate and standard deviation of agents, that are trained on a different number of randomly environments, when tested on 50 test environments whose textures are not seen during training. The bold values represent the algorithm that resulted in the best average success rate according to an amount of training environments and an input type. We see that our method brings stability to the average results and improves generalization even when no depth is added.
reward. We train an actor-critic style agent Konda & Tsitsiklis (1999) to solve the task. The network consists of three convolutional layers and 2 fully connected layers, followed by the policy and value function estimator layers. The policy output is a four-dimensional fully-connected layer, where the four dimensions corresponds to four actions; move forward, turn right, turn left and do nothing. The ouput of the policy layer is a log-probability of each action. The value layer is a single unit that predicts the value function. This network architecture was proposed by Mnih et al. (2015). ReLUs are used as the non-linear operations in all layers Nair & Hinton (2010). As mentioned, we optimize the PPO objective Schulman et al. (2017) with a binary reward function $( + 1$ if goal is reached, 0 otherwise) and a discount factor $\gamma = 0 . 9 9$ .
We generate the variations of the training environment by changing the textures on the surfaces using the numerous textures provided by VizDoom Kempka et al. (2016). We train agents on a subset of 1, 10, 50, 100 and 500 rooms from the generated environments and test on 50 rooms with textures from a hold-out set which are not seen in training. We detail this experimental setup in Appendix B. We experiment with different types of visual input; RGB, RGB-D and Grayscale. The number of training iterations is fixed at $5 \times 1 0 ^ { 6 }$ to ensure repeatability of our experiment. The results are therefore potentially pessimistic, and in future work we would like to choose the number of iterations for each network independently so as to maximize generalization performance. The agent and the goal object are initialized at random positions in the environment at the start of each episode.
The role of depth. Adding a depth channel to the observation plays a significant role in generalization. Depth is invariant to many changes in the visible spectrum of the observations. This might lead the training agent to partly find an invariance in observations in its implicit perception model, which in this case can be as simple as focusing on the depth channel only. Therefore, it was not surprising to see, in Table 1, that the depth agents (RGB-D) generalize better than the agents without any depth information.
Table 1 shows the success rate of the PPO models with respect to the number of training environments used and the input type (RGB, RGB-D). The results are averaged over 5 seeds, a standard practice in the RL literature today. We notice the superior performance of the agent with depth than the agent without depth. The fact that the RGB agent is not able to generalize well even when exposed to numerous environments tells us that it might not be learning the invariance relating the environments. On the other hand, the RGB-D agents perform well on the testing environments even when the agents are only exposed to 10 random training environments.
Looking at the RGB and RGB-D experiments, the agents trained on 100 and 500 environments generalize worse on average than the ones trained on 10 and 50, which indicates that some agents might be overfitting. This is inspite of the fact that these agents are able to maximize the reward in the training set regardless of the set size. Looking at the max statistic of these results (not shown in this paper) the 100 and 500 experiments outperform the rest. However, the 100 and 500 experiments have a higher variance in the success rates of different seeds than the 10 and 50 experiments. High variance in the test results of the 100/500 RGB-D experiments shows that some seeds are able to achieve a near perfect score on the testing environment and others completely fail, thus there is then no empirical guarantee that RL agents will generalize when exposed to numerous environments.
The average success rate for the RGB input without the depth shows that domain randomization alone might not be an effective method to adapt the policy to variations in the observations, at least not in the context of RL. In fact, it shows little progress, e.g., the RGB agent exposed to one environment achieves around a $20 \%$ success on the testing environments and the agents exposed to $5 0 +$ environments achieve less than $40 \%$ success. These results are consistent when running with a grayscale channel (see Table 1).
While training by randomizing the environment did show some success in making supervised learning models generalize better, it fails to do so in RL policies. It is clear from these results, that adding random variations and relying solely on the RL objective is not enough to ensure generalization. Much of the success of domain randomization in previous works Tobin et al. (2017) was reported using supervised learning. Also, the generalization abilities of machine learning algorithms have been linked to supervised learning setups. Therefore, it would make sense to adapt supervised learning techniques to regularize the models trained with DRL.
# 5.2 INVARIANCE REGULARIZATION EXPERIMENTS
In this section we will discuss the results obtained from training the agent using the method proposed in Section 4.2. As mentioned in Section 4.2, we propose two methods of using the proposed IR penalty. The first is to add to the PPO objective as in Equation 1, this method is referred to as (full objective) in the results. The second, which is referred to as (split) in the results, is to split the objective into two parts; RL step and a supervised learning step (more details available in Appendix A). The value of $\lambda$ in Equation 1 used in all IR (full objective) experiments is 1.0.
As for the nature of transformation $\tau$ of the observations, we tested with the same randomly textured environments from VizDoom, that were used in the previous section, in order to be able to make fair comparisons with the pure RL and domain randomization agents. Regarding the distance penalty term $d$ in Equation 1, we did preliminary experiments with the KL divergence, $L 1$ , $L 2$ and cross-entropy losses and the KL divergence returned the best results. Table 1 shows the results for combining PPO with the IR penalty using the two proposed implementations.
Observing the split method’s results, we see that the proposed training procedure returns stable success rates that are improves as more environments are added. The split version was able to outperform vanilla PPO and substantially improve the generalization especially in the cases of RGB/Grayscale inputs. Training with the full objective, however, returned the best results that outperform vanilla PPO with domain randomization and the split version of the IR algorithm. Similar to the split version, training on the full objective shows stable performance for the different inputs across different seeds.
The results, in Table 1, also show that the trained models, on the full objective, are achieving test success rate, with only 10 training environments, that is close if not identical to the agents trained on 50, 100 and 500 environments. These results suggests that training with the full objective version of the IR algorithms does not require a large number of environments to learn the invariant features. Notice the average testing success rate is similar across the different number of training environments since the model learns the invariant features from only 10 environments and adding more environments that share the same invariant features will not make a difference. We can verify that hypothesis when looking at the RGB-D testing results in the full objective part. All agents achieve a near perfect score which we attribute to the availability of an invariant feature map in the input (the depth channel) which only the agents trained with the full objective are able to catch.
# 5.2.1 COMPARISONS WITH OTHER REGULARIZATION TECHNIQUES
Regularization has been shown to help in the generalization of supervised learning models Srivastava et al. (2014). Using regularization in supervised learning often improves the performance of the trained models on test sets. However, regularization has not been frequently used in DRL setups, possibly due to the previously-common poor practise of testing and training in the same environment so there is no generalization gap Cobbe et al. (2018).
 Figure 2: Different regularization methods tested on the RGB input. (Left): The average success rate show that some of these methods achieve similar results to ours in some instances. (Right): The lower SPL of the other regularization methods relative to ours indicates some randomness in their learned policies
We compare our method with some regularization techniques that are frequently used; dropout, batchnorm and $L 2$ . The first experiment has a dropout layer added after each convolutional layer Srivastava et al. (2014), the second has a batchnorm layer added after every convolutional layer Ioffe & Szegedy (2015) and the last uses $L 2$ regularization. We choose the dropout probability to be 0.1 and the $L 2$ weight to be $1 0 ^ { - 4 }$ , the same values that were proposed by Cobbe et al. (2018). As in the previous setup, we train five models (different seeds) for each technique and evaluate on 50 environments whose textures are sampled from a hold-out set. We report the experiments done with RGB input only as it poses a harder problem and a larger gap than RGB-D.
Figure 2 (left) shows the average success rate over 5 seeds for the four methods. We see that our proposed method is the only one that is steadily improving when more environments are added. The batchnorm models performed worst while dropout and $L 2$ achieved similar success rates to the split version of our method given 50 and 500 training environments. However, the entropy of the learned policies is substantially higher when dropout and $L 2$ are added to the model.
We hypothesize that the high entropy policies are able to generalize by acting randomly in some instances and this makes them more robust in certain situations. We show the success weighted shortest path length $( S P L )$ in Figure 2 (right). A random behavior that displays robustness (has a high success probability) would return a relatively lower SPL due to the fact that this random behavior will probably not take the shortest possible path to the goal. Details of the formulation of SPL are available in Appendix C. Figure 2 (right) shows that the dropout and L2 agents have a lower SPL than the IR agents indicating that these policies with higher entropy are inefficient.
# 6 DISCUSSION AND CONCLUSIONS
We present a study of the generalization capabilities of visual navigation agents trained with deep reinforcement learning algorithms. We formalize what it means to generalize in the context of a POMDP. We find that the tendency of RL agent to overfit even when exposed to large training sets is quite visible. We show that using domain randomization with RL, without adding invariant features to the input such as the depth maps, is not enough to generalize. In the second part, we proposed Invariance Regularization (IR), a method that attempts to regularize the RL model with a supervised learning loss. It improves the generalization success and displays stable performance across different seeds.
In this work, we focused our experimentation on generalization to changes in the input observation. However, it is also interesting to generalize the learned skills to different architectural designs of the environment, just as one one wishes to generalize to different levels of the game as proposed in the retro competition Nichol et al. (2018). Another avenue of future work is to explore the appropriate transformation function $\tau$ of the observations.One might consider an adaptive form of $\tau$ learned with data augmentation Cubuk et al. (2018) or adversarial examples Goodfellow et al. (2015).
# REFERENCES
Peter Anderson, Angel X. Chang, Devendra Singh Chaplot, Alexey Dosovitskiy, Saurabh Gupta, Vladlen Koltun, Jana Kosecka, Jitendra Malik, Roozbeh Mottaghi, Manolis Savva, and Amir Roshan Zamir. On evaluation of embodied navigation agents. CoRR, abs/1807.06757, 2018. URL http://arxiv.org/abs/1807.06757.
Francisco Bonin-Font, Alberto Ortiz, and Gabriel Oliver. Visual navigation for mobile robots: A survey. Journal of Intelligent and Robotic Systems, 53:263–296, 11 2008. doi: 10.1007/ s10846-008-9235-4.
Konstantinos Bousmalis, Alex Irpan, Paul Wohlhart, Yunfei Bai, Matthew Kelcey, Mrinal Kalakrishnan, Laura Downs, Julian Ibarz, Peter Pastor, Kurt Konolige, Sergey Levine, and Vincent Vanhoucke. Using simulation and domain adaptation to improve efficiency of deep robotic grasping. CoRR, abs/1709.07857, 2017. URL http://arxiv.org/abs/1709.07857.
Karl Cobbe, Oleg Klimov, Christopher Hesse, Taehoon Kim, and John Schulman. Quantifying generalization in reinforcement learning. CoRR, abs/1812.02341, 2018. URL http://arxiv. org/abs/1812.02341.
Ekin Dogus Cubuk, Barret Zoph, Dandelion Mané, Vijay Vasudevan, and Quoc V. Le. Autoaugment: Learning augmentation policies from data. CoRR, abs/1805.09501, 2018. URL http://arxiv. org/abs/1805.09501.
Ian Goodfellow, Yoshua Bengio, and Aaron Courville. Deep Learning. MIT Press, 2016. http: //www.deeplearningbook.org.
Ian J. Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. CoRR, abs/1412.6572, 2015.
Matthew Hausknecht and Peter Stone. The impact of determinism on learning Atari 2600 games. In AAAI Workshop on Learning for General Competency in Video Games, January 2015.
Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. CoRR, abs/1502.03167, 2015. URL http://arxiv.org/ abs/1502.03167.
Michał Kempka, Marek Wydmuch, Grzegorz Runc, Jakub Toczek, and Wojciech Jaskowski. ViZ- ´ Doom: A Doom-based AI research platform for visual reinforcement learning. In IEEE Conference on Computational Intelligence and Games, pp. 341–348, Santorini, Greece, Sep 2016. IEEE. URL http://arxiv.org/abs/1605.02097.
Vijay R. Konda and John N. Tsitsiklis. Actor-critic algorithms. In Advances in Neural Information Processing Systems 12, pp. 1008–1014, 1999. URL http://papers.nips.cc/paper/ 1786-actor-critic-algorithms.
Sergey Levine, Chelsea Finn, Trevor Darrell, and Pieter Abbeel. End-to-end training of deep visuomotor policies. CoRR, abs/1504.00702, 2015. URL http://arxiv.org/abs/1504. 00702.
Marlos C. Machado, Marc G. Bellemare, Erik Talvitie, Joel Veness, Matthew J. Hausknecht, and Michael Bowling. Revisiting the arcade learning environment: Evaluation protocols and open problems for general agents. CoRR, abs/1709.06009, 2017. URL http://arxiv.org/abs/ 1709.06009.
Piotr Mirowski, Razvan Pascanu, Fabio Viola, Hubert Soyer, Andrew J. Ballard, Andrea Banino, Misha Denil, Ross Goroshin, Laurent Sifre, Koray Kavukcuoglu, Dharshan Kumaran, and Raia Hadsell. Learning to navigate in complex environments. CoRR, abs/1611.03673, 2016. URL http://arxiv.org/abs/1611.03673.
Piotr Mirowski, Matthew Koichi Grimes, Mateusz Malinowski, Karl Moritz Hermann, Keith Anderson, Denis Teplyashin, Karen Simonyan, Koray Kavukcuoglu, Andrew Zisserman, and Raia Hadsell. Learning to navigate in cities without a map. CoRR, abs/1804.00168, 2018. URL http://arxiv.org/abs/1804.00168.
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, Charles 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, 2015.
Mehryar Mohri, Afshin Rostamizadeh, and Ameet Talwalkar. Foundations of Machine Learning. MIT Press, second edition, 2018.
Vinod Nair and Geoffrey E. Hinton. Rectified linear units improve restricted boltzmann machines. In Proceedings of the 27th International Conference on International Conference on Machine Learning, ICML’10, pp. 807–814, USA, 2010. Omnipress. ISBN 978-1-60558-907-7. URL http://dl.acm.org/citation.cfm?id $\equiv$ 3104322.3104425.
Alex Nichol, Vicki Pfau, Christopher Hesse, Oleg Klimov, and John Schulman. Gotta learn fast: A new benchmark for generalization in RL. CoRR, abs/1804.03720, 2018. URL http://arxiv. org/abs/1804.03720.
Kate Rakelly, Aurick Zhou, Deirdre Quillen, Chelsea Finn, and Sergey Levine. Efficient off-policy meta-reinforcement learning via probabilistic context variables. CoRR, abs/1903.08254, 2019. URL http://arxiv.org/abs/1903.08254.
Fereshteh Sadeghi and Sergey Levine. Real single-image flight without a single real image. CoRR, abs/1611.04201, 2016. URL http://arxiv.org/abs/1611.04201.
Tom Schaul, Dan Horgan, Karol Gregor, and David Silver. Universal value function approximators. In Proceedings of the 32nd International Conference on International Conference on Machine Learning - Volume 37, ICML’15, pp. 1312–1320. JMLR.org, 2015. URL http://dl.acm. org/citation.cfm?id=3045118.3045258.
John Schulman, Sergey Levine, Philipp Moritz, Michael I. Jordan, and Pieter Abbeel. Trust region policy optimization. CoRR, abs/1502.05477, 2015. URL http://arxiv.org/abs/1502. 05477.
John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. CoRR, abs/1707.06347, 2017. URL http://arxiv.org/abs/ 1707.06347.
M.T.J. Spaan. Partially observable Markov decision processes. In Reinforcement Learning, pp. 387–414. Springer, 2012.
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:1929–1958, 2014. URL http://jmlr.org/papers/v15/ srivastava14a.html.
Richard S. Sutton and Andrew G. Barto. Introduction to Reinforcement Learning. MIT Press, Cambridge, MA, USA, 1st edition, 1998. ISBN 0262193981.
Matthew E. Taylor and Peter Stone. Transfer learning for reinforcement learning domains: A survey. J. Mach. Learn. Res., 10:1633–1685, December 2009. ISSN 1532-4435. URL http: //dl.acm.org/citation.cfm?id=1577069.1755839.
Joshua Tobin, Rachel Fong, Alex Ray, Jonas Schneider, Wojciech Zaremba, and Pieter Abbeel. Domain randomization for transferring deep neural networks from simulation to the real world. CoRR, abs/1703.06907, 2017. URL http://arxiv.org/abs/1703.06907.
Chiyuan Zhang, Oriol Vinyals, Rémi Munos, and Samy Bengio. A study on overfitting in deep reinforcement learning. CoRR, abs/1804.06893, 2018a. URL http://arxiv.org/abs/ 1804.06893.
Marvin Zhang, Sharad Vikram, Laura Smith, Pieter Abbeel, Matthew J. Johnson, and Sergey Levine. SOLAR: deep structured latent representations for model-based reinforcement learning. CoRR, abs/1808.09105, 2018b. URL http://arxiv.org/abs/1808.09105.
Yuke Zhu, Roozbeh Mottaghi, Eric Kolve, Joseph J. Lim, Abhinav Gupta, Li Fei-Fei, and Ali Farhadi. Target-driven visual navigation in indoor scenes using deep reinforcement learning. CoRR, abs/1609.05143, 2016. URL http://arxiv.org/abs/1609.05143.
# APPENDIX
A IR SPLIT VERSION
# Algorithm 1 RL with iterative supervision
Initialize $k _ { 1 } , k _ { 2 } , \theta _ { 0 } , \mathcal { T } _ { i = \{ 1 . . . , N \} } , e n v$ while not converged do for $i = 1 \ldots , k _ { 1 }$ do // Train $\pi _ { \theta }$ on env on the RL objective $\theta _ { i } \gets \operatorname* { m a x } _ { \theta } L _ { p p o } ( o ^ { e n v } ; \pi _ { \theta _ { i - 1 } } )$ end for for $j = 1 \ldots , k _ { 2 }$ do // Train $\pi$ on env and $\tau ( e n v )$ Sample $\{ o _ { t } ^ { e n v } , \pi _ { \theta _ { k _ { 1 } } } ( o _ { t } ^ { e n v } ) \}$ Generate $\{ o _ { t } ^ { \mathcal { T } _ { i } ( e n v ) } , \pi _ { \theta _ { k _ { 1 } } } ( o _ { t } ^ { \mathcal { T } _ { i } ( e n v ) } ) \} ^ { i = 1 \dots N }$ $\begin{array} { r } { \theta _ { j } \operatorname* { m i n } _ { \theta } d ( \pi _ { \theta _ { k _ { 1 } } } ( o _ { e n v } ) | | \pi _ { \theta _ { j - 1 } } ( \mathcal T _ { i } ( o _ { e n v } ) ) } \end{array}$ end for end while return $\pi _ { \theta }$
The first part consists of training RL on the observations of the original training environment, while the second part can be seen as a supervised learning objective on the transformed observations, as shown in Algorithm 1.
The first step trains RL on one environment and then use the actions that the trained policy would have taken in that environment to tune the model with supervised learning on the textured environments. In the reported experiments using the split version, the model is trained with one iteration of the algorithm. Therefore, the training process has two stages, train RL then train with a supervised learning setup, without iterating between both.
# B EXPERIMENTAL SETUP
As stated in Section 5.1, we run training on a subset of 1, 10, 50, 100 and 500 rooms where the surfaces in each room are sampled from the variety of textures available in Vizdoom. The resulting policies are tested on 50 rooms with textures from a hold-out set which are not seen in training. During training we run several agents in parallel to quickly collect observation-action-reward data in multiple environments. Another advantage of this parallelization is the ability to run each agent on a variation of the training environment. Due to hardware limitations, we cannot run one agent for each environment, at least not when we have a large number of training environments, i.e., 100 or 500. Therefore, each agent samples one environment from the training set and runs on it for some $n$ episodes before sampling another one $n = 2 5$ episodes).
# C SUCCESS WEIGHTED SHORTEST PATH LENGTH (SPL)
SPL was proposed by Anderson et al. (2018) as a way of measuring the navigation agents success rates while taking into account the time it takes agents to succeed 1.
$$S P L = \frac { 1 } { N } \sum _ { i = 1 } ^ { N } S _ { i } \frac { l _ { i } } { p _ { i } } ,$$
where $N$ is the number of runs, $S _ { i }$ is the binary indicator of the success of episode $i , l _ { i }$ is the length of the shortest possible path and $p _ { i }$ is the length of the path taken by the agent.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661# KERNEL AND RICH REGIMES IN OVERPARAMETRIZED MODELS
Anonymous authors Paper under double-blind review
# ABSTRACT
A recent line of work studies overparametrized neural networks in the “kernel regime,” i.e. when the network behaves during training as a kernelized linear predictor, and thus training with gradient descent has the effect of finding the minimum RKHS norm solution. This stands in contrast to other studies which demonstrate how gradient descent on overparametrized multilayer networks can induce rich implicit biases that are not RKHS norms. Building on an observation by Chizat and Bach (2018), we show how the scale of the initialization controls the transition between the “kernel” (aka lazy) and “rich” (aka active) regimes and affects generalization properties in multilayer homogeneous models. We provide a complete and detailed analysis for a simple two-layer model that already exhibits an interesting and meaningful transition between the kernel and rich regimes, and we demonstrate the transition for more complex matrix factorization models and multilayer non-linear networks.
# 1 INTRODUCTION
A string of recent papers study neural networks trained with gradient descent in the “kernel regime.” They observe that, in a certain regime, networks trained with gradient descent behave as kernel methods (Jacot et al., 2018; Daniely et al., 2016; Daniely, 2017). This allows one to prove convergence to zero error solutions in overparametrized settings (Du et al., 2018; 2019; Allen-Zhu et al., 2018), and also implies gradient descent will converge to the minimum norm solution (in the corresponding RKHS) (Chizat and Bach, 2018; Arora et al., 2019b; Mei et al., 2019) and more generally that models inherit the inductive bias and generalization behavior of the RKHS. This suggests that, in a certain regime, deep models can be equivalently replaced by kernel methods with the “right” kernel, and deep learning boils down to a kernel method with a fixed kernel determined by the architecture and initialization, and thus it can only learn problems learnable by some kernel.
This contrasts with other recent results that show how in deep models, including infinitely overparametrized networks, training with gradient descent induces an inductive bias that cannot be represented as an RKHS norm. For example, analytic and/or empirical results suggest that gradient descent on deep linear convolutional networks implicitly biases toward minimizing the $L _ { p }$ bridge penalty, for $p \stackrel { \cdot } { = } 2 / \mathrm { d e p t h } \le 1 .$ , in the frequency domain (Gunasekar et al., 2018b); weight decay on an infinite width single input ReLU implicitly biases towards minimizing the second order total variations $\int { \left| f ^ { \prime \prime } ( x ) \right| d x }$ of the learned function (Savarese et al., 2019); and gradient descent on a overparametrized matrix factorization, which can be thought of as a two layer linear network, induces nuclear norm minimization of the learned matrix (Gunasekar et al., 2017) and can ensure low rank matrix recovery (Li et al., 2018). All these natural inductive biases $\scriptstyle L _ { p }$ bridge penalty for $p < 1$ , total variation norm, nuclear norm) are not Hilbert norms, and therefore cannot be captured by a kernel. This suggests that training deep models with gradient descent can behave very differently from kernel methods, and have much richer inductive biases.
One might then ask whether the kernel approximation indeed captures the behavior of deep learning in a relevant and interesting regime, or does the success of deep learning come when learning escapes this regime? In order to understand this, we must first carefully understand when each of these regimes hold, and how the transition between the “kernel” regime and the “rich” regime happens.
Some investigations of the kernel regime emphasized the number of parameters (“width”) going to infinity as leading to this regime. However Chizat and Bach (2018) identified the scale of the model as a quantity controlling entry into the kernel regime. Their results suggest that for any number of parameters (any width), a model can be approximated by a kernel when its scale at initialization goes to infinity (see details in Section 3). Considering models with increasing (or infinite) width, the relevant regime (kernel or rich) is determined by how the scaling at initialization behaves as the width goes to infinity. In this paper we elaborate and expand of this view, carefully studying how the scale of initialization effects the model behaviour for $D$ -homogeneous models.
In Section 4 we provide a complete and detailed study for a simple 2-homogeneous model that can be viewed as linear regression with squared parametrization, or as a “diagonal” linear neural network. For this model we can exactly characterize the implicit bias of training with gradient descent, as a function of the scale $\alpha$ of initialization, and see how this implicit bias becomes the $\ell _ { 2 }$ norm in the $\alpha \infty$ kernel regime, but the $\ell _ { 1 }$ norm in the $\alpha 0$ rich regime. We can therefore understand how, e.g. for a high dimensional sparse regression problem, where it is necessary to discover the relevant features, we can get good generalization when the initialization scale $\alpha$ is small, but not when $\alpha$ is large. Deeper networks corresponds to higher orders of homogeneity, and so in Section 5 we extend our study to a $D$ -homogeneous model, studying the effects of $D$ . In Sections 6 and 7, we demonstrate similar transitions experimentally in matrix factorization and non-linear networks.
# 2 SETUP AND PRELIMINARIES
We consider models $f : \mathbb { R } ^ { p } \times \mathcal { X } \mathbb { R }$ which map parameters $\mathbf { w _ { \lambda } } \in \mathbb { R } ^ { p }$ and examples $\mathbf { x } \in \mathcal { X }$ to predictions $f ( \mathbf { w } , \mathbf { x } ) \in \mathbb { R }$ . We denote the predictor implemented by the parameters w as $h _ { \mathbf { w } } = F ( \mathbf { w } )$ such that $h _ { \mathbf { w } } ( \mathbf { x } ) = f ( \mathbf { w } , \mathbf { x } )$ . Much of our focus will on models, such a linear networks, which are linear in $\mathbf { x }$ (but not on the parameters w!), in which case $F ( \mathbf { w } ) \in \mathcal { X } ^ { * }$ is a linear predictor and can be represented as a vector $\beta _ { \mathbf { w } }$ with $f ( \mathbf { w } , \mathbf { x } ) = \langle \beta _ { \mathbf { w } } , \mathbf { x } \rangle$ . Such models are essentially alternate parametrizations of linear models, but as we shall see that change of parametrization is crucial.
In this paper, we consider models that are $D$ -positive homogeneous in the parameters w, for some integer $D \geq 1$ , meaning that for any $c \in \mathbb { R } _ { + }$ , ${ \dot { F } } ( c { \cdot } { \mathbf { w } } ) = c ^ { D } { \check { F } } ( { \mathbf { w } } )$ and $f ( c \cdot \mathbf { \bar { w } } , \mathbf { x } ) = c ^ { D } f ( \mathbf { w } , \mathbf { x } )$ . We refer to such models simply as $D$ -homogeneous. Many interesting model classes have this property, including multi-layer ReLU networks with fully connected and convolutional layers, layered linear neural networks, and matrix factorization where $D$ corresponds to the depth of the network.
Consider a training set $\{ ( { \mathbf { x } ^ { ( n ) } , y ^ { ( n ) } } ) \} _ { n = 1 } ^ { N }$ consisting of $N$ examples of input label pairs. For a given loss function $\ell : \mathbb { R } \times \mathbb { R } \to \mathbb { R }$ , the loss of the model parametrized by w is $\begin{array} { r } { L ( F ( \mathbf { w } ) ) = \sum _ { n = 1 } ^ { N } \ell ( f ( \mathbf { w } , \mathbf { x } ^ { ( n ) } ) , y ^ { ( n ) } ) } \end{array}$ . We will focus mostly on the squared loss $\ell _ { \mathrm { s q } } ( \hat { y } , y ) =$ $( \hat { y } - y ) ^ { 2 }$ . We slightly abuse notation and use $f ( \mathbf { w } , X ) \in \mathbb { R } ^ { N }$ to denote the vector of predictions $[ f ( \mathbf { w } , \mathbf { x } ^ { ( 1 ) } ) , \dots , f ( \mathbf { w } , \mathbf { x } ^ { ( N ) } ) ]$ and so for the squared loss we can write $L ( \mathbf { w } ) = \| f ( \mathbf { w } , X ) - \mathbf { y } \| _ { 2 } ^ { 2 }$ , where $\mathbf { y } \in \mathbb { R } ^ { N }$ is the vector of target labels.
Minimizing the loss $L ( \mathbf { w } )$ using gradient descent amounts to iteratively updating the parameters
$$\mathbf { w } ( k + 1 ) = \mathbf { w } ( k ) - \eta \nabla L ( \mathbf { w } ( k ) ) .$$
We consider gradient descent with infinitesimally small stepsize $\eta$ , i.e. gradient flow dynamics
$$\begin{array} { r } { \dot { \mathbf { w } } ( t ) = - \nabla L ( \mathbf { w } ( t ) ) . } \end{array}$$
We are particularly interested in the scale of initialization and we capture it through a scalar parameter $\alpha \in \mathbb { R } _ { + }$ . For scale $\alpha$ , we will denote by ${ \bf w } _ { \alpha } ( t )$ the gradient flow path (2) with the initial condition $\mathbf { w } _ { \alpha } ( 0 ) = \alpha \mathbf { w } _ { 0 }$ for some fixed $\mathbf { w } _ { 0 }$ . We use $\dot { h _ { \alpha } } ( t ) = F ( \mathbf { w } _ { \alpha } ( t ) )$ , and for linear predictors $\beta _ { \alpha } ( t ) = \beta _ { \mathbf { w } _ { \alpha } ( t ) }$ , to denote the dynamics on the predictor $F ( \mathbf { w } )$ induced by the gradient flow on w.
In many cases, we expect the dynamics to converge to a minimizer of $L ( \mathbf { w } )$ , though proving this happens will not be our main focus. Rather, we are interested in the underdetermined case, $N \ll p$ , where there are generally many minimizers of $L ( \mathbf { w } )$ , all with $f ( \mathbf { w } , X ) = \mathbf { y }$ and $L ( \mathbf { w } ) = 0$ . Our main focus is which of the many minimizers does gradient flow converge to. That is, we want to characterize $\begin{array} { r } { \mathbf { w } _ { \alpha } ( \infty ) = \operatorname* { l i m } _ { t \infty } \mathbf { w } _ { \alpha } ( t ) } \end{array}$ or, more importantly, the predictor $h _ { \alpha } ( \infty ) = F ( \mathbf { w } _ { \alpha } ( \infty ) )$ or $\beta _ { \alpha } ( \infty ) = \beta _ { \mathbf { w } _ { \alpha } ( \infty ) }$ we converge to, and how these depend on the scale $\alpha$ . In underdetermined problems, where there are many zero error solutions, simply fitting the data using the model does not provide enough inductive bias to ensure generalization. But in many cases, the specific solution reached by gradient flow (or some other optimization procedure) has special structure, or minimizes some implicit regularizer, and this structure or regularizer provides the needed inductive bias (Gunasekar et al., 2018b;a; Soudry et al., 2018; Ji and Telgarsky, 2018).
# 3 THE KERNEL REGIME
Gradient descent/flow considers only the first-order approximation of the model w.r.t. w:
$$f ( \mathbf { w } , \mathbf { x } ) = f ( \mathbf { w } ( t ) , x ) + \langle \mathbf { w } - \mathbf { w } ( t ) , \nabla _ { \mathbf { w } } f ( \mathbf { w } ( t ) , \mathbf { x } ) \rangle + O ( \| \mathbf { w } - \mathbf { w } ( t ) \| ^ { 2 } ) .$$
That is, locally around any ${ \bf w } ( t )$ , gradient flow operates on the model as if it were an affine model $f ( \mathbf { w } , \mathbf { x } ) \approx f _ { 0 } ( \mathbf { x } ) + \left. \mathbf { w } , \phi _ { \mathbf { w } ( t ) } ( \mathbf { x } ) \right.$ with feature map $\phi _ { \mathbf { w } ( t ) } ( \mathbf { x } ) = \nabla _ { \mathbf { w } } f ( \mathbf { w } ( t ) , \mathbf { x } )$ , corresponding to the tangent kernel $K _ { \mathbf { w } ( t ) } ( x , x ^ { \prime } ) = \langle \nabla _ { \mathbf { w } } f ( \mathbf { w } ( t ) , \mathbf { x } ) , \nabla _ { \mathbf { w } } f ( \mathbf { w } ( t ) , \mathbf { x } ) \rangle$ (Jacot et al., 2018; Zou et al., 2018; Yang, 2019; Lee et al., 2019). Of particular interest is the tangent kernel at initialization, $K _ { { \bf w } _ { \alpha } ( 0 ) } = \bar { \alpha } ^ { 2 ( D - 1 ) } K _ { 0 }$ where we denote $K _ { 0 } = K _ { \mathbf { w } _ { 0 } }$ .
The “kernel regime” refers to a situation in which the tangent kernel $K _ { \mathbf w ( t ) }$ does not change over the course of optimization, and less formally to the regime where it does not change significantly, i.e. where $\forall t K _ { \mathbf { w } ( t ) } \approx K _ { \mathbf { w } ( 0 ) }$ . In this regime, training the model is exactly equivalent to training an affine model $\tilde { f } ( \mathbf { w } , \mathbf { x } ) = \alpha ^ { D } f ( \mathbf { w } _ { 0 } , \mathbf { x } ) + \left. \mathbf { w } , \alpha ^ { D - 1 } \phi _ { 0 } ( \mathbf { x } ) \right.$ with kernelized gradient descent/flow with the kernel $\alpha ^ { 2 ( D - 1 ) } K _ { 0 }$ and a “bias term” of $\alpha ^ { D } f ( \mathbf { w } _ { 0 } , \mathbf { x } )$ . To avoid handling this bias term, and in particular its scaling, Chizat and Bach (2018) suggest using “unbiased” initializations such that $F ( \mathbf { w } _ { 0 } ) = 0$ , so that the bias term vanishes. This can often be achieved by replicating units or components with opposite signs at initialization, which is the approach we use here (see Sections 4–6 for examples and details).
For underdetermined problem with multiple solutions $f ( \mathbf { w } , X ) = \mathbf { y }$ , unbiased kernel gradient flow (or gradient descent) converges to the minimum norm solution ${ \hat { h } } _ { K } = \arg \operatorname* { m i n } _ { h ( X ) = \mathbf { y } } \left\| h \right\| _ { K }$ , where $\left\| h \right\| _ { K }$ is the RKHS norm corresponding to the kernel. And so, in the kernel regime, we will have that $\overset { \vartriangle } { \boldsymbol { h } } ( \infty ) = \hat { \boldsymbol { h } } _ { K _ { 0 } }$ , and the implicit bias of training is precisely given by the kernel.
When does the “kernel regime” happen? Chizat and Bach (2018) showed that for any homogeneous1 model satisfying some technical conditions, the kernel regime is reached as $\alpha \to \infty$ . That is, as we increase the scale of initialization, the dynamics converge to the kernel gradient flow dynamics with the kernel $K _ { 0 }$ , and we have $\begin{array} { r } { \operatorname* { l i m } _ { \alpha \to \infty } h _ { \alpha } ( \infty ) = \hat { h } _ { K } } \end{array}$ . In Sections 4 and 5 we prove this limit directly for our specific models, and we also demonstrate it empirically for matrix factorization and deep networks in Sections 6 and 7.
In contrast, and as we shall see in later sections, the $\alpha 0$ small initialization limit often leads to a very different and rich inductive bias, e.g. inducing sparsity or low-rank structure (Gunasekar et al., 2017; Li et al., 2018; Gunasekar et al., 2018b), that allows for generalization in many settings where kernel methods would not. We refer to this limit reached as $\alpha 0$ as the “rich regime.” This regime is also referred to as the “active” or “adaptive” regime (Chizat and Bach, 2018) since the tangent kernel $K _ { \mathbf w ( t ) }$ changes over the course of training, in a sense adapting to the data. We argue that this regime is the one that truly allows us to exploit the power of depth, and thus is the more relevant regime for understanding the success of deep learning.
# 4 DETAILED STUDY OF A SIMPLE DEPTH-2 MODEL
We study in detail a simple 2-homogeneous model. Consider the class of linear functions over $\chi = \mathbb { R } ^ { d }$ , with squared parameterization as follows:
$$f ( \mathbf { w } , \mathbf { x } ) = \sum _ { i = 1 } ^ { d } ( \mathbf { w } _ { + , i } ^ { 2 } - \mathbf { w } _ { - , i } ^ { 2 } ) \mathbf { x } _ { i } = \langle \beta _ { \mathbf { w } } , \mathbf { x } \rangle , { \mathrm { ~ w h e r e ~ } } \mathbf { w } = { \binom { \mathbf { w } _ { + } } { \mathbf { w } _ { - } } } \in \mathbb { R } ^ { 2 d } { \mathrm { ~ a n d ~ } } \beta _ { \mathbf { w } } = \mathbf { w } _ { + } ^ { 2 } - \mathbf { w } _ { - } ^ { 2 } .$$
where we use the notation $\mathbf { z } ^ { 2 }$ for $\mathbf { z } \in \mathbb { R } ^ { d }$ to denote elementwise squaring. We consider initializing all weights equally with $\mathbf { w } _ { 0 } = \mathbf { 1 }$ .
This is nothing but a linear regression model, except with an unconventional parametrization. The model can also be thought of as a “diagonal” linear neural network (i.e. where the weight matrices have diagonal structure) with $2 d$ units. A standard diagonal linear network would have $d$ units, with each unit connected to just a single input unit with weights $u _ { i }$ and the output with weight $v _ { i }$ , thus implementing the model $\begin{array} { r } { f ( ( \bar { \bf u } , \bar { \bf v } ) , \bar { \bf x } ) = \sum _ { i } { \bf u } _ { i } { \bf v } _ { i } { \bf x } _ { i } } \end{array}$ . But if at initialization $| { \mathbf { } } u _ { i } | = | \bar { \mathbf { } } { \mathbf { } } v _ { i } |$ , their magnitude will remain equal and their signs will not flip throughout training, and so we can equivalently replace both with a single weight $\mathbf { w } _ { i }$ , yielding the model $f ( \mathbf { w } , \mathbf { x } ) = \left. \mathbf { w } ^ { 2 } , \mathbf { x } \right.$ .
The reason for using both $\mathbf { w } _ { + }$ and $\mathbf { w } _ { - }$ (or $2 d$ units) is two-fold. First, it ensures that the image of $F ( \mathbf { w } )$ is all (signed) linear functions, and thus the model is truly equivalent to standard linear regression. Second, it allows for initialization at $F ( \alpha \mathbf { w } _ { 0 } ) = 0$ without this being a saddle point from which gradient flow will never escape.2
The model (4) is perhaps the simplest non-trivial $D$ -homogeneous model for $D > 1$ , and we chose it for this reason, as it already exhibits distinct and interesting kernel and rich regimes. Furthermore, we can completely understand both the implicit regularization driving this model and the transition between the regimes analytically.
Consider the behavior of the limit of gradient flow (2) as a function of the initialization, in the underdetermined $N \ll d$ case where there are many possible solutions $X { \boldsymbol { \beta } } = \mathbf { y }$ . The tangent kernel at initialization is $K _ { 0 } ( { \bf x } , { \bf x } ^ { \prime } ) = 8 \alpha ^ { 2 } \left. { \bf x } , { \bf x } ^ { \prime } \right.$ , i.e. a scaling of the standard inner product kernel, so $\| \beta \| _ { K _ { 0 } } \propto \| \beta \| _ { 2 }$ . Thus, in the kernel regime, gradient flow leads to the minimum $\ell _ { 2 }$ norm solution, $\beta _ { L 2 } ^ { * } \doteq \arg \operatorname* { m i n } _ { X \beta = y } \| \beta \| _ { 2 }$ . Following Chizat and Bach (2018) and the discussion in Section 3, we thus expect that $\begin{array} { r } { \operatorname* { l i m } _ { \alpha \to \infty } \beta _ { \alpha } ( \infty ) = \beta _ { L 2 } ^ { * } } \end{array}$ , and we also show this below.
In contrast, Gunasekar et al. (2017) shows that as $\alpha 0$ , gradient flow leads instead to the minimum $\ell _ { 1 }$ norm solution $\begin{array} { r } { \operatorname* { l i m } _ { \alpha \to 0 } \beta _ { \alpha } ( \infty ) = \beta _ { L 1 } ^ { * } \doteq \arg \operatorname* { m i n } _ { X \beta = y } \| \beta \| _ { 1 } } \end{array}$ . This is the “rich regime.” Comparing this with the kernel regime, we already see two very distinct behaviors and, in high dimensions, two very different inductive biases. In particular, the rich regime’s bias is not an RKHS norm for any choice of kernel. Can we charactarize and understand the transition between the two regimes as $\alpha$ transitions from very small to very large? The following theorem does just that.
Theorem 1. For any $0 < \alpha < \infty$
$${ \displaystyle \beta _ { \alpha } ( \infty ) = \hat { \beta } _ { \alpha } \doteq \arg \operatorname* { m i n } _ { \beta } Q _ { \alpha } ( \beta ) \ s . t . \ X \beta = \bf y } ,$$
$$\begin{array} { r } { Q _ { \alpha } \left( \beta \right) = \sum _ { i = 1 } ^ { d } q \left( \frac { \beta _ { i } } { \alpha ^ { 2 } } \right) a n d q ( z ) = \int _ { 0 } ^ { z } \operatorname { a r c s i n h } \left( \frac { u } { 2 } \right) d u = 2 - \sqrt { 4 + z ^ { 2 } } + z \operatorname { a r c s i n h } \left( \frac { z } { 2 } \right) } \end{array}$$
Proof sketch The proof in Appendix A proceeds by showing the gradient flow dynamics on w lead to a solution of the form
$$\beta _ { \alpha } ( \infty ) = \alpha ^ { 2 } \left( \exp \left( - 4 X ^ { \top } \int _ { 0 } ^ { \infty } r _ { \alpha } ( t ) d t \right) - \exp \left( 4 X ^ { \top } \int _ { 0 } ^ { \infty } r _ { \alpha } ( t ) d t \right) \right)$$
where $\pmb { r } _ { \alpha } ( t ) = X \beta _ { \alpha } ( t ) - \mathbf { y }$ . While evaluating the integral would be very difficult, the fact that
$${ \displaystyle \beta _ { \alpha } ( \infty ) \in \left\{ \alpha ^ { 2 } \left( \exp \left( - X ^ { \top } { \bar { r } } \right) - \exp \left( X ^ { \top } { \bar { r } } \right) : { \bar { r } } \in \mathbb { R } ^ { N } \right) \right\} }$$
already provides a dual certificate for the KKT conditions for $\mathrm { m i n } _ { \beta } Q _ { \alpha } \left( \beta \right)$ s.t. $X { \boldsymbol { \beta } } = \mathbf { y }$
In light of Theorem 1, the function $Q _ { \alpha }$ (referred to elsewhere as the “hypentropy” function (Ghai et al., 2019)) can be understood as an implicit regularizer which biases the gradient flow solution towards one particular zero-error solution out of the many possibilities. As $\alpha$ ranges from 0 to $\infty$ , the $Q _ { \alpha }$ regularizer interpolates between the $\ell _ { 1 }$ and $\ell _ { 2 }$ norms, as illustrated (labelled $D = 2$ ) in Figure 2a, which shows the coordinate function $q$ . As $\alpha \infty$ we have that $\beta _ { i } / \alpha ^ { 2 } 0$ , and so the behaviour of $Q _ { \alpha } ( \beta )$ is controlled by the behaviour of $q ( z )$ around $z = 0$ . In this regime $\begin{array} { r } { q ( z ) = \frac { z ^ { 2 } } { 4 } + O ( z ^ { 4 } ) } \end{array}$ is quadratic, and so $\begin{array} { r } { Q _ { \alpha } ( \beta ) { \tilde { \propto } } \sum _ { i } \beta _ { i } ^ { 2 } = \left\| \beta \right\| _ { 2 } ^ { 2 } } \end{array}$ . On the other hand when $\alpha 0$ $\beta _ { i } / \alpha ^ { 2 } \to \infty$ is governed by the asymptotic behaviour $q ( z ) = \Theta ( z \log z )$ as $z \infty$ . In this regime $\begin{array} { r } { Q _ { \alpha } ( \beta ) { \tilde { \propto } } \sum _ { i } \frac { \beta _ { i } } { \alpha ^ { 2 } } \log \frac { \beta _ { i } } { \alpha ^ { 2 } } \propto \| \beta \| _ { 1 } + o ( 1 ) } \end{array}$ . For any initialization scale $\alpha$ , the function $Q _ { \alpha }$ describes exactly how training will interpolate between the kernel and rich regimes. The following Theorems, proven in Appendix B, provide a quantitative statement of how the $\ell _ { 1 }$ and $\ell _ { 2 }$ norms are approached as $\alpha 0$ and $\alpha \to \infty$ respectively:
 Figure 1: In (a), the population error of the gradient flow solution vs. $\alpha$ in the sparse regression problem described in Section 4. In (b), the excess $\ell _ { 1 }$ norm (blue) and excess $\ell _ { 2 }$ norm (red) of the gradient flow solution, i.e. $\left\| \beta _ { \alpha } ( \infty ) \right\| _ { 1 } - \left\| \beta _ { L 1 } ^ { * } \right\| _ { 1 }$ and $\left\| \beta _ { \alpha } ( \infty ) \right\| _ { 2 } - \left\| \beta _ { L 2 } ^ { * } \right\| _ { 2 }$ . In (c), the largest $\alpha$ such that $\beta _ { \alpha } ( \infty )$ achieves population error at most 0.025 is shown. The dashed line indicates the number of samples needed by $\beta _ { L 1 } ^ { * }$ .
Theorem 2. For any $0 < \epsilon < d$
$$\begin{array} { r l } & { \alpha \leq \operatorname* { m i n } \left. \left( 2 ( 1 + \epsilon ) \| \beta _ { L 1 } ^ { * } \| _ { 1 } \right) ^ { - \frac { 2 + \epsilon } { 2 \epsilon } } , \exp \left( - d / ( \epsilon \| \beta _ { L 1 } ^ { * } \| _ { 1 } ) \right) \right. \implies \| \hat { \beta } _ { \alpha } \| _ { 1 } \leq ( 1 + \epsilon ) \| \beta _ { L 1 } ^ { * } \| _ { 1 } } \\ & { \qquad \alpha \geq \sqrt { 2 ( 1 + \epsilon ) ( 1 + 2 / \epsilon ) \| \beta _ { L 2 } ^ { * } \| _ { 2 } } \implies \| \hat { \beta } _ { \alpha } \| _ { 2 } ^ { 2 } \leq ( 1 + \epsilon ) \| \beta _ { L 2 } ^ { * } \| _ { 2 } ^ { 2 } } \end{array}$$
Theorem 2 indicates a certain asymmetry between reaching the rich and kernel regimes: polynomially large $\alpha$ suffices to approximate $\beta _ { L 2 } ^ { * }$ to a very high degree of accuracy. On the other hand, exponentially small $\alpha$ is sufficient to approximate $\beta _ { L 1 } ^ { * }$ , and Lemma 2 in Appendix B proves that $\alpha \leq d ^ { - \Omega ( 1 / \epsilon ) }$ is necessary in order for $Q _ { \alpha }$ to be proportional to the $\ell _ { 1 }$ norm, which indicates that $\alpha$ must be exceedingly small to approximate $\beta _ { L 1 } ^ { * }$ for certain problems.
This suggestive of an explanation for the difficulty of demonstrating rich regime behavior empirically in matrix factorization problems (Gunasekar et al., 2017; Arora et al., 2019a). If the initialization really needs to be exponentially small, then conducting experiments in this regime may be infeasible for practical reasons.
In order to understand the effects of initialization on generalization, consider a simple sparse regression problem, where $\mathbf { x } ^ { ( 1 ) } , \ldots , \mathbf { x } ^ { ( N ) } \sim N ( 0 , I )$ and $\dot { y } ^ { ( n ) } = \big \langle \beta ^ { * } , \mathbf { x } ^ { ( n ) } \big \rangle + N ( 0 , \bar { 0 . } 0 1 )$ where $\beta ^ { * }$ is $r ^ { * }$ -sparse and its non-zero entries are $1 / \sqrt { r ^ { * } }$ . When $N \leq d$ , gradient flow will reach a zero training error solution, however, not all of these solutions will generalize the same. With $N = \Theta ( r ^ { * } \log d )$ samples, the rich regime, i.e. the minimum $\ell _ { 1 }$ norm solution will generalize well. However, even though we can fit the training data perfectly well, we should not expect any generalization in the kernel regime with this sample size $N = \Omega ( d )$ samples would be needed that regime), see Figure 1c. In this case, to generalize well may require using very small initialization, and generalization will improve as we decrease $\alpha$ . From an optimization perspective this is unfortunate because ${ \bf w } = 0$ is a saddle point, so taking $\alpha 0$ drastically increases the time needed to escape the saddle point.
Thus, there is a tension here between generalization and optimization: a smaller $\alpha$ might improve generalization, but it makes optimization trickier. This suggests that in practice we would want to compromise, and operate just at the edge of the rich regime, using the largest $\alpha$ that still allows for generalization. This is borne out in our neural network experiments in Section 7, where standard initialization schemes correspond to being right on the edge of entering the kernel regime, where we expect models to both generalize well and avoid serious optimization difficulties.
The tension between optimization and generalization can also be seen through a tradeoff between the sample size and the largest $\alpha$ we can use and still generalize. In Figure 1c, for each sample size $N$ , we plot the largest $\alpha$ for which the gradient flow solution $\hat { \beta } _ { \alpha }$ achieves population risk below some threshold. As $N$ approaches the number of samples needed for $\beta _ { L 1 } ^ { * }$ to generalize (the vertical dashed line), $\alpha$ must become extremely small. However, generalization is much easier when the number of samples is only slightly larger, and we can use much more moderate initialization.
 Figure 2: (a) $q _ { D } ( z )$ for several values of $D$ . (b) The ratio $\frac { Q _ { \alpha } ^ { D } ( e _ { 1 } ) } { Q _ { \alpha } ^ { D } ( \mathbf { 1 } _ { d } / \| \mathbf { 1 } _ { d } \| _ { 2 } ) }$ as a function of $\alpha$ , where $e _ { 1 } ~ =$ $[ 1 , 0 , 0 , \ldots , 0 ]$ is the first standard basis vector and $\mathbf { 1 } _ { d } ~ = ~ [ 1 , 1 , \ldots , 1 ]$ is the all ones vector in $\mathbb { R } ^ { d }$ . This captures the transition between approximating the √ $\ell _ { 2 }$ norm (where the ratio is 1) and the $\ell _ { 1 }$ norm (where the ratio is $1 / \sqrt { d } )$ . (c) sparse regression simulation as in Figure 1, using different order models. The y-axis is $\alpha ^ { D }$ (the scale of $\beta$ at initialization) needed to recover the planted predictor to accuracy 0.025. The dashed line indicates the number of samples needed in order for $\beta _ { L 1 } ^ { * }$ to approximate the plant.
# 5 HIGHER ORDER MODELS
In the previous Section, we considered a 2-homogeneous model, corresponding to a simple depth-2 “diagonal” network. Deeper models correspond to higher order homogeneity (a depth- $D$ ReLU or linear network is $D$ -homogeneous), motivating us to understand the effect of the order of homogeneity on the transition between the regimes. We therefore generalize our model and consider:
$$F _ { D } ( \mathbf { w } ) = \beta _ { \mathbf { w } , D } = \mathbf { w } _ { + } ^ { D } - \mathbf { w } _ { - } ^ { D } \quad \mathrm { a n d } \quad f _ { D } ( \mathbf { w } , \mathbf { x } ) = \langle \mathbf { w } _ { + } ^ { D } - \mathbf { w } _ { - } ^ { D } , \mathbf { x } \rangle$$
We again consider initializing all weights equally so $\mathbf { w } _ { 0 } = \mathbf { 1 }$ . As before, this is just a linear regression model with an unconventional parametrization. It is equivalent to a depth- $D$ matrix factorization model with commutative measurement matrices, as studied by Arora et al. (2019a), and can be thought of as a depth- $D$ diagonal linear network.
We can again study the effect of the scale of the initialization $\alpha$ on the implicit bias. Let $\beta _ { \alpha , D } ( \infty )$ denote the limit of gradient flow on w when initialized at $\alpha 1$ for the $D$ -homogeneous model. Using the same approach as in Section 4, in Appendix $\textrm { C }$ we show:
Theorem 3. For any $\alpha$ and $D \geq 3 ,$ , if gradient flow reaches a solution $X \beta _ { \alpha , D } ( \infty ) = y$ , then
$$\beta _ { \alpha , D } ( \infty ) = \arg \operatorname* { m i n } _ { \beta } Q _ { \alpha } ^ { D } ( \beta ) \ s . t \ \mathbf { X } \beta = \mathbf { y }$$
where $\begin{array} { r } { Q _ { \alpha } ^ { D } ( \beta ) = \sum _ { i = 1 } ^ { d } q _ { D } \big ( \beta _ { i } / \alpha ^ { D } \big ) } \end{array}$ and $q _ { D } = \int h _ { D } ^ { - 1 }$ is the antiderivative of the unique inverse of $h _ { D } ( z ) = ( 1 - z ) ^ { - \frac { D } { D - 2 } } - ( 1 + z ) ^ { - \frac { D } { D - 2 } }$ on $[ - 1 , 1 ]$ . Furthermore, $\begin{array} { r } { \operatorname* { l i m } _ { \alpha \to 0 } \beta _ { \alpha , D } ( \infty ) = \beta _ { L 1 } ^ { * } } \end{array}$ and $\begin{array} { r } { \operatorname* { l i m } _ { \alpha \to \infty } \beta _ { \alpha , D } ( \infty ) = \beta _ { L 2 } ^ { * } } \end{array}$ .
In the two extremes we see that we again get the minimum $\ell _ { 2 }$ solution in the kernel regime, and more interestingly, for any depth $D \geq 2$ , we get the same minimum $\ell _ { 1 }$ norm solution in the rich regime, as has also been observed by Arora et al. (2019a). The fact that the rich regime solution does not change with depth is perhaps surprising, and does not agree from what is obtained with explicit regularization (regularizing $\lVert \boldsymbol { w } \rVert _ { 2 }$ is equivalent to $\| \beta \| _ { 2 / D }$ regularization), nor with implicit regularization on logistic-type loss Gunasekar et al. (2017).
Although the two extremes do not change as we go beyond $D = 2$ , what does change is the intermediate regime (the regularizer $Q _ { \alpha } ^ { D }$ is unique and cannot be obtained with any other order $D ^ { \prime } \neq D$ ), as well as the sharpness of the transition into the extreme regimes, as illustrated in Figures 2a-2c. The most striking difference is that for order $D > 2$ the scale of $\alpha$ needed to approximate the $\ell _ { 1 }$ is polynomial rather then exponential, yielding a much quicker transition to the “rich regime”, and allowing near-optimal sparse regression with reasonable initialization scales. Increasing $D$ further hastens the transition. This might also help explain some of the empirical observations about the benefit of depth in deep matrix factorization Arora et al. (2019a).
 Figure 3: Regimes in Matrix Completion We generated a $1 0 \times 1 0$ rank-one matrix completion problem with ground truth $M ^ { * } = u ^ { * } ( v ^ { * } ) ^ { \top }$ by generating $u ^ { \ast } , v ^ { \ast } \in \mathbb { R } ^ { 1 0 }$ with i.i.d. $\mathcal { N } ( 0 , 1 )$ entries and observing $N = 6 0$ random entries $\Omega$ . We fit the observed entries by minimizing the squared loss on a matrix factorization model $F ( U , V ) = U V ^ { \top }$ with $U , V ~ \in ~ \mathbb { R } ^ { d \times 2 k }$ . For different scalings $\alpha$ , we examine the matrix $M ( \infty )$ reached by gradient flow on $U , V$ (solved using python ODE solvers) and plot (i) the reconstruction error on unobserved entries $\begin{array} { r } { \sum _ { i j \notin \Omega } ( M _ { i j } ^ { * } - M ( \infty ) _ { i j } ) ^ { 2 } } \end{array}$ , and (ii) the amount by which the unobserved entries changed during optimization $\begin{array} { r } { \sum _ { i j \notin \Omega } ( M ( \infty ) _ { i j } - M ( 0 ) _ { i j } ) ^ { 2 } } \end{array}$ . In (a) we used $k = 2 d$ and initialized to $U _ { 0 } = V _ { 0 } = \alpha I$ . In (b) for varying $k$ , we initialized to $U _ { 0 } = \alpha \bar { U } _ { 0 }$ and $V _ { 0 } = \alpha \bar { V } _ { 0 }$ with $\bar { U } _ { 0 } , \bar { V } _ { 0 } \in \mathbb { R } ^ { d \times k }$ with i.i.d. $\mathcal { N } ( 0 , 1 )$ entries. For large $k$ , the tangent kernel converges to the kernel corresponding to the Frobenius norm.
# 6 DEMONSTRATION IN MATRIX COMPLETION
We now turn to a more complex depth two model, namely a matrix factorization model, and demonstrate similar transitions empirically. Specifically, we consider the model over matrix inputs $X \in \mathbb { R } ^ { d \times d }$ defined by $f ( ( U , { \dot { V } } ) , X ) \mathbf { \bar { \Psi } } = \left. { \dot { U } } V ^ { \top } , X \right.$ , where $U , V \in \mathbb { R } ^ { d \times k }$ . This corresponds to linear predictors over matrix arguments specified by $F ( U , V ) = U V ^ { \top }$ . In overparameterized regime with $k \geq d$ , the parameterization itself does not introduce any explicit rank constraints. We consider here a random low rank matrix completion problem where Xn = eine>jn represents an uniform random observation of entry $( i _ { n } , j _ { n } )$ of a planted low rank matrix $M ^ { * }$ of rank $r ^ { * } \ll d$ : $y _ { n } = \langle M ^ { * } , X _ { n } \rangle = M _ { i j } ^ { * }$ . For underdetermined problems where $N \ll d ^ { 2 }$ , there are many trivial global minimizers, most of which are not low rank and hence will not guarantee recovery. As was demonstrated empirically by Gunasekar et al. (2017) and also proven rigorously for Gaussian measurements by Li et al. (2018), as $\alpha 0$ gradient flow implicitly regularizes the nuclear norm, which for random measurements leads to recovery of ground truth (Candès and Recht, 2009; Recht et al., 2010): these are very different and rich implicit biases that are not RKHS norms.
Crucially, the reconstruction results in Gunasekar et al. (2017) and Li et al. (2018) are dependent on initialization with scale $\alpha 0$ . Here we further explore the role of initialization. Similar to Section 4, in order to get unbiased 0 initialization, we consider $k \geq 2 d$ and initialization of the form $U ( 0 ) = \alpha \left[ U _ { 0 } , - U _ { 0 } \right]$ and $V ( 0 ) = \alpha \left[ V _ { 0 } , V _ { 0 } \right]$ , where $U _ { 0 } , V _ { 0 } \in \mathbb { R } ^ { d \times k / 2 }$ . We will study implicit bias of gradient flow over the factorized parameterization with above initialization.
For matrix completion problems with $X = e _ { i _ { X } } e _ { j _ { X } } ^ { \top }$ , the tangent kernel at initialization is given by $K _ { 0 } ( X , X ^ { \prime } ) \propto \langle U _ { 0 } [ i _ { X } , : ] , U _ { 0 } [ i _ { X ^ { \prime } } , : ] \rangle { \bf 1 } ( j _ { X } = j _ { X ^ { \prime } } ) + \langle V _ { 0 } [ j _ { X } , : ] , V _ { 0 } [ j _ { X ^ { \prime } } , : ] \rangle { \bf 1 } ( i _ { X } = i _ { X ^ { \prime } } )$ . This defaults to the trivial delta kernel $K ( X , X ^ { \prime } ) = { \bf 1 } ( i _ { X } = i _ { X ^ { \prime } } ) \cdot { \bf 1 } ( j _ { X } = j _ { X ^ { \prime } } )$ for the two special cases (a) $U _ { 0 } , V _ { 0 }$ have orthogonal columns (e.g. $U _ { 0 } = V _ { 0 } = I \rangle$ ), or (b) $U _ { 0 } , V _ { 0 }$ have independent Gaussian entries and $k \infty$ . In these cases, minimizing the RKHS norm of the tangent kernel corresponds to returning a zero imputed matrix (minimum Frobenius norm solution). Figure 3 demonstrates the behaviour of gradient flow updates in the “rich" regime (where for $\alpha 0$ recovers the ground truth) and in the “kernel" regime (where for large $\alpha$ , there are no updates to the unobserved entries).
# 7 NEURAL NETWORK EXPERIMENTS
In the preceding sections, we intentionally focused on the simplest possible models in which a kernel-to-rich transition can be observed, in order to isolate this phenomena and understand it in detail. In those simple models, we were able to obtain a complete analytic description of the transition. Obtaining such a precise description in more complex models is somewhat optimistic at this point, as we do not yet have a satisfying description of even just the rich regime. Instead, we now provide empirical evidence suggesting that also for non-linear and realistic networks, the scale of initialization induces a transition into and out of a “kernel” regime, and that to reach good generalization we must operate outside of the “kernel” regime. To track whether we are in the “kernel” regime, we track how much the gradient $\nabla _ { \mathbf { w } } { f } ( \mathbf { w } ( t ) , \mathbf { x } )$ changes throughout training. In particular, we define the gradient distance to be the cosine distance between the initial tangent kernel feature map $\nabla _ { \mathbf { w } } { f } ( \mathbf { w } ( 0 ) , \mathbf { x } )$ and the final tangent kernel feature map $\nabla _ { \mathbf { w } } { f } ( \mathbf { w } ( T ) , \mathbf { x } )$ .
In Figures 4a and $^ { 4 \mathrm { b } }$ , we see that also for a non-linear ReLU network, we remain in the kernel regime when the initialization is large, and that exiting from the kernel regime is necessary in order to achieve small test error on the synthetic data. Interestingly, when $\alpha ^ { D ^ { - } } \approx 1$ , the models achieve good test error but have smaller gradient distance which, not coincidentally, corresponds to using the out-of-the-box Uniform He initialization. This lies on the boundary between the rich and kernel regimes, which is desirable due to the learning vs. optimization tradeoffs discussed in Section 4. On MNIST data, Figure 4e shows that previously published successes with training overly wide depth-2 ReLU networks without explicit regularization (e.g. Neyshabur et al., 2014) relies on the initialization being small, i.e. being outside of the “kernel regime”. In fact, the $2 . 4 \%$ test error reached for large initialization is no better than what can be achieved with a linear model over a random feature map. Turning to a more realistic network, 4f shows similar behavior when training a VGG11-like network on CIFAR10.
So far, we attempted to use the best fixed stepsize for each initialization (i.e. achieving the best test error). But as demonstrated in Figures 4c and 4d, the stepsize choice can also have a significant effect, with larger stepsizes allowing one to exit the kernel regime even at an initialization scale where a smaller stepsize would remain trapped in the kernel regime. Further analytic and empirical studies are necessary in order to understand the joint behavior of the stepsize and initialization scale.
# 8 DISCUSSION
The main point of this paper is to emphasize the distinction between the “kernel” regime in training overparametrized multi-layered networks, and the “rich” (active, adaptive) regime, show how the scaling of the initialization can transition between them, and understand this transition in detail. We argue that rich inductive bias that enables generalization may arise in the rich regime, but that focusing on the kernel regime restricts us to only what can be done with an RKHS. By studying the transition we also see a tension between generalization and optimization, which suggests we would tend to operate just on the edge of the rich regime, and so understanding this transition, rather then just the extremes, is important. Furthermore, we see that at the edge of the rich regime, the implicit bias of gradient descent differs substantively from that of explicit regularization. Although in our theoretical study we focused on a simple model so that we can carry out a complete and exact analysis analytically, our experiments show that this is representative of the behaviour also in other homogeneous models, and serve as a basis of a more general understanding.
Effect of Width Our treatment focused on the effect of scale on the transition between the regimes, and we saw that, as pointed out by Chizat and Bach, we can observe a very meaningful transition between a kernel and rich regime even for finite width parametric models. The transition becomes even more interesting if the width of the model (the number of units per layer, and so also the number of parameters) increases towards infinity. In this case, we must be careful as to how the initialization of each individual unit scales when the total number of units increase, and which regime we fall in to is controlled by the relative scaling of the width and the scale of individual units at initialization. This is demonstrated, for example, in Figure 5, which shows the regime change in matrix factorization problems, from minimum Frobenius norm recovery (the kernel regime) to minimum nuclear norm recovery (the rich regime), as a function of both the number of factors $k$ and the scale of initialization of each factor $\alpha$ . As is expected, the scale $\alpha$ at which we see the transition decreases as the model becomes wider, but further study is necessary to obtain a complete understanding of this scaling.
A particularly interesting aspect of infinite width networks is that, unlike for fixed-width networks, it may be possible to scale $\alpha$ relative to the width $k$ such that at the infinite-width limit we would have an (asymptotically) unbiased predictor at initialization $\mathrm { l i m } _ { k \to \infty } F _ { k } ( { \bf w } ( 0 ) ) = 0$ , or at least a non-exploding initialization $\mathrm { l i m } \mathrm { s u p } _ { k \to \infty } \| F _ { k } ( \mathbf { w } ( 0 ) ) \| = O ( 1 )$ , even with random initialization (without a doubling trick leading to artificially unbiased initialization), while still being in the kernel regime. For two-layer networks with ReLU activation, Arora et al. (2019b) showed that with width $k \stackrel { \cdot } { \geq } \mathrm { p o l y } ( 1 / \operatorname* { m a x } _ { \| x \| _ { 2 } \leq 1 , N } \| f _ { 0 } ( x ) \| )$ the gradient dynamics stay in the kernel regime forever.
 Figure 4: Synthetic Data: we generated a small regression training set in $\mathbb { R } ^ { 2 }$ by sampling 10 points uniformly from the unit circle, and labelling them with a 1 hidden layer teacher network with 3 hidden units. We trained overparametrized depth- $. D$ , ReLU networks with 30 units per layer with squared loss using full GD and a small stepsize 0.01. The weights of the network are set using the Uniform He initialization, and then multiplied by $\alpha$ . The model is trained until $\approx 0$ training loss. Shown in (a) and (b) are the test error and grad distance vs. the depth-adjusted scale of the initialization, $\overline { { \alpha } } ^ { D }$ , when a small constant stepsize is used. for (c) and (d), we fix $\alpha$ near the transition into the kernel regime, and show the test error and grad distance vs. the stepsize. MNIST: we trained a depth-2 with 5000 hidden units with cross-entropy loss using SGD until it reached $100 \%$ training accuracy. The stepsizes were optimally tuned for each $\alpha$ individually. In (e), the dashed line shows the test error of the resulting network vs. $\alpha$ . We repeated the experiment, but froze the bottom layer and only trained the output layer until convergence. The solid line shows the test error of this predictor vs $\alpha$ . CIFAR10: we trained a VGG11-like deep convolutional network with cross-entropy loss using SGD and a small stepsize $1 0 ^ { - 4 }$ for 2000 epochs; all models reached $100 \%$ training accuracy. In (f), the dashed line shows the final test error vs. $\alpha$ . We repeated the experiment freezing the bottom 10 layers and training only the output layer–the solid line shows this model’s test error. See Appendix E for full details about all of the experiments.
# REFERENCES
Zeyuan Allen-Zhu, Yuanzhi Li, and Zhao Song. A convergence theory for deep learning via overparameterization. arXiv preprint arXiv:1811.03962, 2018.
Sanjeev Arora, Nadav Cohen, Wei Hu, and Yuping Luo. Implicit regularization in deep matrix factorization. arXiv preprint arXiv:1905.13655, 2019a.
Sanjeev Arora, Simon S Du, Wei Hu, Zhiyuan Li, and Ruosong Wang. Fine-grained analysis of optimization and generalization for overparameterized two-layer neural networks. arXiv preprint arXiv:1901.08584, 2019b.
Emmanuel J Candès and Benjamin Recht. Exact matrix completion via convex optimization. Foundations of Computational mathematics, 9(6):717–772, 2009.
Lenaic Chizat and Francis Bach. A note on lazy training in supervised differentiable programming. arXiv preprint arXiv:1812.07956, 2018.
Amit Daniely. SGD learns the conjugate kernel class of the network. In Advances in Neural Information Processing Systems, pages 2422–2430, 2017.
Amit Daniely, Roy Frostig, and Yoram Singer. Toward deeper understanding of neural networks: The power of initialization and a dual view on expressivity. In Advances In Neural Information Processing Systems, pages 2253–2261, 2016.
Simon S Du, Jason D Lee, Haochuan Li, Liwei Wang, and Xiyu Zhai. Gradient descent finds global minima of deep neural networks. arXiv preprint arXiv:1811.03804, 2018.
Simon S. Du, Xiyu Zhai, Barnabas Poczos, and Aarti Singh. Gradient descent provably optimizes over-parameterized neural networks. In International Conference on Learning Representations, 2019.
Rong Ge, Furong Huang, Chi Jin, and Yang Yuan. Escaping from saddle points—online stochastic gradient for tensor decomposition. In Proceedings of The 28th Conference on Learning Theory, pages 797–842, 2015.
Udaya Ghai, Elad Hazan, and Yoram Singer. Exponentiated gradient meets gradient descent. arXiv preprint arXiv:1902.01903, 2019.
Suriya Gunasekar, Blake E Woodworth, Srinadh Bhojanapalli, Behnam Neyshabur, and Nati Srebro. Implicit regularization in matrix factorization. In Advances in Neural Information Processing Systems, pages 6151–6159, 2017.
Suriya Gunasekar, Jason Lee, Daniel Soudry, and Nathan Srebro. Characterizing implicit bias in terms of optimization geometry. arXiv preprint arXiv:1802.08246, 2018a.
Suriya Gunasekar, Jason Lee, Daniel Soudry, and Nathan Srebro. Implicit bias of gradient descent on linear convolutional networks. arXiv preprint arXiv:1806.00468, 2018b.
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.
Arthur Jacot, Franck Gabriel, and Clément Hongler. Neural tangent kernel: Convergence and generalization in neural networks. arXiv preprint arXiv:1806.07572, 2018.
Ziwei Ji and Matus Telgarsky. Gradient descent aligns the layers of deep linear networks. arXiv preprint arXiv:1810.02032, 2018.
Jaehoon Lee, Lechao Xiao, Samuel S Schoenholz, Yasaman Bahri, Jascha Sohl-Dickstein, and Jeffrey Pennington. Wide neural networks of any depth evolve as linear models under gradient descent. arXiv preprint arXiv:1902.06720, 2019.
Yuanzhi Li, Tengyu Ma, and Hongyang Zhang. Algorithmic regularization in over-parameterized matrix sensing and neural networks with quadratic activations. In Conference On Learning Theory, pages 2–47, 2018.
Song Mei, Theodor Misiakiewicz, and Andrea Montanari. Mean-field theory of two-layers neural networks: dimension-free bounds and kernel limit. arXiv preprint arXiv:1902.06015, 2019.
Behnam Neyshabur, Ryota Tomioka, and Nathan Srebro. In search of the real inductive bias: On the role of implicit regularization in deep learning. arXiv preprint arXiv:1412.6614, 2014.
Benjamin Recht, Maryam Fazel, and Pablo A Parrilo. Guaranteed minimum-rank solutions of linear matrix equations via nuclear norm minimization. SIAM review, 52(3):471–501, 2010.
Pedro Savarese, Itay Evron, Daniel Soudry, and Nathan Srebro. How do infinite width bounded norm networks look in function space? arXiv preprint arXiv:1902.05040, 2019.
Daniel Soudry, Elad Hoffer, Mor Shpigel Nacson, Suriya Gunasekar, and Nathan Srebro. The implicit bias of gradient descent on separable data. Journal of Machine Learning Research, 19(70), 2018.
Greg Yang. Scaling limits of wide neural networks with weight sharing: Gaussian process behavior, gradient independence, and neural tangent kernel derivation. arXiv preprint arXiv:1902.04760, 2019.
Peng Zhao, Yun Yang, and Qiao-Chu He. Implicit regularization via hadamard product overparametrization in high-dimensional linear regression. 03 2019.
Difan Zou, Yuan Cao, Dongruo Zhou, and Quanquan Gu. Stochastic gradient descent optimizes over-parameterized deep relu networks. arXiv preprint arXiv:1811.08888, 2018.
# A PROOF OF THEOREM 1
It is straightforward, given the expression for $Q _ { \alpha }$ , to prove that $\hat { \beta } _ { \alpha }$ is the minimum $Q _ { \alpha }$ solution to $X { \boldsymbol { \beta } } = \mathbf { y }$ . In other words, if we had been able to guess from the beginning that the implicit bias would be governed by $Q _ { \alpha }$ , it would have been easy to prove this fact. However, a key contribution of this work is in developing a method for determining what the implicit bias is when we do not already have a good guess.
We will first describe a general approach for deriving the implied regularizer reached at the limit of some gradient flow dynamics which minimize the loss. In particular, our approach will apply whenever solutions of the gradient flow dynamics can be written as $\beta _ { \alpha } ( t ) = f _ { \alpha } \dot { ( } \dot { X } ^ { \top } \nu ( t ) )$ for some $\nu ( t )$ .
The first step is to analyze the gradient flow dynamics of $\beta _ { \alpha }$ and show that
$$\begin{array} { c } { { X \beta _ { \alpha } ( \infty ) = \mathbf { y } } } \\ { { \beta _ { \alpha } ( \infty ) = f _ { \alpha } ( X ^ { \top } \boldsymbol { \nu } ( \infty ) ) } } \end{array}$$
for some function $f _ { \alpha }$ and some vector $\nu ( \infty )$ . It is not important for our approach to know exactly what $\nu ( \infty )$ is. This is useful because calculating this $\nu ( \infty )$ will often be difficult, even for the simple examples we consider.
The next step is to suppose that there is some function $Q _ { \alpha }$ such that
$$\beta _ { \alpha } ( \infty ) = \underset { \beta } { \arg \operatorname* { m i n } } Q _ { \alpha } ( \beta ) \quad \mathrm { s . t . } \quad X \beta = \mathbf { y }$$
and to write down the KKT optimality conditions for (10):
$$\begin{array} { c } { { X { \boldsymbol { \beta } } ^ { * } = \mathbf { y } } } \\ { { \exists \nu \ \nabla Q _ { \alpha } \left( { \boldsymbol { \beta } } ^ { * } \right) = X ^ { \top } \nu } } \end{array}$$
Finally, we connect (9) with (11). Specifically, $\beta _ { \alpha } ( \infty )$ satisfies the first KKT condition, and, if $\beta _ { \alpha } ( \infty ) = \beta ^ { * }$ then by taking $\nu = \nu ( \infty )$ we have
$$\nabla Q _ { \alpha } \left( \beta _ { \alpha } ( \infty ) \right) = \nabla Q _ { \alpha } \left( f _ { \alpha } ( X ^ { \top } \nu ) \right) = X ^ { \top } \nu$$
It follows that $\nabla Q _ { \alpha } ( \beta ) = f _ { \alpha } ^ { - 1 } ( \beta )$ . Therefore, to derive $Q _ { \alpha }$ we simply invert $f _ { \alpha }$ and integrate its inverse. We prove Theorems 1 and 3 using this method.
Theorem 1. For any $0 < \alpha < \infty$
$${ \displaystyle \beta _ { \alpha } ( \infty ) = \hat { \beta } _ { \alpha } \doteq \arg \operatorname* { m i n } _ { \beta } Q _ { \alpha } ( \beta ) \ s . t . \ X \beta = \bf y } ,$$
$$\begin{array} { r } { Q _ { \alpha } \left( \beta \right) = \sum _ { i = 1 } ^ { d } q \left( \frac { \beta _ { i } } { \alpha ^ { 2 } } \right) a n d q ( z ) = \int _ { 0 } ^ { z } \mathrm { a r c s i n h } \left( \frac { u } { 2 } \right) d u = 2 - \sqrt { 4 + z ^ { 2 } } + z \mathrm { a r c s i n h } \left( \frac { z } { 2 } \right) } \end{array}$$
Proof. We begin by calculating the gradient flow dynamics on w, since the linear predictor $\beta _ { \alpha } ( \infty )$ is given by $F$ applied to the limit of the gradient flow dynamics on w. Recalling that $\tilde { X } = [ X \quad - X ]$ ,
$$\begin{array} { r } { \dot { \mathbf { w } } _ { \alpha } ( t ) = - \nabla L ( \mathbf { w } _ { \alpha } ( t ) ) = - \nabla \left( \left\| \tilde { X } \mathbf { w } _ { \alpha } ( t ) ^ { 2 } - y \right\| _ { 2 } ^ { 2 } \right) = - 2 \tilde { X } ^ { \top } r _ { \alpha } ( t ) \circ \mathbf { w } _ { \alpha } ( t ) } \end{array}$$
where the residual $r _ { \alpha } ( t ) \triangleq \tilde { X } \mathbf { w } _ { \alpha } ( t ) ^ { 2 } - y$ , and $a \circ b$ denotes the element-wise product of $a$ and $b$ . It is easily confirmed that these dynamics have a solution:
$${ \bf w } _ { \alpha } ( t ) = { \bf w } _ { \alpha } ( 0 ) \circ \exp \left( - 2 \tilde { X } ^ { \top } \int _ { 0 } ^ { t } r _ { \alpha } ( s ) d s \right)$$
This immediately gives an expression for $\beta _ { \alpha } ( t )$ :
$$\begin{array} { l } { { \displaystyle { \beta _ { \alpha } ( t ) = { \bf w } _ { \alpha , + } ( t ) ^ { 2 } - { \bf w } _ { \alpha , - } ( t ) ^ { 2 } \qquad } } } \\ { { \displaystyle ~ = \alpha ^ { 2 } \left( \exp \left( - 4 X ^ { \top } \int _ { 0 } ^ { t } r _ { \alpha } ( s ) d s \right) - \exp \left( 4 X ^ { \top } \int _ { 0 } ^ { t } r _ { \alpha } ( s ) d s \right) \right) } } \\ { { \displaystyle ~ = 2 \alpha ^ { 2 } \sinh \left( - 4 X ^ { \top } \int _ { 0 } ^ { t } r _ { \alpha } ( s ) d s \right) } } \end{array}$$
In addition, this problem satisfies the strict saddle property (Ge et al., 2015) (Zhao et al., 2019, Lemma 2.1), therefore gradient flow will converge to a zero-error solution, i.e. $X \beta _ { \alpha } ( \infty ) = y$ . Thus, we conclude that $\beta _ { \alpha } ( \infty )$ is a global minimum with zero error, i.e. $X \beta _ { \alpha } ( \infty ) = \mathbf { y }$ .
Thus, we have established that
$$\begin{array} { c } { { X \beta _ { \alpha } ( \infty ) = \mathbf { y } } } \\ { { \beta _ { \alpha } ( \infty ) = f _ { \alpha } ( X ^ { \top } \boldsymbol { \nu } ( \infty ) ) } } \end{array}$$
for $f _ { \alpha } ( z ) = 2 \alpha ^ { 2 } \sinh ( z )$ and $\begin{array} { r } { \nu ( \infty ) = - 4 \int _ { 0 } ^ { t } r _ { \alpha } ( s ) d s } \end{array}$ . This corresponds to (9) from our general approach detailed above. Continuing from (12) we have that
$$\nabla Q _ { \alpha } ( \beta ) = f _ { \alpha } ^ { - 1 } ( \beta ) = \operatorname { a r c s i n h } \left( \beta / 2 \alpha ^ { 2 } \right)$$
Integrating this expression completes the proof.
# B PROOF OF THEOREM 2
Lemma 1. For any $\beta \in \mathbb { R } ^ { d }$
$$\alpha \leq \alpha _ { 1 } \left( \epsilon , \left. \beta \right. _ { 1 } , d \right) : = \operatorname* { m i n } \left. 1 , \sqrt { \left. \beta \right. _ { 1 } } , \left( 2 \left. \beta \right. _ { 1 } \right) ^ { - \frac { 1 } { 2 \epsilon } } , \exp \left( - \frac { d } { 2 \epsilon \left. \beta \right. _ { 1 } } \right) \right.$$
guarantees that
$$\| \beta \| _ { 1 } \left( 1 - \epsilon \right) \le \frac { \alpha ^ { 2 } } { \ln ( 1 / \alpha ^ { 2 } ) } Q ( \beta / \alpha ^ { 2 } ) \le \| \beta \| _ { 1 } \left( 1 + \epsilon \right)$$
Proof. First, we show that $Q ( \beta / \alpha ^ { 2 } ) = Q _ { \alpha } ( | \beta | / \alpha ^ { 2 } )$ . Observe that $g ( x ) = x \arcsin ( x / 2 )$ is even because $x$ and arcsin $( x / 2 )$ are odd. Therefore,
$$\begin{array} { l } { { \displaystyle Q ( \beta / \alpha ^ { 2 } ) = \sum _ { i = 1 } ^ { d } 2 - \sqrt { 4 + \frac { \beta _ { i } ^ { 2 } } { \alpha ^ { 4 } } } + \frac { \beta _ { i } } { \alpha ^ { 2 } } \operatorname { a r c s i n h } \left( \frac { \beta _ { i } } { 2 \alpha ^ { 2 } } \right) } } \\ { { \displaystyle ~ = \sum _ { i = 1 } ^ { d } 2 - \sqrt { 4 + \frac { \beta _ { i } ^ { 2 } } { \alpha ^ { 4 } } } + g \left( \frac { \beta _ { i } } { \alpha ^ { 2 } } \right) } } \\ { { \displaystyle ~ = \sum _ { i = 1 } ^ { d } 2 - \sqrt { 4 + \frac { | \beta _ { i } | ^ { 2 } } { \alpha ^ { 4 } } } + g \left( \left| \frac { \beta _ { i } } { \alpha ^ { 2 } } \right| \right) } } \\ { { \displaystyle ~ = Q _ { \alpha } ( | \beta | / \alpha ^ { 2 } ) } } \end{array}$$
Therefore, we can rewrite
$${ \begin{array} { r l } { { \frac { \alpha ^ { 2 } } { \ln ( 1 / \alpha ^ { 2 } ) } } Q ( \beta / \alpha ^ { 2 } ) = { \frac { \alpha ^ { 2 } } { \ln ( 1 / \alpha ^ { 2 } ) } } Q ( | \beta | / \alpha ^ { 2 } ) } \\ & { = \displaystyle \sum _ { i = 1 } ^ { d } { \frac { 2 \alpha ^ { 2 } } { \ln ( 1 / \alpha ^ { 2 } ) } } - { \frac { { \sqrt { 4 \alpha ^ { 4 } + \beta _ { i } ^ { 2 } } } } { \ln ( 1 / \alpha ^ { 2 } ) } } + { \frac { | \beta _ { i } | } { \ln ( 1 / \alpha ^ { 2 } ) } } \operatorname { a r c s i n h } \left( { \frac { | \beta _ { i } | } { 2 \alpha ^ { 2 } } } \right) } \\ & { = \displaystyle \sum _ { i = 1 } ^ { d } { \frac { 2 \alpha ^ { 2 } } { \ln ( 1 / \alpha ^ { 2 } ) } } - { \frac { { \sqrt { 4 \alpha ^ { 4 } + \beta _ { i } ^ { 2 } } } } { \ln ( 1 / \alpha ^ { 2 } ) } } + { \frac { | \beta _ { i } | } { \ln ( 1 / \alpha ^ { 2 } ) } } \ln \left( { \frac { | \beta _ { i } | } { 2 \alpha ^ { 2 } } } + { \sqrt { 1 + { \frac { \beta _ { i } ^ { 2 } } { 4 \alpha ^ { 4 } } } } } \right) } \\ & { = \displaystyle \sum _ { i = 1 } ^ { d } { \frac { 2 \alpha ^ { 2 } } { \ln ( 1 / \alpha ^ { 2 } ) } } - { \frac { { \sqrt { 4 \alpha ^ { 4 } + \beta _ { i } ^ { 2 } } } } { \ln ( 1 / \alpha ^ { 2 } ) } } + | \beta _ { i } | \left( 1 + { \frac { \ln \left( { \frac { | \beta _ { i } | } { 2 } } + { \sqrt { \alpha ^ { 4 } + { \frac { \beta _ { i } ^ { 2 } } { 4 } } } } \right) } { \ln ( 1 / \alpha ^ { 2 } ) } } \right) } \end{array} }$$
Using the fact that
$$\left| a \right| \leq \sqrt { a ^ { 2 } + b ^ { 2 } } \leq \left| a \right| + \left| b \right|$$
we can bound for $\alpha < 1$
$$\begin{array} { r l } { \displaystyle \frac { \alpha ^ { 2 } } { \ln ( 1 / \alpha ^ { 2 } ) } Q ( \beta / \alpha ^ { 2 } ) \le \sum _ { i = 1 } ^ { d } \displaystyle \frac { 2 \alpha ^ { 2 } } { \ln ( 1 / \alpha ^ { 2 } ) } - \frac { 2 \alpha ^ { 2 } } { \ln ( 1 / \alpha ^ { 2 } ) } + | \beta _ { i } | \left( 1 + \frac { \ln \left( \frac { | \beta _ { i } | } { 2 } + \alpha ^ { 2 } + \frac { | \beta _ { i } | } { 2 } \right) } { \ln ( 1 / \alpha ^ { 2 } ) } \right) } & { } \\ { \displaystyle } & { = \sum _ { i = 1 } ^ { d } | \beta _ { i } | \left( 1 + \frac { \ln \left( | \beta _ { i } | + \alpha ^ { 2 } \right) } { \ln ( 1 / \alpha ^ { 2 } ) } \right) } \\ { \displaystyle } & { \le \| \beta \| _ { 1 } \left( 1 + \operatorname* { m a x } _ { i \in [ d ] } \frac { \ln \left( | \beta _ { i } | + \alpha ^ { 2 } \right) } { \ln ( 1 / \alpha ^ { 2 } ) } \right) } \\ { \displaystyle } & { \le \| \beta \| _ { 1 } \left( 1 + \frac { \ln \left( \| \beta \| _ { 1 } + \alpha ^ { 2 } \right) } { \ln ( 1 / \alpha ^ { 2 } ) } \right) } \end{array}$$
So, for any $\alpha \leq \operatorname* { m i n } \left. 1 , \sqrt { \| \beta \| _ { 1 } } , ( 2 \| \beta \| _ { 1 } ) ^ { - \frac { 1 } { 2 \epsilon } } \right.$ , then
$$\begin{array} { l } { \displaystyle \frac { \alpha ^ { 2 } } { \ln \left( 1 / \alpha ^ { 2 } \right) } Q ( \beta / \alpha ^ { 2 } ) \leq \| \beta \| _ { 1 } \left( 1 + \frac { \ln \left( \| \beta \| _ { 1 } + \alpha ^ { 2 } \right) } { \ln ( 1 / \alpha ^ { 2 } ) } \right) } \\ { \leq \| \beta \| _ { 1 } \left( 1 + \frac { \ln \left( 2 \| \beta \| _ { 1 } \right) } { \ln ( 1 / \alpha ^ { 2 } ) } \right) } \\ { \leq \| \beta \| _ { 1 } \left( 1 + \epsilon \right) } \end{array}$$
On the other hand, using (27) and (28) again,
$$\begin{array} { l } { \displaystyle \frac { \alpha ^ { 2 } } { \ln ( 1 / \alpha ^ { 2 } ) } Q ( \beta / \alpha ^ { 2 } ) \geq \displaystyle \sum _ { i = 1 } ^ { d } \frac { 2 \alpha ^ { 2 } } { \ln ( 1 / \alpha ^ { 2 } ) } - \frac { | \beta _ { i } | + 2 \alpha ^ { 2 } } { \ln ( 1 / \alpha ^ { 2 } ) } + | \beta _ { i } | \left( 1 + \frac { \ln \left( | \beta _ { i } | \right) } { \ln ( 1 / \alpha ^ { 2 } ) } \right) } \\ { \displaystyle = \sum _ { i = 1 } ^ { d } | \beta _ { i } | \left( 1 + \frac { \ln \left( | \beta _ { i } | \right) - 1 } { \ln ( 1 / \alpha ^ { 2 } ) } \right) } \end{array}$$
Using the inequality $\begin{array} { r } { \ln ( x ) \geq 1 - \frac { 1 } { x } } \end{array}$ , this can be further lower bounded by
$$\begin{array} { r l r } { { \frac { \alpha ^ { 2 } } { \ln ( 1 / \alpha ^ { 2 } ) } Q ( \beta / \alpha ^ { 2 } ) \geq \sum _ { i = 1 } ^ { d } | \beta _ { i } | - \frac { 1 } { \ln ( 1 / \alpha ^ { 2 } ) } } } \\ & { } & { = \| \beta \| _ { 1 } - \frac { d } { \ln ( 1 / \alpha ^ { 2 } ) } } \end{array}$$
$\begin{array} { r } { \alpha \le \exp \left( - \frac { d } { 2 \epsilon \| \beta \| _ { 1 } } \right) } \end{array}$
$$\frac { \alpha ^ { 2 } } { \ln ( 1 / \alpha ^ { 2 } ) } Q ( \beta / \alpha ^ { 2 } ) \geq \| \beta \| _ { 1 } \left( 1 - \epsilon \right)$$
We conclude that for $\begin{array} { r } { \alpha \leq \operatorname* { m i n } \left. 1 , \sqrt { \| \beta \| _ { 1 } } , ( 2 \| \beta \| _ { 1 } ) ^ { - \frac { 1 } { 2 \epsilon } } , \exp \left( - \frac { d } { 2 \epsilon \| \beta \| _ { 1 } } \right) \right. } \end{array}$
$$\| \beta \| _ { 1 } \left( 1 - \epsilon \right) \le \frac { \alpha ^ { 2 } } { \ln ( 1 / \alpha ^ { 2 } ) } Q ( \beta / \alpha ^ { 2 } ) \le \| \beta \| _ { 1 } \left( 1 + \epsilon \right)$$
Lemma 2. Fix any $\epsilon > 0$ and $d \geq \operatorname* { m a x } \left. e , 1 2 ^ { 4 \epsilon } \right.$ . Then for any $\alpha \geq d ^ { - \frac { 1 } { 4 } - \frac { 1 } { 8 \epsilon } }$ , $Q ( \beta / \alpha ^ { 2 } ) \not \propto \| \beta \| _ { 1 } i n$ the sense that there exist vectors $v , w$ such that
$${ \frac { Q \left( { \frac { 1 } { \alpha ^ { 2 } } } v \right) } { \left\| v \right\| _ { 1 } } } \geq ( 1 + \epsilon ) { \frac { Q \left( { \frac { 1 } { \alpha ^ { 2 } } } w \right) } { \left\| w \right\| _ { 1 } } }$$
Proof. First, recall that
$$\begin{array} { l } { { q \left( \displaystyle \frac { 1 } { c \alpha ^ { 2 } } \right) = 2 - \sqrt { 4 + \displaystyle \frac { 1 } { c ^ { 2 } \alpha ^ { 4 } } } + \displaystyle \frac { 1 } { c \alpha ^ { 2 } } \operatorname { a r c s i n h } \left( \displaystyle \frac { 1 } { 2 c \alpha ^ { 2 } } \right) } } \\ { { = \displaystyle \frac { 1 } { c \alpha ^ { 2 } } \left( 2 c \alpha ^ { 2 } - \sqrt { 4 c ^ { 2 } \alpha ^ { 4 } + 1 } + \ln \left( \displaystyle \frac { 1 } { 2 c \alpha ^ { 2 } } + \sqrt { 1 + \displaystyle \frac { 1 } { 4 c ^ { 2 } \alpha ^ { 4 } } } \right) \right) } } \\ { { = \displaystyle \frac { 1 } { c \alpha ^ { 2 } } \left( 2 c \alpha ^ { 2 } - \sqrt { 4 c ^ { 2 } \alpha ^ { 4 } + 1 } + \ln \left( \displaystyle \frac { 1 } { c \alpha ^ { 2 } } \right) + \ln \left( \displaystyle \frac { 1 } { 2 } + \sqrt { c ^ { 2 } \alpha ^ { 4 } + \displaystyle \frac { 1 } { 2 } } \right) \right) } } \end{array}$$
Thus,
$$- 1 + \ln \left( \frac { 1 } { c \alpha ^ { 2 } } \right) \le c \alpha ^ { 2 } q \left( \frac { 1 } { c \alpha ^ { 2 } } \right) \le 3 c \alpha ^ { 2 } - 1 + \ln \left( \frac { 1 } { c \alpha ^ { 2 } } \right)$$
Now, consider the ratio
$${ \begin{array} { r l } & { { \frac { Q \left( { \frac { 1 } { \alpha ^ { 2 } } } e _ { 1 } \right) } { Q \left( { \frac { 1 } { \alpha ^ { 2 } } } { \frac { \mathbf { 1 } _ { d } } { \| \mathbf { 1 } _ { d } \| _ { 2 } } } \right) } } = { \frac { q \left( { \frac { 1 } { \alpha ^ { 2 } } } \right) } { d q \left( { \frac { 1 } { \alpha ^ { 2 } { \sqrt { d } } } } \right) } } } \\ & { \qquad = { \frac { 1 } { \sqrt { d } } } { \frac { \alpha ^ { 2 } q \left( { \frac { 1 } { \alpha ^ { 2 } } } \right) } { \alpha ^ { 2 } { \sqrt { d } } q \left( { \frac { 1 } { \alpha ^ { 2 } { \sqrt { d } } } } \right) } } } \end{array} }$$
Using (46), we conclude
$$\begin{array} { r l r } & { } & { \sqrt { d } \frac { Q \left( \frac { 1 } { \alpha ^ { 2 } } e _ { 1 } \right) } { Q \left( \frac { 1 } { \alpha ^ { 2 } } \frac { 1 } { \| \mathbf { 1 } _ { d } \| _ { 2 } } \right) } \ge \frac { - 1 + \ln \left( \frac { 1 } { \alpha ^ { 2 } } \right) } { 3 \sqrt { d } \alpha ^ { 2 } - 1 + \ln \left( \frac { 1 } { \alpha ^ { 2 } \sqrt { d } } \right) } \qquad } \\ & { } & { = \frac { - 1 + \ln \left( \frac { 1 } { \alpha ^ { 2 } } \right) } { 3 \sqrt { d } \alpha ^ { 2 } - 1 + \ln \left( \frac { 1 } { \alpha ^ { 2 } } \right) - \frac { 1 } { 2 } \ln ( d ) } } \\ & { } & { = 1 + \frac { \ln ( d ) - 6 \sqrt { d } \alpha ^ { 2 } } { 6 \sqrt { d } \alpha ^ { 2 } - 2 + 2 \ln \left( \frac { 1 } { \alpha ^ { 2 } \sqrt { d } } \right) } } \end{array}$$
Fix any $\epsilon > 0$ and $d \geq \operatorname* { m a x } \left\{ e , 1 2 ^ { 4 \epsilon } \right\}$ , and set $\alpha = d ^ { - \frac { 1 } { 4 } - \frac { 1 } { 8 \epsilon } }$ . Then
$$\begin{array} { r l r } { \ } & { \ } & { 2 d ^ { \frac { 1 } { 4 \epsilon } } \geq 6 \quad \mathrm { a n d } \quad \frac { d ^ { \frac { 1 } { 4 \epsilon } } } { 2 } \ln d \geq 6 } \\ & { \implies 2 d ^ { \frac { 1 } { 4 \epsilon } } - 6 + \frac { d ^ { \frac { 1 } { 4 \epsilon } } } { 2 \epsilon } \ln d - \frac { 6 } { \epsilon } \geq 0 } \\ & { \implies \Big ( \frac { 1 } { \epsilon } - \frac { 1 } { 2 \epsilon } \Big ) \ln d - \frac { 6 } { \epsilon } d ^ { - \frac { 1 } { 4 \epsilon } } \geq 6 d ^ { - \frac { 1 } { 4 \epsilon } } - 2 } \\ & { \implies \frac { 1 } { \epsilon } \ln d - \frac { 6 } { \epsilon } d ^ { - \frac { 1 } { 4 \epsilon } } \geq 6 d ^ { - \frac { 1 } { 4 \epsilon } } - 2 + \frac { 1 } { 2 \epsilon } \ln d } \\ & { \implies \ln \left( d \right) - 6 \alpha ^ { 2 } \sqrt { d } \geq \epsilon \left( 6 \alpha ^ { 2 } \sqrt { d } - 2 + 2 \ln \left( \frac { 1 } { \alpha ^ { 2 } \sqrt { d } } \right) \right) } \end{array}$$
This implies that the second term of (51) is at least $\epsilon$ . We conclude that for any $\epsilon > 0$ and $d \geq$ max $\{ e , 1 2 ^ { 4 \epsilon } \}$ , $\alpha = d ^ { - \frac { 1 } { 4 } - \frac { 1 } { 8 \epsilon } }$ implies that
$$\frac { Q \left( \frac { 1 } { \alpha ^ { 2 } } e _ { 1 } \right) } { Q \left( \frac { 1 } { \alpha ^ { 2 } } \frac { \mathbf { 1 } _ { d } } { \left\| \mathbf { 1 } _ { d } \right\| _ { 2 } } \right) } \geq ( 1 + \epsilon ) \frac { \left\| e _ { 1 } \right\| _ { 1 } } { \left\| \frac { \mathbf { 1 } _ { d } } { \left\| \mathbf { 1 } _ { d } \right\| _ { 2 } } \right\| _ { 1 } }$$
Consequently, for at least one of these two vectors, $Q$ is not proportional to the $\ell _ { 1 }$ norm up to accuracy $O ( \epsilon )$ for this value of $\alpha$ .
It is straightforward to confirm that
$$\frac { d } { d \alpha } \frac { Q \left( \frac { 1 } { \alpha ^ { 2 } } e _ { 1 } \right) } { Q \left( \frac { 1 } { \alpha ^ { 2 } } \frac { 1 _ { d } } { \left\| \mathbf { 1 } _ { d } \right\| _ { 2 } } \right) } \ge 0$$
which concludes the proof.
Lemma 3. For any $\beta \in \mathbb { R } ^ { d }$ ,
$$\alpha \ge \alpha _ { 2 } ( \epsilon , \| w \| _ { 2 } ) : = \sqrt { \| \beta \| _ { 2 } } \left( 1 + \epsilon ^ { - \frac { 1 } { 4 } } \right)$$
guarantees that
$$\left( 1 - \epsilon \right) \left\| \beta \right\| _ { 2 } ^ { 2 } \leq 4 \alpha ^ { 4 } Q ( \beta / \alpha ^ { 2 } ) \leq ( 1 + \epsilon ) \left\| \beta \right\| _ { 2 } ^ { 2 }$$
Proof. The regularizer $Q$ can be written
$$Q ( \beta / \alpha ^ { 2 } ) = \sum _ { i = 1 } ^ { d } \int _ { 0 } ^ { \beta _ { i } / \alpha ^ { 2 } } \mathrm { a r c s i n h } \left( { \frac { t } { 2 } } \right) d t$$
Let $\begin{array} { r } { \phi ( z ) = \int _ { 0 } ^ { z / \alpha ^ { 2 } } \ d z } \end{array}$ arcsinh $\left( { \frac { t } { 2 } } \right) d t$ , then
$$\begin{array} { c } { { \phi ( 0 ) = 0 } } \\ { { \left. \begin{array} { l } { { \phi ^ { \prime } ( 0 ) = { \frac { 1 } { \alpha ^ { 2 } } } } } \\ { { \left( { \frac { \mathcal { Z } } { \partial \alpha ^ { 2 } } } \right) ^ { \mathrm { a r c s i n h } } \left( { \frac { \mathcal { Z } } { \mathrm { 2 } \alpha ^ { 2 } } } \right) } \end{array} _ { z = 0 } = 0 } } } \\ \right| { { \left. \begin{array} { l } { { \phi ^ { \prime \prime } ( 0 ) = { \frac { 1 } { \alpha ^ { 4 } \sqrt { 4 + { \frac { { \mathcal { Z } } } { \alpha ^ { 2 } } } } } } } } \\ { { \left( { \mathcal { S } ^ { \prime \prime } ( 0 ) = { \frac { - { \mathcal { Z } } } { \alpha ^ { 8 } } } } \right) ^ { \mathrm { b / { Z } } } } } \end{array} \right| _ { z = 0 } = { \frac { 1 } { 2 \alpha ^ { 4 } } } } } \\ { { { \left. \begin{array} { l } { { \phi ^ { \prime \prime \prime } ( 0 ) = { \frac { - { \mathcal { Z } } } { \alpha ^ { 8 } \left( 4 + { \frac { { \mathcal { Z } } } { \alpha ^ { 2 } } } \right) ^ { 3 / 2 } } } } } \\ { { \left( { \mathcal { S } ^ { \prime \prime } ( z ) = { \frac { 1 } { \alpha ^ { 1 2 } } } } \right) ^ { \mathrm { b / { Z } } } { \left( 4 + { \frac { { \mathcal { Z } } ^ { 2 } } { \alpha ^ { 4 } } } \right) } ^ { \mathrm { b / { Z } } } { \left( - { \frac { 1 } { \alpha ^ { 8 } \left( 4 + { \frac { { \mathcal { Z } } } { \alpha ^ { 4 } } } \right)} ^ { 3 / 2 } } \right)} } } \end{array} \right| _ { z = 0 } = 0 } } } \end{array}$$
Also, note that
$$\begin{array} { c } { | \phi ^ { \prime \prime \prime \prime } ( z ) | = \displaystyle \frac { \left| 2 z ^ { 2 } - 4 \alpha ^ { 4 } \right| } { \alpha ^ { 1 2 } \left( 4 + \frac { z ^ { 2 } } { \alpha ^ { 4 } } \right) ^ { 5 / 2 } } } \\ { \leq \displaystyle \frac { z ^ { 2 } + 2 \alpha ^ { 4 } } { 1 6 \alpha ^ { 1 2 } } } \end{array}$$
Therefore, by Taylor’s theorem, for some $\xi$ with $| \xi | \leq | z |$
$$\begin{array} { r l r } & { } & { \left| \phi ( z ) - { \frac { z ^ { 2 } } { 4 \alpha ^ { 4 } } } \right| = { \frac { \phi ^ { \prime \prime \prime \prime } ( \xi ) } { 4 ! } } z ^ { 4 } } \\ & { } & { \implies \left| \phi ( z ) - { \frac { z ^ { 2 } } { 4 \alpha ^ { 4 } } } \right| \le \displaystyle \operatorname* { s u p } _ { | \xi | \le | z | } { \frac { \phi ^ { \prime \prime \prime \prime } ( \xi ) } { 4 ! } } z ^ { 4 } \le { \frac { z ^ { 6 } + 2 \alpha ^ { 4 } z ^ { 4 } } { 3 8 4 \alpha ^ { 1 2 } } } = { \frac { z ^ { 2 } } { 4 \alpha ^ { 4 } } } { \frac { z ^ { 4 } + 2 \alpha ^ { 4 } z ^ { 2 } } { 9 6 \alpha ^ { 8 } } } } \end{array}$$
Therefore, for any $\beta \in \mathbb { R } ^ { d }$
$$\begin{array} { l } { \displaystyle \big \| \alpha ^ { 4 } Q _ { \alpha } ( \beta ) - \| \beta \| _ { 2 } ^ { 2 } \\Big | = 4 \alpha ^ { 4 } \left| \displaystyle \sum _ { i = 1 } ^ { d } \phi ( \beta _ { i } ) - \displaystyle \frac { \beta _ { i } ^ { 2 } } { 4 \alpha ^ { 4 } } \right| } \\ { \displaystyle \qquad \leq 4 \alpha ^ { 4 } \displaystyle \sum _ { i = 1 } ^ { d } \left| \phi ( \beta _ { i } ) - \displaystyle \frac { \beta _ { i } ^ { 2 } } { 4 \alpha ^ { 4 } } \right| } \\ { \displaystyle \qquad \leq \displaystyle \sum _ { i = 1 } ^ { d } \beta _ { i } ^ { 2 } \cdot \displaystyle \frac { \beta _ { i } ^ { 4 } + 2 \alpha ^ { 4 } \beta _ { i } ^ { 2 } } { 9 6 \alpha ^ { 8 } } } \\ { \displaystyle \qquad \leq \| \beta \| _ { 2 \operatorname* { m a x } } ^ { 2 } \beta _ { i } ^ { 4 } + 2 \alpha ^ { 4 } \beta _ { i } ^ { 2 } } \end{array}$$
Therefore, $\alpha \geq \sqrt { \| \beta \| _ { 2 } } \left( 1 + \epsilon ^ { - \frac { 1 } { 4 } } \right)$ ensures
$$\left( 1 - \epsilon \right) \left\| \beta \right\| _ { 2 } ^ { 2 } \leq 4 \alpha ^ { 4 } Q ( \beta / \alpha ^ { 2 } ) \leq ( 1 + \epsilon ) \left\| \beta \right\| _ { 2 } ^ { 2 }$$
Theorem 2. For any $0 < \epsilon < d$
$$\begin{array} { r l } & { \alpha \leq \operatorname* { m i n } \left. \left( 2 ( 1 + \epsilon ) \| \beta _ { L 1 } ^ { * } \| _ { 1 } \right) ^ { - \frac { 2 + \epsilon } { 2 \epsilon } } , \exp \left( - d / ( \epsilon \| \beta _ { L 1 } ^ { * } \| _ { 1 } ) \right) \right. \implies \| \hat { \beta } _ { \alpha } \| _ { 1 } \leq ( 1 + \epsilon ) \| \beta _ { L 1 } ^ { * } \| _ { 1 } } \\ & { \qquad \alpha \geq \sqrt { 2 ( 1 + \epsilon ) ( 1 + 2 / \epsilon ) \| \beta _ { L 2 } ^ { * } \| _ { 2 } } \implies \| \hat { \beta } _ { \alpha } \| _ { 2 } ^ { 2 } \leq ( 1 + \epsilon ) \| \beta _ { L 2 } ^ { * } \| _ { 2 } ^ { 2 } } \end{array}$$
Proof. We prove the $\ell _ { 1 }$ and $\ell _ { 2 }$ statements separately.
$\ell _ { 1 }$ approximation First, we will prove that $\left\| \hat { \beta } _ { \alpha } \right\| _ { 1 } < ( 1 + 2 \epsilon ) \| \beta _ { L 1 } ^ { * } \| _ { 1 }$ . By Lemma 1, since $\alpha \leq$ $\alpha _ { 1 } \left( \frac { \epsilon } { 2 + \epsilon } , ( 1 + 2 \epsilon ) \| \beta _ { L 1 } ^ { * } \| _ { 1 } , d \right)$ , for all $\beta$ with $\left\| \beta \right\| _ { 1 } \leq \left( 1 + 2 \epsilon \right) \left\| \beta _ { L 1 } ^ { * } \right\| _ { 1 }$ we have
$$\| \beta \| _ { 1 } \left( 1 - \frac { \epsilon } { 2 + \epsilon } \right) \le \frac { \alpha ^ { 2 } } { \ln ( 1 / \alpha ^ { 2 } ) } Q ( \beta / \alpha ^ { 2 } ) \le \| \beta \| _ { 1 } \left( 1 + \frac { \epsilon } { 2 + \epsilon } \right)$$
Let $\beta$ be such that $X \beta = y$ and $\| \beta \| _ { 1 } = \left( 1 + 2 \epsilon \right) \| \beta _ { L 1 } ^ { * } \| _ { 1 }$ . Then
$$\begin{array} { r l } { \frac { \alpha ^ { 2 } } { \ln ( 1 / \mu ^ { 2 } ) } Q ( \beta / \alpha ^ { 2 } ) \geq \left( 1 - \frac { \epsilon } { 2 + \epsilon } \right) \| \beta \| _ { 1 } } & { } \\ & { = \left( 1 - \frac { \epsilon } { 2 + \epsilon } \right) \left( 1 + 2 \epsilon \right) \| \beta _ { \Delta ^ { * } } ^ { * } \| _ { 1 } } \\ & { \geq \frac { \left( 1 - \frac { \epsilon } { 2 + \epsilon } \right) } { \left( 1 + \frac { \epsilon } { 2 + \epsilon } \right) } ( 1 + 2 \epsilon ) \frac { \alpha ^ { 2 } } { \ln ( 1 / \mu ^ { 2 } ) } Q ( \beta _ { L _ { 1 } / \alpha ^ { 2 } } ^ { * } ) } \\ & { = \frac { 1 + 2 \epsilon } { 1 + \epsilon } \frac { \alpha ^ { 2 } } { \ln ( 1 / \mu ^ { 2 } ) } Q ( \beta _ { L _ { 1 } / \alpha ^ { 2 } } ^ { * } ) } \\ & { > \frac { \alpha ^ { 2 } } { \ln ( 1 / \mu ^ { 2 } ) } Q ( \beta _ { \Delta ^ { * } } ^ { * } / \alpha ^ { 2 } ) } \\ & { \geq \frac { \alpha ^ { 2 } } { \ln ( 1 / \mu ^ { 2 } ) ^ { 2 } } Q ( \beta _ { \Delta ^ { * } } / \alpha ^ { 2 } ) } \end{array}$$
Therefore, $\beta \neq \hat { \beta } _ { \alpha }$ . Furthermore, let $\beta$ be any solution $X \beta = y$ with $\| \beta \| _ { 1 } > ( 1 + 2 \epsilon ) \| \beta _ { L 1 } ^ { * } \| _ { 1 }$ . It is easily confirmed that there exists $c \in \mathsf { \Gamma } ( 0 , 1 )$ such that the point $\beta ^ { \prime } ~ = ~ ( 1 - c ) \beta + c \beta _ { L 1 } ^ { * }$ is satisfies both $X \beta ^ { \prime } = y$ and $\| \beta ^ { \prime } \| _ { 1 } = \left( 1 + 2 \epsilon \right) \| \beta _ { L 1 } ^ { * } \| _ { 1 }$ . By the convexity of $Q$ , this implies $Q ( \beta / \alpha ^ { 2 } ) \ge Q ( \beta ^ { \prime } / \alpha ^ { 2 } ) > Q _ { \alpha } ( \hat { \beta } _ { \alpha } / \alpha ^ { 2 } )$ . Thus a $\beta$ with a large $\ell _ { 1 }$ norm cannot be a solution, even if $\frac { \alpha ^ { 2 } } { \ln ( 1 / \alpha ^ { 2 } ) } Q ( \beta / \alpha ^ { 2 } ) \not \approx \| \beta \| _ { 1 }$ .
Since $\left\| \hat { \beta } _ { \alpha } \right\| _ { 1 } < ( 1 + 2 \epsilon ) \| \beta _ { L 1 } ^ { * } \| _ { 1 }$ , we conclude
$$\begin{array} { r l } & { \left\| \hat { \beta } _ { \alpha } \right\| _ { 1 } \le \displaystyle \frac { 1 } { 1 - \frac { \epsilon } { 2 + \epsilon } } \frac { \alpha ^ { 2 } } { \ln ( 1 / \alpha ^ { 2 } ) } Q ( \hat { \beta } _ { \alpha } / \alpha ^ { 2 } ) } \\ & { \qquad \le \displaystyle \frac { 1 } { 1 - \frac { \epsilon } { 2 + \epsilon } } \frac { \alpha ^ { 2 } } { \ln ( 1 / \alpha ^ { 2 } ) } Q ( \beta _ { L 1 } ^ { * } / \alpha ^ { 2 } ) } \\ & { \qquad \le \displaystyle \frac { 1 + \frac { \epsilon } { 2 + \epsilon } } { 1 - \frac { \epsilon } { 2 + \epsilon } } \| \beta _ { L 1 } ^ { * } \| _ { 1 } } \\ & { \qquad = ( 1 + \epsilon ) \| \beta _ { L 1 } ^ { * } \| _ { 1 } } \end{array}$$
First, we will prove that $\begin{array} { r l r } { \left\| \hat { \beta } _ { \alpha } \right\| _ { 2 } } & { { } < } & { ( 1 + 2 \epsilon ) \left\| \beta _ { L 2 } ^ { * } \right\| _ { 2 } } \end{array}$ . By Lemma 3, since $\alpha \_ { } \geq$ $\begin{array} { r } { \alpha _ { 2 } \left( \frac { \epsilon } { 2 + \epsilon } , ( 1 + 2 \epsilon ) \left\| \beta _ { L 2 } ^ { * } \right\| _ { 2 } \right) } \end{array}$ , for all $\beta$ with $\left\| \beta \right\| _ { 2 } \leq \left( 1 + 2 \epsilon \right) \left\| \beta _ { L 2 } ^ { * } \right\| _ { 2 }$ we have
$$\left\| \beta \right\| _ { 2 } ^ { 2 } \left( 1 - \frac { \epsilon } { 2 + \epsilon } \right) \leq 4 \alpha ^ { 4 } Q ( \beta / \alpha ^ { 2 } ) \leq \left\| \beta \right\| _ { 2 } ^ { 2 } \left( 1 + \frac { \epsilon } { 2 + \epsilon } \right)$$
Let $\beta$ be such that $X \beta = y$ and $\left\| \beta \right\| _ { 2 } = \left( 1 + 2 \epsilon \right) \left\| \beta _ { L 2 } ^ { * } \right\| _ { 2 }$ . Then
$$\begin{array} { r l } & { 4 \alpha ^ { 4 } Q ( \beta / \alpha ^ { 2 } ) \geq \left( 1 - \frac { \epsilon } { 2 + \epsilon } \right) \| \beta \| _ { 2 } ^ { 2 } } \\ & { \quad \quad \quad = \left( 1 - \frac { \epsilon } { 2 + \epsilon } \right) \left( 1 + 2 \epsilon \right) \| \beta _ { L ^ { 2 } } ^ { * } \| _ { 2 } ^ { 2 } } \\ & { \quad \quad \quad \geq \frac { \left( 1 - \frac { \epsilon } { 2 + \epsilon } \right) } { \left( 1 + \frac { \epsilon } { 2 + \epsilon } \right) } ( 1 + 2 \epsilon ) 4 \alpha ^ { 4 } Q ( \beta _ { L 2 } ^ { * } / \alpha ^ { 2 } ) } \\ & { \quad \quad \quad = \frac { 1 + 2 \epsilon } { 1 + \epsilon } 4 \alpha ^ { 4 } Q ( \beta _ { L 2 } ^ { * } / \alpha ^ { 2 } ) } \\ & { \quad \quad \quad > 4 \alpha ^ { 4 } Q ( \beta _ { L 2 } ^ { * } / \alpha ^ { 2 } ) } \\ & { \quad \quad \quad \geq 4 \alpha ^ { 4 } Q ( \beta _ { \delta \alpha } ^ { * } / \alpha ^ { 2 } ) } \end{array}$$
Therefore, $\beta \neq \hat { \beta } _ { \alpha }$ . Furthermore, let $\beta$ be any solution $X \beta = y$ with $\left\| \beta \right\| _ { 2 } > \left( 1 + 2 \epsilon \right) \left\| \beta _ { L 2 } ^ { * } \right\| _ { 2 }$ . It is easily confirmed that there exists $c \in ( 0 , 1 )$ such that the point $\beta ^ { \prime } = ( 1 - c \bar { ) } \beta + c \beta _ { \bot 2 } ^ { \ast }$ satisfies $\bar { X } \beta ^ { \prime } =$ $y$ and $\| \beta ^ { \prime } \| _ { 2 } = \left( 1 + 2 \epsilon \right) \| \beta _ { L 2 } ^ { * } \| _ { 2 }$ . By the convexity of $Q$ , this implies $Q ( \beta / \alpha ^ { 2 } ) \stackrel { - } { \ } \ge Q ( \beta ^ { \prime } / \alpha ^ { 2 } ) \ >$ $Q ( \beta _ { L 2 } ^ { * } / \alpha ^ { 2 } )$ . Thus a $\beta$ with a large $\ell _ { 2 }$ norm cannot be a solution, even if $4 \alpha ^ { 4 } Q ( \beta / \alpha ^ { 2 } ) \not \approx \| \beta \| _ { 2 } ^ { 2 }$ .
Since $\left\| \hat { \beta } _ { \alpha } \right\| _ { 2 } < ( 1 + 2 \epsilon ) \| \beta _ { 2 } ^ { * } \| _ { 2 }$ , we conclude
$$\begin{array} { l } { \displaystyle \left\| \hat { \beta } _ { \alpha } \right\| _ { 2 } ^ { 2 } \leq \frac { 1 } { 1 - \frac { \epsilon } { 2 + \epsilon } } 4 \alpha ^ { 4 } Q ( \hat { \beta } _ { \alpha } / \alpha ^ { 2 } ) } \\ { \displaystyle \leq \frac { 1 } { 1 - \frac { \epsilon } { 2 + \epsilon } } 4 \alpha ^ { 4 } Q ( \beta _ { L 2 } ^ { * } / \alpha ^ { 2 } ) } \\ { \displaystyle \leq \frac { 1 + \frac { \epsilon } { 2 + \epsilon } } { 1 - \frac { \epsilon } { 2 + \epsilon } } \| \beta _ { L 2 } ^ { * } \| _ { 2 } ^ { 2 } } \\ { \displaystyle = ( 1 + \epsilon ) \| \beta _ { L 2 } ^ { * } \| _ { 2 } ^ { 2 } } \end{array}$$
# C PROOF OF THEOREM 3
Lemma 4. For the $D$ -homogeneous model (8),
$$\forall t \ \left\| X ^ { \top } \int _ { 0 } ^ { t } r ( \tau ) d \tau \right\| _ { \infty } \leq \frac { \alpha ^ { 2 - D } } { D ( D - 2 ) }$$
Proof. For the order- $D$ unbiased model $\beta ( t ) = \mathbf { w } _ { + } ^ { D } - \mathbf { w } _ { - } ^ { D }$ , the gradient flow dynamics are
$$\begin{array} { l } { \displaystyle \dot { \mathbf { w } } _ { + } ( t ) = - \frac { d L } { d \mathbf { w } _ { + } } = - D X ^ { \top } r ( t ) \circ \mathbf { w } _ { + } ^ { D - 1 } ( t ) , \mathbf { w } _ { + } ( 0 ) = \alpha \mathbf { 1 } } \\ { \displaystyle \implies \mathbf { w } _ { + } ( t ) = \left( \alpha ^ { 2 - D } 1 + D ( D - 2 ) X ^ { \top } \int _ { 0 } ^ { t } r ( \tau ) d \tau \right) ^ { - \frac { 1 } { D - 2 } } } \end{array}$$
Where $\circ$ denotes elementwise multiplication, $r ( t ) = X \beta ( t ) - y$ , and where all exponentiation is elementwise. Similarly,
$$\begin{array} { l } { { \displaystyle \dot { \bf w } _ { - } ( t ) = - \frac { d L } { d { \bf w } _ { - } } = D X ^ { \top } r ( t ) \circ { \bf w } _ { - } ^ { D - 1 } ( t ) , ~ { \bf w } _ { - } ( 0 ) = \alpha 1 } } \\ { { \displaystyle \implies { \bf w } _ { - } ( t ) = \left( \alpha ^ { 2 - D } 1 - D ( D - 2 ) X ^ { \top } \int _ { 0 } ^ { t } r ( \tau ) d \tau \right) ^ { - \frac { 1 } { D - 2 } } } } \end{array}$$
First, we observe that $\forall _ { t } \forall _ { i } \mathbf { w } _ { + } ( t ) _ { i } \geq 0$ and $\forall _ { t } \forall _ { i } \mathbf { w } _ { - } ( t ) _ { i } \geq 0$ . This is because at time 0 $\mathbf { \nabla } , \mathbf { w } _ { + } ( 0 ) _ { i } =$ $\mathbf { w } _ { - } ( 0 ) _ { i } = { \boldsymbol { \alpha } } > 0$ ; the gradient flow dynamics are continuous; and ${ \bf w } _ { + } ( t ) _ { i } = 0 \implies \dot { \bf w } _ { + } ( t ) _ { i } = 0$ and $\mathbf { w } _ { - } ( t ) _ { i } = 0 \implies \dot { \mathbf { w } } _ { - } ( t ) _ { i } = 0$ .
Consequently,
$$\begin{array} { c } { { 0 \leq { \bf w } _ { + } ( t ) _ { i } ^ { 2 - D } = \alpha ^ { 2 - D } + D ( D - 2 ) \left[ X ^ { \top } \displaystyle \int _ { 0 } ^ { t } r ( \tau ) d \tau \right] _ { i } } } \\ { { 0 \leq { \bf w } _ { - } ( t ) _ { i } ^ { 2 - D } = \alpha ^ { 2 - D } - D ( D - 2 ) \left[ X ^ { \top } \displaystyle \int _ { 0 } ^ { t } r ( \tau ) d \tau \right] _ { i } } } \\ { { \Longrightarrow - \alpha ^ { 2 - D } \leq D ( D - 2 ) \left[ X ^ { \top } \displaystyle \int _ { 0 } ^ { t } r ( \tau ) d \tau \right] _ { i } \leq \alpha ^ { 2 - D } } } \end{array}$$
which concludes the proof.
Theorem 3. For any $\alpha$ and $D \geq 3 ,$ , if gradient flow reaches a solution $X \beta _ { \alpha , D } ( \infty ) = y$ , then
$$\beta _ { \alpha , D } ( \infty ) = \arg \operatorname* { m i n } _ { \beta } Q _ { \alpha } ^ { D } ( \beta ) \ s . t \ \mathbf { X } \beta = \mathbf { y }$$
where $\begin{array} { r } { Q _ { \alpha } ^ { D } ( \beta ) = \sum _ { i = 1 } ^ { d } q _ { D } \big ( \beta _ { i } / \alpha ^ { D } \big ) } \end{array}$ and $q _ { D } = \int h _ { D } ^ { - 1 }$ is the antiderivative of the unique inverse of $h _ { D } ( z ) = ( 1 - z ) ^ { - \frac { D } { D - 2 } } - ( 1 + z ) ^ { - \frac { D } { D - 2 } }$ on $[ - 1 , 1 ]$ . Furthermore, $\begin{array} { r } { \operatorname* { l i m } _ { \alpha \to 0 } \beta _ { \alpha , D } ( \infty ) = \beta _ { L 1 } ^ { * } } \end{array}$ and $\begin{array} { r } { \operatorname* { l i m } _ { \alpha \to \infty } \beta _ { \alpha , D } ( \infty ) = \beta _ { L 2 } ^ { * } } \end{array}$ .
Proof. For the order- $D$ unbiased model $\beta ( t ) = \mathbf { w } _ { + } ^ { D } - \mathbf { w } _ { - } ^ { D }$ , the gradient flow dynamics are
$$\begin{array} { c } { { \displaystyle \dot { \mathbf { w } } ( t ) = \frac { d L } { d \mathbf { w } } = - D \tilde { X } ^ { \top } r ( t ) \circ \mathbf { w } ^ { D - 1 } , \mathbf { w } ( 0 ) = \alpha 1 } } \\ { { \displaystyle \implies \mathbf { w } ( t ) = \left( \alpha ^ { 2 - D } + D ( D - 2 ) \tilde { X } ^ { \top } \int _ { 0 } ^ { t } r ( \tau ) d \tau \right) ^ { - \frac { D } { D - 2 } } } } \\ { { \displaystyle \implies \beta ( t ) = \alpha ^ { D } \left( 1 + \alpha ^ { D - 2 } D ( D - 2 ) { X } ^ { \top } \int _ { 0 } ^ { t } r ( \tau ) d \tau \right) ^ { - \frac { D } { D - 2 } } } } \\ { { \displaystyle - \alpha ^ { D } \left( 1 - \alpha ^ { D - 2 } D ( D - 2 ) { X } ^ { \top } \int _ { 0 } ^ { t } r ( \tau ) d \tau \right) ^ { - \frac { D } { D - 2 } } } } \end{array}$$
where $\tilde { X } = [ X ~ - X ]$ and $r ( t ) = X \beta ( t ) - y$ . Supposing $\beta ( t )$ converges to a zero-error solution,
$$X \beta ( \infty ) = \mathbf { y } \beta ( \infty ) = \alpha ^ { D } h _ { D } ( X ^ { \top } \nu ( \infty ) )$$
where $\begin{array} { r } { \nu ( \infty ) = - \alpha ^ { D - 2 } D ( D - 2 ) \int _ { 0 } ^ { \infty } r ( \tau ) d \tau } \end{array}$ and the function $h _ { D }$ is applied elementwise and is defined
$$h _ { D } ( z ) = ( 1 - z ) ^ { - \frac { D } { D - 2 } } - ( 1 + z ) ^ { - \frac { D } { D - 2 } }$$
By Lemma 4, $\begin{array} { r } { \left\| \boldsymbol X ^ { \top } \boldsymbol \nu \right\| _ { \infty } \leq 1 } \end{array}$ , so the domain of $h _ { D }$ is the interval $[ - 1 , 1 ]$ , upon which it is monotonically increasing from $\tilde { h } _ { D } ( - 1 ) = - \infty$ to $h _ { D } ( 1 ) = \infty$ . Therefore, there exists an inverse mapping $h _ { D } ^ { - 1 } ( t )$ with domain $[ - \infty , \infty ]$ and range $[ - 1 , 1 ]$ .
This inverse mapping unfortunately does not have a simple closed form. Nevertheless, it is the root of a rational equation. Using the approach outlined in Appendix A (12), we conclude:
$$Q _ { \alpha } ^ { D } ( \beta ) = \sum _ { i } \int _ { 0 } ^ { \beta _ { i } / \alpha ^ { D } } h _ { D } ^ { - 1 } ( t ) d t$$
Rich regime Next, we show that if gradient flow reaches a solution $X \beta _ { \alpha , D } ( \infty ) ~ = ~ y$ , then $\begin{array} { r } { \operatorname* { l i m } _ { \alpha \to 0 } \bar { \beta } _ { \alpha , D } ( \infty ) = \beta _ { L 1 } ^ { * } } \end{array}$ for any $D$ . This is implied by the work of Arora et al. (2019a), but we include it here for an alternative, simpler proof for our special case, and for completeness’s sake.
The KKT conditions for $\beta = \beta _ { L 1 } ^ { * }$ are $X \beta = y$ and $\exists \nu \operatorname { s i g n } ( \beta ) = X ^ { \top } \nu$ (where $\mathrm { s i g n } ( 0 ) = [ - 1 , 1 ] )$ . The first condition is satisfied by assumption. Define $\nu$ as above. We will demonstrate that the second condition holds too in the limit as $\alpha 0$ .
First, by Lemma 4, $\left\| X ^ { \top } \nu \right\| _ { \infty } \ \leq \ 1$ for all $\alpha$ and $D$ . Thus, for any coordinates $i$ such that $\begin{array} { r } { \operatorname* { l i m } _ { \alpha \to 0 } [ \beta _ { \alpha , D } ( \infty ) ] _ { i } ~ = ~ \mathrm { ~ \ddot { 0 } ~ } } \end{array}$ , the second KKT condition holds. Consider now $i$ for which $\mathrm { l i m } _ { \alpha \to 0 } [ \beta _ { \alpha , D } ( \infty ) ] _ { i } > 0$ . As shown above,
$$\begin{array} { l } { { \displaystyle \operatorname* { l i m } _ { \alpha \to 0 } [ \beta _ { \alpha , D } ( \infty ) ] _ { i } = \operatorname* { l i m } _ { \alpha \to 0 } \alpha ^ { D } \left( 1 - [ X ^ { \top } \nu ] _ { i } \right) ^ { - \frac { D } { D - 2 } } - \alpha ^ { D } \left( 1 + [ X ^ { \top } \nu ] _ { i } \right) ^ { - \frac { D } { D - 2 } } > 0 } \ ~ } \\ { { \displaystyle \qquad \implies \ \operatorname* { l i m } _ { \alpha \to 0 } \alpha ^ { D } \left( 1 - [ X ^ { \top } \nu ] _ { i } \right) ^ { - \frac { D } { D - 2 } } > 0 } } \end{array}$$
This and $[ X ^ { \top } \nu ] _ { i } \leq 1$ implies $\begin{array} { r } { \operatorname* { l i m } _ { \alpha \to 0 } [ X ^ { \top } \nu ] _ { i } = 1 } \end{array}$ , and thus the positive coordinates satisfy the second KKT condition. An identical argument can be made for the negative coordinates.
 Figure 5: The plots demonstrate the regimes where gradient flow implicitly minimizes nuclear norm and $\ell _ { 2 }$ norm, respectively.
Kernel Regime Finally, we show that if gradient flow reaches a solution $X \beta _ { \alpha , D } ( \infty ) = y$ , then $\begin{array} { r } { \operatorname* { l i m } _ { \alpha \to \infty } \beta _ { \alpha , D } ( \infty ) = \beta _ { L 2 } ^ { * } } \end{array}$ for any $D$ .
First, since $X$ and $y$ are finite, there exists a solution $\beta ^ { * }$ whose entries are all finite, and thus all the entries of $\beta _ { \alpha , D } ( \infty )$ , which is the $Q _ { \alpha } ^ { D }$ -minimizing solution, will be finite.
The KKT conditions for $\beta = \beta _ { L 2 } ^ { * }$ are $X \beta = y$ and $\exists \mu \beta = X ^ { \top } \mu$ . The first condition is satisfied by assumption. Defining $\nu$ as above, we have
$$\begin{array} { c } { \displaystyle \underset { \alpha \infty } { \operatorname* { l i m } } [ \beta _ { \alpha , D } ( \infty ) ] _ { i } = \displaystyle \operatorname* { l i m } _ { \alpha 0 } \alpha ^ { D } ( 1 - [ X ^ { \top } \nu ] _ { i } ) ^ { - \frac { D } { D - 2 } } - \alpha ^ { D } ( 1 + [ X ^ { \top } \nu ] _ { i } ) ^ { - \frac { D } { D - 2 } } < \infty } \\ { \displaystyle \implies \underset { \alpha \infty } { \operatorname* { l i m } } [ X ^ { \top } \nu ] _ { i } = 0 } \end{array}$$
Consequently, defining $\begin{array} { r } { \mu = \frac { 2 D \alpha ^ { D } } { D - 2 } \nu } \end{array}$ , and observing that for small $z$ ,
$$( 1 - z ) ^ { - { \frac { D } { D - 2 } } } - ( 1 + z ) ^ { - { \frac { D } { D - 2 } } } = { \frac { 2 D } { D - 2 } } z + O ( z ^ { 3 } )$$
we conclude
$$\begin{array} { l } { \displaystyle \underset { \alpha \infty } { \operatorname* { l i m } } \frac { [ \beta _ { \alpha , D } ( \infty ) ] _ { i } } { [ X ^ { \top } \mu ] _ { i } } = \underset { \alpha 0 } { \operatorname* { l i m } } \frac { \alpha ^ { D } ( 1 - [ X ^ { \top } \nu ] _ { i } ) ^ { - \frac { D } { D - 2 } } - \alpha ^ { D } ( 1 + [ X ^ { \top } \nu ] _ { i } ) ^ { - \frac { D } { D - 2 } } } { [ X ^ { \top } \mu ] _ { i } } } \\ { = \displaystyle \operatorname* { l i m } _ { \alpha 0 } \frac { \alpha ^ { D } ( \frac { 2 D } { D - 2 } [ X ^ { \top } \nu ] _ { i } + O ( [ X ^ { \top } \nu ] _ { i } ^ { 3 } ) ) } { \frac { 2 D \alpha ^ { D } } { D - 2 } [ X ^ { \top } \nu ] _ { i } } } \\ { = 1 + \displaystyle \operatorname* { l i m } _ { \alpha 0 } O ( [ X ^ { \top } \nu ] _ { i } ^ { 2 } ) } \\ { = 1 } \end{array}$$
Thus, the KKT conditions are satisfied for $\begin{array} { r } { \operatorname* { l i m } _ { \alpha \to \infty } \beta _ { \alpha , D } ( \infty ) = \beta _ { L 2 } ^ { * } } \end{array}$
# D MATRIX EXPERIMENTS
In the appendix, we provide additional results similar to those in Section 6. First, in Figure 5, we plot the implicit regularization behavior of gradient flow limits with identity initialization as in Figure 3(a): in “rich" regime (small $\alpha$ ) we recover the minimum nuclear norm solution $M _ { N N } ^ { * } = \ \mathrm { a r g } \operatorname* { m i n } _ { P _ { \Omega } ( M ) = y } \left. M \right. _ { \star }$ , while “kernel" regime recovers the minimum Frobenius norm solution $\begin{array} { r } { M _ { L @ } ^ { * } = \arg \operatorname* { m i n } _ { P \Omega ( M ) = y } \left\| M \right\| _ { 2 } } \end{array}$
# E NEURAL NETWORK EXPERIMENTS
Synthetic Experiments We construct a synthetic training set with $N = 1 0$ points drawn uniformly from the unit circle in $\mathbb { R } ^ { 2 }$ and labelled by a teacher model with 1 hidden layer of 3 units. We train fully connected ReLU networks with depths 2, 3, and 5 with 30 units per layer to minimize the square loss using full gradient descent with constant stepsize 0.01 until the training loss is below $1 \bar { 0 } ^ { - 9 }$ . We use Uniform He initialization for the weights and then multiply them by $\alpha$ .
Here, we describe the details of the neural network implementations for the MNIST and CIFAR10 experiments.
 Figure 6: Training curves for the CIFAR10 experiments
MNIST Since our theoretical results hold for the squared loss and gradient flow dynamics, here we empirically assess whether different regimes can be observed when training neural networks following standard practices.
We train a fully-connected neural network with a single hidden layer composed of 5000 units on the MNIST dataset, where weights are initialized as $\alpha \mathbf { w } _ { 0 }$ , $\mathbf { w } _ { 0 } \sim \dot { \mathcal { N } } \left( 0 , \sqrt { \frac { 2 } { n _ { i n } } } \right)$ , $n _ { i n }$ denoting the number of units in the previous layer, as suggested by He et al. (2015). SGD with a batch size of 256 is used to minimize the cross-entropy loss over the 60000 training points, and error over the 10000 test samples are used as measure of generalization. For each value of $\alpha$ , we search over learning rates $( 0 . 5 , 0 . 0 1 , 0 . 0 5 , \dots )$ and use the one which resulted in best generalization.
There is a visible phase transition in Figure $_ { 4 \mathrm { e } }$ in terms of generalization $( \approx 1 . 4 \%$ error for $\alpha \leq 2$ , and $\approx 2 . 4 \%$ error for $\alpha \geq 5 0$ ), even though every network reached $1 0 0 \%$ training accuracy and less than $1 0 ^ { - 5 }$ cross-entropy loss. The black line indicates the test error $( 2 . 7 \% )$ when training only the output layer of the network, as a proxy for the performance of a linear predictor with features given by a fixed, randomly-initialized hidden layer.
CIFAR10 We trained a VGG11-like architecture, which is as follows: 64-M-128-M-256-256-M512-512-M-512-512-M-FC (numbers represent the number of channels in a convolution layers with no bias, M is a maxpooling layer, and FC is a fully connected layer). Weights were initialized using Uniform He initialization multiplied by $\alpha$ . No data augmentation was used, and training done using SGD with batch size of 128 and learning rate of 0.0001. All experiments ran for 2000 epochs, and reached $1 0 0 \%$ train accuracy except when training only the last layer, which reached $5 0 . 3 8 \%$ train accuracy with $\mathrm { L R } = 0 . 0 0 1$ (chosen after hyperparameter tuning).
In addition, to approximate the test error in the kernel regime, we experimented with freezing the bottom layers and only training the output layer for both datasets (the solid lines in Figures 4e and 4f).
Figure 6 illustrates some of the optimization difficulties that arise from using smaller $\alpha$ as discussed in Section 4.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370# LEARNING GENERAL AND REUSABLE FEATURES VIA RACECAR-TRAINING
Anonymous authors Paper under double-blind review
# ABSTRACT
We propose a novel training approach for improving the learning of generalizing features in neural networks. We augment the network with a reverse pass which aims for reconstructing the full sequence of internal states of the network. Despite being a surprisingly simple change, we demonstrate that this forward-backward training approach, i.e. racecar training, leads to significantly more general features to be extracted from a given data set. We demonstrate in our paper that a network obtained in this way is continually trained for the original task, it outperforms baseline models trained in a regular fashion. This improved performance is visible for a wide range of learning tasks from classification, to regression and stylization. In addition, networks trained with our approach exhibit improved performance for task transfers. We additionally analyze the mutual information of our networks to explain the improved generalizing capabilities.
# 1 INTRODUCTION
Humans spend surprising amounts of time assembling and disassembling objects. These deconstruction tasks serve a wide range of purposes from a hobby for motorists, to an important source of learning and exploration for children (Gopnik et al., 1999). Motivated by this behavioral trait of humans, we propose a surprisingly simple, yet powerful modification of neural network training: in addition to a regular forward pass, we add a reverse pass that is constrained to reconstruct all in-between results of the forward pass as well as the input. As we will demonstrate below, this palindromic structure yields substantial improvements for generalization of the learned features in a wide range of architectures, and in many cases even improves the baseline achieved with regular training. Our results indicate that the reversible nature of the proposed training setup, which we will subsequently refer to via the palindrome ”racecar”, encourages the formation of general and reusable features that benefit a wide range of learning tasks.
With our approach we specifically target transfer learning applications. For a regular, i.e., a nontransfer task, the goal usually is to train a network that gives the optimal performance for one specific goal, as has been demonstrated in many success stories over the years (LeCun et al., 1998; Krizhevsky et al., 2012; Goodfellow et al., 2014; He et al., 2016). In such a case, the network naturally exploits any observed correlations between input and output distribution. E.g., if the color of an object in any way correlates with its type, the training of a classifier should find and use this information. In recent years, even networks trained only for a very specific task were shown to be powerful starting points for training models with different tasks (Zamir et al., 2018; Gopalakrishnan et al., 2017; Ding et al., 2017). In many cases, the original network contained features that were applicable to different data domains and beneficial for new inference tasks. An inherent difficulty in this setting is that typically no knowledge about the specifics of the new data and task domains is available at training time of the source model. While it is common practice to target broad and difficult tasks with the hope that this will yield learned features that are applicable in new domains, we instead specifically target improving the generalizing capabilities of learned features while training the source model.
The core idea of our approach is to add a reverse path during training that is constrained to be as reversible as possible every step of the way. This makes the training task more difficult at first, but at the same time encourages the network to learn reversible and general features. Motivated by the disassembly and assembly processes of humans, and in contrast to previous work on invertible networks (Gomez et al., 2017; Jacobsen et al., 2018; Zhang et al., 2018), we constrain the network to represent a as-reversible-as-possible process for all intermediate layer activations, instead of only perfectly reproducing the input. Thus, even for cases where a classifier can, e.g., rely on color for inference of an object type, the model is encouraged to learn a representation that can recover the input in order to not only reconstruct the color of an object but also its shape. Hence the internal representation the network builds naturally has to encode as many aspects of the input data distribution as its representational capabilities permit, in order to recover the input. We demonstrate the benefits of our approach for a variety of architectures, from pure convolutional neural networks (CNNs) with and without batch normalization, to networks that include fully connected layers, as well as GAN architectures.
# 2 RELATED WORK
Transfer learning with deep neural networks has been very successful for a variety of tasks, such as image classification (Duan et al., 2012; Kulis et al., 2011; Zhu et al., 2011), multi-language text classification (Zhou et al., 2014b; Prettenhofer & Stein, 2010; Zhou et al., 2014a), and medical imaging problems (Ravishankar et al., 2016). A central question in transfer learning is whether base and target tasks are related or not. Zamir et al. (2018) proposed an approach to obtain task relationship graphs for different tasks. Another critical point is that we need the neural networks to learn general features from the data set, which are useful for both base and related tasks, rather than some specific features. But how to improve generalization of trained neural networks and reuse them for different related tasks is still a challenge.
In this paper we propose a modified training approach for improving generalization via explicitly building a reverse pass network in addition to a regular forward pass. While Zhang et al. (2018) proposed reverse connected modules, they are primarily used to transfer information from deep layers to shallow layers for a given task. Recovering all input information from hidden representations of a network is generally very difficult (Dinh et al., 2016; Mahendran & Vedaldi, 2016), due to the loss of information over the course of the layer transformations. In this context, Tishby & Zaslavsky (2015) proposed the information bottleneck principle, which states that for an optimal representation, information unrelated to the current task is reduced. This highlights the common specialization of regular training approaches. Ardizzone et al. (2018), Jacobsen et al. (2018) and Gomez et al. (2017) also build reversed networks, but mainly focus on how to make a network fully invertible via introducing special structures. As a consequence, the path from input to output is actually different from the reverse path that translates output to input. In addition, the proposed structures of previous work can not be easily attached to other network architectures. In contrast, we show that it is not necessary to strive for perfect reversibility to obtain an improved performance. Our racecar training also fully preserves an architecture for the backward path, and does not require operations that are not part of the source network. As such it can easily be applied in new settings, such as for adversarial training (Goodfellow et al., 2014).
Aiming for related goals, Bansal et al. (2018) introduced orthogonality regularizations to the loss function. However, the proposed constraints are relatively weak, and make it difficult to arrive at invertible networks. Besides, the orthogonality regularization still focuses on improving performance of a known, given task. This means the training process only extracts features which the network considers useful for improving the performance of the current task. Hence, unlike our method, orthogonality does not necessarily improve generalization or improved transfer performance (Torrey & Shavlik, 2010).
# 3 METHOD
The goal of transfer learning is to reuse a basic model trained for task A for a related new task B. The performance for B naturally depends crucially on whether the content of the basic model yields benefits for the new task. In line with previous work (Yosinski et al., 2014), we consider the generality of features learned on task A as the extent to which the features can be used for task B. This can be measured in terms of the difference between the transfer performance $p _ { A B }$ and training a model for task B from scratch yielding performance $p _ { B }$ . Our central goal is improving the transferability of the basic model w.r.t. the performance metric $p _ { A B } - p _ { B }$ , which at the same time can be seen as a measure of the generalizing capabilities of the basic model.
Regular training approaches typically construct a model with a certain network structure, and train the model weights for a given task via a suitable loss function. Our approach does not modify this initial structure, but adds a second pass that reverses the initial structure while reusing all weights and biases. E.g., for a typical fully connected layer, the forward pass, the operation $L _ { 2 } = M \times L _ { 1 } + b$ is changed to $L _ { 1 } ^ { ' } = M ^ { T } \times ( L _ { 2 } - b )$ for the reverse pass, where $L _ { 1 }$ and $L _ { 2 }$ denote input and output, respectively. Here, $M$ and $b$ denote weight matrix and bias, while $L _ { 1 } ^ { ' }$ denotes the input regenerated via the reverse pass. We will show and discuss $L ^ { ' }$ for several examples below.
Our goal with the reverse pass is to invert all operations of the forward pass to obtain identical intermediate activations between the layers with matching dimensionality. We can then constrain the intermediate results of each layer of the forward pass to match the results of the backward pass. Due to the symmetric structure of the two passes, we can use a simple $\mathcal { L } ^ { 2 }$ difference to drive the network towards aligning the results:
$$\begin{array} { r } { \mathcal { L } _ { \mathrm { r a c e c a r } } = \sum _ { m = 1 } ^ { n } \lambda _ { m } \left\| L _ { m } - L _ { m } ^ { ' } \right\| _ { 2 } } \end{array}$$
Here $L _ { m }$ denotes the input of layer $m$ in the forward pass and $L _ { m } ^ { ' }$ the output of layer $m$ for the reverse pass. $\lambda _ { m }$ denotes a scaling factor for the loss of layer $m$ , which, however, is typically constant in our tests across all layers. An illustration of this process for a CNN structure is shown in Fig. 1. While the construction of the reverse is straight-forward for all standard operations, i.e., fully connected layers, convolutions, pooling etc., batch normalization (BN) and activation function require slight adjustments to map $L _ { m }$ and $L _ { m } ^ { ' }$ to the same range of values such that they can be compared in the loss. Hence, we use the BN parameters and the activation function of layer $m - 1$ from the forward pass for layer $m$ in the reverse pass, Note that with our notation, $L _ { 1 }$ and $L _ { 1 } ^ { ' }$ refer to the input $I$ , and the regenerated input $I ^ { ' }$ , respectively. In the following, we will refer to networks trained with the added reverse structure and the loss terms of equation 1 as racecar training.
The constraints of equation 1 intentionally only minimize differences in an averaged manner with an $\mathcal { L } ^ { 2 }$ norm, as we don’t strive for a perfectly bijective mapping between input and output domains. Rather, our goal with the racecar training is to encourage the network to extract features that preserve as much information from the input data set as possible with the given representative capabilities of the chosen architecture. Hence, while a regular forward training allows a model to specialize its extracted features to maximize performance for a given task, our approach encourages the network to consider the full input data distribution, such that it ideally can be recovered from the latent-space representation of all layers.
To differentiate variants, we will use the following naming scheme: $\mathrm { S t d _ { A / B } }$ , $\mathrm { R R } _ { \mathrm { A / B } } ^ { s }$ , $\mathrm { O r t } _ { \mathrm { A / B } }$ for trained base models. Here, $S t d$ denotes a regular training run (always shown in yellow color in graphs below), while $R R ^ { s }$ denotes models trained with our racecar training (in green below). Here, the $s$ superscript denotes how many intermediate results of layers are used, e.g., $R R ^ { 3 }$ means $n = 3$ in equation 1, which constrains the input data as well as the next two layers of the original structure.
 Figure 1: Left: An overview of the regular forward pass (blue) and corresponding reverse pass (yellow). The right side illustrates how parameters are reused for a convolutional layer. conv and deconv denote convolution and deconvolutional operations, and $f _ { m }$ and $B N _ { m }$ denote activation function and batch normalization of layer $m$ , respectively. Shared kernel and bias are represented by $k _ { m }$ and $b _ { m }$ , and we assume that the deconvolution internally transposes the kernel tensor.
Correspondingly, a network trained with $R R ^ { 1 }$ means the network is trained to regenerate the input without any constraints for the activations inside of the network. This represents a special, and somewhat sub-optimal case of our method, as we will demonstrate below. $O r t$ additionally denotes models trained with orthogonal constraints (Bansal et al., 2018) (in blue). The subscripts $A / B$ denote the task $A / B$ the model was trained for. We will call direct training for either task phase I in the following.
In phase II, we reuse a model trained in phase I for new tasks (typically B), with a regular training approach. I.e., in phase II, all models are only trained with the forward structure and original loss, and do not use the racecar loss or other modifications. We will use the naming scheme StdAA/AB, $\mathsf { R R } _ { \mathrm { A A } / \mathrm { A B } } ^ { s }$ , OrtAA/AB for trained models in phase II. Here $A A / A B$ mean the model was trained for task $A$ during phase I, and is then trained for task $A / B$ in phase II.
It is worth pointing out that the additional constraints of our racecar training lead to increased requirements for memory and additional computations during phase I, e.g., it is $6 1 . 1 3 \%$ slower per epoch for the MNIST tests. And while the constraints can also lead to a slight deterioration of performance, e.g., a $0 . 1 7 \%$ lower accuracy for MNIST tests during phase I, we will demonstrate that our models outperform baselines during phase II even for the original task, and thus in practice justify introducing the racecar training.
# 4 EVALUATION IN TERMS OF MUTUAL INFORMATION
We now evaluate our approach in terms of the mutual information (MI) between input and output data distributions. As our approach hinges on the introduction of the reverse pass, we will show that our approach succeeds in terms of establishing mutual information between the input and the constrained intermediates inside a network. More formally, the mutual information $I ( X ; Y )$ of random variables $X$ and $Y$ measures how different the joint distribution of $X$ and $Y$ is w.r.t. the product of their marginal distributions, i.e., the Kullback-Leibler divergence: I(X; Y ) = $D _ { K L } [ P _ { ( X , Y ) } | | P _ { X } { \bf \bar { P } } _ { Y } ]$ .
Tishby & Zaslavsky (2015) proposed a mutual information plane to analyze the training process, which shows $I ( X ; L )$ and $I ( L ; Y )$ for each layer $L$ over the course of the training epochs. Points in the resulting graphs are colored w.r.t. the epoch, i.e., initially black, and yellow once the training is finished. Each graph shows the 5 middle and output layers. The MI planes visualize how much information about input and output distribution is retained at each layer, and how these relationships change within the network. For regular training, the information bottleneck principle (Tishby & Zaslavsky, 2015) states that early layers contain more information about the input (high $I ( X ; L )$ and $I ( Y ; L ) )$ . Hence they are often visible at the top-right. Later layers have no relationship with the output $I ( Y ; L )$ initially, which increases over the course of a successful training. Thus, they typically move
 Figure 2: MI planes for the initial models $\mathrm { R R } _ { \mathrm { A } } ^ { 1 }$ , $\mathrm { R R } _ { \mathrm { A } } ^ { 6 }$ , $\mathrm { S t d _ { A } }$ and $\mathrm { O r t } _ { \mathrm { A } }$ . End points of $\mathrm { R R } _ { \mathrm { A } } ^ { 6 }$ are located in the middle of the graphs. But for $\mathrm { S t d _ { A } }$ and $\mathrm { O r t } _ { \mathrm { A } }$ , $I ( L ; Y )$ values of every layer are very high, which means more specific features about the given output data set are learned by them.
to the top-left. The intuition behind MI planes is explained in more detail in Appendix A.1. We use the same numerical studies as in Shwartz-Ziv & Tishby (2017) as task $A$ , i.e. a regular feedforward neural network with 6 fully-connected layers. The inputs consist of 12 binary digits, and outputs are 2 binary digits. Models are trained using cross entropy as base loss function. Details of this architecture (and following ones) are given in the Sec. A.1. At first, we train a base model $\mathrm { R R } _ { \mathrm { A } } ^ { 6 }$ with a full racecar loss. For comparison, we also show the MI planes for $\mathrm { S t d _ { A } }$ (a regularly trained model), and $\mathrm { O r t _ { A } }$ (trained with orthogonal constraints (Bansal et al., 2018)). We additionally include a version $\mathrm { R R } _ { \mathrm { A } } ^ { 1 }$ , i.e. trained with only one racecar loss term $\lambda _ { 1 } | L _ { 1 } - L _ { 1 } ^ { ' } | _ { 2 } )$ , which means that only the input is constrained to be recovered. Thus, $\mathrm { R R } _ { \mathrm { A } } ^ { 1 }$ represents a simplified version of our approach which receives no constraints that the intermediate results of forward and backward pass should match. The resulting information planes are shown in Fig. 2. We can see that the end points of $\mathrm { R R } _ { \mathrm { A } } ^ { 6 }$ , i.e., the yellow clusters of points for the final state of the model, are located in the middle part of the graph. This means that all layers successfully encode information about the inputs as well as the outputs. In contrast, for $\mathrm { S t d _ { A } }$ and $\mathrm { O r t } _ { \mathrm { A } }$ , $I ( X ; L )$ values of later layers are very low (points near the top left), while $I ( L ; Y )$ is high throughout. This indicates that the outputs were successfully encoded, and that increasing amounts of information about the inputs are discarded by $\mathrm { S t d _ { A } }$ and $\mathrm { O r t } _ { \mathrm { A } }$ . Hence, both models are highly specialized for the given task. Comparing $\mathrm { R R } _ { \mathrm { A } } ^ { 1 }$ with $\mathsf { R R } _ { \mathrm { A } } ^ { 6 }$ , the yellow end points of the latter are located in a centralized region, which indicates that every layer contains similar information about $X$ and $Y$ . It also indicates that the path from input to output is similar to the path from output to input. The end points of $\mathrm { R R } _ { \mathrm { A } } ^ { 1 }$ , on the other hand, are located in a scattered region. I.e., this network has different amounts of mutual information across its layers, and potentially a very different path in each direction. $\mathrm { R R } _ { \mathrm { A } } ^ { 1 }$ is only constrained to be able to regenerate its input, while the full racecar loss for $\mathrm { R R } _ { \mathrm { A } } ^ { 6 }$ ensures that the network learns features which are beneficial for both directions. This test highlights the importance of the constraints throughout the depth of a network in our racecar loss.
As the discussion above focused on phase I, we now turn to analyzing phase II, i.e., follow-up training runs with models trained during phase I. Based on $\mathrm { R R } _ { \mathrm { A } } ^ { \mathrm { 1 } }$ $\mathrm { R R } _ { \mathrm { A } } ^ { 6 }$ , $\mathrm { O r t } _ { \mathrm { A } }$ and $\mathrm { S t d _ { A } }$ A, we continue training the models only for the original task, i.e., $\dot { \mathsf { R R } } _ { \mathrm { A A } } ^ { 1 }$ , $\mathrm { R R } _ { \mathrm { A A } } ^ { 6 ^ { - } }$ , OrtAA and $\mathrm { S t d _ { A A } }$ . The resulting MI planes are shown in Fig. 3. While all models now focus on the output (yellow points at the top, maximizing $I ( L ; Y )$ , there are differences in the distributions of the yellow points along the
 Figure 3: MI plane and accuracy comparisons for continued training $( \mathrm { R R } _ { \mathrm { A A } } ^ { 1 }$ $\mathrm { R } \check { \mathrm { R } } _ { \mathrm { A A } } ^ { 6 }$ , StdAA and $\mathrm { O r t } _ { \mathrm { A A } }$ ). The $\mathrm { \dot { R } R _ { A A } ^ { 6 } }$ model slightly outperforms the other three models, indicating the positive effect of the full racecar training.
$\mathbf { X }$ axis, i.e., how much MI with the input is retained. We can see that for model $\mathrm { R R } _ { \mathrm { A A } } ^ { 6 }$ , the final $I ( X ; L _ { 6 } )$ value at the end of the training is higher than for $\mathrm { S t d _ { A A } }$ , $\mathrm { O r t } _ { \mathrm { A A } }$ and $\mathrm { R R } _ { \mathrm { A A } } ^ { 1 }$ (final $I ( L _ { 6 } ; Y )$ values are shown above each graph). While the final accuracy is high throughout due to the relatively simple setup, $\mathrm { R R } _ { \mathrm { A A } } ^ { 6 }$ slightly outperforms the other variants for the original task. We will more clearly demonstrate this positive trait of our racecar training with more complex tasks below.
 Figure 4: MI plane and accuracy comparisons for a task transfer for models $\mathrm { R R } _ { \mathrm { A B } } ^ { 1 }$ , $\mathrm { R R } _ { \mathrm { A B } } ^ { 6 }$ , $\mathrm { O r t } _ { \mathrm { A B } }$ and $\mathrm { S t d _ { A B } }$ $\mathrm { R } \breve { \mathrm { R } } _ { \mathrm { A B } } ^ { 6 }$ successfully reuses features from task $A$ for task $\mathbf { B }$ , and outperforms $\mathrm { S t d _ { B } }$ . The regular model $\mathrm { S t d } _ { \mathrm { A B } }$ yields a very low performance.
We now analyze a new task, to check whether the model learned specific or general features, and reverse output labels as transwe invert it to [1,0]. Based on a, , $B$ . nd f the out, we train [, , ginaand set,for $\mathrm { R R } _ { \mathrm { A } } ^ { 1 }$ $\mathsf { R R } _ { \mathrm { A } } ^ { 6 }$ $\mathrm { O r t } _ { \mathrm { A } }$ $\mathrm { S t d _ { A } }$ $\mathrm { R R } _ { \mathrm { A B } } ^ { 1 }$ $\mathrm { R } \bar { \mathrm { R } } _ { \mathrm { A B } } ^ { 6 }$ $\mathrm { O r t } _ { \mathrm { A B } }$ $\mathrm { S t d } _ { \mathrm { A B } }$ the modified data set. For comparison, we also train a model trained $\mathrm { S t d } _ { \mathrm { B } }$ from scratch. MI planes and accuracy comparisons are shown in Fig. 4. While the range in performance is relatively small across most models, ${ \mathrm { S t d } } _ { \mathrm { A B } }$ stands out with a very low accuracy. This model from a regular training run has large difficulties to adapt to the new task. Model $\mathrm { O r t } _ { \mathrm { A B } }$ also performs worse than $\mathrm { S t d _ { B } }$ . $\mathrm { R R } _ { \mathrm { A B } } ^ { 6 }$ shows the best performance in this setting, confirming the previous MI plane visualizations, and demonstrating that our loss formulation helped to learn more general features from the input data, improving the performance for related tasks such as the inverted outputs.
# 5 EXPERIMENTAL RESULTS
We now turn to more complex network structures (CNNs, GANs, Auto-Encoders), with different data sets (MNIST, Cifar, smoke, ImageNet) and different tasks (such as classification and synthesis) to show that models trained with our approach succeed in learning very general features that transfer to new tasks.
# 5.1 DIGIT CLASSIFICATION
The MNIST data set is a commonly used data set for hand written digit classification (LeCun et al., 1998). At first, we train three models for regular MNIST data set classification as task $A$ , one with racecar loss $\mathsf { R R } _ { \mathrm { A } } ^ { 3 }$ , a regular model $\mathrm { S t d _ { A } }$ , and one with orthogonal $\mathrm { O r t } _ { \mathrm { A } }$ constraints (Bansal et al., 2018), as the latter also aims for improving CNN performance. Usually, convolutional layers take up most of the model parameters, so we correspondingly compute the racecar loss for the convolutional layers, omitting the fully connected layers that would be required for class label inference. To highlight the properties of our algorithm, we show comparisons between $I$ and the regenerated $I ^ { \prime }$ in Fig. 5. We can see that for racecar training, most of the features from the input are recovered. Trying to invert the network in the same way for a regular training run or training with orthogonal constraints largely fails, as the extracted features are extracted according to the digit classification and discard information unrelated to this task.
 Figure 5: Comparisons between regenerated inputs. F.l.t.r.: $\mathrm { O r t } _ { \mathrm { A } }$ , $\mathrm { S t { \dot { d } } _ { A } }$ , $\mathrm { R R } _ { \mathrm { A } } ^ { 3 }$ , and the reference. Only $\mathrm { R R } _ { \mathrm { A } } ^ { 3 }$ recovers most of the input information successfully.
Based models $\mathrm { O r t } _ { \mathrm { A } }$ $\mathrm { S t d _ { A } }$ , a $\mathrm { R R _ { A } ^ { 3 } }$ e continue training to obtain. Results are shown in Fig. 6. $\mathrm { O r t } _ { \mathrm { A A } }$ $\mathrm { S t d _ { A A } }$ $\mathrm { R R } _ { \mathrm { A A } } ^ { 3 }$ clusions. We can see that $\mathrm { R R } _ { \mathrm { A A } } ^ { 3 }$ outperforms $\mathrm { O r t } _ { \mathrm { A A } }$ and $\mathrm { S t d _ { A A } }$ at the end of training, which indicates that racecar training yields general features that can also improve performance for original task. Council (2000) illustrated that balanced learning of both general and specific features is more effective for human learning, and our results here are consistent with this intuition.
As general features are more robust than specific features (Novak et al., 2018), we investigate a perturbed data set for the transfer task B. We apply $\mathrm { O r t _ { A } }$ , $\mathrm { S t d _ { A } }$ and $\mathsf { R R } _ { \mathrm { A } } ^ { 3 }$ to $\mathbf { n }$ -MNIST, a data set for classification with motion blur (Basu et al., 2017). Performance results are likewise given in Fig. 6. Based on the same CNN structure and parameters, $\mathsf { R R } _ { \mathrm { A } } ^ { 3 }$ achieves the best performance. This indicates that $\mathsf { R R } _ { \mathrm { A } } ^ { 3 }$ learned more general features via racecar training than $\mathrm { O r t _ { A } }$ and $\mathrm { S t d _ { A } }$ .
 Figure 6: Accuracy comparisons for base task $A$ and transfer learning task $B$ . $\mathrm { R R } _ { \mathrm { A A } } ^ { 3 }$ and $\mathrm { R R } _ { \mathrm { A B } } ^ { 3 }$ achieve the best performance for the base task and transfer learning task, respectively.
# 5.2 NATURAL IMAGE CLASSIFICATION
Natural images arise in many important application scenarios. Hence, we evaluate our approach with the Cifar data set (Krizhevsky et al., 2009). At first, we train two models as Cifar10 data set classification task $A$ , $\mathsf { R R } _ { \mathrm { A } } ^ { 1 3 }$ and $\mathrm { S t d _ { A } }$ . We again continue training to obtain $\mathrm { R R } _ { \mathrm { A A } } ^ { 1 3 }$ and $\mathrm { S t d _ { A A } }$ , results for which are shown in Fig. 7. The racecar training also improves performance for this natureus $\mathsf { R R } _ { \mathrm { A } } ^ { 1 3 }$ ge cland $\mathrm { S t d _ { A } }$ cation task. For transfer learning task for Cifar-100 data set classification $B$ $( \mathrm { R R } _ { \mathrm { A B } } ^ { 1 3 }$ $\mathrm { S t d } _ { \mathrm { A B } }$ same CNN structure and parameters, ${ \mathrm { S t d } } _ { \mathrm { A B } }$ has difficulties adjusting to the new task, while our model from the initial racecar training slightly outperforms the model trained for scratch for B.
 Figure 7: Accuracy comparisons of task $A$ and task $B$ . $\mathbf { R } \dot { \mathbf { R } } _ { \mathbf { A A } } ^ { 1 3 }$ and $\mathrm { R R } _ { \mathrm { A B } } ^ { 1 3 }$ got bestperformance for tast $A$ and $B$ .
# 5.3 GENERATIVE ADVERSARIAL MODELS
In the previous sections, we employed commonly used data sets and transfers to related tasks. Next, we test our approach for a transfer situation with a more challenging transfer from a synthetic single channel data set of synthetic smoke simulations, to RBG videos of real smoke clouds. We use GAN and auto-encoder structures for the following models.
At first, we use a GAN structure (one generator and one discriminator network) for super resolution of the simulation data as task $A$ . $\mathrm { S t d _ { A } }$ is trained via regular training, and $\mathrm { R R } _ { \mathrm { A } } ^ { 6 }$ uses racecar training for the generator network of the GAN. Regenerated low resolution results and high resolution outputs comparisons are shown in Fig. 8. Both $\mathrm { \Delta R R _ { A } ^ { 6 } }$ and $\mathrm { S t d _ { A } }$ can up scale low resolution data 4 times larger to high resolution data very well. But $\mathrm { R } \mathrm { \bar { R } } _ { \mathrm { A } } ^ { 6 }$ can also recover low resolution versions from high resolution data. $\mathrm { S t d _ { A } }$ fails in regenerating the low resolution images. This shows that $\mathrm { R R } _ { \mathrm { A } } ^ { 6 }$ not only focused on
 Figure 8: Regenerated low resolution results and high resolution outputs comparison between $\mathrm { S t d _ { A } }$ , $\mathsf { R R } _ { \mathrm { A } } ^ { 6 }$ and reference. Only $\mathsf { R R } _ { \mathrm { A } } ^ { 6 }$ successfully recovers the input.
generating good features for the super-resolution task, but also preserves information about the input.
We reuse the generator models $\mathrm { R R } _ { \mathrm { A } } ^ { 6 }$ and $\mathrm { S t d _ { A } }$ to train two sets of auto-encoder networks: once for the synthetic smoke data as transfer task $B _ { 1 }$ , and as a second task $B _ { 2 }$ for RBG videos ofelstha $\mathsf { R R } _ { A B _ { 1 , 2 } } ^ { 6 }$ d smand train $\mathrm { S t d } _ { A B _ { 1 , 2 } }$ ds (example frames are given in the appendix). This yields mod-, respectively. The resulting accuracies, summarized in Fig. 9, showrms best for both auto-encoding tasks. This is especially encouraging for task $B _ { 2 }$ , as it represents a transfer from fully synthetic training to real-world images.
Synthetic data and real-world images have significant differences in terms of their features. In the worst case, most of the features learned by the regular learning process $\mathrm { S t d _ { A } }$ can not be transferred to the new task. Besides, an inappropriate starting point of the transfer learning task can guide the whole training process towards a wrong direction. Instead, a model with more general features such as $\mathrm { R R } _ { \mathrm { A } } ^ { 6 }$ can more easily be reused in new tasks, and can provide a better starting point for learning. This indicates the potential of racecar training to obtain generalizable features from synthetic data sets that can be used for tasks working with real-world data.
 Figure 9: Accuracy comparisons of transfer learning tasks. $\dot { \mathsf { R R } } _ { \mathrm { A A } } ^ { 6 }$ and $\mathrm { R R } _ { \mathrm { A B } } ^ { 6 }$ got best performance for task $B _ { 1 }$ and $B _ { 2 }$ .
 Figure 10: Left: stylization test from a natural image to the starry night painting style. Right: stylization test from horse to zebra.
In order to provide a qualitative evaluation in a complex, visual scenario, we turn to the popular task of image stylization. We use V GG19 networks (Simonyan & Zisserman, 2014) in the following, and we train two V GG19 networks $\mathrm { R R } _ { \mathrm { A } } ^ { 1 6 }$ and $\mathrm { S t d _ { A } }$ with ImageNet data set (Deng et al., 2009). Based on these, we train $\mathrm { R R } _ { \mathrm { A A } } ^ { 1 6 }$ and $\mathrm { S t d _ { A A } }$ top5 accuracy of which are $7 7 . 5 9 \%$ and $7 5 . 2 8 \%$ , respectively. Consistent with previous test, $\mathrm { R R } _ { \mathrm { A A } } ^ { 1 6 }$ outperforms the $\mathrm { S t d _ { A A } }$ baseline even in this complex case for a network with ca. 143 million weights. Gatys et al. (2016) achieve excellent stylization results, but the results strongly depend on the pre-trained VGG network, i.e., it stylizes and changes structures that are represented by the features in the VGG network. Hence, we employ stylization to visualize which features, general or specialized, the two VGG versions focus on.
 Figure 11: First primary stylization test, $\mathbf { R } \mathbf { \check { R } } _ { \mathrm { A } } ^ { 1 6 }$ did not change specific features in the results.
Gatys et al. (2016) generate stylized results via optimizing two losses, $L _ { s t y l e }$ and $L _ { c o n t e n t }$ , which measure style difference and content difference, respectively (details are given in the appendix. To compare the feature extracting capabilities between the $\mathrm { R R } _ { \mathrm { A } } ^ { 1 6 }$ and $\mathrm { S t d _ { A } }$ As a first test, we use two simple shapes as source and style images, as shown in Fig. 11. They have the same background and object color. The only difference is the large-scale shape of the object. Thus, as we aim for applying an style that is identical to the source, we can test whether the features can cleanly separate and preserve the large scale shape features from the ones for the localized style. Comparing the results of $\mathrm { R R } _ { \mathrm { A } } ^ { 1 6 }$ and $\mathrm { S t d _ { A } }$ , the output of $\mathrm { R R } _ { \mathrm { A } } ^ { 1 6 }$ is almost identical to the input, while stylization with $\mathrm { S t d _ { A } }$ changes the shape of the object introducing undesirable streaks around the outline. This result indicates that $\mathrm { R R } _ { \mathrm { A } } ^ { 1 6 }$ is able to cleanly encode the shape of the object and preserve it during the stylization.
runs, we only optimize $L _ { s t y l e }$
 Figure 12: Stylization comparison from low resolution to high resolution. $\mathrm { R R } _ { \mathrm { A } } ^ { 1 6 }$ ’s results are closer to the high resolution.
We show more stylization tests in Fig. 10, which optimize both $L _ { c o n t e n t }$ and $L _ { s t y l e }$ . For the left example of Fig. 10 with a Van Gogh style image, both models can generate good stylized results. However, from the results obtained with $\mathrm { S t d _ { A } }$ (orange square area), we can see a star within the building, which indicates that this model mixed style and context information in its features. Across our tests we found that models like this one, trained for more specific features, more often performed simple patch-based matches rather than generating meaningful transfers of styles. However, if the model focuses on more general and abstract features, it can perform a better semantic matching and generate improved stylization results. For the right part of Fig. 10, we show a test transferring a horse image to a zebra style. $\mathrm { R R } _ { \mathrm { A } } ^ { 1 6 }$ focuses more on general features, such as grass, zebra, and their positional relationships. As a result the model successfully distinguishes foreground from background, and changes the style for both foreground and background objects with only smaller mistakes. $\mathrm { S t d _ { A } }$ ’s performance is significantly worse, leading to large grass-like areas within the body of the horse.
We confirm the capabilities of the VGG model from racecar training with a low- to high-resolution transfer where the goal is purely to add detail. I.e., we can compute in place errors w.r.t. high-resolution reference. The result is shown in Fig. 12. The VGG model obtained with a regular training run yields significantly higher errors, as visible on the right side of the figure.
 Figure 13: $\mathrm { R R } _ { \mathrm { A } } ^ { 1 6 }$ generates a zebra pattern in the horse’s shadow, but yields generally improved results compared to the regular transfer in $\mathrm { S t d _ { A } }$ .
$\mathrm { R R } _ { \mathrm { A } } ^ { 1 6 }$ can extract more general information from the input, which is helpful with generating semantically meaningful results. However, we found that this property can also confuse the model in some specific situations. For instance, as shown in Fig. 13, at first, $\mathrm { R R } _ { \mathrm { A } } ^ { 1 6 }$ can distinguish foreground and background and generate better stylization results than $\mathrm { S t d _ { A } }$ . However, $\mathrm { \tilde { R } R _ { A } ^ { 1 6 } }$ also stylizes the shadow of the horse. This also indicates that $\mathrm { \tilde { R } R _ { A } ^ { 1 6 } }$ focuses more on general features. As a consequence, all horse shape objects are extracted and then stylized with zebra textures, such as the shadow in Fig. 13. However, we generally think that this can provide potentially helpful information in other situations, e.g., for classification tasks. Overall, the quality of the racecar transfer also still surpasses the regular version.
# 6 CONCLUSION
We have proposed a novel training approach for improving neural network generalization by adding a constrained reverse pass. We have shown for a range of tasks that this yields networks with more general features that more easily transfer to new tasks, and even outperform baselines for the original task. Our training approach is very general, and imposes no requirements regarding network structure or training method. As future work, we believe it will be very interesting to evaluate our approach for other architectures from the vast zoo of existing work, e.g., we are particularly interested in analyzing recurrent structures such as LSTMs and GRUs (Hochreiter & Schmidhuber, 1997; Cho et al., 2014).
# REFERENCES
Lynton Ardizzone, Jakob Kruse, Sebastian Wirkert, Daniel Rahner, Eric W Pellegrini, Ralf S Klessen, Lena Maier-Hein, Carsten Rother, and Ullrich Kothe. Analyzing inverse problems with ¨ invertible neural networks. arXiv preprint arXiv:1808.04730, 2018. Nitin Bansal, Xiaohan Chen, and Zhangyang Wang. Can we gain more from orthogonality regularizations in training deep cnns? In Proceedings of the 32nd International Conference on Neural Information Processing Systems, pp. 4266–4276. Curran Associates Inc., 2018. Saikat Basu, Manohar Karki, Sangram Ganguly, Robert DiBiano, Supratik Mukhopadhyay, Shreekant Gayaka, Rajgopal Kannan, and Ramakrishna Nemani. Learning sparse feature representations using probabilistic quadtrees and deep belief nets. Neural Processing Letters, 45(3):855– 867, 2017. Kyunghyun Cho, Bart Van Merrienboer, Caglar Gulcehre, Dzmitry Bahdanau, Fethi Bougares, Hol- ¨ ger Schwenk, and Yoshua Bengio. Learning phrase representations using rnn encoder-decoder for statistical machine translation. arXiv preprint arXiv:1406.1078, 2014. National Research Council. How People Learn: Brain, Mind, Experience, and School: Expanded Edition. The National Academies Press, 2000. 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.
Hui Ding, Shaohua Kevin Zhou, and Rama Chellappa. Facenet2expnet: Regularizing a deep face recognition net for expression recognition. In 2017 12th IEEE International Conference on Automatic Face & Gesture Recognition (FG 2017), pp. 118–126. IEEE, 2017.
Laurent Dinh, Jascha Sohl-Dickstein, and Samy Bengio. Density estimation using real nvp. arXiv preprint arXiv:1605.08803, 2016.
Lixin Duan, Dong Xu, and Ivor Tsang. Learning with augmented features for heterogeneous domain adaptation. arXiv preprint arXiv:1206.4660, 2012.
M-L Eckert, Wolfgang Heidrich, and Nils Thuerey. Coupled fluid density and motion from single views. In Computer Graphics Forum, volume 37, pp. 47–58. Wiley Online Library, 2018.
Leon A Gatys, Alexander S Ecker, and Matthias Bethge. Image style transfer using convolutional neural networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2414–2423, 2016.
Aidan N Gomez, Mengye Ren, Raquel Urtasun, and Roger B Grosse. The reversible residual network: Backpropagation without storing activations. In Advances in neural information processing systems, pp. 2214–2224, 2017.
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.
Kasthurirangan Gopalakrishnan, Siddhartha K Khaitan, Alok Choudhary, and Ankit Agrawal. Deep convolutional neural networks with transfer learning for computer vision-based data-driven pavement distress detection. Construction and Building Materials, 157:322–330, 2017.
Alison Gopnik, Andrew N Meltzoff, and Patricia K Kuhl. The scientist in the crib: Minds, brains, and how children learn. William Morrow & Co, 1999.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 770–778, 2016.
Sepp Hochreiter and Jurgen Schmidhuber. Long short-term memory. ¨ Neural computation, 9(8): 1735–1780, 1997.
Jorn-Henrik Jacobsen, Arnold Smeulders, and Edouard Oyallon. i-revnet: Deep invertible networks.¨ arXiv preprint arXiv:1802.07088, 2018.
Michael Kazhdan, Thomas Funkhouser, and Szymon Rusinkiewicz. Rotation invariant spherical harmonic representation of $^ \textrm { \scriptsize 3 d }$ shape descriptors. In Symposium on geometry processing, volume 6, pp. 156–164, 2003.
Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. Technical report, Citeseer, 2009.
Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. In Advances in neural information processing systems, pp. 1097–1105, 2012.
Brian Kulis, Kate Saenko, and Trevor Darrell. What you saw is not what you get: Domain adaptation using asymmetric kernel transforms. In CVPR 2011, pp. 1785–1792. IEEE, 2011.
Yann LeCun, Leon Bottou, Yoshua Bengio, Patrick Haffner, et al. Gradient-based learning applied ´ to document recognition. Proceedings of the IEEE, 86(11):2278–2324, 1998.
Aravindh Mahendran and Andrea Vedaldi. Visualizing deep convolutional neural networks using natural pre-images. International Journal of Computer Vision, 120(3):233–255, 2016.
Roman Novak, Yasaman Bahri, Daniel A Abolafia, Jeffrey Pennington, and Jascha SohlDickstein. Sensitivity and generalization in neural networks: an empirical study. arXiv preprint arXiv:1802.08760, 2018.
Peter Prettenhofer and Benno Stein. Cross-language text classification using structural correspondence learning. In Proceedings of the 48th annual meeting of the association for computational linguistics, pp. 1118–1127, 2010.
Hariharan Ravishankar, Prasad Sudhakar, Rahul Venkataramani, Sheshadri Thiruvenkadam, Pavan Annangi, Narayanan Babu, and Vivek Vaidya. Understanding the mechanisms of deep transfer learning for medical images. In Deep Learning and Data Labeling for Medical Applications, pp. 188–196. Springer, 2016.
Ravid Shwartz-Ziv and Naftali Tishby. Opening the black box of deep neural networks via information. arXiv preprint arXiv:1703.00810, 2017.
Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014.
Jos Stam. Stable fluids. In Siggraph, volume 99, pp. 121–128, 1999.
Naftali Tishby and Noga Zaslavsky. Deep learning and the information bottleneck principle. In 2015 IEEE Information Theory Workshop (ITW), pp. 1–5. IEEE, 2015.
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.
Jason Yosinski, Jeff Clune, Yoshua Bengio, and Hod Lipson. How transferable are features in deep neural networks? In Advances in neural information processing systems, pp. 3320–3328, 2014.
Amir R Zamir, Alexander Sax, William Shen, Leonidas J Guibas, Jitendra Malik, and Silvio Savarese. Taskonomy: Disentangling task transfer learning. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 3712–3722, 2018.
Lijing Zhang, Yao Lu, Ge Song, and Hanfeng Zheng. Rc-cnn: Reverse connected convolutional neural network for accurate player detection. In Pacific Rim International Conference on Artificial Intelligence, pp. 438–446. Springer, 2018.
Joey Tianyi Zhou, Sinno Jialin Pan, Ivor W Tsang, and Yan Yan. Hybrid heterogeneous transfer learning through deep learning. In Twenty-eighth AAAI conference on artificial intelligence, 2014a.
Joey Tianyi Zhou, Ivor W Tsang, Sinno Jialin Pan, and Mingkui Tan. Heterogeneous domain adaptation for multiple classes. In Artificial Intelligence and Statistics, pp. 1095–1103, 2014b.
Yin Zhu, Yuqiang Chen, Zhongqi Lu, Sinno Jialin Pan, Gui-Rong Xue, Yong Yu, and Qiang Yang. Heterogeneous transfer learning for image classification. In Twenty-Fifth AAAI Conference on Artificial Intelligence, 2011.
# A APPENDIX
Here we will present more details, such as data set information, network structures and training parameters, for all of our mentioned tests above: Mutual Information Sec. A.1, MNIST classification Sec. A.2, Cifar Sec. A.3, smoke Sec. A.4 and VGG Sec. A.5. We will use $C ( k , l , s )$ , $D ( k , l , s )$ to represent convolutional and deconvolutional operations, respectively, and fully connected layers are noted with $F ( l )$ , where $k$ , l, $s$ denote kernel size, output channels and stride size, respectively. Bias of CNN layer is denoted with $b$ . $I / O ( z )$ denote input/output and their dimensionality is given by $z$ . $I _ { r }$ denotes the input of reverse pass network. tanh, relu, lrelu denote corresponding activation functions, where we typically use a leaky tangent of 0.2 for the negative half space. $U P$ , $M P$ and $B N$ denote $2 \times$ nearest-neighbor up sampling, max pooling with $2 \times 2$ filters and stride 2, and batch normalization, respectively. All performance numbers were measured on a Nvidia GeForce GTX 1080 Ti GPUs and Intel Core i7-6850K CPUs.
# A.1 MUTUAL INFORMATION TEST
Below we will introduce more details about tests in Sec. 4.For the numerical task (Shwartz-Ziv & Tishby, 2017), input variable $X$ are 12 binary digits that represent 12 uniformly distributed points on a 2D sphere, and this task is about binary decision rules which are invariant under $O ( 3 )$ rotations of the sphere. $X$ has 4096 different patterns, and they are divided into 64 disjoint orbits of the rotation group, which form a minimal sufficient partition/statistics for spherically symmetric rules (Kazhdan et al., 2003). To generate input-output distribution $P ( X , Y )$ , Shwartz-Ziv & Tishby (2017) applied a stochastic rule $\bar { p ( y = 1 | x ) } = \bar { \Psi ( f ( x ) - \theta ) } , ( x \in X , y \in Y )$ , where $\Psi$ is a standard sigmoidal function $\Psi ( u ) = 1 / ( 1 + e x p ( - \gamma u ) )$ . Shwartz-Ziv & Tishby (2017) use a spherically symmetric real valued function of the pattern $f ( x )$ (evaluated through its spherical harmonics power spectrum (Kazhdan et al., 2003) and compared it to a threshold $\theta$ , which was selected to make $p ( y = 1 ) =$ $\textstyle \sum _ { x } p ( y = 1 | x ) p ( x ) \approx 0 . 5$ , with uniform $p ( x )$ . $\gamma$ is high enough to keep the mutual information $I ( \bar { X } ; Y ) \approx 0 . 9 9$ bits. $80 \%$ of the data (3277 data pairs) are used for training and rests (819 data pairs) are used for testing. The forward and reverse pass structures of the fully connected neural networks are in Table 7. Hyper parameters used for training are listed in Table 8.
All and used . For ecar loss. All layers in the, we used the Spectral Res $\mathrm { R R } _ { \mathrm { A } } ^ { 6 }$ andd Iso $\mathrm { S t d _ { A } }$ are reused for trainingy Property (SRIP) regu $\mathrm { R R } _ { \mathrm { A A / A B } } ^ { 6 }$ $\mathrm { S t d } _ { \mathrm { A A / A B } }$ $\mathrm { O r t } _ { \mathrm { A } }$ (Bansal et al., 2018),
$$\mathcal { L } _ { \mathrm { S R I P } } = \beta \sigma ( W ^ { T } W - I ) ,$$
where $W$ is the kernel; $I$ denotes an identity matrix; $\beta$ represents the regularization coefficient; $\sigma ( W ) = s u p _ { z \in \mathbb { R } ^ { n } , z \neq 0 } \frac { | | W _ { z } | | } { | | z | | }$ 0 kWzkkzk denotes the spectral norm of W . Details about all models’ accuracy are shown in Table 1 and Table 2.
Mutual information (MI) plane is a powerful tool for neural networks analysis but admittedly not very intuitive. Here we will use MI plane of $\mathrm { S t d _ { A } }$ in Fig. 2 as an example to illustrate MI plane in details. From Table 7, we can see that neural network in this numerical task has 5 middle layers $( L _ { 1 \sim 5 } )$ and one output layer $( L _ { 6 } )$ . The $X$ axis of the MI plane represents the quantity $I ( X ; L )$ , i..e the mutual information between input variable $X$ and output of each layer $L$ . The $Y$ axis of the MI plane represents $I ( L ; Y )$ , the mutual information between output of each layer $L$ and output variable $Y$ . Besides, every point in the graphs is colored w.r.t.
 Figure 14: MI plane of $\mathrm { S t d _ { A } }$ as an example.
the training epochs, i.e., initially black, and yellow once the training is finished. Hence, we can see six lines changing from black to yellow in figure 14 of the updated version. According to the information bottleneck principle [5], the outputs of the early layers contain more information from the input, which means a high value for $I ( X ; L )$ and $I ( L ; Y )$ . We can see that early layers $L _ { 1 3 }$ are located in the top right part of the graph. For later layers, such as $L _ { 6 }$ , parameters of $L _ { 6 }$ are randomly initialized before training, so there are almost no direct relationships between the output of $L _ { 6 }$ and $X$ or $Y$ , which means low values of $I ( X ; L )$ and $I ( L ; Y )$ . Once the model is well trained, $L _ { 6 }$ of $\mathrm { S t d _ { A } }$ is able to generate data which has the same distribution with $Y$ , so $I ( L ; Y )$ has increased and moved to the top left corner of the graph. The line of $L _ { 6 }$ starts from the bottom left part of the graph, and moves to the top left part during training. For $\mathrm { R R } _ { \mathrm { A } } ^ { 6 }$ in figure 2, the L2 constraint is explicitly applied to decrease difference between $L$ and $L ^ { ' }$ , and the output is pushed to recover lost information of the input, so $I ( X ; L )$ of later layers is increased, and $I ( X ; L )$ of early layers is decreased to make the task easier.
# A.2 MNIST CLASSIFICATION
This section gives details for Sec. 5.1. The regular MNIST data set(LeCun et al., 1998) contains $5 5 k$ images for training and $1 0 k$ images for testing. For the n-MNIST motion blur data set(Basu et al., 2017), there are $6 0 k$ images for training and $1 0 k$ images for testing. Image size of them are all $2 8 \times 2 8$ . Example data from MNIST and $\mathbf { n }$ -MNIST with motion blur are shown in Fig. 15. Details about the forward and reverse pass network structures are shown in Table 9. Hyper parameters are listed in Table 10.
 Figure 15: Left: data from MNIST; Right: data from n-MNIST with motion blur.
All 3 convolutional layers are used for racecar loss and all layers in $\mathsf { R R } _ { \mathrm { A } } ^ { 3 }$ , $\mathrm { S t d _ { A } }$ and $\mathrm { O r t } _ { \mathrm { A } }$ are reused for training $\mathrm { R R } _ { \mathrm { A A / A B } } ^ { 3 }$ , StdAA/AB and OrtAA/AB. Example training processes of the MNIST tests are shown in Fig. 16. We can see that racecar loss increases the task difficulty, so $\mathsf { R R } _ { \mathrm { A } } ^ { 3 }$ yields a lower performance and longer training time than $\mathrm { S t d _ { A } }$ in the first phase. In the second phase $\mathsf { R R } _ { \mathrm { A } } ^ { 3 }$ outperforms $\mathrm { S t d _ { A } }$ and $\mathrm { O r t } _ { \mathrm { A } }$ in both task $A$ an $B$ , which indicates that racecar training is helpful with general feature extraction. For $\mathrm { O r t } _ { \mathrm { A } }$ , we also use equation 2 as orthogonal regularization. All models’ accuracy results are listed in Table 3 and Table 4.
 Figure 16: Left: training processes of $\mathrm { R R } _ { \mathrm { A } } ^ { 3 }$ (blue, accuracy: 0.9810, cost: 5.675 seconds/epoch), $\mathrm { S t d _ { A } }$ (orange, accuracy: 0.9827, cost: 3.522 seconds/epoch) and OrtA (red, accuracy: 0.9792, cost: 4.969 seconds/epoch). Middle: training processes of $\mathrm { R R } _ { \mathrm { A A } } ^ { 3 }$ (blue), $\mathrm { S t d _ { A A } }$ (orange) and $\mathrm { O r t } _ { \mathrm { A A } }$ (red). Right: training processes os $\mathrm { \hat { R } R _ { A B } ^ { 3 } }$ (green), $\mathrm { S t d } _ { \mathrm { A B } }$ (pink), $\mathrm { O r t } _ { \mathrm { A B } }$ (blue), and $\mathrm { S t d _ { B } }$ (grey).
# A.3 CIFAR TEST
 Figure 17: Left: training processes of $\mathrm { R R } _ { \mathrm { A } } ^ { 1 3 }$ (blue, accuracy: 0.5784, cost: 64 seconds/epoch) and $\mathrm { S t d _ { A } }$ (orange, accuracy: 0.8272, cost: 63 seconds/epoch). Middle: training processes of $\mathrm { R R } _ { \mathrm { A A } } ^ { 1 3 }$ (green) and $\mathrm { S t d _ { A A } }$ (blue). Right: training processes of $\mathrm { R R } _ { \mathrm { A B } } ^ { 1 3 }$ (blue), $\mathrm { S t d } _ { \mathrm { A B } }$ (pink) and StdB (green).
All 13 convolutional layers are used for raclayer (because of different output size) in $\mathsf { R R } _ { \mathrm { A } } ^ { 1 3 }$ oss aand $\mathrm { S t d _ { A } }$ l layers except the last fuare reused for training $\mathsf { R } \mathsf { \check { R } } _ { \mathrm { A A } / \mathrm { A B } } ^ { 1 3 }$ ctedand StdAA/AB. Example training processes of the Cifar tests are shown in Fig. 17. In phase II, the model $\mathrm { R R } _ { \mathrm { A } } ^ { 1 3 }$ outperform $\mathrm { S t d _ { A } }$ in both task $A$ and $B$ . We show details about all models in Table 5.
# A.4 SMOKE DATA SETS TEST
In this section, we will introduce details for Sec. 5.3. The smoke simulation data was generated with a standard fluid solver (Stam, 1999) with MacCormack advection and MiC-preconditioned CG solver via the mantaflow library. We generated 20 simulations with 120 frames for every simulation. $10 \%$ of the data was used for training. Smoke inflow region, inflow velocity and buoyancy force were randomized to produce varied data. The low resolution data was down-sampled from the high-resolution data by a factor of 4. Data augmentation, such as flipping and rotation was used in addition. The smoke capture data set contains 2500 smoke images (Eckert et al., 2018), and we again used $10 \%$ as training data set. The forward and reverse pass structures of the network are in Table 13. Hyper parameters are listed in Table 14. Note that inputs of discriminator contain high resolution data $( 6 4 , 6 4 , 1 )$ and low resolution $( 1 6 , 1 6 , 1 )$ , which is up-sampled to $( 6 4 , 6 4 , 1 )$ and concatenated with high resolution data.
All gentraining ayersand volved in racecar loss. All 6 layers of, but only 5 layers are reused for training $\mathrm { R R } _ { \mathrm { A } } ^ { 6 }$ ndan $\mathrm { S t d _ { A } }$ reused forbecause of $\mathsf { R R } _ { A B _ { 1 } } ^ { 6 }$ $\mathrm { S t d } _ { A B _ { 1 } }$ $\mathsf { R R } _ { A B _ { 2 } } ^ { 6 }$ $\mathrm { S t d } _ { A B _ { 2 } }$ diffetask $A B _ { 1 }$ data size. The following results give further details for the auto-encoder transfer which uses synthetic, i.e., simulated fluid data. Example training processes of $\mathrm { R R } _ { A B _ { 1 } } ^ { 6 }$ (orange), $\mathrm { S t d } _ { A B _ { 1 } }$ (blue) and model trained from scratch $\mathrm { S t d } _ { B _ { 1 } }$ (red) are shown in Fig. 18. $\mathsf { R R } _ { A B _ { 1 } } ^ { 6 }$ achieved the lowest L2 loss after training. Example outputs of $\mathbf { R R } _ { A B _ { 1 } } ^ { 6 }$ , $\mathrm { S t d } _ { A B _ { 1 } }$ and $\mathrm { S t d } _ { B _ { 1 } }$ are shown in Fig. 19. It becomes clear that model $\mathsf { R R } _ { A B _ { 1 } } ^ { 6 }$ 1 gives the best performance across these models.
 Figure 18: Training processes of $\mathbf { R R } _ { A B _ { 1 } } ^ { 6 }$ (orange), $\mathrm { S t d } _ { A B _ { 1 } }$ (blue) and $\mathrm { S t d } _ { B _ { 1 } }$ (red). The green inset shows the final loss values.
 Figure 19: Example outputs comparisons between $\mathsf { R R } _ { A B _ { 1 } } ^ { 6 }$ , $\mathrm { S t d } _ { A B _ { 1 } }$ , $\mathrm { S t d } _ { B _ { 1 } }$ and reference. We can see that $\mathbf { R R } _ { A B _ { 1 } } ^ { 6 }$ works better than $\mathrm { S t d } _ { A B _ { 1 } }$ , while $\mathrm { S t d } _ { B _ { 1 } }$ failed for this task producing a mostly black image.
We similarly illustrate the behavior of the transfer learning task ids. This example likewise uses an auto-encoder structure. Exa $A B _ { 2 }$ for images of real-wtraining processes of $\mathsf { R R } _ { A B _ { 2 } } ^ { 6 }$ $\mathrm { S t d } _ { A B _ { 2 } }$ and model trained from scratch $\mathrm { S t d } _ { B _ { 2 } }$ are shown in Fig. 20. $\mathbf { R R } _ { A B _ { 2 } } ^ { 6 }$ 2yields the best performance at the end of training. Example output comparisons of $\mathbf { R R } _ { A B _ { 2 } } ^ { 6 }$ , $\mathrm { S t d } _ { A B _ { 2 } }$ and $\mathrm { S t d } _ { B _ { 2 } }$ are shown in Fig. 21. We can see that error of $\mathsf { R R } _ { A B _ { 2 } } ^ { 6 }$ is lower than $\mathrm { S t d } _ { A B _ { 2 } }$ and $\mathrm { S t d } _ { B _ { 2 } }$ . Detail comparisons between different models are shown in Table 6.
 Figure 20: Training processes of $\mathbf { R R } _ { A B _ { 2 } } ^ { 6 }$ (orange), $\mathrm { S t d } _ { A B _ { 2 } }$ (blue) and $\mathrm { S t d } _ { B _ { 2 } }$ (red). The green inset shows the final loss values.
 Figure 21: Example outputs and mean absolute error comparisons between $\mathsf { R R } _ { A B _ { 2 } } ^ { 6 }$ , $\mathrm { S t d } _ { A B _ { 2 } }$ , $\mathrm { S t d } _ { B _ { 2 } }$ and reference. We can see that error of $\mathbf { R R } _ { A B _ { 2 } } ^ { 6 }$ is lower than $\mathrm { S t d } _ { A B _ { 2 } }$ and $\mathrm { S t d } _ { B _ { 2 } }$ .
# A.5 VGG TEST
We now give details of the tests in Sec. 5.4. For the ImageNet data set (Deng et al., 2009), 1281167 images of 1000 classes are used for training, and 50k images are used for testing. Image size is $2 2 4 \times 2 2 4$ . The forward and reverse pass of VGG19 are in Table 16. Hyper parameters are listed in Table 15.
All 16 convolutional layers are used for racecar loss. To speed up training process offirstly train a model without racecar loss for 6 epochs with batch size 64, as regular trai $\mathrm { R R } _ { \mathrm { A } } ^ { 1 6 }$ , we And then we reuse this model for training $\mathrm { R R } _ { \mathrm { A } } ^ { 1 6 }$ and $\mathrm { S t d _ { A } }$ with batch size 24. Example training processes of RR16A and $\mathrm { S t d _ { A } }$ are shown in Fig. 22, while those of $\mathrm { R R } _ { \mathrm { A A } } ^ { 1 6 }$ and $\mathrm { S t d _ { A A } }$ are shown in Fig. 23.
Next, we will give additional details for the stylization tests. Gatys et al. (2016) use $L _ { t o t a l } =$ $\eta L _ { c o n t e n t } + \delta L _ { s t y l e }$ for stylization optimizations, where $\eta$ and $\delta$ are coefficient factors. $L _ { c o n t e n t }$ is used to calculate content difference between source image $p$ and generated image $g$ , as shown in equation 3.
$$\begin{array} { r } { L _ { c o n t e n t } ( p , g , t ) = \frac { 1 } { 2 } \sum _ { m , n } ( F _ { p } ^ { m , n , t } - F _ { g } ^ { m , n , t } ) ^ { 2 } , } \end{array}$$
 Figure 22: Top5 accuracy of $\mathrm { R R } _ { \mathrm { A } } ^ { 1 6 }$ (red, accuracy: 0.6673, cost: 0.636 second/batch) and $\mathrm { S t d _ { A } }$ (blue, accuracy: 0.7324, cost: 0.308 second/batch).
 Figure 23: Top5 accuracy of $\mathrm { R R } _ { \mathrm { A A } } ^ { 1 6 }$ (grey) and $\mathrm { S t d _ { A A } }$ (blue).
where $F _ { p } ^ { m , n , t }$ is $p ^ { \prime } s$ feature representation of the $m ^ { t h }$ filter at position $n$ in layer $t$ . $\boldsymbol { L _ { s t y l e } }$ is used to calculate style difference between style image $a$ and generated image $g$ , as shown in equation 4. The style loss can be written as:
$$\begin{array} { r l } & { G _ { a } ^ { m , n , t } = \sum _ { f } F _ { a } ^ { m , f , t } F _ { a } ^ { n , f , t } , } \\ & { E _ { t } = \frac { 1 } { 4 N _ { t } ^ { 2 } M _ { t } ^ { 2 } } \sum _ { m , n } ( G _ { g } ^ { m , n , t } - G _ { a } ^ { m , n , t } ) ^ { 2 } , } \\ & { L _ { s t y l e } ( a , g ) = \sum _ { t = 0 } ^ { T } \omega _ { t } E _ { t } , } \end{array}$$
where $\omega _ { t }$ is are the weighting factors for layer $t$ ; $G$ is the Gram matrix; $N _ { t }$ denotes filter numbers of layer $t$ , and $M _ { t }$ is the dimension of layer $t$ ’s filter; $T$ denotes the number of layers included in the style loss.
Table 1: Model accuracy of MI base task tests Table 2: Model accuracy of MI transfer task tests
<table><tr><td rowspan=1 colspan=1>trainingruns</td><td rowspan=1 colspan=1>OrtA</td><td rowspan=1 colspan=1>RRA</td><td rowspan=1 colspan=1>RR</td><td rowspan=1 colspan=1>StdA</td><td rowspan=1 colspan=1>OrtAA</td><td rowspan=1 colspan=1>RRAA</td><td rowspan=1 colspan=1>RRAA</td><td rowspan=1 colspan=1>StdAA</td></tr><tr><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>0.976</td><td rowspan=1 colspan=1>0.682</td><td rowspan=1 colspan=1>0.767</td><td rowspan=1 colspan=1>0.973</td><td rowspan=1 colspan=1>0.973</td><td rowspan=1 colspan=1>0.855</td><td rowspan=1 colspan=1>0.997</td><td rowspan=1 colspan=1>0.956</td></tr><tr><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>0.944</td><td rowspan=1 colspan=1>0.75</td><td rowspan=1 colspan=1>0.779</td><td rowspan=1 colspan=1>0.986</td><td rowspan=1 colspan=1>0.954</td><td rowspan=1 colspan=1>0.909</td><td rowspan=1 colspan=1>0.99</td><td rowspan=1 colspan=1>0.973</td></tr><tr><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1>0.975</td><td rowspan=1 colspan=1>0.731</td><td rowspan=1 colspan=1>0.855</td><td rowspan=1 colspan=1>0.964</td><td rowspan=1 colspan=1>0.979</td><td rowspan=1 colspan=1>0.875</td><td rowspan=1 colspan=1>0.99</td><td rowspan=1 colspan=1>0.986</td></tr><tr><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>0.993</td><td rowspan=1 colspan=1>0.923</td><td rowspan=1 colspan=1>0.855</td><td rowspan=1 colspan=1>0.981</td><td rowspan=1 colspan=1>0.994</td><td rowspan=1 colspan=1>0.984</td><td rowspan=1 colspan=1>0.995</td><td rowspan=1 colspan=1>0.965</td></tr><tr><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>0.965</td><td rowspan=1 colspan=1>0.405</td><td rowspan=1 colspan=1>0.852</td><td rowspan=1 colspan=1>0.94</td><td rowspan=1 colspan=1>0.967</td><td rowspan=1 colspan=1>0.965</td><td rowspan=1 colspan=1>0.999</td><td rowspan=1 colspan=1>0.986</td></tr><tr><td rowspan=1 colspan=1>Avg</td><td rowspan=1 colspan=1>0.971</td><td rowspan=1 colspan=1>0.707</td><td rowspan=1 colspan=1>0.822</td><td rowspan=1 colspan=1>0.967</td><td rowspan=1 colspan=1>0.973</td><td rowspan=1 colspan=1>0.938</td><td rowspan=1 colspan=1>0.994</td><td rowspan=1 colspan=1>0.973</td></tr><tr><td rowspan=1 colspan=1>Std. Dev.</td><td rowspan=1 colspan=1>0.018</td><td rowspan=1 colspan=1>0.187</td><td rowspan=1 colspan=1>0.045</td><td rowspan=1 colspan=1>0.018</td><td rowspan=1 colspan=1>0.015</td><td rowspan=1 colspan=1>0.056</td><td rowspan=1 colspan=1>0.004</td><td rowspan=1 colspan=1>0.013</td></tr></table>
Table 3: Model accuracy of MNIST base task tests
<table><tr><td rowspan=1 colspan=1>trainingruns</td><td rowspan=1 colspan=1>OrtAB</td><td rowspan=1 colspan=1>RRAB</td><td rowspan=1 colspan=1>RRAB</td><td rowspan=1 colspan=1>StdAB</td><td rowspan=1 colspan=1>StdB</td></tr><tr><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>0.978</td><td rowspan=1 colspan=1>0.914</td><td rowspan=1 colspan=1>0.996</td><td rowspan=1 colspan=1>0.136</td><td rowspan=1 colspan=1>0.966</td></tr><tr><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>0.948</td><td rowspan=1 colspan=1>0.956</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>0.136</td><td rowspan=1 colspan=1>0.958</td></tr><tr><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1>0.976</td><td rowspan=1 colspan=1>0.961</td><td rowspan=1 colspan=1>0.993</td><td rowspan=1 colspan=1>0.136</td><td rowspan=1 colspan=1>0.984</td></tr><tr><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>0.994</td><td rowspan=1 colspan=1>0.97</td><td rowspan=1 colspan=1>0.996</td><td rowspan=1 colspan=1>0.136</td><td rowspan=1 colspan=1>0.974</td></tr><tr><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>0.968</td><td rowspan=1 colspan=1>0.959</td><td rowspan=1 colspan=1>0.998</td><td rowspan=1 colspan=1>0.136</td><td rowspan=1 colspan=1>0.989</td></tr><tr><td rowspan=1 colspan=1>Avg.</td><td rowspan=1 colspan=1>0.973</td><td rowspan=1 colspan=1>0.956</td><td rowspan=1 colspan=1>0.997</td><td rowspan=1 colspan=1>0.136</td><td rowspan=1 colspan=1>0.974</td></tr><tr><td rowspan=1 colspan=1>Std. Dev.</td><td rowspan=1 colspan=1>0.017</td><td rowspan=1 colspan=1>0.022</td><td rowspan=1 colspan=1>0.003</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>0.013</td></tr></table>
Table 4: Model accuracy of MNIST transfer task tests
<table><tr><td rowspan=1 colspan=1>trainingruns</td><td rowspan=1 colspan=1>OrtA</td><td rowspan=1 colspan=1>StdA</td><td rowspan=1 colspan=1>RR</td><td rowspan=1 colspan=1>OrtAA</td><td rowspan=1 colspan=1>StdAA</td><td rowspan=1 colspan=1>RRA</td></tr><tr><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>0.9792</td><td rowspan=1 colspan=1>0.9827</td><td rowspan=1 colspan=1>0.981</td><td rowspan=1 colspan=1>0.9819</td><td rowspan=1 colspan=1>0.9854</td><td rowspan=1 colspan=1>0.9856</td></tr><tr><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>0.8322</td><td rowspan=1 colspan=1>0.9815</td><td rowspan=1 colspan=1>0.9824</td><td rowspan=1 colspan=1>0.982</td><td rowspan=1 colspan=1>0.9837</td><td rowspan=1 colspan=1>0.9851</td></tr><tr><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1>0.9511</td><td rowspan=1 colspan=1>0.9815</td><td rowspan=1 colspan=1>0.9828</td><td rowspan=1 colspan=1>0.9792</td><td rowspan=1 colspan=1>0.983</td><td rowspan=1 colspan=1>0.9862</td></tr><tr><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>0.8841</td><td rowspan=1 colspan=1>0.9817</td><td rowspan=1 colspan=1>0.9816</td><td rowspan=1 colspan=1>0.9814</td><td rowspan=1 colspan=1>0.9842</td><td rowspan=1 colspan=1>0.9867</td></tr><tr><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>0.8266</td><td rowspan=1 colspan=1>0.9829</td><td rowspan=1 colspan=1>0.9816</td><td rowspan=1 colspan=1>0.9816</td><td rowspan=1 colspan=1>0.9846</td><td rowspan=1 colspan=1>0.9861</td></tr><tr><td rowspan=1 colspan=1>Avg.</td><td rowspan=1 colspan=1>0.895</td><td rowspan=1 colspan=1>0.982</td><td rowspan=1 colspan=1>0.982</td><td rowspan=1 colspan=1>0.981</td><td rowspan=1 colspan=1>0.984</td><td rowspan=1 colspan=1>0.986</td></tr><tr><td rowspan=1 colspan=1>Std. Dev.</td><td rowspan=1 colspan=1>0.0689</td><td rowspan=1 colspan=1>0.0007</td><td rowspan=1 colspan=1>0.0007</td><td rowspan=1 colspan=1>0.0011</td><td rowspan=1 colspan=1>0.0009</td><td rowspan=1 colspan=1>0.0006</td></tr></table>
<table><tr><td rowspan=1 colspan=1>trainingtimes</td><td rowspan=1 colspan=1>OrtAB</td><td rowspan=1 colspan=1>StdAB</td><td rowspan=1 colspan=1>RRB</td><td rowspan=1 colspan=1>StdB</td></tr><tr><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>0.949</td><td rowspan=1 colspan=1>0.956</td><td rowspan=1 colspan=1>0.9612</td><td rowspan=1 colspan=1>0.8714</td></tr><tr><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>0.8629</td><td rowspan=1 colspan=1>0.9458</td><td rowspan=1 colspan=1>0.954</td><td rowspan=1 colspan=1>0.9657</td></tr><tr><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1>0.9458</td><td rowspan=1 colspan=1>0.9543</td><td rowspan=1 colspan=1>0.9648</td><td rowspan=1 colspan=1>0.9659</td></tr><tr><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>0.9495</td><td rowspan=1 colspan=1>0.9559</td><td rowspan=1 colspan=1>0.9604</td><td rowspan=1 colspan=1>0.8789</td></tr><tr><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>0.8564</td><td rowspan=1 colspan=1>0.9466</td><td rowspan=1 colspan=1>0.9649</td><td rowspan=1 colspan=1>0.9638</td></tr><tr><td rowspan=1 colspan=1>Avg.</td><td rowspan=1 colspan=1>0.913</td><td rowspan=1 colspan=1>0.952</td><td rowspan=1 colspan=1>0.961</td><td rowspan=1 colspan=1>0.929</td></tr><tr><td rowspan=1 colspan=1>Std. Dev.</td><td rowspan=1 colspan=1>0.0485</td><td rowspan=1 colspan=1>0.0051</td><td rowspan=1 colspan=1>0.0044</td><td rowspan=1 colspan=1>0.0494</td></tr></table>
Table 5: Model accuracy of Cifar tests
<table><tr><td rowspan=1 colspan=1>trainingruns</td><td rowspan=1 colspan=1>StdA</td><td rowspan=1 colspan=1>RR</td><td rowspan=1 colspan=1>StdAA</td><td rowspan=1 colspan=1>RRA</td><td rowspan=1 colspan=1>StdAB</td><td rowspan=1 colspan=1>RRAB</td><td rowspan=1 colspan=1>StdB</td></tr><tr><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>0.8263</td><td rowspan=1 colspan=1>0.5784</td><td rowspan=1 colspan=1>0.8351</td><td rowspan=1 colspan=1>0.869</td><td rowspan=1 colspan=1>0.2063</td><td rowspan=1 colspan=1>0.2602</td><td rowspan=1 colspan=1>0.2581</td></tr><tr><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>0.7868</td><td rowspan=1 colspan=1>0.5553</td><td rowspan=1 colspan=1>0.7936</td><td rowspan=1 colspan=1>0.8538</td><td rowspan=1 colspan=1>0.1838</td><td rowspan=1 colspan=1>0.2687</td><td rowspan=1 colspan=1>0.2659</td></tr><tr><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1>0.7729</td><td rowspan=1 colspan=1>0.7686</td><td rowspan=1 colspan=1>0.7718</td><td rowspan=1 colspan=1>0.8449</td><td rowspan=1 colspan=1>0.1795</td><td rowspan=1 colspan=1>0.2803</td><td rowspan=1 colspan=1>0.2386</td></tr><tr><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>0.865</td><td rowspan=1 colspan=1>0.7382</td><td rowspan=1 colspan=1>0.8472</td><td rowspan=1 colspan=1>0.8692</td><td rowspan=1 colspan=1>0.1738</td><td rowspan=1 colspan=1>0.2969</td><td rowspan=1 colspan=1>0.2418</td></tr><tr><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>0.781</td><td rowspan=1 colspan=1>0.6775</td><td rowspan=1 colspan=1>0.7787</td><td rowspan=1 colspan=1>0.8418</td><td rowspan=1 colspan=1>0.1704</td><td rowspan=1 colspan=1>0.2733</td><td rowspan=1 colspan=1>0.2621</td></tr><tr><td rowspan=1 colspan=1>Avg.</td><td rowspan=1 colspan=1>0.806</td><td rowspan=1 colspan=1>0.664</td><td rowspan=1 colspan=1>0.805</td><td rowspan=1 colspan=1>0.856</td><td rowspan=1 colspan=1>0.183</td><td rowspan=1 colspan=1>0.276</td><td rowspan=1 colspan=1>0.253</td></tr><tr><td rowspan=1 colspan=1>Std. Dev.</td><td rowspan=1 colspan=1>0.0387</td><td rowspan=1 colspan=1>0.0945</td><td rowspan=1 colspan=1>0.0340</td><td rowspan=1 colspan=1>0.0130</td><td rowspan=1 colspan=1>0.0141</td><td rowspan=1 colspan=1>0.0138</td><td rowspan=1 colspan=1>0.0123</td></tr></table>
Table 6: Model L2 loss of smoke tests. Results for $B _ { 2 } \colon \times 1 0 ^ { 7 }$ .
<table><tr><td rowspan=1 colspan=1>trainingruns</td><td rowspan=1 colspan=1>StdAB1</td><td rowspan=1 colspan=1>RRAB1</td><td rowspan=1 colspan=1>StdB1</td><td rowspan=1 colspan=1>Std AB2</td><td rowspan=1 colspan=1>RRAB2</td><td rowspan=1 colspan=1>StdB2</td></tr><tr><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>22883</td><td rowspan=1 colspan=1>211.9</td><td rowspan=1 colspan=1>31911</td><td rowspan=1 colspan=1>213</td><td rowspan=1 colspan=1>2.95</td><td rowspan=1 colspan=1>6.13</td></tr><tr><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>493.3</td><td rowspan=1 colspan=1>139</td><td rowspan=1 colspan=1>22291</td><td rowspan=1 colspan=1>2.37</td><td rowspan=1 colspan=1>1.79</td><td rowspan=1 colspan=1>2.66</td></tr><tr><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1>1828</td><td rowspan=1 colspan=1>210.2</td><td rowspan=1 colspan=1>31911</td><td rowspan=1 colspan=1>11.4</td><td rowspan=1 colspan=1>2.32</td><td rowspan=1 colspan=1>3.43</td></tr><tr><td rowspan=1 colspan=1>Avg.</td><td rowspan=1 colspan=1>8401.43</td><td rowspan=1 colspan=1>187.03</td><td rowspan=1 colspan=1>28704.33</td><td rowspan=1 colspan=1>75.6</td><td rowspan=1 colspan=1>2.36</td><td rowspan=1 colspan=1>4.07</td></tr><tr><td rowspan=1 colspan=1>Std. Dev.</td><td rowspan=1 colspan=1>12559.15</td><td rowspan=1 colspan=1>41.61</td><td rowspan=1 colspan=1>5554.11</td><td rowspan=1 colspan=1>119</td><td rowspan=1 colspan=1>0.578</td><td rowspan=1 colspan=1>1.82</td></tr></table>
Table 7: Forward and reverse pass of the neural network in MI tests
<table><tr><td>Forward pass (294 weights): I(12)→tanh(FC(10)+b1)→ tanh(FC(7)+b2)→ tanh(FC(5) +b3) →tanh(FC(4) +b4)→ tanh(FC(3)+b5)→tanh(FC(2)+b6)→O(2).</td></tr><tr><td>Reverse pass: O(2)-b6 → tanh(FC(3))-b5 →tanh(FC(4))-b4 → tanh(FC(5)) -b3 → tanh(FC(7))-b2 →tanh(FC(10))-b1 →tanh(FC(12))→I(12).</td></tr></table>
Table 8: Hyper parameters of MI tests
<table><tr><td rowspan=1 colspan=1>Batch size</td><td rowspan=1 colspan=1>512|Learningrate</td><td rowspan=1 colspan=1>0.0004</td><td rowspan=1 colspan=1>入1~6</td><td rowspan=1 colspan=1>1E-2</td></tr><tr><td rowspan=1 colspan=1>Training Epochs</td><td rowspan=1 colspan=4>20000 for RRA/AA/AB and StdA/AA/AB; 400O0 for StdB</td></tr></table>
Table 9: Forward and reverse pass network of MNIST Classification tests
<table><tr><td>Forward pass (38645 weights): I(28,28,1) →relu(C(3,64,1)+b1)→ MP →relu(C(3,64,1) +b2)→ MP→relu(C(3,1,1)+b3)= Ir</td></tr><tr><td>→FC(i0)→0(10) Reverse pass:</td></tr><tr><td>Ir -b3→ relu(D(3,64,1))→UP-b2→relu(D(3,64,1))→UP-b1 →relu(D(3,1,1)) →I'(28,28,1)</td></tr></table>
Table 10: Hyper parameters of MNIST Classification tests
<table><tr><td>Batch size</td><td>64</td><td>入1~3</td><td>1E-5</td></tr><tr><td>Learning rate</td><td colspan="3">0.001 for RR,StdA and OrtA; 0.0001 for RRA/AB, StdAA/AB/B and OrtAA/AB</td></tr><tr><td>Training Epochs</td><td colspan="3">100 forRR,StdA and OrtA; 400 for RRA, StdAA and OrtAA; 700 for RRB, StdAB and OrtAB</td></tr></table>
Table 11: Forward and reverse pass of the neural network in Cifar tests
<table><tr><td>Forward pass: I(32,32,3) → relu(BN(C(3,64,1) + bi)) →relu(BN(C(3,64,1) +b2))→MP</td></tr><tr><td>→relu(BN(C(3,128,1) +b3)) →relu(BN(C(3,128,i) +b4))→MP→ relu(BN(C(3,256,1) +b5)) → relu(BN(C(3,256,1) +b6)) →relu(BN(C(3,256,1) +b7))→ MP→relu(BN(C(3,512,1) +b8)) →relu(BN(C(3,512,1) +b9))→relu(BN(C(3,512,1) +b10))→MP→relu(BN(C(3,512,1) +b11)) →relu(BN(C(3,512,1) + b12))→ relu(BN(C(3,512,1) + b13)) = Ir → relu(BN(FC(4096) +b14)) →relu(BN(FC(4096) +b15)) →relu(BN(FC(10) +b16)) →O(10).</td></tr><tr><td>Reverse pass: Ir -b13→ relu(BN(D(3,512,1)))-b12→relu(BN(D(3,512,1)) -b11 →relu(BN(D(3,512,1))) →UP-b10 →relu(BN(D(3,512,1)) -bg →relu(BN(D(3,512,1)) -b8 →relu(BN(D(3,256,1))) →UP-b7 →relu(BN(D(3,256,1)))-b6 →relu(BN(D(3,256,1)) -b5_→ relu(BN(D(3,128,1))) →UP-b4 → relu(BN(D(3,128,1))) -b3 → relu(BN(D(3,64,1))→UP-b2</td></tr></table>
Table 12: Hyper parameters of Cifar tests
<table><tr><td>Batch size</td><td>200</td><td>入1~13</td><td>1E-7</td></tr><tr><td>Learning rate</td><td colspan="3">0.1 (0 to 80 epochs); 0.01 (81 to epochs); 0.001 (after 120 epochs)</td></tr><tr><td>Training Epochs</td><td colspan="3">180 for RRAA and StdA/AA; 50forRR and StdAB/B</td></tr></table>
Table 13: Forward and reverse pass of network in smoke tests
<table><tr><td>Generator forward pass: I(16,16,1) →relu(C(5,64,1) +b1)→UP→relu(C(5,128,1) +b2)→UP→relu(C(5,128,1) + b3)</td></tr><tr><td>→relu(C(5,64,1) +b4) →relu(C(5,32,1) +b5)→ relu(C(5,1,1) +b6)→ O(64,64,1)=Ir. Generator reverse pass: Ir -b6→relu(D(5,32,1))-b5 → relu(D(5,64,1))-b4 → relu(D(5,128,1))-b3 →relu(D(5,128,1))</td></tr><tr><td>→MP-b2 →relu(D(5,64,1)) →MP-b1 → relu(D(5,1,1)) →I'(16,16,1). Discriminator: I(64,64,2) → lrelu(BN(C(5,32,1) +bi)) → lrelu(BN(C(5,64,1) +b2))</td></tr></table>
Table 14: Hyper parameters of smoke tests
<table><tr><td rowspan=1 colspan=1>Batch size</td><td rowspan=1 colspan=1>64</td><td rowspan=1 colspan=1>Learning rate</td><td rowspan=1 colspan=1>0.0002</td><td rowspan=1 colspan=1>入1~6</td><td rowspan=1 colspan=1>0.1</td></tr><tr><td rowspan=1 colspan=1>TrainingEpochs</td><td rowspan=1 colspan=5>40000 for RRand StdA;1000for RRAB, RRAB2, StdAB1 and StdAB2</td></tr></table>
Table 15: Hyper parameters of VGG19 training
<table><tr><td rowspan=1 colspan=1>入1~16</td><td rowspan=1 colspan=1>1E-10</td></tr><tr><td rowspan=1 colspan=1>Learning rate</td><td rowspan=1 colspan=1>0.01 (0 to 7 epochs); 0.001 (7 to 10 epochs);0.0001(10 to 15 epochs); 0.00001 (after 15 epochs)</td></tr><tr><td rowspan=1 colspan=1>Training Epochs</td><td rowspan=1 colspan=1>36 epochs for RR and StdA;22 epochs for RR6 aand StdAA</td></tr></table>
Table 16: Forward and reverse pass of VGG19 network
<table><tr><td>Forward pass: I(224,224,3) →relu(C(3,64,1) +b1)→ relu(C(3,64,1) +b2)→ MP→ relu(C(3,128,1)+b3) →relu(C(3,128,1) +b4) →MP→relu(C(3,256,1) +b5)→relu(C(3,256,1) +b6)</td></tr><tr><td>→relu(C(3,512,1) + b13) → relu(C(3,512,1) + b14) → relu(C(3,512,1) + b15) →relu(C(3,512,1) +b16)= Ir →MP→relu(FC(4096) +b17)→relu(FC(4096) +b18) →relu(FC(1000)+b19)→O(1000). Reverse pass: Ir -b16 → relu(D(3,512,1)) -b15 →relu(D(3,512,1)) -b14 →relu(D(3,512,1))- b13 →relu(D(3,512,1)) →UP-b12 →relu(D(3,512,1)) -b11→ relu(D(3,512,1)) -b10 →relu(D(3,512,1))-bg→relu(D(3,256,1)) →UP-bg → relu(D(3,256,1))-b7 →relu(D(3,256,1))-b6 →relu(D(3,256,1)) -b5 →relu(D(3,128,1)) →UP-b4 → relu(D(3,128,1)) -b3 → relu(D(3,64,1))→ UP-b2 →relu(D(3,64,1)) -b1 → relu(D(3,3,1)) →I (224,224,3).</td></tr></table>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382# LEARNING NEURAL CAUSAL MODELS FROM UNKNOWN INTERVENTIONS
Anonymous authors Paper under double-blind review
# ABSTRACT
Meta-learning over a set of distributions can be interpreted as learning different types of parameters corresponding to short-term vs long-term aspects of the mechanisms underlying the generation of data. These are respectively captured by quickly-changing parameters and slowly-changing meta-parameters. We present a new framework for meta-learning causal models where the relationship between each variable and its parents is modeled by a neural network, modulated by structural meta-parameters which capture the overall topology of a directed graphical model. Our approach avoids a discrete search over models in favour of a continuous optimization procedure. We study a setting where interventional distributions are induced as a result of a random intervention on a single unknown variable of an unknown ground truth causal model, and the observations arising after such an intervention constitute one meta-example. To disentangle the slow-changing aspects of each conditional from the fast-changing adaptations to each intervention, we parametrize the neural network into fast parameters and slow meta-parameters. We introduce a meta-learning objective that favours solutions robust to frequent but sparse interventional distribution change, and which generalize well to previously unseen interventions. Optimizing this objective is shown experimentally to recover the structure of the causal graph. Finally, we find that when the learner is unaware of the intervention variable, it is able to infer that information, improving results further and focusing the parameter and meta-parameter updates where needed.
# 1 INTRODUCTION
A major challenge of contemporary deep learning is to generalize well outside the assumptions of independent and identically distributed data, when we care about generalization or fast adaptation to distributions other than the main training distribution. For this purpose, we propose an approach that starts by distinguishing between: (a) an underlying causal model, (b) observational distributions derived from it, an (c) interventional distributions arising from interventions upon its variables, whether they be known or unknown. Fortunately, these distinctions can be addressed by the paradigm of Structural Causal Models (SCMs) (Pearl, 1995; Peters et al., 2017) and a wide body of associated literature. Unlike other frameworks using SCMs we also account for interventions performed by agents other than an experimenter. By treating the interventions of other agents as unknown interventions that lead to changes in the underlying data distribution, the present work is a contribution towards the use of a meta-learning for causal model induction.
Estimating the underlying causal structure from data is an open and challenging problem (Pearl, 2009; Imbens & Rubin, 2015). A lot of prior work has examined learning causal structure based on observational data (Chickering, 2002; Tsamardinos et al., 2006; Goudet et al., 2017; Hauser & Bühlmann, 2012; Spirtes et al., 2000; Sun et al., 2007; Zhang et al., 2012; Shimizu et al., 2006; Hoyer et al., 2009; Daniusis et al., 2012; Budhathoki & Vreeken, 2017; Kalainathan et al., 2018). However, many real-world datasets have an inherent distributional heterogeneity due to different interventions to the variables composing the model. In these situations interventional approaches are needed (e.g. Heckerman et al., 1995; Cooper & Yoo, 1999; Hauser & Bühlmann, 2012; Peters et al., 2016; Rothenhäusler et al., 2015; Ghassami et al., 2017). Established approaches for causal inference are often either relying on restrictive assumptions or on conditional independence testing, which is hard (Shah & Peters, 2018). Furthermore, most of these approaches either assume full knowledge of the intervention or make strong assumptions about its form (Heinze-Deml et al., 2018).
However, in the real world, interventions are also not always performed by an experimenter. They can be performed by other agents, or by environmental changes in ways that are unknown, or by a naive learner (like a robot) which does not know precisely yet how its low-level actions change high-level causal variables. In this paper, we look at the setting where interventions are unknown, and our goal is to discover causal graphs given unknown-intervention samples. The challenging aspect of this setting is to not only learn the causal graph structure, but also predict the intervention accurately. In this setting, we need to make sure to: (1) avoid an exponential search over all possible DAGs, (2) handle unknown interventions, (3) model the effect of interventions, and (4) model the underlying causal structure.
One possibility for learning a causal structure (through SCM modelling) is to perform many experiments in which one executes interventions. Thus, such interventions modify the effect of the intervened upon variable from its parents in the corresponding DAG, which the model has to quickly adapt to. We can make parallel connections to meta-learning, where the inner loop can be considered as fast adaptation to the distribution change, and outer loop can be considered as learning the stationary meta-parameters of the model. For causal induction, one can consider each distribution which arises as a result of an intervention as a meta-example, and use a meta-learning objective for fast adaptation in response to an intervention. One can think of model parameters as being composed of slow- and fast-changing parameters. The slow parameters are analogous to the meta-parameters in meta-learning and are used for (1) intervention prediction in order to handle the unknown intervention and for (2) modeling the underlying causal structure. On the other hand, the fast parameters are used to model the effect of interventions. An explicit search over the exponentially-growing space of all possible DAGs is avoided by modeling the conditionals of the structural causal model using function approximators, with one neural network per variable. The belief over whether one node $i$ is a direct causal parent of another node $j$ corresponds to a dropout probability for the $i$ -th input of network $j$ (which predicts variable $j$ given its parents). This cheaply represents all $2 ^ { M ^ { 2 } }$ possible model graphs, with the graph search implicitly achieved by learning these dropout probabilities. We thus propose a new method for fast adaptation and learning of neural causal models by framing the problem in a meta-learning setting, similar to (Dasgupta et al., 2019; Bengio et al., 2019).
Our contributions Our key contributions can be summarized as follows:
• Handle causal induction to the case where the variable on which a soft intervention took place is not known by the learner, and show that better results can be obtained when the learner attempts to infer that information and uses it to appropriately change parameters and meta-parameters. • We bypass the issue of having to optimize over and represent an exponentially large set of discrete causal graphs by learning an efficiently parametrized ensemble of SCMs, • Show that our algorithm correctly identifies the causal graph and use the learned graph for generalization to an unseen environment.
# 2 PRELIMINARIES
A Structural Causal Model (SCM) (Peters et al., 2017) over a finite number $M$ of random variables $X _ { i }$ is a set of structural assignments
$$X _ { i } : = f _ { i } ( X _ { p a ( i , C ) } , N _ { i } ) , \quad \forall i \in \{ 0 , \dots , M - 1 \}$$
where $N _ { i }$ is jointly-independent noise and $p a ( i , C )$ is the set of parents (direct causes) of variable $i$ under configuration $C$ of the SCM directed acyclic graph, i.e., $C \in \{ 0 , 1 \} ^ { M \times M }$ , with $c _ { i j } = 1$ if node $i$ has node $j$ as a parent (equivalently, $X _ { j } \in X _ { p a ( i , C ) }$ ; i.e. $X _ { j }$ is a direct cause of $X _ { i }$ ). The $n$ -th power of an adjacency matrix, $C ^ { n }$ , counts the number of length- $n$ walks from node $i$ to node $j$ of the graph in element $c _ { i j }$ . The trace of the $n$ -th power of an adjacency matrix, $\mathrm { T r } ( C ^ { n } )$ , counts the number of length- $\mathbf { \nabla } \cdot n$ cycles in the graph. Causal structure learning is the recovery of the ground-truth $C$ from observational and interventional studies.
Functional and structural meta-parameters Let us consider the simplest SCMs, those with $M = 2$ random variables (lets say random variables $A$ and $B$ ). Only three DAGs exist relating them; they are $A B$ , $B A$ or $A \bot B$ . These can be represented as the following. If $A$ causes
$B$ , then the SCM between $A$ and $B$ can be represented as $B = f _ { \theta _ { B } } ( c _ { B A } \cdot A , \epsilon _ { B } )$ , where $c _ { B A } = 1$ $\epsilon _ { B } \sim N _ { B }$ is a sample of an independent noise factor. If $B$ causes $A$ , then the SCM can be presented as $A = f _ { \theta _ { A } } ( c _ { A B } \cdot B , \epsilon _ { A } )$ , where $c _ { A B } = 1$ , $\epsilon _ { A } \sim N _ { A }$ is a sample of an independent noise factor. If $A$ and $B$ are independent, then we have the same equations but we set $c _ { A B } = 0$ and $c _ { B A } = 0$ .
We may now think of learning the structural causal model as learning the two probabilities of $c _ { A B }$ or $c _ { B A }$ being 1 (versus 0), representing our belief in the causal relationship between $A$ and $B$ . We can parametrize these probabilities differentiably using $P ( c _ { A B } = 1 ) ^ { \bar { } } = \sigma ( \gamma _ { A B } )$ and $P ( c _ { B A } = 1 ) = \sigma ( \gamma _ { B A } )$ , with $\gamma$ real numbers and $\begin{array} { r } { \sigma ( x ) \ = \ \frac { \bar { } 1 } { 1 + e ^ { - x } } } \end{array}$ . We can also parametrize the structural equations $f _ { \theta _ { A } }$ and $f _ { \theta _ { B } }$ in a differentiable manner, using conditional probability tables (CPTs) or neural networks.
Hence, the problem becomes simultaneously learning the structural meta-parameters $\gamma$ and the functional meta-parameters $\theta$ . Functional meta-parameters $\theta$ may be easily learned by maximum likelihood or a proxy, and using backpropagation. However, the $\gamma$ are more difficult to infer. Bengio et al. (2019) propose to learn them by using observations of how the distribution changes sparsely, with the transfer generalization (the adaptation rate after the sparse change) being the training objective for $\gamma$ . Simultaneously inferring both $\theta$ and $\gamma$ is still more difficult. An $M$ -variable SCM over random variables $X _ { i }$ , $i \in \{ 0 , \ldots , M - 1 \}$ can induce a super-exponential number of adjacency matrices $C$ . The super-exponential explosion in the number of potential graph connectivity patterns and the super-exponentially growing storage requirements of their defining conditional probability tables make CPT-based parametrizations of the structural assignments $f _ { i }$ increasingly unwieldy as $M$ scales. As shown below, neural networks with $c _ { i j }$ -masked inputs can provide a more manageable parametrization. For more background about different kinds of intervention we ask the reader to refer Appendix A.3.
# 3 PROPOSED FRAMEWORK: META LEARNING FOR CAUSAL INDUCTION
Our framework disentangles the slow-changing meta-parameters, which reflect the stationary properties discovered by the learner, and the fast-changing parameters, which adapt in response to interventional changes in distribution. We consider two kinds of meta-parameters: the causal graph structure $\gamma$ and the model’s slow weights $\theta _ { \mathrm { s l o w } }$ , along with the meta-learning objective for both of them. We also consider one kind of parameter: the model’s fast weights, $\theta _ { \mathrm { f a s t } }$ . We will call $\theta = \theta _ { \mathrm { s l o w } } + \theta _ { \mathrm { f a s t } }$ the sum of the slow, stationary meta-parameters and the fast, adaptational parameters.
# 3.1 TASK DESCRIPTION
Our task setup deviates from most common deep learning modeling setups. For the purposes of this work, we restrict ourselves to inference of randomly-generated or manually-provided ground-truth SCMs of $M$ categorical random variables causally related via a DAG. The model is permitted to see (1) data from the original ground-truth model, and (2) data from a modified ground-truth model with a random intervention applied. In our experiments, at most one intervention is concurrently performed. When an intervention is performed, a single node is randomly and uniformly chosen among all $M$ nodes, and its ground-truth distribution soft-intervened upon. The learner model is aware of the samples having come from an intervention distribution, but is not aware of the identity of the intervention node, and so must predict it. Each run of sampling steps under a given intervention is referred to as an episode. The learner, over a large number of episodes, will experience all nodes being intervened upon, and should be able to infer the SCM from these interventions.
# 3.2 CAUSAL INDUCTION AS AN OPTIMIZATION PROBLEM
We first explain how we mitigate the problem of searching in the super-exponential set of graph structures. If there are $M$ such variables, the strategy of considering all the possible structural graphs as separate hypotheses is not feasible because it would require maintaining $O ( 2 ^ { M ^ { 2 } } )$ models of the data. We note that we can cheaply choose any of the $2 ^ { M ^ { 2 } }$ possible DAGs through suitable independent Bernoulli choices $c _ { i j }$ associated with each edge $i j$ of the causal graph, i.e., sampling all the $c _ { i j }$ ’s independently. Then we only need to learn the $M ^ { 2 }$ coefficients $\gamma _ { i j }$ , and we implicitly maintain a distribution over the $2 ^ { M ^ { 2 } }$ models corresponding to all the possible draws of $c _ { i j }$ . Note that a slight dependency between the $c _ { i j }$ is induced if we require the causal graph to be acyclic (which allows one to sample the $X$ using ancestral sampling). To enforce that constraint it is not sufficient to require $c _ { i j } c _ { j i } = 0$ (both cannot be 1). We deal with this problem with a regularizer acting on the $\gamma$ ’s in order to favour acyclic solutions (Zheng et al., 2018).
In our approach, each random variable’s structural assignment is modeled via $X _ { i } : = f _ { \theta _ { i } } ( \bar { c } _ { i 0 } \times X _ { 0 } , c _ { i 1 } \times$ $X _ { 1 } , . . . , c _ { i m } \times X _ { m } , \epsilon _ { i } )$ , where $f _ { \theta _ { i } } ( \dot { ) }$ is a neural network (MLP) with parameters $\theta _ { i }$ , and $c _ { i j } \sim \mathrm { B i n } ( \mathrm { s i g m o i d } ( \gamma _ { i j } ) )$ . Through this construction we can frame the causal induction problem as an optimization problem, with $\theta$ optimized to maximize the likelihood of data under the model but $\gamma$ optimized with respect to a meta-learning objective arising from changes in distribution because of interventions. There are a few benefits for learning a parametrized ensemble of SCMs. Such an ensemble is analogous to an ensemble of neural nets differing by their binary input dropout masks, which select what variables are used as predictors of another variable.
 Figure 1: MLP Model Architecture for $M = 3$ , $N = 2$ (fork3) SCM. The model computes the conditional probabilities of ${ \hat { A } } , { \hat { B } } , { \hat { C } }$ given their parents using a stack of three independent MLPs. The MLP input layer uses an adjacency matrix sampled from $\mathrm { B e r } ( \sigma ( \gamma ) )$ as an input mask to force the model to make use only of parent nodes to predict their child node.
# 3.3 FAST ADAPTATION BY META-LEARNING
Fast and slow weights To disentangle an environment’s stable, unchanging properties (the causal structure) from unstable, changing properties (the effects of an intervention), we proposed in $\ S 3$ to distinguish between the model’s functional meta-parameters $\theta _ { \mathrm { s l o w } }$ and parameters $\theta _ { \mathrm { f a s t } }$ . The sum of these weights, $\theta = \theta _ { \mathrm { s l o w } } + \theta _ { \mathrm { f a s t } }$ , parametrizes the MLPs computing the conditionals $P _ { i } ( X _ { i } | X _ { p a ( i ) } ; \theta _ { i } )$ The fast weights and the slow weights terminology is drawn from Hinton & Plaut (1987). The construction of $\theta$ as a sum of initial, slow weights plus zeroed, fast weight that are then allowed to quickly adapt during a transfer episode is due to MAML (Finn et al., 2017). The ability to generalize out-of-distribution by adapting to a transfer distribution can then be measured by the likelihood after adapting the fast weights on transfer data.
Since an intervention is generally not persistent from one transfer distribution to another, the model’s functional parameters $( \theta _ { \mathrm { f a s t } } )$ are reset after each episode of transfer distribution adaptation. The meta-parameters $( \theta _ { \mathrm { { s l o w } } } , \gamma )$ are preserved, then updated after each episode. Inspired by Bengio et al. (2019), the meta-objective for each meta-example over some intervention distribution $D _ { \mathrm { i n t } }$ is the following1 "meta-transfer" loss:
$$\mathcal { R } = - \mathbb { E } _ { X \sim D _ { \mathrm { i n t } } } [ \log \mathbb { E } _ { C \sim \mathrm { B e r } ( \gamma ) } [ \prod _ { i } \mathcal { L } _ { C , i } ( X ; \theta _ { \mathrm { s l o w } } ) ] ]$$
where $X$ is an example sampled from the intervention distribution $D _ { \mathrm { i n t } }$ , $C$ is an adjacency matrix drawn from our belief distribution (parametrized by $\gamma$ ) about graph structure configurations and
$$\mathcal { L } _ { C , i } ( X ) = P ( X _ { i } | X _ { p a ( i , C ) } ; \theta _ { \mathrm { s l o w } } )$$
is the likelihood of the $i$ -th variable $X _ { i }$ of the sample $X$ , when predicting it under the configuration $C$ from the set of its putative parents, $X _ { p a ( i , C ) }$ .
Structural Parameter Gradient Estimator Because a discrete Bernoulli random sampling process is used to produce the configurations under which the log-likelihood of data samples is obtained, we require a gradient estimator to propagate gradient through to the $\gamma$ structural meta-parameters.
We adopt for this purpose the gradient estimate of Bengio et al. (2019) (but see footnote 1):
$$g _ { i j } = \frac { \sum _ { k } ( \sigma ( \gamma _ { i j } ) - c _ { i j } ^ { ( k ) } ) \mathcal { L } _ { C , i } ^ { ( k ) } ( X ) } { \sum _ { k } \mathcal { L } _ { C , i } ^ { ( k ) } ( X ) }$$
where the $( k )$ superscript indicates the values obtained for the $k$ -th draw of $C$ . This gradient is estimated solely with $\theta _ { \mathrm { s l o w } }$ because estimates employing $\theta$ have much greater variance.
Acyclic Constraint We add a regularization term to the loss term that discourages the model from having length-2 cycles in the learned adjacency matrix. The regularizer term is
$$J _ { \mathrm { D A G } } = \sum _ { i \neq j } \cosh ( \sigma ( \gamma _ { i j } ) \sigma ( \gamma _ { j i } ) ) , \quad \forall i , j \in \{ 0 , \ldots , M - 1 \}$$
and is derived from Zheng et al. (2018). The details of the derivation are in the Appendix.
# 3.4 MODEL DESCRIPTION
Learner Model We model the $M$ structural assignments $X _ { i } : = f _ { i } ( X _ { p a ( i , C ) } , N _ { i } )$ (Eq. 1) of the SCM as a set of $M$ multi-layer perceptrons (MLPs), as in Bengio et al. (2019). The MLPs are identical in shape but do not share any parameters, since they are modeling independent causal mechanisms. Each possesses an input layer of $M \times N$ neurons (for $M$ one-hot vectors of length $N$ each), a single hidden layer chosen arbitrarily to have $\operatorname* { m a x } ( 4 M , 4 N )$ neurons with a LeakyReLU activation of slope 0.1, and an output layer of $N$ neurons representing the unnormalized log-probabilities of each category. To force $f _ { i }$ to rely exclusively on the direct ancestor set $p a ( i , C )$ under adjacency matrix $C$ (See Eqn. 2), the one-hot input vector $X _ { j }$ for variable $X _ { i }$ ’s MLP is masked by the Boolean element $c _ { i j }$ . The functional parameters of the MLP are the set $\theta = \left\{ { \cal W } 0 _ { i h j n } , { \tt B } 0 _ { i h } , { \tt W } 1 _ { i n h } , { \tt B } 1 _ { i n } \right\}$ .
An example of the multi-MLP architecture with $M = 3$ categorical variables of $N = 2$ categories is shown in Figure 1.
Ground-Truth Model In our experiments, ground-truth SCM models are parametrized as a set of MLPs of the same size as the learner models, thus avoid having to manually define the Conditional Probability Tables (CPTs). Ground-truth models exist in two variants that differ mainly in initialization: synthetic, where the $\theta$ are randomly initialized and the $\gamma$ are either randomly-initialized or pre-specified; and real-world, where the $\theta$ and $\gamma$ are both initialized so as to closely replicate the CPTs of given Bayesian networks.
# 3.5 INTERVENTIONS
Soft interventions To execute an intervention on variable $X _ { i }$ , we reinitialize $X _ { i }$ ’s ground-truth MLP parameters randomly while leaving other variables’ MLPs untouched. A copy of the old parameters is saved, allowing the intervention to be undone by resetting the parameters back to their original values.
Predicting interventions After an intervention on $X _ { i }$ , the gradients into the learned model’s $\gamma _ { i }$ and the slow weights for the $i$ -th conditional are false, because they do not bear the blame for $X _ { i }$ ’s outcome (which lies with the intervener). We find that ignoring this issue considerably hurts or slows down meta-learning, suggesting that we should try to infer on which variable the intervention took place. For this purpose, we take advantage of the fact that the conditional likelihood of the intervened variable tends to have a poorer relative likelihood under $D _ { \mathrm { i n t } }$ , so we pick the variable with the greatest deterioration in likelihood as our guess.
# 3.6 TRAINING ALGORITHM
The structural meta-parameters $\sigma ( \gamma _ { i j } )$ represent the belief in the hypothesis that node $i$ has node $j$ as a direct causal parent. We may sample from this belief, obtaining different configurations (causal structures) of the causal graph. We hypothesize that the correct configuration enables better adaptation to a slight change in distribution, e.g. resulting from a soft intervention. Hence, we evaluate different configurations under the transfer distribution; those giving a higher transfer likelihood under $\theta _ { \mathrm { s l o w } }$ get a higher reward and their probability is increased. The functional (meta-)parameters are trained as usual by gradient ascent on the log-likelihood. The details of the training algorithm is in Section A.2 in the Appendix.
Synthetic datasets use either a specified edge structure for $\gamma$ , or randomly initialize $\gamma _ { i j }$ such that it is Boolean, strictly lower-triangular, and each row has an expected sum of 1-5 (and therefore each node expects 1-5 direct ancestors). Real-world datasets, specified as CPTs, must first be converted or approximated by a near-ground-truth MLP. We use the graph’s proper edge structure to initialize $\gamma$ and learn $\theta$ by training individually each MLP in the set to replicate the correct pre-softmax logits. In practice, excellent reproductions of the CPT can be achieved.
Stability of training Our model requires simultaneous training of both the structural and the functional meta-parameters, but these are not independent and do influence each other, which leads to instability in training. For example, if $\sigma ( \gamma _ { i j } ) \approx 0$ incorrectly, the $i$ -th MLP does not learn to use input $X _ { j }$ , and vice-versa, if the $i$ -th MLP has not learned to properly use input $X _ { j }$ , this will favour pushing $\sigma ( \gamma _ { i j } )$ towards 0. To overcome this instability, we pretrain the model under observational data (from the distribution of the data before interventions) using dropout on the inputs. This ensures that the functional meta-parameters $\theta _ { \mathrm { s l o w } }$ are not too biased towards certain configurations of the meta-parameters $\gamma$ .
# 4 RELATED WORK
The recovery of the underlying structural causal graph from observational and interventional data is a fundamental problem (Pearl, 1995; 2009). Different approaches have been studied, score-based, constraint-based and asymmetry-based methods. Score-based methods search through the space of all possible directed acyclic graphs (DAGs) representing the causal structure based on some form of scoring function for network structures (Chickering, 2002; Tsamardinos et al., 2006; Goudet et al., 2017; Hauser & Bühlmann, 2012; Heckerman et al., 1995; Cooper & Yoo, 1999; Hauser & Bühlmann, 2012). Constraint-based methods (Spirtes et al., 2000; Sun et al., 2007; Zhang et al., 2012) infer the DAG by analyzing the conditional independence of data. Eaton & Murphy (2007b) use dynamic programming techniques to accelerate Markov Chain Monte Carlo (MCMC) sampling in a Bayesian approach to structure learning for discrete variable DAGs. Asymmetry-based methods (Shimizu et al., 2006; Hoyer et al., 2009; Daniusis et al., 2012; Budhathoki & Vreeken, 2017; Mitrovic et al., 2018) assume asymmetry between cause and effect in the data and try to use this information to estimate the causal structure. Recently Peters et al. (2016); Ghassami et al. (2017) proposed to exploit invariance across different environments to infer causal structure, but are difficult to scale to large graphs due to the necessary iteration over the super-exponential set of possible graphs.
For interventional data, it is often assumed that the models have access to full intervention information, which is rare in the real world. Rothenhäusler et al. (2015) have investigated the case of additive shift interventions, while Eaton & Murphy (2007a) have examined the situation where the targets of experimental interventions are imperfect or uncertain. This is different from our setting where the intervention is unknown to start with and is assumed to arise from other agents and the environment.
Learning based methods have been proposed (Guyon, a;b; Lopez-Paz et al., 2015) and there also exist recent approaches using the generalization ability of neural networks to learn causal signals from purely observational data (Kalainathan et al., 2018; Goudet et al., 2018). Neural network methods equipped with learned masks, such as (Ivanov et al., 2018; Li et al., 2019; Yoon et al., 2018; Douglas et al., 2017), exist in the literature, but only a few (Kalainathan et al., 2018) have been adapted to causal inference. This last work is, however, tailored for causal inference on continuous variables and from observations only. Adapting it to a discrete-variable setting is made difficult by its use of a Generative Adversarial Network (GAN) Goodfellow et al. (2014) framework.
Turning now to meta-learning, Dasgupta et al. (2019) have used it to learn to make predictions under interventions. However, their approach does not induce a causal graph, neither explicitly nor via decoding. Thus, it cannot be used for general causal discovery, but only to make predictions of variable values. Most similar to our work, Bengio et al. (2019) proposes a meta-learning framework for learning causal models from interventional data. However, the proposed method (Bengio et al., 2019) explicitly models every possible set of parents for every child variable and attempts to distinguish the best among them. Because there are combinatorially-many such parent sets, the method cannot scale beyond trivial graphs. In our work, we bypass this restriction by modeling the edge between any 2 variables as a dropout probability and hence our model only scales quadratically with the graph size.
# 5 EXPERIMENTAL SETUP AND RESULTS
Our experiments aim to evaluate the proposed method to recover the correct causal structure and which elements of the method matter. We first evaluate our model on a synthetic dataset where we have control over the number of variables and causal edges in the ground-truth SCM. This allows us to verify after learning with what accuracy we recover the individual decisions about $c _ { i j }$ and understand the performance of our algorithm under various conditions. We then evaluate our method on real world datasets collected from the BnLearn dataset repository, and show that the proposed approach recovers the true causal structure. We then show that the trained models can correctly predict the consequences of previously unseen interventions on the rest of the graph. We also perform ablations showing how important is each component of the model.
# 5.1 SYNTHETIC DATASETS
 Figure 2: Learned edges at three different stages of training. Left: Chain graph with 4 variables. Right: Fully-connected DAG graph with 4 variables.
We first evaluate the model’s performance on several randomly-initialized SCMs with specific, representative graph structures. For $M = 3$ -variable DAGs, we consider every possible connected graph: chain3, fork3, collider3 and confounder3 (See Fig. 7 in appendix). They exhibit every graph sub-structure that can exist in larger graphs, and must be mastered before tackling larger graphs. Since the number of possible DAGs grows super-exponentially with the number of variables, for $M > 3$ up to 8 a selection of representative and edge-case graphs are chosen. The chainM and fullM graphs $( \mathbb { M } = 3 - 8$ ) are the minimally and maximally connected M-variable graphs, while the remaining graphs are randomly generated with a varying sparsity level (1-4 expected number of parents per node). The details of the setup can be found in Appendix A.5.
Results The model can successfully recover the correct edge structure for all synthetic graphs considered. The learning curves plotting the average cross-entropy (CE) loss for the learned edges against the ground-truth model for $M = 3$ are shown in Figure 7. The fully-connected confounder3 graph is particularly easy to learn, but all 3-variable graphs are learned perfectly. Plots of the same process on 4- through 8-variable graphs were similarly encouraging, with all models converging to a negligible loss. The results are, however, sensitive to some hyperparameters, notably the DAG penalty and the sparsity penalty.
# 5.2 REAL-WORLD DATASETS: BNLEARN
The Bayesian Network Repository is a collection of commonlyused causal Bayesian networks from the literature, suitable for Bayesian and causal learning benchmarks. We evaluate our model on the Earthquake (Korb & Nicholson, 2010), Cancer (Korb & Nicholson, 2010) and Asia (Lauritzen & Spiegelhalter, 1988) datasets ( $M = 5$ , 5 and 8-variables respectively, maximum 2 parents per node) in the BnLearn dataset repository.
The ground-truth SCM is given for each dataset, and the functional parameters are represented as conditional probability tables (CPTs). We learn a near-ground-truth MLP from the dataset’s CPT and use it as the ground-truth data generator. We also insert a (greater than 1) temperature factor in order to increase the likelihood of sampling some very rare events in the CPTs. Details of the setup can be found in Appendix A.5.1.
 Figure 3: Earthquake: Learned edges at three different stages of training.
Results The model can successfully recover the correct edge structure for all BnLearn graphs considered up to and including 8-variable Asia. Figures 3 and 4 illustrate what the model has learned at several stages of learning. In these figures, the $\sigma ( \gamma _ { i j } )$ and $c _ { i j }$ adjacency matrix elements are plotted as colored squares and dots. Off-diagonal terms are unknown, and appear yellow.
 Figure 4: Asia: Learned edges at three different stages of training.
 Figure 5: Left: Cross entropy (CE) for edge probability between learned and ground-truth graphs for all 3-variable SCMs. Error bars are $\pm 1 \sigma$ over PRNG seeds 1-5. Middle: Edge CE loss for the chain graph with 4-7 variables. Right: Edge CE loss for 3-variable graphs with no dropout during pretraining, showing the importance of this dropout.
 Figure 6: Ablations study results on all possible 3 variable graphs. Both graphs show the cross-entropy loss on learned vs ground-truth edges over training time. Left: Models that infer the intervention (prediction, bold) vs models that have knowledge of the true intervention (ground truth, long dash) vs models that use no knowledge of the intervention at all (no prediction, short dash). Result suggests inferring the intervention works almost as well as knowing the true intervention. Right: Comparisons of model trained with and without DAG regularizer $( L _ { \mathrm { D A G } } )$ , showing that DAG regularizer helps convergence.
The color of the squares indicates belief in the presence or absence of an edge $( \sigma ( \gamma _ { i j } ) )$ , while the color of the dot indicates the ground truth $c _ { i j }$ . Red indicates (belief in) an edge; Blue indicates (belief in) the absence of an edge. Yellow indicates maximum uncertainty At the beginning of training, the main diagonal is a priori known to be clear of edges, and therefore is solid blue.
As training progresses, the beliefs approach the ground truth, which visually appears as the squares converging towards the color of the dot within them. When they coincide, the dot vanishes. An erroneous belief stands out as a red dot on blue square or, vice-versa, a blue dot on red square. Because we pre-sort the nodes in BnLearn datasets so that they are in topological order, the model must learn a lower triangle. This corresponds to a completely blue uppper triangle. Anti-causal violations are easily recognizable as non-blue squares in the upper triangle.
Baseline comparisons We compared our method to ICP (Peters et al., 2016) and Eaton & Murphy (2007a). Eaton & Murphy (2007a) handles uncertain interventions and Peters et al. (2016) handles unknown interventions. However, neither attempt to predict the intervention.
Table 1: Baseline comparisons: Cross entropy (lower is better) for edge probability on learned and ground-truth edges on Asia graph. compared to to Peters et al. (2016), (Eaton & Murphy, 2007a) and (Zheng et al., 2018)
<table><tr><td>Our method</td><td>(Eaton & Murphy,2007a)</td><td>(Peters et al., 2016)</td><td>(Zheng et al., 2018)</td></tr><tr><td>0.0</td><td>0.0</td><td>10.7</td><td>3.1</td></tr></table>
Importance of Dropout To perform initial pretraining for an observational distribution, sampling adjacency matrices is required. One may be tempted to make these “fully-connected” (all-ones except for a zero diagonal), to give the MLP maximum freedom to learn any potential causal relations itself. We demonstrate that pretraining cannot be carried out this way, and that it is necessary to “drop out” each edge (with probability 0.5 in our experiments) during pre-training of the conditional distributions of the SCM. We attempt to recover the previously-recoverable graphs chain3, fork3 and confounder3 without dropout, but fail to do so, as shown in Figure 5.
Generalization to Previously Unseen Interventions It is often argued that learning approaches based on prediction do not necessarily yield models that generalize to unseen experiments, since they do not explicitly model changes through interventions - in contrast causal models use the concept of interventions to explicitly model changing environments and hold thus the promise to work even under distributional shifts (Pearl, 2009; Schölkopf et al., 2012; Peters et al., 2017).
Table 2: Evaluating the consequences of a previously unseen intervention: (test log-likelihood under intervention)
<table><tr><td></td><td>fork3</td><td>chain3</td><td>confounder3</td><td>collider3</td></tr><tr><td>Our Model</td><td>-0.4502</td><td>-0.3801</td><td>-0.2819</td><td>-0.4677</td></tr><tr><td>Baseline</td><td>-0.5036</td><td>-0.4562</td><td>-0.3628</td><td>-0.5082</td></tr></table>
To test the robustness of causal modelling to previously unseen interventions (new values for an intervened variable), we evaluate a well-trained causal model against a non-causal variant model where all $c _ { i j } = 1 , \ i \neq j$ . In both cases, an intervention is performed, and the models, with knowledge of the intervention, are asked to predict the rest. For this purpose, a batch of samples $X$ are drawn from $D _ { \mathrm { i n t } }$ and their average log-likelihoods are computed and contrasted. The intervention variable’s contribution to the log-likelihood is ignored.
For all 3-variable graphs (chain3, fork3, collider3, confounder3), the causal model attributes higher log-likelihood to the intervention distribution’s samples than the non-causal variant, thereby demonstrating causal models’ superior generalization ability in transfer tasks. Table 2 collects these results.
Importance of Inference After the intervention has been performed, the learner draws data samples from the intervention distribution and computes the per-variable average log-probability under sampled adjacency matrices. The variable consistently producing the least-likely outputs is pre
Table 3: Intervention Prediction Accuracy: (identify on which variable the intervention took place)
<table><tr><td>3 variables</td><td>4 variables</td><td> 5 variables</td><td>8 variables</td></tr><tr><td>95%</td><td>90%</td><td>81%</td><td>63%</td></tr></table>
dicted to be the intervention node. Experiments over all 3-variable DAGs show that this prediction mechanism functions well in practice, yielding far above-random accuracy in correctly predicting the intervention node (Table 3), the model performance dropped significantly without the predication (Figure 6 Left) and is comparable to having the ground-truth intervention (Figure 6 Right).
Effect of DAG Regularizer: To promote the acyclicity of $C$ , we include a DAG regularizer . This significantly improves cross-entropy of the solution (wrt. ground truth DAG) on all 3-variable graphs, as illustrated in Figure 6, and was therefore included in all experiments with $M > 3$ variables.
# 6 CONCLUSION
In this work, we introduced a framework for fast adaptation and slow learning of neural causal models. We demonstrate through experiments that the principle of optimizing an out-of-distribution meta-learning objective enables the learner to recover the causal graph structure for graphs with more than two variables. To achieve this we introduce an efficient parametrization of the belief regarding the underlying graph structure, implemented as an adaptive form of dropout on the inputs of MLPs computing the conditionals of the model. This relies on pre-training the conditionals using agnostic beliefs and by approximately inferring on which variable the intervention took place. We believe that our approach of treating seemingly observational data as being derived from an environment with agents executing interventions could represent an important change in modelling perspective with deeper implications.
# REFERENCES
Yoshua Bengio, Tristan Deleu, Nasim Rahaman, Rosemary Ke, Sébastien Lachapelle, Olexa Bilaniuk, Anirudh Goyal, and Christopher Pal. A meta-transfer objective for learning to disentangle causal mechanisms. arXiv preprint arXiv:1901.10912, 2019.
Kailash Budhathoki and Jilles Vreeken. Causal inference by stochastic complexity. arXiv:1702.06776, 2017.
David Maxwell Chickering. Optimal structure identification with greedy search. Journal of machine learning research, 3(Nov):507–554, 2002.
Gregory F. Cooper and Changwon Yoo. Causal Discovery from a Mixture of Experimental and Observational Data. In Proceedings of the Fifteenth Conference on Uncertainty in Artificial Intelligence, UAI’99, pp. 116–125, San Francisco, CA, USA, 1999.
Povilas Daniusis, Dominik Janzing, Joris Mooij, Jakob Zscheischler, Bastian Steudel, Kun Zhang, and Bernhard Schölkopf. Inferring deterministic causal relations. arXiv preprint arXiv:1203.3475, 2012.
Ishita Dasgupta, Jane Wang, Silvia Chiappa, Jovana Mitrovic, Pedro Ortega, David Raposo, Edward Hughes, Peter Battaglia, Matthew Botvinick, and Zeb Kurth-Nelson. Causal Reasoning from Meta-reinforcement Learning. arXiv preprint arXiv:1901.08162, 2019.
Laura Douglas, Iliyan Zarov, Konstantinos Gourgoulias, Chris Lucas, Chris Hart, Adam Baker, Maneesh Sahani, Yura Perov, and Saurabh Johri. A universal marginalizer for amortized inference in generative models. arXiv preprint arXiv:1711.00695, 2017.
Daniel Eaton and Kevin Murphy. Exact bayesian structure learning from uncertain interventions. In Artificial Intelligence and Statistics, pp. 107–114, 2007a.
Daniel Eaton and Kevin Murphy. Bayesian structure learning using dynamic programming and MCMC. In Uncertainty in Artificial Intelligence, pp. 101–108, 2007b.
Frederick Eberhardt, Clark Glymour, and Richard Scheines. On the number of experiments sufficient and in the worst case necessary to identify all causal relations among n variables. arXiv preprint arXiv:1207.1389, 2012.
Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. In Proceedings of the 34th International Conference on Machine Learning - Volume 70, ICML’17, pp. 1126–1135. JMLR.org, 2017. URL http://dl.acm.org/citation. cfm?id $\underline { { \underline { { \mathbf { \Pi } } } } }$ 3305381.3305498.
AmirEmad Ghassami, Saber Salehkaleybar, Negar Kiyavash, and Kun Zhang. Learning causal structures using regression invariance. In Advances in Neural Information Processing Systems, pp. 3011–3021, 2017.
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.
Olivier Goudet, Diviyan Kalainathan, Philippe Caillou, Isabelle Guyon, David Lopez-Paz, and Michèle Sebag. Causal generative neural networks. arXiv preprint arXiv:1711.08936, 2017.
Olivier Goudet, Diviyan Kalainathan, Philippe Caillou, Isabelle Guyon, David Lopez-Paz, and Michele Sebag. Learning functional causal models with generative neural networks. In Explainable and Interpretable Models in Computer Vision and Machine Learning, pp. 39–80. Springer, 2018.
Isabelle Guyon. Cause-effect pairs kaggle competition, 2013. URL https://www. kaggle. com/c/causeeffect-pairs, pp. 165, a.
Isabelle Guyon. Chalearn fast causation coefficient challenge, 2014. URL https://www. codalab. org/competitions/1381, pp. 165, b.
Alain Hauser and Peter Bühlmann. Characterization and greedy learning of interventional markov equivalence classes of directed acyclic graphs. Journal of Machine Learning Research, 13(Aug): 2409–2464, 2012.
David Heckerman, Dan Geiger, and David M Chickering. Learning bayesian networks: The combination of knowledge and statistical data. Machine learning, 20(3):197–243, 1995.
Christina Heinze-Deml, Marloes H Maathuis, and Nicolai Meinshausen. Causal structure learning. Annual Review of Statistics and Its Application, 5:371–391, 2018.
Geoffrey E Hinton and David C Plaut. Using fast weights to deblur old memories. In Proceedings of the ninth annual conference of the Cognitive Science Society, pp. 177–186, 1987.
Patrik O Hoyer, Dominik Janzing, Joris M Mooij, Jonas Peters, and Bernhard Schölkopf. Nonlinear causal discovery with additive noise models. In Advances in neural information processing systems, pp. 689–696, 2009.
Guido W Imbens and Donald B Rubin. Causal inference in statistics, social, and biomedical sciences. Cambridge University Press, 2015.
Oleg Ivanov, Michael Figurnov, and Dmitry Vetrov. Variational autoencoder with arbitrary conditioning. arXiv preprint arXiv:1806.02382, 2018.
Diviyan Kalainathan, Olivier Goudet, Isabelle Guyon, David Lopez-Paz, and Michèle Sebag. Sam: Structural agnostic model, causal discovery and penalized adversarial learning. arXiv preprint arXiv:1803.04929, 2018.
Kevin B Korb and Ann E Nicholson. Bayesian artificial intelligence. CRC press, 2010.
Steffen L Lauritzen and David J Spiegelhalter. Local computations with probabilities on graphical structures and their application to expert systems. Journal of the Royal Statistical Society: Series B (Methodological), 50(2):157–194, 1988.
Yang Li, Shoaib Akbar, and Junier B Oliva. Flow models for arbitrary conditional likelihoods. arXiv preprint arXiv $^ { \prime } =$ 1909.06319, 2019.
David Lopez-Paz, Krikamol Muandet, Bernhard Schölkopf, and Iliya Tolstikhin. Towards a learning theory of cause-effect inference. In International Conference on Machine Learning, pp. 1452–1461, 2015.
Jovana Mitrovic, Dino Sejdinovic, and Yee Whye Teh. Causal inference via kernel deviance measures. In Advances in Neural Information Processing Systems, pp. 6986–6994, 2018.
Judea Pearl. Causal diagrams for empirical research. Biometrika, 82(4):669–688, 1995.
Judea Pearl. Causality. Cambridge university press, 2009.
Jonas Peters, Peter Bühlmann, and Nicolai Meinshausen. Causal inference by using invariant prediction: identification and confidence intervals. Journal of the Royal Statistical Society: Series $B$ (Statistical Methodology), 78(5):947–1012, 2016.
Jonas Peters, Dominik Janzing, and Bernhard Schölkopf. Elements of causal inference: foundations and learning algorithms. MIT press, 2017.
Dominik Rothenhäusler, Christina Heinze, Jonas Peters, and Nicolai Meinshausen. Backshift: Learning causal cyclic graphs from unknown shift interventions. In Advances in Neural Information Processing Systems, pp. 1513–1521, 2015.
Bernhard Schölkopf, Dominik Janzing, Jonas Peters, Eleni Sgouritsa, Kun Zhang, and Joris Mooij. On causal and anticausal learning. arXiv preprint arXiv:1206.6471, 2012.
Rajen D Shah and Jonas Peters. The hardness of conditional independence testing and the generalised covariance measure. arXiv preprint arXiv:1804.07203, 2018.
Shohei Shimizu, Patrik O Hoyer, Aapo Hyvärinen, and Antti Kerminen. A linear non-gaussian acyclic model for causal discovery. Journal of Machine Learning Research, 7(Oct):2003–2030, 2006.
Peter Spirtes, Clark N Glymour, Richard Scheines, David Heckerman, Christopher Meek, Gregory Cooper, and Thomas Richardson. Causation, prediction, and search. MIT press, 2000.
Xiaohai Sun, Dominik Janzing, Bernhard Schölkopf, and Kenji Fukumizu. A kernel-based causal learning algorithm. In Proceedings of the 24th international conference on Machine learning, pp. 855–862. ACM, 2007.
Ioannis Tsamardinos, Laura E Brown, and Constantin F Aliferis. The max-min hill-climbing bayesian network structure learning algorithm. Machine learning, 65(1):31–78, 2006.
Jinsung Yoon, James Jordon, and Mihaela Van Der Schaar. Gain: Missing data imputation using generative adversarial nets. arXiv preprint arXiv:1806.02920, 2018.
Kun Zhang, Jonas Peters, Dominik Janzing, and Bernhard Schölkopf. Kernel-based conditional independence test and application in causal discovery. arXiv preprint arXiv:1202.3775, 2012.
Xun Zheng, Bryon Aragam, Pradeep K Ravikumar, and Eric P Xing. Dags with no tears: Continuous optimization for structure learning. In Advances in Neural Information Processing Systems, pp. 9472–9483, 2018.
# A APPENDIX
A.1 DAG PENALTY DERIVATION
Recall, from Zheng et al. (2018):
Theorem 1. A matrix $W \in \mathbb { R } ^ { d \times d }$ is a DAG if and only if
$$h ( \boldsymbol { W } ) = \mathrm { T r } ( e ^ { \boldsymbol { W } \circ \boldsymbol { W } } ) - d = 0$$
For the two-variable $\ Q = 2$ ) graph with adjacency matrix
$$W = \left( \begin{array} { c c } { { 0 } } & { { \sigma ( w _ { 1 2 } ) } } \\ { { \sigma ( w _ { 2 1 } ) } } & { { 0 } } \end{array} \right)$$
we have
$$\begin{array} { c } { { \displaystyle \mathrm { T r } ( \exp ( { \cal A } ) ) = \mathrm { T r } \sum _ { n = 0 } ^ { \infty } \frac { { \cal A } ^ { n } } { n ! } } } \\ { { \displaystyle \mathrm { T r } ( \exp ( W \circ W ) ) = \mathrm { T r } \sum _ { n = 0 } ^ { \infty } \frac { 1 } { n ! } \left( \begin{array} { c c } { { 0 } } & { { \sigma ^ { 2 } ( w _ { 1 2 } ) } } \\ { { \sigma ^ { 2 } ( w _ { 2 1 } ) } } & { { 0 } } \end{array} \right) ^ { n } } } \end{array}$$
There can only be even- or odd-length paths in a graph. Because, in a two-variable graph with no self-edges, all even-length paths are cycles and none of the odd-length paths are, we have
$$\begin{array} { r l } & { = \underbrace { \mathbb { T } \sum _ { k = 0 } ^ { \infty } \frac { 1 } { ( 2 k ) ! } \left( \begin{array} { c c } { 0 } & { \sigma ^ { 2 } \left( w _ { 1 : 2 } \right) } \\ { \sigma ^ { 2 } \left( w _ { 2 : 1 } \right) } & { 0 } \end{array} \right) ^ { 2 k } } _ { \mathrm { E v e n } , \ \Gamma \to 0 } } \\ & { + \underbrace { \mathbb { T } \sum _ { k = 0 } ^ { \infty } \frac { 1 } { ( 2 k ) ! } \left( \hdots \sigma ^ { 2 } \left( w _ { 2 : 1 } \right) - \sigma ^ { 2 } \left( w _ { 1 : 2 } \right) - \sigma ^ { 2 k + \Gamma } \right) } _ { \mathrm { d a t a } , \ \Gamma = 0 } } \\ & { = \mathbb { T } \sum _ { k = 0 } ^ { \infty } \frac { 1 } { ( 2 k ) ! } \left( \begin{array} { c c } { \sigma ^ { 2 } \left( w _ { 1 : 2 } \right) \sigma ^ { 2 } \left( w _ { 2 : 1 } \right) } & { 0 } \\ { 0 } & { 0 } \end{array} \right) ^ { 2 } } \\ & { = 2 \underbrace { \sum _ { k = 0 } ^ { \infty } \frac { \sigma ^ { 2 k } \left( w _ { 1 : 2 } \right) \sigma ^ { 2 k } \left( w _ { 2 : 1 } \right) } { ( 2 k ) ! } } _ { \mathrm { k } = 0 } \mathcal { L } } \\ & { = \exp \left( \frac { \sigma ^ { 2 } w _ { 1 : 1 } \left( w _ { 1 : 2 } \right) \sigma ^ { 2 k } \left( w _ { 2 : 1 } \right) } { ( 2 k ) ! } \right. } \end{array}$$
A pairwise generalization to multinode graphs over all $i \neq j$ is:
$$J _ { \mathrm { D A G } } = \sum _ { i \neq j } \cosh ( \sigma ( w _ { i j } ) \sigma ( w _ { j i } ) )$$
# A.2 TRAINING ALGORITHM
In this section, we describe the training algorithm in detail.
<table><tr><td colspan="2">Algorithm1Training Algorithm</td></tr><tr><td colspan="2">1: procedure TRAINING(Categorical Distribution D,with M nodes and N categories) Let ian integer from O to M-1</td></tr><tr><td>2: 34</td><td></td></tr><tr><td></td><td>for kpretrain steps do</td></tr><tr><td>5:</td><td>x~D</td></tr><tr><td>6:</td><td>c ~ Ber(σ(γ))</td></tr><tr><td>7: 8:</td><td>L = -log P(xlc) > Compute log-probability of data given config</td></tr><tr><td></td><td>0slow ←Adam(0slow,VL)</td></tr><tr><td>9: for kintervention steps do</td><td></td></tr><tr><td>10:</td><td>I_N←randint(O,M-1)</td></tr><tr><td>11:</td><td>Dint := D with intervention on node I_N</td></tr><tr><td>12:</td><td>if predicting intervention then</td></tr><tr><td>13:</td><td>Li←O∀i</td></tr><tr><td>14:</td><td>for Kpredict steps do</td></tr><tr><td>15:</td><td>x~Dint</td></tr><tr><td>16:</td><td>c ~ Ber(σ(γ))</td></tr><tr><td>17: 18:</td><td>Li←Li+-logPi(xlci;Oslow)∀i</td></tr><tr><td></td><td>>Accumulate NLL for every node i separately I_N←argmax(Li)</td></tr><tr><td></td><td></td></tr><tr><td>19: 20:</td><td>gammagrads,logregrets =[],[] >Transfer Episode Adaptation Loop</td></tr><tr><td>21:</td><td>for Kepisode steps do x~Dint</td></tr><tr><td>22:</td><td>gammagrad,logregret = 0,0</td></tr><tr><td>23:</td><td>for kcfg steps do</td></tr><tr><td>24:</td><td>c ~ Ber(σ(γ))</td></tr><tr><td>25:</td><td>Li=-log Pi(xlci;0slow)∀i</td></tr><tr><td>26:</td><td>gammagrad += σ(γ)-c</td></tr><tr><td>27:</td><td>logregret += ∑ Li</td></tr><tr><td>28:</td><td>I_N</td></tr><tr><td>29:</td><td>gammagrads.append(gammagrad) logregrets.append(logregret)</td></tr><tr><td></td><td></td></tr><tr><td>30:</td><td>J ←入MaxEnt LMaxEnt(γ)+ 入sparse LSparse(γ)+ 入DAG LDAG(γ)</td></tr><tr><td>31:</td><td>Vγ←VγJ+∑gammagradskijlogregrets.softmax(0) ki</td></tr><tr><td>32:</td><td>k γ ← Adam(γ,∀γ)</td></tr></table>
# A.3 PRELIMINARIES
Interventions In a purely-observational setting, it is known that causal graphs can be distinguished only up to a Markov equivalence class. In order to identify the true causal graph intervention data is needed (Eberhardt et al., 2012). Several types of common interventions may be available (Eaton & Murphy, 2007a). These are: No intervention: only observational data is obtained from the ground truth causal model. Hard/perfect: the value of a single or several variables is fixed and then ancestral sampling is performed on the other variables. Soft/imperfect: the conditional distribution of the variable on which the intervention is performed is changed. Uncertain: the learner is not sure of which variable exactly the intervention affected directly. Here we make use of soft interventions for several reasons: First, they include hard interventions as a limiting case and hence are more general. Second, in many real-world scenarios, it is more difficult to perform a hard intervention compared to a soft one. We also deal with a special case of uncertain interventions, where the variable selected for intervention is random and unknown. We call these unidentified or unknown interventions.
Causal sufficiency The inability to distinguish which causal graph, within a Markov equivalence class, is the correct one in the purely-observational setting is called the identifiability problem. In our setting, all variables are observed (there are no latent confounders) and all interventions are random and independent. Hence, within our setting the true causal graph is always identifiable in principle (Eberhardt et al., 2012; Heinze-Deml et al., 2018). We consider here situations where a single variable is randomly selected and intervened upon with a soft or imprecise intervention, its identity is unknown and must be inferred.
# A.4 EXPERIMENTAL SETUP
For all datasets, the weight parameters for the learned model is initialized randomly. In order to not bias the structural parameters, all $\gamma$ is initialized to 0.5 in the beginning of training.
# A.5 SYNTHETIC DATA
SCM with $n$ variables is modeled by $n$ feedforward neural networks (MLPs) as described in section 3.1. For simplicity, we assume use an acyclic causal graph such that we could easily sample from it. Hence, given any pair of random variables $A$ and $B$ , either $A B$ , $B A$ or $A$ and $B$ are independent.
The MLP representing the ground-truth SCM has its weights $\theta$ initialized use orthogonal initialization with gain 2.5 and the biases are initialized using a uniform initialization between $- 1 . 1$ and 1.1, which was empirically found to yield "interesting" yet learnable random SCMs.
 Figure 7: Left: Every possible 3-variable connected DAG. Right: Cross entropy for edge probability between learned and ground-truth SCM for all 3-variable SCMs.
# A.5.1 BNLEARN DATA REPOSITORY
The repo contains many datasets with various sizes and structures modeling different variables. We evaluate our model on 3 of the datasets in the repo, namely the Earthquake (Korb & Nicholson, 2010), Cancer (Korb & Nicholson, 2010) and Asia (Lauritzen & Spiegelhalter, 1988) datasets. The ground-truth model structure for the Cancer (Korb & Nicholson, 2010) and Earthquake (Korb & Nicholson, 2010) datasets are shown in Figure 8. Note that even though the structure for the 2 datasets seems to be the same, the conditional probability tables (CPTs) for these 2 datasets are very different and hence results in different structured causal models (SCMs) for the 2 datasets.
 Figure 8: Left: Ground Truth SCM for Cancer. Middle: Groundtruth SCM for Earthquake. Right: Groundtruth SCM for Asia.
# A.5.2 TRAINING GROUND-TRUTH DATA GENERATOR
Because a CPT is capable of representing any distribution, and MLPs are strictly less powerful in this respect, it may not be possible to learn perfectly the distribution with our MLP learner model. We therefore train a near-ground-truth MLP to replicate as closely as possible the CPT’s probability table, and then use this trained MLP are the ground-truth SCM data generator.
Training is by 1000 iterations of full-batch gradient descent with learning rate 0.001 and momentum 0.9, with all possible parent values masked with the ground-truth vector $\gamma _ { i }$ . The objective is to minimize mean squared error between the MLP’s logits and the log-probability as drawn from the CPT. If the CPT contains a zero, it is approximated by a logit of $- 1 0 0$ .
Given that some of the CPTs contain very unlikely events, we have found it necessary to add a temperature parameter in order to make them more frequent. The near-ground-truth MLP model’s logit outputs are divided by the temperature before being used for sampling. Temperatures above 1 result in more uniform distributions for all causal variables; Temperatures below 1 result in less uniform, sharper distributions that peak around the most likely value. We find empirically that a temperature of about 2 is required for our BnLearn benchmarks.
# A.6 EFFECT OF SPARSITY
We use a $L 1$ regularizer on the structure parameters $\gamma$ to encourage a sparse representation of edges in the causal graph. In order to better understand the effect of the $L 1$ regularizer, we conducted ablation studies on the $L 1$ regularizer. It seems that the regularizer has an small effect on rate of converges and that the model converges faster with the regularizer. This is shown in Figure 9
 Figure 9: Effect of Sparsity: On 5 variable, 6 variable and 8 variable Nodes
# A.7 EFFECT OF TEMPERATURE
As noted in section A.5.1, we have introduced a temperature hyperparameter in order to encourage the groundtruth model to generate some very rare events in the conditional probability tables (CPTs) more frequently. We run ablation studies to understand the importance of the temperature term. A temperature of 1 corresponds to no changes to the underlying CPTs. As shown in Figure 12, for the Cancer (Korb & Nicholson, 2010) dataset, a temperature of 2 improves the accuracy of causal graph recovery.
 Figure 10: Cross entropy for edge probability between learned and ground-truth SCM for Cancer at varying temperatures.
 Figure 11: Cross entropy for edge probability between learned and ground-truth SCM. Left: The Earthquake dataset with 6 variables. Right: The Asia dataset with 8 variables
 Figure 12: Left: SCM for cross5 graph. Right: Cross entropy for edge probability between learned and ground-truth SCM for chain5 and cross5, comparing the learning process with prediction of edges to ground-truth intervention123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335# PREDICTING THE GENERALIZATION GAP IN DEEP NETWORKS WITH MARGIN DISTRIBUTIONS
Yiding Jiang ∗, Dilip Krishnan, Hossein Mobahi, Samy Bengio Google AI {ydjiang, dilipkay, hmobahi, bengio}@google.com
# ABSTRACT
Recent research has demonstrated that deep neural networks can perfectly fit randomly labeled data, but with very poor accuracy on held out data. This phenomenon indicates that loss functions such as cross-entropy are not a reliable indicator of generalization. This leads to the crucial question of how generalization gap can be predicted from training data and network parameters. In this paper, we propose such a measure, and conduct extensive empirical studies on how well it can predict the generalization gap. Our measure is based on the concept of margin distribution, which are the distances of training points to the decision boundary. We find that it is necessary to use margin distributions at multiple layers of a deep network. On the CIFAR-10 and the CIFAR-100 datasets, our proposed measure correlates very strongly with the generalization gap. In addition, we find the following other factors to be of importance: normalizing margin values for scale independence, using characterizations of margin distribution rather than just the margin (closest distance to decision boundary), and working in log space instead of linear space (effectively using a product of margins rather than a sum). Our measure can be easily applied to feedforward deep networks with any architecture and may point towards new training loss functions that could enable better generalization.
# 1 INTRODUCTION
Generalization, the ability of a classifier to perform well on unseen examples, is a desideratum for progress towards real-world deployment of deep neural networks in domains such as autonomous cars and healthcare. Until recently, it was commonly believed that deep networks generalize well to unseen examples. This was based on empirical evidence about performance on held-out dataset. However, new research has started to question this assumption. Adversarial examples cause networks to misclassify even slightly perturbed images at very high rates (Goodfellow et al., 2014; Papernot et al., 2016). In addition, deep networks can overfit to arbitrarily corrupted data (Zhang et al., 2016), and they are sensitive to small geometric transformations (Azulay & Weiss, 2018; Engstrom et al., 2017). These results have led to the important question about how the generalization gap (difference between train and test accuracy) of a deep network can be predicted using the training data and network parameters. Since in all of the above cases, the training loss is usually very small, it is clear that existing losses such as cross-entropy cannot serve that purpose. It has also been shown (e.g. in Zhang et al. (2016)) that regularizers such as weight decay cannot solve this problem either.
Consequently, a number of recent works (Neyshabur et al., 2017b; Kawaguchi et al., 2017; Bartlett et al., 2017; Poggio et al., 2017; Arora et al., 2018) have started to address this question, proposing generalization bounds based on analyses of network complexity or noise stability properties. However, a thorough empirical assessment of these bounds in terms of how accurately they can predict the generalization gap across various practical settings is not yet available.
In this work, we propose a new quantity for predicting generalization gap of a feedforward neural network. Using the notion of margin in support vector machines (Vapnik, 1995) and extension to deep networks (Elsayed et al., 2018), we develop a measure that shows a strong correlation with generalization gap and significantly outperforms recently developed theoretical bounds on generalization2. This is empirically shown by studying a wide range of deep networks trained on the CIFAR-10 and CIFAR-100 datasets. The measure presented in this paper may be useful for a constructing new loss functions with better generalization. Besides improvement in the prediction of the generalization gap, our work is distinct from recently developed bounds and margin definitions in a number of ways:
 Figure 1: (Best seen as PDF) Density plots (top) and box plots (bottom) of normalized margin of three convolutional networks trained with cross-entropy loss on CIFAR-10 with varying test accuracy: left: $5 5 . 2 \%$ , middle: $7 0 . 6 \%$ , right: $8 5 . 1 \%$ . The left network was trained with $20 \%$ corrupted labels. Train accuracy of all above networks are close to $100 \%$ , and training losses close to zero. The densities and box plots are computed on the training set. Normalized margin distributions are strongly correlated with test accuracy (moving to the right as accuracy increases). This motivates our use of normalized margins at all layers. The (Tukey) box plots show the median and other order statistics (see section 3.2 for details), and motivates their use as features to summarize the distributions.
1. These recently developed bounds are typically functions of weight norms (such as the spectral, Frobenius or various mixed norms). Consequently, they cannot capture variations in network topology that are not reflected in the weight norms, e.g. adding residual connections (He et al., 2016) without careful additional engineering based on the topology changes. Furthermore, some of the bounds require specific treatment for nonlinear activations. Our proposed measure can handle any feedforward deep network. 2. Although some of these bounds involve margin, the margin is only defined and measured at the output layer (Bartlett et al., 2017; Neyshabur et al., 2017b). For a deep network, however, margin can be defined at any layer (Elsayed et al., 2018). We show that measuring margin at a single layer does not suffice to capture generalization gap. We argue that it is crucial to use margin information across layers and show that this significantly improves generalization gap prediction. 3. The common definition of margin, as used in the recent bounds e.g. Neyshabur et al. (2017b), or as extended to deep networks, is based on the closest distance of the training points to the decision boundary. However, this notion is brittle and sensitive to outliers. In contrast, we adopt margin distribution (Garg et al., 2002; Langford & Shawe-Taylor, 2002; Zhang & Zhou, 2017; 2018) by looking at the entire distribution of distances. This is shown to have far better prediction power.
4. We argue that the direct extension of margin definition to deep networks (Elsayed et al., 2018), although allowing margin to be defined on all layers of the model, is unable to capture
generalization gap without proper normalization. We propose a simple normalization scheme that significantly boosts prediction accuracy.
# 2 RELATED WORK
The recent seminal work of Zhang et al. (2016) has brought into focus the question of how generalization can be measured from training data. They showed that deep networks can easily learn to fit randomly labeled data with extremely high accuracy, but with arbitrarily low generalization capability. This overfitting is not countered by deploying commonly used regularizers. The work of Bartlett et al. (2017) proposes a measure based on the ratio of two quantities: the margin distribution measured at the output layer of the network; and a spectral complexity measure related to the network’s Lipschitz constant. Their normalized margin distribution provides a strong indication of the complexity of the learning task, e.g. the distribution is skewed towards the origin (lower normalized margin) for training with random labels. Neyshabur et al. (2017b;a) also develop bounds based on the product of norms of the weights across layers. Arora et al. (2018) develop bounds based on noise stability properties of networks: more stability implies better generalization. Using these criteria, they are able to derive stronger generalization bounds than previous works.
The margin distribution (specifically, boosting of margins across the training set) has been shown to correspond to generalization properties in the literature on linear models (Schapire et al., 1998): they used this connection to explain the effectiveness of boosting and bagging techniques. Reyzin & Schapire (2006) showed that it was important to control the complexity of a classifier when measuring margin, which calls for some type of normalization. In the linear case (SVM), margin is naturally defined as a function of norm of the weights Vapnik (1995). In the case of deep networks, true margin is intractable. Recent work (Elsayed et al., 2018) proposed a linearization to approximate the margin, and defined the margin at any layer of the network. (Sokolic et al., 2016) provide another approximation to the margin based on the norm of the Jacobian with respect to the input layer. They show that maximizing their approximations to the margin leads to improved generalization. However, their analysis was restricted to margin at the input layer. Poggio et al. (2017) and Liao et al. (2018) propose a normalized cross-entropy measure that correlates well with test loss. Their proposed normalized loss trades off confidence of predictions with stability, which leads to better correlation with test accuracy, leading to a significant lowering of output margin.
# 3 PREDICTION OF GENERALIZATION GAP
In this section, we introduce our margin-based measure. We first explain the construction scheme for obtaining the margin distribution. We then squeeze the distributional information of the margin to a small number of statistics. Finally, we regress these statistics to the value of the generalization gap. We assess prediction quality by applying the learned regression coefficients to predict the generalization gap of unseen models. We will start with providing a motivation for using the margins at the hidden layers which is supported by our empirical findings. SVM owes a large part of its success to the kernel that allows for inner product in a higher and richer feature space. At its crux, the primal kernel SVM problem is separated into the feature extractor and the classifier on the extracted features. We can separate any feed forward network at any given hidden layer and treat the hidden representation as a feature map. From this view, the layers that precede this hidden layer can be treated as a learned feature extractor and then the layers that come after are naturally the classifier. If the margins at the input layers or the output layers play important roles in generalization of the classifier, it is a natural conjecture that the margins at these hidden representations are also important in generalization. In fact, if we ignore the optimization procedure and focus on a converged network, generalization theories developed on the input such as Lv et al. (2019) can be easily extended to the hidden layers or the extracted features.
# 3.1 MARGIN APPROXIMATION
First, we establish some notation. Consider a classification problem with $n$ classes. We assume a classifier $f$ consists of non-linear functions $f _ { i } : \mathcal { X } \mathbb { R }$ , for $i = 1 , \ldots , n$ that generate a prediction score for classifying the input vector $\mathbf { \boldsymbol { x } } \in \mathcal { X }$ to class $i$ . The predicted label is decided by the class with maximal score, i.e. $i ^ { * } = \arg \operatorname* { m a x } _ { i } f _ { i } ( \pmb { x } _ { }$ . Define the decision boundary for each class pair $( i , j )$
as:
$${ \mathcal { D } } _ { ( i , j ) } \triangleq \{ { \pmb x } | f _ { i } ( { \pmb x } ) = f _ { j } ( { \pmb x } ) \}$$
Under this definition, the $l _ { p }$ distance of a point $_ { \textbf { \em x } }$ to the decision boundary $\mathcal { D } _ { ( i , j ) }$ can be expressed as the smallest displacement of the point that results in a score tie:
$$d _ { f , \pmb { x } , ( i , j ) } \triangleq \operatorname* { m i n } _ { \pmb { \delta } } \| \pmb { \delta } \| _ { p } \quad \mathrm { s . t . } \quad f _ { i } ( \pmb { x } + \pmb { \delta } ) = f _ { j } ( \pmb { x } + \pmb { \delta } )$$
Unlike an SVM, computing the “exact” distance of a point to the decision boundary (Eq. 2) for a deep network is intractable3. In this work, we adopt the approximation scheme from Elsayed et al. (2018) to capture the distance of a point to the decision boundary. This a first-order Taylor approximation to the true distance Eq. 2. Formally, given an input $_ { \textbf { \em x } }$ to a network, denote its representation at the $l ^ { t h }$ layer (the layer activation vector) by $\mathbf { \Delta } _ { \mathbf { \boldsymbol { x } } } l$ . For the input layer, let $l = 0$ and thus $\mathbf { x } ^ { 0 } = \pmb { x }$ . Then for $p = 2$ , the distance of the representation vector $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } } l$ to the decision boundary for class pair $( i , j )$ is given by the following approximation:
$$d _ { f , ( i , j ) } ( \pmb { x } ^ { l } ) = \frac { f _ { i } ( \pmb { x } ^ { l } ) - f _ { j } ( \pmb { x } ^ { l } ) } { \| \nabla _ { \pmb { x } ^ { l } } f _ { i } ( \pmb { x } ^ { l } ) - \nabla _ { \pmb { x } ^ { l } } f _ { j } ( \pmb { x } ^ { l } ) \| _ { 2 } }$$
Here $f _ { i } ( { \pmb x } ^ { l } )$ represents the output (logit) of the network logit $i$ given $\mathbf { \Delta } _ { \mathbf { \boldsymbol { x } } } l$ . Note that this distance can be positive or negative, denoting whether the training sample is on the “correct” or “wrong” side of the decision boundary respectively. This distance is well defined for all $( i , j )$ pairs, but in this work we assume that $i$ always refers to the ground truth label and $j$ refers to the second highest or highest class (if the point is misclassified). The training data $_ { \textbf { \em x } }$ induces a distribution of distances at each layer $l$ which, following earlier naming convention (Garg et al., 2002; Langford $\&$ Shawe-Taylor, 2002), we refer to as margin distribution (at layer $l$ ). For margin distribution, we only consider distances with positive sign (we ignore all misclassified training points). Such design choice facilitates our empirical analysis when we transform our features (e.g. log transform); further, it has also been suggested that it may be possible to obtain a better generalization bound by only considering the correct examples when the classifier classifies a significant proportion of the training examples correctly, which is usually the case for neural networks (Bartlett, 1998). For completeness, the results with negative margins are included in appendix Sec. 7.
A problem with plain distances and their associated distribution is that they can be trivially boosted without any significant change in the way classifier separates the classes. For example, consider multiplying weights at a layer by a constant and dividing weights in the following layer by the same constant. In a ReLU network, due to positive homogeneity property (Liao et al., 2018), this operation does not affect how the network classifies a point, but it changes the distances to the decision boundary4. To offset the scaling effect, we normalize the margin distribution. Consider margin distribution at some layer $l$ , and let $\mathbf { \Delta } _ { \mathbf { \boldsymbol { x } } _ { k } ^ { l } }$ be the representation vector for training sample $k$ . We compute the variance of each coordinate of $\{ \pmb { x } _ { k } ^ { l } \}$ separately, and then sum these individual variances. This quantity is called total variation of $\mathbf { \Delta } _ { \mathbf { \boldsymbol { x } } } l$ . The square root of this quantity relates to the scale of the distribution. That is, if $\mathbf { \Delta } _ { \mathbf { \boldsymbol { x } } } l$ is scaled by a factor, so is the square root of the total variation. Thus, by dividing distances by the square root of total variation, we can construct a margin distribution invariant to scaling. More concretely, the total variation is computed as:
$$\nu ( { \pmb x } ^ { l } ) = \mathrm { t r } \Big ( \frac { 1 } { n } \sum _ { k = 1 } ^ { n } ( { \pmb x } _ { k } ^ { l } - \bar { { \pmb x } } ^ { l } ) ( { \pmb x } _ { k } ^ { l } - \bar { { \pmb x } } ^ { l } ) ^ { T } \Big ) \quad , \quad \bar { { \pmb x } } ^ { l } = \frac { 1 } { n } \sum _ { k = 1 } ^ { n } { \pmb x } _ { k } ^ { l } ,$$
i.e. the trace of the empirical covariance matrix of activations. Using the total variation, the normalized margin is specified by:
$$\hat { d } _ { f , ( i , j ) } ( \pmb { x } _ { k } ^ { l } ) = \frac { d _ { f , ( i , j ) } ( \pmb { x } _ { k } ^ { l } ) } { \sqrt { \nu ( \pmb { x } ^ { l } ) } }$$
While the quantity is relatively primitive and easy to compute, Fig. 1 (top) shows that the normalizedmargin distributions based on Eq. 5 have the desirable effect of becoming heavier tailed and shifting
to the right (increasing margin) as generalization gap decreases. We find that this effect holds across a range of networks trained with different hyper-parameters.
# 3.2 SUMMARIZING THE MARGIN DISTRIBUTION
Instead of working directly with the (normalized) margin distribution, it is easier to analyze a compact signature of that. The moments of a distribution are a natural criterion for this purpose. Perhaps the most standard way of doing this is computing the empirical moments from the samples and then take the $n ^ { t h }$ root of the $n ^ { t h }$ moment. In our experiments, we used the first five moments. However, it is a well-known phenomenon that the estimation of higher order moments based on samples can be unreliable. Therefore, we also consider an alternate way to construct the distribution’s signature. Given a set of distances $\mathcal { D } = \{ \hat { d } _ { m } \} _ { m = 1 } ^ { n }$ , which constitute the margin distribution. We use the median $Q _ { 2 }$ , first quartile $Q _ { 1 }$ and third quartile $Q _ { 3 }$ of the normalized margin distribution, along with the two fences that indicate variability outside the upper and lower quartiles. There are many variations for fences, but in this work, with $I Q R = Q _ { 3 } - Q _ { 1 }$ , we define the upper fence to be $\operatorname* { m a x } ( \{ \hat { d } _ { m } : \hat { d } _ { m } \in$ ${ \mathcal { D } } \wedge { \hat { d } } _ { m } \leq Q _ { 3 } + 1 . 5 I Q R \} ,$ ) and the lower fence to be $\operatorname* { m i n } ( \{ \hat { d } _ { m } : \hat { d } _ { m } \in \mathcal { D } \wedge \hat { d } _ { m } \geq Q _ { 1 } - 1 . 5 I Q R \} )$ (McGill et al., 1978). These 5 statistics form the quartile description that summarizes the normalized margin distribution at a specific layer, as shown in the box plots of Fig. 1. We will later see that both signature representations are able to predict the generalization gap, with the second signature working slightly better.
A number of prior works such as Bartlett et al. (2017), Neyshabur et al. (2017b), Liu et al. (2016), Sun et al. (2015), Sokolic et al. (2016), and Liang et al. (2017) have focused on analyzing or maximizing the margin at either the input or the output layer of a deep network. Since a deep network has many hidden layers with evolving representations, it is not immediately clear which of the layer margins is of importance for improving generalization. Our experiments reveal that margin distribution from all of the layers of the network contribute to prediction of generalization gap. This is also clear from Fig. 1 (top): comparing the input layer (layer 0) margin distributions between the left and right plots, the input layer distribution shifts slightly left, but the other layer distributions shift the other way. For example, if we use quartile signature, we have $5 L$ components in this vector, where $L$ is the total number of layers in the network. We incorporate dependence on all layers simply by concatenating margin signatures of all layers into a single combined vector $\pmb { \theta }$ that we refer to as total signature. Empirically, we found constructing the total signature based on four evenly-spaced layers (input, and 3 hidden layers) sufficiently captures the variation in the distributions and generalization gap, and also makes the signature agnostic to the depth of the network.
# 3.3 EVALUATION METRICS
Our goal is to predict the generalization gap, i.e. the difference between training and test accuracy at the end of training, based on total signature $\pmb \theta$ of a trained model. We use the simplest prediction model, i.e. a linear form $\hat { \boldsymbol g } = \pmb { a } ^ { T } \phi ( \pmb \theta ) + \boldsymbol b$ , where $\pmb { a } \in \mathbb { R } ^ { \mathrm { d i m } ( \pmb { \theta } ) }$ and $b \in \mathbb { R }$ are parameters of the predictor, and $\phi : \mathbb { R } \mathbb { R }$ is a function applied element-wise to $\pmb { \theta }$ . Specifically, we will explore two choices of $\phi$ : the identity $\phi ( x ) = x$ and entry-wise log transform $\phi ( x ) = \log ( x )$ , which correspond to additive and multiplicative combination of margin statistics respectively. We do not claim this model is the true relation, but rather it is a simple model for prediction; and our results suggest that it is a surprisingly good approximation.
In order to estimate predictor parameters $a , b$ , we generate a pool of $n$ pretrained models (covering different datasets, architectures, regularization schemes, etc. as explained in Sec. 4) each of which gives one instance of the pair $\theta , g$ $\boldsymbol { \mathscr { g } }$ being the generalization gap for that model). We then find $\mathbf { \delta } _ { \mathbf { \alpha } ^ { a , b } }$ by minimizing mean squared error: $\begin{array} { r } { ( { \pmb a } ^ { * } , { \pmb b } ^ { * } ) = \arg \operatorname* { m i n } _ { { \pmb a } , { \boldsymbol b } } \sum _ { i } \left( { \pmb a } ^ { T } \phi ( { \pmb \theta } _ { i } ) + { \boldsymbol b } - g _ { i } \right) ^ { 2 } } \end{array}$ , where $i$ indexes the $i ^ { t h }$ model in the pool. The next step is to assess the prediction quality. We consider two metrics for this. The first metric examines quality of predictions on unseen models. For that, we consider a held-out pool of $m$ models, different from those used to estimate $( a , b )$ , and compute the value of $\hat { g }$ on them via $\hat { g } = { \pmb a } ^ { T } \phi ( { \pmb \theta } ) + b$ . In order to quantify the discrepancy between predicted gap $\hat { g }$ and ground truth gap $g$ we use the notion of coefficient of determination $\dot { ( R ^ { 2 } ) }$ (Glantz et al., 1990):
$$R ^ { 2 } = 1 - \frac { \sum _ { j = 1 } ^ { n } ( \hat { g } _ { j } - g _ { j } ) ^ { 2 } } { \sum _ { j = 1 } ^ { n } ( g _ { j } - \frac { 1 } { n } \sum _ { j = 1 } ^ { n } g _ { j } ) ^ { 2 } }$$
$R ^ { 2 }$ measures what fraction of data variance can be explained by the linear model5 (it ranges from 0 to 1 on training points but can be outside that range on unseen points). To be precise, we use $\mathbf { k }$ -fold validation to study how the predictor can perform on held out pool of trained deep networks. We use 90/10 split, fit the linear model with the training pool, and measure $R ^ { 2 }$ on the held out pool. The performance is averaged over the 10 splits. Since $\bar { R ^ { 2 } }$ is now not measured on the training pool, it does not suffer from high data dimension and can be negative. In all of our experiments, we use $k = 1 0$ . We provide a subset of residual plots and corresponding univariate F-Test for the experiments in the appendix (Sec. 8). The F-score also indicates how important each individual variable is. The second metric examines how well the model fits based on the provided training pool; it does not require a test pool. To characterize this, we use adjusted $\bar { R } ^ { 2 }$ (Glantz et al., 1990) defined as:
$$\bar { R } ^ { 2 } = 1 - ( 1 - R ^ { 2 } ) \frac { n - 1 } { n - \mathrm { d i m } ( \theta ) - 1 } .$$
The $\bar { R } ^ { 2 }$ can be negative when the data is non-linear. Note that $\bar { R } ^ { 2 }$ is always smaller than $R ^ { 2 }$ . Intuitively, $\bar { R } ^ { 2 }$ penalizes the model if the number of features is high relative to the available data points. The closer $\bar { R } ^ { 2 }$ is to 1, the better the model fits. Using $\bar { R } ^ { 2 }$ is a simple yet effective method to test the fitness of linear model and is independent of the scale of the target, making it a more illustrative metric than residuals.
# 4 EXPERIMENTS
We tested our measure of generalization gap $\hat { g }$ , along with baseline measures, on a number of deep networks and architectures: nine-layer convolutional networks on CIFAR-10 (10 with input layer), and 32-layer residual networks on both CIFAR-10 and CIFAR-100 datasets. The trained models and relevant Tensorflow Abadi et al. (2016) code to compute margin distributions are released at https://github.com/google-research/google-research/tree/master/demogen
# 4.1 CONVOLUTIONAL NEURAL NETWORKS ON CIFAR-10
Using the CIFAR-10 dataset, we train 216 nine-layer convolutional networks with different settings of hyperparameters and training techniques. We apply weight decay and dropout with different strengths; we use networks with and without batch norm and data augmentation; we change the number of hidden units in the hidden layers. Finally, we also include training with and without corrupted labels, as introduced in Zhang et al. (2016); we use a fixed amount of $2 0 \%$ corruption of the true labels. The accuracy on the test set ranges from $6 0 \%$ to $9 0 . 5 \%$ and the generalization gap ranges from $1 \%$ to $3 5 \%$ . In standard settings, creating neural network models with small generalization gap is difficult; in order to create sufficiently diverse generalization behaviors, we limit some models’ capacities by large weight regularization which decreases generalization gap by lowering the training accuracy. All networks are trained by SGD with momentum. Further details are provided in the supplementary material (Sec. 6).
For each trained network, we compute the depth-agnostic signature of the normalized margin distribution (see Sec. 3). This results in a 20-dimensional signature vector. We estimate the parameters of the linear predictor $( a , b )$ with the log transform $\phi ( x ) \bar { { } } = \log ( x )$ and using the 20-dimensional signature vector $\pmb \theta$ . Fig. 2 (left) shows the resulting scatter plot of the predicted generalization gap $\hat { g }$ and the true generalization gap $g$ . As it can be seen, it is very close to being linear across the range of generalization gaps, and this is also supported by the $\bar { R } ^ { 2 }$ of the model, which is 0.96 (max is 1).
As a first baseline method, we compare against the work of Bartlett et al. (2017) which provides one of the best generalization bounds currently known for deep networks. This work also constructs a margin distribution for the network, but in a different way. To make a fair comparison, we extract the same signature $\pmb { \theta }$ from their margin distribution. Since their margin distribution can only be defined for the output layer, their $\pmb \theta$ is 5-dimensional for any network. The resulting fit is shown in Fig. 2(right). It is clearly a poorer fit than that of our signature, with a significantly lower $\bar { R } ^ { 2 }$ of 0.72.
For a fairer comparison, we also reduced our signature $\pmb \theta$ from 20 dimensions to the best performing 4 dimensions (even one dimension less than what we used for Bartlett’s) by dropping 16 components in our $\pmb \theta$ . This is shown in Fig. 2 (middle) and has a $\bar { R } ^ { 2 }$ of 0.89, which is poorer than our complete
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=3>CNN+CIFAR10</td><td rowspan=1 colspan=3>ResNet+CIFAR10</td><td rowspan=1 colspan=3>ResNet+CIFAR100</td></tr><tr><td rowspan=1 colspan=1>Experiment Settings</td><td rowspan=1 colspan=1>A R²</td><td rowspan=1 colspan=1>kf R²</td><td rowspan=1 colspan=1>mse</td><td rowspan=1 colspan=1>A R²</td><td rowspan=1 colspan=1>kf R²</td><td rowspan=1 colspan=1>mse</td><td rowspan=1 colspan=1>A R²</td><td rowspan=1 colspan=1>kf R²</td><td rowspan=1 colspan=1>mse</td></tr><tr><td rowspan=1 colspan=1>qrt+log</td><td rowspan=1 colspan=1>0.94</td><td rowspan=1 colspan=1>0.90</td><td rowspan=1 colspan=1>1.5</td><td rowspan=1 colspan=1>0.87</td><td rowspan=1 colspan=1>0.81</td><td rowspan=1 colspan=1>0.40</td><td rowspan=1 colspan=1>0.97</td><td rowspan=1 colspan=1>0.96</td><td rowspan=1 colspan=1>1.6</td></tr><tr><td rowspan=1 colspan=1>qrt+log+unnorm</td><td rowspan=1 colspan=1>0.89</td><td rowspan=1 colspan=1>0.86</td><td rowspan=1 colspan=1>2.0</td><td rowspan=1 colspan=1>0.82</td><td rowspan=1 colspan=1>0.74</td><td rowspan=1 colspan=1>0.48</td><td rowspan=1 colspan=1>0.95</td><td rowspan=1 colspan=1>0.94</td><td rowspan=1 colspan=1>1.9</td></tr><tr><td rowspan=1 colspan=1>qrt+linear</td><td rowspan=1 colspan=1>0.88</td><td rowspan=1 colspan=1>0.84</td><td rowspan=1 colspan=1>2.2</td><td rowspan=1 colspan=1>0.77</td><td rowspan=1 colspan=1>0.66</td><td rowspan=1 colspan=1>0.54</td><td rowspan=1 colspan=1>0.91</td><td rowspan=1 colspan=1>0.87</td><td rowspan=1 colspan=1>2.6</td></tr><tr><td rowspan=1 colspan=1>sf+log</td><td rowspan=1 colspan=1>0.73</td><td rowspan=1 colspan=1>0.69</td><td rowspan=1 colspan=1>3.5</td><td rowspan=1 colspan=1>0.53</td><td rowspan=1 colspan=1>0.41</td><td rowspan=1 colspan=1>0.80</td><td rowspan=1 colspan=1>0.80</td><td rowspan=1 colspan=1>0.78</td><td rowspan=1 colspan=1>4.0</td></tr><tr><td rowspan=1 colspan=1>sl+log</td><td rowspan=1 colspan=1>0.86</td><td rowspan=1 colspan=1>0.84</td><td rowspan=1 colspan=1>2.2</td><td rowspan=1 colspan=1>0.44</td><td rowspan=1 colspan=1>0.33</td><td rowspan=1 colspan=1>0.87</td><td rowspan=1 colspan=1>0.95</td><td rowspan=1 colspan=1>0.94</td><td rowspan=1 colspan=1>1.8</td></tr><tr><td rowspan=1 colspan=1>moment+log</td><td rowspan=1 colspan=1>0.93</td><td rowspan=1 colspan=1>0.87</td><td rowspan=1 colspan=1>1.6</td><td rowspan=1 colspan=1>0.83</td><td rowspan=1 colspan=1>0.74</td><td rowspan=1 colspan=1>0.45</td><td rowspan=1 colspan=1>0.94</td><td rowspan=1 colspan=1>0.92</td><td rowspan=1 colspan=1>2.0</td></tr><tr><td rowspan=1 colspan=1>best4+log</td><td rowspan=1 colspan=1>0.89</td><td rowspan=1 colspan=1>0.88</td><td rowspan=1 colspan=1>2.1</td><td rowspan=1 colspan=1>0.54</td><td rowspan=1 colspan=1>0.43</td><td rowspan=1 colspan=1>0.80</td><td rowspan=1 colspan=1>0.93</td><td rowspan=1 colspan=1>0.92</td><td rowspan=1 colspan=1>2.4</td></tr><tr><td rowspan=1 colspan=1>spectral+log</td><td rowspan=1 colspan=1>0.73</td><td rowspan=1 colspan=1>0.70</td><td rowspan=1 colspan=1>3.5</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>-</td></tr><tr><td rowspan=1 colspan=1>Jacobian+log</td><td rowspan=1 colspan=1>0.42</td><td rowspan=1 colspan=1>N</td><td rowspan=1 colspan=1>5.0</td><td rowspan=1 colspan=1>0.20</td><td rowspan=1 colspan=1>N</td><td rowspan=1 colspan=1>1.0</td><td rowspan=1 colspan=1>0.47</td><td rowspan=1 colspan=1>N</td><td rowspan=1 colspan=1>6.0</td></tr><tr><td rowspan=1 colspan=1>LM+linear</td><td rowspan=1 colspan=1>0.35</td><td rowspan=1 colspan=1>N</td><td rowspan=1 colspan=1>5.2</td><td rowspan=1 colspan=1>0.68</td><td rowspan=1 colspan=1>N</td><td rowspan=1 colspan=1>0.66</td><td rowspan=1 colspan=1>0.74</td><td rowspan=1 colspan=1>N</td><td rowspan=1 colspan=1>4.0</td></tr></table>
Table 1: Ablation experiments considering different scenarios (see text for details). The last 3 rows are baselines from: (Bartlett et al., 2017; Sokolic et al., 2016; Elsayed et al., 2018). A indicates adjusted; kf indicates $\mathbf { k }$ -fold; mse indicates mean squared error in $1 0 ^ { - 3 }$ ; N indicates negative.
$\pmb \theta$ but still significantly higher than that of Bartlett et al. (2017). In addition, we considered two other baseline comparisons: Sokolic et al. (2016), where margin at input is defined as a function of the Jacobian of output (logits) with respect to input; and Elsayed et al. (2018) where the linearized approximation to margin is derived (for the same layers where we use our normalized margin approximation).
 Figure 2: (Best seen as PDF) Regression models to predict generalization gap. Left: regression model fit in log space for the full 20-dimensional feature space ( $\ddot { R ^ { 2 } } = 0 . 9 4 )$ ; Middle: fit for a subset of only 4 features, 2 each from 2 of the hidden layers $\bar { R } ^ { 2 } = 0 . 8 \dot { 9 } )$ ; Right: fit for features extracted from the normalized margin distribution as used in Bartlett et al. (2017) ( $\bar { R } ^ { 2 } = 0 . 7 2 $ ).
To quantify the effect of the normalization, different layers, feature transformation etc., we conduct a number of ablation experiments with the following configuration: 1. linear/log: Use signature transform of $\phi ( x ) = { \dot { x } }$ or $\phi ( x ) = \log ( x )$ ; 2. sl: Use signature from the single best layer $\mathcal { O } \in \mathbb { R } ^ { 5 } .$ ); 3. sf: Use only the single best statistic from the total signature for all the layers $\pmb { \theta } \in \dot { \mathbb { R } } ^ { 4 }$ , individual layer result can be found in Sec. 7); 4. moment: Use the first 5 moments of the normalized margin distribution as signature instead of quartile statistics $\pmb \theta \in \mathbb { R } ^ { 2 0 }$ (Sec. 3); 5. spectral: Use signature of spectrally normalized margins from Bartlett et al. (2017) $( \pmb \theta \in \mathbb R ^ { 5 } )$ ); 6. qrt: Use all the quartile statistics as total signature $\pmb { \theta } \in \mathbb { R } ^ { 2 0 }$ (Sec. 3); 7. best4: Use the 4 best statistics from the total signature $( \pmb { \theta } \in \mathbb { R } ^ { 4 } )$ ); 8. Jacobian: Use the Jacobian-based margin defined in Eq (39) of Sokolic et al. (2016) $( \pmb \theta \in \mathbb R ^ { 5 } )$ ); 9. LM: Use the large margin loss from Elsayed et al. (2018) at the same four layers where the statistics are measured $( \pmb \theta \in \mathbb R ^ { 4 }$ ); 10. unnorm indicates no normalization. In Table 1, we list the $\bar { R } ^ { 2 }$ from fitting models based on each of these scenarios. We see that, both quartile and moment signatures perform similarly, lending support to our thesis that the margin distribution, rather than the smallest or largest margin, is of importance in the context of generalization.
# 4.2 RESIDUAL NETWORKS ON CIFAR-10
On the CIFAR-10 dataset, we train 216 convolutional networks with residual connections; these networks are 32 layers deep with standard ResNet 32 topology (He et al., 2016). Since it is difficult to train ResNet without activation normalization, we created generalization gap variation with batch normalization (Ioffe & Szegedy, 2015) and group normalization $\mathrm { W u }$ & He, 2018). We further use different initial learning rates. The range of accuracy on the test set ranges from $8 3 \%$ to $9 3 . 5 \%$ and generalization gap from $6 \%$ to $1 3 . 5 \%$ . The residual networks were much deeper, and so we only chose 4 layers for feature-length compatibility with the shallower convoluational networks. This design choice also facilitates ease of analysis and circumvents the dependency on depth of the models. Table 1 shows the $\bar { R } ^ { 2 }$ . Note in the presence of residual connections that use convolution instead of identity and identity blocks that span more than one convolutional layers, it is not immediately clear how to properly apply the bounds of Bartlett et al. (2017) (third from last row) without morphing the topology of the architecture and careful design of reference matrices. As such, we omit them for ResNet. Fig. 3 (left) shows the fit for the resnet models, with $\bar { R } ^ { 2 } = 0 . 8 7$ . Fig. 3 (middle) and Fig. 3 (right) compare the log normalized density plots of a CIFAR-10 resnet and CIFAR-10 CNN. The plots show that the Resnet achieves a better margin distribution, correlated with greater test accuracy, even though it was trained without data augmentation.
 Figure 3: (Best seen as PDF) Left: Regression model fit in log space for the full 20-dimensional feature space for 216 residual networks $\bar { R } ^ { 2 } = 0 . 8 7 )$ on CIFAR-10; Middle: Log density plot of normalized margins of a particular residual network that achieves $9 1 . 7 \%$ test accuracy without data augmentation; Right: Log density plot of normalized margins of a CNN that achieves $8 7 . 2 \%$ with data augmentation. We see that the resnet achieves larger margins, especially at the hidden layers, and this is reflected in the higher test accuracy.
# 4.3 RESNET ON CIFAR-100
On the CIFAR-100 dataset, we trained 324 ResNet-32 with the same variation in hyperparameter settings as for the networks for CIFAR-10 with one additional initial learning rate. The range of accuracy on the test set ranges from $1 2 \%$ to $7 3 \%$ and the generalization gap ranges from $1 \%$ to $7 5 \%$ . Table 1 shows $\bar { R } ^ { 2 }$ for a number of ablation experiments and the full feature set. Fig. 4 (left) shows the fit of predicted and true generalization gaps over the networks $\bar { R } ^ { 2 } = 0 . 9 7 )$ . Fig. 4 (middle) and Fig. 4 (right) compare a CIFAR-100 residual network and a CIFAR-10 residual network with the same architecture and hyperparameters. Under these settings, the CIFAR-100 network achieves $4 4 \%$ test accuracy, whereas CIFAR-10 achieves $6 1 \%$ . The resulting normalized margin density plots clearly reflect the better generalization achieved by CIFAR-10: the densities at all layers are wider and shifted to the right. Thus, the normalized margin distributions reflect the relative “difficulty” of a particular dataset for a given architecture.
# 5 DISCUSSION
We have presented a predictor for generalization gap based on margin distribution in deep networks and conducted extensive experiments to assess it. Our results show that our scheme achieves a high adjusted coefficient of determination (a linear regression predicts generalization gap accurately). Specifically, the predictor uses normalized margin distribution across multiple layers of the network. The best predictor uses quartiles of the distribution combined in multiplicative way (additive in log transform). Compared to the strong baseline of spectral complexity normalized output margin (Bartlett et al., 2017), our scheme exhibits much higher predictive power and can be applied to any feedforward network (including ResNets, unlike generalization bounds such as (Bartlett et al., 2017; Neyshabur et al., 2017b; Arora et al., 2018)). We also find that using hidden layers is crucial for the predictive power. Our findings could be a stepping stone for studying new generalization theories and new loss functions with better generalization properties. We include the results on cross architecture and cross data comparison as well as some final thoughts in Appendix Sec. 9.
 Figure 4: (Best seen as PDF) Left: Regression model fit in log space for the full 20-dimensional feature space for 300 residual networks $\bar { R } ^ { 2 } = 0 . 9 7 )$ on CIFAR-100; Middle: density plot of normalized margins of a particular residual network trained on CIFAR-100 that achieves $4 4 \%$ test accuracy; Right: Density plot of normalized margins of a residual network trained on CIFAR-10 that achieves $6 1 \%$ .
# ACKNOWLEDGMENTS
We are thankful to Gamaleldin Elsayed (Google), Tomer Koren (Google), Sergey Ioffe (Google), Vighnesh Birodkar (Google), Shraman Ray Chaudhuri (Google), Kevin Regan (Google), Behnam Neyshabur (NYU), and Dylan Foster (Cornell), for discussions and helpful feedbacks.
# REFERENCES
Mart´ın Abadi, Paul Barham, Jianmin Chen, Zhifeng Chen, Andy Davis, Jeffrey Dean, Matthieu Devin, Sanjay Ghemawat, Geoffrey Irving, Michael Isard, et al. Tensorflow: A system for large-scale machine learning. In OSDI, volume 16, pp. 265–283, 2016.
Sanjeev Arora, Rong Ge, Behnam Neyshabur, and Yi Zhang. Stronger generalization bounds for deep nets via a compression approach. arXiv preprint arXiv:1802.05296, 2018.
Aharon Azulay and Yair Weiss. Why do deep convolutional networks generalize so poorly to small image transformations? arXiv preprint arXiv:1805.12177, 2018.
P. L. Bartlett. The sample complexity of pattern classification with neural networks: the size of the weights is more important than the size of the network. IEEE Transactions on Information Theory, 44(2):525–536, March 1998. ISSN 0018-9448. doi: 10.1109/18.661502.
Peter L Bartlett, Dylan J Foster, and Matus J Telgarsky. Spectrally-normalized margin bounds for neural networks. In Advances in Neural Information Processing Systems, pp. 6240–6249, 2017.
Gamaleldin F Elsayed, Dilip Krishnan, Hossein Mobahi, Kevin Regan, and Samy Bengio. Large margin deep networks for classification. arXiv preprint arXiv:1803.05598, 2018.
Logan Engstrom, Dimitris Tsipras, Ludwig Schmidt, and Aleksander Madry. A rotation and a translation suffice: Fooling cnns with simple transformations. arXiv preprint arXiv:1712.02779, 2017.
Ashutosh Garg, Sariel Har-Peled, and Dan Roth. On generalization bounds, projection profile, and margin distribution. In Machine Learning, Proceedings of the Nineteenth International Conference (ICML 2002), University of New South Wales, Sydney, Australia, July 8-12, 2002, pp. 171–178, 2002.
Stanton A Glantz, Bryan K Slinker, and Torsten B Neilands. Primer of applied regression and analysis of variance, volume 309. McGraw-Hill New York, 1990.
Ian J Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. arXiv preprint arXiv:1412.6572, 2014.
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.
Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. arXiv preprint arXiv:1502.03167, 2015.
Kenji Kawaguchi, Leslie Pack Kaelbling, and Yoshua Bengio. Generalization in deep learning. arXiv preprint arXiv:1710.05468, 2017.
John Langford and John Shawe-Taylor. Pac-bayes margins. In Proceedings of the 15th International Conference on Neural Information Processing Systems, NIPS’02, pp. 439–446, Cambridge, MA, USA, 2002. MIT Press.
Xuezhi Liang, Xiaobo Wang, Zhen Lei, Shengcai Liao, and Stan Z Li. Soft-margin softmax for deep classification. In International Conference on Neural Information Processing, pp. 413–421. Springer, 2017.
Qianli Liao, Brando Miranda, Andrzej Banburski, Jack Hidary, and Tomaso Poggio. A surprising linear relationship predicts test performance in deep networks. arXiv preprint arXiv:1807.09659, 2018.
Min Lin, Qiang Chen, and Shuicheng Yan. Network in network. arXiv preprint arXiv:1312.4400, 2013.
Weiyang Liu, Yandong Wen, Zhiding Yu, and Meng Yang. Large-margin softmax loss for convolutional neural networks. In ICML, pp. 507–516, 2016.
Shen-Huan Lv, Lu Wang, and Zhi-Hua Zhou. Optimal margin distribution network, 2019. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ HygcvsAcFX.
Robert McGill, John W Tukey, and Wayne A Larsen. Variations of box plots. The American Statistician, 32(1):12–16, 1978.
Behnam Neyshabur, Srinadh Bhojanapalli, David McAllester, and Nathan Srebro. A pacbayesian approach to spectrally-normalized margin bounds for neural networks. arXiv preprint arXiv:1707.09564, 2017a.
Behnam Neyshabur, Srinadh Bhojanapalli, David McAllester, and Nati Srebro. Exploring generalization in deep learning. In Advances in Neural Information Processing Systems, pp. 5947–5956, 2017b.
Nicolas Papernot, Patrick McDaniel, Ian Goodfellow, Somesh Jha, Z Berkay Celik, and Ananthram Swami. Practical black-box attacks against deep learning systems using adversarial examples. arXiv preprint arXiv:1602.02697, 2016.
Tomaso Poggio, Kenji Kawaguchi, Qianli Liao, Brando Miranda, Lorenzo Rosasco, Xavier Boix, Jack Hidary, and Hrushikesh Mhaskar. Theory of deep learning iii: explaining the non-overfitting puzzle. arXiv preprint arXiv:1801.00173, 2017.
Lev Reyzin and Robert E Schapire. How boosting the margin can also boost classifier complexity. In Proceedings of the 23rd international conference on Machine learning, pp. 753–760. ACM, 2006.
Robert E Schapire, Yoav Freund, Peter Bartlett, Wee Sun Lee, et al. Boosting the margin: A new explanation for the effectiveness of voting methods. The annals of statistics, 26(5):1651–1686, 1998.
Jure Sokolic, Raja Giryes, Guillermo Sapiro, and Miguel R. D. Rodrigues. Robust large margin deep neural networks. CoRR, abs/1605.08254, 2016. URL http://arxiv.org/abs/1605. 08254.
Shizhao Sun, Wei Chen, Liwei Wang, and Tie-Yan Liu. Large margin deep neural networks: Theory and algorithms. CoRR, abs/1506.05232, 2015. URL http://arxiv.org/abs/ 1506.05232.
Vladimir N. Vapnik. The Nature of Statistical Learning Theory. Springer-Verlag New York, Inc., New York, NY, USA, 1995. ISBN 0-387-94559-8.
Yuxin Wu and Kaiming He. Group normalization. arXiv preprint arXiv:1803.08494, 2018.
Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning requires rethinking generalization. arXiv preprint arXiv:1611.03530, 2016.
Teng Zhang and Zhi-Hua Zhou. Multi-class optimal margin distribution machine. In Doina Precup and Yee Whye Teh (eds.), Proceedings of the 34th International Conference on Machine Learning, volume 70 of Proceedings of Machine Learning Research, pp. 4063–4071, International Convention Centre, Sydney, Australia, 06–11 Aug 2017. PMLR. URL http://proceedings.mlr. press/v70/zhang17h.html.
Teng Zhang and Zhi-Hua Zhou. Optimal margin distribution clustering, 2018. URL https: //aaai.org/ocs/index.php/AAAI/AAAI18/paper/view/16895.
# 6 APPENDIX: EXPERIMENTAL DETAILS
# 6.1 CNN $^ +$ CIFAR-10
We use an architecture very similar to Network in Network (Lin et al. (2013)), but we remove all dropout and max pool from the network.
Table 2: Architecture of base CNN model.
<table><tr><td rowspan=1 colspan=1>Layer Index</td><td rowspan=1 colspan=1>Layer Type</td><td rowspan=1 colspan=1>Output Shape</td></tr><tr><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>Input</td><td rowspan=1 colspan=1>32 × 32×3</td></tr><tr><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>3 ×3 convolution + stride 2</td><td rowspan=1 colspan=1>16×16×192</td></tr><tr><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>1 ×1 convolution + stride 1</td><td rowspan=1 colspan=1>16 ×16×192</td></tr><tr><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1>1 ×1 convolution + stride 1</td><td rowspan=1 colspan=1>16 ×16×192</td></tr><tr><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>3 ×3 convolution + stride 2</td><td rowspan=1 colspan=1>8×8×192</td></tr><tr><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>1 ×1 convolution+ stride1</td><td rowspan=1 colspan=1>8×8×192</td></tr><tr><td rowspan=1 colspan=1>6</td><td rowspan=1 colspan=1>1 ×1 convolution + stride 1</td><td rowspan=1 colspan=1>8×8×192</td></tr><tr><td rowspan=1 colspan=1>7</td><td rowspan=1 colspan=1>3 × 3 convolution + stride 2</td><td rowspan=1 colspan=1>4×4×192</td></tr><tr><td rowspan=1 colspan=1>8</td><td rowspan=1 colspan=1>1 × 1 convolution + stride 1</td><td rowspan=1 colspan=1>4×4×192</td></tr><tr><td rowspan=1 colspan=1>9</td><td rowspan=1 colspan=1>1 ×1 convolution + stride 1</td><td rowspan=1 colspan=1>4×4×192</td></tr><tr><td rowspan=1 colspan=1>10</td><td rowspan=1 colspan=1>4 × 4 convolution + stride 1</td><td rowspan=1 colspan=1>1×1×10</td></tr></table>
To create generalization gap in this model, we make the following modification to the base architecture:
1. Use channel size of 192, 288, and 384 to create different width 2. Train with and without batch norm at all convolutional layers 3. Apply dropout at layer 3 and 6 with $p = 0 . 0 , 0 . 2 , 0 . 5$ 4. Apply $l _ { 2 }$ regularization with $\lambda = 0 . 0 , 0 . 0 0 1 , 0 . 0 0 5$ 5. Train with and without data augmentation with random cropping, flipping and shifting 6. Train each configuration twice
In total this gives us $3 \times 2 \times 3 \times 3 \times 2 \times 2 = 2 1 6$ different network architectures. The models are trained with SGD with momentum $\alpha = 0 . 9$ ) at minibatch size of 128 and intial learning rate of 0.01. All networks are trained for 380 epoch with $1 0 \times$ learning rate decay at interval of 100 epoch.
# 6.2 RESNET $^ { 3 2 + }$ CIFAR-10
For this experiments, we use the standard ResNet 32 architectures. We consider down sampling to the marker of a stage, so there are in total 3 stages in the ResNet 32 architecture. To create generalization gap in this model, we make the following modifications to the architecture:
1. Use network width that are $1 \times , 2 \times , 4 \times$ wider in number of channels. 2. Train with batch norm or group norm (Wu & He, 2018) 3. Train with initial learning rate of 0.01, 0.001 4. Apply $l _ { 2 }$ regularization with $\lambda = 0 . 0 , 0 . 0 2 , 0 . 0 0 2$ 5. Trian with and without data augmentation with random cropping, flipping and shifting 6. Train each configuration 3 times
In total this gives us $3 \times 2 \times 2 \times 3 \times 2 \times 3 = 2 1 6$ different network architectures. The models are trained with SGD with momentum $\dot { \alpha } = 0 . 9$ ) at minibatch size of 128. All networks are trained for 380 epoch with $1 0 \times$ learning rate decay at interval of 100 epoch.
# 6.3 RESNET $^ { 3 2 + }$ CIFAR-100
For this experiments, we use the standard ResNet 32 architectures. We consider down sampling to the marker of a stage, so there are in total 3 stages in the ResNet 32 architecture. To create generalization gap in this model, we make the following modifications to the architecture:
1. Use network width that are $1 \times , 2 \times , 4 \times$ wider in number of channels. 2. Train with batch norm or group norm (Wu & He, 2018) 3. Train with initial learning rate of $0 . 1 , 0 . 0 1 , 0 . 0 0 1$ 4. Apply $l _ { 2 }$ regularization with $\lambda = 0 . 0 , 0 . 0 2 , 0 . 0 0 2$ 5. Trian with and without data augmentation with random cropping, flipping and shifting 6. Train each configuration 3 times
In total this gives us $3 \times 2 \times 3 \times 3 \times 2 \times 3 = 3 2 4$ different network architectures. The models are trained with SGD with momentum $\alpha = 0 . 9$ ) at minibatch size of 128. All networks are trained for 380 epoch with $1 0 \times$ learning rate decay at interval of 100 epoch.
# 7 APPENDIX: MORE REGRESSION RESULTS
# 7.1 ANALYSIS WITH NEGATIVE MARGINS
The last two rows contain the results of including the negative margins and regress against both the gap (generalization gap) and against acc (test accuracy). We see that including when negative margin is included, it is in general easier to predict the accuracy of the models rather than the gap itself. For convenience, we have reproduced Table 1.
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=3>CNN+CIFAR10</td><td rowspan=1 colspan=3>ResNet+CIFAR10</td><td rowspan=1 colspan=3>ResNet+CIFAR100</td></tr><tr><td rowspan=1 colspan=1>Experiment Settings</td><td rowspan=1 colspan=1>AR</td><td rowspan=1 colspan=1>kf R²</td><td rowspan=1 colspan=1>mse</td><td rowspan=1 colspan=1>AR</td><td rowspan=1 colspan=1>kf R²</td><td rowspan=1 colspan=1>mse</td><td rowspan=1 colspan=1>A R²</td><td rowspan=1 colspan=1>kf R²</td><td rowspan=1 colspan=1>mse</td></tr><tr><td rowspan=1 colspan=1>qrt+log</td><td rowspan=1 colspan=1>0.94</td><td rowspan=1 colspan=1>0.90</td><td rowspan=1 colspan=1>1.5</td><td rowspan=1 colspan=1>0.87</td><td rowspan=1 colspan=1>0.81</td><td rowspan=1 colspan=1>0.40</td><td rowspan=1 colspan=1>0.97</td><td rowspan=1 colspan=1>0.96</td><td rowspan=1 colspan=1>1.6</td></tr><tr><td rowspan=1 colspan=1>qrt+log+unnorm</td><td rowspan=1 colspan=1>0.89</td><td rowspan=1 colspan=1>0.86</td><td rowspan=1 colspan=1>2.0</td><td rowspan=1 colspan=1>0.82</td><td rowspan=1 colspan=1>0.74</td><td rowspan=1 colspan=1>0.48</td><td rowspan=1 colspan=1>0.95</td><td rowspan=1 colspan=1>0.94</td><td rowspan=1 colspan=1>1.9</td></tr><tr><td rowspan=1 colspan=1>qrt+linear</td><td rowspan=1 colspan=1>0.88</td><td rowspan=1 colspan=1>0.84</td><td rowspan=1 colspan=1>2.2</td><td rowspan=1 colspan=1>0.77</td><td rowspan=1 colspan=1>0.66</td><td rowspan=1 colspan=1>0.54</td><td rowspan=1 colspan=1>0.91</td><td rowspan=1 colspan=1>0.87</td><td rowspan=1 colspan=1>2.6</td></tr><tr><td rowspan=1 colspan=1>sf+log</td><td rowspan=1 colspan=1>0.73</td><td rowspan=1 colspan=1>0.69</td><td rowspan=1 colspan=1>3.5</td><td rowspan=1 colspan=1>0.53</td><td rowspan=1 colspan=1>0.41</td><td rowspan=1 colspan=1>0.80</td><td rowspan=1 colspan=1>0.80</td><td rowspan=1 colspan=1>0.78</td><td rowspan=1 colspan=1>4.0</td></tr><tr><td rowspan=1 colspan=1>sl+log</td><td rowspan=1 colspan=1>0.86</td><td rowspan=1 colspan=1>0.84</td><td rowspan=1 colspan=1>2.2</td><td rowspan=1 colspan=1>0.44</td><td rowspan=1 colspan=1>0.33</td><td rowspan=1 colspan=1>0.87</td><td rowspan=1 colspan=1>0.95</td><td rowspan=1 colspan=1>0.94</td><td rowspan=1 colspan=1>1.8</td></tr><tr><td rowspan=1 colspan=1>moment+log</td><td rowspan=1 colspan=1>0.93</td><td rowspan=1 colspan=1>0.87</td><td rowspan=1 colspan=1>1.6</td><td rowspan=1 colspan=1>0.83</td><td rowspan=1 colspan=1>0.74</td><td rowspan=1 colspan=1>0.45</td><td rowspan=1 colspan=1>0.94</td><td rowspan=1 colspan=1>0.92</td><td rowspan=1 colspan=1>2.0</td></tr><tr><td rowspan=1 colspan=1>best4+log</td><td rowspan=1 colspan=1>0.89</td><td rowspan=1 colspan=1>0.88</td><td rowspan=1 colspan=1>2.1</td><td rowspan=1 colspan=1>0.54</td><td rowspan=1 colspan=1>0.43</td><td rowspan=1 colspan=1>0.80</td><td rowspan=1 colspan=1>0.93</td><td rowspan=1 colspan=1>0.92</td><td rowspan=1 colspan=1>2.4</td></tr><tr><td rowspan=1 colspan=1>spectral+log</td><td rowspan=1 colspan=1>0.73</td><td rowspan=1 colspan=1>0.70</td><td rowspan=1 colspan=1>3.5</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>-</td></tr><tr><td rowspan=1 colspan=1>Jacobian+log</td><td rowspan=1 colspan=1>0.42</td><td rowspan=1 colspan=1>N</td><td rowspan=1 colspan=1>5.0</td><td rowspan=1 colspan=1>0.20</td><td rowspan=1 colspan=1>N</td><td rowspan=1 colspan=1>1.0</td><td rowspan=1 colspan=1>0.47</td><td rowspan=1 colspan=1>N</td><td rowspan=1 colspan=1>6.0</td></tr><tr><td rowspan=1 colspan=1>LM+linear</td><td rowspan=1 colspan=1>0.35</td><td rowspan=1 colspan=1>N</td><td rowspan=1 colspan=1>5.2</td><td rowspan=1 colspan=1>0.68</td><td rowspan=1 colspan=1>N</td><td rowspan=1 colspan=1>0.66</td><td rowspan=1 colspan=1>0.74</td><td rowspan=1 colspan=1>N</td><td rowspan=1 colspan=1>4.0</td></tr><tr><td rowspan=1 colspan=1>qrt+linear+gap</td><td rowspan=1 colspan=1>0.90</td><td rowspan=1 colspan=1>0.86</td><td rowspan=1 colspan=1>2.0</td><td rowspan=1 colspan=1>0.71</td><td rowspan=1 colspan=1>0.61</td><td rowspan=1 colspan=1>0.6</td><td rowspan=1 colspan=1>0.93</td><td rowspan=1 colspan=1>0.89</td><td rowspan=1 colspan=1>2.0</td></tr><tr><td rowspan=1 colspan=1>qrt+linear+acc</td><td rowspan=1 colspan=1>0.91</td><td rowspan=1 colspan=1>0.88</td><td rowspan=1 colspan=1>1.6</td><td rowspan=1 colspan=1>0.98</td><td rowspan=1 colspan=1>0.96</td><td rowspan=1 colspan=1>0.2</td><td rowspan=1 colspan=1>0.92</td><td rowspan=1 colspan=1>0.89</td><td rowspan=1 colspan=1>2.0</td></tr></table>
Table 3: Table 1 with two additional row. The second to last row shows prediction of generalization gap when negative margins are used; the last row is for prediction of test accuracy rather than gap. Note that negative margins can only be used with linear features.
# 7.2 ANALYSIS FOR INDIVIDUAL LAYER’S MARGIN DISTRIBUTIONS
This is a comparison of different individual layer’s predictive power by using only the margin distribution at that layer. This results illustrates the importance of margins in the hidden layers.
Table 4: Single layer comparison, all with qrt+log
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=3>CNN+CIFAR10</td><td rowspan=1 colspan=3>ResNet+CIFAR10</td><td rowspan=1 colspan=3>ResNet+CIFAR100</td></tr><tr><td rowspan=1 colspan=1>Experiment Settings</td><td rowspan=1 colspan=1>A R²</td><td rowspan=1 colspan=1>kf R²</td><td rowspan=1 colspan=1>mse</td><td rowspan=1 colspan=1>A R²</td><td rowspan=1 colspan=1>kf R²</td><td rowspan=1 colspan=1>mse</td><td rowspan=1 colspan=1>A R²</td><td rowspan=1 colspan=1>kf R²</td><td rowspan=1 colspan=1>mse</td></tr><tr><td rowspan=1 colspan=1>input</td><td rowspan=1 colspan=1>0.77</td><td rowspan=1 colspan=1>0.73</td><td rowspan=1 colspan=1>3.1</td><td rowspan=1 colspan=1>0.16</td><td rowspan=1 colspan=1>0.02</td><td rowspan=1 colspan=1>1.0</td><td rowspan=1 colspan=1>0.82</td><td rowspan=1 colspan=1>0.81</td><td rowspan=1 colspan=1>3.9</td></tr><tr><td rowspan=1 colspan=1>h1</td><td rowspan=1 colspan=1>0.77</td><td rowspan=1 colspan=1>0.74</td><td rowspan=1 colspan=1>3.1</td><td rowspan=1 colspan=1>0.36</td><td rowspan=1 colspan=1>0.26</td><td rowspan=1 colspan=1>0.94</td><td rowspan=1 colspan=1>0.95</td><td rowspan=1 colspan=1>0.94</td><td rowspan=1 colspan=1>1.8</td></tr><tr><td rowspan=1 colspan=1>h2</td><td rowspan=1 colspan=1>0.80</td><td rowspan=1 colspan=1>0.77</td><td rowspan=1 colspan=1>3.0</td><td rowspan=1 colspan=1>0.41</td><td rowspan=1 colspan=1>0.31</td><td rowspan=1 colspan=1>0.90</td><td rowspan=1 colspan=1>0.77</td><td rowspan=1 colspan=1>0.73</td><td rowspan=1 colspan=1>4.4</td></tr><tr><td rowspan=1 colspan=1>h3</td><td rowspan=1 colspan=1>0.86</td><td rowspan=1 colspan=1>0.84</td><td rowspan=1 colspan=1>2.2</td><td rowspan=1 colspan=1>0.44</td><td rowspan=1 colspan=1>0.33</td><td rowspan=1 colspan=1>0.87</td><td rowspan=1 colspan=1>0.54</td><td rowspan=1 colspan=1>0.53</td><td rowspan=1 colspan=1>6.3</td></tr><tr><td rowspan=1 colspan=1>alllayer</td><td rowspan=1 colspan=1>0.94</td><td rowspan=1 colspan=1>0.90</td><td rowspan=1 colspan=1>1.5</td><td rowspan=1 colspan=1>0.87</td><td rowspan=1 colspan=1>0.81</td><td rowspan=1 colspan=1>0.40</td><td rowspan=1 colspan=1>0.97</td><td rowspan=1 colspan=1>0.96</td><td rowspan=1 colspan=1>1.6</td></tr></table>
# 8 APPENDIX: FURTHER ANALYSIS OF REGRESSION
# 8.1 CNN $^ +$ CIFAR- $^ { 1 0 + }$ ALL QUARTILE SIGNATURE
 Figure 5: Residual plots for all explanatory variables, row: h0, h1, h2, h3, column: lower fence, $Q _ { 1 }$ , $Q _ { 2 }$ , $Q _ { 3 }$ , upper fence. lower fence is clipped because distance cannot be smaller than 0. The residual is fairly evenly distributed around 0. Table 5: F score (top) and $\mathsf { p }$ -values (bottom) for all 20 variables. Using $p = 0 . 0 5$ , the null hypotheses are rejected for every variable.
<table><tr><td rowspan=5 colspan=1></td><td rowspan=1 colspan=2></td><td rowspan=1 colspan=2>lower fence</td><td rowspan=1 colspan=2>Q1</td><td rowspan=1 colspan=1>Q2</td><td rowspan=1 colspan=2>Q3</td><td rowspan=1 colspan=2>upper fence</td><td rowspan=5 colspan=1></td></tr><tr><td rowspan=1 colspan=2>h0</td><td rowspan=1 colspan=2>306.40</td><td rowspan=1 colspan=2>114.41</td><td rowspan=1 colspan=1>39.56</td><td rowspan=1 colspan=2>12.54</td><td rowspan=1 colspan=2>5.07</td></tr><tr><td rowspan=1 colspan=2>h1</td><td rowspan=1 colspan=2>286.53</td><td rowspan=1 colspan=2>9.42</td><td rowspan=1 colspan=1>5.16</td><td rowspan=1 colspan=2>17.29</td><td rowspan=1 colspan=2>38.57</td></tr><tr><td rowspan=1 colspan=2>h2</td><td rowspan=1 colspan=2>259.68</td><td rowspan=1 colspan=2>6.95</td><td rowspan=1 colspan=1>77.03</td><td rowspan=1 colspan=2>110.40</td><td rowspan=1 colspan=2>152.20</td></tr><tr><td rowspan=1 colspan=2>h3</td><td rowspan=1 colspan=2>188.59</td><td rowspan=1 colspan=2>10.29</td><td rowspan=1 colspan=1>49.76</td><td rowspan=1 colspan=2>83.40</td><td rowspan=1 colspan=2>143.23</td></tr><tr><td rowspan=1 colspan=2></td><td rowspan=1 colspan=2>lower fence</td><td rowspan=1 colspan=2>Q1</td><td rowspan=1 colspan=2>Q2</td><td></td><td rowspan=1 colspan=2>Q3</td><td rowspan=1 colspan=2>upper fence</td></tr><tr><td rowspan=1 colspan=2>h0</td><td rowspan=1 colspan=2>3.59e-43</td><td rowspan=1 colspan=2>1.13e-21</td><td rowspan=1 colspan=2>1.76e-9</td><td></td><td rowspan=1 colspan=2>4.87e-4</td><td rowspan=1 colspan=2>2.52e-2</td></tr><tr><td rowspan=1 colspan=2>h1</td><td rowspan=1 colspan=2>2.34e-41</td><td rowspan=1 colspan=2>2.41e-3</td><td rowspan=1 colspan=2>2.40e-2</td><td></td><td rowspan=1 colspan=2>4.64e-5</td><td rowspan=1 colspan=2>2.70e-09</td></tr><tr><td rowspan=1 colspan=2>h2</td><td rowspan=1 colspan=2>8.76e-39</td><td rowspan=1 colspan=2>8.95e-3</td><td rowspan=1 colspan=2>5.38e-16</td><td></td><td rowspan=1 colspan=2>4.30e-21</td><td rowspan=1 colspan=2>9.12e-27</td></tr><tr><td rowspan=1 colspan=2>h3</td><td rowspan=1 colspan=2>3.40e-31</td><td rowspan=1 colspan=2>1.54e-3</td><td rowspan=1 colspan=2>2.37e-11</td><td></td><td rowspan=1 colspan=2>5.17e-17</td><td rowspan=1 colspan=2>1.31e-25</td></tr></table>
 Figure 6: Residual plots for all explanatory variables, row: h0, h1, h2, h3, column: lower fence, $Q _ { 1 }$ , $Q _ { 2 }$ , $Q _ { 3 }$ , upper fence. lower fence is clipped because distance cannot be smaller than 0. The residual is less evenly distributed as are in other two settings; this fact is well reflected in the cluster along the $\mathbf { X }$ axis and in the $\bar { R } ^ { 2 }$ ; we speculate that this is due to not having diverse enough generalization gap in the models trained to cover the entire space of the “model” unlike in the other two settings.
<table><tr><td rowspan=5 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=2>lower fence</td><td rowspan=1 colspan=1>Q1</td><td rowspan=1 colspan=1>Q2</td><td rowspan=1 colspan=2>Q3</td><td rowspan=1 colspan=2>upper fence</td><td rowspan=5 colspan=1></td></tr><tr><td rowspan=1 colspan=1>h0</td><td rowspan=1 colspan=2>45.67</td><td rowspan=1 colspan=1>16.67</td><td rowspan=1 colspan=1>6.97</td><td rowspan=1 colspan=2>1.71</td><td rowspan=1 colspan=2>0.68</td></tr><tr><td rowspan=1 colspan=1>h1</td><td rowspan=1 colspan=2>58.84</td><td rowspan=1 colspan=1>88.14</td><td rowspan=1 colspan=1>44.15</td><td rowspan=1 colspan=2>15.59</td><td rowspan=1 colspan=2>9.36</td></tr><tr><td rowspan=1 colspan=1>h2</td><td rowspan=1 colspan=2>60.20</td><td rowspan=1 colspan=1>78.57</td><td rowspan=1 colspan=1>35.76</td><td rowspan=1 colspan=2>12.89</td><td rowspan=1 colspan=2>7.52</td></tr><tr><td rowspan=1 colspan=1>h3</td><td rowspan=1 colspan=2>59.75</td><td rowspan=1 colspan=1>0.27</td><td rowspan=1 colspan=1>1.192</td><td rowspan=1 colspan=2>7.37</td><td rowspan=1 colspan=2>44.22</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=2>lower fence</td><td rowspan=1 colspan=2>Q1</td><td rowspan=1 colspan=2>Q2</td><td rowspan=1 colspan=2>Q3</td><td rowspan=1 colspan=2>upper fence</td></tr><tr><td rowspan=1 colspan=1>h0</td><td rowspan=1 colspan=2>1.30e-10</td><td rowspan=1 colspan=2>6.25e-5</td><td rowspan=1 colspan=2>8.88e-3</td><td rowspan=1 colspan=2>0.192</td><td rowspan=1 colspan=2>0.40</td></tr><tr><td rowspan=1 colspan=1>h1</td><td rowspan=1 colspan=2>5.94e-13</td><td rowspan=1 colspan=2>9.33e-18</td><td rowspan=1 colspan=2>2.47e-10</td><td rowspan=1 colspan=2>1.06e-4</td><td rowspan=1 colspan=2>2.49e-3</td></tr><tr><td rowspan=1 colspan=1>h2</td><td rowspan=1 colspan=2>3.45e-13</td><td rowspan=1 colspan=2>3.04e-16</td><td rowspan=1 colspan=2>9.21e-9</td><td rowspan=1 colspan=2>4.07e-4</td><td rowspan=1 colspan=2>6.59e-3</td></tr><tr><td rowspan=1 colspan=1>h3</td><td rowspan=1 colspan=2>4.14e-13</td><td rowspan=1 colspan=2>0.60</td><td rowspan=1 colspan=2>0.27</td><td rowspan=1 colspan=2>7.14e-3</td><td rowspan=1 colspan=2>2.4e-10</td></tr></table>
Table 6: F score (top) and $\mathfrak { p }$ -values (bottom) for all 20 variables. Using $p = 0 . 0 5$ , we see that the null hypotheses are not rejected for 4 of the variables. We believe having a more diverse generalization behavior in the study will solve this problem.
 Figure 7: Residual plots for all explanatory variables, row: h0, h1, h2, h3, column: lower fence, $Q _ { 1 }$ , $Q _ { 2 }$ , $Q _ { 3 }$ , upper fence. lower fence is clipped because distance cannot be smaller than 0. The residual is fairly evenly distributed around 0. There is one outlier in this experimental setting as shown in the plots.
Table 7: F score (top) and $\mathsf { p }$ -values (bottom) for all 20 variables. Using $p = 0 . 0 5$ , the null hypotheses are rejected for every variable except for h3 upper fence.
<table><tr><td rowspan=5 colspan=1></td><td rowspan=1 colspan=2></td><td rowspan=1 colspan=2>lower fence</td><td rowspan=1 colspan=1>Q1</td><td rowspan=1 colspan=1>Q2</td><td rowspan=1 colspan=1>Q3</td><td rowspan=1 colspan=2>upper fence</td><td rowspan=5 colspan=1></td></tr><tr><td rowspan=1 colspan=2>h0</td><td rowspan=1 colspan=2>80.12</td><td rowspan=1 colspan=1>8.40</td><td rowspan=1 colspan=1>59.62</td><td rowspan=1 colspan=1>141.56</td><td rowspan=1 colspan=2>248.77</td></tr><tr><td rowspan=1 colspan=2>h1</td><td rowspan=1 colspan=2>65.24</td><td rowspan=1 colspan=1>109.86</td><td rowspan=1 colspan=1>343.57</td><td rowspan=1 colspan=1>700.91</td><td rowspan=1 colspan=2>1124.43</td></tr><tr><td rowspan=1 colspan=2>h2</td><td rowspan=1 colspan=2>99.06</td><td rowspan=1 colspan=1>15.47</td><td rowspan=1 colspan=1>122.36</td><td rowspan=1 colspan=1>305.88</td><td rowspan=1 colspan=2>512.69</td></tr><tr><td rowspan=1 colspan=2>h3</td><td rowspan=1 colspan=2>244.07</td><td rowspan=1 colspan=1>128.45</td><td rowspan=1 colspan=1>65.58</td><td rowspan=1 colspan=1>28.10</td><td rowspan=1 colspan=2>2.34</td></tr><tr><td rowspan=1 colspan=2></td><td rowspan=1 colspan=2>lower fence</td><td rowspan=1 colspan=2>Q1</td><td rowspan=1 colspan=1>Q2</td><td rowspan=1 colspan=2>Q3</td><td rowspan=1 colspan=2>upper fence</td></tr><tr><td rowspan=1 colspan=2>h0</td><td rowspan=1 colspan=2>2.85e-17</td><td rowspan=1 colspan=2>4.00e-3</td><td rowspan=1 colspan=1>1.46e-13</td><td rowspan=1 colspan=2>2.65e-27</td><td rowspan=1 colspan=2>6.32e-42</td></tr><tr><td rowspan=1 colspan=2>h1</td><td rowspan=1 colspan=2>1.34e-14</td><td rowspan=1 colspan=2>2.60e-22</td><td rowspan=1 colspan=1>1.04e-52</td><td rowspan=1 colspan=2>8.12e-83</td><td rowspan=1 colspan=2>4.55e-107</td></tr><tr><td rowspan=1 colspan=2>h2</td><td rowspan=1 colspan=2>1.59e-20</td><td rowspan=1 colspan=2>1.03e-4</td><td rowspan=1 colspan=1>2.53e-24</td><td rowspan=1 colspan=2>1.29e-48</td><td rowspan=1 colspan=2>1.42e-68</td></tr><tr><td rowspan=1 colspan=2>h3</td><td rowspan=1 colspan=2>2.40e-41</td><td rowspan=1 colspan=2>2.78e-25</td><td rowspan=1 colspan=1>1.16e-14</td><td rowspan=1 colspan=2>2.13e-7</td><td rowspan=1 colspan=2>0.127</td></tr></table>
# 9 APPENDIX: SOME OBSERVATIONS AND CONJECTURES
Everythig here uses the full quartile description.
# 9.1 CROSS ARCHITECTURE COMPARISON
We perform regression analysis with both base CNN and ResNet32 on CIFAR-10. The resulting $\bar { R } ^ { 2 } = 0 . 9 1$ and the $\mathbf { k }$ -fold $R ^ { \bar { 2 } } = 0 . 8 8$ . This suggests that the same coefficient works generally well across architectures provided they are trained on the same data. Somehow, the distribution at the 3 locations of the networks are comparable even though the depths are vastly different.
 Figure 8: Scatter Plots
# 9.2 CROSS DATASET COMPARISON
We perform regression analysis with ResNet32 on both CIFAR-10 and CIFAR-100. The resulting $\bar { R } ^ { 2 } = 0 . 9 6$ and the $\mathbf { k }$ -fold $R ^ { \bar { 2 } } = 0 . 9 5$ . This suggests that the same coefficient works generally well across dataset of the same architecture.
 Figure 9: Scatter Plots
# 9.3 CROSS EVERYTHING
We join all our experiment data and the resulting The resulting $\bar { R } ^ { 2 } = 0 . 9 3$ and the $\mathrm { k }$ -fold $R ^ { 2 } = 0 . 9 3$ . It is perhaps surprising that a set of coefficient exists across both datasets and architectures.
 Figure 10: Scatter Plots
# 9.4 IMPLICATIONS ON GENERALIZATION BOUNDS
We believe that the method developed here can be used in complementary with existing generalization bound; more sophisticated engineering of the predictor may be used to actually verify what kind of function the generalization bound should look like up to constant factor or exponents; it may be helpful for developing generalization bound tighter than the existing ones.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162# DEEP BIAFFINE ATTENTION FOR NEURALDEPENDENCY PARSING
Timothy Dozat Stanford University tdozat@stanford.edu
Christopher D. Manning Stanford University manning@stanford.edu
# ABSTRACT
This paper builds off recent work from Kiperwasser & Goldberg (2016) using neural attention in a simple graph-based dependency parser. We use a larger but more thoroughly regularized parser than other recent BiLSTM-based approaches, with biaffine classifiers to predict arcs and labels. Our parser gets state of the art or near state of the art performance on standard treebanks for six different languages, achieving $9 5 . 7 \%$ UAS and $9 4 . 1 \%$ LAS on the most popular English PTB dataset. This makes it the highest-performing graph-based parser on this benchmark— outperforming Kiperwasser & Goldberg (2016) by $1 . 8 \%$ and $2 . 2 \%$ —and comparable to the highest performing transition-based parser (Kuncoro et al., 2016), which achieves $9 5 . 8 \%$ UAS and $9 4 . 6 \%$ LAS. We also show which hyperparameter choices had a significant effect on parsing accuracy, allowing us to achieve large gains over other graph-based approaches.
# 1 INTRODUCTION
Dependency parsers—which annotate sentences in a way designed to be easy for humans and computers alike to understand—have been found to be extremely useful for a sizable number of NLP tasks, especially those involving natural language understanding in some way (Bowman et al., 2016; Angeli et al., 2015; Levy & Goldberg, 2014; Toutanova et al., 2016; Parikh et al., 2015). However, frequent incorrect parses can severely inhibit final performance, so improving the quality of dependency parsers is needed for the improvement and success of these downstream tasks.
The current state-of-the-art transition-based neural dependency parser (Kuncoro et al., 2016) substantially outperforms many much simpler neural graph-based parsers. We modify the neural graphbased approach first proposed by Kiperwasser & Goldberg (2016) in a few ways to achieve competitive performance: we build a network that’s larger but uses more regularization; we replace the traditional MLP-based attention mechanism and affine label classifier with biaffine ones; and rather than using the top recurrent states of the LSTM in the biaffine transformations, we first put them through MLP operations that reduce their dimensionality. Furthermore, we compare models trained with different architectures and hyperparameters to motivate our approach empirically. The resulting parser maintains most of the simplicity of neural graph-based approaches while approaching the performance of the SOTA transition-based one.
# 2 BACKGROUND AND RELATED WORK
Transition-based parsers—such as shift-reduce parsers—parse sentences from left to right, maintaining a “buffer” of words that have not yet been parsed and a “stack” of words whose head has not been seen or whose dependents have not all been fully parsed. At each step, transition-based parsers can access and manipulate the stack and buffer and assign arcs from one word to another. One can then train any multi-class machine learning classifier on features extracted from the stack, buffer, and previous arc actions in order to predict the next action.
Chen & Manning (2014) make the first successful attempt at incorporating deep learning into a transition-based dependency parser. At each step, the (feedforward) network assigns a probability to each action the parser can take based on word, tag, and label embeddings from certain words on the stack and buffer. A number of other researchers have attempted to address some limitations of Chen & Manning’s Chen & Manning parser by augmenting it with additional complexity: Weiss et al. (2015) and Andor et al. (2016) augment it with a beam search and a conditional random field loss objective to allow the parser to “undo” previous actions once it finds evidence that they may have been incorrect; and Dyer et al. (2015) and (Kuncoro et al., 2016) instead use LSTMs to represent the stack and buffer, getting state-of-the-art performance by building in a way of composing parsed phrases together.
 Figure 1: A dependency tree parse for Casey hugged Kim, including part-of-speech tags and a special root token. Directed edges (or arcs) with labels (or relations) connect the verb to the root and the arguments to the verb head.
Transition-based parsing processes a sentence sequentially to build up a parse tree one arc at a time. Consequently, these parsers don’t use machine learning for directly predicting edges; they use it for predicting the operations of the transition algorithm. Graph-based parsers, by contrast, use machine learning to assign a weight or probability to each possible edge and then construct a maximum spaning tree (MST) from these weighted edges. Kiperwasser & Goldberg (2016) present a neural graph-based parser (in addition to a transition-based one) that uses the same kind of attention mechanism as Bahdanau et al. (2014) for machine translation. In Kiperwasser & Goldberg’s 2016 model, the (bidirectional) LSTM’s recurrent output vector for each word is concatenated with each possible head’s recurrent vector, and the result is used as input to an MLP that scores each resulting arc. The predicted tree structure at training time is the one where each word depends on its highestscoring head. Labels are generated analogously, with each word’s recurrent output vector and its gold or predicted head word’s recurrent vector being used in a multi-class MLP.
Similarly, Hashimoto et al. (2016) include a graph-based dependency parser in their multi-task neural model. In addition to training the model with multiple distinct objectives, they replace the traditional MLP-based attention mechanism that Kiperwasser & Goldberg (2016) use with a bilinear one (but still using an MLP label classifier). This makes it analogous to Luong et al.’s 2015 proposed attention mechanism for neural machine translation. Cheng et al. (2016) likewise propose a graph-based neural dependency parser, but in a way that attempts to circumvent the limitation of other neural graph-based parsers being unable to condition the scores of each possible arc on previous parsing decisions. In addition to having one bidirectional recurrent network that computes a recurrent hidden vector for each word, they have additional, unidirectional recurrent networks (leftto-right and right-to-left) that keep track of the probabilities of each previous arc, and use these together to predict the scores for the next arc.
# 3 PROPOSED DEPENDENCY PARSER
# 3.1 DEEP BIAFFINE ATTENTION
We make a few modifications to the graph-based architectures of Kiperwasser & Goldberg (2016), Hashimoto et al. (2016), and Cheng et al. (2016), shown in Figure 2: we use biaffine attention instead of bilinear or traditional MLP-based attention; we use a biaffine dependency label classifier; and we apply dimension-reducing MLPs to each recurrent output vector $\mathbf { r } _ { i }$ before applying the biaffine transformation.1 The choice of biaffine rather than bilinear or MLP mechanisms makes the classifiers in our model analogous to traditional affine classifiers, which use an affine transformation over a single LSTM output state $\mathbf { r } _ { i }$ (or other vector input) to predict the vector of scores $\mathbf { s } _ { i }$ for all classes (1). We can think of the proposed biaffine attention mechanism as being a traditional affine classifier, but using a $( d \times d )$ linear transformation of the stacked LSTM output $R U ^ { ( 1 ) }$ in place of the weight matrix $W$ and a $( d \times 1 )$ transformation $R \mathbf { u } ^ { ( 2 ) }$ for the bias term b (2).
 Figure 2: BiLSTM with deep biaffine attention to score each possible head for each dependent, applied to the sentence “Casey hugged Kim”. We reverse the order of the biaffine transformation here for clarity.
$${ \begin{array} { r l r } & { \qquad \mathbf { s } _ { i } = W \mathbf { r } _ { i } + \mathbf { b } } & { { \mathrm { F i r e d - c l a s s ~ a f f i n e ~ c l a s s i f i e r } } } \\ & { \mathbf { s } _ { i } ^ { ( a r c ) } = \left( R U ^ { ( 1 ) } \right) \mathbf { r } _ { i } + \left( R \mathbf { u } ^ { ( 2 ) } \right) } & { { \mathrm { V a r i a b l e - c l a s s ~ b i a f f i n e ~ c l a s s i f i e r } } } \end{array} }$$
In addition to being arguably simpler than the MLP-based approach (involving one bilinear layer rather than two linear layers and a nonlinearity), this has the conceptual advantage of directly modeling both the prior probability of a word $j$ receiving any dependents in the term $\mathbf { r } _ { j } ^ { \top } \mathbf { u } ^ { ( 2 ) }$ and the likelihood of $j$ receiving a specific dependent $i$ in the term $\mathbf { r } _ { j } ^ { \top } U ^ { ( 1 ) } \mathbf { r } _ { i }$ . Analogously, we also use a biaffine classifier to predict dependency labels given the gold or predicted head $y _ { i }$ (3).
$$\mathbf { s } _ { i } ^ { ( l a b e l ) } = \mathbf { r } _ { y _ { i } } ^ { \top } \mathbf { U } ^ { ( 1 ) } \mathbf { r } _ { i } + \left( \mathbf { r } _ { y _ { i } } \oplus \mathbf { r } _ { i } \right) ^ { \top } U ^ { ( 2 ) } + \mathbf { b }$$
Fixed-class biaffine classifier
This likewise directly models each of the prior probability of each class, the likelihood of a class given just word $i$ (how probable a word is to take a particular label), the likelihood of a class given just the head word $y _ { i }$ (how probable a word is to take dependents with a particular label), and the likelihood of a class given both word $i$ and its head (how probable a word is to take a particular label given that word’s head).
Applying smaller MLPs to the recurrent output states before the biaffine classifier has the advantage of stripping away information not relevant to the current decision. That is, every top recurrent state $\mathbf { r } _ { i }$ will need to carry enough information to identify word $i$ ’s head, find all its dependents, exclude all its non-dependents, assign itself the correct label, and assign all its dependents their correct labels, as well as transfer any relevant information to the recurrent states of words before and after it. Thus $\mathbf { r } _ { i }$ necessarily contains significantly more information than is needed to compute any individual score, and training on this superfluous information needlessly reduces parsing speed and increases the risk of overfitting. Reducing dimensionality and applying a nonlinearity $( 4 - 6 )$ addresses both of these problems. We call this a deep bilinear attention mechanism, as opposed to shallow bilinear attention, which uses the recurrent states directly.
$$\begin{array} { r l } & { \mathbf { h } _ { i } ^ { ( a r c - d e p ) } = \mathbf { M } \mathbf { L } \mathbf { P } ^ { ( a r c - d e p ) } ( \mathbf { r } _ { i } ) } \\ & { \mathbf { h } _ { j } ^ { ( a r c - h e a d ) } = \mathbf { M } \mathbf { L } \mathbf { P } ^ { ( a r c - h e a d ) } ( \mathbf { r } _ { j } ) } \\ & { \qquad \mathbf { s } _ { i } ^ { ( a r c ) } = H ^ { ( a r c - h e a d ) } U ^ { ( 1 ) } \mathbf { h } _ { i } ^ { ( a r c - d e p ) } } \\ & { \qquad + H ^ { ( a r c - h e a d ) } \mathbf { u } ^ { ( 2 ) } } \end{array}$$
We apply MLPs to the recurrent states before using them in the label classifier as well. As with other graph-based models, the predicted tree at training time is the one where each word is a dependent of its highest scoring head (although at test time we ensure that the parse is a well-formed tree via the MST algorithm).
# 3.2 HYPERPARAMETER CONFIGURATION
Table 1: Model hyperparameters
<table><tr><td>Param</td><td>Value</td><td>Param</td><td>Value</td></tr><tr><td>Embedding size</td><td>100</td><td>Embedding dropout</td><td>33%</td></tr><tr><td>LSTM size</td><td>400</td><td>LSTM dropout</td><td>33%</td></tr><tr><td>Arc MLP size</td><td>500</td><td>Arc MLP dropout</td><td>33%</td></tr><tr><td>Label MLP size</td><td>100</td><td>Label MLP dropout</td><td>33%</td></tr><tr><td>LSTM depth</td><td>3</td><td>MLP depth</td><td>1</td></tr><tr><td>α</td><td>2e-3</td><td>β1,β2</td><td>.9</td></tr><tr><td>Annealing</td><td>.755000</td><td>tmax</td><td>50.000</td></tr></table>
Aside from architectural differences between ours and the other graph-based parsers, we make a number of hyperparameter choices that allow us to outperform theirs, laid out in Table 1. We use 100-dimensional uncased word vectors2 and POS tag vectors; three BiLSTM layers (400 dimensions in each direction); and 500- and 100-dimensional ReLU MLP layers. We also apply dropout at every stage of the model: we drop words and tags (independently); we drop nodes in the LSTM layers (input and recurrent connections), applying the same dropout mask at every recurrent timestep (cf. the Bayesian dropout of Gal & Ghahramani (2015)); and we drop nodes in the MLP layers and classifiers, likewise applying the same dropout mask at every timestep. We optimize the network with annealed Adam (Kingma & Ba, 2014) for about 50,000 steps, rounded up to the nearest epoch.
# 4 EXPERIMENTS & RESULTS
# 4.1 DATASETS
We show test results for the proposed model on the English Penn Treebank, converted into Stanford Dependencies using both version 3.3.0 and version 3.5.0 of the Stanford Dependency converter (PTB-SD 3.3.0 and PTB-SD 3.5.0); the Chinese Penn Treebank; and the CoNLL 09 shared task dataset,3 following standard practices for each dataset. We omit punctuation from evaluation only for the PTB-SD and CTB. For the English PTB-SD datasets, we use POS tags generated from the Stanford POS tagger (Toutanova et al., 2003); for the Chinese PTB dataset we use gold tags; and for the CoNLL 09 dataset we use the provided predicted tags. Our hyperparameter search was done with the PTB-SD 3.5.0 validation dataset in order to minimize overfitting to the more popular PTB-SD 3.3.0 benchmark, and in our hyperparameter analysis in the following section we report performance on the PTB-SD 3.5.0 test set, shown in Tables 2 and 3.
# 4.2 HYPERPARAMETER CHOICES
# 4.2.1 ATTENTION MECHANISM
We examined the effect of different classifier architectures on accuracy and performance. What we see is that the deep bilinear model outperforms the others with respect to both speed and accuracy. The model with shallow bilinear arc and label classifiers gets the same unlabeled performance as the deep model with the same settings, but because the label classifier is much larger ( $( 8 0 1 \times c \times 8 0 1 )$ as opposed to $( 1 0 1 \times c \times 1 0 1 )$ ), it runs much slower and overfits. One way to decrease this overfitting is by increasing the MLP dropout, but that of course doesn’t change parsing speed; another way is to decrease the recurrent size to 300, but this hinders unlabeled accuracy without increasing parsing speed up to the same levels as our deeper model. We also implemented the MLP-based approach to attention and classification used in Kiperwasser & Goldberg (2016).4 We found this version to likewise be somewhat slower and significantly underperform the deep biaffine approach in both labeled and unlabeled accuracy.
<table><tr><td colspan="5">Classifier</td><td colspan="3">Size</td></tr><tr><td>Model</td><td>UAS</td><td>LAS</td><td>Sents/sec</td><td>Model</td><td>UAS</td><td>LAS</td><td></td><td>Sents/sec</td></tr><tr><td>Deep</td><td>95.75</td><td>94.22</td><td>410.91</td><td>3 layers,400d</td><td>95.75</td><td></td><td>94.22</td><td>410.91</td></tr><tr><td>Shallow</td><td>95.74</td><td>94.00*</td><td>298.99</td><td>3 layers,300d</td><td>95.82</td><td></td><td>94.24</td><td>460.01</td></tr><tr><td>Shallow, 50% drop</td><td>95.73</td><td>94.05*</td><td>300.04</td><td></td><td>3 layers,200d</td><td>95.55*</td><td>93.89*</td><td>469.45</td></tr><tr><td>Shallow, 300d</td><td>95.63*</td><td>93.86*</td><td>373.24</td><td>2 layers,400d</td><td></td><td>95.62*</td><td>93.98*</td><td>497.99</td></tr><tr><td>MLP</td><td>95.53*</td><td>93.91*</td><td>367.44</td><td>4 layers, 400d</td><td></td><td>95.83</td><td>94.22</td><td>362.09</td></tr><tr><td></td><td>Recurrent Cell</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Model</td><td>UAS</td><td>LAS</td><td></td><td>Sents/sec</td><td></td><td></td><td></td><td></td></tr><tr><td>LSTM</td><td>95.75</td><td>94.22</td><td>410.91</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>GRU</td><td>93.18*</td><td>91.08*</td><td>435.32</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Cif-LSTM</td><td>95.67</td><td>94.06*</td><td>463.25</td><td></td><td></td><td></td><td></td><td></td></tr></table>
Table 2: Test accuracy and speed on PTB-SD 3.5.0. Statistically significant differences are marked with an asterisk. Table 3: Test Accuracy on PTB-SD 3.5.0. Statistically significant differences are marked with an asterisk.
<table><tr><td colspan="4">Input Dropout</td><td colspan="2">Adam</td></tr><tr><td>Model</td><td>UAS</td><td>LAS</td><td>Model</td><td>UAS</td><td>LAS</td></tr><tr><td>Default</td><td>95.75</td><td>94.22</td><td>β=.9</td><td>95.75</td><td>94.22</td></tr><tr><td>No word dropout</td><td>95.74</td><td>94.08*</td><td>β2= .999</td><td>95.53*</td><td>93.91*</td></tr><tr><td>No tag dropout</td><td>95.28*</td><td>93.60*</td><td></td><td></td><td></td></tr><tr><td>No tags</td><td>95.77</td><td>93.91*</td><td></td><td></td><td></td></tr></table>
# 4.2.2 NETWORK SIZE
We also examine more closely how network size influences speed and accuracy. In Kiperwasser & Goldberg’s 2016 model, the network uses 2 layers of 125-dimensional bidirectional LSTMs; in Hashimoto et al.’s 2016 model, it has one layer of 100-dimensional bidirectional LSTMs dedicated to parsing (two lower layers are also trained on other objectives); and Cheng et al.’s 2016 model has one layer of 368-dimensional GRU cells. We find that using three or four layers gets significantly better performance than two layers, and increasing the LSTM sizes from 200 to 300 or 400 dimensions likewise signficantly improves performance.5
# 4.2.3 RECURRENT CELL
GRU cells have been promoted as a faster and simpler alternative to LSTM cells, and are used in the approach of Cheng et al. (2016); however, in our model they drastically underperformed LSTM cells. We also implemented the coupled input-forget gate LSTM cells (Cif-LSTM) suggested by Greff et al. (2015),6 finding that while the resulting model still slightly underperforms the more popular LSTM cells, the difference between the two is much smaller. Additionally, because the gate and candidate cell activations can be computed simultaneously with one matrix multiplication, the Cif-LSTM model is faster than the GRU version even though they have the same number of parameters. We hypothesize that the output gate in the Cif-LSTM model allows it to maintain a sparse recurrent output state, which helps it adapt to the high levels of dropout needed to prevent overfitting in a way that GRU cells are unable to do.
Table 4: Results on the English PTB and Chinese PTB parsing datasets
<table><tr><td rowspan="2">Type Model</td><td rowspan="2"></td><td colspan="2">English PTB-SD3.3.0</td><td colspan="2">Chinese PTB 5.1</td></tr><tr><td>UAS</td><td>LAS</td><td>UAS</td><td>LAS</td></tr><tr><td rowspan="4">Transition</td><td>Ballesteros et al. (2016)</td><td>93.56</td><td>91.42</td><td>87.65</td><td>86.21</td></tr><tr><td>Andor et al. (2016)</td><td>94.61</td><td>92.79</td><td>1</td><td>1</td></tr><tr><td>Kuncoro et al. (2016)</td><td>95.8</td><td>94.6</td><td>1</td><td>一</td></tr><tr><td>Kiperwasser & Goldberg (2016)</td><td>93.9</td><td>91.9</td><td>87.6</td><td>86.1</td></tr><tr><td rowspan="3">Graph</td><td>Cheng et al. (2016)</td><td>94.10</td><td>91.49</td><td>88.1</td><td>85.7</td></tr><tr><td>Hashimoto et al. (2016)</td><td>94.67</td><td>92.90</td><td>一</td><td></td></tr><tr><td>Deep Biaffine</td><td>95.74</td><td>94.08</td><td>89.30</td><td>88.23</td></tr></table>
Table 5: Results on the CoNLL $^ { , 0 9 }$ shared task datasets
<table><tr><td colspan="3">Catalan</td><td colspan="2">Chinese</td><td colspan="2">Czech</td></tr><tr><td>Model</td><td>UAS</td><td>LAS</td><td>UAS</td><td>LAS</td><td>UAS</td><td>LAS</td></tr><tr><td>Andor et al.</td><td>92.67</td><td>89.83</td><td>84.72</td><td>80.85</td><td>88.94</td><td>84.56</td></tr><tr><td>Deep Biaffine</td><td>94.69</td><td>92.02</td><td>88.90</td><td>85.38</td><td>92.08</td><td>87.38</td></tr><tr><td></td><td colspan="2">English</td><td colspan="2">German</td><td colspan="2">Spanish</td></tr><tr><td>Model</td><td>UAS</td><td>LAS</td><td>UAS</td><td>LAS</td><td>UAS</td><td>LAS</td></tr><tr><td>Andor et al.</td><td>93.22</td><td>91.23</td><td>90.91</td><td>89.15</td><td>92.62</td><td>89.95</td></tr><tr><td>Deep Biaffine</td><td>95.21</td><td>93.20</td><td>93.46</td><td>91.44</td><td>94.34</td><td>91.65</td></tr></table>
# 4.2.4 EMBEDDING DROPOUT
Because we increase the parser’s power, we also have to increase its regularization. In addition to using relatively extreme dropout in the recurrent and MLP layers mentioned in Table 1, we also regularize the input layer. We drop $33 \%$ of words and $33 \%$ of tags during training: when one is dropped the other is scaled by a factor of two to compensate, and when both are dropped together, the model simply gets an input of zeros. Models trained with only word or tag dropout but not both wind up signficantly overfitting, hindering label accuracy and—in the latter case—attachment accuracy. Interestingly, not using any tags at all actually results in better performance than using tags without dropout.
# 4.2.5 OPTIMIZER
We choose to optimize with Adam (Kingma & Ba, 2014), which (among other things) keeps a moving average of the $L _ { 2 }$ norm of the gradient for each parameter throughout training and divides the gradient for each parameter by this moving average, ensuring that the magnitude of the gradients will on average be close to one. However, we find that the value for $\beta _ { 2 }$ recommended by Kingma & Ba—which controls the decay rate for this moving average—is too high for this task (and we suspect more generally). When this value is very large, the magnitude of the current update is heavily influenced by the larger magnitude of gradients very far in the past, with the effect that the optimizer can’t adapt quickly to recent changes in the model. Thus we find that setting $\beta _ { 2 }$ to .9 instead of .999 makes a large positive impact on final performance.
# 4.3 RESULTS
Our model gets nearly the same UAS performance on PTB-SD 3.3.0 as the current SOTA model from Kuncoro et al. (2016) in spite of its substantially simpler architecture, and gets SOTA UAS performance on CTB $5 . 1 ^ { 7 }$ as well as SOTA performance on all CoNLL 09 languages. It is worth noting that the CoNLL 09 datasets contain many non-projective dependencies, which are difficult or impossible for transition-based—but not graph-based—parsers to predict. This may account for some of the large, consistent difference between our model and Andor et al.’s 2016 transition-based model applied to these datasets.
Where our model appears to lag behind the SOTA model is in LAS, indicating one of a few possibilities. Firstly, it may be the result of inefficiencies or errors in the GloVe embeddings or POS tagger, in which case using alternative pretrained embeddings or a more accurate tagger might improve label classification. Secondly, the SOTA model is specifically designed to capture phrasal compositionality; so another possibility is that ours doesn’t capture this compositionality as effectively, and that this results in a worse label score. Similarly, it may be the result of a more general limitation of graph-based parsers, which have access to less explicit syntactic information than transition-based parsers when making decisions. Addressing these latter two limitations would require a more innovative architecture than the relatively simple one used in current neural graph-based parsers.
# 5 CONCLUSION
In this paper we proposed using a modified version of bilinear attention in a neural dependency parser that increases parsing speed without hurting performance. We showed that our larger but more regularized network outperforms other neural graph-based parsers and gets comparable performance to the current SOTA transition-based parser. We also provided empirical motivation for the proposed architecture and configuration over similar ones in the existing literature. Future work will involve exploring ways of bridging the gap between labeled and unlabeled accuracy and augment the parser with a smarter way of handling out-of-vocabulary tokens for morphologically richer languages.
# REFERENCES
Daniel Andor, Chris Alberti, David Weiss, Aliaksei Severyn, Alessandro Presta, Kuzman Ganchev, Slav Petrov, and Michael Collins. Globally normalized transition-based neural networks. In Association for Computational Linguistics, 2016. URL https://arxiv.org/abs/1603. 06042.
Gabor Angeli, Melvin Johnson Premkumar, and Christopher D Manning. Leveraging linguistic structure for open domain information extraction. In Proceedings of the 53rd Annual Meeting of the Association for Computational Linguistics (ACL 2015), 2015.
Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. International Conference on Learning Representations, 2014.
Miguel Ballesteros, Yoav Goldberg, Chris Dyer, and Noah A Smith. Training with exploration improves a greedy stack-LSTM parser. Proceedings of the conference on empirical methods in natural language processing, 2016.
Samuel R Bowman, Jon Gauthier, Abhinav Rastogi, Raghav Gupta, Christopher D Manning, and Christopher Potts. A fast unified model for parsing and sentence understanding. ACL 2016, 2016.
Danqi Chen and Christopher D Manning. A fast and accurate dependency parser using neural networks. In Proceedings of the conference on empirical methods in natural language processing, pp. 740–750, 2014.
Hao Cheng, Hao Fang, Xiaodong He, Jianfeng Gao, and Li Deng. Bi-directional attention with agreement for dependency parsing. arXiv preprint arXiv:1608.02076, 2016.
Chris Dyer, Miguel Ballesteros, Wang Ling, Austin Matthews, and Noah A Smith. Transitionbased dependency parsing with stack long short-term memory. Proceedings of the conference on empirical methods in natural language processing, 2015.
Yarin Gal and Zoubin Ghahramani. Dropout as a bayesian approximation: Representing model uncertainty in deep learning. International Conference on Machine Learning, 2015.
Klaus Greff, Rupesh Kumar Srivastava, Jan Koutn´ık, Bas R Steunebrink, and Jurgen Schmidhuber. ¨ LSTM: A search space odyssey. IEEE Transactions on Neural Networks and Learning Systems, 2015.
Kazuma Hashimoto, Caiming Xiong, Yoshimasa Tsuruoka, and Richard Socher. A joint many-task model: Growing a neural network for multiple nlp tasks. arXiv preprint arXiv:1611.01587, 2016.
Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. International Conference on Learning Representations, 2014.
Eliyahu Kiperwasser and Yoav Goldberg. Simple and accurate dependency parsing using bidirectional LSTM feature representations. Transactions of the Association for Computational Linguistics, 4:313–327, 2016.
Adhiguna Kuncoro, Miguel Ballesteros, Lingpeng Kong, Chris Dyer, Graham Neubig, and Noah A. Smith. What do recurrent neural network grammars learn about syntax? CoRR, abs/1611.05774, 2016. URL http://arxiv.org/abs/1611.05774.
Omer Levy and Yoav Goldberg. Dependency-based word embeddings. In ACL 2014, pp. 302–308, 2014.
Minh-Thang Luong, Hieu Pham, and Christopher D Manning. Effective approaches to attentionbased neural machine translation. Empirical Methods in Natural Language Processing, 2015.
Ankur P Parikh, Hoifung Poon, and Kristina Toutanova. Grounded semantic parsing for complex knowledge extraction. In Proceedings of North American Chapter of the Association for Computational Linguistics, pp. 756–766, 2015.
Kristina Toutanova, Dan Klein, Christopher D Manning, and Yoram Singer. Feature-rich part-ofspeech tagging with a cyclic dependency network. In Proceedings of the 2003 Conference of the North American Chapter of the Association for Computational Linguistics on Human Language Technology-Volume 1, pp. 173–180. Association for Computational Linguistics, 2003.
Kristina Toutanova, Xi Victoria Lin, and Wen-tau Yih. Compositional learning of embeddings for relation paths in knowledge bases and text. In ACL, 2016.
David Weiss, Chris Alberti, Michael Collins, and Slav Petrov. Structured training for neural network transition-based parsing. Annual Meeting of the Association for Computational Linguistics, 2015.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475# MIXED PRECISION DNNS: ALL YOU NEED IS A GOOD PARAMETRIZATION
Stefan Uhlich∗, Lukas Mauch∗, Fabien Cardinaux∗, Kazuki Yoshiyama Javier Alonso García, Stephen Tiedemann, Thomas Kemp
Sony Europe B.V., Germany firstname.lastname@sony.com
Akira Nakamura Sony Corporate, Japan akira.b.nakamura@sony.com
# ABSTRACT
Efficient deep neural network (DNN) inference on mobile or embedded devices typically involves quantization of the network parameters and activations. In particular, mixed precision networks achieve better performance than networks with homogeneous bitwidth for the same size constraint. Since choosing the optimal bitwidths is not straight forward, training methods, which can learn them, are desirable. Differentiable quantization with straight-through gradients allows to learn the quantizer’s parameters using gradient methods. We show that a suited parametrization of the quantizer is the key to achieve a stable training and a good final performance. Specifically, we propose to parametrize the quantizer with the step size and dynamic range. The bitwidth can then be inferred from them. Other parametrizations, which explicitly use the bitwidth, consistently perform worse. We confirm our findings with experiments on CIFAR-10 and ImageNet and we obtain mixed precision DNNs with learned quantization parameters, achieving state-of-the-art performance.
# 1 INTRODUCTION
Quantized DNNs apply quantizers $Q : \mathbb { R } \{ q _ { 1 } , . . . , q _ { I } \}$ to discretize the weights and/or activations of a DNN (Han et al., 2015; Zhou et al., 2017; Li et al., 2016; Liu & Mattina, 2019; Cardinaux et al., 2018; Jain et al., 2019; Bai et al., 2018). They require considerably less memory and have a lower computational complexity, since discretized values $\{ q _ { 1 } , . . . , q _ { I } \}$ can be stored, multiplied and accumulated efficiently. This is particularly relevant for inference on mobile or embedded devices with limited computational power.
However, gradient based training of quantized DNNs is difficult, as the gradient of a quantization function vanishes almost everywhere, i.e., backpropagation through a quantized DNN almost always returns a zero gradient. Different solutions to this problem have been proposed in the literature: A first possibility is to use DNNs with stochastic weights from a categorical distribution and to optimize the evidence lower bound (ELBO) to obtain an estimate of the posterior distribution of the weights. As proposed in (Jang et al., 2016; Maddison et al., 2016; Louizos et al., 2019), the categorical distribution can be relaxed to a concrete distribution – a smoothed approximation of the categorical distribution – such that the ELBO becomes differentiable under reparametrization. A second possibility is to use the straight through estimator (STE) (Bengio et al., 2013). STE allows the gradients to be backpropagated through the quantizers and, thus, the network weights can be adapted with standard gradient descent (Hubara et al., 2016). Compared to STE based methods, stochastic methods suffer from large gradient variance, which makes training of large quantized DNNs difficult. Therefore, STE based methods are more popular in practice.
More recent research (Jain et al., 2019; Esser et al., 2019; Wang et al., 2018; Elthakeb et al., 2018) focuses on methods which can also learn the optimal quantization parameters, e.g., the stepsize, dynamic range and bitwidth, in parallel to the network weights. This is a promising approach as DNNs with learned quantization parameters almost always outperform DNNs with handcrafted ones.
Recently, and in parallel to our work, (Jain et al., 2019) explored the use of STE to define the gradient with respect to the quantizers’s dynamic range. The authors applied a per-tensor quantization and used the dynamic range as an additional trainable parameter also learned with gradient descent. Similarly, (Esser et al., 2019) learned the stepsize using gradient descent. However, neither of them learned the optimal bitwidth of the quantizers.
One approach was proposed in (Wang et al., 2018; Elthakeb et al., 2018). They learn the bitwidth with reinforcement learning, i.e., they learn an optimal bitwidth assignment policy. Their experiments show that a DNN with a learned and heterogeneous bitwidth assignment outperforms quantized DNNs with a homogeneous bitwidth assignment. However, such methods have a high computational complexity as the bitwidth policy must be learned, which involves training many quantized DNNs.
In this paper, we will use the STE approach and show that the quantizer’s parameters, including the bitwidth, can be learned with gradient methods if a good parametrization is chosen. Specifically, we show that directly learning the bitwidth is not optimal. Instead, we propose to learn the stepsize and dynamic range. The bitwidth can then be inferred from them. Compared to (Wang et al., 2018; Elthakeb et al., 2018), our method has the advantage that training quantized DNNs has nearly the same computational complexity as standard float32 training.
The contributions of this paper are:
1. We show that there are three different parametrizations for uniform and power-of-two quantization and that, in both cases, one of them has gradients particularly well suited to train quantized DNNs. The other parametrizations have the problem of yielding gradients with an unbounded gradient norm and coupled components.
2. Using this parametrization, we are able to learn all quantization parameters for DNNs with per-tensor quantization and global memory constraints. We formulate the training as a constrained optimization problem, where the quantized DNN is constrained not to exceed a given overall memory budget, and show how to solve it in a penalty framework.
3. We confirm our findings with experiments on CIFAR-10 and ImageNet. For example, we train a heterogeneously quantized MobileNetV2 on ImageNet requiring a total of only 1.65MB to store the weights and only 0.57MB to store its largest feature map. This is equivalent to a homogenous 4bit quantization of both weights and activations. However, our network learns to allocate the bitwidth heterogeneously in an optimal way. Our MobileNetV2 achieves an error of $3 0 . 2 6 \%$ compared to $2 9 . 8 2 \%$ for the floating point baseline. This is state-of-the-art for such a heavily quantized MobileNetV2.
We use the following notation throughout this paper: x, x, $\mathbf { X }$ and $_ { x }$ denote a scalar, a (column) vector, a matrix and a tensor with three or four dimensions, respectively; $\lfloor . \rfloor$ and d.e are the floor and ceiling operators. Finally, $\delta ( . )$ denotes the Dirac delta function.
# 2 CHOOSING A QUANTIZATION PARAMETRIZATION
Let $Q ( x ; \pmb \theta )$ be a quantizer with the parameters $\pmb { \theta }$ , which maps $x \in \mathbb { R }$ to discrete values $\{ q _ { 1 } , . . . , q _ { I } \}$ . In this section, we compare different parametrizations of $Q ( x ; \pmb \theta )$ for uniform quantization and powerof-two quantization and analyze how well the corresponding straight-through gradient estimates $\partial _ { x } Q ( x ; \pmb \theta )$ and $\nabla _ { \boldsymbol { \theta } } Q ( x ; \boldsymbol { \theta } )$ are suited to optimize the quantizer parameters $\pmb \theta$ . Our key result is, that the training of quantized DNNs which learns both, the optimal quantized weights and the optimal quantization parameters $\pmb \theta$ , is very sensitive to the choice of the parametrization of the quantizers. From an optimization point of view, it is best to parametrize the quantizer $Q ( x ; \pmb \theta )$ with the stepsize $d$ and the dynamic range $q _ { \mathrm { m a x } }$ as it leads to gradients with stable norms. Doing so, we can use standard gradient descent to learn the quantization parameters and do not need to use stochastic or reinforcement based algorithms, which are computationally expensive.
# 2.1 PARAMETRIZATION AND STRAIGHT THROUGH GRADIENT ESTIMATES
A symmetric uniform quantizer $Q _ { U } ( x ; \theta )$ which maps a real value $x \in \mathbb { R }$ to one of $I = 2 k + 1$ quantized values $q \in \{ - k d , . . . , 0 , . . . , k d \}$ computes
$$\begin{array} { r } { q = Q _ { U } ( x ; \theta ) = \mathrm { s i g n } ( x ) \left\{ \begin{array} { l l } { d \left\lfloor \frac { | x | } { d } + \frac { 1 } { 2 } \right\rfloor } & { | x | \le q _ { \mathrm { m a x } } } \\ { q _ { \mathrm { m a x } } } & { | x | > q _ { \mathrm { m a x } } } \end{array} \right. , } \end{array}$$
 Figure 1: Maximum gradient norm $\operatorname* { m a x } _ { x } \| \pmb { \nabla } _ { \pmb { \theta } } Q _ { U } ( x ; \pmb { \theta } ) \|$ . For “U1” and “U2” the maximum gradient norm can grow exponentially with varying bitwidth $b$ whereas it is bounded for “U3”.
where the parameter vector $\pmb { \theta } = [ d , q _ { \mathrm { m a x } } , b ] ^ { T }$ consists of the step size $d \in \mathbb { R }$ , the maximum value $q _ { \operatorname* { m a x } } \in \mathbb { R }$ and the number of bits $b \in \mathbb { N } , b \geq 2$ used to encode the quantized values $q$ .
When training quantized DNNs, we want to optimize $Q _ { U } ( x ; \theta )$ with respect to the input $x$ and the quantization parameters $\pmb \theta$ , meaning that we need the gradients $\nabla _ { \boldsymbol { x } } Q _ { U } ( \boldsymbol { x } ; \boldsymbol { \theta } )$ and $\nabla _ { \boldsymbol { \theta } } Q ( x ; \boldsymbol { \theta } )$ . A common problem is, that the exact gradients are not useful for training. For example, $\partial _ { x } Q _ { U } ( x ; \pmb \theta ) =$ $d \textstyle \sum _ { k = - 2 ^ { b - 1 } + 1 } ^ { 2 ^ { b - 1 } - 2 } \delta \left( x - d \left( k + { \frac { 1 } { 2 } } \right) \right)$ vanishes almost everywhere. A solution is to define the derivative using STE (Bengio et al., 2013), which ignores the floor operation in (1). This leads to
$$\partial _ { x } Q _ { U } ( x ) = \left\{ 1 \ \begin{array} { l l } { { | x | \leq q _ { \mathrm { m a x } } } } \\ { { 0 } } & { { | x | > q _ { \mathrm { m a x } } } } \end{array} , \right.$$
which is non-zero in the interesting region $| x | \leq q _ { \mathrm { m a x } }$ and which turned out to be very useful to train quantized DNNs in practice (Yin et al., 2019). In this work, we follow this idea and define the gradients $\nabla _ { x } Q ( x ; \theta )$ and $\nabla _ { \boldsymbol { \theta } } Q ( x ; \boldsymbol { \theta } )$ , using STE whenever we need to differentiate a floor operation. We refer to this as differentiable quantization (DQ).
An important observation from (1) is that the parameters $\pmb { \theta } = [ d , q _ { \mathrm { m a x } } , b ] ^ { T }$ of a quantizer depend on each other, i.e., $q _ { \operatorname* { m a x } } = ( 2 ^ { b - 1 } - 1 ) d$ . This means, that we can choose from three equivalent parametrizations of $Q _ { U } ( x ; \theta )$ : Case “U1” with $\pmb { \theta } = [ b , d ] ^ { T }$ , case “U2” with $\pmb { \theta } = [ b , q _ { \mathrm { m a x } } ] ^ { T }$ and case “U3” with $\pmb { \theta } = [ d , q _ { \mathrm { m a x } } ] ^ { T }$ . Interestingly, they differ in their gradients:
Case $U I$ : Parametrization with respect to $\pmb { \theta } = [ b , d ] ^ { T }$ , using $q _ { \operatorname* { m a x } } = q _ { \operatorname* { m a x } } ( b , d )$ gives
$$\nabla _ { \theta } Q _ { U } ( x ; \theta ) = \left[ \partial _ { b } Q _ { U } ( x ; \theta ) \right] = \left\{ \begin{array} { l l } { \left[ \frac { 0 } { 4 } \right] \left( Q _ { U } ( x ; \theta ) - x \right) } & { | x | \leq ( 2 ^ { b - 1 } - 1 ) d } \\ { \left[ 2 ^ { b - 1 } \log ( 2 ) d \right] \quad \mathrm { s i g n } ( x ) } & { | x | > ( 2 ^ { b - 1 } - 1 ) d } \end{array} \right.$$
Case $U 2$ : Parametrization with respect to $\pmb { \theta } = [ b , q _ { \mathrm { m a x } } ] ^ { T }$ , using $d = d ( b , q _ { \mathrm { m a x } } )$ gives
$$\nabla _ { \theta } Q _ { U } ( { x } ; \theta ) = \left[ \begin{array} { l } { \partial _ { b } Q _ { U } ( { x } ; \theta ) } \\ { \partial _ { q _ { \operatorname* { m a x } } } Q _ { U } ( { x } ; \theta ) } \end{array} \right] = \left\{ \begin{array} { l l } { \left[ \begin{array} { l } { - \frac { 2 ^ { b - 1 } \log 2 } { 2 ^ { b - 1 } - 1 } } \\ { \phantom { - } \frac { 1 } { q _ { \operatorname* { m a x } } } } \end{array} \right] \left( Q _ { U } ( { x } ; \theta ) - { x } \right) } & { \left| { x } \right| \leq q _ { \operatorname* { m a x } } } \\ { \left[ \begin{array} { l } { 0 } \\ { \mathrm { s i g n } ( { x } ) } \end{array} \right] } & { \left| { x } \right| > q _ { \operatorname* { m a x } } } \end{array} \right.$$
Case $U 3$ : Parametrization with respect to $\pmb { \theta } = [ d , q _ { \mathrm { m a x } } ] ^ { T }$ , using $b = b ( d , q _ { \mathrm { m a x } } )$ gives
$$\nabla _ { \theta } Q _ { U } ( x ; \theta ) = \left[ \partial _ { q _ { \mathrm { m a x } } } Q _ { U } ( x ; \theta ) \right] = \left\{ \begin{array} { l l } { \left[ \frac { 1 } { d } \right] \left( Q _ { U } ( x ; \theta ) - x \right) } & { | x | \leq q _ { \mathrm { m a x } } } \\ { \left[ 0 \right] } & { \left[ x \right] > q _ { \mathrm { m a x } } } \end{array} \right.$$
Fig. 1 shows the maximum gradient norm $\operatorname* { m a x } _ { x } \| \nabla _ { \theta } Q _ { U } ( x ; \pmb { \theta } ) \|$ for the three parametrizations “U1” to “U3”. For the parametrizations “U1” and “U2”, $\operatorname* { m a x } _ { x } \| \pmb { \nabla } _ { \pmb { \theta } } Q _ { U } ( x ; \pmb { \theta } ) \|$ can grow exponentially with varying bitwidth $b$ as $\partial _ { d } Q _ { U } ( x ; \pmb \theta ) \in [ - 2 ^ { b - 1 } - 1 , 2 ^ { b - 1 } - 1 ]$ for “U1” and $\partial _ { b } Q _ { U } ( x ; \pmb \theta ) \ \in$ $\begin{array} { r } { \left[ - { \frac { q _ { m a x } } { 2 ^ { b - 1 } - 1 } } \log 2 , { \frac { q _ { m a x } } { 2 ^ { b - 1 } - 1 } } \log 2 \right] } \end{array}$ for “U2”. This is not desirable when training quantized DNNs, because it will lead to large changes of the gradient norm and forces us to use small learning rates to avoid divergence. However, parametrization “U3” does not suffer from such an unbounded gradient norm as both partial derivatives $\partial _ { d } Q _ { U } ( x ; \pmb \theta ) \in [ - \frac { 1 } { 2 } , \frac { 1 } { 2 } ]$ and $\partial _ { q _ { \mathrm { m a x } } } Q _ { U } ( x ; \pmb \theta ) \in \{ - 1 , 1 \}$ are bounded.
 Figure 2: Partial derivatives of $Q _ { U } ( x ; \theta )$ with respect to the input and the quantization parameters $d , q _ { \mathrm { m a x } }$ and $b$ . Partial derivatives are coupled for “U1” and “U2” but are decoupled for “U3”.
Fig. 2 shows the gradients for the parametrization “U1” to “U3”. For parametrization “U3”, the partial derivatives in $\nabla _ { \boldsymbol { \theta } } Q _ { U } ( \boldsymbol { x } ; \boldsymbol { \theta } )$ are decoupled, i.e., $\nabla _ { \boldsymbol { \theta } } Q _ { U } ( \boldsymbol { x } ; \boldsymbol { \theta } )$ is a unit vector, which either points only in the direction of $d$ if $| x | \leq q _ { \mathrm { m a x } }$ or only in the direction of $q _ { \mathrm { m a x } }$ , if $| x | > q _ { \mathrm { m a x } }$ . We will show in Sec. 2.3 that this implies a diagonal Hessian, which results in a better convergence behavior of gradient descent. In contrast, both parametrizations “U1” and “U2” have partial derivatives that are coupled. In summary, this implies that parametrization “U3” is the best DQ parametrization.
Similar considerations can be made for the power-of-two quantization $Q _ { P } ( x ; \theta )$ , which maps a real-valued number $x \in \mathbb { R }$ to a quantized value $q \in \{ \pm 2 ^ { k } : k ^ { \mathbf { \bar { \alpha } } } \in \mathbb { Z } \}$ by
$$q = Q _ { P } ( x ; \pmb \theta ) = \mathrm { s i g n } ( x ) \left\{ \begin{array} { l l } { q _ { \mathrm { m i n } } } & { | x | \leq q _ { \mathrm { m i n } } } \\ { 2 ^ { \lfloor 0 . 5 + \log _ { 2 } \left| x \right| \rfloor } } & { q _ { \mathrm { m i n } } < \left| x \right| \leq q _ { \mathrm { m a x } } } \\ { q _ { \mathrm { m a x } } } & { | x | > q _ { \mathrm { m a x } } } \end{array} , \right.$$
where $q _ { \mathrm { m i n } }$ and $q _ { \mathrm { m a x } }$ are the minimum and maximum absolute values of the quantizer for a bitwidth of $b$ bit. Power-of-two quantization is an especially interesting scheme for DNN quantization, since a multiplication of quantized values can be implemented as an addition of the exponents. Using the STE for the floor operation, the derivative $\partial _ { x } \bar { Q } _ { P } ( x ; \theta )$ is given by
$$\partial _ { x } Q _ { P } ( x ) = \left\{ \begin{array} { l l } { 0 } & { | x | \le q _ { \mathrm { m i n } } } \\ { \frac { 2 ^ { \lfloor 0 . 5 + \log _ { 2 } \lvert x \rvert \rfloor } } { \lvert x \rvert } } & { q _ { \mathrm { m i n } } < \lvert x \rvert \le q _ { \mathrm { m a x } } } \\ { 0 } & { \lvert x \rvert > q _ { \mathrm { m a x } } } \end{array} \right. .$$
The power-of-two quantization each other with the relationship ters . Th $[ b , q _ { \mathrm { m i n } } , q _ { \mathrm { m a x } } ] \ = : \ \theta$ , which depend ongain three different $q _ { \mathrm { m a x } } \ = \ 2 ^ { 2 ^ { b - 1 } - 1 } q _ { \mathrm { m i n } }$ parametrizations with $\pmb \theta = [ b , q _ { \mathrm { m i n } } ]$ , $\theta = [ b , q _ { \mathrm { m a x } } ]$ or $\pmb { \theta } = [ q _ { \mathrm { m i n } } , q _ { \mathrm { m a x } } ]$ , respectively. Similarly to the uniform case, one parametrization $\Theta = [ q _ { \mathrm { m i n } } , q _ { \mathrm { m a x } } ] )$ leads to a gradient of a very simple form
$$\pmb { \nabla } _ { \theta } Q _ { P } ( x ; \pmb { \theta } ) = \left[ \partial _ { q _ { \operatorname* { m a x } } } Q _ { U } ( x ; \pmb { \theta } ) \right] = \left\{ \begin{array} { l l } { [ 1 , 0 ] ^ { T } } & { | x | \leq q _ { \operatorname* { m i n } } } \\ { [ 0 , 0 ] ^ { T } } & { q _ { \operatorname* { m i n } } < | x | \leq q _ { \operatorname* { m a x } } , } \\ { [ 0 , 1 ] ^ { T } } & { | x | > q _ { \operatorname* { m a x } } } \end{array} \right.$$
which has again a bounded gradient magnitude and independent components and is, hence, best suited for first order gradient based optimization.
# 2.2 CONSTRAINTS ON $\theta$
In practice, for an efficient hardware implementation, we need to ensure that the quantization parameters only take specific discrete values: for uniform quantization, only integer values are allowed for the bitwidth $b$ , and the stepsize $d$ must be a power-of-two, see e.g. (Jain et al., 2019); for power-of-two quantization, the bitwidth must be an integer, and the minimum and maximum absolute values $q _ { \mathrm { m i n } }$ and $q _ { \mathrm { m a x } }$ must be powers-of-two.
We fulfill these constraints by rounding the parameters in the forward pass to the closest integer or power-of-two value. In the backward pass we update the original float values, i.e., we used again the STE to propagate the gradients.
# 2.3 EXPERIMENTAL COMPARISON OF DQ PARAMETRIZATIONS
In the following we compare the parametrizations using two experiments.
 Figure 3: MSE for quantizing Gaussian data $x \sim N ( 0 , 1 )$ with uniform and power-of-two quantization. Parametrizations “U3” and “P3” converge to the lowest MSE without any oscillations.
1) Quantization of Gaussian data In our first experiment we use DQ to learn the optimal quantization parameters $\pmb { \theta } ^ { * }$ which minimize the mean squared error (MSE) $\mathrm { E } \left[ \textstyle { \frac { 1 } { 2 } } ( Q ( x ; \mathbf { \dot { \theta } } ) - x ) ^ { \cdot } 2 \right]$ with gradient descent and compare the convergence speed for three possible parametrizations of a uniform and power-of-two quantizer. We choose this example as the gradient $\nabla _ { \theta } Q ( x ; \theta ) \ =$ $\mathrm { E } \left[ ( Q ( x ; \pmb { \theta } ) - \overset { \cdot } { x } ) \pmb { \nabla } _ { \theta } Q ( x ; \pmb { \theta } ) \right]$ is just a scaled version of $\nabla _ { \boldsymbol { \theta } } Q ( { \bar { x } } ; { \boldsymbol { \theta } } )$ , i.e., the gradient direction depends directly on the parametrization of $Q ( x ; \pmb \theta )$ and thus the effects of changing the parametrization can be observed.
It is interesting to study the Hessian $\mathbf { H } = \pmb { \nabla } _ { \pmb { \theta } } \pmb { \nabla } _ { \pmb { \theta } } ^ { T } \mathrm { E } \left[ ( Q ( x ; \pmb { \theta } ) - x ) ^ { 2 } \right] \in \mathbb { R } ^ { 2 \times 2 }$ of the MSE:
$$\mathbf { I } = \operatorname { E } \left[ \nabla _ { \theta } Q ( x ; \theta ) \nabla _ { \theta } Q ( x ; \theta ) ^ { T } + ( Q ( x ; \theta ) - x ) \nabla _ { \theta } \nabla _ { \theta } ^ { T } Q ( x ; \theta ) \right] \approx \operatorname { E } \left[ \nabla _ { \theta } Q ( x ; \theta ) \nabla _ { \theta } Q ( x ; \theta ) ^ { T } \right] .$$
Note that we use the outer-product approximation (Bishop, 2006) in order to simplify our considerations. From this equation it is apparent that the Hessian will be diagonal for the case U3 as $\pmb { \nabla } _ { \theta } Q ( x ; \pmb { \theta } ) \pmb { \nabla } _ { \theta } Q ( x ; \mathbf { \bar { \theta } } ) ^ { T }$ only contains an element in either $( 1 , 1 )$ or $( 2 , 2 )$ and, therefore, $\mathrm { E } \left[ \pmb { \nabla } _ { \pmb { \theta } } Q ( \pmb { x } ; \pmb { \theta } ) \pmb { \nabla } _ { \pmb { \theta } } Q ( \pmb { x } ; \pmb { \theta } ) ^ { T } \right]$ is a diagonal matrix. From this, we can see that gradient descent with an individual learning rate for each parameter is equivalent to Newton’s method and, therefore, efficient. In general this will not be the case for U1 and U2.
We conduct an experiment, using ADAM to optimize the mean squared quantization error on artificially generated data, which is generated by drawing $1 0 ^ { 4 }$ samples from $N ( 0 , 1 )$ . Please note that the same example was studied in (Jain et al., 2019). The results in Fig. 3 clearly show that the parametrizations “U3” and “P3” are best suited to optimize the uniform and power-of-two quantization parameters, respectively. Indeed, these quantizers converge without oscillation to the lowest MSE. It is interesting to see, that even adaptive gradient methods like ADAM can not solve the scaling issue described in Sec. 2.1. In the Appendix A.4 we give further empirical evidence to support this claim and compare the different parametrizations for the training of a quantized ResNet-20 on CIFAR-10 using ADAM. Note that all cases use the same learning rate. For the interested reader, a more detailed visualization of the error surfaces over the quantization parameters can be found in Appendix A.3.
2) CIFAR-10 In our second experiment we train a ResNet-20 (He et al., 2016) with quantized parameters and activations on CIFAR-10 (Krizhevsky & Hinton, 2009) using the same settings as proposed by (He et al., 2016). Fig. 4 shows the evolution of the training and validation error during training for the case of uniform quantization. The plots for power-of-two quantization can be found in the appendix (Fig. 10). We initialize this network from random parameters or from a pre-trained float network. The quantized DNNs are trained for 160 epochs, using SGD with momentum 0.9 and a learning rate schedule starting with 0.01 and reducing it by a factor of 10 after 80 and 120 epochs, respectively. We use random flips and crops for data augmentation. Each epoch takes about $2 . 5 \mathrm { { m i n } }$ on a single GTX 1080 Ti.
In case of randomly initialized weights, we use an initial stepsize $d _ { l } = 2 ^ { - 3 }$ for the quantization of weights and activations. Otherwise, we initialize the weights using a pre-trained floating point network and the initial stepsize for a layer is chosen to be $\bar { d } _ { l } = 2 \bar { \lfloor \log _ { 2 } ( \operatorname* { m a x } \mid \mathscr { W } _ { l } \mid / ( 2 ^ { b - 1 } - 1 ) ) \rfloor }$ . The remaining quantization parameters are chosen such that we start from an initial bitwidth of $b = 4$ bit. This is a reasonable upper limit for $b$ , as in practice no performance degradation can be observed for $b >$ 4bit. Even simple offline algorithms like min/max quantization result in networks with good accuracies. We define no memory constraints during training, i.e., the network can learn to use a large number of bits to quantize weights and activations of each layer. From Fig. 4, we again observe that the parametrization $\pmb { \theta } = [ d , q _ { \mathrm { m a x } } ] ^ { T }$ is best suited to train a uniformly quantized DNN as it converges to the best local optimum. Furthermore, we observe the smallest oscillation of the validation error for this parametrization.
 Figure 4: ResNet-20 with uniformly quantized weights and activations.
Table 1 compares the best validation error for all parametrizations of the uniform and power-of-two quantizations. We trained networks either with quantized weights and full precision activations or with both being quantized. In case of activation quantization with power-of-two, we use one bit to explicitly represent the value $x = 0$ . This is advantageous as the ReLU nonlinearity will map many activations to this value. We can observe that training the quantized DNN with the optimal parametrization of DQ, i.e., using either $\pmb { \theta } = [ d , q _ { \mathrm { m a x } } ] ^ { T }$ or $\pmb { \theta } \overset { - } { = } [ q _ { \mathrm { m i n } } , q _ { \mathrm { m a x } } ] ^ { T }$ results in a network with the lowest validation error. This result again supports our theoretical considerations from Sec. 2.1.
# 3 TRAINING QUANTIZED DNNS WITH MEMORY CONSTRAINTS
We now discuss how to train quantized DNNs with memory constraints. Such constraints appear in many applications when the network inference is performed on an embedded device with limited computational power and memory resources.
A quantized DNN consists of layers which compute
$$\pmb { \mathcal { X } } _ { l } = f _ { l } ( Q ( \pmb { \mathcal { W } } _ { l } ; \pmb { \theta } _ { l } ^ { w } ) * Q ( \pmb { \mathcal { X } } _ { l - 1 } ; \pmb { \theta } _ { l - 1 } ^ { x } ) + Q ( \pmb { c } _ { l } ; \pmb { \theta } _ { l } ^ { w } ) ) \ \mathrm { w i t h } \ l = 1 , . . . , L ,$$
where $f _ { l } ( \cdot )$ denotes the nonlinear activation function of layer $l$ and $Q ( \cdot ; \theta )$ is a per-tensor quantization with parameters $\pmb \theta$ applied separately to the input and output tensors $\pmb { \mathcal { X } } _ { l - 1 } \in \mathcal { T } _ { l }$ and $\pmb { \chi } _ { l } \in \mathcal { T } _ { l }$ , and also to both the weight tensors $w _ { l } \in \mathcal { P } _ { l }$ and the bias vector $\mathbf { \boldsymbol { c } } _ { l } \in \mathbb { R } ^ { M _ { l } }$ .1 For a fully connected layer, $\mathcal { T } _ { l - 1 } = \mathbb { R } ^ { M _ { l - 1 } }$ , $\mathcal { T } _ { l } = \mathbb { R } ^ { M _ { l } }$ are vectors, $\mathcal { P } _ { l } = \mathbb { R } ^ { M _ { l } \times M _ { l - 1 } }$ are matrices and $A * B$ is a matrixvector product. In case of a convolutional layer, $\mathcal { T } _ { l - 1 } = \mathbb { R } ^ { M _ { l - 1 } \times N _ { l - 1 } \times N _ { l - 1 } }$ , $\mathcal { T } _ { l } = \mathbb { R } ^ { M _ { l } \times N _ { l } \times N _ { l } }$ , $\mathcal { P } _ { l } = \dot { \mathbb { R } } ^ { M _ { l } \times M _ { l - 1 } \times K _ { l } \times K _ { l } }$ are tensors and $A * B$ is a set of $M _ { l - 1 } M _ { l }$ 2D convolutions, where the convolution is performed on square-sized feature maps of size $N _ { l - 1 } \times N _ { l - 1 }$ using square-sized kernels of size $K _ { l } \times K _ { l }$ .
DNNs with quantized weights and activations have a smaller memory footprint and are also computationally cheaper to evaluate since $Q ( \alpha ; \pmb \theta ) \cdot Q ( \beta ; \pmb \theta )$ for $\alpha , \beta \in \mathbb { R }$ requires only an integer multiplication for the case of uniform quantization or an integer addition of the exponents for powerof-two quantization. Furthermore, $Q ( \bar { \alpha ; \pmb \theta } ) + Q ( \beta ; \pmb \theta )$ for $\alpha , \beta \in \mathbb { R }$ only requires an integer addition. Table 2 compares the computational complexity and the memory footprint of layers which apply uniform or power-of-two quantization to weights and activations.
We consider the following memory characteristics of the DNN, constraining them during training: 1. Total memory $\begin{array} { r } { \dot { S ^ { w } ( \pmb { \theta } _ { 1 } ^ { w } , . . . , \pmb { \theta } _ { L } ^ { w } ) } = \sum _ { l = 1 } ^ { L } S _ { l } ^ { w } ( \pmb { \theta } _ { l } ^ { w } ) } \end{array}$ to store all weights: We use the constraint
$$g _ { 1 } ( \pmb { \theta } _ { 1 } ^ { w } , . . . , \pmb { \theta } _ { L } ^ { w } ) = S ^ { w } ( \pmb { \theta } _ { 1 } ^ { w } , . . . , \pmb { \theta } _ { L } ^ { w } ) - S _ { 0 } ^ { w } = \sum _ { l = 1 } ^ { L } S _ { l } ^ { w } ( \pmb { \theta } _ { l } ^ { w } ) - S _ { 0 } ^ { w } \leq 0 ,$$
Table 2: Number of multiplications $C _ { l } ^ { m u l }$ , additions $C _ { l } ^ { a d d }$ as well as required memory to store the weights $S _ { l } ^ { w }$ and activations $S _ { l } ^ { x }$ of fully connected and convolutional layers.
<table><tr><td>Layer</td><td>Quantization</td><td>cmul</td><td>Cadd</td><td>s</td><td>S</td></tr><tr><td>Fully connected</td><td>uniform pow-2</td><td>MMl-1 0</td><td>MM-1 2MMl-1</td><td>M(M-1+1)b</td><td>Mb</td></tr><tr><td>Convolutional</td><td>uniform pow-2</td><td>MM-1N²K² 0</td><td>MM-1N²K² 2MM1-1NK2</td><td>Mt(M-1K²+1)b</td><td>MN²</td></tr></table>
to ensure that the total weight memory requirement $S ^ { w } ( \pmb { \theta } _ { 1 } ^ { w } , . . . , \pmb { \theta } _ { L } ^ { w } )$ is smaller than a certain maximum weight memory size $S _ { 0 } ^ { w }$ . Table 2 gives $S _ { l } ^ { w } ( \pmb \theta _ { l } ^ { w } )$ for the case of fully connected and convolutional layers. Each layer’s memory requirement $S _ { l } ^ { w } ( \pmb { \theta } _ { l } ^ { w } )$ depends on the bitwidth $b _ { l } ^ { w }$ : reducing $S _ { l } ^ { w } ( \pmb { \theta } _ { l } ^ { w } )$ will reduce the bitwidth $b _ { l } ^ { w }$ .
2. Total activation memory $\begin{array} { r l } { S ^ { x } ( \pmb { \theta } _ { 1 } ^ { x } , . . . , \pmb { \theta } _ { L } ^ { x } ) = \sum _ { l = 1 } ^ { L } S _ { l } ^ { x } ( \pmb { \theta } _ { l } ^ { x } ) } & { { } } \end{array}$ to store all feature maps: We use the constraint
$$g _ { 2 } ( \pmb { \theta } _ { 1 } ^ { x } , . . . , \pmb { \theta } _ { L } ^ { x } ) = S ^ { x } ( \pmb { \theta } _ { 1 } ^ { x } , . . . , \pmb { \theta } _ { L } ^ { x } ) - S _ { 0 } ^ { x } = \sum _ { l = 1 } ^ { L } S _ { l } ^ { x } ( \pmb { \theta } _ { l } ^ { x } ) - S _ { 0 } ^ { x } \leq 0 ,$$
to ensure an upper limit on the total activation memory size $S _ { 0 } ^ { x }$ . Table 2 gives $S _ { l } ^ { x } ( \pmb { \theta } _ { l } ^ { x } )$ for the case of fully connected and convolutional layers. Such a constraint is important if we use pipelining for accelerated inference, i.e., if we evaluate multiple layers with several consecutive inputs in parallel. This can, e.g., be the case for FPGA implementations (Guo et al., 2017).
3. Maximum activation memory $\begin{array} { r } { \hat { S } ^ { x } ( \pmb { \theta } _ { 1 } ^ { x } , . . . , \pmb { \theta } _ { L } ^ { x } ) = \operatorname* { m a x } _ { l = 1 , . . . , L } S _ { l } ^ { x } } \end{array}$ to store the largest feature map: We use the constraint
$$g _ { 3 } ( \pmb { \theta } _ { 1 } ^ { x } , . . . , \pmb { \theta } _ { L } ^ { x } ) = \hat { S } ^ { x } ( \pmb { \theta } _ { 1 } ^ { x } , . . . , \pmb { \theta } _ { L } ^ { x } ) - \hat { S } _ { 0 } ^ { x } = \operatorname* { m a x } _ { l = 1 , . . . , L } ( S _ { l } ^ { x } ) - \hat { S } _ { 0 } ^ { x } \leq 0 ,$$
to ensure that the maximum activation size $\hat { S } ^ { x }$ does not exceed a given limit $\hat { S } _ { 0 } ^ { x }$ . This constraint is relevant for DNN implementations where layers are processed sequentially.
To train the quantized DNN with memory constraints, we need to solve the optimization problem
$$\operatorname* { m i n } _ { \mathcal { W } _ { l } , c _ { l } , \theta _ { l } ^ { w } , \theta _ { l } ^ { x } } \mathrm { E } _ { p } ( x , y ) \left[ J ( \mathcal { X } _ { L } , \mathcal { Y } ) \right] \mathrm { ~ s . t . ~ } g _ { j } \big ( \theta _ { 1 } ^ { w } , . . . , \theta _ { L } ^ { w } , \theta _ { 1 } ^ { x } , . . . , \theta _ { L } ^ { x } \big ) \leq 0 \mathrm { ~ f o r ~ a l l ~ } j = 1 , . . . , 3$$
where $J ( \pmb { \mathscr { X } } _ { L } , \pmb { \mathscr { D } } )$ is the loss function for yielding the DNN output $\scriptstyle { \mathcal { X } } _ { L }$ although the ground truth is $_ { \mathscr { y } }$ . Eq. (9) learns the weights $w _ { l }$ , $c _ { l }$ as well as the quantization parameters $\pmb { \theta } _ { l } ^ { x }$ , $\pmb { \theta } _ { l } ^ { w }$ . In order to use simple stochastic gradient descent solvers, we use the penalty method (Bertsekas, 2014) to convert (9) into the unconstrained optimization problem
$$\operatorname* { m i n } _ { \mathcal { W } _ { l } , c _ { l } , \theta _ { l } ^ { w } , \theta _ { l } ^ { x } } \mathrm { E } _ { p ( \pmb { \mathscr { X } } , \pmb { \mathscr { Y } } ) } \left[ J ( \pmb { \mathscr { X } } _ { L } , \pmb { \mathscr { Y } } ) \right] + \sum _ { j = 1 } ^ { J } \lambda _ { j } \operatorname* { m a x } ( 0 , g _ { j } ( \pmb { \theta } _ { 1 } ^ { w } , . . . , \pmb { \theta } _ { L } ^ { w } , \pmb { \theta } _ { 1 } ^ { x } , . . . , \pmb { \theta } _ { L } ^ { x } ) ) ^ { 2 } ,$$
where $\lambda _ { j } \in \mathbb { R } ^ { + }$ are individual weightings for the penalty terms. Hence, training with weight and activation size constraints requires choosing two penalty weightings $\lambda _ { j }$ , one for (8a) and one for either (8b) or (8c).
Note, that the optimization problem (10) does not necessarily give a quantized DNN which fulfills the memory constraints. The probability to fulfill the constraint $g _ { j }$ depends on the choice of $\lambda _ { j }$ . In particular, this probability increases with larger $\lambda _ { j }$ . However, choosing a too large $\lambda _ { j }$ will yield a penalty term that dominates over the network loss decreasing the network performance. In our experiments, we choose $\lambda _ { j }$ such that the initial loss and the penalty term have approximately the same magnitude. Using this simple heuristic, we optained quantized DNNs that reached a high accuracy and at the same time fulfilled the constraints at the end of training.
# 4 EXPERIMENTS
In the following, we will use the best parametrizations for uniform and power-of-two DQ, i.e., ${ \pmb \theta } _ { U } = [ d , q _ { \mathrm { m a x } } ] ^ { \widetilde { T } }$ and $\pmb { \theta } _ { P } = [ q _ { \mathrm { m i n } } , q _ { \mathrm { m a x } } ] ^ { \hat { T } }$ , that we found in Sec. 2. Both parametrizations do not directly depend on the bitwidth $b$ . Therefore, we compute it by using $\begin{array} { r } { b ( \pmb { \theta } _ { U } ) = \left\lceil \log _ { 2 } \left( \frac { q _ { \operatorname* { m a x } } } { d } + 1 \right) + 1 \right\rceil } \end{array}$ and $\begin{array} { r } { b ( \pmb \theta _ { P } ) = \left\lceil \log _ { 2 } \left( \log _ { 2 } \left( \frac { q _ { \mathrm { m a x } } } { q _ { \mathrm { m i n } } } \right) + 1 \right) + 1 \right\rceil } \end{array}$ . All quantized networks use a pre-trained float32 network for initialization and all quantizers are initialized as described in Sec. 2.3. For our experiments on CIFAR-10, we use the same training setup as described in Sec. 2.3. For the experiments on
Table 3: Homogeneous vs. heterogeneous quantization of ResNet-20 on CIFAR-10.
<table><tr><td></td><td>Bitwidth Weight/Activ.</td><td>qmax Weight/Activ.</td><td>Size Weight/Activ.(max)/Activ.(sum)</td><td>Validation error</td><td>Uniform quant. Power-of-two quant. Validation error</td></tr><tr><td>Baseline</td><td>32bit/32bit</td><td>1</td><td>1048KB/64KB/736KB</td><td colspan="2">7.29%</td></tr><tr><td>Fixed</td><td>2bit/32bit</td><td>fixed/-</td><td>65.5KB/64KB/736KB</td><td>10.81%</td><td>8.99%</td></tr><tr><td>TQT (Jain et al.,2019)</td><td>2bit/32bit</td><td>learned/-</td><td>65.5KB/64KB/736KB</td><td>9.47%</td><td>8.79%</td></tr><tr><td>Ours (w/constr. (8a))</td><td>learned/32bit</td><td>learned/-</td><td>70KB/64KB/736KB</td><td>8.59%</td><td>8.53%</td></tr><tr><td>Fixed</td><td>2bit/4bit</td><td>fixed/fixed</td><td>65.5KB/8KB/92KB</td><td>11.30%</td><td>11.62%</td></tr><tr><td>TQT (Jain et al.,2019)</td><td>2bit/4bit</td><td>learned/learned</td><td>65.5KB/8KB/92KB</td><td>9.62%</td><td>11.29%</td></tr><tr><td>Ours (w/constr.(8a) and(8b)) learned/learned learned/learned</td><td></td><td></td><td>70KB/- /92KB</td><td>9.38%</td><td>11.29%</td></tr><tr><td>Ours (w/constr.(8a) and (8c))</td><td>)learned/learned</td><td>learned/learned</td><td>70KB/8KB/-</td><td>8.58%</td><td>11.23%</td></tr></table>
ImageNet, we train the quantized DNNs for 50 epochs, using SGD with momentum 0.9 and a learning rate schedule starting with 0.01 and reducing it by a factor of 10 after 16 and 32 epochs, respectively. Please note that we quantize all layers opposed to other papers which use a higher precision for the first and/or last layer.
In our experiments, we noticed that the performance of DQ is not sensitive to the choice of $\lambda _ { j }$ in (10). For the CIFAR-10 experiments, we use $\lambda = 0 . 1$ for both constraints (for sizes in kB). For the ImageNet experiments, we kept the same regularization level by scaling $\lambda _ { j }$ with the square of the size ratio between the ImageNet model and the CIFAR-10 model. We scale with the square-ratio as the constraints in (10) are squared penalty terms.
First, in Table 3/top, we train a ResNet-20 on CIFAR-10 with quantized weights and float32 activations. We start with the most restrictive quantization scheme with fixed $q _ { \mathrm { m a x } }$ and $b = 2 \mathrm { b i t }$ (“Fixed”). Then, we allow the model to learn $q _ { \mathrm { m a x } }$ while $b = 2$ bit remains fixed as was done in (Jain et al., 2019) (“TQT”). Finally, we learn both $q _ { \mathrm { m a x } }$ and $b$ with the constraint that the weight size is at most 70KB (“Ours”), which is just $4 . 5 \mathrm { k B }$ larger that the previous 2Bit networks. This allows the model to allocate more than two bits to some layers. From Table 3/top, we observe that the error is smallest when we learn all quantization parameters.
In Table 3/bottom, weights and activations are quantized. For activation quantization, we consider two cases as discussed in Sec. 3. The first one constrains the total activation memory $S ^ { x }$ while the second constrains the maximum activation memory ${ \hat { S } } ^ { x }$ such that both have the same size as a homogeneously quantized model with 4bit activations. Again, we observe that the error is smallest when we learn all quantization parameters.
We also use DQ to train quantized ResNet-18 (He et al., 2016) and MobileNetV2 (Sandler et al., 2018) on ImageNet (Deng et al., 2009) with 4bit uniform weights and activations or equivalent-sized networks with learned quantization parameters. This is quite aggressive and, thus, a fixed quantization scheme loses more than $6 \%$ accuracy while our quantization scheme loses less than $0 . 5 \%$ compared to a float32 precision network.
Our results compare favorably to other recent quantization approaches. To our knowledge, the best result for a 4bit ResNet-18 was reported by (Esser et al., 2019) $( 2 9 . 9 1 \%$ error). This is very close to our performance $( 2 9 . 9 2 \%$ error). Importantly, (Esser et al., 2019) did not quantize the first and last layers, meaning that their network is much bigger. Specifically, compared to our quantized ResNet-18, their model with high precision input and output layers requires $37 \%$ more memory to store the weights. Moreover, (Esser et al., 2019) learns stepsizes which are not restricted to powers-of-two. As explained in Sec. 2.2, uniform quantization with power-of-two stepsize leads to more efficient inference, effectively allowing to efficiently compute any multiplication with an integer multiplication and bit-shift. To our knowledge only (Wang et al., 2018) reported results of MobileNetV2 quantized to 4bit. They keep the baseline performance constraining the network to the same size as the 4bit network. However, they do not quantize the activations in this case. In addition, DQ training is efficient since it is comparable to the training of unquantized network. Specifically, one epoch on ImageNet takes $3 7 \mathrm { m i n }$ for MobileNetV2 and 18min for ResNet-18 on four Nvidia Tesla V100.
Fig. 5 shows the weight bitwidth assignment over layers. We observe that small bitwidths are used for layers with many parameters, i.e., pointwise convolutions and fully connected layers. However, the resulting bitwidth assignments are complex, meaning that there is no simple heuristic. Therefore, it is important to learn the optimal bitwidth assignment.
 Figure 5: Weight bitwidth assignment over layers for ResNet-18 and MobileNetV2 on ImageNet with weights constrained to a maximum size of 5.57MB. Our method has learned a heterogeneous bitwidth distribution, which gives a better performance than a homogeneous one (see Table 4).
# 5 CONCLUSIONS
In this paper we discussed differentiable quantization and its application to the training of compact DNNs with memory constraints. In order to fulfill memory constraints, we introduced penalty functions during training and used stochastic gradient descent to find the optimal weights as well as the optimal quantization values in a joint fashion. We showed that there are several possible parametrizations of the quantization function. In particular, learning the bitwidth directly is not optimal; therefore, we proposed to parametrize the quantizer with the stepsize and dynamic range instead. The bitwidth can then be inferred from them. This approach is competitive to other recent quantization methods while it does not require to retrain the network multiple times in contrast to reinforcement learning approaches (Wang et al., 2018; Elthakeb et al., 2018).
# ACKNOWLEDGEMENTS
We would like to thank Masato Ishii for many helpful comments during the preparation of this manuscript.
# REFERENCES
Yu Bai, Yu-Xiang Wang, and Edo Liberty. Proxquant: Quantized neural networks via proximal operators. CoRR, abs/1810.00861, 2018. URL http://arxiv.org/abs/1810.00861.
Yoshua Bengio, Nicholas Léonard, and Aaron Courville. Estimating or propagating gradients through stochastic neurons for conditional computation. arXiv preprint arXiv:1308.3432, 2013.
Dimitri P Bertsekas. Constrained optimization and Lagrange multiplier methods. Academic press, 2014.
Christopher M. Bishop. Pattern Recognition and Machine Learning. Springer, 2006.
Fabien Cardinaux, Stefan Uhlich, Kazuki Yoshiyama, Javier Alonso García, Stephen Tiedemann, Thomas Kemp, and Akira Nakamura. Iteratively training look-up tables for network quantization. arXiv preprint arXiv:1811.05355, 2018.
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.
Ahmed T. Elthakeb, Prannoy Pilligundla, Amir Yazdanbakhsh, Sean Kinzer, and Hadi Esmaeilzadeh. Releq: A reinforcement learning approach for deep quantization of neural networks. CoRR, abs/1811.01704, 2018. URL http://arxiv.org/abs/1811.01704.
Steven K. Esser, Jeffrey L. McKinstry, Deepika Bablani, Rathinakumar Appuswamy, and Dharmendra S. Modha. Learned step size quantization. CoRR, abs/1902.08153, 2019. URL http://arxiv.org/abs/1902.08153.
Kaiyuan Guo, Shulin Zeng, Jincheng Yu, Yu Wang, and Huazhong Yang. A survey of fpga-based neural network accelerator. arXiv preprint arXiv:1712.08934, 2017.
Song Han, Huizi Mao, and William J. Dally. Deep compression: Compressing deep neural network with pruning, trained quantization and huffman coding. CoRR, abs/1510.00149, 2015. URL http://arxiv.org/abs/1510.00149.
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.
Itay Hubara, Matthieu Courbariaux, Daniel Soudry, Ran El-Yaniv, and Yoshua Bengio. Quantized neural networks: Training neural networks with low precision weights and activations. CoRR, abs/1609.07061, 2016. URL http://arxiv.org/abs/1609.07061.
Sambhav R. Jain, Albert Gural, Michael Wu, and Chris Dick. Trained uniform quantization for accurate and efficient neural network inference on fixed-point hardware. CoRR, abs/1903.08066, 2019. URL http://arxiv.org/abs/1903.08066.
Eric Jang, Shixiang Gu, and Ben Poole. Categorical reparameterization with gumbel-softmax. arXiv preprint arXiv:1611.01144, 2016.
Alex Krizhevsky and Geoffrey Hinton. Learning multiple layers of features from tiny images. Technical report, Citeseer, 2009.
Fengfu Li, Bo Zhang, and Bin Liu. Ternary weight networks. arXiv preprint arXiv:1605.04711, 2016.
Zhi-Gang Liu and Matthew Mattina. Learning low-precision neural networks without straight-through estimator (ste). arXiv preprint arXiv:1903.01061, 2019.
Christos Louizos, Matthias Reisser, Tijmen Blankevoort, Efstratios Gavves, and Max Welling. Relaxed quantization for discretized neural networks. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ HkxjYoCqKX.
Chris J. Maddison, Andriy Mnih, and Yee Whye Teh. The concrete distribution: A continuous relaxation of discrete random variables. CoRR, abs/1611.00712, 2016. URL http://arxiv. org/abs/1611.00712.
Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, and Liang-Chieh Chen. Mobilenetv2: Inverted residuals and linear bottlenecks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 4510–4520, 2018.
Sony. Neural Network Libraries (NNabla). https://github.com/sony/nnabla.
Kuan Wang, Zhijian Liu, Yujun Lin, Ji Lin, and Song Han. HAQ: hardware-aware automated quantization. CoRR, abs/1811.08886, 2018. URL http://arxiv.org/abs/1811.08886.
Penghang Yin, Jiancheng Lyu, Shuai Zhang, Stanley Osher, Yingyong Qi, and Jack Xin. Understanding straight-through estimator in training activation quantized neural nets. arXiv preprint arXiv:1903.05662, 2019.
Aojun Zhou, Anbang Yao, Yiwen Guo, Lin Xu, and Yurong Chen. Incremental network quantization: Towards lossless cnns with low-precision weights. arXiv preprint arXiv:1702.03044, 2017.
# A DERIVATION OF THE GRADIENTS FOR DIFFERENTIABLE QUANTIZATION (DQ)
In the following sections, we will give the derivatives $\textstyle { \frac { \partial } { \partial x } } Q ( x ; \theta )$ and gradients $\nabla _ { \boldsymbol { \theta } } Q ( x ; \boldsymbol { \theta } )$ for the uniform and the power-of-two quantizers. The results are summarized in Sec. 2.
We use the straight-through gradient estimate whenever we need to differentiate a non-differentiable floor function, i.e., we assume
$${ \frac { \partial } { \partial x } } \left\lfloor x \right\rfloor = 1 .$$
# A.1 DERIVATIVES OF THE UNIFORM QUANTIZER
Fig. 6(a) shows a symmetric uniform quantizer $Q _ { U } ( x ; \theta )$ which maps a real value $x \in \mathbb { R }$ to one of $I = 2 k + 1$ quantized values $q \in \{ - k d , . . . , 0 , . . . , k d \}$ by computing
$$q = Q _ { U } ( x ; \pmb \theta ) = \mathrm { s i g n } ( x ) \left\{ \begin{array} { l l } { d \left\lfloor \frac { | x | } { d } + \frac { 1 } { 2 } \right\rfloor } & { | x | \leq q _ { \operatorname* { m a x } } } \\ { q _ { \operatorname* { m a x } } } & { | x | > q _ { \operatorname* { m a x } } } \end{array} \right.$$
using the parameters $\pmb { \theta } = [ d , q _ { \mathrm { m a x } } , b ] ^ { T }$ where $d \in \mathbb { R }$ is the stepsize, $q _ { \operatorname* { m a x } } \in \mathbb { R }$ is the maximum value and $b \in \mathbb { N }$ is the number of bits that we use to encode the quantized values $q$ . The elements of $\pmb { \theta }$ are dependent as there is the relationship $q _ { \operatorname* { m a x } } = ( 2 ^ { b - 1 } - 1 ) d$ .
# A.1.1 CASE U1: PARAMETRIZATION WITH RESPECT TO $b$ AND $d$
For the parametrization with respect to the bitwidth $b$ and steps size $d$ , (12) is given by
$$q = Q _ { U } ( x ; b , d ) = \mathrm { s i g n } ( x ) d \left\{ \frac { \left. \frac { 1 } { d } \right. } { 2 ^ { b - 1 } } + \frac { 1 } { 2 } \right. \quad \left. x \right. \leq ( 2 ^ { b - 1 } - 1 ) d$$
and the derivatives are given by
$$\begin{array} { r l } & { \frac { \partial Q _ { U } ( x ; b , d ) } { \partial b } = \mathrm { s i g n } ( x ) \frac { 2 ^ { b - 1 } \log 2 } { 2 ^ { b - 1 } - 1 } \{ ( 2 ^ { b - 1 } - 1 ) d \ | x | > ( 2 ^ { b - 1 } - 1 ) d } \\ & { \frac { \partial Q _ { U } ( x ; b , d ) } { \partial d } = \mathrm { s i g n } ( x ) \frac { 1 } { d } \{ \begin{array} { l l } { d \lfloor \frac { \lfloor x \rfloor } { d } + \frac { 1 } { 2 } \rfloor - | x | } & { | x | \leq ( 2 ^ { b - 1 } - 1 ) d } \\ { ( 2 ^ { b - 1 } - 1 ) d } & { | x | > ( 2 ^ { b - 1 } - 1 ) d } \end{array} . } \end{array}$$
A.1.2 CASE U2: PARAMETRIZATION WITH RESPECT TO $b$ AND $q _ { \mathrm { M A X } }$
For the parametrization with respect to the bitwidth $b$ and maximum value $q _ { \mathrm { m a x } }$ , (12) is given by
$$\begin{array} { r } { q = Q _ { U } ( x ; b , q _ { \operatorname* { m a x } } ) = \operatorname { s i g n } ( x ) q _ { \operatorname* { m a x } } \{ \frac { 1 } { 2 ^ { b - 1 } - 1 } \lfloor | x | \frac { 2 ^ { b - 1 } - 1 } { q _ { \operatorname* { m a x } } } + \frac { 1 } { 2 } \rfloor \ | x | \leq q _ { \operatorname* { m a x } } } \\ { 1 \ ~ | x | > q _ { \operatorname* { m a x } } } \end{array}$$
and the derivatives are given by
$$\begin{array} { r l } & { \frac { \partial Q _ { U } ( x ; b , q _ { \mathrm { m a x } } ) } { \partial b } = \mathrm { s i g n } ( x ) \frac { 2 ^ { b - 1 } \log 2 } { 2 ^ { b - 1 } - 1 } \left\{ { - \frac { q _ { \mathrm { m a x } } } { 2 ^ { b - 1 } - 1 } \left[ | x | \frac { 2 ^ { b - 1 } - 1 } { q _ { \mathrm { m a x } } } + \frac 1 2 \right] + \beta _ { 1 } } \right. \left| x \right| \leq q _ { \mathrm { m a x } } } , \ \\ & { \frac { \partial Q _ { U } ( x ; b , q _ { \mathrm { m a x } } ) } { \partial q _ { \mathrm { m a x } } } = \mathrm { s i g n } ( x ) \frac { 1 } { q _ { \mathrm { m a x } } } \left\{ \frac { q _ { \mathrm { m a x } } ^ { q _ { \mathrm { m a x } } } } { 2 ^ { b - 1 } - 1 } \left[ | x | \frac { 2 ^ { b - 1 } - 1 } { q _ { \mathrm { m a x } } } + \frac 1 2 \right] + \beta _ { 2 } \right. \left. \left| x \right| \leq q _ { \mathrm { m a x } } \right.} , \\ & { \left. \left. \frac { \partial { l } } { \partial q _ { \mathrm { m a x } } } \right. \left[ x \right] > q _ { \mathrm { m a x } } , \right. } \end{array}$$
where $\begin{array} { r } { \beta _ { 1 } = \frac { q _ { \mathrm { m a x } } } { 2 ^ { b - 1 } \log 2 } \frac { \partial \left\lfloor | x | \frac { 2 ^ { b - 1 } - 1 } { q _ { \mathrm { m a x } } } + \frac { 1 } { 2 } \right\rfloor } { \partial b } = | x | } \end{array}$ and $\begin{array} { r } { \beta _ { 2 } = \frac { q _ { \mathrm { m a x } } ^ { 2 } } { 2 ^ { b - 1 } - 1 } \frac { \partial \left\lfloor | x | \frac { 2 ^ { b - 1 } - 1 } { q _ { \mathrm { m a x } } } + \frac { 1 } { 2 } \right\rfloor } { \partial q _ { \mathrm { m a x } } } = - | x | } \end{array}$ , if we use the straight-through gradient estimate for the floor function.
 Figure 6: Examples of uniform quantizer $Q _ { U } ( x )$ and power-of-two quantizer $Q _ { P } ( x )$ for $b = 3$ bits
A.1.3 CASE U3: PARAMETRIZATION WITH RESPECT TO $d$ AND $q _ { \mathrm { M A X } }$
Eq. (12) gives the quantization with respect to the step size $d$ and maximum value $q _ { \mathrm { m a x } }$ . The derivatives are
$$\begin{array} { r l r } & { \frac { \partial Q _ { U } ( x ; d , q _ { \mathrm { m a x } } ) } { \partial d } = \mathrm { s i g n } ( x ) \frac { 1 } { d } \left\{ \begin{array} { l l } { d \left\lfloor \frac { | x | } { d } + \frac { 1 } { 2 } \right\rfloor - | x | } & { | x | \leq q _ { \mathrm { m a x } } } \\ { 0 } & { | x | > q _ { \mathrm { m a x } } } \end{array} , \right. } & \\ & { \frac { \partial Q _ { U } ( x ; d , q _ { \mathrm { m a x } } ) } { \partial q _ { \mathrm { m a x } } } = \mathrm { s i g n } ( x ) \frac { 1 } { q _ { \mathrm { m a x } } } \left\{ \begin{array} { l l } { 0 } & { | x | \leq q _ { \mathrm { m a x } } } \\ { q _ { \mathrm { m a x } } } & { | x | > q _ { \mathrm { m a x } } } \end{array} . \right. } & \end{array}$$
# A.2 DERIVATIVES OF THE POWER-OF-TWO QUANTIZER
Power-of-two quantization $Q _ { P } ( x ; \theta )$ maps a real-valued number $x \in \mathbb { R }$ to a quantized value $q \in$ $\{ \pm 2 ^ { k } : k \in \mathbb { Z } \}$ by
$$q = Q _ { P } ( x ; \pmb \theta ) = \mathrm { s i g n } ( x ) \left\{ \begin{array} { l l } { q _ { \mathrm { m i n } } } & { | x | \leq q _ { \mathrm { m i n } } } \\ { 2 ^ { \lfloor 0 . 5 + \log _ { 2 } | x | \rfloor } } & { q _ { \mathrm { m i n } } < | x | \leq q _ { \mathrm { m a x } } } \\ { q _ { \mathrm { m a x } } } & { | x | > q _ { \mathrm { m a x } } } \end{array} , \right.$$
where $q _ { \mathrm { m i n } }$ and $q _ { \mathrm { m a x } }$ are the minimum and maximum (absolute) values of the quantizer for a bitwidth of $b$ bits. Fig. 6b shows the quantization curve for this quantization scheme.
Using the STE for the floor operation, the derivative $\partial _ { x } Q _ { P } ( x ; \theta )$ is given by
$$\partial _ { x } Q _ { P } ( x ) = \left\{ \begin{array} { l l } { 0 } & { | x | \le q _ { \mathrm { m i n } } } \\ { \frac { 2 ^ { \lfloor 0 . 5 + \log _ { 2 } \lvert x \rvert \rfloor } } { \lvert x \rvert } } & { q _ { \mathrm { m i n } } < \lvert x \rvert \le q _ { \mathrm { m a x } } } \\ { 0 } & { \lvert x \rvert > q _ { \mathrm { m a x } } } \end{array} \right. .$$
The power-of-two quantization has the three parameters $\theta = [ b , q _ { \mathrm { m i n } } , q _ { \mathrm { m a x } } ]$ , which are dependent on each other, i.e., $q _ { \operatorname* { m a x } } = 2 ^ { 2 ^ { b - 1 } - 1 } q _ { \operatorname* { m i n } }$ . Therefore, we have again three different parametrizations with $\pmb \theta = [ b , q _ { \mathrm { m i n } } ]$ , $\pmb \theta = [ b , q _ { \mathrm { m a x } } ]$ or $\theta = [ q _ { \mathrm { m i n } } , q _ { \mathrm { m a x } } ]$ , respectively. The resulting partial derivatives for each parametrization are shown in Fig. 7 and summarized in the following sections. Similar to the uniform case, one parametrization $\theta = [ q _ { \mathrm { m i n } } , q _ { \mathrm { m a x } } ] )$ leads to a gradient with the nice form
$$\pmb { \nabla } _ { \theta } Q _ { P } ( x ; \pmb { \theta } ) = \left[ \partial _ { q _ { \operatorname* { m a x } } } Q _ { U } ( x ; \pmb { \theta } ) \right] = \left\{ \begin{array} { l l } { [ 1 , 0 ] ^ { T } } & { | x | \leq q _ { \operatorname* { m i n } } } \\ { [ 0 , 0 ] ^ { T } } & { q _ { \operatorname* { m i n } } < | x | \leq q _ { \operatorname* { m a x } } , } \\ { [ 0 , 1 ] ^ { T } } & { | x | > q _ { \operatorname* { m a x } } } \end{array} \right.$$
which has a bounded gradient magnitude and independent components and is, hence, well suited for first order gradient based optimization.
# A.2.1 CASE P1: PARAMETRIZATION WITH RESPECT TO $b$ AND $q _ { \mathrm { M A X } }$
For the parametrization with $\pmb \theta = [ b , q _ { \mathrm { m a x } } ]$ , (18) is given by
$$\begin{array} { r l } { Q _ { P } ( x ; b , q _ { \mathrm { m a x } } ) = \operatorname { s i g n } ( x ) \left\{ \begin{array} { l l } { 2 ^ { - 2 ^ { b - 1 } + 1 } q _ { \mathrm { m a x } } } & { \left| x \right| \leq 2 ^ { - 2 ^ { b - 1 } + 1 } q _ { \mathrm { m a x } } } \\ { 2 ^ { \left\lfloor 0 . 5 + \log _ { 2 } \left. x \right. \right\rfloor } } & { 2 ^ { - 2 ^ { b - 1 } + 1 } q _ { \mathrm { m a x } } < \left| x \right| \leq q _ { \mathrm { m a x } } } \\ { q _ { \mathrm { m a x } } } & { \left| x \right| > q _ { \mathrm { m a x } } } \end{array} \right. } \end{array}$$
 Figure 7: Derivatives for the three different parametrizations of $Q _ { P } ( x ; \theta )$
and the partial derivatives are
$$\frac { \partial Q _ { P } ( x ; b , q _ { \mathrm { m a x } } ) } { \partial b } = \mathrm { s i g n } ( x ) \left\{ \begin{array} { l l } { - 2 ^ { - 2 ^ { b - 1 } + b } ( \log 2 ) ^ { 2 } q _ { \mathrm { m a x } } } & { | x | \leq - 2 ^ { - 2 ^ { b - 1 } + 1 } q _ { \mathrm { m a x } } } \\ { 0 } & { - 2 ^ { - 2 ^ { b - 1 } + 1 } q _ { \mathrm { m a x } } < | x | \leq q _ { \mathrm { m a x } } } \\ { 0 } & { | x | > q _ { \mathrm { m a x } } } \end{array} \right. ,$$
$$\frac { \partial Q _ { P } ( x ; b , q _ { \mathrm { m a x } } ) } { \partial q _ { \mathrm { m a x } } } = \mathrm { s i g n } ( x ) \left\{ \begin{array} { l l } { 2 ^ { - 2 ^ { b - 1 } + 1 } } & { | x | \leq - 2 ^ { - 2 ^ { b - 1 } + 1 } q _ { \mathrm { m a x } } } \\ { 0 } & { - 2 ^ { - 2 ^ { b - 1 } + 1 } q _ { \mathrm { m a x } } < | x | \leq q _ { \mathrm { m a x } } } \\ { 1 } & { | x | > q _ { \mathrm { m a x } } } \end{array} \right. .$$
A.2.2 CASE P2: PARAMETRIZATION WITH RESPECT TO $b$ AND $q _ { \mathrm { M I N } }$
For the parametrization with $\pmb \theta = [ b , q _ { \mathrm { m i n } } ]$ , (18) is given by
$$Q _ { P } ( x ; b , q _ { \mathrm { m i n } } ) = \mathrm { s i g n } ( x ) \left\{ \begin{array} { l c } { { q _ { \mathrm { m i n } } } } & { { | x | \leq q _ { \mathrm { m i n } } } } \\ { { 2 ^ { \left\lfloor 0 . 5 + \log _ { 2 } \left. x \right. \right\rfloor } } } & { { q _ { \mathrm { m i n } } < | x | \leq 2 ^ { 2 ^ { b - 1 } - 1 } q _ { \mathrm { m i n } } } } \\ { { 2 ^ { 2 ^ { b - 1 } - 1 } q _ { \mathrm { m i n } } } } & { { | x | > 2 ^ { 2 ^ { b - 1 } - 1 } q _ { \mathrm { m i n } } } } \end{array} \right.$$
and the partial derivatives are
$$\begin{array} { r l } & { \frac { \partial Q _ { P } ( x ; b , q _ { \mathrm { m i n } } ) } { \partial b } = \mathrm { s i g n } ( x ) \left\{ \begin{array} { l l } { 0 } & { | x | \leq q _ { \mathrm { m i n } } } \\ { 0 } & { q _ { \mathrm { m i n } } < | x | \leq 2 ^ { 2 ^ { b - 1 } - 1 } q _ { \mathrm { m i n } } ~ , } \\ { 2 ^ { 2 ^ { b - 1 } + b - 2 } ( \log 2 ) ^ { 2 } q _ { \mathrm { m i n } } } & { | x | > 2 ^ { 2 ^ { 2 ^ { b - 1 } } - 1 } q _ { \mathrm { m i n } } ~ , } \end{array} \right. } \\ & { \frac { \partial Q _ { P } ( x ; b , q _ { \mathrm { m i n } } ) } { \partial q _ { \mathrm { m i n } } } = \mathrm { s i g n } ( x ) \left\{ \begin{array} { l l } { 1 } & { | x | \leq q _ { \mathrm { m i n } } } \\ { 0 } & { q _ { \mathrm { m i n } } < | x | \leq 2 ^ { 2 ^ { b - 1 } - 1 } q _ { \mathrm { m i n } } ~ . } \\ { 2 ^ { 2 ^ { b - 1 } - 1 } } & { | x | > 2 ^ { 2 ^ { 2 ^ { b - 1 } } - 1 } q _ { \mathrm { m i n } } } \end{array} \right. } \end{array}$$
# A.2.3 CASE P3: PARAMETRIZATION WITH RESPECT TO $q _ { \mathrm { M I N } } ~ \mathrm { A N D } ~ q _ { \mathrm { M A X } }$
Eq. (18) gives the parametrization of $Q ( x ; \pmb \theta )$ with respect to the minimum value $q _ { \mathrm { m i n } }$ and maximum value $q _ { \mathrm { m a x } }$ . The derivatives are
$$\frac { \partial Q _ { P } ( x ; q _ { \mathrm { m i n } } , q _ { \mathrm { m a x } } ) } { \partial q _ { \mathrm { m i n } } } = \mathrm { s i g n } ( x ) \left\{ 0 \begin{array} { l l } { 1 } & { | x | \leq q _ { \mathrm { m i n } } } \\ { 0 } & { q _ { \mathrm { m i n } } < | x | \leq q _ { \mathrm { m a x } } , } \\ { 0 } & { | x | > q _ { \mathrm { m a x } } } \end{array} \right.$$
$$\frac { \partial Q _ { P } ( x ; q _ { \mathrm { m i n } } , q _ { \mathrm { m a x } } ) } { \partial q _ { \mathrm { m a x } } } = \mathrm { s i g n } ( x ) \left\{ 0 \begin{array} { l l } { { 0 } } & { { | x | \leq q _ { \mathrm { m i n } } } } \\ { { 0 } } & { { q _ { \mathrm { m i n } } < | x | \leq q _ { \mathrm { m a x } } . } } \\ { { 1 } } & { { | x | > q _ { \mathrm { m a x } } } } \end{array} \right.$$
 Figure 8: MSE surfaces for uniform quantization. Only U3 reaches the optimum $\pmb { \theta } ^ { * }$ .
 Figure 9: MSE surfaces for power-of-two quantization. Only P3 reaches the optimum $\pmb { \theta } ^ { * }$ .
A.3 VISUALIZATION OF THE ERROR SURFACE FOR THE QUANTIZATION OF GAUSSIAN DATA
In Sec. 2.3 of the paper, we compared the three different parametrizations of the uniform quantizer at the example of optimal quantization of Gaussian data. To get a better understanding of Fig 3, we show how the error surfaces look like for this example problem. The experimental setup is the same as in Sec. 2.3, i.e., we use DQ to learn the optimal quantization parameters of a uniform and a power-of-two quantizer, which minimize the expected quantization error $\mathrm { m i n } _ { \pmb \theta } \mathrm { E } \left[ \left( \boldsymbol x - \dot { Q } ( \boldsymbol x ; \pmb \theta ) \right) ^ { 2 } \right]$ . We use three different parametrizations, adapt the quantizer’s parameters with gradient descent and compare the convergence speed as well as the final quantization error. As an input, we generate $1 0 ^ { 4 }$ samples from $N ( 0 , 1 )$ .
Fig. 8 shows the corresponding error surfaces for the three different parametrizations of the uniform quantization. The red curve shows the path through the parameter space taken by gradient descent in order to optimize the MSE, starting with the initial values $b = 2$ , $d = q _ { \mathrm { m a x } } = 1$ . The optimum $\pmb { \theta } ^ { * }$ is located at $b = 1 6$ , $d _ { \approx } ^ { < 2 ^ { - 1 3 } }$ , $q _ { \mathrm { m a x } } = 4$ , since we allow a maximal bitwidth of 16bit and the largest sample magnitude in our dataset is $\operatorname* { m a x } \{ x _ { 1 } , . . . , x _ { N } \} \lessapprox 4$ . In each of the cases U1-U3, the error surface is composed of steep ridges and large flat regions. The steep ridges force us to use small learning rates to avoid divergence. For cases U1 and U2, the optimal $\pmb { \theta } ^ { * }$ can not be reached. However, for U3, $\pmb { \theta } ^ { * }$ lies at the border of a flat region and can be easily reached. Furthermore, case U3 shows a much faster and more stable convergence without oscillation, since the gradient magnitudes are bounded and the error surface has fewer steep ridges where gradient descent starts oscillating.
Fig. 9 shows the corresponding error surfaces for the three different parametrizations of the power-oftwo quantization. Again, the optimum $\pmb { \theta } ^ { * }$ is not attained for two parametrizations, namely P1 and P2, as $\pmb { \theta } ^ { * }$ is surrounded by a large, mostly flat region. For these two cases, gradient descent tends to oscillate at steep ridges and tends to be unstable. However, gradient descent converges to a point close to $\pmb { \theta } ^ { * }$ for parametrization P3, where $\theta = [ q _ { \mathrm { m i n } } , q _ { \mathrm { m a x } } ]$ .
Finally, we also did a comparison of the different power-of-two quantizations on CIFAR-10. Fig. 10 shows the evolution of the training and validation error if we start from a random or a pre-trained float network initialization. We can observe that $\theta = [ q _ { \mathrm { m i n } } , q _ { \mathrm { m a x } } ]$ has the best convergence behavior and thus also results in the smallest validation error (cf. Table 1). The unstable behavior of P2 is expected as the derivative $\frac { \partial Q _ { P } } { \partial q _ { \mathrm { m i n } } }$ can take very large (absolute) values.
# A.4 FURTHER EXPERIMENTS WITH ADAM
Finally, we did an experiment to verify that the parametrization is important, even if adaptive gradient descent methods like ADAM are used for optimization. Table 5 gives the results for a ResNet-20 trained on CIFAR-10. We observe, that again U3 and P3 are the best parametrizations.
 Figure 10: ResNet-20 with power-of-two quantized weights and activations.
Table 5: Error rate of ResNet-20 on CIFAR-10 using different quantization parametrizations. Training is done either by SGD with momentum or ADAM.
<table><tr><td>Parametrization</td><td>SGD momentum</td><td>ADAM</td></tr><tr><td>U1</td><td>11.74</td><td>7.61</td></tr><tr><td>U2</td><td>7.44</td><td>7.85</td></tr><tr><td>U3</td><td>7.32</td><td>7.36</td></tr><tr><td>P1</td><td>15.35</td><td>7.54</td></tr><tr><td>P2</td><td>7.74</td><td>7.79</td></tr><tr><td>P3</td><td>7.40</td><td>7.40</td></tr></table>
# B IMPLEMENTATION DETAILS FOR DIFFERENTIABLE QUANTIZATION
The following code gives our differentiable quantizer implementation in NNabla (Sony). The source code for reproducing our results will be published after the review process has been finished.
# B.1 UNIFORM QUANTIZATION
# B.1.1 CASE U1: PARAMETRIZATION WITH RESPECT TO b AND $d$

# B.1.2 CASE U2: PARAMETRIZATION WITH RESPECT TO b AND $q _ { \mathrm { M A X } }$

# B.1.3 CASE U3: PARAMETRIZATION WITH RESPECT TO $d$ AND $q _ { \mathrm { M A X } }$

# B.2 POWER-OF-TWO QUANTIZATION
# B.2.1 CASE P1: PARAMETRIZATION WITH RESPECT TO b AND $q _ { \mathrm { M A X } }$

# B.2.2 CASE P2: PARAMETRIZATION WITH RESPECT TO b AND $q _ { \mathrm { M I N } }$

# B.2.3 CASE P3: PARAMETRIZATION WITH RESPECT TO $q _ { \mathrm { M I N } }$ AND qMAX
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332# ReAct: Out-of-distribution Detection With Rectified Activations
Yiyou Sun Department of Computer Sciences University of Wisconsin-Madison sunyiyou@cs.wisc.edu
Chuan Guo Facebook AI Research chuanguo@fb.com
Yixuan Li Department of Computer Sciences University of Wisconsin-Madison sharonli@cs.wisc.edu
# Abstract
Out-of-distribution (OOD) detection has received much attention lately due to its practical importance in enhancing the safe deployment of neural networks. One of the primary challenges is that models often produce highly confident predictions on OOD data, which undermines the driving principle in OOD detection that the model should only be confident about in-distribution samples. In this work, we propose ReAct—a simple and effective technique for reducing model overconfidence on OOD data. Our method is motivated by novel analysis on internal activations of neural networks, which displays highly distinctive signature patterns for OOD distributions. Our method can generalize effectively to different network architectures and different OOD detection scores. We empirically demonstrate that ReAct achieves competitive detection performance on a comprehensive suite of benchmark datasets, and give theoretical explication for our method’s efficacy. On the ImageNet benchmark, ReAct reduces the false positive rate (FPR95) by $2 5 . 0 5 \%$ compared to the previous best method1.
# 1 Introduction
Neural networks deployed in real-world systems often encounter out-of-distribution (OOD) inputs— unknown samples that the network has not been exposed to during training. Identifying and handling these OOD inputs can be paramount in safety-critical applications such as autonomous driving [9] and health care. For example, an autonomous vehicle may fail to recognize objects on the road that do not appear in its object detection model’s training set, potentially leading to a crash. This can be prevented if the system identifies the unrecognized object as OOD and warns the driver in advance.
A driving idea behind OOD detection is that the model should be much more uncertain about samples outside of its training distribution. However, $\mathrm { \Delta N g u y e n \ e t { a l . } } \rVert { 3 8 } \rVert$ revealed that modern neural networks can produce overconfident predictions on OOD inputs. This phenomenon renders the separation of in-distribution (ID) and OOD data a non-trivial task. Indeed, much of the prior work on OOD detection focused on defining more suitable measures of OOD uncertainty [17, 19, 28, 29, 31, 33]. Despite the improvement, it is arguable that continued research progress in OOD detection requires insights into the fundamental cause and mitigation of model overconfidence on OOD data.
In this paper, we start by revealing an important observation that OOD data can trigger unit activation patterns that are significantly different from ID data. Figure 1(b) shows the distribution of activations in the penultimate layer of ResNet-50 trained on ImageNet [7]. Each point on the horizontal axis corresponds to a single unit. The mean and standard deviation are shown by the solid line and shaded area, respectively. The mean activation for ID data (blue) is well-behaved with a near-constant mean and standard deviation. In contrast, for OOD data (gray), the mean activation has significantly larger variations across units and is biased towards having sharp positive values (i.e., positively skewed). As a result, such high unit activation can undesirably manifest in model output, producing overconfident predictions on OOD data. A similar distributional property holds for other OOD datasets as well.
 Figure 1: Plots showing (a) the distribution of ID (ImageNet $\mathbb { U }$ ) and OOD (iNaturalist $\mathbb { I } 1 6 \mathbb { I }$ ) uncertainty scores before truncation, (b) the distribution of per-unit activations in the penultimate layer for ID and OOD data, and (c) the distribution of OOD uncertainty scores $\pmb { \Vert 3 3 } \Vert$ after rectification. Applying ReAct drastically improves the separation of ID and OOD data. See text for details.
The above observation naturally inspires a simple yet surprisingly effective method—Rectified Activations (dubbed ReAct) for OOD detection. In particular, the outsized activation of a few selected hidden units can be attenuated by rectifying the activations at an upper limit $c > 0$ . Conveniently, this can be done on a pre-trained model without any modification to training. The dashed horizontal line in Figure 1(b) shows the cutoff point $c$ , and its effect on the OOD uncertainty score is shown in Figure 1(c). After rectification, the output distributions for ID and OOD data become much more well-separated and the false positive rate (FPR) is significantly reduced from $5 5 . 7 2 \%$ to $2 0 . 3 8 \%$ . Importantly, this truncation largely preserves the activation for in-distribution data, and therefore ensures the classification accuracy on the original task is largely comparable.
We provide both empirical and theoretical insights, characterizing and explaining the mechanism by which ReAct improves OOD detection. We perform extensive evaluations and establish state-ofthe-art performance on a suite of common OOD detection benchmarks, including CIFAR-10 and CIFAR-100, as well as a large-scale ImageNet dataset $\mathbb { U }$ . ReAct outperforms the best baseline by a large margin, reducing the average FPR95 by up to $2 5 . 0 5 \%$ . We further analyze our method theoretically and show that ReAct is more beneficial when OOD activations are more chaotic (i.e., having a larger variance) and positively skewed compared to ID activations, a behavior that is typical of many OOD datasets (cf. Figure 1) . In summary, our key results and contributions are:
1. We introduce ReAct —a simple and effective post hoc OOD detection approach that utilizes activation truncation. We show that ReAct can generalize effectively to different network architectures and works with different OOD detection methods including MSP [15], ODIN [31], and energy score $\mathbb { \lVert 3 3 \rVert }$ .
2. We extensively evaluate ReAct on a suite of OOD detection tasks and establish a stateof-the-art performance among post hoc methods. Compared to the previous best method, ReAct achieves an FPR95 reduction of $2 5 . 0 5 \%$ on a large-scale ImageNet benchmark.
3. We provide both empirical ablation and theoretical analysis, revealing important insights that abnormally high activations on OOD data can harm their detection and how ReAct effectively mitigates this issue. We hope that our insights inspire future research to further examine the internal mechanisms of neural networks for OOD detection. Code and dataset will be released for reproducible research.
# 2 Background
The problem of out-of-distribution detection for classification is defined using the following setup. Let $\mathcal { X }$ (resp. $\mathcal { V }$ ) be the input (resp. output) space and let $\mathcal { P }$ be a distribution over $\mathcal { X } \times \mathcal { V }$ . Let $f : \mathcal { X } \to \mathbb { R } ^ { | \mathcal { V } | }$ be a neural network trained on samples drawn from $\mathcal { P }$ to output a logit vector, which is used to predict the label of an input sample. Denote by $\mathcal { D } _ { \mathrm { i n } }$ the marginal distribution of $\mathcal { P }$ for $\mathcal { X }$ , which represents the distribution of in-distribution data. At test time, the environment can present a distribution $\mathcal { D } _ { \mathrm { o u t } }$ over $\mathcal { X }$ of out-of-distribution data. The goal of OOD detection is to define a decision function $G$ such that for a given test input $\mathbf { x } \in \mathcal { X }$ :
$$\begin{array} { r } { G ( \mathbf { x } ; f ) = \left\{ \begin{array} { l l } { 0 } & { \mathrm { i f } \mathbf { x } \sim \mathcal { D } _ { \mathrm { o u t } } , } \\ { 1 } & { \mathrm { i f } \mathbf { x } \sim \mathcal { D } _ { \mathrm { i n } } . } \end{array} \right. } \end{array}$$
The difficulty of OOD detection greatly depends on the separation between $\mathcal { D } _ { \mathrm { i n } }$ and $\mathcal { D } _ { \mathrm { o u t } }$ . In the extreme case, if $\mathcal { D } _ { \mathrm { i n } } = \mathcal { D } _ { \mathrm { o u t } }$ then the optimal decision function is a random coin flip. In practice, $\mathcal { D } _ { \mathrm { o u t } }$ is often defined by a distribution that simulates unknowns encountered during deployment time, such as samples from an irrelevant distribution whose label set has no intersection with $\mathcal { V }$ and therefore should not be predicted by the model.
# 3 Method
We introduce a simple and surprisingly effective technique, Rectified Activations (ReAct), for improving OOD detection performance. Our key idea is to perform post hoc modification to the unit activation, so to bring the overall activation pattern closer to the well-behaved case. Specifically, we consider a pre-trained neural network parameterized by $\theta$ , which encodes an input $\mathbf { x } \in \mathbb { R } ^ { d }$ to a feature space with dimension $m$ . We denote by $h ( \mathbf { x } ) \in \mathbb { R } ^ { \bar { m } }$ the feature vector from the penultimate layer of the network. A weight matrix $\mathbf { W } \in \mathbb { R } ^ { m \times K }$ connects the feature $h ( \mathbf { x } )$ to the output $f ( \mathbf { x } )$ , where $K$ is the total number of classes in $\mathcal { V } = \{ 1 , 2 , . . . , K \}$ .
ReAct: Rectified Activation. We propose the ReAct operation, which is applied on the penultimate layer of a network:
$$\begin{array} { r } { \bar { h } ( \mathbf { x } ) = \mathtt { R e A c t } ( h ( \mathbf { x } ) ; c ) , } \end{array}$$
where $\mathtt { R e A c t } ( x ; c ) = \operatorname* { m i n } ( x , c )$ and is applied element-wise to the feature vector $h ( \mathbf { x } )$ . In effect, this operation truncates activations above $c$ to limit the effect of noise. The model output after rectified activation is given by:
$$f ^ { \mathrm { R e A c t } } ( \mathbf { x } ; \boldsymbol { \theta } ) = \mathbf { W } ^ { \top } \bar { h } ( \mathbf { x } ) + \mathbf { b } ,$$
where $\mathbf { b } \in \mathbb { R } ^ { K }$ is the bias vector. A higher $c$ indicates a larger threshold of activation truncation. When $c = \infty$ , the output becomes equivalent to the original output $f ( \mathbf { x } ; \theta )$ without rectification, where $f ( \mathbf { x } ; \theta ) = \mathbf { W } ^ { \top } h ( \mathbf { x } ) + \mathbf { b }$ . Ideally, the rectification parameter $c$ should be chosen to sufficiently preserve the activations for ID data while rectifying that of OOD data. In practice, we set $c$ based on the $p$ -th percentile of activations estimated on the ID data. For example, when $p = 9 0$ , it indicates that $90 \%$ percent of the ID activations are less than the threshold $c$ . We discuss the effect of percentile in detail in Section 4.
OOD detection with rectified activation. During test time, ReAct can be leveraged by a variety of downstream OOD scoring functions relying on $f ^ { \widetilde { \mathrm { R e A c t } } } ( \mathbf { x } ; \theta )$ :
$$G _ { \lambda } ( \mathbf { x } ; f ^ { \mathrm { R e A c t } } ) = \left\{ { \begin{array} { l l } { \mathrm { i n } } & { S ( \mathbf { x } ; f ^ { \mathrm { R e A c t } } ) \geq \lambda } \\ { \mathrm { o u t } } & { S ( \mathbf { x } ; f ^ { \mathrm { R e A c t } } ) < \lambda } \end{array} } , \right.$$
where a thresholding mechanism is exercised to distinguish between $\mathrm { I D }$ and OOD during test time. To align with the convention, samples with higher scores $S ( \mathbf { x } ; f )$ are classified as ID and vice versa. The threshold $\lambda$ is typically chosen so that a high fraction of ID data (e.g., $9 5 \%$ ) is correctly classified. ReAct can be compatible with several commonly used OOD scoring functions derived from the model output $f ( \mathbf { x } ; \theta )$ , including the softmax confidence $\mathbb { \left. \boldsymbol { \cdot } \boldsymbol { \cdot } \right. }$ , ODIN score $\pmb { \mathbb { B } } \pmb { \mathbb { 1 } }$ , and the energy score $\mathbb { \lVert 3 3 \rVert }$ . For readers’ convenience, we provide an expansive description of these methods in Appendix $\boxed { \mathbf { B } }$ In Section $^ { 4 , }$ we default to using the energy score (since it is hyperparameter-free and does not require fine-tuning), but demonstrate the benefit of using ReAct with other OOD scoring functions too.
<table><tr><td rowspan="3">Model</td><td rowspan="3">Methods</td><td colspan="7">OODDatasets</td><td rowspan="2" colspan="2">Average</td></tr><tr><td colspan="2">iNaturalist</td><td colspan="2">SUN</td><td colspan="2">Places</td><td colspan="2">Textures</td></tr><tr><td>FPR95</td><td>AUROC</td><td>FPR95</td><td>AUROC 个</td><td>FPR95</td><td>AUROC</td><td>FPR95</td><td>AUROC</td><td>FPR95 AUROC</td></tr><tr><td rowspan="6">ResNet</td><td>MSP 园</td><td>↓ 54.99</td><td>→ 87.74</td><td>√ 70.83</td><td>80.86</td><td>↓ 73.99</td><td>个 79.76</td><td>↓ 68.00</td><td>↑ 79.61</td><td>√ 66.95</td><td>→ 81.99</td></tr><tr><td>ODIN 白</td><td>47.66</td><td>89.66</td><td>60.15</td><td>84.59</td><td>67.89</td><td>81.78</td><td>50.23</td><td>85.62</td><td>56.48</td><td>85.41</td></tr><tr><td>Mahalanobis [ 29</td><td>97.00</td><td>52.65</td><td>98.50</td><td>42.41</td><td>98.40</td><td>41.79</td><td>55.80</td><td>85.01</td><td>87.43</td><td>55.47</td></tr><tr><td>Energy 国</td><td>55.72</td><td>89.95</td><td>59.26</td><td>85.89</td><td>64.92</td><td>82.86</td><td>53.72</td><td>85.99</td><td>58.41</td><td>86.17</td></tr><tr><td>ReAct (Ours)</td><td>20.38</td><td>96.22</td><td>24.20</td><td>94.20</td><td>33.85</td><td>91.58</td><td>47.30</td><td>89.80</td><td>31.43</td><td>92.95</td></tr><tr><td></td><td></td><td></td><td>77.02</td><td></td><td>79.23</td><td>76.27</td><td></td><td>77.30</td><td>73.51</td><td>79.00</td></tr><tr><td rowspan="5">MobileNet</td><td>MSP 固</td><td>64.29</td><td>85.32 87.62</td><td>54.07</td><td>77.10 85.88</td><td></td><td></td><td>73.51</td><td>85.03</td><td>54.20</td><td>85.81</td></tr><tr><td>ODIN 白 四</td><td>55.39 62.11</td><td>81.00</td><td>47.82</td><td>86.33</td><td>57.36 52.09</td><td>84.71 83.63</td><td>49.96 92.38</td><td>33.06</td><td>63.60</td><td>71.01</td></tr><tr><td>Mahalanobis</td><td>59.50</td><td>88.91</td><td>62.65</td><td>84.50</td><td>69.37</td><td>81.19</td><td>58.05</td><td>85.03</td><td>62.39</td><td>84.91</td></tr><tr><td>Energy 国 ReAct (Ours)</td><td>42.40</td><td>91.53</td><td>47.69</td><td>88.16</td><td>51.56</td><td>86.64</td><td>38.42</td><td>91.53</td><td>45.02</td><td>89.47</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
Table 1: Main results. Comparison with competitive post hoc out-of-distribution detection methods. All methods are based on a model trained on ID data only (ImageNet-1k), without using any auxiliary outlier data. $\uparrow$ indicates larger values are better and $\downarrow$ indicates smaller values are better. All values are percentages.
# 4 Experiments
In this section, we evaluate ReAct on a suite of OOD detection tasks. We first evaluate a on large-scale OOD detection benchmark based on ImageNet [18] ( Section $\boxed { 4 . 1 }$ , and then proceed in Section 4.2 with CIFAR benchmarks $ { \mathbb { \left[ \left[ 2 7 \right] \right] } }$ .
# 4.1 Evaluation on Large-scale ImageNet Classification Networks
We first evaluate ReAct on a large-scale OOD detection benchmark developed in [18]. Compared to the CIFAR benchmarks that are routinely used in literature, the ImageNet benchmark is more challenging due to a larger label space $( K = 1 , 0 0 0 )$ . Moreover, such large-scale evaluation is more relevant to real-world applications, where the deployed models often operate on images that have high resolution and contain more classes than the CIFAR benchmarks.
Setup. We use a pre-trained ResNet-50 model $[ \mathbb { 1 2 } ]$ for ImageNet-1k. At test time, all images are resized to $2 2 4 \times 2 2 4$ . We evaluate on four test OOD datasets from (subsets of) Places365 $\lVert \rVert \mathbf { 6 } 2 \rVert$ , Textures [5], iNaturalist $\mathbb { I } \mathbb { 1 6 } ]$ , and SUN $\mathbb { \left[ \left. 5 5 \right] \right. }$ with non-overlapping categories w.r.t ImageNet. Our evaluations span a diverse range of domains including fine-grained images, scene images, and textural images (see Appendix $\boxed { \mathbf { C } }$ for details). We use a validation set of Gaussian noise images, which are generated by sampling from $\mathcal { N } ( 0 , 1 )$ for each pixel location. To ensure validity, we further verify the activation pattern under Gaussian noise, which exhibits a similar distributional trend with positive skewness and chaoticness; see Figure $^ { 7 }$ in Appendix $\mathbf { G }$ for details. We select $p$ from $\{ 1 0 , \bar { 6 } 5 , 8 0 , 8 5 , 9 0 , 9 5 , 9 9 \}$ based on the FPR95 performance. The optimal $p$ is 90. All experiments are based on the hardware described in Appendix D.
Comparison with competitive OOD detection methods. In Table 1, we compare ReAct with OOD detection methods that are competitive in the literature, where ReAct establishes the state-of-the-art performance. For a fair comparison, all methods use the pre-trained networks post hoc. We report performance for each OOD test dataset, as well as the average of the four. ReAct outperforms all baselines considered, including Maximum Softmax Probability $\mathbb { \lVert 1 5 \rVert }$ , ODIN $\pmb { \mathbb { B } } \mathbf { \mathbb { 1 } }$ , Mahalanobis distance $\mathbb { \left. 2 9 \right. }$ , and energy score $\bar { \big \| } \bar { 3 3 } \big \|$ . Noticeably, ReAct reduces the FPR95 by $2 5 . 0 5 \%$ compared to the best baseline $\pmb { \mathbb { B } } \mathbf { \mathbb { 1 } }$ on ResNet. Note that Mahalanobis requires training a separate binary classifier, and displays limiting performance since the increased size of label space makes the class-conditional Gaussian density estimation less viable. In contrast, ReAct is much easier to use in practice, and can be implemented through a simple post hoc activation rectification.
Effect of rectification threshold $c$ . We now characterize the effect of the rectification parameter $c$ , which can be modulated by the percentile $p$ described in Section $3 .$ In Table $^ { 2 , }$ we summarize the OOD detection performance, where we vary $p = \{ 1 0 , 6 5 , 8 0 , 8 5 , 9 0 , 9 5 , 9 9 \}$ . This ablation confirms that over-activation does compromise the ability to detect OOD data, and ReAct can effectively alleviate this problem. Moreover, when $p$ is sufficiently large, ReAct can improve OOD detection while maintaining a comparable ID classification accuracy. Alternatively, once a sample is detected to be ID, one can always use the original activation $h ( \dot { \bf x } )$ , which is guaranteed to give identical classification accuracy. When $p$ is too small, OOD performance starts to degrade as expected.
<table><tr><td>Rectification percentile</td><td>FPR95 √</td><td>AUROC →</td><td>AUPR 个</td><td>ID ACC. 个</td><td>Rectification threshold c</td></tr><tr><td>No ReAct 3</td><td>58.41</td><td>86.17</td><td>96.88</td><td>75.08</td><td>8</td></tr><tr><td>p=99</td><td>44.57</td><td>90.45</td><td>97.96</td><td>75.12</td><td>2.25</td></tr><tr><td>p=95</td><td>35.39</td><td>92.39</td><td>98.37</td><td>74.76</td><td>1.50</td></tr><tr><td>p= 90</td><td>31.43</td><td>92.95</td><td>98.50</td><td>73.75</td><td>1.00</td></tr><tr><td>p=85</td><td>34.08</td><td>92.05</td><td>98.35</td><td>72.91</td><td>0.84</td></tr><tr><td>p=80</td><td>41.51</td><td>89.54</td><td>97.91</td><td>71.93</td><td>0.72</td></tr><tr><td>p=65</td><td>74.62</td><td>74.14</td><td>94.39</td><td>67.14</td><td>0.50</td></tr><tr><td>p=10</td><td>74.70</td><td>57.55</td><td>86.06</td><td>1.22</td><td>0.06</td></tr></table>
Table 2: Effect of rectification threshold for inference. Model is trained on ImageNet using ResNet-50 [11]. All numbers are percentages and are averaged over 4 OOD test datasets.
Effect on other network architectures. We show that ReAct is effective on a different architecture in Table $\mathbb { A }$ In particular, we consider a lightweight model MobileNet-v2 [44], which can be suitable for OOD detection in on-device mobile applications. Same as before, we apply ReAct on the output of the penultimate layer, with the rectification threshold chosen based on the 90-th percentile. Our method reduces the FPR95 by $9 . 1 8 \%$ compared to the best baseline [31].
What about applying ReAct on other layers? Our results suggest that applying ReAct on the penultimate layer is the most effective, since the activation patterns are most distinctive. To see this, we provide the activation and performance study for intermediate layers in Appendix E (see Figure 6 and Table $^ { 6 ) }$ . Interestingly, early layers display less distinctive signatures between ID and OOD data. This is expected because neural networks generally capture lower-level features in early layers (such as Gabor filters $\left[ \left[ 6 1 \right] \right]$ in layer 1), whose activations can be very similar between ID and OOD. The semantic-level features only emerge as with deeper layers, where ReAct is the most effective.
# 4.2 Evaluation on CIFAR Benchmarks
Datasets. We evaluate on CIFAR-10 and CIFAR-100 [27] datasets as in-distribution data, using the standard split with 50,000 training images and 10,000 test images. For OOD data, we consider six common benchmark datasets: Textures [5], SVHN [37], Places365 [62], LSUN-Crop [60], LSUN-Resize $\pmb { \mathbb { H } }$ , and iSUN [57].
Experimental details. We train a standard ResNet-18 [11] model on in-distribution data. The feature dimension of the penultimate layer is 512. For both CIFAR-10 and CIFAR-100, the models are trained for 100 epochs. The start learning rate is 0.1 and decays by a factor of 10 at epochs 50, 75, and 90. For threshold $c$ , we use the 90-th percentile of activations estimated on the ID data.
ReAct is compatible with various OOD scoring functions. We show in Table $\textcircled { 3 }$ that ReAct is a flexible method that is compatible with alternative scoring functions $S ( \mathbf { x } ; f ^ { \mathrm { R e A c t } } )$ . To see this, we consider commonly used scoring functions, and compare the performance both with and without using ReAct respectively. In particular, we consider softmax confidence $\mathbb { \lVert 1 5 \rVert }$ , ODIN score $\textcircled { \scriptsize { 1 3 1 } }$ as well as energy score [33]— all of which derive OOD scores directly from the output $f ( \mathbf { x } )$ . In particular, using ReAct on energy score yields the best performance, which is desirable as energy is a hyperparameter-free OOD score and is easy to compute in practice. Note that Mahalanobis $\overline { { \| 2 9 } }$ estimates OOD score using feature representations instead of the model output $f ( \mathbf { x } )$ , hence is less compatible with ReAct. On all three in-distribution datasets, using ReAct consistently outperforms the counterpart without rectification. Results in Table $3$ are based on the average across multiple OOD test datasets. Detailed performance for each OOD test dataset is provided in Appendix, Table 7.
<table><tr><td rowspan="2">Method</td><td colspan="3">CIFAR-10</td><td colspan="3">CIFAR-100</td><td colspan="3">ImageNet</td></tr><tr><td>FPR95 √</td><td>AUROC →</td><td>AUPR →</td><td>FPR95 ←</td><td>AUROC →</td><td>AUPR 个</td><td>FPR95 ←</td><td>AUROC →</td><td>AUPR →</td></tr><tr><td>Softmax score 园</td><td>56.71</td><td>91.17</td><td>79.11</td><td>80.72</td><td>76.83</td><td>78.41</td><td>66.95</td><td>81.99</td><td>95.76</td></tr><tr><td>Softmax score + ReAct</td><td>53.81</td><td>91.70</td><td>92.11</td><td>75.45</td><td>80.40</td><td>84.28</td><td>58.28</td><td>87.06</td><td>97.22</td></tr><tr><td>Energy B3</td><td>35.60</td><td>93.57</td><td>95.01</td><td>71.93</td><td>82.82</td><td>86.28</td><td>58.41</td><td>86.17</td><td>96.88</td></tr><tr><td>Energy+ReAct</td><td>32.91</td><td>94.27</td><td>95.53</td><td>59.61</td><td>87.48</td><td>89.63</td><td> 31.43</td><td>92.95</td><td>98.50</td></tr><tr><td>ODIN B1</td><td>31.10</td><td>93.79</td><td>94.95</td><td>66.21</td><td>82.88</td><td>86.25</td><td>56.48</td><td>85.41</td><td>96.61</td></tr><tr><td>ODIN+ReAct</td><td>28.81</td><td>94.04</td><td>94.82</td><td>59.91</td><td>85.23</td><td>87.53</td><td>44.10</td><td>90.70</td><td>98.04</td></tr></table>
Table 3: Ablation results. ReAct is compatible with different OOD scoring functions. For each ID dataset, we use the same model and compare the performance with and without ReAct respectively. $\uparrow$ indicates larger values are better and $\downarrow$ indicates smaller values are better. All values are percentages and are averaged over multiple OOD test datasets. Detailed performance for each OOD test dataset is available in Table $^ { 7 }$ in Appendix.
 Figure 2: Positively skewed distribution of $\mu _ { i }$ (mean of each unit) in the penultimate layer for four OOD datasets (iNaturalist [16], SUN [55], Places $\pmb { \| 6 2 \| }$ , Textures $\pmb { \| 5 \| }$ ). Model is trained on ImageNet. Note that the right tail has a higher density than the left tail. By left and right tail we refer to the samples that are to the left and right of the median, which is close to the mode in the case of skewed distribution.
# 5 Theoretical Analysis
To better understand the effect of ReAct, we mathematically model the ID and OOD activations as rectified Gaussian distributions and derive their respective distributions after applying ReAct. These modeling assumptions are based on the activation statistics observed on ImageNet in Figure $^ { 1 } .$ In the following analysis, we show that ReAct reduces mean OOD activations more than ID activations since OOD activations are more positively skewed (see Appendix A for derivations).
ID activations. Let $h ( \mathbf { x } ) = ( z _ { 1 } , \ldots , z _ { m } ) = : \mathbf { z }$ be the activations for the penultimate layer. We assume each $z _ { i } \sim \mathcal { N } ^ { R } ( \mu , \sigma _ { \mathrm { i n } } ^ { 2 } )$ for some $\sigma _ { \mathrm { i n } } > 0$ . Here $\mathcal N ^ { R } ( \mu , \sigma _ { \mathrm { i n } } ^ { 2 } ) = \operatorname* { m a x } ( 0 , \mathcal N ( \mu , \sigma _ { \mathrm { i n } } ^ { 2 } ) )$ denotes the rectified Gaussian distribution, which reflects the fact that activations after ReLU have no negative components. Before truncation with ReAct, the expectation of $z _ { i }$ is given by:
$$\mathbb { E } _ { \mathrm { i n } } [ z _ { i } ] = \left[ 1 - \Phi \left( \frac { - \mu } { \sigma _ { \mathrm { i n } } } \right) \right] \cdot \mu + \phi \left( \frac { - \mu } { \sigma _ { \mathrm { i n } } } \right) \cdot \sigma _ { \mathrm { i n } } ,$$
where $\Phi$ and $\phi$ denote the cdf and pdf of the standard normal distribution, respectively. After rectification with ReAct, the expectation of $\bar { z } _ { i } = \operatorname* { m i n } ( z _ { i } , c )$ is:
$$\mathcal { \bar { c } } _ { \mathrm { i n } } \big [ \bar { z } _ { \mathrm { i } } \big ] = \left[ \Phi \left( \frac { c - \mu } { \sigma _ { \mathrm { i n } } } \right) - \Phi \left( \frac { - \mu } { \sigma _ { \mathrm { i n } } } \right) \right] \cdot \mu + \left[ 1 - \Phi \left( \frac { c - \mu } { \sigma _ { \mathrm { i n } } } \right) \right] \cdot c + \left[ \phi \left( \frac { - \mu } { \sigma _ { \mathrm { i n } } } \right) - \phi \left( \frac { c - \mu } { \sigma _ { \mathrm { i n } } } \right) \right] \cdot \sigma _ { \mathrm { i n } } ,$$
The reduction in activation after ReAct is:
$$\mathbb { E } _ { \mathrm { i n } } [ z _ { i } - \bar { z } _ { i } ] = \phi \left( \frac { c - \mu } { \sigma _ { \mathrm { i n } } } \right) \cdot \sigma _ { \mathrm { i n } } - \left[ 1 - \Phi \left( \frac { c - \mu } { \sigma _ { \mathrm { i n } } } \right) \right] \cdot ( c - \mu )$$
OOD activations. We model OOD activations as being generated by a two-stage process: Each OOD distribution defines a set of $\mu _ { i }$ ’s that represent the mode of the activation distribution for unit $i$ , and the activations $z _ { i }$ given $\mu _ { i }$ is represented by $z _ { i } | \mu _ { i } \sim \mathcal { N } ^ { R } ( \mu _ { i } , \tau ^ { 2 } )$ with $\tau > 0$ . For instance, the dark gray line in Figure $^ 1$ shows the set $\mu _ { i }$ ’s on the iNaturalist dataset, and the light gray area depicts the distribution of $z _ { i } | \mu _ { i }$ . One commonality across different OOD datasets is that the distribution of $\mu _ { i }$ is positively skewed. The assumption of positive skewness is motivated by our observation on real OOD data. Indeed, Figure $2$ shows the empirical distribution of $\mu _ { i }$ on an ImageNet pre-trained model for four OOD datasets, all of which display strong positive-skewness, i.e., the right tail has a much higher density than the left tail. This observation is surprisingly consistent across datasets and model architectures. Although a more in-depth understanding of the fundamental cause of positive skewness is important, for this work, we chose to rely on this empirically verifiable assumption and instead focus on analyzing our method ReAct.
Utilizing the positive-skewness property of $\mu _ { i }$ , we analyze the distribution of $z _ { i }$ after marginalizing out $\mu _ { i }$ , which corresponds to averaging across different $\mu _ { i }$ ’s induced by various OOD distributions. Let $\dot { x } _ { i } | \mu _ { i } \sim \mathcal { N } ( \mu _ { i } , \tau ^ { 2 } )$ so that $z _ { i } | \mu _ { i } = \operatorname* { m a x } ( x _ { i } | \mu _ { i } , 0 )$ . Since $x _ { i } | \mu _ { i }$ is symmetric and $\mu _ { i }$ is positivelyskewed, the marginal distribution of $x _ { i }$ is also positively-skewed $\bigstar$ which we model with the epsilonskew-normal (ESN) distribution $\begin{array} { r l } { { \bigl \| \overline { { 3 5 } } \bigr \| } } & { { } } \end{array}$ . Specifically, we assume that $x _ { i } \sim \mathrm { E S N } ( \mu , \sigma _ { \mathrm { o u t } } ^ { 2 } , \epsilon )$ , which has
 Figure 3: Plot showing the relationship between the skewness parameter $\epsilon$ and the chaotic-ness parameter $\sigma$ on activation reduction after applying ReAct. The function $\mathbb { E } [ z _ { i } - \bar { z } _ { i } ]$ is increasing in both $- \epsilon$ and $\sigma$ , which suggests that ReAct has a greater reduction effect for activation distributions with positive skewness $( \epsilon < 0 )$ ) and chaoticness—two signature characteristics of OOD activation.
the following density function:
$$q ( x ) = \left\{ \begin{array} { l l } { \phi ( ( x - \mu ) / \sigma _ { \mathrm { o u t } } ( 1 + \epsilon ) ) / \sigma _ { \mathrm { o u t } } } & { \mathrm { i f ~ } x < \mu , } \\ { \phi ( ( x - \mu ) / \sigma _ { \mathrm { o u t } } ( 1 - \epsilon ) ) / \sigma _ { \mathrm { o u t } } } & { \mathrm { i f ~ } x \geq \mu . } \end{array} \right.$$
with $\epsilon \in [ - 1 , 1 ]$ controlling the skewness. In particular, the ESN distribution is positively-skewed when $\epsilon < 0$ . It follows that $z _ { i } = \operatorname* { m a x } ( x _ { i } , 0 )$ , with expectation:
$$\mathbb { E } _ { \mathrm { o u t } } [ z _ { i } ] = \mu - ( 1 + \epsilon ) \Phi \left( \frac { - \mu } { ( 1 + \epsilon ) \sigma _ { \mathrm { o u t } } } \right) \cdot \mu + ( 1 + \epsilon ) ^ { 2 } \phi \left( \frac { - \mu } { ( 1 + \epsilon ) \sigma _ { \mathrm { o u t } } } \right) \cdot \sigma _ { \mathrm { o u t } } - \frac { 4 \epsilon } { \sqrt { 2 \pi } } \cdot \sigma _ { \mathrm { o u t } } .$$
Expectation after applying ReAct becomes:
$$\begin{array} { r } { \mathbb { E } _ { \mathrm { o u t } } [ \bar { z } _ { i } ] = \mu - ( 1 + \epsilon ) \Phi \left( \frac { - \mu } { ( 1 + \epsilon ) \sigma _ { \mathrm { o u t } } } \right) \cdot \mu + ( 1 - \epsilon ) \left[ 1 - \Phi \left( \frac { c - \mu } { ( 1 - \epsilon ) \sigma _ { \mathrm { o u t } } } \right) \right] \cdot ( c - \mu ) } \\ { + \left[ ( 1 + \epsilon ) ^ { 2 } \phi \left( \frac { - \mu } { ( 1 + \epsilon ) \sigma _ { \mathrm { o u t } } } \right) - ( 1 - \epsilon ) ^ { 2 } \phi \left( \frac { c - \mu } { ( 1 - \epsilon ) \sigma _ { \mathrm { o u t } } } \right) - \frac { 4 \epsilon } { \sqrt { 2 \pi } } \right] \cdot \sigma _ { \mathrm { o u t } } , } \end{array}$$
Hence:
$\mathbb { E } _ { \mathrm { o u t } } [ z _ { i } - \bar { z } _ { i } ] = ( 1 - \epsilon ) ^ { 2 } \phi \left( \frac { c - \mu } { ( 1 - \epsilon ) \sigma _ { \mathrm { o u t } } } \right) \cdot \sigma _ { \mathrm { o u t } } - ( 1 - \epsilon ) \left[ 1 - \Phi \left( \frac { c - \mu } { ( 1 - \epsilon ) \sigma _ { \mathrm { o u t } } } \right) \right] \cdot ( c - \mu ) ,$ which recovers Equation 4 when $\epsilon = 0$ and $\sigma _ { \mathrm { o u t } } = \sigma _ { \mathrm { i n } }$ .
Remark 1: Activation reduction on OOD is more than ID. Figure 3 shows a plot of $\mathbb { E } [ z _ { i } - \bar { z } _ { i } ]$ for $\mu = 0 . 5$ and $c = 1$ . Observe that decreasing $\epsilon$ (more positive-skewness) or increasing $\sigma$ (more chaotic-ness) leads to a larger reduction in the mean activation after applying ReAct. For example, under the same $\sigma$ , a larger $\mathbb { E } _ { \mathrm { o u t } } [ z _ { i } - \bar { z } _ { i } ] - \mathbb { E } _ { \mathrm { i n } } [ z _ { i } - \bar { z } _ { i } ]$ can be observed by the gap of $z$ -axis value between $\epsilon = 0$ and $\epsilon < 0$ (e.g., $\epsilon = - 0 . 4 )$ . This suggests that rectification on average affects OOD activations more severely compared to ID activations.
Remark 2: Output reduction on OOD is more than ID. To derive the effect on the distribution of model output, consider output logits $f ( \mathbf { z } ) = W \mathbf { z } + \mathbf { b }$ and assume without loss of generality that $W \mathbf { 1 } > 0$ element-wise. This can be achieved by adding a positive constant to $W$ without changing the output probabilities or classification decision. Let $\begin{array} { r } { \bar { \boldsymbol \delta } = \mathbf { \dot { \mathbb { E } } _ { \mathrm { o u t } } } [ \mathbf { z } - \bar { \mathbf { z } } ] - \mathbb { E } _ { \mathrm { i n } } [ \mathbf { z } - \bar { \mathbf { z } } ] > 0 . } \end{array}$ Then:
$$\begin{array} { r l } & { \mathbb { E } _ { \mathrm { o u t } } [ f ( \mathbf { z } ) - f ( \bar { \mathbf { z } } ) ] = \mathbb { E } _ { \mathrm { o u t } } [ W ( \mathbf { z } - \bar { \mathbf { z } } ) ] = W \mathbb { E } _ { \mathrm { o u t } } [ \mathbf { z } - \bar { \mathbf { z } } ] = W \left( \mathbb { E } _ { \mathrm { i n } } [ \mathbf { z } - \bar { \mathbf { z } } ] + \delta \mathbf { 1 } \right) } \\ & { \qquad = \mathbb { E } _ { \mathrm { i n } } [ W ( \mathbf { z } - \bar { \mathbf { z } } ) ] + \delta W \mathbf { 1 } } \\ & { \qquad > \mathbb { E } _ { \mathrm { i n } } [ f ( \mathbf { z } ) - f ( \bar { \mathbf { z } } ) ] . } \end{array}$$
Hence the increased separation between OOD and $\mathrm { I D }$ activations transfers to the output space as well. Note that the condition of $W \mathbf { 1 } > 0$ is sufficient but not necessary for this result to hold. In fact, our experiments in Section $\textcircled { 4 } \mathrm { d o }$ not require this condition. However, we verified empirically that ensuring $W \mathbf { 1 } > 0$ by adding a positive constant to $W$ and applying ReAct does confer benefits to OOD detection, which validates our theoretical analysis.
Why ReAct improves the OOD scoring functions? Our theoretical analysis above shows that ReAct suppresses logit output for OOD data more so than for ID data. This means that for detection scores depending on the logit output (e.g., energy score $\mathbb { \lVert 3 3 \rVert }$ ), the gap between OOD and ID score will be enlarged after applying ReAct, which makes thresholding more capable of separating OOD and ID inputs; see Figure 1(a) and (c) for a concrete example showing this effect.
# 6 Discussion and Further Analysis
Why do OOD samples trigger abnormal unit activation patterns? So far we have shown that OOD data can trigger unit activation patterns that are significantly different from ID data, and that ReAct can effectively alleviate this issue (empirically in Section $^ 4$ and theoretically in Section 5). Yet a question left in mystery is why such a pattern occurs in modern neural networks? Answering this question requires carefully examining the internal mechanism by which the network is trained and evaluated. Here we provide one plausible explanation for the activation patterns observed in Figure 1, with the hope of shedding light for future research.
Intriguingly, our analysis reveals an important insight that batch normalization (BatchNorm) $[ [ 2 2 ] ] { - \mathsf { a } }$ common technique employed during model training—is in fact both a blessing (for ID classification) and a curse (for OOD detection). Specifically, for a unit activation denoted by $z$ , the network estimates the running mean $\mathbb { E } _ { \mathrm { i n } } ( z )$ and variance $\mathrm { V a r } _ { \mathrm { i n } } ( z )$ , over the entire ID training set during training. During inference time, the network applies BatchNorm statistics $\mathbb { E } _ { \mathrm { i n } } ( z )$ and $\mathrm { V a r } _ { \mathrm { i n } } ( z )$ , which helps normalize the activations for the test data with the same distribution $\mathcal { D } _ { \mathrm { i n } }$ :
$$\mathrm { B a t c h N o r m } ( z ; \gamma , \beta , \epsilon ) = \frac { z - \mathbb { E } _ { \mathrm { i n } } [ z ] } { \sqrt { \mathrm { V a r } _ { \mathrm { i n } } [ z ] + \epsilon } } \cdot \gamma + \beta$$
However, our key observation is that using mismatched BatchNorm statistics—that are estimated on $\mathcal { D } _ { \mathrm { i n } }$ yet blindly applied to the OOD $\mathcal { D } _ { \mathrm { o u t } }$ —can trigger abnormally high unit activations. As a thought experiment, we instead apply the true BatchNorm statistics estimated on a batch of OOD images and we observe well-behaved activation patterns with near-constant mean and standard deviations—just like the ones observed on the ID data (see Figure $\mathbb { E } ,$ top). Our study therefore reveals one of the fundamental causes for neural networks to produce overconfident predictions for OOD data. After applying the true statistics (estimated on OOD), the output distributions between ID and OOD data become much more separable. While this thought experiment has shed some guiding light, the solution of estimating BatchNorm statistics on a batch of OOD data is not at all satisfactory and realistic. Arguably, it poses a strong and impractical assumption of having access to a batch of OOD data during test time. Despite its limitation, we view it as an oracle, which serves as an upper bound on performance for ReAct.
 Figure 4: The distribution of per-unit activations in the penultimate layer for OOD data (iNaturalist) by using true (top) vs. mismatched (bottom) BatchNorm statistics for OOD data.
<table><tr><td>Method</td><td>iNaturalist</td><td>Places</td><td>SUN</td><td>Textures</td></tr><tr><td>Oracle (batch OOD for estimating BN statistics)</td><td>99.59</td><td>99.09</td><td>98.32</td><td>91.43</td></tr><tr><td>ReAct (single OOD)</td><td>96.22</td><td>94.20</td><td>91.58</td><td>89.80</td></tr><tr><td>No ReAct B3</td><td>89.95</td><td>85.89</td><td>82.86</td><td>85.99</td></tr></table>
Table 4: Comparison with oracle using OOD BN statistics. Model is trained on ImageNet (see Section 4.1) Values are AUROC.
In particular, results in Table $\boxed { \sharp }$ suggest that our method favorably matches the oracle performance using the ground truth BN statistics. This is encouraging as our method does not impose any batch assumption and can be feasible for single-input testing scenarios.
What about networks trained with different normalization mechanisms? Going beyond batch normalization $\pmb { \left. 2 2 \right. }$ , we further investigate (1) whether networks trained with alternative normalization approaches exhibit similar activation patterns, and (2) whether ReAct is helpful there. To answer this question, we additionally evaluate networks trained with WeightNorm $\underline { { \hat { \vert 4 3 \vert } } }$ and GroupNorm [54]— two other well-known normalization methods. As shown in Figure $\triangledown$ the unit activations also display highly distinctive signature patterns between ID and OOD data, with more chaos on OOD data. In all cases, the networks are trained to adapt to the ID data, resulting in abnormal activation signatures on OOD data in testing. Unlike BatchNorm, there is no easy oracle (e.g., re-estimating the statistics on OOD data) to counteract the ill-fated normalizations.
We apply ReAct on models trained with WeightNorm and GroupNorm, and report results in Table 5. Our results suggest that ReAct is consistently effective under various normalization schemes. For example, ReAct reduces the average FPR95 by $2 3 . 5 4 \%$ and $1 4 . 7 \%$ respectively. Overall, ReAct has shown broad efficacy and compatibility with different OOD scoring functions (Section $4 . 2 )$
 Model: WeightNormFigure 5: The distribution of per-unit activations in the penultimate layer for ID (ImageNet $\pmb { \mathbb { Z } } \mathbf { I }$ ) and OOD (iNaturalist $\pm \boxed { 1 6 }$ ) on model trained with weight normalization [43]. Table 5: Effectiveness of ReAct for different normalization methods. ReAct consistently improves OOD detection performance for the model trained with GroupNorm and WeightNorm. In-distribution is ImageNet-1k dataset. Bold numbers are superior results.
<table><tr><td rowspan="3"></td><td rowspan="3">Methods</td><td colspan="8">OODDatasets</td><td rowspan="2" colspan="2">Average</td></tr><tr><td colspan="2">iNaturalist</td><td colspan="2">SUN</td><td colspan="2">Places</td><td colspan="2">Textures</td></tr><tr><td>FPR95 ↓</td><td>AUROC 个</td><td>FPR95 ↓</td><td>AUROC 个</td><td>FPR95</td><td>AUROC</td><td>FPR95</td><td>AUROC 个</td><td>FPR95 ↓</td><td>AUROC 个</td></tr><tr><td rowspan="2">GroupNorm</td><td>w.o.ReAct</td><td>65.38</td><td>88.45</td><td>65.11</td><td>85.52</td><td>↓ 65.46</td><td>个 84.34</td><td>↓ 69.17</td><td>83.22</td><td>66.28</td><td>85.38</td></tr><tr><td>w/ReAct</td><td>39.45</td><td>92.95</td><td>51.57</td><td>87.90</td><td>52.78</td><td>87.32</td><td>62.50</td><td>81.76</td><td>51.58</td><td>87.48</td></tr><tr><td rowspan="2">WeightNorm</td><td>w.o. ReAct</td><td>40.71</td><td>92.52</td><td>48.07</td><td>89.39</td><td>50.92</td><td>87.87</td><td>61.65</td><td>80.71</td><td>50.34</td><td>87.62</td></tr><tr><td>w/ReAct</td><td>19.73</td><td>95.91</td><td>31.39</td><td>93.21</td><td>42.34</td><td>88.94</td><td>13.74</td><td>96.98</td><td>26.80</td><td>93.76</td></tr></table>
# 7 Related Work
OOD uncertainty estimation with discriminative models. The problem of classification with rejection can date back to early works on abstention [4, 10], which considered simple model families such as SVMs $\pmb { \Vert 6 \Vert }$ . A comprehensive survey on OOD detection can be found in $\left[ \left[ 5 8 \right] \right]$ . The phenomenon of neural networks’ overconfidence in out-of-distribution data is first revealed by Nguyen et al. [38]. Early works attempted to improve the OOD uncertainty estimation by proposing the ODIN score [17, 31], OpenMax score $\pmb { \mathbb { B } } \|$ , and Mahalanobis distance-based score $\pmb { \mathbb { Z } } \pmb { \mathcal { 0 } }$ . Recent work by Liu et al. [33] proposed using an energy score for OOD uncertainty estimation, which can be easily derived from a discriminative classifier and demonstrated advantages over the softmax confidence score both empirically and theoretically. Wang et al. [51] further showed an energy-based approach can improve OOD uncertainty estimation for multi-label classification networks. Huang and Li [18] revealed that approaches developed for common CIFAR benchmarks might not translate effectively into a large-scale ImageNet benchmark, highlighting the need to evaluate OOD uncertainty estimation in a large-scale real-world setting. Previous methods primarily derive OOD scores using original activations. In contrast, our work is motivated by a novel analysis of internal activations, and shows that rectifying activations is a surprisingly effective approach for OOD detection.
Neural network activation analysis. Neural networks have been studied at the granularity of the activation of individual layers [21, 34, 59, 63], or individual networks $\textcircled { \lvert 3 0 \rvert }$ . In particular, Li et al. [30] studied the similarity of activation space between two independently trained neural networks.
Previously, $\underline { { \mathrm { f l e i n ~ e t ~ a l . } } } \underline { { \mathbb { ( } \mathbb { 1 3 } } } \|$ showed that neural networks with ReLU activation can lead to arbitrary high activation for inputs far away from the training data. We show that using ReAct could efficiently alleviate this undesirable phenomenon. ReAct does not rely on auxiliary data and can be conveniently used for pre-trained models. The idea of rectifying unit activation $\dot { \mathbb { Z } } \dot { 6 } \mathbb { I }$ , which is known as Relu6, was used to facilitate the learning of sparse features. In this paper, we first show that rectifying activation can drastically alleviate the overconfidence issue for OOD data, and as a result, improve OOD detection.
OOD uncertainty estimation with generative models. Alternative approaches for detecting OOD inputs resort to generative models that directly estimate density [8, 20, 23, 41, 49, 50]. An input is deemed as OOD if it lies in the low-likelihood regions. A plethora of literature has emerged to utilize generative models for OOD detection [24, 40, 45, 46, 52, 56]. Interestingly, Nalisnick et al. [36] showed that deep generative models can assign a high likelihood to OOD data. Moreover, generative models can be prohibitively challenging to train and optimize, and the performance can often lag behind the discriminative counterpart. In contrast, our method relies on a discriminative classifier, which is easier to optimize and achieves stronger performance.
Distributional shifts. Distributional shifts have attracted increasing research interests $\mathbb { \left[ \left[ 2 5 \right] \right] }$ . It is important to recognize and differentiate various types of distributional shift problems. Literature in OOD detection is commonly concerned about model reliability and detection of label-space shifts, where the OOD inputs have disjoint labels w.r.t. ID data and therefore should not be predicted by the model. Meanwhile, some works considered label distribution shift [1, 2, 32, 42, 47, 53], where the label space is common between ID and OOD but the marginal label distribution changes, as well as covariate shift in the input space [14, 39], where inputs can be corruption-shifted or domainshifted $ { \mathbb { I } } { \mathrm { I Z } } , { \mathbb { H } } { \mathrm { 8 l } }$ . It is important to note that our work focuses on the detection of shifts where the label space $\mathcal { V }$ is different between ID and OOD data and hence the model should not make any prediction, instead of label distribution shift and covariate shift where the model is expected to generalize.
# 8 Conclusion
This paper provides a simple activation rectification strategy termed ReAct, which truncates the high activations during test time for OOD detection. We provide both empirical and theoretical insights characterizing and explaining the mechanism by which ReAct improves OOD uncertainty estimation. By rectifying the activations, the outsized contribution of hidden units on OOD output can be attenuated, resulting in a stronger separability from ID data. Extensive experiments show ReAct can significantly improve the performance of OOD detection on both common benchmarks and large-scale image classification models. Applications of multi-class classification can benefit from our method, and we anticipate further research in OOD detection to extend this work to tasks beyond image classification. We hope that our insights inspire future research to further examine the internal mechanisms of neural networks for OOD detection.
# 9 Societal Impact
Our project aims to improve the dependability and trustworthiness of modern machine learning models. This stands to benefit a wide range of fields and societal activities. We believe out-ofdistribution uncertainty estimation is an increasingly critical component of systems that range from consumer and business applications (e.g., digital content understanding) to transportation (e.g., driver assistance systems and autonomous vehicles), and to health care (e.g., unseen disease identification). Many of these applications require classification models in operation. Through this work and by releasing our code, we hope to provide machine learning researchers with a new methodological perspective and offer machine learning practitioners a plug-and-play tool that renders safety against OOD data in the real world. While we do not anticipate any negative consequences to our work, we hope to continue to build on our method in future work.
# Acknowledgement
YS and YL are supported by the Office of the Vice Chancellor for Research and Graduate Education (OVCRGE) with funding from the Wisconsin Alumni Research Foundation (WARF).
References [1] Amr Alexandari, Anshul Kundaje, and Avanti Shrikumar. Maximum likelihood with biascorrected calibration is hard-to-beat at label shift adaptation. In International Conference on Machine Learning, pages 222–232. PMLR, 2020. [2] Kamyar Azizzadenesheli, Anqi Liu, Fanny Yang, and Animashree Anandkumar. Regularized learning for domain adaptation under label shifts. In International Conference on Learning Representations, 2019. [3] Abhijit Bendale and Terrance E Boult. Towards open set deep networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 1563–1572, 2016. [4] CK Chow. On optimum recognition error and reject tradeoff. IEEE Transactions on information theory, 16(1):41–46, 1970. [5] Mircea Cimpoi, Subhransu Maji, Iasonas Kokkinos, Sammy Mohamed, and Andrea Vedaldi. Describing textures in the wild. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 3606–3613, 2014. [6] Corinna Cortes and Vladimir Vapnik. Support-vector networks. Machine learning, 20(3): 273–297, 1995. [7] Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In IEEE conference on computer vision and pattern recognition, pages 248–255, 2009. [8] Laurent Dinh, Jascha Sohl-Dickstein, and Samy Bengio. Density estimation using real NVP. In 5th International Conference on Learning Representations, ICLR 2017, 2017. [9] Angelos Filos, Panagiotis Tigkas, Rowan McAllister, Nicholas Rhinehart, Sergey Levine, and Yarin Gal. Can autonomous vehicles identify, recover from, and adapt to distribution shifts? In International Conference on Machine Learning, pages 3145–3153. PMLR, 2020. [10] Giorgio Fumera and Fabio Roli. Support vector machines with embedded reject option. In International Workshop on Support Vector Machines, pages 68–82. Springer, 2002. [11] 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. [12] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Identity mappings in deep residual networks. In European conference on computer vision, pages 630–645. Springer, 2016. [13] Matthias Hein, Maksym Andriushchenko, and Julian Bitterwolf. Why relu networks yield high-confidence predictions far away from the training data and how to mitigate the problem. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), June 2019. [14] Dan Hendrycks and Thomas Dietterich. Benchmarking neural network robustness to common corruptions and perturbations. arXiv preprint arXiv:1903.12261, 2019. [15] Dan Hendrycks and Kevin Gimpel. A baseline for detecting misclassified and out-of-distribution examples in neural networks. Proceedings of International Conference on Learning Representations, 2017. [16] Grant Horn, Oisin Aodha, Yang Song, Yin Cui, Chen Sun, Alex Shepard, Hartwig Adam, Pietro Perona, and Serge Belongie. The iNaturalist Species Classification and Detection Dataset. 06 2018. [17] Yen-Chang Hsu, Yilin Shen, Hongxia Jin, and Zsolt Kira. Generalized odin: Detecting outof-distribution image without learning from out-of-distribution data. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10951–10960, 2020.
[18] Rui Huang and Yixuan Li. Mos: Towards scaling out-of-distribution detection for large semantic space. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 8710–8719, June 2021.
[19] Rui Huang, Andrew Geng, and Yixuan Li. On the importance of gradients for detecting distributional shifts in the wild. In Advances in Neural Information Processing Systems, 2021.
[20] Xun Huang, Yixuan Li, Omid Poursaeed, John E Hopcroft, and Serge J Belongie. Stacked generative adversarial networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, volume 2, page 3, 2017.
[21] Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In Francis Bach and David Blei, editors, Proceedings of the 32nd International Conference on Machine Learning, volume 37 of Proceedings of Machine Learning Research, pages 448–456, Lille, France, 07–09 Jul 2015. PMLR.
[22] 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.
[23] Diederik P. Kingma and Max Welling. Auto-encoding variational bayes. In Yoshua Bengio and Yann LeCun, editors, 2nd International Conference on Learning Representations, ICLR 2014, 2014.
[24] Polina Kirichenko, Pavel Izmailov, and Andrew G Wilson. Why normalizing flows fail to detect out-of-distribution data. Advances in Neural Information Processing Systems, 33, 2020.
[25] Pang Wei Koh, Shiori Sagawa, Sang Michael Xie, Marvin Zhang, Akshay Balsubramani, Weihua Hu, Michihiro Yasunaga, Richard Lanas Phillips, Irena Gao, Tony Lee, et al. Wilds: A benchmark of in-the-wild distribution shifts. In International Conference on Machine Learning, pages 5637–5664. PMLR, 2021.
[26] Alex Krizhevsky. Convolutional deep belief networks on cifar-10, 2010.
[27] Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009.
[28] Balaji Lakshminarayanan, Alexander Pritzel, and Charles Blundell. Simple and scalable predictive uncertainty estimation using deep ensembles. In Advances in neural information processing systems, pages 6402–6413, 2017.
[29] Kimin Lee, Kibok Lee, Honglak Lee, and Jinwoo Shin. A simple unified framework for detecting out-of-distribution samples and adversarial attacks. In Advances in Neural Information Processing Systems, pages 7167–7177, 2018.
[30] Yixuan Li, Jason Yosinski, Jeff Clune, Hod Lipson, and John E Hopcroft. Convergent learning: Do different neural networks learn the same representations? In International Conference on Learning Representations (ICLR), 2016.
[31] Shiyu Liang, Yixuan Li, and Rayadurgam Srikant. Enhancing the reliability of out-ofdistribution image detection in neural networks. In 6th International Conference on Learning Representations, ICLR 2018, 2018.
[32] Zachary Lipton, Yu-Xiang Wang, and Alexander Smola. Detecting and correcting for label shift with black box predictors. In International conference on machine learning, pages 3122–3130. PMLR, 2018.
[33] Weitang Liu, Xiaoyun Wang, John Owens, and Yixuan Li. Energy-based out-of-distribution detection. Advances in Neural Information Processing Systems (NeurIPS), 2020.
[34] Ari S. Morcos, David G.T. Barrett, Neil C. Rabinowitz, and Matthew Botvinick. On the importance of single directions for generalization. In International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id=r1iuQjxCZ.
[35] Govind S Mudholkar and Alan D Hutson. The epsilon–skew–normal distribution for analyzing near-normal data. Journal of statistical planning and inference, 83(2):291–309, 2000.
[36] Eric Nalisnick, Akihiro Matsukawa, Yee Whye Teh, Dilan Gorur, and Balaji Lakshminarayanan. Do deep generative models know what they don’t know? In International Conference on Learning Representations, 2019.
[37] Yuval Netzer, Tao Wang, Adam Coates, Alessandro Bissacco, Bo Wu, and Andrew Y Ng. Reading digits in natural images with unsupervised feature learning. 2011.
[38] Anh Nguyen, Jason Yosinski, and Jeff Clune. Deep neural networks are easily fooled: High confidence predictions for unrecognizable images. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 427–436, 2015.
[39] Yaniv Ovadia, Emily Fertig, Jie Ren, Zachary Nado, D Sculley, Sebastian Nowozin, Joshua Dillon, Balaji Lakshminarayanan, and Jasper Snoek. Can you trust your model’s uncertainty? evaluating predictive uncertainty under dataset shift. Advances in Neural Information Processing Systems, 32:13991–14002, 2019.
[40] Jie Ren, Peter J Liu, Emily Fertig, Jasper Snoek, Ryan Poplin, Mark Depristo, Joshua Dillon, and Balaji Lakshminarayanan. Likelihood ratios for out-of-distribution detection. In Advances in Neural Information Processing Systems, pages 14680–14691, 2019.
[41] Danilo Jimenez Rezende, Shakir Mohamed, and Daan Wierstra. Stochastic backpropagation and approximate inference in deep generative models. arXiv preprint arXiv:1401.4082, 2014.
[42] Marco Saerens, Patrice Latinne, and Christine Decaestecker. Adjusting the outputs of a classifier to new a priori probabilities: a simple procedure. Neural Computation, 14(1):21–41, 2002.
[43] Tim Salimans and Diederik P Kingma. Weight normalization: a simple reparameterization to accelerate training of deep neural networks. In Proceedings of the 30th International Conference on Neural Information Processing Systems, pages 901–909, 2016.
[44] 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 (CVPR), June 2018.
[45] Robin Tibor Schirrmeister, Yuxuan Zhou, Tonio Ball, and Dan Zhang. Understanding anomaly detection with deep invertible networks through hierarchies of distributions and features. arXiv preprint arXiv:2006.10848, 2020.
[46] Joan Serrà, David Álvarez, Vicenç Gómez, Olga Slizovskaia, José F. Núñez, and Jordi Luque. Input complexity and out-of-distribution detection with likelihood-based generative models. In International Conference on Learning Representations, 2020.
[47] Avanti Shrikumar and Anshul Kundaje. Calibration with bias-corrected temperature scaling improves domain adaptation under label shift in modern neural networks. Preprint at https://arxiv. org/abs/1901.06852 v1, 2019.
[48] Yu Sun, Xiaolong Wang, Zhuang Liu, John Miller, Alexei Efros, and Moritz Hardt. Test-time training with self-supervision for generalization under distribution shifts. In International Conference on Machine Learning, pages 9229–9248. PMLR, 2020.
[49] Esteban G Tabak and Cristina V Turner. A family of nonparametric density estimation algorithms. Communications on Pure and Applied Mathematics, 66(2):145–164, 2013.
[50] Aaron Van den Oord, Nal Kalchbrenner, Lasse Espeholt, Oriol Vinyals, Alex Graves, et al. Conditional image generation with pixelcnn decoders. In Advances in neural information processing systems, pages 4790–4798, 2016.
[51] Haoran Wang, Weitang Liu, Alex Bocchieri, and Yixuan Li. Can multi-label classification networks know what they don’t know? Advances in Neural Information Processing Systems, 2021.
[52] Ziyu Wang, Bin Dai, David Wipf, and Jun Zhu. Further analysis of outlier detection with deep generative models. Advances in Neural Information Processing Systems, 33, 2020.
[53] Ruihan Wu, Chuan Guo, Yi Su, and Kilian Q Weinberger. Online adaptation to label distribution shift. arXiv preprint arXiv:2107.04520, 2021. [54] Yuxin Wu and Kaiming He. Group normalization. In Proceedings of the European conference on computer vision (ECCV), pages 3–19, 2018. [55] Jianxiong Xiao, James Hays, Krista A. Ehinger, Aude Oliva, and Antonio Torralba. Sun database: Large-scale scene recognition from abbey to zoo. In CVPR, pages 3485–3492. IEEE Computer Society, 2010. [56] Zhisheng Xiao, Qing Yan, and Yali Amit. Likelihood regret: An out-of-distribution detection score for variational auto-encoder. Advances in Neural Information Processing Systems, 33, 2020. [57] Pingmei Xu, Krista A Ehinger, Yinda Zhang, Adam Finkelstein, Sanjeev R Kulkarni, and Jianxiong Xiao. Turkergaze: Crowdsourcing saliency with webcam based eye tracking. arXiv preprint arXiv:1504.06755, 2015. [58] Jingkang Yang, Kaiyang Zhou, Yixuan Li, and Ziwei Liu. Generalized out-of-distribution detection: A survey. arXiv preprint arXiv:2110.11334, 2021. [59] Jason Yosinski, Jeff Clune, Yoshua Bengio, and Hod Lipson. How transferable are features in deep neural networks? In Advances in Neural Information Processing Systems, volume 27, 2014. [60] Fisher Yu, Ari Seff, Yinda Zhang, Shuran Song, Thomas Funkhouser, and Jianxiong Xiao. Lsun: Construction of a large-scale image dataset using deep learning with humans in the loop. arXiv preprint arXiv:1506.03365, 2015. [61] Matthew D Zeiler and Rob Fergus. Visualizing and understanding convolutional networks. In European conference on computer vision, pages 818–833. Springer, 2014. [62] Bolei Zhou, Agata Lapedriza, Aditya Khosla, Aude Oliva, and Antonio Torralba. Places: A 10 million image database for scene recognition. IEEE transactions on pattern analysis and machine intelligence, 40(6):1452–1464, 2017. [63] Bolei Zhou, Yiyou Sun, David Bau, and Antonio Torralba. Revisiting the importance of individual units in cnns via ablation. arXiv preprint arXiv:1806.02891, 2018.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478# CHARACTERIZING SIGNAL PROPAGATION TO CLOSE THE PERFORMANCE GAP IN UNNORMALIZED RESNETS
Andrew Brock, Soham De & Samuel L. Smith Deepmind {ajbrock, sohamde, slsmith}@google.com
# ABSTRACT
Batch Normalization is a key component in almost all state-of-the-art image classifiers, but it also introduces practical challenges: it breaks the independence between training examples within a batch, can incur compute and memory overhead, and often results in unexpected bugs. Building on recent theoretical analyses of deep ResNets at initialization, we propose a simple set of analysis tools to characterize signal propagation on the forward pass, and leverage these tools to design highly performant ResNets without activation normalization layers. Crucial to our success is an adapted version of the recently proposed Weight Standardization. Our analysis tools show how this technique preserves the signal in networks with ReLU or Swish activation functions by ensuring that the per-channel activation means do not grow with depth. Across a range of FLOP budgets, our networks attain performance competitive with the state-of-the-art EfficientNets on ImageNet. Our code is available at http://dpmd.ai/nfnets.
# 1 INTRODUCTION
BatchNorm has become a core computational primitive in deep learning (Ioffe & Szegedy, 2015), and it is used in almost all state-of-the-art image classifiers (Tan & Le, 2019; Wei et al., 2020). A number of different benefits of BatchNorm have been identified. It smoothens the loss landscape (Santurkar et al., 2018), which allows training with larger learning rates (Bjorck et al., 2018), and the noise arising from the minibatch estimates of the batch statistics introduces implicit regularization (Luo et al., 2019). Crucially, recent theoretical work (Balduzzi et al., 2017; De & Smith, 2020) has demonstrated that BatchNorm ensures good signal propagation at initialization in deep residual networks with identity skip connections (He et al., 2016b;a), and this benefit has enabled practitioners to train deep ResNets with hundreds or even thousands of layers (Zhang et al., 2019).
However, BatchNorm also has many disadvantages. Its behavior is strongly dependent on the batch size, performing poorly when the per device batch size is too small or too large (Hoffer et al., 2017), and it introduces a discrepancy between the behaviour of the model during training and at inference time. BatchNorm also adds memory overhead (Rota Bulo et al., 2018), and is a common source \` of implementation errors (Pham et al., 2019). In addition, it is often difficult to replicate batch normalized models trained on different hardware. A number of alternative normalization layers have been proposed (Ba et al., 2016; Wu & He, 2018), but typically these alternatives generalize poorly or introduce their own drawbacks, such as added compute costs at inference.
Another line of work has sought to eliminate layers which normalize hidden activations entirely. A common trend is to initialize residual branches to output zeros (Goyal et al., 2017; Zhang et al., 2019; De & Smith, 2020; Bachlechner et al., 2020), which ensures that the signal is dominated by the skip path early in training. However while this strategy enables us to train deep ResNets with thousands of layers, it still degrades generalization when compared to well-tuned baselines (De & Smith, 2020). These simple initialization strategies are also not applicable to more complicated architectures like EfficientNets (Tan & Le, 2019), the current state of the art on ImageNet (Russakovsky et al., 2015).
This work seeks to establish a general recipe for training deep ResNets without normalization layers, which achieve test accuracy competitive with the state of the art. Our contributions are as follows:
• We introduce Signal Propagation Plots (SPPs): a simple set of visualizations which help us inspect signal propagation at initialization on the forward pass in deep residual networks. Leveraging these SPPs, we show how to design unnormalized ResNets which are constrained to have signal propagation properties similar to batch-normalized ResNets. We identify a key failure mode in unnormalized ResNets with ReLU or Swish activations and Gaussian weights. Because the mean output of these non-linearities is positive, the squared mean of the hidden activations on each channel grows rapidly as the network depth increases. To resolve this, we propose Scaled Weight Standardization, a minor modification of the recently proposed Weight Standardization (Qiao et al., 2019; Huang et al., 2017b), which prevents the growth in the mean signal, leading to a substantial boost in performance. • We apply our normalization-free network structure in conjunction with Scaled Weight Standardization to ResNets on ImageNet, where we for the first time attain performance which is comparable or better than batch-normalized ResNets on networks as deep as 288 layers. • Finally, we apply our normalization-free approach to the RegNet architecture (Radosavovic et al., 2020). By combining this architecture with the compound scaling strategy proposed by Tan & Le (2019), we develop a class of models without normalization layers which are competitive with the current ImageNet state of the art across a range of FLOP budgets.
# 2 BACKGROUND
Deep ResNets at initialization: The combination of BatchNorm (Ioffe & Szegedy, 2015) and skip connections (Srivastava et al., 2015; He et al., 2016a) has allowed practitioners to train deep ResNets with hundreds or thousands of layers. To understand this effect, a number of papers have analyzed signal propagation in normalized ResNets at initialization (Balduzzi et al., 2017; Yang et al., 2019). In a recent work, De & Smith (2020) showed that in normalized ResNets with Gaussian initializa-√ tion, the activations on the $\ell ^ { t h }$ residual branch are suppressed by factor of $O ( { \sqrt { \ell } } )$ , relative to the scale of the activations on the skip path. This biases the residual blocks in deep ResNets towards the identity function at initialization, ensuring well-behaved gradients. In unnormalized networks, one can preserve this benefit by introducing a learnable scalar at the end of each residual branch, initialized to zero (Zhang et al., 2019; De & Smith, 2020; Bachlechner et al., 2020). This simple change is sufficient to train deep ResNets with thousands of layers without normalization. However, while this method is easy to implement and achieves excellent convergence on the training set, it still achieves lower test accuracies than normalized networks when compared to well-tuned baselines.
These insights from studies of batch-normalized ResNets are also supported by theoretical analyses of unnormalized networks (Taki, 2017; Yang & Schoenholz, 2017; Hanin & Rolnick, 2018; Qi et al., 2020). These works suggest that, in ResNets with identity skip connections, if the signal does not explode on the forward pass, the gradients will neither explode nor vanish on the backward pass. Hanin & Rolnick (2018) conclude that multiplying the hidden activations on the residual branch by a factor of $O ( 1 / d )$ or less, where $d$ denotes the network depth, is sufficient to ensure trainability at initialization.
Alternate normalizers: To counteract the limitations of BatchNorm in different situations, a range of alternative normalization schemes have been proposed, each operating on different components of the hidden activations. These include LayerNorm (Ba et al., 2016), InstanceNorm (Ulyanov et al., 2016), GroupNorm (Wu & He, 2018), and many more (Huang et al., 2020). While these alternatives remove the dependency on the batch size and typically work better than BatchNorm for very small batch sizes, they also introduce limitations of their own, such as introducing additional computational costs during inference time. Furthermore for image classification, these alternatives still tend to achieve lower test accuracies than well-tuned BatchNorm baselines. As one exception, we note that the combination of GroupNorm with Weight Standardization (Qiao et al., 2019) was recently identified as a promising alternative to BatchNorm in ResNet-50 (Kolesnikov et al., 2019).
# 3 SIGNAL PROPAGATION PLOTS
Although papers have recently theoretically analyzed signal propagation in ResNets (see Section 2), practitioners rarely empirically evaluate the scales of the hidden activations at different depths inside a specific deep network when designing new models or proposing modifications to existing architectures. By contrast, we have found that plotting the statistics of the hidden activations at different points inside a network, when conditioned on a batch of either random Gaussian inputs or real training examples, can be extremely beneficial. This practice both enables us to immediately detect hidden bugs in our implementation before launching an expensive training run destined to fail, and also allows us to identify surprising phenomena which might be challenging to derive from scratch.
 Figure 1: Signal Propagation Plot for a ResNetV2-600 at initialization with BatchNorm, ReLU activations and He init, in response to an $\mathcal { N } ( 0 , 1 )$ input at $5 1 2 \mathrm { p x }$ resolution. Black dots indicate the end of a stage. Blue plots use the BN-ReLU-Conv ordering while red plots use ReLU-BN-Conv.
We therefore propose to formalize this good practice by introducing Signal Propagation Plots (SPPs), a simple graphical method for visualizing signal propagation on the forward pass in deep ResNets. We assume identity residual blocks of the form $x _ { \ell + 1 } = f _ { \ell } ( x _ { \ell } ) _ { . } + x _ { \ell }$ , where $x _ { \ell }$ denotes the input to the $\ell ^ { t h }$ block and $f _ { \ell }$ denotes the function computed by the $\ell ^ { t h }$ residual branch. We consider 4- dimensional input and output tensors with dimensions denoted by $N H W C$ , where $N$ denotes the batch dimension, $C$ denotes the channels, and $H$ and $W$ denote the two spatial dimensions. To generate SPPs, we initialize a single set of weights according to the network initialization scheme, and then provide the network with a batch of input examples sampled from a unit Gaussian distribution. Then, we plot the following hidden activation statistics at the output of each residual block:
• Average Channel Squared Mean, computed as the square of the mean across the $N H W$ axes, and then averaged across the $C$ axis. In a network with good signal propagation, we would expect the mean activations on each channel, averaged across a batch of examples, to be close to zero. Importantly, we note that it is necessary to measure the averaged squared value of the mean, since the means of different channels may have opposite signs. • Average Channel Variance, computed by taking the channel variance across the NHW axes, and then averaging across the $C$ axis. We generally find this to be the most informative measure of the signal magnitude, and to clearly show signal explosion or attenuation. • Average Channel Variance on the end of the residual branch, before merging with the skip path. This helps assess whether the layers on the residual branch are correctly initialized.
We explore several other possible choices of statistics one could measure in Appendix G, but we have found these three to be the most informative. We also experiment with feeding the network real data samples instead of random noise, but find that this step does not meaningfully affect the key trends. We emphasize that SPPs do not capture every property of signal propagation, and they only consider the statistics of the forward pass. Despite this simplicity, SPPs are surprisingly useful for analyzing deep ResNets in practice. We speculate that this may be because in ResNets, as discussed in Section 2 (Taki, 2017; Yang & Schoenholz, 2017; Hanin & Rolnick, 2018), the backward pass will typically neither explode nor vanish so long as the signal on the forward pass is well behaved.
As an example, in Figure 1 we present the SPP for a 600-layer pre-activation ResNet (He et al., 2016a)1 with BatchNorm, ReLU activations, and He initialization (He et al., 2015). We compare the standard BN-ReLU-Conv ordering to the less common ReLU-BN-Conv ordering. Immediately, several key patterns emerge. First, we note that the Average Channel Variance grows linearly with the depth in a given stage, and resets at each transition block to a fixed value close to 1. The linear growth arises because, at initialization, the variance of the activations satisfy $\textstyle \operatorname { V a r } ( x _ { \ell + 1 } ) =$ $\mathrm { V a r } ( x _ { \ell } ) + \mathrm { V a r } ( f _ { \ell } ( x _ { \ell } ) )$ , while BatchNorm ensures that the variance of the activations at the end of each residual branch is independent of depth (De & Smith, 2020). The variance is reset at each transition block because in these blocks the skip connection is replaced by a convolution operating on a normalized input, undoing any signal growth on the skip path in the preceding blocks.
 Figure 2: SPPs for three different variants of the ResNetV2-600 network (with ReLU activations). In red, we show a batch normalized network with ReLU-BN-Conv ordering. In green we show a normalizer-free network with He-init and $\alpha = 1$ . In cyan, we show the same normalizer-free network but with Scaled Weight Standardization. We note that the SPPs for a normalizer-free network with Scaled Weight Standardization are almost identical to those for the batch normalized network.
With the BN-ReLU-Conv ordering, the Average Squared Channel Means display similar behavior, growing linearly with depth between transition blocks. This may seem surprising, since we expect BatchNorm to center the activations. However with this ordering the final convolution on a residual branch receives a rectified input with positive mean. As we show in the following section, this causes the outputs of the branch on any single channel to also have non-zero mean, and explains why $\mathrm { V a r } ( f _ { \ell } ( \bar { x _ { \ell } } ) ) \approx 0 . 6 8$ for all depths $\ell$ . Although this “mean-shift” is explicitly counteracted by the normalization layers in subsequent residual branches, it will have serious consequences when attempting to remove normalization layers, as discussed below. In contrast, the ReLU-BN-Conv ordering trains equally stably while avoiding this mean-shift issue, with $\mathrm { V a r } ( f _ { \ell } ( x _ { \ell } ) ) \approx 1$ for all $\ell$ .
# 4 NORMALIZER-FREE RESNETS (NF-RESNETS)
With SPPs in hand to aid our analysis, we now seek to develop ResNet variants without normalization layers, which have good signal propagation, are stable during training, and reach test accuracies competitive with batch-normalized ResNets. We begin with two observations from Section 3. First, for standard initializations, BatchNorm downscales the input to each residual block by a factor proportional to the standard deviation of the input signal (De & Smith, 2020). Second, each residual block increases the variance of the signal by an approximately constant factor. We propose to mimic this effect by using residual blocks of the form $x _ { \ell + 1 } = x _ { \ell } + \alpha f _ { \ell } ( x _ { \ell } / \beta _ { \ell } )$ , where $x _ { \ell }$ denotes the input to the $\ell ^ { t h }$ residual block and $f _ { \ell } ( \cdot )$ denotes the $\ell ^ { t h }$ residual branch. We design the network such that:
• $f ( \cdot )$ , the function computed by the residual branch, is parameterized to be variance preserving at initialization, i.e., $\dot { \mathrm { V a r } } ( f _ { \ell } ( z ) ) = \mathrm { V a r } ( z )$ for all $\ell$ . This constraint enables us to reason about the signal growth in the network, and estimate the variances analytically. • $\beta _ { \ell }$ is a fixed scalar, chosen as $\sqrt { \mathrm { V a r } ( x _ { \ell } ) }$ , the expected empirical standard deviation of the activations $x _ { \ell }$ at initialization. This ensures the input to $f _ { \ell } \bar { ( \cdot ) }$ has unit variance. • $\alpha$ is a scalar hyperparameter which controls the rate of variance growth between blocks.
We compute the expected empirical variance at residual block $\ell$ analytically according to $\mathrm { V a r } ( x _ { \ell } ) =$ $\mathrm { V a r } ( x _ { \ell - 1 } ) + \alpha ^ { 2 }$ , with an initial expected variance of $\mathrm { V a r } ( x _ { 0 } ) = 1$ , and we set $\beta _ { \ell } = \sqrt { \mathrm { V a r } ( x _ { \ell } ) }$ . A similar approach was proposed by Arpit et al. (2016) for non-residual networks. As noted in Section 3, the signal variance in normalized ResNets is reset at each transition layer due to the shortcut convolution receiving a normalized input. We mimic this reset by having the shortcut convolution in transition layers operate on $( x _ { \ell } / \beta _ { \ell } )$ rather than $x _ { \ell }$ , ensuring unit signal variance at the start of each stage $( \mathrm { V a r } \dot { ( } x \ell + 1 ) \dot { = } 1 + \alpha ^ { 2 }$ following each transition layer). For simplicity, we call residual networks employing this simple scaling strategy Normalizer-Free ResNets (NF-ResNets).
# 4.1 RELU ACTIVATIONS INDUCE MEAN SHIFTS
We plot the SPPs for Normalizer-Free ResNets (NF-ResNets) with $\alpha = 1$ in Figure 2. In green, we consider a NF-ResNet, which initializes the convolutions with Gaussian weights using He initialization (He et al., 2015). Although one might expect this simple recipe to be sufficient to achieve good signal propagation, we observe two unexpected features in practice. First, the average value of the squared channel mean grows rapidly with depth, achieving large values which exceed the average channel variance. This indicates a large “mean shift”, whereby the hidden activations for different training inputs (in this case different vectors sampled from the unit normal) are strongly correlated (Jacot et al., 2019; Ruff et al., 2019). Second, as observed for BN-ReLU-Conv networks in Section 3, the scale of the empirical variances on the residual branch are consistently smaller than one.
To identify the origin of these effects, in Figure 7 (in Appendix F) we provide a similar SPP for a linearized version of ResNetV2-600 without ReLU activation functions. When the ReLU activations are removed, the averaged squared channel means remain close to zero for all block depths, and the empirical variance on the residual branch fluctuates around one. This motivates the following question: why might ReLU activations cause the scale of the mean activations on a channel to grow?
To develop an intuition for this phenomenon, consider the transformation $z = W g ( x )$ , where $W$ is arbitrary and fixed, and $g ( \cdot )$ is an activation function that acts component-wise on iid inputs $x$ such that $g ( x )$ is also iid. Thus, $g ( \cdot )$ can be any popular activation function like ReLU, tanh, SiLU, etc. Let $\mathbb { E } ( g ( x _ { i } ) ) = \mu _ { g }$ and $\mathrm { V a r } ( \dot { g } ( x _ { i } ) ) = \sigma _ { g } ^ { 2 }$ for all dimensions $i$ . It is straightforward to show that the expected value and the variance of any single unit $i$ of the output $\begin{array} { r } { z _ { i } = \sum _ { j } ^ { N } W _ { i , j } g ( x _ { j } ) } \end{array}$ is given by:
$$\mathbb { E } ( z _ { i } ) = N \mu _ { g } \mu _ { W _ { i , \cdot } } , \quad \mathrm { a n d } \quad \mathrm { V a r } ( z _ { i } ) = N \sigma _ { g } ^ { 2 } ( \sigma _ { W _ { i , \cdot } } ^ { 2 } + \mu _ { W _ { i , \cdot } } ^ { 2 } ) ,$$
where $\begin{array} { r } { \mu { W _ { i , } } } \end{array}$ · and $\sigma _ { W _ { i , } }$ · are the mean and standard deviation of the $i ^ { t h }$ row of $W$ :
$$\begin{array} { r } { \mu _ { W _ { i , \cdot } } = \frac { 1 } { N } \sum _ { j } ^ { N } W _ { i , j } , \quad \mathrm { a n d } \quad \sigma _ { W _ { i , \cdot } } ^ { 2 } = \frac { 1 } { N } \sum _ { j } ^ { N } W _ { i , j } ^ { 2 } - \mu _ { W _ { i , \cdot } } ^ { 2 } . } \end{array}$$
Now consider $g ( \cdot )$ to be the ReLU activation function, i.e., $g ( x ) = \operatorname* { m a x } ( x , 0 )$ . Then $g ( x ) \geq 0$ , which implies that the input to the linear layer has positive mean (ignoring the edge case when all inputs are less than or equal to zero). In particular, notice that if $x _ { i } \sim \mathcal { N } ( 0 , 1 )$ for all $i$ , then $\mu _ { g } \ : = \ : 1 / \sqrt { 2 \pi }$ . Since we know that $\mu _ { g } ~ > ~ 0$ , if $\mu _ { W _ { i , \cdot } }$ is also non-zero, then the output of the transformation, $z _ { i }$ , will also exhibit a non-zero mean. Crucially, even if we sample $W$ from a distribution centred around zero, any specific weight matrix drawn from this distribution will almost surely have a non-zero empirical mean, and consequently the outputs of the residual branches on any specific channel will have non-zero mean values. This simple NF-ResNet model with He-initialized weights is therefore often unstable, and it is increasingly difficult to train as the depth increases.
# 4.2 SCALED WEIGHT STANDARDIZATION
To prevent the emergence of a mean shift, and to ensure that the residual branch $f _ { \ell } ( \cdot )$ is variance preserving, we propose Scaled Weight Standardization, a minor modification of the recently proposed Weight Standardization (Qiao et al., 2019) which is also closely related to Centered Weight Normalization (Huang et al., 2017b). We re-parameterize the convolutional layers, by imposing,
$$\hat { W } _ { i , j } = \gamma \cdot \frac { W _ { i , j } - \mu _ { W _ { i , \cdot } } } { \sigma _ { W _ { i , \cdot } } \sqrt { N } } ,$$
where the mean $\mu$ and variance $\sigma$ are computed across the fan-in extent of the convolutional filters. We initialize the underlying parameters $W$ from Gaussian weights, while $\gamma$ is a fixed constant. As in Qiao et al. (2019), we impose this constraint throughout training as a differentiable operation in the forward pass of the network. Recalling equation 1, we can immediately see that the output of the transformthus eliminating on using Scaled WS, e mean shift. Further $z \ = \ \hat { W } g ( x )$ , a se $\mathbb { E } ( z _ { i } ) ~ = ~ 0$ for all that for $i$ , $\mathrm { V a r } ( z _ { i } ) = \gamma ^ { 2 } \sigma _ { g } ^ { 2 }$ $\gamma .$ , which depends on the non-linearity $g$ , the layer will be variance preserving. Scaled Weight Standardization is cheap during training and free at inference, scales well (with the number of parameters rather than activations), introduces no dependence between batch elements and no discrepancy in training and test behavior, and its implementation does not differ in distributed training. These desirable properties make it a compelling alternative for replacing BatchNorm.
The SPP of a normalizer-free ResNet-600 employing Scaled WS is shown in Figure 2 in cyan. As we can see, Scaled Weight Standardization eliminates the growth of the average channel squared mean at initialization. Indeed, the SPPs are almost identical to the SPPs for a batch-normalized network employing the ReLU-BN-Conv ordering, shown in red. Note that we select the constant $\gamma$ to ensure that the channel variance on the residual branch is close to one (discussed further below). The variance on the residual branch decays slightly near the end of the network due to zero padding.
# 4.3 DETERMINING NONLINEARITY-SPECIFIC CONSTANTS $\gamma$
The final ingredient we need is to determine the value of the gain $\gamma$ , in order to ensure that the variances of the hidden activations on the residual branch are close to 1 at initialization. Note that the value of $\gamma$ will depend on the specific nonlinearity used in the network. We derive the value of $\gamma$ by assuming that the input $x$ to the nonlinearity is sampled iid from $\mathcal { N } ( 0 , 1 )$ . For ReLU networks, this implies that the outputs $g ( x ) = \operatorname* { m a x } ( x , 0 )$ will be sampled from the rectified Gaussian distribution with variance $\sigma _ { g } ^ { 2 } = ( 1 / 2 ) ( 1 - ( 1 / \pi ) )$ (Arpit et al., 2016). Since $\mathrm { V a r } ( \hat { W } g ( x ) ) = \gamma ^ { 2 } \sigma _ { g } ^ { 2 }$ , we set $\begin{array} { r } { \gamma = 1 / \sigma _ { g } = \frac { \sqrt { 2 } } { \sqrt { 1 - \frac { 1 } { \pi } } } } \end{array}$ to ensure that $\mathrm { V a r } ( \hat { W } g ( x ) ) = 1$ . While the assumption $x \sim \mathcal { N } ( 0 , 1 )$ is not typically true unless the network width is large, we find this approximation to work well in practice.
For simple nonlinearities like ReLU or tanh, the analytical variance of the non-linearity $g ( x )$ when $x$ is drawn from the unit normal may be known or easy to derive. For other nonlinearities, such as SiLU ((Elfwing et al., 2018; Hendrycks & Gimpel, 2016), recently popularized as Swish (Ramachandran et al., 2018)), analytically determining the variance can involve solving difficult integrals, or may even not have an analytical form. In practice, we find that it is sufficient to numerically approximate this value by the simple procedure of drawing many $N$ dimensional vectors $x$ from the Gaussian distribution, computing the empirical variance $\mathrm { V a r } ( g ( x ) )$ for each vector, and taking the square root of the average of this empirical variance. We provide an example in Appendix D showing how this can be accomplished for any nonlinearity with just a few lines of code and provide reference values.
# 4.4 OTHER BUILDING BLOCKS AND RELAXED CONSTRAINTS
Our method generally requires that any additional operations used in a network maintain good signal propagation, which means many common building blocks must be modified. As with selecting $\gamma$ values, the necessary modification can be determined analytically or empirically. For example, the popular Squeeze-and-Excitation operation $\mathrm { _ { } } S { + } \mathrm { E }$ , Hu et al. (2018)), $y = s \bar { i } g m o i \bar { d } ( M L P ( p o o \bar { l } ( h ) ) ) *$ $h$ , involves multiplication by an activation in $[ 0 , 1 ]$ , and will tend to attenuate the signal and make the model unstable. This attenuation can clearly be seen in the SPP of a normalizer-free ResNet using these blocks (see Figure 9 in Appendix F). If we examine this operation in isolation using our simple numerical procedure explained above, we find that the expected variance is 0.5 (for unit normal inputs), indicating that we simply need to multiply the output by 2 to recover good signal propagation. We empirically verified that this simple change is sufficient to restore training stability.
In practice, we find that either a similarly simple modification to any given operation is sufficient to maintain good signal propagation, or that the network is sufficiently robust to the degradation induced by the operation to train well without modification. We also explore the degree to which we can relax our constraints and still maintain stable training. As an example of this, to recover some of the expressivity of a normal convolution, we introduce learnable affine gains and biases to the Scaled WS layer (the gain is applied to the weight, while the bias is added to the activation, as is typical). While we could constrain these values to enforce good signal propagation by, for example, downscaling the output by a scalar proportional to the values of the gains, we find that this is not necessary for stable training, and that stability is not impacted when these parameters vary freely. Relatedly, we find that using a learnable scalar multiplier at the end of the residual branch initialized to 0 (Goyal et al., 2017; De & Smith, 2020) helps when training networks over 150 layers, even if we ignore this modification when computing $\beta _ { \ell }$ . In our final models, we employ several such relaxations without loss of training stability. We provide detailed explanations for each operation and any modifications we make in Appendix C (also detailed in our model code in Appendix D).
# 4.5 SUMMARY
In summary, the core recipe for a Normalizer-Free ResNet (NF-ResNet) is:
1. Compute and forward propagate the expected signal variance $\beta _ { \ell } ^ { 2 }$ , which grows by $\alpha ^ { 2 }$ after each residual block ( $\left. \beta _ { 0 } = 1 \right.$ ). Downscale the input to each residual branch by $\beta _ { \ell }$ . 2. Additionally, downscale the input to the convolution on the skip path in transition blocks by $\beta _ { \ell }$ , and reset $\beta _ { \ell + 1 } = 1 + \alpha ^ { \bar { 2 } }$ following a transition block. 3. Employ Scaled Weight Standardization in all convolutional layers, computing $\gamma$ , the gain specific to the activation function $g ( x )$ , as the reciprocal of the expected standard deviation, $\scriptstyle { \frac { 1 } { \sqrt { \operatorname { V a r } ( g ( x ) ) } } }$ , assuming $\boldsymbol { x } \sim \mathcal { N } ( \boldsymbol { 0 } , \boldsymbol { 1 } )$ .
Code is provided in Appendix $\mathrm { D }$ for a reference Normalizer-Free Network.
# 5 EXPERIMENTS
5.1 AN EMPIRICAL EVALUATION ON RESNETS
<table><tr><td rowspan=2 colspan=2>FixUpUnreg.</td><td rowspan=1 colspan=2>FixUp</td><td rowspan=1 colspan=2>SkipInit</td><td rowspan=1 colspan=2>NF-ResNets (ours)</td><td rowspan=1 colspan=1>BN-ResNets</td></tr><tr><td rowspan=1 colspan=1>Reg.</td><td rowspan=1 colspan=1>Unreg.</td><td rowspan=1 colspan=1>Reg.</td><td rowspan=1 colspan=1>Unreg.</td><td rowspan=1 colspan=1>Reg.</td><td rowspan=1 colspan=1>Unreg.</td><td rowspan=1 colspan=1>Reg.</td></tr><tr><td rowspan=1 colspan=1>RN50</td><td rowspan=1 colspan=1>74.0 ± .5</td><td rowspan=1 colspan=1>75.9 ± .3</td><td rowspan=1 colspan=1>73.7 ± .2</td><td rowspan=1 colspan=1>75.8 ± .2</td><td rowspan=1 colspan=1>75.8 ± .1</td><td rowspan=1 colspan=1>76.8±.1</td><td rowspan=1 colspan=1>76.8± .1</td><td rowspan=1 colspan=1>76.4 ±.1</td></tr><tr><td rowspan=1 colspan=1>RN101</td><td rowspan=1 colspan=1>75.4± .6</td><td rowspan=1 colspan=1>77.6 ± .3</td><td rowspan=1 colspan=1>75.1± .1</td><td rowspan=1 colspan=1>77.3 ± .2</td><td rowspan=1 colspan=1>77.1 ± .1</td><td rowspan=1 colspan=1>78.4± .1</td><td rowspan=1 colspan=1>78.0 ± .1</td><td rowspan=1 colspan=1>78.1 ± .1</td></tr><tr><td rowspan=1 colspan=1>RN152</td><td rowspan=1 colspan=1>75.8±.4</td><td rowspan=1 colspan=1>78.4 ± .3</td><td rowspan=1 colspan=1>75.7 ± .2</td><td rowspan=1 colspan=1>78.0±.1</td><td rowspan=1 colspan=1>77.6± .1</td><td rowspan=1 colspan=1>79.1 ± .1</td><td rowspan=1 colspan=1>78.6± .2</td><td rowspan=1 colspan=1>78.8±.1</td></tr><tr><td rowspan=1 colspan=1>RN200</td><td rowspan=1 colspan=1>76.2 ± .5</td><td rowspan=1 colspan=1>78.7± .3</td><td rowspan=1 colspan=1>75.9± .2</td><td rowspan=1 colspan=1>78.2 ± .1</td><td rowspan=1 colspan=1>77.9 ± .2</td><td rowspan=1 colspan=1>79.6 ± .1</td><td rowspan=1 colspan=1>79.0 ± .2</td><td rowspan=1 colspan=1>79.2 ± .1</td></tr><tr><td rowspan=1 colspan=1>RN288</td><td rowspan=1 colspan=1>76.2±.4</td><td rowspan=1 colspan=1>78.4±.4</td><td rowspan=1 colspan=1>76.3 ± .2</td><td rowspan=1 colspan=1>78.7± .2</td><td rowspan=1 colspan=1>78.1±.1*</td><td rowspan=1 colspan=1>79.5 ± .1</td><td rowspan=1 colspan=1>78.8±.1</td><td rowspan=1 colspan=1>79.5 ± .1</td></tr></table>
Table 1: ImageNet Top-1 Accuracy $( \% )$ for ResNets with FixUp (Zhang et al., 2019) or SkipInit (De & Smith, 2020), Normalizer-Free ResNets (ours), and Batch-Normalized ResNets. We train all variants both with and without additional regularization (stochastic depth and dropout). Results are given as the median accuracy $\pm$ the standard deviation across 5 random seeds. ∗ indicates a setting where two runs collapsed and results are reported only using the 3 seeds which train successfully.
We begin by investigating the performance of Normalizer-Free pre-activation ResNets on the ILSVRC dataset (Russakovsky et al., 2015), for which we compare our networks to FixUp initialization (Zhang et al., 2019), SkipInit (De & Smith, 2020), and batch-normalized ResNets. We use a training setup based on Goyal et al. (2017), and train our models using SGD (Robbins & Monro, 1951) with Nesterov’s Momentum (Nesterov, 1983; Sutskever et al., 2013) for 90 epochs with a batch size of 1024 and a learning rate which warms up from zero to 0.4 over the first 5 epochs, then decays to zero using cosine annealing (Loshchilov & Hutter, 2017). We employ standard baseline preprocessing (sampling and resizing distorted bounding boxes, along with random flips), weight decay of 5e-5, and label smoothing of 0.1 (Szegedy et al., 2016). For Normalizer-Free ResNets (NF-ResNets), we chose $\alpha = 0 . 2$ based on a small sweep, and employ SkipInit as discussed above. For both FixUp and SkipInit we had to reduce the learning rate to 0.2 to enable stable training.
We find that without additional regularization, our NF-ResNets achieve higher training accuracies but lower test accuracies than their batch-normalized counterparts. This is likely caused by the known regularization effect of BatchNorm (Hoffer et al., 2017; Luo et al., 2019; De & Smith, 2020). We therefore introduce stochastic depth (Huang et al., 2016) with a rate of 0.1, and Dropout (Srivastava et al., 2014) before the final linear layer with a drop probability of 0.25. We note that adding this same regularization does not substantially improve the performance of the normalized ResNets in our setup, suggesting that BatchNorm is indeed already providing some regularization benefit.
In Table 1 we compare performance of our networks (NF-ResNets) against the baseline (BNResNets), across a wide range of network depths. After introducing additional regularization, NFResNets achieve performance better than FixUp/SkipInit and competitive with BN across all network depths, with our regularized NF-ResNet-288 achieving top-1 accuracy of $7 9 . 5 \%$ . However, some of the 288 layer normalizer-free models undergo training collapse at the chosen learning rate, but only when unregularized. While we can remove this instability by reducing the learning rate to 0.2, this comes at the cost of test accuracy. We investigate this failure mode in Appendix A.
Table 2: ImageNet Top-1 Accuracy $( \% )$ for Normalizer-Free ResNets and Batch-Normalized ResNet-50s on ImageNet, using very small batch sizes trained for 15 epochs. Results are given as the median accuracy $\pm$ the standard deviation across 5 random seeds. Performance degrades severely for Batch-Normalized networks, while Normalizer-Free ResNets retain good performance.
<table><tr><td rowspan=2 colspan=4>NF-ResNets (ours)BS=1024 BS=8 BS=4</td><td rowspan=1 colspan=3>BN-ResNets</td></tr><tr><td rowspan=1 colspan=1>BS=8</td><td rowspan=1 colspan=1>BS=4</td><td rowspan=1 colspan=1>BS=1024</td><td rowspan=1 colspan=1>BS=8</td><td rowspan=1 colspan=1>BS=4</td></tr><tr><td rowspan=1 colspan=1>ResNet-50</td><td rowspan=1 colspan=1>69.9 ±0.1</td><td rowspan=1 colspan=1>69.6 ± 0.1</td><td rowspan=1 colspan=1>69.9 ± 0.1</td><td rowspan=1 colspan=1>70.9 ± 0.1</td><td rowspan=1 colspan=1>65.7 ± 0.2</td><td rowspan=1 colspan=1>55.7 ± 0.3</td></tr></table>
One important limitation of BatchNorm is that its performance degrades when the per-device batch size is small (Hoffer et al., 2017; Wu & He, 2018). To demonstrate that our normalizer-free models overcome this limitation, we train ResNet-50s on ImageNet using very small batch sizes of 8 and 4, and report the results in Table 2. These models are trained for 15 epochs (4.8M and 2.4M training steps, respectively) with a learning rate of 0.025 for batch size 8 and 0.01 for batch size 4. For comparison, we also include the accuracy obtained when training for 15 epochs at batch size 1024 and learning rate 0.4. The NF-ResNet achieves significantly better performance when the batch size is small, and is not affected by the shift from batch size 8 to 4, demonstrating the usefulness of our approach in the microbatch setting. Note that we do not apply stochastic depth or dropout in these experiments, which may explain superior performance of the BN-ResNet at batch size 1024. We also study the transferability of our learned representations to the downstream tasks of semantic segmentation and depth estimation, and present the results of these experiments in Appendix H.
# 5.2 DESIGNING PERFORMANT NORMALIZER-FREE NETWORKS
We now turn our attention to developing unnormalized networks which are competitive with the state-of-the-art EfficientNet model family across a range of FLOP budgets (Tan & Le, 2019), We focus primarily on the small budget regime (EfficientNets B0-B4), but also report results for B5 and hope to extend our investigation to larger variants in future work.
First, we apply Scaled WS and our Normalizer-Free structure directly to the EfficientNet backbone.2 While we succeed in training these networks stably without normalization, we find that even after extensive tuning our NormalizerFree EfficientNets still substantially underperform their batch-normalized baselines. For example, our normalization free B0 variant achieves $7 3 . 5 \%$ top-1, a $3 . 2 \%$ absolute degradation relative to the baseline. We hypothesize that this degradation arises because Weight Standardization imposes a very strong constraint on depth-wise convolutions (which have an input channel count of 1), and this constraint may remove a substantial fraction of the model expressivity. To support this claim, we note that removing Scaled WS from the depth-wise convolutions improves the test accuracy of Normalizer-Free EfficientNets, although this also reduces the training stability.
 Figure 3: ImageNet Top-1 test accuracy versus FLOPs.
Therefore, to overcome the potentially poor interactions between Weight Standardization and depth-wise convolutions,
we decided to instead study Normalizer-Free variants of the RegNet model family (Radosavovic et al., 2020). RegNets are slightly modified variants of ResNeXts (Xie et al., 2017), developed via manual architecture search. Crucially, RegNets employ grouped convolutions, which we anticipate are more compatible with Scaled WS than depth-wise convolutions, since the fraction of the degrees of freedom in the model weights remaining after the weight standardization operation is higher.
We develop a new base model by taking the 0.4B FLOP RegNet variant, and making several minor architectural changes which cumulatively substantially improve the model performance. We describe our final model in full in Appendix C, however we emphasize that most of the architecture changes we introduce simply reflect well-known best practices from the literature (Tan & Le, 2019; He et al., 2019). To assess the performance of our Normalizer-Free RegNets across a range of FLOPS budgets, we apply the EfficientNet compound scaling approach (which increases the width, depth and input resolution in tandem according to a set of three power laws learned using architecture search) to obtain model variants at a range of approximate FLOPS targets. Denoting these models NF-RegNets, we train variants B0-B5 (analogous to EfficientNet variants) using both baseline preprocessing and combined CutMix (Yun et al., 2019) and MixUp (Zhang et al., 2018) augmentation. Note that we follow the same compound scaling hyper-parameters used by EfficientNets, and do not retune these hyper-parameters on our own architecture. We compare the test accuracies of EfficientNets and NF-RegNets on ImageNet in Figure 3, and we provide the corresponding numerical values in Table 3 of Appendix A. We present a comparison of training speeds in Table 5 of Appendix A.
For each FLOPS and augmentation setting, NF-RegNets attain comparable but slightly lower test accuracies than EfficientNets, while being substantially faster to train. In the augmented setting, we report EfficientNet results with AutoAugment (AA) or RandAugment (RA), (Cubuk et al., 2019; 2020), which we find performs better than training EfficientNets with CutMix $^ +$ MixUp. However, both AA and RA degrade the performance and stability of NF-RegNets, and hence we report results of NF-RegNets with CutMix $+$ Mixup instead. We hypothesize that this occurs because AA and RA were developed by applying architecture search on batch-normalized models, and that they may therefore change the statistics of the dataset in a way that negatively impacts signal propagation when normalization layers are removed. To support this claim, we note that inserting a single BatchNorm layer after the first convolution in an NF-RegNet removes these instabilities and enables us to train stably with either AA or RA, although this approach does not achieve higher test set accuracies.
These observations highlight that, although our models do benefit from most of the architectural improvements and best practices which researchers have developed from the hundreds of thousands of device hours used while tuning batch-normalized models, there are certain aspects of existing state-of-the-art models, like AA and RA, which may implicitly rely on the presence of activation normalization layers in the network. Furthermore there may be other components, like depth-wise convolutions, which are incompatible with promising new primitives like Weight Standardization. It is therefore inevitable that some fine-tuning and model development is necessary to achieve competitive accuracies when removing a component like batch normalization which is crucial to the performance of existing state-of-the-art networks. Our experiments confirm for the first time that it is possible to develop deep ResNets which do not require batch normalization or other activation normalization layers, and which not only train stably and achieve low training losses, but also attain test accuracy competitive with the current state of the art on a challenging benchmark like ImageNet.
# 6 CONCLUSION
We introduce Normalizer-Free Networks, a simple approach for designing residual networks which do not require activation normalization layers. Across a range of FLOP budgets, our models achieve performance competitive with the state-of-the-art EfficientNets on ImageNet. Meanwhile, our empirical analysis of signal propagation suggests that batch normalization resolves two key failure modes at initialization in deep ResNets. First, it suppresses the scale of the hidden activations on the residual branch, preventing signal explosion. Second, it prevents the mean squared scale of the activations on each channel from exceeding the variance of the activations between examples. Our Normalizer-Free Networks were carefully designed to resolve both of these failure modes.
# ACKNOWLEDGMENTS
We would like to thank Karen Simonyan for helpful discussions and guidance, as well as Guillaume Desjardins, Michael Figurnov, Nikolay Savinov, Omar Rivasplata, Relja Arandjelovic, and Rishub ´ Jain.
# REFERENCES
Devansh Arpit, Yingbo Zhou, Bhargava Kota, and Venu Govindaraju. Normalization propagation: A parametric technique for removing internal covariate shift in deep networks. In International Conference on Machine Learning, pp. 1168–1176, 2016.
Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016.
Thomas Bachlechner, Bodhisattwa Prasad Majumder, Huanru Henry Mao, Garrison W Cottrell, and Julian McAuley. Rezero is all you need: Fast convergence at large depth. arXiv preprint arXiv:2003.04887, 2020.
David Balduzzi, Marcus Frean, Lennox Leary, JP Lewis, Kurt Wan-Duo Ma, and Brian McWilliams. The shattered gradients problem: If resnets are the answer, then what is the question? In International Conference on Machine Learning, pp. 342–350, 2017.
Nils Bjorck, Carla P Gomes, Bart Selman, and Kilian Q Weinberger. Understanding batch normalization. In Advances in Neural Information Processing Systems, pp. 7694–7705, 2018.
James Bradbury, Roy Frostig, Peter Hawkins, Matthew James Johnson, Chris Leary, Dougal Maclaurin, and Skye Wanderman-Milne. JAX: composable transformations of Python+NumPy programs, 2018. URL http://github.com/google/jax.
Ekin D Cubuk, Barret Zoph, Dandelion Mane, Vijay Vasudevan, and Quoc V Le. Autoaugment: Learning augmentation strategies from data. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 113–123, 2019.
Ekin D Cubuk, Barret Zoph, Jonathon Shlens, and Quoc V Le. Randaugment: Practical automated data augmentation with a reduced search space. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops, pp. 702–703, 2020.
Soham De and Sam Smith. Batch normalization biases residual blocks towards the identity function in deep networks. Advances in Neural Information Processing Systems, 33, 2020.
Stefan Elfwing, Eiji Uchibe, and Kenji Doya. Sigmoid-weighted linear units for neural network function approximation in reinforcement learning. Neural Networks, 107:3–11, 2018.
Priya Goyal, Piotr Dollar, Ross Girshick, Pieter Noordhuis, Lukasz Wesolowski, Aapo Kyrola, An-´ drew Tulloch, Yangqing Jia, and Kaiming He. Accurate, large minibatch sgd: Training imagenet in 1 hour. arXiv preprint arXiv:1706.02677, 2017.
Jean-Bastien Grill, Florian Strub, Florent Altche, 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, 2020.
Ishaan Gulrajani, Faruk Ahmed, Mart´ın Arjovsky, Vincent Dumoulin, and Aaron C. Courville. Improved training of Wasserstein GANs. In Advances in neural information processing systems, 2017.
Boris Hanin and David Rolnick. How to start training: The effect of initialization and architecture. In Advances in Neural Information Processing Systems, pp. 571–581, 2018.
Charles R. Harris, K. Jarrod Millman, Stefan J. van der Walt, Ralf Gommers, Pauli Virtanen, David ´ Cournapeau, Eric Wieser, Julian Taylor, Sebastian Berg, Nathaniel J. Smith, Robert Kern, Matti Picus, Stephan Hoyer, Marten H. van Kerkwijk, Matthew Brett, Allan Haldane, Jaime Fernandez ´ del R´ıo, Mark Wiebe, Pearu Peterson, Pierre Gerard-Marchant, Kevin Sheppard, Tyler Reddy, ´ Warren Weckesser, Hameer Abbasi, Christoph Gohlke, and Travis E. Oliphant. Array programming with numpy. Nature, 585(7825):357–362, Sep 2020. ISSN 1476-4687.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Delving deep into rectifiers: Surpassing human-level performance on imagenet classification. In Proceedings of the 2015 IEEE International Conference on Computer Vision (ICCV), pp. 1026–1034, 2015.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Identity mappings in deep residual networks. In European conference on computer vision, pp. 630–645. Springer, 2016a.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, 2016b.
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.
Tong He, Zhi Zhang, Hang Zhang, Zhongyue Zhang, Junyuan Xie, and Mu Li. Bag of tricks for image classification with convolutional neural networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 558–567, 2019.
Dan Hendrycks and Kevin Gimpel. Gaussian error linear units (gelus). arXiv preprint arXiv:1606.08415, 2016.
Elad Hoffer, Itay Hubara, and Daniel Soudry. Train longer, generalize better: closing the generalization gap in large batch training of neural networks. In Advances in Neural Information Processing Systems, pp. 1731–1741, 2017.
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.
Jie Hu, Li Shen, and Gang Sun. Squeeze-and-excitation networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 7132–7141, 2018.
Gao Huang, Yu Sun, Zhuang Liu, Daniel Sedra, and Kilian Q Weinberger. Deep networks with stochastic depth. In European conference on computer vision, pp. 646–661. Springer, 2016.
Gao Huang, Zhuang Liu, Laurens Van Der Maaten, and Kilian Q Weinberger. Densely connected convolutional networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 4700–4708, 2017a.
Lei Huang, Xianglong Liu, Yang Liu, Bo Lang, and Dacheng Tao. Centered weight normalization in accelerating training of deep neural networks. In Proceedings of the IEEE International Conference on Computer Vision, pp. 2803–2811, 2017b.
Lei Huang, Jie Qin, Yi Zhou, Fan Zhu, Li Liu, and Ling Shao. Normalization techniques in training DNNs: Methodology, analysis and application. arXiv preprint arXiv:2009.12836, 2020.
Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In ICML, 2015.
Arthur Jacot, Franck Gabriel, and Clement Hongler. Freeze and chaos for dnns: an ntk view of batch ´ normalization, checkerboard and boundary effects. arXiv preprint arXiv:1907.05715, 2019.
Durk P Kingma and Prafulla Dhariwal. Glow: Generative flow with invertible 1x1 convolutions. In Advances in Neural Information Processing Systems, pp. 10215–10224, 2018.
Gunter Klambauer, Thomas Unterthiner, Andreas Mayr, and Sepp Hochreiter. Self-normalizing ¨ neural networks. In Advances in neural information processing systems, pp. 971–980, 2017.
Alexander Kolesnikov, Lucas Beyer, Xiaohua Zhai, Joan Puigcerver, Jessica Yung, Sylvain Gelly, and Neil Houlsby. Large scale learning of general visual representations for transfer. arXiv preprint arXiv:1912.11370, 2019.
Iro Laina, Christian Rupprecht, Vasileios Belagiannis, Federico Tombari, and Nassir Navab. Deeper depth prediction with fully convolutional residual networks. In 2016 Fourth international conference on 3D vision (3DV), pp. 239–248. IEEE, 2016.
Jonathan Long, Evan Shelhamer, and Trevor Darrell. Fully convolutional networks for semantic segmentation. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 3431–3440, 2015.
Ilya Loshchilov and Frank Hutter. SGDR: stochastic gradient descent with warm restarts. In 5th International Conference on Learning Representations, ICLR, 2017.
Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In 7th International Conference on Learning Representations, ICLR, 2019.
Ping Luo, Xinjiang Wang, Wenqi Shao, and Zhanglin Peng. Towards understanding regularization in batch normalization. In 7th International Conference on Learning Representations, ICLR, 2019.
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), pp. 116–131, 2018.
Dmytro Mishkin and Jiri Matas. All you need is a good init. In 4th International Conference on Learning Representations, ICLR, 2016.
Takeru Miyato, Toshiki Kataoka, Masanori Koyama, and Yuichi Yoshida. Spectral normalization for generative adversarial networks. In ICLR, 2018.
Y. Nesterov. A method for unconstrained convex minimization problem with the rate of convergence $O ( 1 / k ^ { 2 } )$ . Doklady AN USSR, pp. (269), 543–547, 1983.
Art B Owen. A robust hybrid of lasso and ridge regression. 2007.
Hung Viet Pham, Thibaud Lutellier, Weizhen Qi, and Lin Tan. Cradle: cross-backend validation to detect and localize bugs in deep learning libraries. In 2019 IEEE/ACM 41st International Conference on Software Engineering (ICSE), pp. 1027–1038. IEEE, 2019.
Boris Polyak. Some methods of speeding up the convergence of iteration methods. USSR Computational Mathematics and Mathematical Physics, pp. 4(5):1–17, 1964.
Haozhi Qi, Chong You, Xiaolong Wang, Yi Ma, and Jitendra Malik. Deep isometric learning for visual recognition. In International Conference on Machine Learning, pp. 7824–7835. PMLR, 2020.
Siyuan Qiao, Huiyu Wang, Chenxi Liu, Wei Shen, and Alan Yuille. Weight standardization. arXiv preprint arXiv:1903.10520, 2019.
Ilija Radosavovic, Raj Prateek Kosaraju, Ross Girshick, Kaiming He, and Piotr Dollar. Designing ´ network design spaces. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 10428–10436, 2020.
Prajit Ramachandran, Barret Zoph, and Quoc V. Le. Searching for activation functions. In 6th International Conference on Learning Representations, ICLR, Workshop Track Proceedings, 2018.
Herbert Robbins and Sutton Monro. A stochastic approximation method. The Annals of Mathematical Statistics, pp. 22(3):400–407, 1951.
Samuel Rota Bulo, Lorenzo Porzi, and Peter Kontschieder. In-place activated batchnorm for \` memory-optimized training of dnns. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 5639–5647, 2018.
Brendan Ruff, Taylor Beck, and Joscha Bach. Mean shift rejection: Training deep neural networks without minibatch statistics or normalization. arXiv preprint arXiv:1911.13173, 2019.
Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, and Michael Bernstein. ImageNet large scale visual recognition challenge. IJCV, 115:211–252, 2015.
Tim Salimans and Durk P Kingma. Weight normalization: A simple reparameterization to accelerate training of deep neural networks. In Advances in neural information processing systems, pp. 901– 909, 2016.
Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, and Liang-Chieh Chen. Mobilenetv2: Inverted residuals and linear bottlenecks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 4510–4520, 2018.
Shibani Santurkar, Dimitris Tsipras, Andrew Ilyas, and Aleksander Madry. How does batch normalization help optimization? In Advances in Neural Information Processing Systems, pp. 2483– 2493, 2018.
Nathan Silberman, Derek Hoiem, Pushmeet Kohli, and Rob Fergus. Indoor segmentation and support inference from rgbd images. In European conference on computer vision, pp. 746–760. Springer, 2012.
Samuel Smith, Erich Elsen, and Soham De. On the generalization benefit of noise in stochastic gradient descent. In International Conference on Machine Learning, pp. 9058–9067. PMLR, 2020.
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.
Rupesh Kumar Srivastava, Klaus Greff, and Jurgen Schmidhuber. Highway networks. ¨ arXiv preprint arXiv:1505.00387, 2015.
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, pp. 1139–1147, 2013.
C Szegedy, V Vanhoucke, S Ioffe, J Shlens, and Z Wojna. Rethinking the inception architecture for computer vision. In 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 2818–2826, 2016.
Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, and Alexander A. Alemi. Inception-v4, inception-resnet and the impact of residual connections on learning. In Proceedings of the ThirtyFirst AAAI Conference on Artificial Intelligence, pp. 4278–4284, 2017.
Masato Taki. Deep residual networks and weight initialization. arXiv preprint arXiv:1709.02956, 2017.
Mingxing Tan and Quoc Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In International Conference on Machine Learning, pp. 6105–6114, 2019.
Hugo Touvron, Andrea Vedaldi, Matthijs Douze, and Herve J ´ egou. Fixing the train-test resolution ´ discrepancy. In Advances in Neural Information Processing Systems, pp. 8252–8262, 2019.
Dmitry Ulyanov, Andrea Vedaldi, and Victor Lempitsky. Instance normalization: The missing ingredient for fast stylization. arXiv preprint arXiv:1607.08022, 2016.
Longhui Wei, An Xiao, Lingxi Xie, Xiaopeng Zhang, Xin Chen, and Qi Tian. Circumventing outliers of autoaugment with knowledge distillation. In ECCV, pp. 608–625, 2020.
Yuxin Wu and Kaiming He. Group normalization. In Proceedings of the European Conference on Computer Vision (ECCV), pp. 3–19, 2018.
Saining Xie, Ross Girshick, Piotr Dollar, Zhuowen Tu, and Kaiming He. Aggregated residual trans- ´ formations for deep neural networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 1492–1500, 2017.
Yunyang Xiong, Hanxiao Liu, Suyog Gupta, Berkin Akin, Gabriel Bender, Pieter-Jan Kindermans, Mingxing Tan, Vikas Singh, and Bo Chen. Mobiledets: Searching for object detection architectures for mobile accelerators. arXiv preprint arXiv:2004.14525, 2020.
Ge Yang and Samuel Schoenholz. Mean field residual networks: On the edge of chaos. In Advances in neural information processing systems, pp. 7103–7114, 2017.
Greg Yang, Jeffrey Pennington, Vinay Rao, Jascha Sohl-Dickstein, and Samuel S. Schoenholz. A mean field theory of batch normalization. In 7th International Conference on Learning Representations, ICLR, 2019.
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 Proceedings of the IEEE International Conference on Computer Vision, pp. 6023–6032, 2019.
Sergey Zagoruyko and Nikos Komodakis. Wide residual networks. In Proceedings of the British Machine Vision Conference 2016, BMVC, 2016.
Hongyi Zhang, Moustapha Cisse, Yann N. Dauphin, and David Lopez-Paz. mixup: Beyond em- ´ pirical risk minimization. In 6th International Conference on Learning Representations, ICLR, 2018.
Hongyi Zhang, Yann N. Dauphin, and Tengyu Ma. Fixup initialization: Residual learning without normalization. In 7th International Conference on Learning Representations, ICLR, 2019.
APPENDIX A EXPERIMENT DETAILS Table 3: ImageNet Top-1 Accuracy $( \% )$ comparison for NF-RegNets and recent state-of-the-art models. “w/ Augs” refers to accuracy with advanced augmentations: for EfficientNets, this is with AutoAugment or RandAugment. For NF-RegNets, this is with CutMix $^ +$ MixUp. NF-RegNet results are reported as the median and standard deviation across 5 random seeds.
<table><tr><td>Model</td><td>#FLOPs #Params</td><td> Top-1 w/o Augs</td><td>Top-1 w/ Augs</td></tr><tr><td>NF-RegNet-B0</td><td>0.44B 8.3M</td><td>76.8 ± 0.2</td><td>77.0± 0.1</td></tr><tr><td>EfficientNet-B0</td><td>0.39B 5.3M</td><td>76.7</td><td>77.1</td></tr><tr><td>RegNetY-400MF</td><td>0.40B 4.3M</td><td>74.1</td><td></td></tr><tr><td>NF-RegNet-B1</td><td>0.73B 9.8M</td><td>78.6 ± 0.1</td><td>78.7± 0.1</td></tr><tr><td>EfficientNet-B1</td><td>0.70B 7.8M</td><td>78.7</td><td>79.1</td></tr><tr><td>RegNetY-600MF</td><td>0.60B 6.1M</td><td>75.5</td><td>1</td></tr><tr><td>RegNetY-800MF</td><td>0.80B 6.3M</td><td>76.3</td><td></td></tr><tr><td>MobileNet (Howard et al., 2017)</td><td>0.60B 4.2M</td><td>70.6</td><td></td></tr><tr><td>MobileNet v2 (Sandler et al.,2018)</td><td>0.59B 6.9M</td><td>74.7</td><td></td></tr><tr><td>ShuffleNet v2 (Ma et al., 2018)</td><td>0.59B 1</td><td>74.9</td><td></td></tr><tr><td>NF-RegNet-B2</td><td>1.09B 13.4M</td><td>79.6 ± 0.1</td><td>80.0± 0.1</td></tr><tr><td>EfficientNet-B2</td><td>1.00B 9.2M</td><td>79.8</td><td>80.1</td></tr><tr><td>NF-RegNet-B3</td><td>1.98B 17.6M</td><td>80.6 ± 0.1</td><td>81.2 ± 0.1</td></tr><tr><td>EfficientNet-B3</td><td>1.80B 12.0M</td><td>81.1</td><td>81.6</td></tr><tr><td>NF-RegNet-B4</td><td>4.43B 28.5M</td><td>81.7 ± 0.1</td><td>82.5 ± 0.1</td></tr><tr><td>EfficientNet-B4</td><td>4.20B 19.0M</td><td>82.5</td><td>82.9</td></tr><tr><td>RegNetY-4.0GF</td><td>4.00B 20.6M</td><td>79.4</td><td>1</td></tr><tr><td>ResNet50</td><td>4.10B 26.0M</td><td>76.8</td><td>78.6</td></tr><tr><td>DenseNet-169 (Huang et al., 2017a)</td><td>3.50B 14.0M</td><td>76.2</td><td></td></tr><tr><td>NF-RegNet-B5</td><td>47.5M</td><td></td><td></td></tr><tr><td>EfficientNet-B5</td><td>10.48B 9.90B</td><td>82.0 ±0.2</td><td>83.0± 0.2</td></tr><tr><td></td><td>30.0M</td><td>83.1</td><td>83.7</td></tr><tr><td>RegNetY-12GF</td><td>12.10B 51.8M</td><td>80.3</td><td>1</td></tr><tr><td>ResNet152</td><td>11.00B 60.0M</td><td>78.6</td><td></td></tr><tr><td>Inception-v4 (Szegedy et al., 2017)</td><td>13.00B 48.0M</td><td>80.0</td><td></td></tr></table>
# A.1 STABILITY, LEARNING RATES, AND BATCH SIZES
Previous work (Goyal et al., 2017) has established a fairly robust linear relationship between the optimal learning rate (or highest stable learning rate) and batch size for Batch-Normalized ResNets. As noted in Smith et al. (2020), we also find that this relationship breaks down past batch size 1024 for our unnormalized ResNets, as opposed to 2048 or 4096 for normalized ResNets. Both the optimal learning rate and the highest stable learning rate decrease for higher batch sizes. This also appears to correlate with depth: when not regularized, our deepest models are not always stable with a learning rate of 0.4. While we can mitigate this collapse by reducing the learning rate for deeper nets, this introduces additional tuning expense and is clearly undesirable. It is not presently clear why regularization aids in stability; we leave investigation of this phenomenon to future work.
Taking a closer look at collapsed networks, we find that even though their outputs have exploded (becoming large enough to go NaN), their weight magnitudes are not especially large, even if we remove our relaxed affine transforms and train networks whose layers are purely weight-standardized. The singular values of the weights, however, end up poorly conditioned, meaning that the Lipschitz constant of the network can become quite large, an effect which Scaled WS does not prevent. One might consider adopting one of the many techniques from the GAN literature to regularize or constrain this constant (Gulrajani et al., 2017; Miyato et al., 2018), but we have found that this added complexity and expense is not necessary to develop performant unnormalized networks.
This collapse highlights an important limitation of our approach, and of SPPs: as SPPs only show signal prop for a given state of a network (i.e., at initialization), no guarantees are provided far from initialization. This fact drives us to prefer parameterizations like Scaled WS rather than solely relying on initialization strategies, and highlights that while good signal propagation is generally necessary for stable optimization, it is not always sufficient.
# A.2 TRAINING SPEED
Table 4: Training speed (in training iterations per second) comparisons of NF-ResNets and BNResNets on a single 16GB V100 for various batch sizes.
<table><tr><td rowspan="2"></td><td colspan="2">BS16</td><td colspan="2">BS32</td><td colspan="2">BS64</td></tr><tr><td>NF</td><td>BN</td><td>NF</td><td>BN</td><td>NF</td><td>BN</td></tr><tr><td>ResNet-50</td><td>17.3</td><td>16.42</td><td>10.5</td><td>9.45</td><td>5.79</td><td>5.24</td></tr><tr><td>ResNet-101</td><td>10.4</td><td>9.4</td><td>6.28</td><td>5.75</td><td>3.46</td><td>3.08</td></tr><tr><td>ResNet-152</td><td>7.02</td><td>5.57</td><td>4.4</td><td>3.95</td><td>2.4</td><td>2.17</td></tr><tr><td>ResNet-200</td><td>5.22</td><td>3.53</td><td>3.26</td><td>2.61</td><td>0OM</td><td>00M</td></tr><tr><td>ResNet-288</td><td>3.0</td><td>2.25</td><td>0OM</td><td>0OM</td><td>0OM</td><td>0OM</td></tr></table>
Table 5: Training speed (in training iterations per second) comparisons of NF-RegNets and BatchNormalized EfficientNets on a single 16GB V100 for various batch sizes.
<table><tr><td rowspan="2"></td><td colspan="2">BS16</td><td colspan="2">BS32</td><td colspan="2">BS64</td></tr><tr><td>NF-RegNet</td><td>EffNet</td><td>NF-RegNet</td><td>EffNet</td><td>NF-RegNet</td><td>EffNet</td></tr><tr><td>B0</td><td>12.2</td><td>5.23</td><td>9.25</td><td>3.61</td><td>6.51</td><td>2.61</td></tr><tr><td>B1</td><td>9.06</td><td>3.0</td><td>6.5</td><td>2.14</td><td>4.69</td><td>1.55</td></tr><tr><td>B2</td><td>5.84</td><td>2.22</td><td>4.05</td><td>1.68</td><td>2.7</td><td>1.16</td></tr><tr><td>B3</td><td>4.49</td><td>1.57</td><td>3.1</td><td>1.05</td><td>2.13</td><td>0OM</td></tr><tr><td>B4</td><td>2.73</td><td>0.94</td><td>1.96</td><td>0OM</td><td>0OM</td><td>0OM</td></tr><tr><td>B5</td><td>1.66</td><td>0OM</td><td>OOM</td><td>OOM</td><td>0OM</td><td>0OM</td></tr></table>
We evaluate the relative training speed of our normalizer-free models against batch-normalized models by comparing training speed (measured as the number of training steps per second). For comparing NF-RegNets against EfficientNets, we measure using the EfficientNet image sizes for each variant to employ comparable settings, but in practice we employ smaller image sizes so that our actual observed training speed for NF-RegNets is faster.
# APPENDIX B MODIFIED BUILDING BLOCKS
In order to maintain good signal propagation in our Normalizer-Free models, we must ensure that any architectural modifications do not compromise our model’s conditioning, as we cannot rely on activation normalizers to automatically correct for such changes. However, our models are not so fragile as to be unable to handle slight relaxations in this realm. We leverage this robustness to improve model expressivity and to incorporate known best practices for model design.
# B.1 AFFINE GAINS AND BIASES
First, we add affine gains and biases to our network, similar to those used by activation normalizers. These are applied as a vector gain, each element of which multiplies a given output unit of a reparameterized convolutional weight, and a vector bias, which is added to the output of each convolution. We also experimented with using these as a separate affine transform applied before the ReLU, but moved the parameters next to the weight instead to enable constant-folding for inference. As is common practice with normalizer parameters, we do not weight decay or otherwise regularize these weights.
Even though these parameters are allowed to vary freely, we do not find that they are responsible for training instability, even in networks where we observe collapse. Indeed, we find that for settings which collapse (typically due to learning rates being too high), removing the affine transform has no impact on stability. As discussed in Appendix A, we observe that model instability arises as a result of the collapse of the spectra of the weights, rather than any consequence of the affine gains and biases.
# B.2 STOCHASTIC DEPTH
We incorporate Stochastic Depth (Huang et al., 2016), where the output of the residual branch of a block is randomly set to zero during training. This is often implemented such that if the block is kept, its value is divided by the keep probability. We remove this rescaling factor to help maintain signal propagation when the signal is kept, but otherwise do not find it necessary to modify this block.
While it is possible that we might have an example where many blocks are dropped and signals are attenuated, in practice we find that, as with affine gains, removing Stochastic Depth does not improve stability, and adding it does not reduce stability. One might also consider a slightly more principled variant of Stochastic Depth in this context, where the skip connection is upscaled by $1 + \alpha$ if the residual branch is dropped, resulting in the variance growing as expected, but we did not find this strategy necessary.
# B.3 SQUEEZE AND EXCITE LAYERS
As mentioned in Section 4.4, we incorporate Squeeze and Excitation layers (Hu et al., 2018), which we empirically find to reduce signal magnitude by a factor of 0.5, which is simply corrected by multiplying by 2. This was determined using a similar procedure to that used to find $\gamma$ values for a given nonlinearity, as demonstrated in Appendix D. We validate this empirically by training NFRegNet models with unmodified $\mathrm { S + E }$ blocks, which do not train stably, and NF-RegNet models with the additional correcting factor of 2, which do train stably.
# B.4 AVERAGE POOLING
In line with best practices determined by He et al. (2019), in our NF-RegNet models we replace the strided 1x1 convolutions with average pooling followed by 1x1 convolutions, a common alternative also employed in Zagoruyko & Komodakis (2016). We found that average pooling with a kernel of size $k \times k$ tended to attenuate the signal by a factor of $k$ , but that it was not necessary to apply any correction due to this. While this will result in mis-estimation of $\beta$ values at initialization, it does not harm training (and average pooling in fact improved results over strided 1x1 convolutions in every case we tried), so we simply include this operation as-is.
APPENDIX C MODEL DETAILS
We develop the NF-RegNet architecture starting with a RegNetY-400MF architecture (Radosavovic et al. (2020)) a low-latency RegNet variant which also uses Squeeze+Excite blocks (Hu et al., 2018)) and uses grouped convolutions with a group width of 8. Following EfficientNets, we first add an additional expansion convolution after the final residual block, expanding to $1 2 8 0 w$ channels, where $w$ is a model width multiplier hyperparameter. We find this to be very important for performance: if the classifier layer does not have access to a large enough feature basis, it will tend to underfit (as measured by higher training losses) and underperform. We also experimented with adding an additional linear expansion layer after the global average pooling, but found this not to provide the same benefit.
Next, we replace the strided 1x1 convolutions in transition layers with average pooling followed by 1x1 convolutions (following He et al. (2019)), which we also find to improve performance. We switch from ReLU activations to SiLU activations (Elfwing et al., 2018; Hendrycks & Gimpel, 2016; Ramachandran et al., 2018). We find that SiLU’s benefits are only realized when used in conjunction with EMA (the model averaging we use, explained below), as in EfficientNets. The performance of the underlying weights does not seem to be affected by the difference in nonlinearities, so the improvement appears to come from SiLU apparently being more amenable to averaging.
We then tune the choice of width $w$ and bottleneck ratio $g$ by sweeping them on the 0.4B FLOP model. Contrary to Radosavovic et al. (2020) which found that inverted bottlenecks (Sandler et al., 2018) were not performant, we find that inverted bottlenecks strongly outperformed their compressive bottleneck counterparts, and select $w = 0 . 7 5$ and $g = 2 . 2 5$ . Following EfficientNets (Tan & Le, 2019), the very first residual block in a network uses $g = 1$ , a FLOP-reducing strategy that does not appear to harmfully impact performance.
We also modify the $\mathrm { S + E }$ layers to be wider by making their hidden channel width a function of the block’s expanded width, rather than the block’s input width (which is smaller in an inverted bottleneck). This results in our models having higher parameter counts than their equivalent FLOP target EfficientNets, but has minimal effect on FLOPS, while improving performance. While both FLOPS and parameter count play a part in the latency of a deployed model, (the quantity which is often most relevant in practice) neither are fully predictive of latency (Xiong et al., 2020). We choose to focus on the FLOPS target instead of parameter count, as one can typically obtain large improvements in accuracy at a given parameter count by, for example, increasing the resolution of the input image, which will dramatically increase the FLOPS.
With our baseline model in hand, we apply the EfficientNet compound scaling (increasing width, depth, and input image resolution) to obtain a family of models at approximately the same FLOP targets as each EfficientNet variant. We directly use the EfficientNet width and depth multipliers for models B0 through B5, and tune the test image resolution to attain similar FLOP counts (although our models tend to have slightly higher FLOP budgets). Again contrary to Radosavovic et al. (2020), which scales models almost entirely by increasing width and group width, we find that the EfficientNet compound scaling works effectively as originally reported, particularly with respect to image size. Improvements might be made by applying further architecture search, such as tuning the $w$ and $g$ values for each variant separately, or by choosing the group width separately for each variant.
Following Touvron et al. (2019), we train on images of slightly lower resolution than we test on, primarily to reduce the resource costs of training. We do not employ the fine-tuning procedure of Touvron et al. (2019). The exact train and test image sizes we use are visible in our model code in Appendix D.
We train using SGD with Nesterov Momentum, using a batch size of 1024 for 360 epochs, which is chosen to be in line with EfficientNet’s schedule of 360 epoch training at batch size 4096. We employ a 5 epoch warmup to a learning rate of 0.4 (Goyal et al., 2017), and cosine annealing to 0 over the remaining epochs (Loshchilov & Hutter, 2017). As with EfficientNets, we also take an exponential moving average of the weights (Polyak, 1964), using a decay of 0.99999 which employs a warmup schedule such that at iteration $i$ , the decay is $\begin{array} { r } { d e c a y \bar { = } m i n ( \bar { i } , \frac { 1 + i } { 1 0 + i } ) } \end{array}$ . We choose a larger decay than the EfficientNets value of 0.9999, as EfficientNets also take an EMA of the running average statistics of the BatchNorm layers, resulting in a longer horizon for the averaged model.
As with EfficientNets, we find that some of our models attain their best performance before the end of training, but unlike EfficientNets we do not employ early stopping, instead simply reporting performance at the end of training. The source of this phenomenon is that as some models (particularly larger models) reach the end of their decay schedule, the rate of change of their weights slows, ultimately resulting in the averaged weights converging back towards the underlying (less performant) weights. Future work in this area might consider examining the interaction between averaging and learning rate schedules.
Following EfficientNets, we also use stochastic depth (modified to remove the rescaling by the keep rate, so as to better preserve signal) with a drop rate that scales from 0 to 0.1 with depth (reduced from the EfficientNets value of 0.2). We swept this value and found the model to not be especially sensitive to it as long as it was not chosen beyond 0.25. We apply Dropout (Srivastava et al., 2014) to the final pooled activations, using the same Dropout rates as EfficientNets for each variant. We also use label smoothing (Szegedy et al., 2016) of 0.1, and weight decay of 5e-5.
# APPENDIX D MODEL CODE
We here provide reference code using Numpy (Harris et al., 2020) and JAX (Bradbury et al., 2018). Our full training code is publicly available at dpmd.ai/nfnets.
# D.1 NUMERICAL APPROXIMATIONS OF NONLINEARITY-SPECIFIC GAINS
It is often faster to determine the nonlinearity-specific constants $\gamma$ empirically, especially when the chosen activation functions are complex or difficult to integrate. One simple way to do this is for the SiLU function is to sample many (say, 1024) random C-dimensional vectors (of say size 256) and compute the average variance, which will allow for computing an estimate of the constant. Empirically estimating constants to ensure good signal propagation in networks at initialization has previously been proposed in Mishkin & Matas (2016) and Kingma & Dhariwal (2018).
import jax import jax.numpy as jnp $\mathtt { k e y } \ =$ jax.random.PRNGKey(2) # Arbitrary key # Produce a large batch of random noise vectors $\begin{array} { r l } { \mathrm { ~ x ~ } } & { { } = } \end{array}$ jax.random.normal(key, (1024, 256)) $\begin{array} { r l } { \mathrm { y } } & { { } = } \end{array}$ jax.nn.silu(x) # Take the average variance of many random batches gamma $=$ jnp.mean(jnp.var(y, axi $\mathbf { S } { = } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf \Psi \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf \Psi \mathbf { } \mathbf { } \mathbf \Psi \mathbf { } \mathbf { } \mathbf \mathbf { } \mathbf \Psi \mathbf { } \mathbf \mathbf { } \mathbf \Psi \mathbf { } \mathbf \mathbf \Psi \mathbf { } \mathbf \mathbf \Psi \mathbf { } \mathbf \mathbf \Psi \mathbf \Psi \mathbf \Psi \mathbf { } \mathbf \mathbf \mathbf \Psi \mathbf \Psi \mathbf \Psi \mathbf \Psi \mathbf \mathbf \Psi \mathbf \mathbf \Psi \mathbf \Psi \mathbf \mathbf \Psi \mathbf \mathbf \Psi \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf $ )) $\star \star \quad - 0 . 5$
# APPENDIX E OVERVIEW OF EXISTING BLOCKS
This appendix contains an overview of several different types of residual blocks.
 Figure 4: Residual Blocks for pre-activation ResNets (He et al., 2016a). Note that some variants swap the order of the nonlinearity and the BatchNorm, resulting in signal propagation which is more similar to that of our normalizer-free networks.
 Figure 5: Residual Blocks for post-activation (original) ResNets (He et al., 2016b).
# APPENDIX F ADDITIONAL SPPS
In this appendix, we include additional Signal Propagation Plots. For reference, given an NHW C tensor, we compute the measured properties using the equivalent of the following Numpy (Harris et al., 2020) snippets:
• Average Channel Mean Squared: np.mean(np.mean(y, axis $=$ [0, 1, 2]) \*\* 2) • Average Channel Variance: np.mean(np.var(y, axis $=$ [0, 1, 2])) • Residual Average Channel Variance: np.mean(np.var(f(x), axis=[0, 1, 2]))
 Figure 6: Signal Propagation Plot for a ResNetV2-600 with ReLU and He initialization, without any normalization, on a semilog scale. The scales of all three properties grow logarithmically due to signal explosion.
 Figure 7: Signal Propagation Plot for 600-layer ResNetV2s with linear activations, comparing BatchNorm against with normalizer-free scaling. Note that the max-pooling operation in the ResNet stem has here been removed so that the inputs to the first blocks are centered.

Figure 8: Signal Propagation Plot for a Normalizer-Free ResNetV2-600 with ReLU and Scaled WS, using $\gamma = \sqrt { 2 }$ , the gain for ReLU from (He et al., 2015). As this gain (derived from $\scriptstyle { \sqrt { \frac { 1 } { \mathbb { E } [ g ( x ) ^ { 2 } ] } } } )$ is lower than the correct gain $( \sqrt { \frac { 1 } { V a r ( g ( x ) ) } } )$ , signals attenuate progressively in the first stage, then are further downscaled at each transition which uses a $\beta$ value that assumes a higher incoming scale.
 Figure 9: Signal Propagation Plot for a Normalizer-Free ResNetV2-600 with ReLU, Scaled WS with correctly chosen gains, and unmodified Squeeze-and-Excite Blocks. Similar to understimating $\gamma$ values, unmodified $\mathtt { S + E }$ blocks will attenuate the signal.
 Figure 10: Signal Propagation Plot for a ResNet-600 with FixUp. Due to the zero-initialized weights, FixUp networks have constant variance in a stage, and still demonstrate variance resets across stages.
 Figure 11: Signal Propagation Plot for a ResNet-600 V1 with post-activation ordering. As this variant applies BatchNorm at the end of the residual block, the Residual Average Channel Variance is kept constant at 1 throughout the model. This ordering also applies BatchNorm on shortcut 1x1 convolutions at stage transition, and thus also displays variance resets.
# APPENDIX G NEGATIVE RESULTS
# G.1 FORWARD MODE VS DECOUPLED WS
Parameterization methods like Weight Standardization (Qiao et al., 2019), Weight Normalization (Salimans & Kingma, 2016), and Spectral Normalization (Miyato et al., 2018) are typically proposed as “foward mode” modifications applied to parameters during the forward pass of a network. This has two consequences: first, this means that the gradients with respect to the underlying parameters are influenced by the parameterization, and that the weights which are optimized may differ substantially from the weights which are actually plugged into the network.
One alternative approach is to implement “decoupled” variants of these parameterizers, by applying them as a projection step in the optimizer. For example, “Decoupled Weight Standardization” can be implemented atop any gradient based optimizer by replacing $W$ with the normalized $\hat { W }$ after the update step. Most papers proposing parameterizations (including the above) argue that the parameterization’s gradient influence is helpful for learning, but this is typically argued with respect to simply ignoring the parameterization during the backward pass, rather than with respect to a strategy such as this.
Using a Forward-Mode parameterization may result in interesting interactions with moving averages or weight decay. For example, with WS, if one takes a moving average of the underlying weights, then applies the WS parameterization to the averaged weights, this will produce different results than if one took the EMA of the Weight-Standardized parameters. Weight decay will have a similar phenomenon: if one is weight decaying a parameter which is actually a proxy for a weight-standardized parameter, how does this change the behavior of the regularization?
We experimented with Decoupled WS and found that it reduced sensitivity to weight decay (presumably because of the strength of the projection step) and often improved the accuracy of the EMA weights early in training, but ultimately led to worse performance than using the originally proposed “forward-mode” formulation. We emphasize that our experiments in this regime were only cursory, and suggest that future work might seek to analyze these interactions in more depth.
We also tried applying Scaled WS as a regularizer (“Soft WS”) by penalizing the mean squared error between the parameter $W$ and its Scaled WS parameterization, $\hat { W }$ . We implemented this as a direct addition to the parameters following Loshchilov & Hutter (2019) rather than as a differentiated loss, with a scale hyperparameter controlling the strength of the regularization. We found that this scale could not be meaningfully decreased from its maximal value without drastic training instability, indicating that relaxing the WS constraint is better done through other means, such as the affine gains and biases we employ.
# G.2 MISCELLANEOUS
• For SPPs, we initially explored plotting activation mean (np.mean(h)) instead of the average squared channel mean, but found that this was less informative. • We also initially explored plotting the average pixel norm: the Frobenius norm of each pixel (reduced across the $C$ axis) then averaged across the $N H W$ axis, np.mean(np.linalg.norm(h, axi $\hphantom { 0 } \mathrm { m } = - 1$ ))). We found that this value did not add any information not already contained in the channel or residual variance measures, and was harder to interpret due to it varying with the channel count. We explored NF-ResNet variants which maintained constant signal variance, rather than mimicking Batch-Normalized ResNets with signal growth $^ +$ resets. The first of two key components in this approach was making use of “rescaled sum junctions,” where the sum junction in a residual block was rewritten to downscale the shortcut path as $\begin{array} { r } { y = \frac { \alpha * f ( x ) + x } { \alpha ^ { 2 } } } \end{array}$ , which is approximately norm-preserving if $f ( x )$ is orthogonal to $x$ (which we observed to generally hold in practice). Instead of Scaled WS, this variant employed SeLU (Klambauer et al., 2017) activations, which we found to work as-advertised in encouraging centering and good scaling. While these networks could be made to train stably, we found tuning them to be difficult and were not able to easily recover the performance of BN-ResNets as we were with the approach ultimately presented in this paper.
# APPENDIX H EXPERIMENTS WITH ADDITIONAL TASKS
H.1 SEMANTIC SEGMENTATION ON PASCAL VOC Table 6: Results on Pascal VOC Semantic Segmentation.
<table><tr><td rowspan=2 colspan=2>NF-ResNets (ours)mIoU</td><td rowspan=1 colspan=1>BN-ResNets</td></tr><tr><td rowspan=1 colspan=1>mIoU</td></tr><tr><td rowspan=1 colspan=1>ResNet-50</td><td rowspan=1 colspan=1>74.4</td><td rowspan=1 colspan=1>75.4</td></tr><tr><td rowspan=1 colspan=1>ResNet-101</td><td rowspan=1 colspan=1>76.7</td><td rowspan=1 colspan=1>77.0</td></tr><tr><td rowspan=1 colspan=1>ResNet-152</td><td rowspan=1 colspan=1>77.6</td><td rowspan=1 colspan=1>77.9</td></tr><tr><td rowspan=1 colspan=1>ResNet-200</td><td rowspan=1 colspan=1>78.4</td><td rowspan=1 colspan=1>78.0</td></tr></table>
We present additional results investigating the transferability of our normalizer-free models to downstream tasks, beginning with the Pascal VOC Semantic Segmentation task. We use the FCN architecture (Long et al., 2015) following He et al. (2020) and Grill et al. (2020) . We take the ResNet backbones of each variant and modify the $3 \mathrm { x } 3$ convolutions in the final stage to have dilation 2 and stride of 1, then add two extra $3 { \bf x } 3$ convolutions with dilation of 6, and a final 1x1 convolution for classification. We train for 30000 steps at batch size 16 using SGD with Nesterov Momentum of 0.9, a learning rate of 0.003 which is reduced by a factor of 10 at $70 \%$ and $90 \%$ of training, and weight decay of 5e-5. Training images are augmented with random scaling in the range [0.5, 2.0]), random horizontal flips, and random crops. Results in mean Intersection over Union (mIoU) are reported in Table 6 on the val2012 set using a single 513 pixel center crop. We do not add any additional regularization such as stochastic depth or dropout. NF-ResNets obtain comparable performance to their BN-ResNet counterparts across all variants.
# H.2 DEPTH ESTIMATION ON NYU DEPTH V2
Table 7: Results on NYUv2 Depth Estimation.
<table><tr><td rowspan="2"></td><td colspan="3">Higher better</td><td rowspan="2">Lower Better rms rel</td></tr><tr><td>pct. <1.25</td><td>pct.<1.252</td><td>pct.<1.253</td></tr><tr><td>NF-ResNet-50</td><td>81.9</td><td>95.9</td><td>98.9</td><td>0.572 0.141</td></tr><tr><td>BN-ResNet-50</td><td>81.7</td><td>95.7</td><td>98.8</td><td>0.579 0.141</td></tr><tr><td>NF-ResNet-101</td><td>82.7</td><td>96.4</td><td>99.0</td><td>0.564 0.136</td></tr><tr><td>BN-ResNet-101</td><td>83.4</td><td>96.2</td><td>98.9</td><td>0.563 0.132</td></tr><tr><td>NF-ResNet-152</td><td>83.2</td><td>96.4</td><td>99.1</td><td>0.558 0.135</td></tr><tr><td>BN-ResNet-152</td><td>81.6</td><td>96.0</td><td>98.9</td><td>0.579 0.140</td></tr><tr><td>NF-ResNet-200</td><td>84.0</td><td>96.7</td><td>99.2</td><td>0.552 0.130</td></tr><tr><td>BN-ResNet-200</td><td>84.6</td><td>96.6</td><td>99.1</td><td>0.548 0.125</td></tr></table>
We next present results for depth estimation on the NYU v2 dataset (Silberman et al., 2012) using the protocol from (Laina et al., 2016). We downsample the images and center crop them to [304, 228] pixels, then randomly flip and apply several color augmentations: grayscale with probability $30 \%$ , brightness with a maximum difference of 0.1255, saturation with a random factor picked from [0.5, 1.5], and Hue with adjustment factor picked in [-0.2, 0.2]. We take the features from the final residual stage and feed them into the up-projection blocks from (Silberman et al., 2012), then train with a reverse Huber loss (Laina et al., 2016; Owen, 2007). We train for 7500 steps at batch size 256 using SGD with Nesterov Momentum of 0.9, a learning rate of 0.16, and cosine annealing. We report results in Table7 using five metrics commonly used for this task: the percentage of pixels where the magnitude of the relative error (taken as the ratio of the predicted depth and the ground truth, where the denominator is whichever is smaller) is below a certain threshold, as well as rootmean-squared and relative error (rms and rel). As with semantic segmentation, we do not apply any additional regularization, and find that our normalizer-free ResNets attain comparable performance across all model variants.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451# SOGCN: SECOND-ORDER GRAPH CONVOLUTIONAL NETWORKS
Anonymous authors Paper under double-blind review
# ABSTRACT
We introduce a second-order graph convolution (SoGC), a maximally localized kernel, that can express a polynomial spectral filter with arbitrary coefficients. We contrast our SoGC with vanilla GCN, first-order (one-hop) aggregation, and higher-order (multi-hop) aggregation by analyzing graph convolutional layers via generalized filter space. We argue that SoGC is a simple design capable of forming the basic building block of graph convolution, playing the same role as $3 \times 3$ kernels in CNNs. We build purely topological Second-Order Graph Convolutional Networks (SoGCN) and demonstrate that SoGCN consistently achieves state-ofthe-art performance on the latest benchmark. Moreover, we introduce the Gated Recurrent Unit (GRU) to spectral GCNs. This explorative attempt further improves our experimental results.
# 1 INTRODUCTION
Deep localized convolutional filters have achieved great success in the field of deep learning. In image recognition, the effectiveness of $3 \times 3$ kernels as the basic building block in Convolutional Neural Networks (CNNs) is shown both experimentally and theoretically (Zhou, 2020). We are inspired to search for the maximally localized Graph Convolution (GC) kernel with full expressiveness power for Graph Convolutional Networks (GCNs).
Most existing GCN methods utilize localized GCs based on one-hop aggregation scheme as the basic building block. Extensive works have shown performance limitations of such design due to over-smoothing (Li et al., 2018; Oono & Suzuki, 2019; Cai & Wang, 2020). In vanilla GCNs (Kipf & Welling, 2017) the root cause of its deficiency is the lumping of the graph node self-connection with pairwise neighboring connections. Recent works of Xu et al. (2019); Dehmamy et al. (2019); Ming Chen et al. (2020) disentangle the effect of self-connection by adding an identity mapping (so-called first-order GC). However, its lack of expressive power in filter representation remains (Abu-El-Haija et al., 2019). The work of (Ming Chen et al., 2020) conjectured that the ability to express a polynomial filter with arbitrary coefficients is essential for preventing over-smoothing.
A longer propagation distance in the graph facilitates GCNs to retain its expressive power, as pointed out by (Liao et al., 2019; Luan et al., 2019; Abu-El-Haija et al., 2019). The minimum propagation distance needed to construct our building block of GCN remains the open question. We show that the minimum propagation distance is two: a two-hop graph kernel with the second-order polynomials in adjacency matrices is sufficient. We call our graph kernel Second-Order GC (SoGC).
We introduce a Layer Spanning Space (LSS) framework to quantify the expressive power of multilayer GCs for modeling a polynomial filter with arbitrary coefficients. By relating low-pass filtering on the graph spectrum (Hoang & Maehara, 2019) with over-smoothing, one can see the lack of filter representation power (Ming Chen et al., 2020) can lead to the performance limitation of GCN.
Using the LSS framework, we show that SoGCs can approximate any linear GCNs in channel-wise filtering. Furthermore, higher-order GCs do not contribute more expressiveness, and vanilla GCN or first-order GCs cannot represent all polynomial filters in general. In this sense, SoGC is the maximally localized graph kernel with the full representation power.
To validate our theory, we build Second-Order Graph Convolutional Networks (SoGCN) using SoGC kernels. Our SoGCN using simple graph topological features consistently achieves stateof-the-art performance on the GNN benchmark datasets (Dwivedi et al., 2020), including citation networks, super-pixel classification, and molecule regression.
 Figure 1: Vertex domain interpretations of vanilla GC, First-Order GC and SoGC. Denote $I$ as the zero-hop aggregator, $A$ the first-hop aggregator and $A ^ { 2 }$ the second-hop aggregator. Nodes in the same colored ring share the same weights. (a) $I$ and $A$ of vanilla GC share the same weights. (b) First-order GC disentangles $I$ from $A$ . (c) SoGC introduces new weights for $A ^ { 2 }$ in addition.
To our best knowledge, this work is the first study that identifies the importance of the two-hop neighborhood in the context of GCNs’ ability to express a polynomial filter with arbitrary coefficients. Our model is a special but non-trivial case of Defferrard et al. (2016). Kipf & Welling (2017) conducted an ablation study with GC kernels of different orders but missed the effectiveness of the second-order relationships. The work of Abu-El-Haija et al. (2019) talked about muti-hop graph kernels; however, they did not identify the critical importance of the second-order form. In contrast, we clarify the prominence of SoGCs in theories and experiments.
Our research on graph convolution using pure topologically relationship is orthogonal to those uses geometric relations (Monti et al., 2017; Fey et al., 2018; Pei et al., 2020), or those with expressive edge features (Li et al., 2016; Gilmer et al., 2017; Corso et al., 2020), and hyper-edges (Morris et al., 2019; Maron et al., 2018; 2019). It is also independent with graph sampling procedures (Rong et al., 2019; Hamilton et al., 2017; Li et al., 2019).
# 2 PRELIMINARIES
We begin by reformulating spectral GCNs and introducing our notation. We are interested in a finite graph set $\dot { \mathcal { G } } = \{ G _ { 1 } , \cdot \cdot \cdot , \mathbf { \bar { G } } _ { | \mathcal { G } | } \}$ . Assume each graph $G \in { \mathcal { G } }$ is simple and undirected, associated with a finite vertex set $\mathcal { V } ( G )$ , an edge set $\mathcal { E } ( G ) = \{ ( u , v ) : \forall u v \}$ , and a symmetric normalized adjacency matrix $A ( G )$ (Chung & Graham, 1997; Shi & Malik, 2000). Without loss of generality and for simplicity, $| \mathcal { V } ( G ) | = N$ for every $G \in { \mathcal { G } }$ . Single-channel features $\pmb { x } \in \mathbb { R } ^ { N }$ supported in graph $G \in { \mathcal { G } }$ is a vectorization of function $\mathcal { V } ( G ) \mathbb { R }$ .
Graph Convolutions (GCs) is known as Linear Shift-Invariant (LSI) operators to adjacency matrices (Sandryhaila & Moura, 2013). By this definition, GCs can extract features regardless of where local structures fall. Given parameter space $\Omega \subseteq \mathbb { R }$ , we write a single-channel GC (Sandryhaila $\&$ Moura, 2013; Defferrard et al., 2016) as a mapping $f _ { \pmb \theta } : \mathcal { G } \times \mathbb { R } ^ { N } \mathbf { \bar { \mathbb { R } } } ^ { N }$ such that 1:
$$f _ { \pmb \theta } ( G , \pmb x ) = \sum _ { k = 0 } ^ { K } \theta _ { k } \pmb { A } ( G ) ^ { k } \pmb x ,$$
where $\pmb { \theta } = \left[ \theta _ { 0 } \quad \cdot \cdot \cdot \quad \theta _ { K } \right] ^ { T } \in \Omega ^ { K + 1 }$ parameterizes the GC. $K$ reflects the localization of $f _ { \theta }$ : a linear combination of features aggregated by $A ( G ) ^ { k }$ . Moreover, we reformulate two popular models, vanilla GC (Figure 1a) and first-order GC (Figure 1b), as below:
$$f _ { 0 } ( G , \pmb { x } ) = \theta \left( \pmb { A } ( G ) + \pmb { I } \right) \pmb { x } , \quad f _ { 1 } ( G , \pmb { x } ) = \left( \theta _ { 1 } \pmb { A } ( G ) + \theta _ { 0 } \pmb { I } \right) \pmb { x } .$$
The general spectral GCNs stack $L$ layers of GCs (Equation 1) with nonlinear activations. Let $f ^ { ( l ) }$ be GC layers with parameters $\pmb { \theta } ^ { ( l ) } \in \Omega ^ { K + 1 } , l \in [ L ]$ , the single-channel GCNs can be written as:
$$F ( G , \pmb { x } ) = g \circ f ^ { ( L ) } \circ \sigma \circ f ^ { ( L - 1 ) } \circ \cdots \circ \sigma \circ f ^ { ( 1 ) } ( G , \pmb { x } ) ,$$
 Figure 2: Visualizing output activation in graph spectrum domain for vanilla GCN, SoGCN, and GRU variants. The test is conducted on a graph from the ZINC dataset. The spectrum is defined as a projection of activation functions on the graph eigenvectors. SoGCN preserved higher-order spectrum, while vanilla GCN shows over-smoothing. See Appendix F for more visualizations on the ZINC dataset.
where $\sigma$ is an element-wise activation function, the superscripts denote the corresponding layer number, $g$ is a task-specified readout function (e.g., softmax), the inputs are graph $G \in { \mathcal { G } }$ and signals $\pmb { x } \in \mathbb { R } ^ { N }$ . The compositionality principle of deep learning suggests $L$ being large, while $K$ being small and localized (LeCun et al., 2015).
# 3 OVERVIEW: SECOND-ORDER GRAPH CONVOLUTION
We are interested in the overall graph convolution network’s representation power of expressing a polynomial filter (Equorder polynomial filter multi-layer GCN approximate a , by stacking basic building block $K$ -f $\begin{array} { r } { \sum _ { k = 0 } ^ { K } \theta _ { k } \pmb { A } ( G ) ^ { k } , \theta _ { k } \in \Omega , k = 0 , \cdot \cdot \cdot K } \end{array}$ graph convolution (GC) layers (Wu et al., 2019; Ming Chen et al., 2020).
We formally define the second-order GC (SoGC) using the second-order polynomials of adjacency matrices:
$$f _ { 2 } ( G , \pmb { x } ) = \left( \theta _ { 2 } \pmb { A } ( G ) ^ { 2 } + \theta _ { 1 } \pmb { A } ( G ) + \theta _ { 0 } \pmb { I } \right) \pmb { x } ,$$
where $\theta _ { i } \in \mathbb { R } , i = 0 , 1 , 2$ are trainable paremeters in the context of machine learning. Its vertexdomain interpretation is illustrated in Figure 1c. At first glance, it seems that we could stack two one-hop graph convolution (GC) kernels to approximate a SoGC. However, as shown in Section 4.3, that is not the case.
The critical insight is that graph filter approximation can be viewed as a polynomial factorization problem. It is known that any univariate polynomial can be factorized into sub-polynomials of degree two. Based on this fact, we show by stacking enough SoGCs (and varying their parameters) can achieve decomposition of any polynomial filters.
In contrast, first-order GCs are not universal approximators; two stacked one-hop GCs cannot model every two-hop GC. Polynomial filter completeness of SoGC leads to better performance of GCNs. As shown in Figure 2, networks built with SoGC can overcome over-smoothing and extract features on high-frequency bands. In the next section, we demonstrate our formal arguments on polynomial approximation.
# 4 REPRESENTATION POWER ANALYSIS
# 4.1 LAYER SPANNING SPACE FRAMEWORK
To illustrate the representation power of GC layers, we establish a Layer Spanning Space (LSS) framework to study the graph filter space spanned by stacking multiple graph kernels.
First, we present our mathematical devices in Definition 1, 2 with Lemma 1 as below.
Definition 1. Suppose the parameter space $\Omega \ = \ \mathbb { R }$ . The Linear Shift-Invariant (LSI) graph filter space of degree $\ : \ : K \ : \ : > \ : \ : 0 \ :$ with respect to a finite graph set $\mathcal { G }$ is defined as $\begin{array} { r l } { A } & { { } = } \end{array}$ $\{ f _ { \pmb \theta } : \hat { \mathcal { G } } \times \mathbb { R } ^ { N } \mathbb { R } ^ { N } , \forall \pmb \theta \in \mathbb { R } ^ { K + 1 } \}$ , where fθ follows the definition in Equation $^ { l }$ .
Definition 2. Let spectrum set $S ( \mathcal { G } ) = \{ \lambda : \lambda \in \mathcal { S } ( A ( G ) ) , \forall G \in \mathcal { G } \}$ , where $ { \mathcal { S } } ( A )$ denotes the eigenvalues of $\pmb { A }$ . Define spectrum capacity $\Gamma = | S ( \mathcal { G } ) |$ . In particular, $\Gamma = ( N - 1 ) | \mathcal { G } |$ if every graph adjacency matrix has no common eigenvalues other than 1.
Lemma 1. A of degree $K > 0$ has dimension $\operatorname* { m i n } \{ K + 1 , \Gamma \}$ as a vector space.
Proof of Lemma 1 follows from Theorem 3 of Sandryhaila & Moura (2013). The complete version can be found in Appendix C. Here, we induce a finite-dimension filter space by Lemma 1.
For simplicity, we will model the linear composition of filters to analyze its representation power. The nonlinear activation effects are beyond the scope of this work. Following Definition 1, let $\mathcal { A }$ be the full filter space of degree $\Gamma - 1$ and $\boldsymbol { B }$ be the low-level filter space as a set of polynomials in adjacency matrices (Equation 1). Denote the GC at $l$ -th layer by $f ^ { ( l ) } \in B$ , then we yield the LSS of stacking $L$ layers as below:
$$\mathcal { B } ^ { L } = \left\{ f : f ( G , \pmb { x } ) = f ^ { ( L ) } \circ \cdots \circ f ^ { ( 1 ) } ( G , \pmb { x } ) = \prod _ { l = 1 } ^ { L } p ^ { ( l ) } ( \pmb { A } ( G ) ) \pmb { x } \right\} ,$$
where $p ^ { ( l ) } ( x )$ varies in a certain class of polynomials. We can assess the expressive capability of GC layers by comparing the LSS with $\mathcal { A }$ . Kernels in $\boldsymbol { B }$ have full representation power if ${ \mathcal { A } } \subseteq { \mathcal { B } } ^ { L }$ . We are interested in $\boldsymbol { B } _ { K }$ , which denotes all localized filters of degree at most $K$ . The LSS of $\boldsymbol { B } _ { K }$ is modeled as:
$$\mathcal { B } _ { K } ^ { L } = \left\{ f : f ( G , \pmb { x } ) = \prod _ { l = 1 } ^ { L } \sum _ { k = 0 } ^ { K } \theta _ { k } ^ { ( l ) } \pmb { A } ( G ) ^ { k } \pmb { x } , \theta _ { k } ^ { ( l ) } \in \mathbb { R } \right\} ,$$
where the number of layers is bounded by $L \le \lceil ( \Gamma - 1 ) / K \rceil$ , according to Lemma 1.
# 4.2 UNIVERSAL REPRESENTATION POWER OF SOGC
In this section, we present Theorem 1 to demonstrate the universal representation power of SoGCs as claimed in Section 3. Formally, we add superscripts to Equation 4 to indicate the layer number. Then we leverage a fundamental polynomial factorization theorem to conclude Theorem 1 as below.
Theorem 1. For any $f \in { \mathcal { A } }$ , there exists $f _ { 2 } ^ { ( l ) } \in B _ { 2 }$ with coefficients $\theta _ { 0 } ^ { ( l ) } , \theta _ { 1 } ^ { ( l ) } , \theta _ { 2 } ^ { ( l ) } \in \mathbb { R } , l = 1 , \cdots , L$ such that $f = f _ { 2 } ^ { ( L ) } \circ \cdots \circ f _ { 2 } ^ { ( 1 ) }$ where $L \leq \lceil ( \Gamma - 1 ) / 2 \rceil$ .
The complete proof is presented Appendix D. Theorem 1 can be regarded as the universal approximation theorem of linear GCNs, which implies multi-layer SoGCs have full filter expressiveness.
Theorem 1 also demonstrates how GCNs with SoGCs benefit from depth, which coincides with the view of Dehmamy et al. (2019). Figure 3a verifies our SoGCN can overcome over-smoothing and successfully utilize depth to attain performance gain.
# 4.3 REPRESENTATION POWER OF OTHER GRAPH CONVOLUTION
In this section, we show that vanilla and first-order GCs lack expressiveness, while higher-order GCs reduce compactness and increase fitting difficulty.
Vanilla vs. second-order. Extensive works have shown the performance deficiency of vanilla GCNs (Hoang & Maehara, 2019; Luan et al., 2019; Oono & Suzuki, 2019; Cai & Wang, 2020). Based on the LSS framework, we can point out a similar issue but from a novel perspective. Let us write $f _ { 0 } ^ { ( l ) } ( G , \pmb { x } ) = \theta ^ { ( l ) } ( \pmb { A } ( G ) + \pmb { I } ) \pmb { x } \in \mathcal { B } _ { 0 }$ as the $l$ -th GC layer2. Then $L$ of them can represent a LSS as follows:
$$\mathcal { B } _ { 0 } ^ { L } = \left\{ f : f ( G , \pmb { x } ) = \theta \sum _ { l = 0 } ^ { L } { \binom { l } { L } \pmb { A } ( G ) ^ { l } \pmb { x } } \right\} ,$$
by letting $\theta = \theta ^ { ( L ) } \cdot \cdot \cdot \theta ^ { ( 1 ) }$ . No matter how large $L$ is or how a optimizer tunes the parameters $\theta ^ { ( l ) }$ , $\dot { \dim } { \cal B } _ { 0 } ^ { L } \dot { = } 1$ which signifies $B _ { 0 } ^ { L }$ degenerates to a negligible subspace of $\mathcal { A }$ .
First-order vs. second-order. We denote first-order GCs as $f _ { 1 } ^ { ( l ) } ( G , { \pmb x } ) = ( \theta _ { 1 } ^ { ( l ) } { \pmb A } ( G ) + \theta _ { 0 } ^ { ( l ) } { \pmb I } ) { \pmb x } \in$ $\boldsymbol { B } _ { 1 }$ . In the spirit of Section 4.1, write the LSS as:
$$\mathcal { B } _ { 1 } ^ { L } = \left\{ f : f ( G , \pmb { x } ) = \prod _ { l = 1 } ^ { L } \left( \theta _ { 1 } ^ { ( l ) } A ( G ) + \theta _ { 0 } ^ { ( l ) } \pmb { I } \right) \pmb { x } , \theta _ { 0 } ^ { ( l ) } , \theta _ { 1 } ^ { ( l ) } \in \mathbb { R } \right\} ,$$
which is isomorphic to a polynomial space whose elements split over the real domain. Compared with $B _ { 0 } ^ { L }$ (Equation 7), $\vec { B _ { 1 } ^ { L } }$ represents a much larger subset of $\mathcal { A }$ . This highlights the importance of the first-order term or the identity mapping mentioned in $\mathrm { X u }$ et al., 2019; Dehmamy et al., 2019; Ming Chen et al., 2020).
The limitations also become obvious since not all polynomials can be factorized into first-order polynomials. These polynomials only occupy a small proportion in the ambient polynomial space (Li, 2011), which indicates first-order GCs are not universal approximators in general.
Higher-order vs. second-order. GCs of degree $K \ \geq \ 2$ are called higher-order GCs. They can model multi-hop GCNs such as Luan et al. (2019); Liao et al. (2019); Abu-El-Haija et al. (2019). Higher-order GCs have equivalent expressive power to SoGCs, since they can be reduced to SoGCs as long as coefficient sparsity can be achieved. But this by-product–an uncertain sparsity of coefficients–is not compatible with gradient-based optimization algorithms. Extensive experiments (Defferrard et al., 2016) have shown the ineffectiveness of learning higher-order kernels, because eigenvalues of graph adjacency matrices diminish when powered. This results in a decreasing numerical rank of ${ \bar { \mathbf { A } } } ( G ) ^ { k }$ , which prevent higher-order GCs from aggregating larger-scale information. SoGCs can alleviate this problem by preventing the loss of information due to higher-order powering operation. Finally, higher-order GC lacks nonlinearity. SoGCN can bring a better balance between the expressive power of low-level layers and nonlinearity among them.
# 5 SECOND-ORDER GRAPH CONVOLUTIONAL NETWORKS
In this section, we introduce other building blocks of GCNs and establish our Second-Order Graph Convolutional Networks (SoGCN) following the fashion of deep learning. First, we promote SoGC to the multi-channel version analogous to Kipf & Welling (2017). Then we cascade a feature embedding layer, multiple SoGC layers, and append a readout module. Suppose the multi-channel input is $\pmb { X } \in \mathbb { R } ^ { N \times D }$ supported in graph $G \in { \mathcal { G } }$ , denote the output of $l$ -th layer as $\pmb { X } ^ { ( l ) } \in \mathbb { R } ^ { N \times E }$ , the final node-level output as $\pmb { Y } \in \bar { \mathbb { R } } ^ { N \times F }$ , or graph-level output as $\pmb { Y } \in \mathbb { R } ^ { \pmb { E } }$ , we formulate our novel deep GCN based on SoGC as follows:
$$\begin{array} { r l } & { \pmb { X } ^ { ( 0 ) } = \rho \left( \pmb { X } ; \pmb { \Phi } \right) , } \\ & { \pmb { X } ^ { ( l + 1 ) } = \sigma \left( \pmb { A } ( G ) ^ { 2 } \pmb { X } ^ { ( l ) } \pmb { \Theta } _ { 2 } ^ { ( l + 1 ) } + \pmb { A } ( G ) \pmb { X } ^ { ( l ) } \pmb { \Theta } _ { 1 } ^ { ( l + 1 ) } + \pmb { X } ^ { ( l ) } \pmb { \Theta } _ { 0 } ^ { ( l + 1 ) } \right) , } \\ & { \pmb { Y } = \tau \left( \pmb { X } ^ { ( L ) } ; \pmb { \Psi } \right) , } \end{array}$$
where $\Theta _ { i } ^ { ( l ) } \in \mathbb { R } ^ { E \times E } , i = 0 , 1 , 2$ are trainable weights for linear filters; $\rho : \mathbb { R } ^ { N \times D } \mathbb { R } ^ { N \times E }$ is an equivariant embedder (Maron et al., 2018) with parameters Φ; σ : RN×E → RN×E is an activation function. For node-level readout, $\tau : \mathbb { R } ^ { N \times E } \stackrel { \bullet } { \to } \mathbb { R } ^ { N \times F }$ can be a decoder (with parameters $\Psi$ ) or a nonlinear activation (e.g., softmax) in place of the prior layer. For graph-level output, $\tau : \mathbb { R } ^ { N \times E } \mathbb { R } ^ { E }$ should be an invariant readout function (Maron et al., 2018), e.g., channel-wise sum, mean or max (Hamilton et al., 2017). In practice, we adopt ReLU as nonlinear activation (i.e., $\sigma = \mathrm { R e L U }$ ), a multi-layer perceptron (MLP) as the embedding function $\rho$ , another MLP for node regression readout, and sum ( $\mathrm { { X u } }$ et al., 2019) for graph classification readout.
# 5.1 GATED RECURRENT UNIT
Gated Recurrent Unit (GRU) has been served as a basic building block in message-passing GNN architectures (Li et al., 2016; Gilmer et al., 2017; Corso et al., 2020). In this subsection, we explore its application in spectral GCNs.
According to Cho et al. (2014), GRU can utilize gate mechanism to preserve and forget information. We hypothesize that a GRU can be trained to remove redundant signals and retain lost features on the spectrum. This function can be used to alleviate the oversmoothing problem of vanilla GCNs by maintaining information from previous layer and canceling the dominance of low-frequencies. By the same means, GRU can also relieve the side-effect of ReLU, which is proved to be a special low-pass filter (Oono & Suzuki, 2019; Cai & Wang, 2020). Even though piled-up SoGCs attain full expressiveness, we show by our experiment that GRU can still facilitate SoGCN in avoiding noises and enhancing features on the spectrum (Figure 2)
Similar to Li et al. (2016); Gilmer et al. (2017), we appends a shared GRU module after each GC layer, which takes the signal before the GC layer as the hidden state, after the GC layer as the current input. We note that GRU can cooperate with any spectral GCs (Equation 1). When integrated with SoGCN, we call this special variant SoGCN-GRU. We formulate its implementation by replacing Equation 10 with Equation 12 as below.
$$\begin{array} { r l } & { \pmb { X } _ { c o n v } ^ { ( l + 1 ) } = \pmb { A } ( G ) ^ { 2 } \pmb { X } ^ { ( l ) } \pmb { \Theta } _ { 2 } ^ { ( l + 1 ) } + \pmb { A } ( G ) \pmb { X } ^ { ( l ) } \pmb { \Theta } _ { 1 } ^ { ( l + 1 ) } + \pmb { X } ^ { ( l ) } \pmb { \Theta } _ { 0 } ^ { ( l + 1 ) } , } \\ & { \pmb { X } ^ { ( l + 1 ) } = \mathrm { G R U } \left( \mathrm { R e L U } \left( \pmb { X } _ { c o n v } ^ { ( l + 1 ) } \right) , \pmb { X } ^ { ( l ) } ; \pmb { \Omega } \right) , } \end{array}$$
where $X _ { c o n v } ^ { ( l + 1 ) }$ is the input, $\pmb { X } ^ { ( l ) }$ represents the hidden state, $\pmb { \Omega }$ denotes parameters of the GRU.
Figure 2 and Figure 6 verify our conjecture. We observe more steady low-frequency component on the spectrum head and more characteristic bands on the high-frequency tail. Our empirical study in Table 3 also indicates the effectiveness of GRU for spectral GCNs in general. Hence, we suggest including this recurrent module as another basic building block of our SoGCNs.
# 5.2 COMPARISON TO RELATED WORK
Spectral GCNs. Spectral GCN leverages polynomials in the adjacency matrix to represent graph convolutional layers (Bruna et al., 2014). Many works have been discussing how to design the polynomial and choose its degree to compose a localized GC layer. ChebyNet (Defferrard et al., 2016) approximates graph filters using Chebyshev polynomials. Vanilla GCN (Kipf & Welling, 2017; Wu et al., 2019) further reduces the GC layer to a degree-one polynomial with first-order and constant terms merged. However, these simplifications cause over-smoothing and performance loss. Our SoGC incorporates only one hop longer but obtains the full representation power. This design keeps each layer localized, simple, and easy to implement but makes the whole GCN much more powerful. Our work reveals the critical degree of polynomial filters where kernel size is minimized while filter representation power is maximized.
Multi-Hop GCNs. To exploit multi-scale information, Luan et al. (2019) devises Snowball GCN and Truncated Krylov GCN to capture neighborhoods at different distances. To simulate hop delta functions, Abu-El-Haija et al. (2019) repeat mixing multi-hop features to identify more topological information. These models exhibit the strength of multi-hop GCNs over one-hop GCNs while leaving the propagation length as a hyper-parameter. Modeling those multi-hop GCNs as our higherorder models, SoGCN possesses the identical representation power but has fixed size and better localization, making SoGC more suitable to be the basic building block in GCNs. It is noteworthy that, although Abu-El-Haija et al. (2019) investigates the two-hop delta function (a Gabor-like filter), their final proposed solution is only a generic class of multi-hop GCNs. The discussion on two-hop delta functions cannot attain our theoretical results.
Expressiveness of GCNs. Most of the works on GCN’s expressiveness are restricted to the oversmoothing problem: Li et al. (2018) first poses the over-smoothing problem; Hoang & Maehara (2019) indicates GCNs are no more than low-pass filters; Luan et al. (2019); Oono & Suzuki (2019) demonstrate the asymptotic behavior of feature activation to a subspace; Cai & Wang (2020) examines the decreasing Dirichlet energy. Unlike them, our established LSS framework can identify specific issues of GCNs with algebraic and geometric interpretations. The over-smoothing problem can be formulated as one of our sub-problems (Section 4.3). In this sense, SoGCN solves a more general expressiveness issue than those relieving over-smoothing problem only $\mathrm { { X u } }$ et al., 2018; Rong et al., 2019; Chen et al., 2020). Ming Chen et al. (2020) introduces identity and initial mapping to recover filter expressiveness. Their analytic framework is also similar to ours. But we generalize their filter space to a graph set, and upper bound its dimension. In the meanwhile, our SoGCN’s architecture is more lightweight. We investigate the overall expressive power of GCNs by discussing filter completeness. This direction is orthogonal to those studying message-passing GNNs (Scarselli et al., 2008) and Weisfeiler-Leman GNNs (Xu et al., 2019; Morris et al., 2019).
# 6 EXPERIMENTS
Experiments are conducted on the synthetic dataset in Section 6.1 and on the GNN benchmarks (Dwivedi et al., 2020) in Section 6.2.
# 6.1 SYNTHETIC GRAPH SPECTRUM DATASET FOR NODE REGRESSION
To validate the expressiveness of SoGCN, and its power to preserve higher-order graph signal, we build a Synthetic Graph Spectrum (SGS) dataset for the node signal filtering regression task. We construct SGS dataset with random graphs. The learning task is to mimic three types of hand-crafted filtering functions: high-pass, low-pass, and band-pass on the graph spectral space (defined over the graph eigenvectors). There are 1k training graphs, 1k validation graphs, and 2k testing graphs for each filtering function. Each graph is undirected and comprises $8 0 \sim 1 2 0$ nodes. Appendix E covers more details of our SGS dataset. We choose Mean Absolute Error (MAE) as the evaluation metric.
Experimental Setup. We compare SoGCN with vanilla GCN (Kipf & Welling, 2017), first-order GCN, and higher-order GCNs on the synthetic dataset.
To evaluate each model’s expressiveness purely on the graph kernel design, we remove ReLU activations for all tested models. We adopt the Adam optimizer (Kingma & Ba, 2015) in our training process, with a batch size of 128. The learning rate begins with 0.01 and decays by half once the validation loss stagnates for more than 10 training epochs.
Table 1: The performance of graph node signal regression with High-Pass, Low-Pass, and BandPass filters (over graph spectral space) as learning target. Each model has 16 GC layers and 16 channels of hidden layers.
<table><tr><td rowspan="2">Model</td><td rowspan="2">#Param</td><td colspan="3">Test MAE± s.d.</td></tr><tr><td>High-Pass</td><td>Low-Pass</td><td>Band-Pass</td></tr><tr><td>Vanilla GCN</td><td>4611</td><td>0.308±0.006</td><td>0.317±0.011</td><td>0.559±0.071</td></tr><tr><td>Vanilla GCN + ReLU 3</td><td>4611</td><td>0.466±0.002</td><td>0.457±0.002</td><td>0.299±0.000</td></tr><tr><td>1st-Order GCN</td><td>8467</td><td>0.036±0.004</td><td>0.032±0.002</td><td>0.115±0.008</td></tr><tr><td>3rd-Order GCN</td><td>16179</td><td>0.021±0.003</td><td>0.022±0.001</td><td>0.045±0.008</td></tr><tr><td>4th-Order GCN</td><td>20035</td><td>0.021±0.003</td><td>0.022±0.002</td><td>0.049±0.006</td></tr><tr><td>SoGCN</td><td>12323</td><td>0.021±0.003</td><td>0.023±0.002</td><td>0.050±0.004</td></tr></table>
Results and Discussion. Table 1 summarizes the quantitative comparisons. SoGCN achieves the superior performance on all of the 3 tasks outperforming vanilla GCN and 1st-order GCN, which implies that SoGC graph convolutional kernel does benefit from explicit disentangling of the $\theta _ { 0 } I$ (zero-hop) and $\theta _ { 2 } \bar { A ^ { 2 } }$ (second-hop) terms. Our results also show that higher-order (third-order and fourth-order) GCNs do not improve the performance further, even though they have many more parameters. SoGCN possesses a more expressive representation ability and a good trade-off between performance and model size.
Figure 3 plots MAE results as we vary the depth and channel width of GC layers. Vanilla GCN can benefit from neither depth nor width. First-order GC, SoGC, and higher-order GC can leverage depth to span larger LSS. Figure 3a illustrates the corresponding performance for each graph kernel types. SoGC and higher-order GC both outperform first-order GC as depth increases. Figure 3b shows the benefits of SoGC remain as we move to multi-channel construction. Comparing Figure 3a and 3b, we find that depth has larger effect on GCNs.
 Figure 3: Relations between test MAE and depth or width. Experiments of both (a) and (b) are conducted on synthetic Band-Pass dataset. Each model in (a) has 16 channels per hidden layer with varying depth. Each model in (b) consists of $1 6 \mathrm { G C }$ layers with varying width.
# 6.2 GNN BENCHMARKS
We follow the benchmarks outlined in Dwivedi et al. (2020) for evaluating GNNs on several datasets across a variety of artificial and real-world tasks. We choose to evaluate our SoGCN on a real-world chemistry dataset (ZINC molecules) for the graph regression task, two semi-artificial computer vision datasets (CIFAR10 and MNIST superpixels) for the graph classification task, and two artificial social network datasets (CLUSTER and PATTERN) for the node classification task.
Table 2: Results and comparison with other GNN models on ZINC, CIFAR10, MNIST, CLUSTER and PATTERN datasets. For ZINC dataset, the parameter budget is set to $5 0 0 \mathrm { k }$ . For CIFAR10, MNIST, CLUSTER and PATTERN datasets, the parameter budget is set to $1 0 0 \mathrm { k }$ . Red: the best model, Green: good models.
<table><tr><td rowspan=2 colspan=1>Model</td><td rowspan=1 colspan=3>Test MAE± s.d.</td><td rowspan=1 colspan=6>Test ACC ± s.d. (%)</td></tr><tr><td rowspan=1 colspan=3>ZINC</td><td rowspan=1 colspan=3>MNIST</td><td rowspan=1 colspan=1>CIFAR10</td><td rowspan=1 colspan=1>CLUSTER</td><td rowspan=1 colspan=1>PATTERN</td></tr><tr><td rowspan=1 colspan=1>Vanilla GCN</td><td rowspan=1 colspan=3>0.367±0.011</td><td rowspan=1 colspan=3>90.705±0.218</td><td rowspan=1 colspan=1>55.710±0.381</td><td rowspan=1 colspan=1>53.445±2.029</td><td rowspan=1 colspan=1>63.880±0.074</td></tr><tr><td rowspan=1 colspan=1>Vanilla GCN-GRU</td><td rowspan=1 colspan=3>0.295±0.005</td><td rowspan=1 colspan=3>96.020±0.090</td><td rowspan=1 colspan=1>61.332±0.849</td><td rowspan=1 colspan=1>57.932±0.168</td><td rowspan=1 colspan=1>70.194±0.216</td></tr><tr><td rowspan=1 colspan=1>GAT</td><td rowspan=1 colspan=3>0.384±0.007</td><td rowspan=1 colspan=3>95.535±0.205</td><td rowspan=1 colspan=1>64.223±0.455</td><td rowspan=1 colspan=1>57.732±0.323</td><td rowspan=1 colspan=1>75.824±1.823</td></tr><tr><td rowspan=1 colspan=1>MoNet</td><td rowspan=1 colspan=3>0.292±0.006</td><td rowspan=1 colspan=3>90.805±0.032</td><td rowspan=1 colspan=1>65.911±2.515</td><td rowspan=1 colspan=1>58.064±0.131</td><td rowspan=1 colspan=1>85.482±0.037</td></tr><tr><td rowspan=4 colspan=1>GraphSageGINGatedGCN3WLGNN</td><td rowspan=2 colspan=3>0.398±0.0020.387±0.015</td><td rowspan=1 colspan=2>97.312±0.097</td><td rowspan=3 colspan=2>97.312±0.09796.485±0.25297.340±0.143</td><td rowspan=1 colspan=1>65.767±0.308</td><td rowspan=1 colspan=1>50.454±0.145</td></tr><tr><td rowspan=2 colspan=3>0.387±0.0150.350±0.020</td><td rowspan=1 colspan=2>0.387±0.015</td><td></td><td rowspan=2 colspan=1>55.255±1.52767.312±0.311</td><td rowspan=1 colspan=1>58.384±0.236</td><td rowspan=2 colspan=1>85.590±0.01184.480±0.122</td></tr><tr><td></td><td></td><td rowspan=1 colspan=1>60.404±0.419</td></tr><tr><td rowspan=1 colspan=3>0.407±0.028 4</td><td rowspan=1 colspan=3>95.075±0.961</td><td rowspan=1 colspan=1>59.175±1.593</td><td rowspan=1 colspan=1>57.130±6.539</td><td rowspan=1 colspan=1>85.661±0.353</td></tr><tr><td rowspan=2 colspan=1>SoGCNSoGCN-GRU</td><td rowspan=2 colspan=3>0.238±0.0170.201±0.006</td><td rowspan=2 colspan=3>96.785±0.11397.729±0.159</td><td rowspan=1 colspan=1>66.338±0.155</td><td rowspan=1 colspan=1>68.167±1.164</td><td rowspan=1 colspan=1>85.735±0.037</td></tr><tr><td rowspan=1 colspan=1>68.208±0.271</td><td rowspan=1 colspan=1>67.994±2.619</td><td rowspan=1 colspan=1>85.711±0.047</td></tr></table>
Experimental Setup. We compare our proposed SoGCN and SoGCN-GRU with state-of-the-art GNNs: vanilla GCN (Kipf & Welling, 2017), GAT (Velickovi ˇ c et al., 2018), MoNet (Monti et al., ´ 2017), GIN ( $\mathrm { { X u } }$ et al., 2019), GraphSage (Hamilton et al., 2017), GatedGCN (Bresson & Laurent, 2017) and 3WL-GNN (Maron et al., 2019). To ensure fair comparisons, we follow the same training and evaluation pipelines (including optimizer settings) and data splits of benchmarks. Furthermore, we adjust our model’s depth and width to ensure it satisfies parameter budgets as specified in the benchmark. Note that we do not use any geometrical information to encode rich graph edge relationship, as in models such as GatedGCN-E-PE. We only employ graph connectivity information for all tested models.
Table 3: Results of ablation study on ZINC, MNIST and CIFAR10 datasets. Vanilla GCN is the comparison baseline and the number in the (↑ ·) and $( \downarrow \cdot )$ represents the performance gain compared with the baseline.
<table><tr><td rowspan="2">Model</td><td>Test MAE± s.d.</td><td colspan="2">Test ACC ± s.d. (%)</td></tr><tr><td>ZINC</td><td>MNIST</td><td>CIFAR10</td></tr><tr><td>Vanilla GCN</td><td>0.367 ± 0.011 (Baseline)</td><td>90.705 ± 0.218 (Baseline)</td><td>55.710± 0.381(Baseline)</td></tr><tr><td>1st-Order GCN</td><td>0.253 ± 0.012 (↓ 0.113)</td><td>96.407 ± 0.089 (↑5.701)</td><td>64.993 ± 0.092 (↑9.283)</td></tr><tr><td>SoGCN</td><td>0.238 ± 0.017 (↓0.129)</td><td>96.785 ± 0.113 (↑6.080)</td><td>66.338 ± 0.155 (个10.628)</td></tr><tr><td>3rd-Order GCN</td><td>0.242 ±0.005 (↓0.125)</td><td>96.367 ± 0.227 (↑5.662)</td><td>64.267 ± 0.182 (↑8.557)</td></tr><tr><td>4th-Order GCN</td><td>0.243±0.009 (↓0.124)</td><td>96.167 ± 0.198 (↑ 5.462)</td><td>64.230 ± 0.212 (个8.520)</td></tr><tr><td>VanillaGCN+GRU</td><td>0.295±0.005 (↓0.072)</td><td>96.020±0.090 (个 5.315)</td><td>61.332± 0.381 (个 5.622)</td></tr><tr><td>1st-Order GCN + GRU</td><td>0.226± 0.015 (↓ 0.141)</td><td>96.945 ±0.093 (↑6.240)</td><td>62.372 ± 0.522 (个6.662)</td></tr><tr><td>SoGCN+GRU</td><td>0.201± 0.006 (↓0.166)</td><td>97.729 ± 0.159 (↑ 7.024)</td><td>68.208 ± 0.271 (个12.498)</td></tr><tr><td>3rd-Order GCN+ GRU</td><td>0.203 ±0.001 (↓0.164)</td><td>97.375 ± 0.052 (↑6.670)</td><td>64.242 ±0.511 (个8.532)</td></tr><tr><td>4th-Order GCN + GRU</td><td>0.204±0.004 (↓0.163)</td><td>97.304± 0.296 (个6.599)</td><td>64.697 ± 0.341 (个 8.987)</td></tr></table>
Results and Discussion. Table 2 reports the benchmark results. Our model SoGCN makes small computational changes to GCN by adopting second-hop and zero-hop neighborhoods, and it outperforms models with complex message-passing mechanisms. With GRU module, SoGCN-GRU tops almost all state-of-the-art GNNs on the ZINC, MNIST and CIFAR10 datasets. Whereas, GRU does not lift performance on the CLUSTER and PATTERN datasets for node classification task. As suggested by Li et al. (2018), graph node classification benefits from low-frequency features. That GRU suppresses low-frequency band will result in a slight performance drop on the CLUSTER and PATTERN datasets.
Ablation Study on High-Order GCNs. To contrast the performance gain produced by different orders on the benchmarks, we evaluate 1st-Order GCN, 3rd-Order GCN, 4th-Order GCN as well as their GRU variants on the ZINC, MNIST and CIFAR10 datasets. Table 3 presents the results of our ablation study, which are consistent to our experiments on the synthetic datasets (Section 6.1). As shown by our ablation study, aggregating zero-hop features brings about significant improvements (Vanilla GCN vs. 1st-Order GCN), and adopting the second-hop features further promotes the performance (1st-Order GCN vs. SoGCN). However, high-order GCNs are not capable of boosting the performance over SoGCN. On the contrary, high-order GCs can even lead to the performance decline (3rd-Order GCN vs. 4th-Order GCN vs. SoGCN). On the ZINC and MNIST datasets, we testify GRU’s effectiveness for each tested model, but the gain brought by GRU is not as significant as aggregating the second-hop features. On the CIFAR10 dataset, GRU fails to improve performance for 1st-Order GCN and 3rd-Order GCN.
# 7 CONCLUSION
What should be the basic building blocks for GCNs? To answer this, we seek the most localized graph convolution kernel (GC) with full expressiveness. We generalize the filter space to a finite graph set and establish our LSS framework to assess GC layers functioning on different hops. We show the second-order localized graph convolutional filter, called SoGC, possesses the full representation power than one-hop GCs. Thus, it becomes the most localized GC that we adopt as the basic building block to establish our SoGCN. Both synthetic and benchmark experiments exhibit the prominence of our theoretic design. We also make an empirical study on the GRU module cooperating with spectral GCNs. Interesting directions for future work include analyzing two-hop aggregation schemes with message-passing GNNs and proving the universality of nonlinear GCNs.
# REFERENCES
Sami Abu-El-Haija, Bryan Perozzi, Amol Kapoor, Nazanin Alipourfard, Kristina Lerman, Hrayr Harutyunyan, Greg Ver Steeg, and Aram Galstyan. Mixhop: Higher-order graph convolutional architectures via sparsified neighborhood mixing. In ICML, 2019.
Xavier Bresson and Thomas Laurent. Residual gated graph convnets. arXiv:1711.07553, 2017.
Joan Bruna, Wojciech Zaremba, Arthur Szlam, and Yann LeCun. Spectral networks and locally connected networks on graphs. 2014.
Chen Cai and Yusu Wang. A note on over-smoothing for graph neural networks. In ICML, 2020.
Deli Chen, Yankai Lin, Wei Li, Peng Li, Jie Zhou, and Xu Sun. Measuring and relieving the oversmoothing problem for graph neural networks from the topological view. In AAAI, 2020.
Kyunghyun Cho, Bart Van Merrienboer, Caglar Gulcehre, Dzmitry Bahdanau, Fethi Bougares, Hol- ¨ ger Schwenk, and Yoshua Bengio. Learning phrase representations using rnn encoder-decoder for statistical machine translation. arXiv preprint arXiv:1406.1078, 2014.
Fan RK Chung and Fan Chung Graham. Spectral graph theory. American Mathematical Soc., 1997.
Gabriele Corso, Luca Cavalleri, Dominique Beaini, Pietro Lio, and Petar Velickovic. Principal neighbourhood aggregation for graph nets. In ICML, 2020.
Michael Defferrard, Xavier Bresson, and Pierre Vandergheynst. Convolutional neural networks on ¨ graphs with fast localized spectral filtering. In NeurIPS, 2016.
Nima Dehmamy, Albert-Laszl ´ o Barab ´ asi, and Rose Yu. Understanding the representation power of ´ graph neural networks in learning graph topology. In NeurIPS, 2019.
Vijay Prakash Dwivedi, Chaitanya K Joshi, Thomas Laurent, Yoshua Bengio, and Xavier Bresson. Benchmarking graph neural networks. arXiv:2003.00982, 2020.
Matthias Fey, Jan Eric Lenssen, Frank Weichert, and Heinrich Muller. Splinecnn: Fast geometric¨ deep learning with continuous b-spline kernels. In CVPR, 2018.
Justin Gilmer, Samuel S Schoenholz, Patrick F Riley, Oriol Vinyals, and George E Dahl. Neural message passing for quantum chemistry. 2017.
Will Hamilton, Zhitao Ying, and Jure Leskovec. Inductive representation learning on large graphs. In NeurIPS, 2017.
NT Hoang and Takanori Maehara. Revisiting graph neural networks: All we have is low-pass filters. arXiv:1905.09550, 2019.
Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. 2015.
Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. In ICLR, 2017.
Yann LeCun, Yoshua Bengio, and Geoffrey Hinton. Deep learning. Nature, 2015.
Guohao Li, Matthias Muller, Ali Thabet, and Bernard Ghanem. Deepgcns: Can gcns go as deep as ¨ cnns? In ICCV, 2019.
Qimai Li, Zhichao Han, and Xiao-Ming Wu. Deeper insights into graph convolutional networks for semi-supervised learning. In AAAI, 2018.
Wembo Li. Probability of all real zeros for random polynomial with the exponential ensemble. Preprint, 2011.
Yujia Li, Daniel Tarlow, Marc Brockschmidt, and Richard Zemel. Gated graph sequence neural networks. In ICLR, 2016.
Renjie Liao, Zhizhen Zhao, Raquel Urtasun, and Richard S Zemel. Lanczosnet: Multi-scale deep graph convolutional networks. In ICLR, 2019.
Sitao Luan, Mingde Zhao, Xiao-Wen Chang, and Doina Precup. Break the ceiling: Stronger multiscale deep graph convolutional networks. In NeurIPS, 2019.
Haggai Maron, Heli Ben-Hamu, Nadav Shamir, and Yaron Lipman. Invariant and equivariant graph networks. In ICLR, 2018.
Haggai Maron, Heli Ben-Hamu, Hadar Serviansky, and Yaron Lipman. Provably powerful graph networks. In NeurIPS, 2019.
Zhewei Wei Ming Chen, Bolin Ding Zengfeng Huang, and Yaliang Li. Simple and deep graph convolutional networks. In ICML, 2020.
Federico Monti, Davide Boscaini, Jonathan Masci, Emanuele Rodola, Jan Svoboda, and Michael M Bronstein. Geometric deep learning on graphs and manifolds using mixture model cnns. In CVPR, 2017.
Christopher Morris, Martin Ritzert, Matthias Fey, William L Hamilton, Jan Eric Lenssen, Gaurav Rattan, and Martin Grohe. Weisfeiler and leman go neural: Higher-order graph neural networks. In AAAI, 2019.
Kenta Oono and Taiji Suzuki. Graph neural networks exponentially lose expressive power for node classification. In ICLR, 2019.
Antonio Ortega, Pascal Frossard, Jelena Kovacevi ˇ c, Jos ´ e MF Moura, and Pierre Vandergheynst.´ Graph signal processing: Overview, challenges, and applications. IEEE, 2018.
Hongbin Pei, Bingzhe Wei, Kevin Chen-Chuan Chang, Yu Lei, and Bo Yang. Geom-gcn: Geometric graph convolutional networks. In ICLR, 2020.
Yu Rong, Wenbing Huang, Tingyang Xu, and Junzhou Huang. Dropedge: Towards deep graph convolutional networks on node classification. In ICLR, 2019.
Aliaksei Sandryhaila and Jose MF Moura. Discrete signal processing on graphs. ´ IEEE Trans. Signal Process, 2013.
Franco Scarselli, Marco Gori, Ah Chung Tsoi, Markus Hagenbuchner, and Gabriele Monfardini. Computational capabilities of graph neural networks. TNN, 2008.
Jianbo Shi and J. Malik. Normalized cuts and image segmentation. TPAMI, 2000.
Petar Velickovi ˇ c, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Lio, and Yoshua ´ Bengio. Graph attention networks. In ICLR, 2018.
Felix Wu, Tianyi Zhang, Amauri Holanda de Souza Jr, Christopher Fifty, Tao Yu, and Kilian Q Weinberger. Simplifying graph convolutional networks. In ICML, 2019.
Keyulu Xu, Chengtao Li, Yonglong Tian, Tomohiro Sonobe, Ken-ichi Kawarabayashi, and Stefanie Jegelka. Representation learning on graphs with jumping knowledge networks. In ICML, 2018.
Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural networks? In ICLR, 2019.
Ding-Xuan Zhou. Universality of deep convolutional neural networks. ACHA, 2020.
# A REMARK ON DEFINITION 1
Let us rewrite the $\mathcal { A }$ of degree $K$ in Definition 1:
$$\mathcal { A } = \left\{ f : f ( G , \pmb { x } ) = \sum _ { k = 0 } ^ { K } \theta _ { k } \pmb { A } ( G ) ^ { k } \pmb { x } , \forall \theta _ { k } \in \mathbb { R } \right\} ,$$
which contains all LSI functions $f : \mathcal { G } \times \mathbb { R } ^ { N } \to \mathbb { R } ^ { N }$ with adjacency matrix as the graph shift. We show this in the following way. First, all linear transformations $\pmb { H }$ invariant to the shift $\pmb { S }$ should have $H S = S H$ . Second, specifying arbitrary graph $G \in { \mathcal { G } }$ , any filter associated with it can be written as below:
$$\pmb { H } ( G ) = \sum _ { k = 0 } ^ { K } \theta _ { k } \pmb { A } ( G ) ^ { k } = \pmb { U } \left( \sum _ { k = 0 } ^ { K } \theta _ { k } \pmb { \Lambda } ^ { k } \right) \pmb { U } ^ { T } ,$$
where $\mathbf { \ } A ( G ) = U \mathbf { \Delta } \mathbf { \Lambda } U ^ { T }$ is the eigendecomposition of $A ( G )$ . Then we can conclude the shiftinvariance property by the following Lemma 2.
Lemma 2. Diagonalizable matrices $\pmb { A } _ { 1 }$ and $A _ { 2 }$ are simultaneously diagonalized if and only if $A _ { 1 } A _ { 2 } = A _ { 2 } A _ { 1 }$ .
# B RING ISOMORPHISM: $A \to \tau$
We derive an equivalent form of $\mathcal { A }$ , namely construct a tractable space for $\mathcal { A }$ . Notice that, this construction is essential to the proof of Lemma 1 and Theorem 1.
Since $\mathcal { G }$ is finite, we can construct a block diagonal matrix $\pmb { T } \in \mathbb { R } ^ { N | \mathcal { G } | \times N | \mathcal { G } | }$ , consisting of all adjacency matrices on the diagonal.
$$\pmb { T } = \left[ \begin{array} { l l l } { \pmb { A } ( G _ { 1 } ) } & { } & { } \\ { } & { \ddots } & { } \\ { } & { } & { \pmb { A } ( G _ { | \mathcal { G } | } ) } \end{array} \right] \in \mathbb { R } ^ { N | \mathcal { G } | \times N | \mathcal { G } | } .$$
Hereby, we stop to explain the big picture of Definition 2 with Equation 15. Obviously, the spectrum capacity $\Gamma$ represents the number of eigenvalues of $\mathbf { T }$ without multiplicity. Note that, eigenvalues of adjacency matrices signify graph similarity. The spectrum capacity $\Gamma$ identifies a set of graphs by enumerating the structural patterns. Even if the graph set goes extremely large (to guarantee the generalization capability), the distribution of spectrum provide the upper bound of $\Gamma$ , so our theories will not lose generality.
Now we get back to construct a matrix space $\tau$ from $\mathcal { A }$ via a ring homomorphism $\pi : { \mathcal { A } } \mathcal { T }$ :
$$\pi : \sum _ { k = 0 } ^ { K } \theta _ { k } \pmb { A } ( G ) ^ { k } \mapsto \sum _ { k = 0 } ^ { K } \theta _ { k } \pmb { T } ^ { k } .$$
Recall that a ring homomorphism preserves the “summation” and “multiplication”. Concretely, we write the matrix space $\tau$ as follows:
$$\mathcal { T } = \left\{ H : H = \sum _ { k = 0 } ^ { K } \theta _ { k } \pmb { T } ^ { k } , \forall \theta _ { k } \in \mathbb { R } \right\} .$$
In the following part, we prove that $\pi$ is an isomorphism.
Proof. First, the definition of $\tau$ (Equation 17) basically conclude the surjectivity. Second, for any $f _ { 1 } \neq f _ { 2 } \in { \mathcal { A } }$ with parameter $\alpha _ { k } , \beta _ { k } \in \mathbb { R }$ where $k = 0 , \cdots , K$ , there exists $G _ { j } \doteq \mathcal { G } , \pmb { x } \in \mathbb { R } ^ { N }$ such that $f _ { 1 } ( G _ { j } , \pmb { x } ) \neq f _ { 2 } ( G _ { j } , \pmb { x } )$ . And we have their images $\pmb { H } _ { 1 } = \pi ( f _ { 1 } ) , \pmb { H } _ { 2 } = \bar { \pi } ( f _ { 2 } )$ . By padding $_ { \textbf { \em x } }$ with zeros like:
$$\begin{array} { r } { \pmb { x } ^ { \prime } = \left[ \mathbf { 0 } _ { N ( j - 1 ) } ^ { T } \quad \pmb { x } ^ { T } \quad \mathbf { 0 } _ { N ( | \mathcal { G } | - j ) } ^ { T } \right] ^ { T } , } \end{array}$$
where ${ \mathbf { 0 } } _ { N }$ denote the all-zero vector of length $N$ . We apply $H _ { 1 } , H _ { 2 }$ to $\mathbf { { x } ^ { \prime } }$ :
$$\begin{array} { r } { \mathbf { { q } } _ { 1 } \mathbf { { x } } ^ { \prime } = \left[ \mathbf { { 0 } } _ { N ( j - 1 ) } ^ { T } \left( \sum _ { k = 0 } ^ { K } \alpha _ { k } A ( G _ { j } ) ^ { k } x \right) ^ { T } \mathbf { { 0 } } _ { N ( | \mathcal { G } | - j ) } ^ { T } \right] ^ { T } = \left[ \mathbf { { 0 } } _ { N ( j - 1 ) } ^ { T } \quad f _ { 1 } ( G _ { j } , x ) ^ { T } \mathbf { { 0 } } _ { N ( | \mathcal { G } | - j ) } ^ { T } \right] ^ { T } , } \end{array}$$
$$\begin{array} { r } { \mathbf { { q } } _ { 2 } \mathbf { { x } } ^ { \prime } = \left[ \mathbf { { 0 } } _ { N ( j - 1 ) } ^ { T } \left( \sum _ { k = 0 } ^ { K } \beta _ { k } { \cal A } ( G _ { j } ) ^ { k } \mathbf { { x } } \right) ^ { T } \mathbf { { 0 } } _ { N ( | \mathcal { G } | - j ) } ^ { T } \right] ^ { T } = \left[ \mathbf { { 0 } } _ { N ( j - 1 ) } ^ { T } \quad f _ { 2 } ( G _ { j } , \mathbf { { x } } ) ^ { T } \quad \mathbf { { 0 } } _ { N ( | \mathcal { G } | - j ) } ^ { T } \right] ^ { T } , } \end{array}$$
Hence, ${ H } _ { 1 } \ne { H } _ { 2 }$ concludes the injectivity.
# C PROOF OF LEMMA 1
We first show $\mathcal { A }$ is a vector space, then we leverage the isomorphism to have equality $\mathrm { d i m } A =$ $\mathrm { d i m } \mathcal { T }$ . Figuring out the dimension of $\tau$ is much more tractable.
Proof. By verifying the linear combination is closed or simply implied from the ring isomorphism $\pi$ , $\mathcal { A }$ is at least a vector space
Then Lemma 1 follows from the Theorem 3 of Sandryhaila & Moura (2013). We briefly conclude the proof in the following way. Let $m ( x )$ denote the minimal polynomial of $_ { \mathbf { T } }$ . We have $\Gamma = \deg m ( x )$ . Due to the isomorphism, $\dim { \mathcal { A } } = \dim { \mathcal { T } }$ .
Suppose $K + 1 < \Gamma$ . First, $\dim \mathcal { T }$ cannot be larger than $K + 1$ , because $\{ I , T , \cdots , T ^ { K } \}$ is a spanning set. If $\dim \mathcal { T } < K + 1$ , then there exists some polynomial $p ( x )$ with $\deg p ( x ) \leq K$ , such that $p ( A ) = \mathbf { 0 }$ . This contradicts the minimality of $m ( x )$ . $\dim \mathcal { T }$ can only be $K + 1$ .
Suppose $K + 1 \ge \Gamma$ . For any $H = h ( \mathbf { T } )$ for some polynomial $h ( x )$ with $\deg h ( x ) \leq K$ . By polynomial division, there exists unique polynomials $q ( x )$ and $r ( x )$ such that
$$h ( \boldsymbol { x } ) = q ( \boldsymbol { x } ) m ( \boldsymbol { x } ) + r ( \boldsymbol { x } ) ,$$
where $\deg r ( x ) < \deg m ( x ) = \Gamma$ . Insert $_ { \mathbf { T } }$ into Equation 21:
$$h ( \pmb { T } ) = q ( \pmb { T } ) m ( \pmb { T } ) + r ( \pmb { T } ) = q ( \pmb { T } ) \pmb { 0 } + r ( \pmb { T } ) = r ( \pmb { T } ) .$$
Therefore, $\{ I , T , \cdots , T ^ { \Gamma - 1 } \}$ form a basis of $\tau$ , i.e., $\dim T = \Gamma$
Remark that, we assume each graph contains the same number of vertices only for the sake of simplicity. Lemma 1 still holds when the vertex numbers are varying, since the construction of Equation 15 is independent of this assumption. However, we need the graph set to be finite, otherwise $\Gamma$ might be uncountable. We leave the discussion on infinite graph sets for future study.
# D PROOF OF THEOREM 1
First, we borrow the concept of $\tau$ (Equation 17) in place of $\mathcal { A }$ . Then we leverage the following basic yet powerful Lemma 3 to conclude the proof of Theorem 1 straightforwardly.
Lemma 3. Over the field of reals, the degree of an irreducible non-trivial univariate polynomial is either one or two.
Proof. For any $f \in A$ , let us map it to $H = h ( A )$ through the isomorphism $\pi$ (Equation 16) for some polynomial $h ( x )$ with $\deg h ( x ) \leq \Gamma - 1$ (By Lemma 1).
By Lemma 3, factorize $h ( x )$ into series of polynomials with the degree at most two, and then merge first-order polynomials into second-order ones until no paired first-order polynomials remaining. Finally, we obtain the following equation:
$$h ( x ) = \prod _ { l = 1 } ^ { \lceil D / 2 \rceil } h ^ { ( l ) } ( x ) ,$$
where $D = \deg h ( x )$ . If $D$ is even, $\deg h ^ { ( l ) } = 2$ for $l = 1 , \cdots , \lceil D / 2 \rceil$ . Otherwise, there exists some $j \in [ L ]$ such that $\deg h ^ { ( j ) } ( x ) = 1$ . Notice that, the remaining first-order polynomials is at most 1, which indicates the sparsity of coefficients is very low.
Now we obtain filters $\pmb { H } ^ { ( l ) } = h ^ { ( l ) } ( \pmb { T } )$ for $l = 1 , \cdots , \lceil D / 2 \rceil$ . The last step is applying the inverse of isomorphism $\pi ^ { - 1 }$ to map $\pmb { H } ^ { ( l ) } \in \mathcal { T }$ back to $f ^ { ( l ) } \in { \mathcal { A } }$ as below:
$$\pi ^ { - 1 } : \sum _ { k = 0 } ^ { K } \theta _ { k } \pmb { T } ^ { k } \mapsto \sum _ { k = 0 } ^ { K } \theta _ { k } \pmb { A } ( G ) ^ { k } .$$
Recalling Section 4.1, $f ^ { ( l ) } \in B _ { 2 }$ for $l = 1 , \cdots , \lceil D / 2 \rceil$ . Since $\pi ^ { - 1 }$ is also a ring isomorphism, ${ \pmb H } = { \pmb H } ^ { ( \lceil D / 2 \rceil ) } \circ \cdot \cdot \cdot \circ { \pmb H } ^ { ( 1 ) }$ implies $f = f ^ { ( \lceil D / 2 \rceil ) } \circ \cdot \cdot \cdot \circ f ^ { ( 1 ) }$ .
Remark that Theorem 1 can be considered as the GCN-version of Theorem 3 in Zhou (2020). It plays a key step in proving the universality of nonlinear CNNs. Our Theorem 1, thus, provides a strong tool for analyzing nonlinear GCNs.
# E SYNTHETIC GRAPH SPECTRUM (SGS) DATASET
Our SGS dataset works for node signal filtering regression tasks. We designed 3 types of graph signal filters: high-pass (HP), low-pass (LP) and band-pass (BP) filters, as given in Equation 25. For each type, we generate 1000, 1000 and 2000 undirected graphs with graph signals and groundtruth response in the training set, validation set and test set, repectively. Each graph approximately has $8 0 ~ \tilde { ~ } 1 2 0$ nodes and $8 0 ~ \tilde { ~ } 3 5 0$ edges. Models trained on each sub-dataset are expected to learn the corresponding filter by supervising the MAE loss.
$${ \begin{array} { l } { F _ { H P } ^ { * } ( x ) = { \cfrac { 1 } { 1 + \exp \{ - 5 0 ( x - 1 ) \} } } } \\ { F _ { L P } ^ { * } ( x ) = 1 - { \cfrac { 1 } { 1 + \exp \{ - 5 0 ( x - 1 ) \} } } } \\ { F _ { B P } ^ { * } ( x ) = { \cfrac { - 1 } { 1 + \exp \{ - 1 0 0 ( x - 1 . 0 5 ) \} } } + { \cfrac { 1 } { 1 + \exp \{ - 1 0 0 ( x - 0 . 9 5 ) \} } } } \end{array} }$$
Undirected graphs are randomly sampled through rejection sampling of edges from complete graphs. In detail, we randomly draw an integer $N$ from [80, 120] as the number of nodes, and then generate a $N \times N$ random matrix $\textbf { { B } }$ with each element independently sampled from $\mathrm { U n i f } ( 0 , 1 )$ . Set a threshold $\epsilon$ and we can construct an adjacency matrix $\pmb { A }$ by letting $a _ { i , j } = 1$ if $b _ { i , j } > \epsilon$ , otherwise $a _ { i , j } = 0$ , where $a _ { i , j }$ is the element located at the i-th row and j-th column of $\pmb { A }$ .
Next, we need to generate spectral signals $\pmb { s }$ for the graph. Independent sampling for each spectrum from a probabilistic distribution will only generate noises. Hence, we synthesize spectrum by summing random functions. We notice that pdf of the beta distribution $\mathrm { B e t a } ( a , b )$ is a powerful tool to construct diverse curves by tuning shape parameters $a$ and $b$ . Also, Gaussian function $\operatorname { N o r m } ( \mu , \sigma )$ is able to yield diverse bell-shaped curves by tuning $\mu$ and $\sigma$ . We sum 2 discretized beta functions, 4 discretized Gaussian functions with random parameters to generate spectral signals. Equation 26 elaborates the generation process and hyper-parameter choosing in our experiments, where $g [ x ; a , b ]$ is the pdf of $\mathrm { B e t a } ( a , b )$ distribution, $f [ x ; \mu , \sigma ]$ is the pdf of $\operatorname { N o r m } ( \mu , \sigma )$ distribution.
$$\begin{array} { l } { \displaystyle s [ x ] = \sum _ { i = 1 } ^ { 2 } g [ x / N ; a _ { i } , b _ { i } ] + \sum _ { j = 1 } ^ { 4 } c _ { j } f [ x ; \mu _ { j } , \sigma _ { j } ] \quad x \in [ N ] } \\ { \displaystyle a _ { i } , b _ { i } \sim \mathrm { U n i f } \{ 0 . 1 , 5 \} \quad \mu _ { j } \sim \mathrm { U n i f } \{ 0 , N \} \quad \sigma _ { j } \sim \mathrm { U n i f } \left\{ \frac { N } { ( j + 1 ) } , \frac { N } { j } \right\} / 9 } \\ { \displaystyle c _ { j } \sim \frac { \mathrm { U n i f } \{ 0 . 5 , 2 \} } { \operatorname* { m a x } _ { x \in [ N ] } f [ x ; \mu _ { j } , \sigma _ { j } ] } } \end{array}$$
In most real-world cases, graph signals are usually represented in vertex-domain. With a generated graph and its spectral signals, we can retrieve the vertex-domain signals by inverse graph Fourier transformation: perform eigen-decomposition on the normalized adjacency matrix $\tilde { A }$ of the graph to retrieve its graph Fourier basis $\tilde { U }$ , then we can find vertex-domain signals by $\tilde { U } s$ .
For supervising purpose, we retrieve the groundtruth of each filter’s response by applying each filter to the generated spectral signals, namely $F _ { k } ^ { * } ( s ) , k \in \{ H P , L P , B P \}$ . Figure 4 illustrates an example of the generated spectral signals and its groundtruth filtering response of the 3 filters.
 Figure 4: An example of graph spectrum in our SGS dataset and its corresponding high-pass, lowpass and band-pass filtering response using our hand-crafted filters.
# F MORE VISUALIZATIONS OF SPECTRUM
We compute spectrum as follows: suppose we have an undirected and unweighted graph with normalized adjacency matrix $\pmb { A }$ and node signal $\pmb { X } \in \mathbb { R } ^ { N \times D }$ , where $N$ is the number of nodes and $D$ is the number of signal channels. Since $\pmb { A }$ is symmetric, we perform an eigen-decomposition on the adjacency matrix $\mathbf { \bar { A } } = \mathbf { U } \mathbf { A } \pmb { U } ^ { T }$ . Then the spectrum of $\boldsymbol { X }$ is computed by ${ \boldsymbol { S } } = { \boldsymbol { U } } ^ { \prime } { \boldsymbol { X } }$ . More information about the graph spectrum and graph Fourier transformation can be found in Ortega et al. (2018).
Figure 5 shows the output spectrum of Vanilla GCN, 1st-Order GCN and SoGCN on the synthetic Band-Pass dataset. The visualizations are consistent to the Table 1 and Figure 3. Vanilla GCN almost loses all the band-pass frequency, resulting in a very poor performance. 1st-Order GCN learns to pass a part of medium-frequency band but still have an obvious distance from the groundtruth filter. SoGCN’s filtering response is close to the groundtruth response, showing its strong ability to represent graph signal filters.
Figure 6 gives more spectrum visualizations on the ZINC dataset. We can observe the spectrum impacts of GRU on Vanilla GCN and our SoGCN. Each curve in the visualization figure represents the spectrum of each output channel, i.e., we plot each column of $_ { s }$ as a curve.
 Figure 5: Visualizations of output spectrum on the SGS Band-Pass dataset.
 Figure 6: More visualizations of output spectrum on the ZINC dataset.md/train/5KWmB6JePx/5KWmB6JePx.mdAdded+357
md/train/8PA2nX9v_r2/8PA2nX9v_r2.mdAdded+269
md/train/9FWas6YbmB3/9FWas6YbmB3.mdAdded+390
md/train/B1IDRdeCW/B1IDRdeCW.mdAdded+270
md/train/B1g8VkHFPH/B1g8VkHFPH.mdAdded+343
md/train/B1xtFpVtvB/B1xtFpVtvB.mdAdded+256
md/train/Byg9bxrtwS/Byg9bxrtwS.mdAdded+661
md/train/H1gDaa4YwS/H1gDaa4YwS.mdAdded+370
md/train/H1gN6kSFwS/H1gN6kSFwS.mdAdded+382
md/train/HJlQfnCqKX/HJlQfnCqKX.mdAdded+335
md/train/Hk95PK9le/Hk95PK9le.mdAdded+162
md/train/Hyx0slrFvH/Hyx0slrFvH.mdAdded+475
md/train/IBVBtz_sRSm/IBVBtz_sRSm.mdAdded+332
md/train/IX3Nnir2omJ/IX3Nnir2omJ.mdAdded+478
md/train/JeweO9-QqV-/JeweO9-QqV-.mdAdded+451
md/train/KCzRX9N8BIH/KCzRX9N8BIH.mdAdded
md/train/PhtFY9plHk/PhtFY9plHk.mdAdded
md/train/Re_VXFOyyO/Re_VXFOyyO.mdAdded
md/train/Rnn8zoAkrwr/Rnn8zoAkrwr.mdAdded
md/train/S1eZYeHFDS/S1eZYeHFDS.mdAdded
md/train/S1lg0jAcYm/S1lg0jAcYm.mdAdded
md/train/ShnM-rRh4T/ShnM-rRh4T.mdAdded
md/train/SkBsEQYll/SkBsEQYll.mdAdded
md/train/SkgKO0EtvS/SkgKO0EtvS.mdAdded
md/train/Sy2fzU9gl/Sy2fzU9gl.mdAdded
md/train/SyL9u-WA-/SyL9u-WA-.mdAdded
md/train/SylO2yStDr/SylO2yStDr.mdAdded
md/train/SysEexbRb/SysEexbRb.mdAdded
md/train/SyxBxCNFwr/SyxBxCNFwr.mdAdded
md/train/UfX6vkvhtl/UfX6vkvhtl.mdAdded
md/train/WEKfdiZYZi-/WEKfdiZYZi-.mdAdded
md/train/_TGlfdZOHY3/_TGlfdZOHY3.mdAdded
md/train/b9PoimzZFJ/b9PoimzZFJ.mdAdded
md/train/eedamFFTcK5/eedamFFTcK5.mdAdded
md/train/fpJX0O5bWKJ/fpJX0O5bWKJ.mdAdded
md/train/iaO_IH7CnGJ/iaO_IH7CnGJ.mdAdded
md/train/j5NrN8ffXC/j5NrN8ffXC.mdAdded
md/train/jrA5GAccy_/jrA5GAccy_.mdAdded
md/train/lvRTC669EY_/lvRTC669EY_.mdAdded
md/train/m7QWxKp2Xqd/m7QWxKp2Xqd.mdAdded
md/train/r1f0YiCctm/r1f0YiCctm.mdAdded
md/train/r1ltnp4KwS/r1ltnp4KwS.mdAdded
md/train/r7UC-b67YkO/r7UC-b67YkO.mdAdded
md/train/rJfUCoR5KX/rJfUCoR5KX.mdAdded
md/train/rJlk6iRqKX/rJlk6iRqKX.mdAdded
md/train/rkGZuJb0b/rkGZuJb0b.mdAdded
md/train/rkgbwsAcYm/rkgbwsAcYm.mdAdded
md/train/uxpzitPEooJ/uxpzitPEooJ.mdAdded
md/train/wxobw18IYOxu4/wxobw18IYOxu4.mdAdded
md/train/zzdf0CirJM4/zzdf0CirJM4.mdAdded