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/1Jv6b0Zq3qi/1Jv6b0Zq3qi.mdAdded+338
- md/train/2zCRcTafea/2zCRcTafea.mdAdded+267
- md/train/30EvkP2aQLD/30EvkP2aQLD.mdAdded+611
- md/train/3EwcMzmUbNd/3EwcMzmUbNd.mdAdded+356
- md/train/5vShUEyjmm/5vShUEyjmm.mdAdded+389
- md/train/7_eLEvFjCi3/7_eLEvFjCi3.mdAdded+318
- md/train/8q_ca26L1fz/8q_ca26L1fz.mdAdded+346
- md/train/B7v4QMR6Z9w/B7v4QMR6Z9w.mdAdded
- md/train/BJInEZsTb/BJInEZsTb.mdAdded+396
- md/train/BJLmN8xRW/BJLmN8xRW.mdAdded+169
- md/train/BJlkgaNKvr/BJlkgaNKvr.mdAdded
- md/train/BkV4VS9ll/BkV4VS9ll.mdAdded+599
- md/train/BkeaEyBYDB/BkeaEyBYDB.mdAdded+234
- md/train/D7bPRxNt_AP/D7bPRxNt_AP.mdAdded+292
- md/train/Fo6S5-3Dx_/Fo6S5-3Dx_.mdAdded+329
- md/train/GrB-y0SNkQ/GrB-y0SNkQ.mdAdded+636
- md/train/H1eCw3EKvH/H1eCw3EKvH.mdAdded+354
- md/train/H1gBsgBYwH/H1gBsgBYwH.mdAdded
- md/train/H1xwNhCcYm/H1xwNhCcYm.mdAdded
- md/train/HJ1kmv9xx/HJ1kmv9xx.mdAdded
- md/train/HJxeWnCcF7/HJxeWnCcF7.mdAdded
- md/train/HyGhN2A5tm/HyGhN2A5tm.mdAdded
- md/train/Hyx6Bi0qYm/Hyx6Bi0qYm.mdAdded
- md/train/Ig53hpHxS4/Ig53hpHxS4.mdAdded
- md/train/QpU7n-6l0n/QpU7n-6l0n.mdAdded
- md/train/RQfcckT1M_4/RQfcckT1M_4.mdAdded
- md/train/RtNpzLdHUAW/RtNpzLdHUAW.mdAdded
- md/train/S1eK3i09YQ/S1eK3i09YQ.mdAdded
- md/train/S1lF8xHYwS/S1lF8xHYwS.mdAdded
- md/train/SJlKrkSFPH/SJlKrkSFPH.mdAdded
- md/train/SJx7Jrtgl/SJx7Jrtgl.mdAdded
- md/train/SkgHtkrYPH/SkgHtkrYPH.mdAdded
- md/train/SkxKPDv5xl/SkxKPDv5xl.mdAdded
- md/train/Sy1f0e-R-/Sy1f0e-R-.mdAdded
- md/train/UZgGf92u5N0/UZgGf92u5N0.mdAdded
- md/train/VKVShLsAuZ/VKVShLsAuZ.mdAdded
- md/train/VRgITLy0l2/VRgITLy0l2.mdAdded
- md/train/WGWzwdjm8mS/WGWzwdjm8mS.mdAdded
- md/train/XZDeL25T12l/XZDeL25T12l.mdAdded
- md/train/YicbFdNTTy/YicbFdNTTy.mdAdded
- md/train/dBE8OI8_ZOa/dBE8OI8_ZOa.mdAdded
- md/train/m1CD7tPubNy/m1CD7tPubNy.mdAdded
- md/train/r1eBeyHFDH/r1eBeyHFDH.mdAdded
- md/train/r1efr3C9Ym/r1efr3C9Ym.mdAdded
- md/train/rJfHoM-C-/rJfHoM-C-.mdAdded
- md/train/rJiNwv9gg/rJiNwv9gg.mdAdded
- md/train/rklB76EKPr/rklB76EKPr.mdAdded
- md/train/rkxY-sl0W/rkxY-sl0W.mdAdded
- md/train/uDeDDoFOEpj/uDeDDoFOEpj.mdAdded
- md/train/zI38PZQHWKj/zI38PZQHWKj.mdAdded
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338# UNCERTAINTY IN GRADIENT BOOSTING VIA ENSEMBLES
Andrey Malinin∗ Yandex; HSE University Moscow, Russia am969@yandex-team.ru Liudmila Prokhorenkova∗ Yandex; HSE University; Moscow Institute of Physics and Technology Moscow, Russia ostroumova-la@yandex-team.ru
# Aleksei Ustimenko∗
Yandex Moscow, Russia austimenko@yandex-team.ru
# ABSTRACT
For many practical, high-risk applications, it is essential to quantify uncertainty in a model’s predictions to avoid costly mistakes. While predictive uncertainty is widely studied for neural networks, the topic seems to be under-explored for models based on gradient boosting. However, gradient boosting often achieves stateof-the-art results on tabular data. This work examines a probabilistic ensemblebased framework for deriving uncertainty estimates in the predictions of gradient boosting classification and regression models. We conducted experiments on a range of synthetic and real datasets and investigated the applicability of ensemble approaches to gradient boosting models that are themselves ensembles of decision trees. Our analysis shows that ensembles of gradient boosting models successfully detect anomalous inputs while having limited ability to improve the predicted total uncertainty. Importantly, we also propose a concept of a virtual ensemble to get the benefits of an ensemble via only one gradient boosting model, which significantly reduces complexity.
# 1 INTRODUCTION
Gradient boosting (Friedman, 2001) is a widely used machine learning algorithm that achieves stateof-the-art results on tasks containing heterogeneous features, complex dependencies, and noisy data: web search, recommendation systems, weather forecasting, and many others (Burges, 2010; Caruana & Niculescu-Mizil, 2006; Richardson et al., 2007; Roe et al., 2005; Wu et al., 2010; Zhang & Haghani, 2015). Gradient boosting based on decision trees (GBDT) underlies such well-known libraries like XGBoost, LightGBM, and CatBoost. In this paper, we investigate the estimation of predictive uncertainty in GBDT models. Uncertainty estimation is crucial for avoiding costly mistakes in high-risk applications, such as autonomous driving, medical diagnostics, and financial forecasting. For example, in self-driving cars, it is necessary to know when the AI-pilot is confident in its ability to drive and when it is not to avoid a fatal collision. In financial forecasting and medical diagnostics, mistakes on the part of an AI forecasting or diagnostic system could either lead to large financial or reputational loss or to the loss of life. Crucially, both financial and medical data are often represented in heterogeneous tabular form — data on which GBDTs are typically applied, highlighting the relevance of our work on obtaining uncertainty estimates for GBDT models.
Approximate Bayesian approaches for uncertainty estimation have been extensively studied for neural network models (Gal, 2016; Malinin, 2019). Bayesian methods for tree-based models (Chipman et al., 2010; Linero, 2017) have also been widely studied in the literature. However, this research did not explicitly focus on studying uncertainty estimation and its applications. Some related work was done by Coulston et al. (2016); Shaker & Hüllermeier (2020), who examined quantifying predictive uncertainty for random forests. However, the area has been otherwise relatively under-explored, especially for GBDT models that are widely used in practice and known to outperform other approaches based on tree ensembles.
While for classification problems GDBT models already return a distribution over class labels, for regression tasks they typically yield only point predictions. Recently, this problem was addressed in the NGBoost algorithm (Duan et al., 2020), where a GBDT model is trained to return the mean and variance of a normal distribution over the target variable $y$ for a given feature vector. However, such models only capture data uncertainty (Gal, 2016; Malinin, 2019), also known as aleatoric uncertainty, which arises due to inherent class overlap or noise in the data. However, this does not quantify uncertainty due to the model’s inherent lack of knowledge about inputs from regions either far from the training data or sparsely covered by it, known as knowledge uncertainty, or epistemic uncertainty (Gal, 2016; Malinin, 2019). One class of approaches for capturing knowledge uncertainty are Bayesian ensemble methods, which have recently become popular for estimating predictive uncertainty in neural networks (Depeweg et al., 2017; Gal & Ghahramani, 2016; Kendall et al., 2018; Lakshminarayanan et al., 2017; Maddox et al., 2019; Smith & Gal, 2018). A key feature of ensemble approaches is that they allow overall uncertainty to be decomposed into data uncertainty and knowledge uncertainty within an interpretable probabilistic framework (Depeweg et al., 2017; Gal, 2016; Malinin, 2019). Ensembles are also known to yield improvements in predictive performance.
This work examines ensemble-based uncertainty-estimation for GBDT models. The contributions are as follows. First, we consider generating ensembles using both classical Stochastic Gradient Boosting (SGB) as well as the recently proposed Stochastic Gradient Langevin Boosting (SGLB) (Ustimenko & Prokhorenkova, 2020). Importantly, SGLB allows us to guarantee that the models are asymptotically sampled from a true Bayesian posterior. Second, we show that using SGLB we can construct a virtual ensemble using only one gradient boosting model, significantly reducing the computational complexity. Third, to understand the attributes of using ensembles-based uncertainty estimation in GBDT models, we conduct extensive analysis on several synthetic datasets. Finally, we evaluate the proposed approach on a range of real regression and classification datasets. Our results show that this approach successfully enables the detection of anomalous out-of-domain inputs. Importantly, our solution is easy to combine with any implementation of GBDT. Our methods have been implemented within the open-source CatBoost library. The code of our experiments is publicly available at https://github.com/yandex-research/GBDT-uncertainty.
# 2 PRELIMINARIES
Uncertainty Estimation via Bayesian Ensembles In this work we consider uncertainty estimation within the standard Bayesian ensemble-based framework (Gal, 2016; Malinin, 2019). Here, model parameters $\pmb { \theta }$ are considered random variables and a prior $\mathtt { p } ( \pmb \theta )$ is placed over them to compute a posterior $\mathtt { p } ( \pmb { \theta } | \mathcal { D } )$ via Bayes’ rule:
$$\mathtt { p } ( \pmb { \theta } | \mathcal { D } ) = \frac { \mathtt { p } ( \mathcal { D } | \pmb { \theta } ) \mathtt { p } ( \pmb { \theta } ) } { \mathtt { p } ( \mathcal { D } ) } .$$
where $\mathcal { D } = \{ \pmb { x } ^ { ( i ) } , y ^ { ( i ) } \} _ { i = 1 } ^ { N }$ is the training dataset. Each set of parameters can be considered a hypothesis or explanation about how the world works. Samples from the posterior should yield explanations consistent with the observations of the world contained within the training data $\mathcal { D }$ . However, on data far from $\mathcal { D }$ each set of parameters can yield different predictions. Therefore, estimates of knowledge uncertainty can be obtained by examining the diversity of predictions.
Consider an ensemble of probabilistic models $\{ \mathsf { P } ( y | \pmb { x } ; \pmb { \theta } ^ { ( m ) } ) \} _ { m = 1 } ^ { M }$ sampled from the posterior $\mathtt { p } ( \pmb { \theta } | \mathcal { D } )$ . Each model $\mathsf { P } ( y | \pmb { x } , \pmb { \theta } ^ { ( m ) } )$ yields a different estimate of data uncertainty, represented by the entropy of its predictive distribution (Malinin, 2019). Uncertainty in predictions due to knowledge uncertainty is expressed as the level of spread, or “disagreement”, of models in the ensemble (Malinin, 2019). Note that exact Bayesian inference is often intractable, and it is common to consider either an explicit or implicit approximation ${ \mathfrak { q } } ( \theta )$ to the true posterior ${ \tt p } ( \pmb \theta | \mathcal { D } )$ . While a range of approximations has been explored for neural network models (Gal & Ghahramani, 2016; Lakshminarayanan et al., 2017; Maddox et al., 2019)1, to the best of our knowledge, limited work has explored Bayesian inference for gradient-boosted trees. Given ${ \tt p } ( \pmb \theta | \mathcal { D } )$ , the predictive posterior of the ensemble is obtained by taking the expectation with respect to the models in the ensemble:
$$\mathbb { P } \big ( \boldsymbol { y } | \boldsymbol { x } , \mathcal { D } \big ) = \mathbb { E } _ { \mathbb { P } ^ { ( \theta | \mathcal { D } ) } } \big [ \mathbb { P } \big ( \boldsymbol { y } | \boldsymbol { x } ; \boldsymbol { \theta } \big ) \big ] \approx \ \frac { 1 } { M } \sum _ { m = 1 } ^ { M } \mathbb { P } \big ( \boldsymbol { y } | \boldsymbol { x } ; \boldsymbol { \theta } ^ { ( m ) } \big ) , \ \boldsymbol { \theta } ^ { ( m ) } \sim \mathbb { p } ( \boldsymbol { \theta } | \mathcal { D } ) .$$
The entropy of the predictive posterior estimates total uncertainty in predictions:
$$\begin{array} { r } { \mathcal { H } \big [ \mathrm { P } ( y | x , \mathcal { D } ) \big ] = \mathbb { E } _ { \mathrm { P } ( y | x , \mathcal { D } ) } \big [ - \ln \mathrm { P } ( y | x , \mathcal { D } ) \big ] . } \end{array}$$
Total uncertainty is due to both data uncertainty and knowledge uncertainty. However, in applications like active learning (Kirsch et al., 2019) and out-of-domain detection it is desirable to estimate knowledge uncertainty separately. The sources of uncertainty can be decomposed by considering the mutual information between the parameters $\pmb \theta$ and the prediction $y$ (Depeweg et al., 2017):
$$\begin{array} { r l r } { { \underbrace { \underline { { \mathcal { L } \big [ \boldsymbol { y } , \boldsymbol { \theta } | \boldsymbol { x } , \mathcal { D } \big ] } } } _ { \mathrm { K n o w l e d g e ~ U n c e r t a i n t y } } = \underbrace { \mathcal { H } \big [ \mathtt { P } ( \boldsymbol { y } | \boldsymbol { x } , \mathcal { D } ) \big ] } _ { \mathrm { T o t a l ~ U n c e r t a i n t y } } - \underbrace { \mathbb { E } _ { \mathtt { P } ( \boldsymbol { \theta } | \mathcal { D } ) } \big [ \mathcal { H } \big [ \mathtt { P } ( \boldsymbol { y } | \boldsymbol { x } ; \boldsymbol { \theta } ) \big ] \big ] } _ { \mathrm { E x p e c t e d ~ D a t a ~ U n c e r t a i n t y } } } } \\ & { } & { \approx \mathcal { H } \big [ \frac { 1 } { M } \sum _ { m = 1 } ^ { M } \mathtt { P } ( \boldsymbol { y } | \boldsymbol { x } ; \boldsymbol { \theta } ^ { ( m ) } ) \big ] - \frac { 1 } { M } \sum _ { m = 1 } ^ { M } \mathcal { H } \big [ \mathtt { P } ( \boldsymbol { y } | \boldsymbol { x } ; \boldsymbol { \theta } ^ { ( m ) } ) \big ] . } \end{array}$$
This is expressed as the difference between the entropy of the predictive posterior, a measure of total uncertainty, and the expected entropy of each model in the ensemble, a measure of expected data uncertainty. Their difference is a measure of ensemble diversity and estimates knowledge uncertainty.
Unfortunately, when considering ensembles of probabilistic regression models $\{ \mathsf { p } ( \boldsymbol { y } | \boldsymbol { x } ; \boldsymbol { \theta } ^ { ( m ) } ) \} _ { m = 1 } ^ { M }$ over continuous-valued target $y \in \mathbb { R }$ , it is no longer possible to obtain tractable estimates of the (differential) entropy of the predictive posterior, and, by extension, mutual information. In this cases uncertainty estimates can instead derived via the law of total variation:
$$\underbrace { \mathbb { V } _ { \mathtt { p } ( y | x , \mathcal { D } ) } [ y ] } _ { \mathrm { T o t a l ~ U n c e r t a i n t y } } = \underbrace { \mathbb { V } _ { \mathtt { p } ( \theta | \mathcal { D } ) } \left[ \mathbb { E } _ { \mathtt { p } ( y | x , \theta ) } [ y ] \right] } _ { \mathrm { K n o w l e d g e ~ U n c e r t a i n t y } } + \underbrace { \mathbb { E } _ { \mathtt { p } ( \theta | \mathcal { D } ) } \left[ \mathbb { V } _ { \mathtt { p } ( y | x , \theta ) } [ y ] \right] } _ { \mathrm { E x p e c t e d ~ D a t a ~ U n c e r t a i n t y } } .$$
This is conceptually similar to the decomposition (4) obtained via mutual information. For an ensemble of probabilistic regression models which parameterize the normal distribution, and where each models yields a mean and standard-deviation, the total variance can be computed as follows:
$$\underbrace { \mathbb { V } _ { \mathrm { p } ( y | \mathbf { x } , \mathcal { D } ) } [ y ] } _ { \mathrm { T r a t a l } \Pi _ { \mathrm { m e a r i a n t y } } } \approx \frac { 1 } { M } \sum _ { m = 1 } ^ { M } \Big [ \Big ( \sum _ { m = 1 } ^ { M } \frac { \mu _ { m } } { M } \Big ) - \mu _ { m } \Big ] ^ { 2 } + \quad \frac { 1 } { M } \sum _ { m = 1 } ^ { M } \sigma _ { m } ^ { 2 } \quad , \ \{ \mu _ { m } , \sigma _ { m } \} = f ( \mathbf { x } ; \theta ^ { ( m ) } ) .$$
However, while these measures are tractable, they are based on only first and second moments, and may therefore miss high-order details in the uncertainty. They are also not scale-invariant, which can cause issues is the scale of prediction on in-domain and out-of-domain data is very different.
Gradient boosting is a powerful machine learning technique especially useful on tasks containing heterogeneous features. It iteratively combines weak models, such as decision trees, to obtain more accurate predictions. Formally, given a dataset $\mathcal { D }$ and a loss function $L : \mathbb { R } ^ { 2 } \to \mathbb { R }$ , the gradient boosting algorithm (Friedman, 2001) iteratively constructs a model $F : X \mathbb { R }$ to minimize the empirical risk $\mathcal { L } ( F | \mathcal { D } ) = \mathbb { E } _ { \mathcal { D } } [ L ( F ( \pmb { x } ) , y ) ]$ . At each iteration $t$ the model is updated as:
$${ \cal F } ^ { ( t ) } ( { \pmb x } ) = { \cal F } ^ { ( t - 1 ) } ( { \pmb x } ) + \epsilon h ^ { ( t ) } ( { \pmb x } ) ,$$
where $F ^ { ( t - 1 ) }$ is a model constructed at the previous iteration, $h ^ { ( t ) } ( { \pmb x } ) \in \mathcal { H }$ is a weak learner chosen from some family of functionds $\mathcal { H }$ , and $\epsilon$ is learning rate. The weak learner $h ^ { ( t ) }$ is usually chosen to approximate the negative gradient $\begin{array} { r } { - g ^ { ( t ) } ( \pmb { x } , y ) : = - \frac { \partial L ( y , s ) } { \partial s } \big | _ { s = F ^ { ( t - 1 ) } ( \pmb { x } ) } } \end{array}$ :
$$\boldsymbol { h } ^ { ( t ) } = \underset { \boldsymbol { h } \in \mathcal { H } } { \arg \operatorname* { m i n } } \mathbb { E } _ { \mathcal { D } } \big [ \big ( - \boldsymbol { g } ^ { ( t ) } ( \boldsymbol { x } , \boldsymbol { y } ) - \boldsymbol { h } ( \boldsymbol { x } ) \big ) ^ { 2 } \big ] .$$
A weak learner $h ^ { ( t ) }$ is associated with parameters $\phi ^ { ( t ) } \in \mathbb { R } ^ { d }$ . We write $h ^ { ( t ) } ( { \pmb x } , \phi ^ { ( t ) } )$ to reflect this dependence. The set of weak learners $\mathcal { H }$ often consists of shallow decision trees, which are models that recursively partition the feature space into disjoint regions called leaves. Each leaf $R _ { j }$ of the tree iwrite estimated response , so the decision tre $y$ in the correspondings a linear function of n. We c. The fin $\begin{array} { r } { h ( \pmb { x } , \phi ^ { ( t ) } ) = \sum _ { j = 1 } ^ { d } \phi _ { j } ^ { ( t ) } \mathbf { 1 } _ { \{ \pmb { x } \in R _ { j } \} } } \end{array}$ $\phi ^ { ( t ) }$ $F$ $\pmb \theta$
For classification tasks, a model yields estimates data uncertainty if it is trained via negative loglikelihood and provides a distribution over class labels. However, classic GBDT regression models yield point predictions, and there has been little research devoted to estimating predictive uncertainty. Recently, this issue was addressed by Duan et al. (2020) via an algorithm called NGBoost (Natural Gradient Boosting), which allows estimating data uncertainty. NGBoost simultaneously estimates the parameters of a conditional distribution $\mathtt { p } ( y | \pmb { x } , \pmb { \theta } )$ over the target $y$ given the features $_ { \textbf { \em x } }$ , by optimizing a proper scoring rule. Typically, a normal distribution over $y$ is assumed and negative log-likelihood is taken as a scoring rule. Formally, given an input $_ { \textbf { \em x } }$ , the model $F$ predicts two parameters of normal distribution - the mean $\mu$ and the logarithm of the standard deviation $\log \sigma$ The loss function is the expected negative log-likelihood:2
$$\mathrm { p } ( \boldsymbol { y } | \mathbf { \boldsymbol { x } } , \pmb { \theta } ^ { ( t ) } ) = \mathcal { N } ( \boldsymbol { y } | \mu ^ { ( t ) } , \boldsymbol { \sigma } ^ { ( t ) } ) , \quad \{ \mu ^ { ( t ) } , \log \sigma ^ { ( t ) } \} = F ^ { ( t ) } ( \pmb { x } ) .$$
$$\mathcal { L } ( \pmb { \theta } | \mathcal { D } ) = \mathbb { E } _ { \mathcal { D } } [ - \log \mathbb { p } ( \pmb { y } | \pmb { x } , \pmb { \theta } ) ] = - \frac { 1 } { N } \sum _ { i = 1 } ^ { N } \log \mathbb { p } ( \pmb { y } ^ { ( i ) } | \pmb { x } ^ { ( i ) } , \pmb { \theta } ) .$$
Note that $\pmb \theta$ denotes the concatenation of two parameter vectors used to predict $\mu$ and $\log \sigma$ .
# 3 GENERATING ENSEMBLES OF GDBT MODELS
As discussed in Section 2, knowledge uncertainty can be estimated by considering an ensemble of models $\{ \mathsf { p } ( \boldsymbol { y } | \boldsymbol { x } ; \boldsymbol { \theta } ^ { ( m ) } ) \} _ { m = 1 } ^ { M }$ sampled from the posterior ${ \tt p } ( \pmb \theta | \mathcal { D } )$ . The level of diversity or “disagreement” between the models is an estimate of knowledge uncertainty. In this section, we consider three approaches to generating an ensemble of GBDT models. We emphasize that this section discusses ensembles of GBDT models, where a each GBDT model is itself an ensemble of trees.
SGB ensembles One way to generate an ensemble is to consider several independent models generated via Stochastic Gradient Boosting (SGB). Stochasticity is added to GBDT models via random subsampling of the data at every iteration (Friedman, 2002). Specifically, at each iteration of (8) we select a subset of training objects $\mathcal { D } ^ { \prime }$ (via bootstrap or uniformly without replacement), which is smaller than the original training dataset $\mathcal { D }$ , and use $\mathcal { D } ^ { \prime }$ to fit the next tree instead of $\mathcal { D }$ . The fraction of chosen objects is called sample rate. This implicitly injects noise into the learning process, effectively inducing a distribution ${ \mathfrak { q } } ( \theta )$ over such models. Thus, an SGB ensemble is an ensemble of independent models $\{ \pmb { \theta } ^ { ( m ) } \} _ { m = 1 } ^ { M }$ built according to SGB with different random seeds for subsampling data. Unfortunately, there are no guarantees on how well the distribution ${ \mathfrak { q } } ( \theta )$ estimates the true posterior $\mathtt { p } ( \pmb { \theta } | \mathcal { D } )$ .
SGLB ensembles Remarkably, there is a way to sample GBDT models from the true posterior $\mathtt { p } ( \pmb { \theta } | \mathcal { D } )$ via a recently proposed Stochastic Gradient Langevin Boosting (SGLB) algorithm (Ustimenko $\&$ Prokhorenkova, 2020). SGLB combines gradient boosting with stochastic gradient Langevin dynamics (Raginsky et al., 2017) in order to achieve convergence to the global optimum even for non-convex loss functions. The algorithm has two differences compared with SGB. First, Gaussian noise is explicitly injected into the gradients, so (8) is replaced by:
$$h ^ { ( t ) } = \underset { h \in \mathcal { H } } { \mathrm { a r g } \mathrm { m i n } } \mathbb { E } _ { \mathcal { D } } \left[ \left( - g ^ { ( t ) } ( \pmb { x } , y ) - h ( \pmb { x } , \phi ) + \nu \right) ^ { 2 } \right] , \nu \sim \mathcal { N } \left( 0 , \frac { 2 } { \beta \epsilon } I _ { | \mathcal { D } | } \right) ,$$
where $\beta$ is the inverse diffusion temperature and $I _ { | \mathcal { D } | }$ is an identity matrix. This random noise $\nu$ helps to explore the solution space in order to find the global optimum and the diffusion temperature controls the level of exploration. Second, the update (7) is modified as:
$$F ^ { ( t ) } ( { \pmb x } ) = ( 1 - \gamma \epsilon ) F ^ { ( t - 1 ) } ( { \pmb x } ) + \epsilon h ^ { ( t ) } ( { \pmb x } , { \phi } ^ { ( t ) } ) ,$$
 Figure 1: Virtual ensemble
where $\gamma$ is regularization parameter. If the number of all possible trees is finite (a natural assumption given that the training dataset is finite), then the SGLB parameters ${ \pmb \theta } ^ { ( t ) }$ at each iteration form a Markov chain that weakly converges to the stationary distribution, also called the invariant measure:
$$p _ { \beta } ^ { * } ( \pmb { \theta } ) \propto \exp ( - \beta \mathcal { L } ( \pmb { \theta } | \mathcal { D } ) - \beta \gamma \| \Gamma \pmb { \theta } \| _ { 2 } ^ { 2 } ) ,$$
where $\Gamma = \Gamma ^ { T } > 0$ is an implicitly defined regularization matrix which depends on a particular tree construction algorithm (Ustimenko & Prokhorenkova, 2020).
While Ustimenko & Prokhorenkova (2020) used the weak convergence to (13) to prove the global convergence, we apply this to enable sampling from the true posterior. For this purpose, we set $\beta = | \mathcal { D } |$ and $\begin{array} { r } { \gamma = \frac { \hat { \mathrm { ~ T ~ } } } { 2 \left| \mathcal { D } \right| } } \end{array}$ . For the negative log-likelihood loss function (10) the invariant measure (13) can be expressed as:
$$p _ { \beta } ^ { * } ( \pmb { \theta } ) \propto \exp \left( \log \mathbb { p } ( \mathcal { D } | \pmb { \theta } ) - \frac { 1 } { 2 } \| \Gamma \pmb { \theta } \| _ { 2 } ^ { 2 } \right) \propto \mathrm { p } ( \mathcal { D } | \pmb { \theta } ) \mathrm { p } ( \pmb { \theta } ) ,$$
which is proportional to the true posterior distribution ${ \tt p } ( \pmb \theta | \mathcal { D } )$ under Gaussian prior $\mathsf { p } ( \theta ) = \mathcal { N } ( 0 , \Gamma )$ . Thus, an SGLB ensemble is an ensemble of independent models $\{ \pmb { \theta } ^ { ( m ) } \} _ { m = 1 } ^ { M }$ generated according to the SGLB algorithm using different random seeds. In this case, asymptotically, models are sampled from the true posterior ${ \tt p } ( \pmb \theta | \mathcal { D } )$ .
Virtual SGLB ensembles While SGB and SGLB yield ensembles of independent models, their time and space complexity is $M$ times larger than that of a single model, which is a significant overhead. Consequently, generating an ensemble requires either significantly increasing complexity or sacrificing the quality by reducing the number of training iterations. To address this, we introduce the concept of a virtual ensemble that enables generating an ensemble using only one model. This is possible since a GBDT model is itself an ensemble of trees. However, in contrast to random forests formed by independent trees (Shaker & Hüllermeier, 2020), the sequential nature of GBDT models implies that all trees are dependent and individual trees cannot be considered as separate models. Hence, we use “truncated” sub-models of a single GBDT model as elements of an ensemble, as illustrated in Figure 1. Notably, a virtual ensemble can be obtained using any already constructed GBDT model. Below we formally describe this procedure applied to SGLB models since in this case we can guarantee asymptotically sampling from the true posterior ${ \tt p } ( \pmb \theta | \mathcal { D } )$ .
Each “truncated” model is described by the vector of parameters $\pmb \theta ^ { ( t ) }$ . As the parameters ${ \pmb \theta } ^ { ( t ) }$ at each iteration of the SGLB algorithm form a Markov chain that weakly convergences to the stationary distribution (14), we can consider using them as an ensemble of models. However, unlike parameters taken from different SGLB trajectories, these will have a high degree of correlation, which adversely affects the ensemble’s quality. This problem can be overcome by retaining only every $K$ -th set of parameters. Formally, fix $K \geq 1$ and consider a set of models $\begin{array} { r } { \Theta _ { T , K } = \{ \pmb { \theta } ^ { ( K t ) } , \left[ \frac { T } { 2 K } \right] \leq t \leq \left[ \frac { T } { K } \right] \} } \end{array}$ i.e., we add to $\Theta _ { T , K }$ every $K$ -th model obtained while constructing one SGLB model using $T$ iterations of gradient boosting. Choosing larger values of $K$ allows us to reduce the correlation between samples from the SGLB Markov chain. Furthermore, we do not include to the ensemble the models $\bar { \pmb { \theta } ( t ) }$ with $t < T / 2$ as (14) holds only asymptotically. The set of $\begin{array} { r } { M \ : = \ : \left[ \frac { T } { 2 K } \right] } \end{array}$ models $\Theta _ { T , K }$ is called a virtual ensemble. Note that virtual ensembles behave similarly to true ensembles in the limit (for large $K$ and $T$ ).
Importantly, we can compute the prediction of $\Theta _ { T , K }$ with the same computation time as one ${ \pmb \theta } ^ { ( T ) }$ Indeed, when computing the prediction of one model, we have to sum up the predictions made by individual trees. To get the virtual ensemble, we only have to store the partial sums. For SGLB, we also have to account for regularization (12). Formally, according to (12), for SGLB we have $\begin{array} { r } { \pmb { \theta } ^ { ( T ) } = \sum _ { i = 1 } ^ { T } \epsilon ( 1 - \gamma \epsilon ) ^ { T - i } \pmb { \phi } ^ { ( i ) } } \end{array}$ , where $( 1 - \gamma \epsilon ) ^ { T - i }$ appears due to shrinkage. While computing ${ \pmb \theta } ^ { ( T ) }$ i=1 we store the partial sums $\begin{array} { r } { \pmb { \theta } _ { \leq t } ^ { ( T ) } = \sum _ { i = 1 } ^ { t } \epsilon ( 1 - \gamma \epsilon ) ^ { T - i } \pmb { \phi } ^ { ( i ) } } \end{array}$ . Then, any model $\pmb \theta ^ { ( t ) }$ from $\Theta _ { T , K }$ can easily be obtained from the stored values:
 Figure 2: Uncertainty for synthetic regression dataset with two categorical features. Inside the heart (white region on the first figure) there are no training examples.
$$\pmb \theta ^ { ( t ) } = \sum _ { i = 1 } ^ { t } \epsilon ( 1 - \gamma \epsilon ) ^ { t - i } \pmb \phi ^ { ( i ) } = ( 1 - \gamma \epsilon ) ^ { t - T } \pmb \theta _ { \leq t } ^ { ( T ) } .$$
# 4 ANALYSIS ON SYNTHETIC DATA
In this section, we analyze how ensemble algorithms discussed in Section 3 perform on synthetic data. The aim is to understand the attributes of ensembles of GBDT models for estimating data and knowledge uncertainty in a controllable setting.
GBDT models are usually applied to tabular data, where features are often categorical. Hence, we first generate a dataset with each example described by two categorical features $x _ { 1 } , x _ { 2 }$ with 9 values each, resulting in 81 possible combinations. The target depends on the features as $y = a ( x _ { 1 } , x _ { 2 } ) + \varepsilon ( x _ { 1 } , \stackrel { \_ } { x } _ { 2 } )$ , where $\varepsilon ( x _ { 1 } , x _ { 2 } ) \sim \mathcal { N } ( 0 , b ( x _ { 1 } , x _ { 2 } ) )$ and $a ( \overset { \cdot } { x _ { 1 } } , x _ { 2 } ) , b ( \overset { \cdot } { x } _ { 1 } , \overset { \cdot } { x } _ { 2 } )$ are some deterministic functions. The values for $a ( x _ { 1 } , x _ { 2 } )$ are randomly generated according to the uniform distribution over $[ 0 , 1 ]$ . The values for $b ( x _ { 1 } , x _ { 2 } )$ are shown on Figure 2(a). We generate a heartshaped dataset with this distribution: inside the heart (white region on Figure 2(a)) there are no training points, for the other cells we have 1000 examples per cell.
We train an ensemble of 10 SGLB models (each model consists of 1000 trees) and observe the following effects. First, Figure 2(b) shows the total uncertainty estimated with SGLB ensemble and we see that the models correctly capture this uncertainty in all cells containing training examples. At the same time, arbitrary values can be predicted inside the heart, as no training data constrain the models’ behavior there. Second, Figure 2(c) shows that estimates of knowledge uncertainty allow us to detect regions that are out-of-domain and are not covered by the training data. Notably, the separation is perfect, as there is no trace of the original heart border.
To further analyze ensembles of GBDT models, we apply them to a two-dimensional classification task with continuous-valued features. We consider a 3-class spiral dataset shown on Figure 3(a); and this setting is much harder for gradient boosted trees.3 Figure 3(b) shows the total uncertainty estimated with SGLB ensemble, while Figure 3(c) demonstrates knowledge uncertainty. We observe several effects. First, total uncertainty correctly detects class boundaries and ‘sectors’ of input space outside the training dataset. Second, looking at these ‘sectors’ of high uncertainty, we can better understand how GBDT ensembles work: as decision trees are discriminative functions (Bishop, 2006), if features have values outside the training domain, then the prediction is the same as for the “closest” elements in the dataset. In other words, the models’ behavior on the boundary of the dataset is further extended to the outer regions. Third, estimates of knowledge uncertainty allow discrimination between out-of-domain regions and class boundaries. However, we still can see traces of the class boundaries in Figure 3(c). A possible reason is the fact that for real-valued features, near the class borders, the splitting values may vary across all models in the ensemble, resulting in nonzero estimates of knowledge uncertainty due to decision-boundary ‘jitter’.
 Figure 3: Uncertainty for synthetic classification dataset
 Figure 4: Comparison of SGLB and vSGLB knowledge uncertainty estimates
On both “heart” and “spiral” datasets, we observed that the absolute values of knowledge uncertainty are much smaller than of data uncertainty and therefore contribute very little to total uncertainty. Thus, we expect that while knowledge uncertainty is especially useful for detecting anomalous inputs, the proposed approaches will contribute little to error detection on top of estimates of data uncertainty provided by single models.
Finally, on Figure 4, we compare the performance of ‘true’ SGLB ensembles with the virtual SGLB ensembles (vSGBL) on both the “heart” and “spiral” datasets. The virtual ensemble is ten times cheaper to train and infer, but the ensemble members are strongly correlated. We observe that on the “heart” dataset, vSGLB perfectly detects regions not covered by training data. However, the absolute values of knowledge uncertainty are much smaller than for SGLB, which can be explained by the correlations. The “spiral” dataset is more challenging for both SGLB and vSGLB. While having qualitatively similar behavior, virtual ensembles struggle to detect out-of-domain regions and separate them from class boundaries. In all cases, the absolute values of knowledge uncertainty are far lower than for ‘true’ SGLB ensembles. This shows that while vSGLB yields very cheap estimates of knowledge uncertainty by exploiting the ‘ensemble of trees’ structure of GBDT models, the quality of these estimates is inferior to ensembles of independent models.
# 5 EXPERIMENTS ON CLASSIFICATION AND REGRESSION DATASETS
In this section, we evaluate the performance of ensembles of GBDT models on a range of classification and regression tasks, focusing on their ability to detect errors and out-of-domain inputs.
Experimental setup Our implementation of all GBDT models is based on the CatBoost library that is known to achieve state-of-the-art results in a variety of tasks (Prokhorenkova et al., 2018). Classification models yield a probability distribution over binary class labels, while regression models yield the mean and variance of the normal distribution, as discussed in Section 2. All models are trained by optimizing the negative log-likelihood.4 We consider SGB and SGBL single models as the baselines and examine all ensemble methods defined in Section 3. Ensembles of SGB and SGLB models consist of 10 independent (with different seeds) models with 1000 trees each. The virtual ensemble vSGLB is obtained from one model with 1000 trees, where each 50th model from the interval [501, 1000] is added to the ensemble. Thus, vSGLB has the same computational and space complexity as just one SGB or SGLB model. Hyper-parameters are tuned by grid search, for details see Appendix A.2.
We compare the algorithms on several classification and regression tasks (Gal & Ghahramani, 2016; Prokhorenkova et al., 2018), the description of which is available in Appendix A.3.
While not being the focus of the current research, Random Forest (RF) models are naturally suitable for ensemble approaches. Hence, we conduct additional experiments and analyze the performance of ensemble approaches applied to RF models in Appendix C.
Detection of errors and anomalous inputs We analyze whether measures of total and knowledge uncertainty can be used to detect errors and out-of-domain inputs. Error detection can be evaluated via the Prediction-Rejection Ratio (PRR) (Malinin, 2019; Malinin et al., 2020), which measures how well uncertainty estimates correlate with errors and rank-order them. The best value is 100, random is 0. Out-of-domain (OOD) detection is assessed via area under the ROC curve (AUCROC) (Hendrycks & Gimpel, 2016). For OOD detection, we need an OOD test-set. However, obtaining ‘real’ OOD examples for the datasets considered in this work is challenging, so we instead create synthetic OOD data as follows. For each dataset, we take its test set as the in-domain examples and sample an OOD dataset of the same size from the Year MSD dataset to get out-of-domain (OOD) data. The only exceptions are KDD datasets (Appetency, Churn, Upselling) and Year MSD, for which we sample OOD data from the Relative location of CT slices on axial axis Data Set (Graf et al., 2011). All numerical features in OOD data are normalized by the per-column mean and variance obtained on the in-domain training data. For categorical features, we sample a random category uniformly at random from the set of all feature’s categories. Total and knowledge uncertainty are estimated via entropy of the predictive posterior (3) and mutual information (4) for classification models and via total variance and variance of the mean (5) for regression ones.
Test errors can occur due to both noise and lack of knowledge, so we expect that ranking elements by total uncertainty would give better values of PRR. Table 1 shows that measures of total uncertainty consistently yield better PPR results across all datasets. This is consistent with results obtained for ensembles of neural network models (Lakshminarayanan et al., 2017; Malinin, 2019; Malinin & Gales, 2019; Malinin et al., 2020). However, ensembles do not outperform single models. We believe this occurs for two reasons. First, due to the additive nature of boosting, GDBT models are already ensembles. Second, as we have discussed in Section 4, for GBDT models, estimates of knowledge uncertainty obtained via the approaches considered here contribute little to estimates of total uncertainty.
In contrast, Table 1 shows that measures of knowledge uncertainty yield superior OOD detection performance compared to total uncertainty in terms of AUC-ROC, which is consistent with results for non-GBDT models (Malinin, 2019; Malinin & Gales, 2019; Malinin et al., 2020).5 The results also show that SGB and SGLB ensembles performed almost equally well. At the same time, virtual ensembling (vSGLB) performed consistently worse (with one exception) than SGB/SGLB ensembles, which is explained by the presence of strong correlations between the models in a virtual ensemble. However, in classification tasks, estimates of knowledge uncertainty provided by vSGLB nevertheless outperform uncertainty estimates derived from single SGB and SGLB models. This shows that useful measures of knowledge uncertainty can be derived from a single SGLB model by interpreting it as a virtual ensemble at no additional computational or memory cost. For vSGLB, the difference between classification and regression tasks can be explained by the presence or absence of categorical features. In our preliminary experiments on synthetic data, we noticed that categorical features may have a noticeable effect on the diversity of vSGLB models, and our classification datasets contain categorical features.
# 6 CONCLUSION
This work examined principled, ensemble-based uncertainty-estimation for GBDT models. Two main approaches to generating ensembles of GDBT models, where each model is itself an ensemble of trees, were considered — Stochastic Gradient Boosting (SGB) and Stochastic Gradient Langevin Boosting (SGLB). Based on SGLB, we propose constructing a virtual ensemble (vSGLB) by exploiting the ‘ensemble-of-trees’ nature of GBDT models. Properties of the estimates of total, data, and knowledge uncertainty derived from these ensembles were first analyzed on synthetic data. It was shown that the proposed approach can successfully detect anomalous inputs and is especially successful on tabular data. On continuous data, detecting knowledge uncertainty is still possible, but it becomes harder to differentiate it with data uncertainty due to decision-boundary ‘jitter’. Further experiments on a wide range of classification and regression datasets showed that while ensembles of GDBT models do not offer much advantage in terms of error detection, as each model is already an ensemble of trees, they do yield useful measures of knowledge uncertainty, which enables outof-domain detection in both regression and classification tasks. Notably, measures of knowledge uncertainty, which can only be obtained via ensembles, achieve far better OOD detection performance than measures of total uncertainty. It is also shown that while there is little practical difference between SGB and SGLB ensembles, vSGLB performs noticeably worse. However, for classification tasks containing categorical features, vSGLB still yields useful measures of knowledge uncertainty at the computational time and space complexity of a single SGLB model. Thus, vSGLB allows us to derive the benefits of an ensemble at no additional computational and memory cost.
Table 1: Detection of errors and OOD examples for regression and classification tasks
<table><tr><td rowspan="2">Dataset</td><td rowspan="2"></td><td colspan="2">Single SGB</td><td colspan="3">Ensemble</td><td colspan="2">Single</td><td colspan="3">Ensemble</td></tr><tr><td></td><td>SGLB</td><td>SGB Classification % PRR (↑)</td><td>SGLB</td><td>vSGLB</td><td>SGB</td><td>SGLB Clasification % AUC-ROC (↑)</td><td>SGB</td><td>SGLB</td><td>vSGLB</td></tr><tr><td>Adult</td><td>TU KU</td><td>72</td><td colspan="3">72 72</td><td>72</td><td colspan="3">53 50</td><td>51</td><td>51</td></tr><tr><td></td><td>TU</td><td>一 71</td><td>一 69</td><td>49 70</td><td>49 68</td><td>38 68</td><td>丨 86</td><td>一 87</td><td>89 86</td><td>89 86</td><td>85 86</td></tr><tr><td>Amazon Click</td><td>KU TU</td><td>丨 43</td><td>一 44</td><td>64 43</td><td>61 44</td><td>40 44</td><td>丨 61</td><td>一 67</td><td>88 64</td><td>74 64</td><td>67 68</td></tr><tr><td>Internet</td><td>KU TU</td><td>丨 76</td><td>一 79</td><td>22 77</td><td>22 79</td><td>11 79</td><td>1 67</td><td>1 68</td><td>91 70</td><td>92 69</td><td>90 68</td></tr><tr><td></td><td>KU TU</td><td>一 68</td><td>1 69</td><td>69 69</td><td>72 69</td><td>61 69</td><td>1 29</td><td>1 48</td><td>87 47</td><td>89 50</td><td>81 52</td></tr><tr><td>KDD-Appetency KDD-Churn</td><td>KU TU</td><td>1 47</td><td>1 45</td><td>64 48</td><td>54 46</td><td>14 46</td><td>1 81</td><td>1 57</td><td>90 82</td><td>91 75</td><td>93 60</td></tr><tr><td>KDD-Upselling</td><td>KU TU</td><td>1 56</td><td>1 56</td><td>33 57</td><td>35 57</td><td>28 56</td><td>1 53</td><td>1 51</td><td>99 62</td><td>98 60</td><td>92 47</td></tr><tr><td>Kick</td><td>KU TU KU</td><td>丨 44</td><td>1 45</td><td>45 44 34</td><td>49 44 34</td><td>33 45 20</td><td>1 45</td><td>1 37</td><td>97 52</td><td>97 58 98</td><td>78 38 89</td></tr><tr><td>Dataset</td><td></td><td colspan="5">Regression % PRR (↑)</td><td colspan="5">98 Regression % AUC-ROC (↑)</td></tr><tr><td>BostonH</td><td>TU KU</td><td>45 一</td><td>45 1</td><td>44 36</td><td>45 37</td><td>46 38</td><td>70 1</td><td>68 1</td><td>71 80</td><td>69 80</td><td>64 49</td></tr><tr><td>Concrete</td><td>TU KU</td><td>45 一</td><td>41 一</td><td>44 27</td><td>42 27</td><td>41 25</td><td>78</td><td>80 1</td><td>79 92</td><td>81 92</td><td>78 56</td></tr><tr><td>Energy</td><td>TU KU</td><td>58 1</td><td>56 1</td><td>58 36</td><td>56 31</td><td>62 54</td><td>67 1</td><td>69 1</td><td>89 100</td><td>89 100</td><td>69 32</td></tr><tr><td>Kin8nm</td><td>TU KU</td><td>59</td><td>59 一</td><td>59 18</td><td>59 19</td><td>58 35</td><td>43 一</td><td>43 1</td><td>43 45</td><td>43 45</td><td>42 45</td></tr><tr><td>Naval-p</td><td>TU KU</td><td>75 一</td><td>76 丨</td><td>82 52</td><td>82 56</td><td>81 69</td><td>99 1</td><td>99 1</td><td>100 100</td><td>100 100</td><td>99 87</td></tr><tr><td>Power-p</td><td>TU KU</td><td>30 丨</td><td>32 1</td><td>31 8</td><td>33 9</td><td>32 13</td><td>48 1</td><td>47 1</td><td>51 72</td><td>49 73</td><td>47 57</td></tr><tr><td>Protein</td><td>TU KU</td><td>49 丨</td><td>48 1</td><td>52 30</td><td>50 29</td><td>48 12</td><td>82 1</td><td>84 1</td><td>92 99</td><td>91 99</td><td>86 94</td></tr><tr><td>Wine-qu</td><td>TU KU</td><td>33 丨</td><td>32 1</td><td>33 25</td><td>32 19</td><td>32 9</td><td>60 1</td><td>56 1</td><td>60 74</td><td>56 72</td><td>56 49</td></tr><tr><td>Yacht</td><td>TU KU</td><td>89 一</td><td>88 1</td><td>88 74</td><td>88 78</td><td>88 66</td><td>57 1</td><td>57 1</td><td>58 62</td><td>58 60</td><td>55 40</td></tr><tr><td>Year</td><td>TU KU</td><td>61 一</td><td>62 1</td><td>62 30</td><td>63 30</td><td>62 25</td><td>59 1</td><td>58 1</td><td>60 67</td><td>60 57</td><td>57 52</td></tr></table>
# ACKNOWLEDGMENTS
We would like to thank Ekaterina Ermishkina and Stanislav Kirillov for implementing the proposed methods within the CatBoost library.
# REFERENCES
UCI datasets. https://github.com/yaringal/DropoutUncertaintyExps/tree/ master/UCI_Datasets.
Arsenii Ashukha, Alexander Lyzhov, Dmitry Molchanov, and Dmitry Vetrov. Pitfalls of in-domain uncertainty estimation and ensembling in deep learning. In International Conference on Learning Representations, 2020. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ BJxI5gHKDr.
Thierry Bertin-Mahieux, Daniel PW Ellis, Brian Whitman, and Paul Lamere. The million song dataset. In Proceedings of the 12th International Society for Music Information Retrieval Conference (ISMIR 2011), 2011.
Christopher M Bishop. Pattern recognition and machine learning. springer, 2006.
Christopher JC Burges. From RankNet to LambdaRank to LambdaMART: An overview. Learning, 11(23-581):81, 2010.
Rich Caruana and Alexandru Niculescu-Mizil. An empirical comparison of supervised learning algorithms. In Proceedings of the 23rd international conference on Machine learning, pp. 161– 168. ACM, 2006.
Hugh A Chipman, Edward I George, Robert E McCulloch, et al. Bart: Bayesian additive regression trees. The Annals of Applied Statistics, 4(1):266–298, 2010.
John W Coulston, Christine E Blinn, Valerie A Thomas, and Randolph H Wynne. Approximating prediction uncertainty for random forest regression models. Photogrammetric Engineering & Remote Sensing, 82(3):189–197, 2016.
Stefan Depeweg, José Miguel Hernández-Lobato, Finale Doshi-Velez, and Steffen Udluft. Decomposition of uncertainty for active learning and reliable reinforcement learning in stochastic systems. stat, 1050:11, 2017.
Tony Duan, Anand Avati, Daisy Yi Ding, Sanjay Basu, Andrew $\mathrm { ~ Y ~ N ~ g ~ }$ , and Alejandro Schuler. Ngboost: Natural gradient boosting for probabilistic prediction. Proc. 37th International Conference on Machine Learning (ICML), 2020.
Jerome H Friedman. Greedy function approximation: a gradient boosting machine. Annals of statistics, pp. 1189–1232, 2001.
Jerome H Friedman. Stochastic gradient boosting. Computational Statistics & Data Analysis, 38(4): 367–378, 2002.
Yarin Gal. Uncertainty in Deep Learning. PhD thesis, University of Cambridge, 2016.
Yarin Gal and Zoubin Ghahramani. Dropout as a Bayesian Approximation: Representing Model Uncertainty in Deep Learning. In Proc. 33rd International Conference on Machine Learning (ICML-16), 2016.
Franz Graf, Hans-Peter Kriegel, Matthias Schubert, Sebastian Pölsterl, and Alexander Cavallaro. 2d image registration in ct images using radial image descriptors. In International Conference on Medical Image Computing and Computer-Assisted Intervention, pp. 607���614. Springer, 2011.
Dan Hendrycks and Kevin Gimpel. A Baseline for Detecting Misclassified and Out-ofDistribution Examples in Neural Networks. http://arxiv.org/abs/1610.02136, 2016. arXiv:1610.02136.
Kaggle. "Don’t Get Kicked!". https://www.kaggle.com/c/DontGetKicked, 2011.
Kaggle. Amazon dataset. https://www.kaggle.com/bittlingmayer/ amazonreviews, 2017. KDD. Kdd cup 2009: Customer relationship prediction. https://www.kdd.org/kdd-cup/ view/kdd-cup-2009/Data, 2009. KDD. Kdd cup 2012 (track 2): Predict the click-through rate of ads given the query and user information. https://www.kdd.org/kdd-cup/view/kdd-cup-2012-track-2, 2012. Alex Kendall, Yarin Gal, and Roberto Cipolla. Multi-task learning using uncertainty to weigh losses for scene geometry and semantics. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 7482–7491, 2018. Andreas Kirsch, Joost van Amersfoort, and Yarin Gal. BatchBALD: Efficient and diverse batch acquisition for deep bayesian active learning. In Advances in Neural Information Processing Systems 32 (NeurIPS 2019), 2019. Ron Kohavi. Scaling up the accuracy of naive-bayes classifiers: A decision-tree hybrid. In Proceedings of the Second International Conference on Knowledge Discovery and Data Mining, 1996. B. Lakshminarayanan, A. Pritzel, and C. Blundell. Simple and Scalable Predictive Uncertainty Estimation using Deep Ensembles. In Proc. Conference on Neural Information Processing Systems (NIPS), 2017. Antonio R Linero. A review of tree-based bayesian methods. Communications for Statistical Applications and Methods, 24(6), 2017. Wesley Maddox, Timur Garipov, Pavel Izmailov, Dmitry Vetrov, and Andrew Gordon Wilson. A simple baseline for bayesian uncertainty in deep learning. arXiv preprint arXiv:1902.02476, 2019. Andrey Malinin. Uncertainty Estimation in Deep Learning with application to Spoken Language Assessment. PhD thesis, University of Cambridge, 2019. Andrey Malinin and Mark JF Gales. Reverse kl-divergence training of prior networks: Improved uncertainty and adversarial robustness. 2019. Andrey Malinin, Bruno Mlodozeniec, and Mark JF Gales. Ensemble distribution distillation. In International Conference on Learning Representations, 2020. URL https://openreview. net/forum?id $=$ BygSP6Vtvr. Yaniv Ovadia, Emily Fertig, Jie Ren, Zachary Nado, D Sculley, Sebastian Nowozin, Joshua V 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, 2019. F. Pedregosa, G. Varoquaux, A. Gramfort, V. Michel, B. Thirion, O. Grisel, M. Blondel, P. Prettenhofer, R. Weiss, V. Dubourg, J. Vanderplas, A. Passos, D. Cournapeau, M. Brucher, M. Perrot, and E. Duchesnay. Scikit-learn: Machine Learning in Python. Journal of Machine Learning Research, 12:2825–2830, 2011. Liudmila Prokhorenkova, Gleb Gusev, Aleksandr Vorobev, Anna Veronika Dorogush, and Andrey Gulin. Catboost: unbiased boosting with categorical features. In Proceedings of the 32nd International Conference on Neural Information Processing Systems (NeurIPS), pp. 6638–6648, 2018. Maxim Raginsky, Alexander Rakhlin, and Matus Telgarsky. Non-convex learning via stochastic gradient langevin dynamics: a nonasymptotic analysis. CoRR, abs/1702.03849, 2017. Matthew Richardson, Ewa Dominowska, and Robert Ragno. Predicting clicks: estimating the clickthrough rate for new ads. In Proceedings of the 16th international conference on World Wide Web, pp. 521–530. ACM, 2007. Byron P Roe, Hai-Jun Yang, Ji Zhu, Yong Liu, Ion Stancu, and Gordon McGregor. Boosted decision trees as an alternative to artificial neural networks for particle identification. Nuclear Instruments and Methods in Physics Research Section A: Accelerators, Spectrometers, Detectors and Associated Equipment, 543(2):577–584, 2005.
Mohammad Hossein Shaker and Eyke Hüllermeier. Aleatoric and epistemic uncertainty with random forests. In International Symposium on Intelligent Data Analysis, pp. 444–456. Springer, 2020.
Lewis Smith and Yarin Gal. Understanding Measures of Uncertainty for Adversarial Example Detection. In UAI, 2018.
UCI. KDD internet usage data. https://archive.ics.uci.edu/ml/datasets/ Internet $^ +$ Usage+Data, 1997.
Aleksei Ustimenko and Liudmila Prokhorenkova. SGLB: Stochastic Gradient Langevin Boosting. arXiv e-prints, art. arXiv:2001.07248, 2020.
Qiang Wu, Christopher JC Burges, Krysta M Svore, and Jianfeng Gao. Adapting boosting for information retrieval measures. Information Retrieval, 13(3):254–270, 2010.
Yanru Zhang and Ali Haghani. A gradient boosting method to improve travel time prediction. Transportation Research Part C: Emerging Technologies, 58:308–324, 2015.
A EXPERIMENTAL SETUP
# A.1 OUR IMPLEMENTATION OF DATA UNCERTAINTY
As discussed in Section 2.2 of the main text, for regression we simultaneously predict the parameters $\mu$ and $\log \sigma$ of the Normal distribution. Similarly to NGBoost, we use the natural gradients. For our loss and parameterization, the natural gradient is:
$$g ^ { ( t ) } ( \pmb { x } , y ) = \left( \mu ^ { ( t - 1 ) } - y , \frac { 1 } { 2 } - \frac { 1 } { 2 } \left( \frac { y - \mu ^ { ( t - 1 ) } } { \sigma ^ { ( t - 1 ) } } \right) ^ { 2 } \right) .$$
At each step of the gradient boosting procedure, we construct one tree predicting both components of $g ^ { ( t ) }$ , similarly to the MultiRMSE regime of CatBoost.6
Recall that for classification we optimize the logistic loss.
In Table 2, we compare our implementation with NGBoots (Duan et al., 2020) and Deep Ensembles (Lakshminarayanan et al., 2017) on regression datasets. For our implementation, we consider SGB with fixed sample rate (0.5) and perform parameter tuning as described below. The best results are highlighted.
Table 2: Comparison of our implementation with existing methods
<table><tr><td rowspan="2">Dataset</td><td colspan="3">RMSE</td><td colspan="3">NLL</td></tr><tr><td>Deep. Ens.</td><td>NGBoost</td><td>CatBoost</td><td>Deep. Ens.</td><td>NGBoost</td><td>CatBoost</td></tr><tr><td>Boston</td><td>3.28 ±1.00</td><td>2.94 ± 0.53</td><td>3.06 ± 0.68</td><td>2.41 ± 0.25</td><td>2.43 ± 0.15</td><td>2.47 ± 0.20</td></tr><tr><td>Concrete</td><td>6.03 ± 0.58</td><td>5.06 ± 0.61</td><td>5.21 ± 0.53</td><td>3.06 ± 0.18</td><td>3.04 ± 0.17</td><td>3.06 ± 0.13</td></tr><tr><td>Energy</td><td>2.09 ±0.29</td><td>0.46 ± 0.06</td><td>0.57 ± 0.06</td><td>1.38 ± 0.22</td><td>0.60 ± 0.45</td><td>1.24 ± 1.28</td></tr><tr><td>Kin8nm</td><td>0.09 ± 0.00</td><td>0.16 ± 0.00</td><td>0.14 ± 0.00</td><td>-1.20 ± 0.02</td><td>-0.49 ± 0.02</td><td>- 0.63 ± 0.02</td></tr><tr><td>Naval</td><td>0.00 ± 0.00</td><td>0.00 ± 0.00</td><td>0.00 ±0.00</td><td>-5.63 ± 0.05</td><td>-5.34 ± 0.04</td><td>-5.39 ± 0.04</td></tr><tr><td>Power</td><td>4.11 ± 0.17</td><td>3.79 ± 0.18</td><td>3.55 ± 0.27</td><td>2.79 ± 0.04</td><td>2.79 ± 0.11</td><td>2.72 ± 0.12</td></tr><tr><td>Protein</td><td>4.71 ± 0.06</td><td>4.33 ±0.03</td><td>3.92 ± 0.08</td><td>2.83 ± 0.02</td><td>2.81 ± 0.03</td><td>2.73 ± 0.07</td></tr><tr><td>Wine</td><td>0.64 ± 0.04</td><td>0.63 ± 0.04</td><td>0.63 ± 0.04</td><td>0.94 ± 0.12</td><td>0.91 ± 0.06</td><td>0.93 ± 0.08</td></tr><tr><td>Yacht</td><td>1.58 ± 0.48</td><td>0.50 ± 0.20</td><td>0.82 ± 0.40</td><td>1.18 ± 0.21</td><td>0.20 ± 0.26</td><td>0.41 ± 0.39</td></tr><tr><td>Year MSD</td><td>8.89 ± NA</td><td>8.94±NA</td><td>8.99±NA</td><td>3.35± NA</td><td>3.43±NA</td><td>3.43±NA</td></tr></table>
# A.2 PARAMETER TUNING
For all approaches, we use grid search to tune learning-rate in $\{ 0 . 0 0 1 , 0 . 0 1 , 0 . 1 \}$ , tree depth in $\{ 3 , 4 , 5 , \bar { 6 } \bar \}$ . We fix subsample to 0.5 for SGB and to 1 for SGLB. This is done to avoid joint randomization effects of SGB sampling and SGLB noise in gradients. We also set diffusion-temperature $= N$ and model-shrink-rate $\scriptstyle { \dot { \mathbf { \theta } } } = { \frac { \mathbf { \bar { 1 } } } { 2 N } }$ for SGLB.
# A.3 DATASETS
The datasets are described in Table 3. For regression, we use standard train/validation/test splits (UCI). For classification, we split the datasets into proportion 65/15/20 in train, validation, and test sets. For more details, see our GitHub repository.7
# A.4 STATISTICAL SIGNIFICANCE
For regression, we perform cross-validation to estimate statistical significance with paired $t$ -test. In the corresponding tables, we highlight the approaches that are insignificantly different from the best one (p-value $> 0 . 0 5$ ).
Table 3: Datasets description
<table><tr><td>Dataset</td><td># Examples</td><td>#Features</td></tr><tr><td colspan="3">Classification</td></tr><tr><td>Adult (Kohavi, 1996)</td><td>48842</td><td>14</td></tr><tr><td>Amazon (Kaggle,2017)</td><td>32769</td><td>9</td></tr><tr><td>Click (KDD,2012)</td><td>399482</td><td>11</td></tr><tr><td>Internet (UCI, 1997)</td><td>10108</td><td>68</td></tr><tr><td>KDD-Appetency (KDD,2009)</td><td>50000</td><td>419</td></tr><tr><td>KDD-Churn (KDD, 2009)</td><td>50000</td><td>419</td></tr><tr><td>KDD-Upselling (KDD, 2009)</td><td>50000</td><td>419</td></tr><tr><td>Kick (Kaggle,2011)</td><td>72983</td><td>43</td></tr><tr><td colspan="3">Regression</td></tr><tr><td>Boston (UCI)</td><td>506</td><td>13</td></tr><tr><td>Concrete (UCI)</td><td>1030</td><td>8</td></tr><tr><td>Energy (UCI)</td><td>768</td><td>8</td></tr><tr><td>Kin8nm (UCI)</td><td>8192</td><td>8</td></tr><tr><td>Naval (UCI)</td><td>11934</td><td>16</td></tr><tr><td></td><td></td><td></td></tr><tr><td>Power (UCI)</td><td>9568</td><td>4</td></tr><tr><td>Protein (UCI)</td><td>45730</td><td>9</td></tr><tr><td>Wine (UCI)</td><td>1599</td><td>11</td></tr><tr><td>Yacht (UCI)</td><td>308</td><td>6</td></tr><tr><td>Year MSD (Bertin-Mahieux et al.,2011)</td><td>515345</td><td>90</td></tr></table>
Table 4: NLL and RMSE/Error rate for regression and classification
<table><tr><td rowspan="2">Dataset</td><td colspan="2">Single SGB SGLB</td><td colspan="3">Ensemble SGB SGLB</td><td colspan="2">Single SGB SGLB</td><td colspan="3">Ensemble SGLB vSGLB</td></tr><tr><td></td><td>Classification NLL (↓)</td><td></td><td></td><td>vSGLB</td><td></td><td>SGB Classification % Error (↓)</td><td></td><td></td><td></td></tr><tr><td>Adult</td><td colspan="5">0.273 0.276</td><td colspan="5">12.8 12.7 12.8</td></tr><tr><td>Amazon</td><td>0.276 0.141</td><td>0.142</td><td>0.140</td><td>0.271 0.142</td><td>0.274 0.143</td><td>4.7</td><td>4.6</td><td>4.6</td><td>12.6 4.5</td><td>12.7 4.5</td></tr><tr><td>Click</td><td>0.393</td><td>0.392</td><td>0.392</td><td>0.391</td><td>0.392</td><td>15.6</td><td>15.7</td><td>15.6</td><td>15.6</td><td>15.6</td></tr><tr><td>Internet</td><td>0.224</td><td>0.218</td><td>0.221</td><td>0.217</td><td>0.218</td><td>9.9</td><td>10.0</td><td>9.7</td><td>10.0</td><td>10.0</td></tr><tr><td>Appetency</td><td>0.073</td><td>0.073</td><td>0.073</td><td>0.073</td><td>0.073</td><td>1.8</td><td>1.8</td><td>1.8</td><td>1.8</td><td>1.8</td></tr><tr><td>Churn</td><td>0.235</td><td>0.236</td><td>0.233</td><td>0.234</td><td>0.235</td><td>7.3</td><td>7.2</td><td>7.3</td><td>7.2</td><td>7.2</td></tr><tr><td>Upselling</td><td>0.168</td><td>0.168</td><td>0.168</td><td>0.168</td><td>0.168</td><td>5.0</td><td>4.9</td><td>5.0</td><td>5.0</td><td>4.9</td></tr><tr><td>Kick</td><td>0.287</td><td>0.286</td><td>0.286</td><td>0.285</td><td>0.286</td><td>9.5</td><td>9.6</td><td>9.5</td><td>9.4</td><td>9.6</td></tr><tr><td>Dataset</td><td></td><td colspan="3">Regression NLL (↓)</td><td></td><td colspan="5"></td></tr><tr><td>BostonH</td><td>2.47</td><td>2.52</td><td>2.46</td><td>2.50</td><td>2.50</td><td>3.06</td><td>Regression RMSE (↓) 3.12</td><td>3.04</td><td>3.10</td><td>3.27</td></tr><tr><td>Concrete</td><td>3.06</td><td>3.06</td><td>3.05</td><td>3.05</td><td>3.06</td><td>5.21</td><td>5.11</td><td>5.21</td><td>5.10</td><td>5.37</td></tr><tr><td>Energy</td><td>1.24</td><td>1.70</td><td>1.13</td><td>1.52</td><td>0.70</td><td>0.57</td><td>0.54</td><td>0.57</td><td>0.54</td><td>0.64</td></tr><tr><td>Kin8nm</td><td>-0.63</td><td>-0.65</td><td>-0.63</td><td>-0.65</td><td>-0.60</td><td>0.14</td><td>0.14</td><td>0.14</td><td>0.14</td><td>0.15</td></tr><tr><td>Naval-p</td><td>-5.39</td><td>-5.42</td><td>-5.61</td><td>-5.65</td><td>-5.39</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.00</td></tr><tr><td>Power-p</td><td>2.72</td><td>2.71</td><td>2.66</td><td>2.66</td><td>2.69</td><td>3.55</td><td>3.56</td><td>3.52</td><td>3.54</td><td>3.64</td></tr><tr><td>Protein</td><td>2.73</td><td>2.73</td><td>2.61</td><td>2.64</td><td>2.70</td><td>3.92</td><td>3.96</td><td>3.90</td><td>3.93</td><td>4.02</td></tr><tr><td>Wine-qu</td><td>0.93</td><td>0.99</td><td>0.92</td><td>0.98</td><td>0.96</td><td>0.63</td><td>0.65</td><td>0.63</td><td>0.65</td><td>0.66</td></tr><tr><td>Yacht</td><td>0.41</td><td>0.38</td><td>0.27</td><td>0.32</td><td>0.51</td><td>0.82</td><td>0.84</td><td>0.83</td><td>0.84</td><td>0.97</td></tr><tr><td>Year</td><td>3.43</td><td>3.43</td><td>3.41</td><td>3.40</td><td>3.42</td><td>8.99</td><td>8.96</td><td>8.97</td><td>8.94</td><td>8.98</td></tr></table>
For classification (and Year MSD), we measure statistical significance for NLL and error/RMSE on the test set. In the corresponding tables, the approaches that are insignificantly different from the best one are highlighted. For PRR and AUC-ROC (for classification and Year MSD), we highlight the best value.
# B ADDITIONAL EXPERIMENTAL RESULTS
In Table 4, we compare ensemble approaches with single models in terms of NLL and error rate for classification and in terms of NLL and RMSE for regression tasks. Results for NLL demonstrate an advantage of ensembling approaches compared to single models. However, in some cases the difference is not significant, which can be explained by the additive nature of boosting: averaging several tree ensembles gives another (larger) tree ensemble. Thus, improved NLL can result from the increased complexity of ensemble models. We can make a similar conclusion from the results for RMSE and error rate.
# C COMPARISON WITH RANDOM FOREST
Our paper specifically focuses on uncertainty estimation in Gradient Boosted Decision Trees (GBDT) models. However, some related work was done for quantifying uncertainty in random forests (Coulston et al., 2016; Shaker & Hüllermeier, 2020), which are also ensembles of decision trees. Thus, for completeness, we also analyze how ensemble approaches perform in combination with random forests.
In these experiments, we use the scikit-learn implementation of random forests (Pedregosa et al., 2011). We limit the maximum depth to 10 and keep all other parameters default. For categorical features, we use leave-one-out encoding.
Unlike GBDT, where trees are added to correct the previous model’s mistakes, random forests (RF) consist of decision trees that are independently trained on bootstrapped sub-samples of the dataset. Hence, for knowledge uncertainty we can divide RF into several independent parts, each consisting of several trees. Drawing a parallel to virtual SGLB, we call this approach vRF (virtual RF) since it allows estimating knowledge uncertainty using only one trained random forest model. In our experiments with vRF, we divide one RF model into 10 independent parts, each consisting of 100 trees. Similarly, one can also construct an ensemble of several independently trained random forest models, which is expected to be a stronger baseline. However, we expect a small difference between vRF and an ensemble of random forests, as there are, a priori, no correlations between trees both in a single model and across multiple RF models.
In Tables 5 and 6, we compare the predictive performance of random forests (both individual models and explicit ensembles of multiple models) to SGLB individual and ensemble models on classification and regression tasks. The results show that generally GBDT models outperform random forest models in terms of classification error rate and NLL. Note that we cannot calculate NLL for RF regression models as they are not naturally probabilistic (do not yield a predicted variance). As a result, they are unable to estimate data uncertainty, and therefore we can only obtain estimates of knowledge uncertainty.
Table 7 compares SGLB and RF ensembles in terms of error detection (PRR) and out-of-domain input detection (ROC-AUC). One can see that SGLB usually outperforms RF, especially for OOD detection. Notably, as we expected, for OOD detection vRF and RF give similar results. Thus, we conclude that for random forests, a virtual ensemble is a good and cheap alternative to the true one.
Table 5: Comparison with random forest: NLL and error rate for classification
<table><tr><td rowspan="3">Dataset</td><td colspan="2">Single</td><td colspan="2">Ensemble</td><td colspan="2">Single</td><td colspan="2">Ensemble</td></tr><tr><td>SGLB</td><td>RF</td><td>SGLB</td><td>RF</td><td>SGLB</td><td>RF</td><td>SGLB</td><td>RF</td></tr><tr><td colspan="4">Classification NLL (↓)</td><td colspan="4">Classification %Error ()</td></tr><tr><td>Adult</td><td>0.273</td><td>0.300</td><td>0.271</td><td>0.300</td><td>12.7</td><td>13.9</td><td>12.6</td><td>13.9</td></tr><tr><td>Amazon</td><td>0.142</td><td>0.183</td><td>0.142</td><td>0.183</td><td>4.6</td><td>5.6</td><td>4.5</td><td>5.6</td></tr><tr><td>Click</td><td>0.392</td><td>0.411</td><td>0.391</td><td>0.411</td><td>15.7</td><td>16.0</td><td>15.6</td><td>16.0</td></tr><tr><td>Internet</td><td>0.218</td><td>0.275</td><td>0.217</td><td>0.274</td><td>10.0</td><td>11.2</td><td>10.0</td><td>11.0</td></tr><tr><td>KDD-Appetency</td><td>0.073</td><td>0.083</td><td>0.073</td><td>0.083</td><td>1.8</td><td>1.8</td><td>1.8</td><td>1.8</td></tr><tr><td>KDD-Churn</td><td>0.236</td><td>0.249</td><td>0.234</td><td>0.249</td><td>7.2</td><td>7.3</td><td>7.2</td><td>7.3</td></tr><tr><td>KDD-Upselling</td><td>0.168</td><td>0.202</td><td>0.168</td><td>0.202</td><td>4.9</td><td>7.4</td><td>5.0</td><td>7.4</td></tr><tr><td>Kick</td><td>0.286</td><td>0.311</td><td>0.285</td><td>0.311</td><td>9.6</td><td>10.4</td><td>9.4</td><td>10.4</td></tr></table>
Table 6: Comparison with random forest: RMSE for regression
<table><tr><td rowspan="2">Dataset</td><td colspan="2">Single</td><td colspan="2">Ensemble</td></tr><tr><td>SGLB</td><td>RF</td><td>SGLB</td><td>RF</td></tr><tr><td>BostonH</td><td>3.12</td><td>2.98</td><td>3.10</td><td>2.98</td></tr><tr><td>Concrete</td><td>5.11</td><td>4.96</td><td>5.10</td><td>4.95</td></tr><tr><td>Energy</td><td>0.54</td><td>0.50</td><td>0.54</td><td>0.50</td></tr><tr><td>Kin8nm</td><td>0.14</td><td>0.15</td><td>0.14</td><td>0.15</td></tr><tr><td>Naval-p</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.00</td></tr><tr><td>Power-p</td><td>3.56</td><td>3.53</td><td>3.54</td><td>3.53</td></tr><tr><td>Protein</td><td>3.96</td><td>4.19</td><td>3.93</td><td>4.19</td></tr><tr><td>Wine-qu</td><td>0.65</td><td>0.58</td><td>0.65</td><td>0.58</td></tr><tr><td>Yacht</td><td>0.84</td><td>0.84</td><td>0.84</td><td>0.84</td></tr><tr><td>Year</td><td>8.96</td><td>9.43</td><td>8.94</td><td>9.43</td></tr></table>
Table 7: Comparison with random forest: detection of errors and OOD examples for regression and classification (virtual and true ensembles)
<table><tr><td colspan="2">Dataset</td><td>vSGLB</td><td>vRF</td><td>SGLB</td><td>RF</td><td>vSGLB</td><td>vRF</td><td>SGLB</td><td>RF</td></tr><tr><td colspan="2"></td><td></td><td colspan="3">Classification % PRR (↑)</td><td></td><td>Classfcation % AUC-ROC (1)</td><td></td><td></td></tr><tr><td rowspan="2">Adult</td><td>TU KU</td><td>72</td><td>70</td><td>72</td><td>70</td><td>51</td><td>58</td><td>51</td><td>58</td></tr><tr><td></td><td>38</td><td>20</td><td>49</td><td>22</td><td>85</td><td>86</td><td>89</td><td>87</td></tr><tr><td rowspan="2">Amazon</td><td>TU</td><td>68</td><td>63</td><td>68</td><td>64</td><td>86</td><td>48</td><td>86</td><td>49</td></tr><tr><td>KU</td><td>40</td><td>45</td><td>61</td><td>52</td><td>67</td><td>55</td><td>74</td><td>53</td></tr><tr><td rowspan="2">Click</td><td>TU</td><td>44</td><td>36</td><td>44</td><td>37</td><td>68</td><td>71</td><td>64</td><td>71</td></tr><tr><td>KU</td><td>11</td><td>20</td><td>22</td><td>21</td><td>90</td><td>81</td><td>92</td><td>80</td></tr><tr><td rowspan="2">Internet</td><td>TU</td><td>79</td><td>69</td><td>79</td><td>68</td><td>68</td><td>72</td><td>69</td><td>72</td></tr><tr><td>KU</td><td>61</td><td>38</td><td>72</td><td>36</td><td>81</td><td>79</td><td>89</td><td>79</td></tr><tr><td rowspan="2"> KDD-Appetency</td><td>TU</td><td>69</td><td>56</td><td>69</td><td>56</td><td>52</td><td>82</td><td>50</td><td>81</td></tr><tr><td>KU</td><td>14</td><td>34</td><td>54</td><td>34</td><td>93</td><td>97</td><td>91</td><td>98</td></tr><tr><td rowspan="2">KDD-Churn</td><td>TU</td><td>46</td><td>39</td><td>46</td><td>39</td><td>60</td><td>75</td><td>75</td><td>78</td></tr><tr><td>KU</td><td>28</td><td>13</td><td>35</td><td>9</td><td>92</td><td>93</td><td>98</td><td>94</td></tr><tr><td>KDD-Upselling</td><td>TU KU</td><td>56 33</td><td>66</td><td>57</td><td>66</td><td>47</td><td>73</td><td>60</td><td>72</td></tr><tr><td rowspan="2">Kick</td><td>TU</td><td></td><td>45</td><td>49</td><td>44</td><td>78</td><td>90</td><td>97</td><td>92</td></tr><tr><td>KU</td><td>45 20</td><td>38 27</td><td>44</td><td>38</td><td>38</td><td>64</td><td>58</td><td>63</td></tr><tr><td>Dataset</td><td></td><td>Regression % PRR (1)</td><td></td><td>34</td><td>29</td><td>89</td><td>89</td><td>98</td><td>89</td></tr><tr><td></td><td>TU</td><td></td><td></td><td></td><td></td><td>Regression % AUC-ROC (1)</td><td></td><td></td><td></td></tr><tr><td rowspan="2">BostonH</td><td>KU</td><td>46 38</td><td>1 53</td><td>45</td><td>一</td><td>64</td><td>一</td><td>69</td><td>1</td></tr><tr><td></td><td></td><td></td><td>37</td><td>55</td><td>49</td><td>75</td><td>80</td><td>76</td></tr><tr><td rowspan="2">Concrete</td><td>TU KU</td><td>41</td><td>1</td><td>42</td><td>1</td><td>78</td><td>1</td><td>81</td><td>1</td></tr><tr><td></td><td>25</td><td>43</td><td>27</td><td>42</td><td>56</td><td>80</td><td>92</td><td>80</td></tr><tr><td rowspan="2">Energy</td><td>TU KU</td><td>62</td><td>1</td><td>56</td><td>一</td><td>69</td><td>丨</td><td>89</td><td>丨</td></tr><tr><td></td><td>54</td><td>40</td><td>31</td><td>41</td><td>32</td><td>100</td><td>100</td><td>100</td></tr><tr><td rowspan="2">Kin8nm</td><td>TU KU</td><td>58</td><td>1</td><td>59</td><td>1</td><td>42</td><td>1</td><td>43</td><td>1</td></tr><tr><td></td><td>35</td><td>33</td><td>19</td><td>33</td><td>45</td><td>48</td><td>45</td><td>48</td></tr><tr><td rowspan="2">Power-p</td><td>TU KU</td><td>32</td><td>一</td><td>33</td><td></td><td>47</td><td>一</td><td>49</td><td>一</td></tr><tr><td></td><td>13</td><td>21</td><td>9</td><td>22</td><td>57</td><td>66</td><td>73</td><td>65</td></tr><tr><td rowspan="2">Protein</td><td>TU</td><td>48</td><td>一</td><td>50</td><td></td><td>86</td><td>一</td><td>91</td><td></td></tr><tr><td>KU</td><td>12</td><td>40</td><td>29</td><td>40</td><td>94</td><td>91</td><td>99</td><td>92</td></tr><tr><td rowspan="2">Wine-qu</td><td>TU</td><td>32</td><td></td><td>32</td><td></td><td>56</td><td></td><td>56</td><td></td></tr><tr><td>KU</td><td>9</td><td>35</td><td>19</td><td>32</td><td>49</td><td>74</td><td>72</td><td>74</td></tr><tr><td rowspan="2">Yacht</td><td>TU</td><td>88</td><td>一</td><td>88</td><td>丨</td><td>55</td><td>1</td><td>58</td><td>1</td></tr><tr><td>KU</td><td>66</td><td>79</td><td>78</td><td>81</td><td>40</td><td>52</td><td>60</td><td>52</td></tr><tr><td rowspan="2">Year</td><td>TU</td><td>62</td><td>1</td><td>63</td><td>1</td><td>57</td><td>丨</td><td>60</td><td>1</td></tr><tr><td>KU</td><td>25</td><td>28</td><td>30</td><td>27</td><td>52</td><td>74</td><td>57</td><td>74</td></tr></table>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267# Focal Attention for Long-Range Interactions in Vision Transformers
Jianwei Yang1 Chunyuan $\mathbf { L i } ^ { 1 }$ Pengchuan Zhang1 Xiyang Dai2 Bin Xiao2 Lu Yuan2 Jianfeng Gao1 1Microsoft Research at Redmond, 2Microsoft Cloud $^ +$ AI {jianwyan,chunyl,penzhan,xidai,bixi,luyuan,jfgao}@microsoft.com
# Abstract
Recently, Vision Transformer and its variants have shown great promise on various computer vision tasks. The ability of capturing local and global visual dependencies through self-attention is the key to its success. However, this also brings challenges due to quadratic computational overhead, especially for the high-resolution vision tasks (e.g., object detection). Many recent works have attempted to reduce the cost and improve model performance by applying either coarse-grained global attention or fine-grained local attention. However, both approaches cripple the modeling power of the original self-attention mechanism of multi-layer Transformers, leading to sub-optimal solutions. In this paper, we present focal attention, a new attention mechanism that incorporates both fine-grained local and coarse-grained global interactions. In this new mechanism, each token attends its closest surrounding tokens at fine granularity and the tokens far away at coarse granularity, and thus can capture both short- and long-range visual dependencies efficiently and effectively. With focal attention, we build a new variant of Vision Transformer models, called Focal Transformers, which achieve superior performance over the state-of-theart (SoTA) Vision Transformers on a range of public image classification and object detection benchmarks. In particular, our Focal Transformer models with a moderate size of 51.1M and a large size of $8 9 . 8 \mathbf { M }$ achieve $\mathbf { 8 3 . 6 \% }$ and $\mathbf { 8 4 . 0 \% }$ Top-1 accuracy, respectively, on ImageNet classification at $2 2 4 \times 2 2 4$ . When employed as the backbones, Focal Transformers achieve consistent and substantial improvements over the current SoTA Swin Transformers [43] across 6 different object detection methods. Our largest Focal Transformer yields 58.7/59.0 box mAPs and 50.9/51.3 mask mAPs on COCO mini-val/test-dev, and 55.4 mIoU on ADE20K for semantic segmentation, creating new SoTA on three of the most challenging computer vision tasks. Our code is available at: https://github. com/microsoft/Focal-Transformer.
# 1 Introduction
Nowadays, Transformer [57] has become a prevalent model architecture in natural language processing (NLP) [20, 6]. In the light of its success in NLP, there is an increasing effort on adapting it to computer vision (CV) [47, 50]. Since its promise firstly demonstrated in Vision Transformer (ViT) [21], we have witnessed a flourish of full-Transformer models for image classification [55, 60, 64, 43, 76, 56], object detection [8, 85, 79, 18] and semantic segmentation [58, 62]. Beyond these static image tasks, it has also been applied on various temporal understanding tasks, such as action recognition [40, 78, 10], object tracking [13, 59], scene flow estimation [38].
The self-attention mechanism is arguably the key component that differentiates Transformers from the widely used convolutional neural networks (CNNs) [37] in computer vision. At each Transformer layer, self-attention enables global content-dependent interactions among different image regions for modeling short- and long-range dependencies, respectively. Through the visualization of full selfattention results1, we indeed observe that self-attention learns to attend local surroundings (like CNNs) and the global contexts at the same time, as illustrated in Fig. 1 (Left). Nevertheless, when dealing with high-resolution vision tasks such as object detection or segmentation, an efficient implementation of a global and fine-grained self-attention becomes non-trivial due to the quadratic computational cost with respect to the number of tokens in feature maps. Recent works have alternatively exploited either a coarse-grained global self-attention [60, 64] or a fine-grained local self-attention [43, 76, 56], for the sake of reducing the computational cost. However, both approaches cripple the power of the original full self-attention i.e., the ability to simultaneously capture local and global visual dependencies.
 Figure 1: Left: Visualization of the attention maps of the three heads at the given query patch (blue) in the first layer of the DeiT-Tiny model [55]. Right: An illustrative depiction of focal attention mechanism. Three granularity levels are used to compose the attention region for the blue query.
In this paper, we present a new attention mechanism to capture both short- and long-range interactions in Transformer layers for high-resolution input images. Considering that the visual dependencies between the nearby (local) regions are usually much stronger than the dependencies between the regions that are far away, we perform the fine-grained attention only in local regions while the coarse-grained attention globally. As depicted in Fig. 1 (Right), a query token in the feature map attends its closest local surroundings at the finest granularity as itself. However, when it goes to the regions far away, it attends to summarized tokens to capture coarse-grained visual dependencies. We call this new mechanism focal attention, as each token attends the others in a focal manner. We will show in this study that focal attention allows to effectively model visual dependencies among all regions covering the whole high-resolution feature maps while introducing much less number of tokens in the computation than that in the standard self-attention mechanism.
Equipped with focal attention, a series of Focal Transformers are developed and validated via a comprehensive empirical study across three core vision tasks, including image classification, object detection and segmentation. Results show that Focal Transformers consistently outperform the SoTA Vision Transformers across various settings (i.e., in model sizes and complexities). Notably, the small Focal Transformer with 51.1M parameters achieves $8 3 . 6 \%$ top-1 accuracy on ImageNet-1K, and the base model with 89.8M parameters obtains $8 4 . 0 \%$ top-1 accuracy. In the fine-tuning experiments for object detection, Focal Transformers consistently outperform the SoTA Swin Transformers [43] across six popular object detection methods. Our largest Focal Transformer model achieves 59.0 box mAP and 51.3 mask mAP on COCO test-dev for object detection and instance segmentation, respectively, and 55.4 mIoU on ADE20K for semantic segmentation. These results demonstrate that focal attention is highly effective in modeling the global interactions in Vision Transformers.
# 2 Related work
Vision Transformers. Vision Transformer (ViT) is first introduced in [21]. It applies a standard Transformer, originally developed for NLP [57], to encode an image by analogously splitting the image into a sequence of visual tokens. It has demonstrated superior performance to CNNs such as ResNet [33] on multiple image classification benchmarks, when trained with sufficient data [21] and carefully designed data augmentation and regularization methods [55]. The results thus inspire researchers to explore the applications of ViT on various vision tasks beyond image classification, such as self-supervised learning [14, 9, 39], object detection [8, 85, 79, 18] and semantic segmentation [58, 62, 81]. There are also increasing number of studies for improving ViT via data-efficient training [55], improved patch embedding/encoding [16, 71, 31], integrating convolutional projections into transformers [64, 70], and using multi-scale architectures and efficient self-attention mechanisms for high-resolution vision tasks [60, 64, 43, 76, 15]. Recent surveys include [36, 30, 36]. This paper focuses on improving the self-attention mechanism of ViT for encoding high-resolution images.
 Figure 2: Model architecture for our Focal Transformers. As highlighted in light blue boxes, our main innovation is the proposed focal attention in each Transformer layer.
Efficient global and local self-attention. In many real-world tasks, Transformers need to cope with a large number of input tokens, such as long documents in NLP and high-resolution images in computer vision (CV). Recently, many efficient self-attention mechanisms have been proposed to deal with the quadratic computational and memory cost incurred by the standard self-attention mechanism. On one hand, a number of works in both NLP and CV resort to coarse-grained global self-attention (i.e., attending the down-sampled or summarized tokens) to capture the long-range interactions [49, 46, 60, 64, 31, 23]. Although this approach improves the model efficiency, it loses the detailed context information surrounding the query tokens. On the other hand, to make the computational cost manageable, various local fine-grained attention mechanism (i.e., attending neighboring tokens within a pre-set window size) are used for both NLP [3, 74, 1] and CV [56, 43, 76]. In this paper, we argue that both global and local attentions are important for model performance. This is also validated by some recent studies that aim to improve CNNs by incorporating ways of modeling global attentions [35, 63, 61, 68, 2, 7, 51]. The standard self-attention mechanism used by ViT can indeed learned both types of attentions, as shown in Fig. 1 (Left). But it often incurs a prohibitively high cost for high-resolution images. To the best of our knowledge, the proposed focal attention provides the first mechanism to incorporate local and global attention in a single Transformer layer 2. It can capture both short- and long-range interactions as standard self-attention but in a much more efficient and effective way, especially for high-resolution images.
# 3 Method
# 3.1 Model architecture
To accommodate high-resolution dense prediction tasks, we employ a multi-scale model architecture as in [60, 76, 43]. As shown in Fig. 2, an image $I \in \mathcal { R } ^ { H \times W \times 3 }$ is first partitioned into patches of size $4 \times 4$ , resulting in ${ \frac { H } { 4 } } \times { \frac { W } { 4 } }$ visual tokens with dimension $4 \times 4 \times 3$ . Then, we use a patch embedding layer, consisting of a convolutional layer with filter size and stride both equal to 4, to project these patches into hidden features with dimension $d$ . We then pass this spatial feature map to the four stages of Focal Transformer blocks. In each stage $i \in \{ 1 , 2 , 3 , 4 \}$ , the Focal Transformer block consists of $N _ { i }$ Focal Transformer layers. After each stage, we use a patch embedding layer to reduce the spatial size of feature map by factor 2 and increase the feature dimension by 2. For image classification tasks, we take the average of the output from the last stage and send it to a classification layer. For object detection, the feature maps from the last 3 or all 4 stages are fed to a particular object detector head, depending on the specific detection method we choose to use. The model capacity can be customized by varying the input feature dimension $d$ and the number of Focal Transformer layers.
Standard self-attention can capture both short- and long-range interactions at fine-grain, but suffers from high computational cost when it performs attention on high-resolution feature maps as noted in [76]. Take stage 1 in Fig. 2 as an example. For a feature map of size ${ \frac { H } { 4 } } \times { \frac { W } { 4 } } \times d$ , the complexity of self-attention is $\begin{array} { r } { \mathcal { O } ( ( \frac { H } { 4 } \times \frac { W } { 4 } ) ^ { 2 } d ) } \end{array}$ , resulting in an explosion of time and memory cost, considering that $\operatorname* { m i n } ( H , W )$ could be 800 or even larger for object detection. In the next section, we describe how we address this issue with the proposed focal attention mechanism.
# 3.2 Token-wise focal attention
Focal attention is proposed to make the Transformer layers suitable for encoding high-resolution input images. Instead of attending all tokens at fine-grain, we attend the fine-grain tokens only locally, but the summarized ones (i.e., the coarse-grained tokens generated by sub-window pooling, which is illustrated in Fig. 4 and will be described later) globally. As such, focal attention can cover the same amount of image regions as standard self-attention but with much less cost. In Fig. 3, we show the size of the receptive field for standard self-attention and our focal attention as a function of the number of attended tokens. For a given query position, by reducing the granularity of its surroundings based on their distance to the query, focal attention can have significantly larger receptive fields at the same cost measured by the number of visual tokens, compared to the standard self-attention mechanism.
 Figure 3: The size of receptive field (yaxis) as a function of the number of used visual tokens $\mathbf { \bar { x } }$ -axis) in regular (standard) self-attention and focal attention. When plotting the curve for focal attention, we increase the focal window size by 2 for each focal level up to the maximal window size of 8.
Theoretically, the focal attention mechanism enables global interaction with much less time and memory cost, because it attends a much smaller number of surrounding (summarized) tokens. In practice, however, extracting the surrounding tokens for each query position could incur high time cost since we need to duplicate the extraction of each token for all queries that the token surrounds. This issue had been extensively discussed in [56, 76, 43] and a common solution is to partition the input feature map into windows. Thus, in our Focal Transformers, we resort to performing focal attention at the window level. We elaborate the window-wise focal attention in the following.
# 3.2.1 Window-wise focal attention
Given a feature map of $\boldsymbol { x } \in \mathcal { R } ^ { M \times N \times d }$ with spatial size $M \times N$ , we first partition it into a grid of windows of size $s _ { p } \times s _ { p }$ . Then, we extract the surroundings for each window rather than each individual token. The proposed window-wise focal attention is illustrated in Fig. 4. To clarify, we first define three terms:
• Focal level $L$ refers to the granularity level at which we extract the tokens for focal attention. • Focal window size $s _ { w } ^ { l }$ is the size of sub-window on which the summarized tokens are formed via sub-window pooling at granularity level of $l \in \{ 1 , . . . , L \}$ . • Focal region size $s _ { r } ^ { l }$ denotes the number of sub-windows that are filled up horizontally (or vertically) in an attended region at level $l$ .
Now, we detail how window-wise focal attention works in the following two steps, sub-window pooling and attention computing.
Sub-window pooling. Consider input feature map $\boldsymbol { x } \in \mathcal { R } ^ { M \times N \times d }$ , where $M \times N$ is the spatial dimension and $d$ the feature dimension. We perform sub-window pooling for all $L$ levels. At focal level $l$ , we first split the input feature map $x$ into a grid of sub-windows with size $s _ { w } ^ { l } \times s _ { w } ^ { l }$ . Then we use a linear projection layer $f _ { p } ^ { l }$ to pool the sub-windows spatially by
$$\begin{array} { r } { x ^ { l } = f _ { p } ^ { l } ( \hat { x } ) \in \mathcal { R } ^ { \frac { M } { s _ { w } ^ { l } } \times \frac { N } { s _ { w } ^ { l } } \times d } , \quad \hat { x } = \mathrm { R e s h a p e } ( x ) \in \mathcal { R } ^ { ( \frac { M } { s _ { w } ^ { l } } \times \frac { N } { s _ { w } ^ { l } } \times d ) \times ( s _ { w } ^ { l } \times s _ { w } ^ { l } ) } . } \end{array}$$
The pooled feature maps $\{ x ^ { l } \} _ { 1 } ^ { L }$ at different levels $l$ provide rich information at both fine-grain and coarse-grain. Since we set $s _ { w } ^ { l } = 1$ for the first focal level which has the same granularity as the input
 Figure 4: An illustration of focal attention at window level. Each of the square cells represents a visual token that is either from the original feature map or a summarized token formed by sub-window pooling. Suppose we have an input feature map of size $2 0 \times 2 0$ . We first partition it into $5 \times 5$ windows of size $4 \times 4$ . Take the $4 \times 4$ blue window in the middle as the query set, we extract its surrounding tokens at three granularity levels as its keys and values. For the first level, we extract the $8 \times 8$ tokens which are closest to the blue window at the finest grain. At the second level, we expand the attention region and pool the surrounding $2 \times 2$ sub-windows to form summarized tokens, which results in $6 \times 6$ summarized tokens. At the third level, we attend a larger region covering the whole feature map and pool $4 \times 4$ sub-windows, which leads to $5 \times 5$ summarized tokens. Finally, these three levels of tokens are concatenated to compute the keys and values for the $4 \times 4 = 1 6$ tokens (queries) in the blue window.
feature map, there is no need to perform any sub-window pooling. Considering that the focal window size is usually very small (7 maximally in our settings), the number of extra parameters introduced by sub-window pooling is negligible.
Attention computing. Once we obtain the pooled feature maps $\{ x ^ { l } \} _ { 1 } ^ { L }$ at all $L$ levels, we compute the query at the first level, and key and value for all levels using three linear projection layers $f _ { q } , f _ { k }$ and $f _ { v }$ , respectively, as
$$Q = f _ { q } ( x ^ { 1 } ) , \quad K = \{ K ^ { l } \} _ { 1 } ^ { L } = f _ { k } ( \{ x ^ { 1 } , . . . , x ^ { L } \} ) , \quad V = \{ V ^ { l } \} _ { 1 } ^ { L } = f _ { v } ( \{ x ^ { 1 } , . . . , x ^ { L } \} ) .$$
To perform focal attention, we need to first extract the surrounding tokens for each query token in the feature map. As mentioned earlier, tokens inside a window partition $s _ { p } \times s _ { p }$ share the same set of surroundings. For the queries inside the $i$ -th window $Q _ { i } \in \mathcal { R } ^ { s _ { p } \times s _ { p } \times d }$ , we extract the $s _ { r } ^ { l } \times s _ { r } ^ { l }$ keys and values from $K ^ { l }$ and $V ^ { l }$ surrounding the window which the query lies in, and then gather the keys and values from all $L$ levels to obtain $\breve { K } _ { i } = \{ K _ { i } ^ { 1 } , . . . , K _ { i } ^ { L } \} \in \mathscr { R } ^ { \bar { s } \times d }$ and $V _ { i } = \{ V _ { i } ^ { 1 } , . . . , \mathbf { \bar { V } } _ { i } ^ { L } \} \in \mathcal { R } ^ { s \times d }$ , where imple $s$ is the sum of focal regions from all levels, i.e., ntation of focal attention following Fig. 1 requires $\begin{array} { r } { s = \sum _ { l = 1 } ^ { L } ( s _ { r } ^ { l } ) ^ { 2 } } \end{array}$ . Note that a canonicalverlapped regions across different levels. In our implementation, we intentionally keep them in order to capture the pyramid information for the overlapped regions. Finally, we follow [43] to include a relative position bias and compute the focal attention for $Q _ { i }$ by
$$\mathrm { A t t e n t i o n } ( Q _ { i } , K _ { i } , V _ { i } ) = \mathrm { S o f t m a x } ( \frac { Q _ { i } K _ { i } ^ { T } } { \sqrt { d } } + B ) V _ { i } ,$$
where $B = \{ B ^ { l } \} _ { 1 } ^ { L }$ is the learnable relative position bias. It consists of $L$ subsets for $L$ focal levels. Similar to [43], for the first level, we parameterize it as $B ^ { 1 } \in \mathcal { R } ^ { ( 2 s _ { p } - 1 ) \times ( 2 s _ { p } - 1 ) }$ , considering that the horizontal and vertical position ranges are both in $[ - s _ { p } + 1 , s _ { p } - 1 ]$ . For the other focal levels, considering that they have different granularity with respect to the queries, we treat all the queries inside a window equally and use $B ^ { l } \in \mathcal { R } ^ { s _ { r } ^ { l } \times s _ { r } ^ { l } }$ to represent the relative position bias between the query window and each of $s _ { r } ^ { l } \times s _ { r } ^ { l }$ summarized tokens. Since the focal attention for each window can be performed independent of the others, we can compute Eq. (3) in parallel. Once we obtain attention scores for the whole input feature map, we send them to LayerNorm and the MLP block.
<table><tr><td></td><td>Output Size</td><td>Layer Name</td><td>Focal-Tiny</td><td></td><td>Focal-Small</td><td></td><td>Focal-Base</td><td></td></tr><tr><td rowspan="2">stage 1</td><td>56×56</td><td>Patch Embedding</td><td>p1= 4;c1 = 96</td><td></td><td>p1=4;c1= 96</td><td></td><td>p1 = 4;c1 = 128</td><td></td></tr><tr><td>56×56</td><td>Transformer Block</td><td>{1,13} 三 s={7,7</td><td>×2</td><td>二 {1,13} ={7,7}</td><td>×2</td><td>{1,13} ={7,7}</td><td>×2</td></tr><tr><td rowspan="2">stage 2</td><td>28×28</td><td>Patch Embedding</td><td>P2=2;c=192</td><td></td><td>P2=2;C=192</td><td></td><td>P2=2;C= 256</td><td></td></tr><tr><td>28×28</td><td>Transformer Block</td><td>{1,13} 三 swr={7,5} 1</td><td>×2</td><td>={1,13} sw,r={7,5} 1</td><td>×2</td><td>{1,13} 二 su,r={7,5}</td><td>×2</td></tr><tr><td rowspan="2">stage 3</td><td>14 × 14</td><td>Patch Embedding</td><td>p3=2;c3=384</td><td></td><td>p3=2; c3= 384</td><td></td><td>p3=2; c3= 512</td><td></td></tr><tr><td>14 × 14</td><td>Transformer Block</td><td>={1,13} s={7,3}</td><td>×6</td><td>={1,13} ={7,3}</td><td>×18</td><td>={1,13} ={7,3}</td><td>×18</td></tr><tr><td rowspan="2">stage 4</td><td>7×7</td><td>Patch Embedding</td><td>P4=2;C4=768</td><td></td><td>P4=2;C4=768</td><td></td><td>P4= 2;C4=1024</td><td></td></tr><tr><td>7×7</td><td>Transformer Block</td><td>二 {1,7}</td><td>×2</td><td>{1,7} s 三 ={7,1}</td><td>×2</td><td>二 {1,7} su,r {7,1} 二</td><td>×2</td></tr></table>
Table 1: Model configurations for Focal Transformers. We use three configurations with different model capacities: Focal-Tiny, Focal-Small and Focal-Base.
# 3.2.2 Complexity analysis
We analyze the computational complexity for the two steps of focal attention described above. For the input feature map $\dot { \boldsymbol { x } } \in \mathcal { R } ^ { M \times N \times d }$ , we have $\begin{array} { r } { \frac { M } { s _ { w } ^ { l } } \times \frac { N } { s _ { w } ^ { l } } } \end{array}$ sub-windows at focal level l. For each sub-window, the pooling operation in Eq.1 has the complexity of $\mathcal { O } ( ( s _ { w } ^ { l } ) ^ { 2 } d )$ . Aggregating all sub-windows brings us $O ( ( M N ) d )$ . Then for all focal levels, we have the complexity of $\mathcal { O } ( L ( M N ) d )$ in total, which is independent of the sub-window size at each focal level. Regarding the attention computation in Eq. 3, the computational cost for a query window $s _ { p } \times s _ { p }$ is $\mathcal { O } ( ( s _ { p } ) ^ { 2 } \textstyle \sum _ { l } ( s _ { r } ^ { l } ) ^ { 2 } d )$ , and $\mathcal { O } ( \dot { \sum } _ { l } ( s _ { r } ^ { l } ) ^ { 2 } ( M \dot { N } ) d )$ for the whole input feature map. To sum up, the overall computational cost for focal attention is $\begin{array} { r } { \mathcal { O } ( ( L + \sum _ { l } ( s _ { r } ^ { l } ) ^ { \bar { 2 } } ) ( M N ) d ) } \end{array}$ . In an extreme case, one can set $s _ { r } ^ { \hat { L } } = 2 \times \operatorname* { m a x } ( M , N ) / s _ { w } ^ { L }$ to ensure a global receptive field for all queries (including both corner and middle queries) in this layer.
# 3.3 Model configurations
For fair comparison, we consider three network configurations for Focal Transformers, following [60, 64, 43]. Specifically, we follow the design of the Tiny, Small and Base models in Swin Transformer [43], as shown in Table 1. Our models take $2 2 4 \times 2 2 4$ images as inputs and the window partition size is set to 7 to make our models comparable to Swin Transformers. For the focal attention layer, we introduce two levels, one for fine-grained local attention and the other for coarse-grained global attention. Except for the last stage, the focal region size is set to 13 for the window partition size of 7, which means that we expand 3 tokens for each window partition. For the last stage, since the whole feature map is $7 \times 7$ , the focal region size at level 0 is set to 7, which is sufficient to cover the entire feature map. For the coarse-grained global attention, we set its focal window size the same as the window partition size 7, but gradually decrease the focal region size to get $\{ 7 , 5 , 3 , 1 \}$ for the four stages, respectively. For the patch embedding layer, the spatial reduction ratio $p _ { i }$ for the four stages are all $\{ 4 , 2 , 2 , 2 \}$ . Note that Focal-Base has a higher hidden dimension $c _ { i }$ , compared to Focal-Tiny and Focal-Small.
# 4 Experiments
# 4.1 Image classification on ImageNet-1K
We compare different methods on ImageNet-1K [19]. For fair comparison, we follow the training recipes in [55, 60]. All models are trained for 300 epochs with batch size 1024. The initial learning rate is set to $1 0 ^ { - 3 }$ with 20 epochs of linear warm-up starting from $1 0 ^ { - 5 }$ . For optimization, we use AdamW [44] as the optimizer with a cosine learning rate scheduler. The weight decay is set to 0.05 and the maximal gradient norm is clipped to 5.0. We use the same set of data augmentation and regularization strategies used in [55] after excluding random erasing [82], repeated augmentation [4, 34] and exponential moving average (EMA) [48]. The stochastic depth drop rates are set to 0.2, 0.2 and 0.3 for our tiny, small and base models, respectively. During training, we crop images randomly to $2 2 4 \times 2 2 4$ , while a center crop is used during evaluation on the validation set.
<table><tr><td>Model</td><td>#Params. FLOPs</td><td>Top-1 (%)</td></tr><tr><td>ResNet-50 [33]</td><td>25.0 4.1</td><td>76.2</td></tr><tr><td>DeiT-Small/16 [55]</td><td>22.1 4.6</td><td>79.9</td></tr><tr><td>PVT-Small [60]</td><td>24.5 3.8</td><td>79.8</td></tr><tr><td>ViL-Small [76]</td><td>24.6 5.1</td><td>82.0</td></tr><tr><td>CvT-13 [64]</td><td>20.0 4.5</td><td>81.6</td></tr><tr><td>Swin-Tiny [43]</td><td>28.3 4.5</td><td>81.2</td></tr><tr><td>Focal-Tiny (Ours)</td><td>28.9 4.9</td><td>82.2</td></tr><tr><td>ResNet-101[33]</td><td>45.0 7.9</td><td>77.4</td></tr><tr><td>PVT-Medium [60]</td><td>44.2 6.7</td><td>81.2</td></tr><tr><td>CvT-21 [64]</td><td>32.0 7.1</td><td>82.5</td></tr><tr><td>ViL-Medium [76]</td><td>39.7 9.1</td><td>83.3</td></tr><tr><td>Swin-Small [43]</td><td>49.6 8.7</td><td>83.1</td></tr><tr><td>Focal-Small (Ours)</td><td>51.1 9.4</td><td>83.6</td></tr><tr><td>ResNet-152[33]</td><td>60.0 11.0</td><td>78.3</td></tr><tr><td>ViT-Base/16 [21]</td><td>86.6 17.6</td><td>77.9</td></tr><tr><td>DeiT-Base/16 [55]</td><td>17.5</td><td>81.8</td></tr><tr><td></td><td>86.6</td><td></td></tr><tr><td>PVT-Large [60]</td><td>61.4 9.8</td><td>81.7</td></tr><tr><td>ViL-Base[76]</td><td>55.7 13.4</td><td>83.2</td></tr><tr><td>Swin-Base [43]</td><td>87.8 15.4</td><td>83.4</td></tr><tr><td>Focal-Base (Ours)</td><td>89.8</td><td>16.4 84.0</td></tr></table>
Table 2: Comparison of image classification on ImageNet-1K for different models. Except for ViT-Base/16, all other models are trained and evaluated on $2 2 4 \times 2 2 4$ resolution.
Table 3: Comparisons with CNN and Transformer baselines and SoTA methods on COCO object detection. The box mAP $( A P ^ { b } )$ and mask mAP $( A P ^ { m } )$ are reported for RetinaNet and Mask R-CNN trained with $1 \times$ schedule. More detailed comparisons with $3 \times$ schedule are in Table 4.
<table><tr><td rowspan="2">Backbone</td><td>RetinaNet</td><td>Mask R-CNN</td><td></td></tr><tr><td>APb</td><td>Apb</td><td>APm</td></tr><tr><td>ResNet-50 [33]</td><td>36.3</td><td>38.0</td><td>34.4</td></tr><tr><td>PVT-Small</td><td>40.4</td><td>40.4</td><td>37.8</td></tr><tr><td>ViL-Small [76]</td><td>41.6</td><td>41.8</td><td>38.5</td></tr><tr><td>Swin-Tiny [43]</td><td>42.0</td><td>43.7</td><td>39.8</td></tr><tr><td>Focal-Tiny (Ours)</td><td>43.7 (+1.7)</td><td>44.8 (+1.1)</td><td> 41.0 (+1.3)</td></tr><tr><td>ResNet-101[33]</td><td>38.5</td><td>40.4</td><td>36.4</td></tr><tr><td>ResNeXt101-32x4d [67]</td><td>39.9</td><td>41.9</td><td>37.5</td></tr><tr><td>PVT-Medium [60]</td><td>41.9</td><td>42.0</td><td>39.0</td></tr><tr><td>ViL-Medium [76]</td><td>42.9</td><td>43.4</td><td>39.7</td></tr><tr><td>Swin-Small [43]</td><td>45.0</td><td>46.5</td><td>42.1</td></tr><tr><td>Focal-Small (Ours)</td><td>45.6 (+0.6)</td><td>47.4 (+0.9)</td><td> 42.8 (+0.7)</td></tr><tr><td>ResNeXt101-64x4d[67] 41.0</td><td></td><td>42.8</td><td>38.4</td></tr><tr><td>PVT-Large [60]</td><td>42.6</td><td>42.9</td><td>39.5</td></tr><tr><td>ViL-Base[76]</td><td>44.3</td><td>45.1</td><td>41.0</td></tr><tr><td>Swin-Base [43]</td><td>45.0</td><td>46.9</td><td>42.3</td></tr><tr><td>Focal-Base (Ours)</td><td>46.3 (+1.3)</td><td>47.8 (+0.9)</td><td>43.2 (+0.9)</td></tr></table>
In Table 2, we summarize the results for baseline models and the state-of-the-art models on image classification task. We can see that Focal Transformers consistently outperform other methods with similar model sizes (#Params.) and computational complexities (GFLOPs). Specifically, Focal-Tiny improves over the Transformer baseline DeiT-Small/16 by $2 . 3 \%$ . Meanwhile, using the same model configuration (2-2-6-2) and a few extra parameters and computations, Focal-Tiny improves over Swin-Tiny by 1.0 point. For small and base models, Focal-Small with 51.1M parameters can reach $8 3 . 6 \%$ which is better than all the counterpart small and base models using much less parameters. By increasing the model size, Focal-Base model achieves $8 4 . 0 \%$ , surpassing all the other models with comparable parameters and FLOPs.
To compare with the large-scale models, we further build Focal-Large Transformer by increasing the hidden dimension in Focal-Base from 128 to 196 while keeping all the other hyperparameters the same. We follow the common practice to pretrain our Focal-Large Transformer on ImageNet-22K and transfer it to detection and segmentation tasks [64, 43].
# 4.2 Object detection and instance segmentation
We benchmark our models on object detection with COCO 2017 [42]. The pretrained models are used as visual backbones and then plugged into two representative pipelines, RetinaNet [41] and Mask R-CNN [32]. All models are trained on the $1 1 8 \mathrm { k }$ training images and the results are reported on 5K validation set. We use the two standard training schedules, $1 \times$ with 12 epochs and $3 \times$ with 36 epochs. For the $1 \times$ schedule, we resize image’s shorter side to 800 while keeping its longer side no more than 1,333. For the $3 \times$ schedule, we use the multi-scale training strategy by randomly resizing its shorter side to the range of [480, 800]. Considering this higher input resolution, we adaptively increase the focal sizes at four stages to (15, 13, 9, 7), to ensures that the focal attention covers more than half of the image region at the first two stages, and the whole image at the last two stages. With the focal size increased, the relative position biases are accordingly up-sampled to the corresponding sizes using bilinear interpolation. During training, we use AdamW [44] for optimization with initial learning rate $1 0 ^ { - 4 }$ and weight decay 0.05. Similarly, we use 0.2, 0.3 and 0.5 stochastic depth drop rates to regularize the training for our Tiny, Small and Base models, respectively. Since Swin Transformer does not report the results on RetinaNet, we obtain the results by ourselves using their official code with the same hyper-parameters as that of Focal Transformers.
In Table 3, we show the performance for both CNN-based models and the current Transformerbased state-of-the-art models. The bbox mAP $( A P ^ { b } )$ and mask mAP $( A P ^ { m } )$ are reported. We see that Focal Transformers outperform the CNN-based models consistently with the gap of 4.8-7.1 points. Compared with the other methods which also use multi-scale Transformer architectures,
Table 4: COCO object detection and segmentation results with RetinaNet [41] and Mask R-CNN [33]. All models are trained with $3 \times$ schedule and multi-scale inputs (MS). The numbers before and after “/” at column 2 and 3 are the model size and complexity for RetinaNet and Mask R-CNN, respectively.
<table><tr><td rowspan="2">Backbone</td><td rowspan="2">#Params (M)</td><td rowspan="2">FLOPs (G)</td><td colspan="6">RetinaNet 3x schedule + MS</td><td colspan="6">Mask R-CNN 3x schedule + MS</td></tr><tr><td>AP</td><td>AP5</td><td>AP</td><td>APs</td><td>APM</td><td>APL</td><td>AP6</td><td>AP</td><td>AP</td><td>Apm</td><td>AP</td><td>AP</td></tr><tr><td>ResNet50 [33]</td><td>37.7/44.2</td><td>239/260</td><td>39.0</td><td>58.4</td><td>41.8</td><td>22.4</td><td>42.8</td><td>51.6</td><td>41.0</td><td>61.7</td><td>44.9</td><td>37.1</td><td>58.4</td><td>40.1</td></tr><tr><td>PVT-Small[60]</td><td>34.2/44.1</td><td>226/245</td><td>42.2</td><td>62.7</td><td>45.0</td><td>26.2</td><td>45.2</td><td>57.2</td><td>43.0</td><td>65.3</td><td>46.9</td><td>39.9</td><td>62.5</td><td>42.8</td></tr><tr><td>ViL-Small [76]</td><td>35.7/45.0</td><td>252/174 42.9</td><td></td><td>63.8</td><td>45.6</td><td>27.8</td><td>46.4</td><td>56.3</td><td>43.4</td><td>64.9</td><td>47.0</td><td>39.6</td><td>62.1</td><td>42.4</td></tr><tr><td>Swin-Tiny [43]</td><td>38.5/47.8</td><td>245/264 45.0</td><td></td><td>65.9</td><td>48.4</td><td>29.7</td><td>48.9</td><td>58.1</td><td>46.0</td><td>68.1</td><td>50.3</td><td>41.6</td><td>65.1</td><td>44.9</td></tr><tr><td>Focal-Tiny (Ours)</td><td>39.4/48.8</td><td>265/291</td><td> 45.5</td><td>66.3</td><td>48.8</td><td>31.2</td><td>49.2</td><td>58.7</td><td>47.2</td><td>69.4</td><td>51.9</td><td>42.7</td><td>66.5</td><td> 45.9</td></tr><tr><td>ResNet101 [33]</td><td>56.7/63.2</td><td>315/33640.9</td><td></td><td>60.1</td><td>44.0</td><td>23.7</td><td>45.0</td><td>53.8</td><td>42.8</td><td>63.2</td><td>47.1</td><td>38.5</td><td>60.1</td><td>41.3</td></tr><tr><td>ResNeXt101-32x4d [67]</td><td>56.4/62.8</td><td>319/340</td><td>41.4</td><td>61.0</td><td>44.3</td><td>23.9</td><td>45.5</td><td>53.7</td><td>44.0</td><td>64.4</td><td>48.0</td><td>39.2</td><td>61.4</td><td>41.9</td></tr><tr><td>PVT-Medium [60]</td><td>53.9/63.9</td><td>283/302</td><td>43.2</td><td>63.8</td><td>46.1</td><td>27.3</td><td>46.3</td><td>58.9</td><td>44.2</td><td>66.0</td><td>48.2</td><td>40.5</td><td>63.1</td><td>43.5</td></tr><tr><td>ViL-Medium [76]</td><td>50.8/60.1</td><td>339/261</td><td>43.7</td><td>64.6</td><td>46.4</td><td>27.9</td><td>47.1</td><td>56.9</td><td>44.6</td><td>66.3</td><td>48.5</td><td>40.7</td><td>63.8</td><td>43.7</td></tr><tr><td>Swin-Small [43]</td><td>59.8/69.1</td><td>335/354 46.4</td><td></td><td>67.0</td><td>50.1</td><td>31.0</td><td>50.1</td><td>60.3</td><td>48.5</td><td>70.2</td><td>53.5</td><td>43.3</td><td>67.3</td><td>46.6</td></tr><tr><td>Focal-Small (Ours)</td><td>61.7/71.2</td><td>367/401</td><td>47.3</td><td>67.8</td><td>51.0</td><td>31.6</td><td>50.9</td><td>61.1</td><td>48.8</td><td>70.5</td><td>53.6</td><td>43.8</td><td>67.7</td><td>47.2</td></tr><tr><td>ResNeXt101-64x4d [67]</td><td>95.5/102</td><td>473/493</td><td>41.8</td><td>61.5</td><td>44.4</td><td>25.2</td><td>45.4</td><td>54.6</td><td>44.4</td><td>64.9</td><td>48.8</td><td>39.7</td><td>61.9</td><td>42.6</td></tr><tr><td>PVT-Large[60]</td><td>71.1/81.0</td><td>345/364 43.4</td><td></td><td>63.6</td><td>46.1</td><td>26.1</td><td>46.0</td><td>59.5</td><td>44.5</td><td>66.0</td><td>48.3</td><td>40.7</td><td>63.4</td><td>43.7</td></tr><tr><td>ViL-Base [76]</td><td>66.7/76.1</td><td>443/365 44.7</td><td></td><td>65.5</td><td>47.6</td><td>29.9</td><td>48.0</td><td>58.1</td><td>45.7</td><td>67.2</td><td>49.9</td><td>41.3</td><td>64.4</td><td>44.5</td></tr><tr><td>Swin-Base 43]</td><td>98.4/107</td><td>477/496 45.8</td><td></td><td>66.4</td><td>49.1</td><td>29.9</td><td>49.4</td><td>60.3</td><td>48.5</td><td>69.8</td><td>53.2</td><td>43.4</td><td>66.8</td><td>46.9</td></tr><tr><td>Focal-Base (Ours)</td><td>100.8/110.0 514/533 46.9</td><td></td><td></td><td>67.8</td><td>50.3</td><td>31.9</td><td>50.3</td><td>61.5</td><td>49.0</td><td>70.1</td><td>53.6</td><td>43.7</td><td>67.6</td><td>47.0</td></tr></table>
Focal Transformers show substantial gains across all settings and metrics. Particularly, Focal Transformers brings 0.7-1.7 points of mAP against the current best approach Swin Transformer [43] at comparable settings. Different from the other multi-scale Transformer models, Focal Transformers can simultaneously enable short-range fine-grain and long-range coarse-grain interactions for each visual token, and thus capture richer visual contexts at each layer for better dense predictions. To have more comprehensive comparisons, we train all models using the $3 \times$ schedule and show the detailed numbers for RetinaNet and Mask R-CNN in Table 4. As we can see, even with the $3 \times$ schedule, Focal Transformers can still achieve 0.3-1.1 gain over Swin Transformer models in comparable settings.
Comparison with large SoTA detection models. We follow Swin Transformers to use HTC [11] as the detection method in that it reported SoTA performance on COCO detection when using Swin Transformer as the backbone. For fair comparison, we also use soft-NMS [5], instaboost [24] and a multi-scale training strategy with the shorter side in range [400, 1400] and the longer side no more than 1600. We train the model using AdamW [44] with base learning rate 1e-4 and weight decay 0.1. The model is trained using the standard $3 \times$ schedule. The box and mask mAPs on COCO validation set and test-dev are reported in Table 5, where both single-scale evaluation and multi-scale evaluation results are presented. Our Focal-Large model with multi-scale test achieves 58.1 box mAP and 50.9 mask mAP on mini-val set, which is better than the reported numbers for Swin-Large in [43]. When evaluating our model on the test-dev set, it achieves 58.4 box mAP and 51.3 mask mAP, which is slightly better than Swin Transformer. Note that because our model does not include the global self-attention layer used in Swin Transformer at the last stage, it has a smaller model size and fewer FLOPs. More recently, DyHead [17] achieves new SoTA on COCO, when combined with Swin-Large. We replace the Swin-Large model with the Focal-Large model, and use the same $2 \times$ training schedule as in [17]. We report the box mAPs for both mini-val and test-dev. Focal-Large achieves 58.7 and 59.0 on mini-val and test-dev, respectively.
# 4.3 Semantic Segmentation
In addition to the instance segmentation results, we also evaluate our models on the semantic segmentation task which usually takes high-resolution input images and requires capturing long-range interactions. We benchmark our methods on ADE20K [83]. We use UperNet [65] as the segmentation method and Focal Transformers as the backbones. We train three models as Focal-Tiny, Focal-Small, Focal-Base, respectively. For all the models, we use a standard recipe that sets the input size to $5 1 2 \times 5 1 2$ and trains the model for 160k iterations with batch size 16. Table 6 shows the comparison results. We see that Focal-Tiny, Focal-Small and Focal-Base models consistently outperform Swin Transformers of the similar size in single-scale and multi-scale mIoUs.
Comparison with large SoTA semantic segmentation models. We use the pretrained Focal-Large model as the backbone for semantic segmentation. Follow the setting in [43], we use input image size $6 4 0 \times 6 4 0$ and train the model for 160k iterations with a batch size of 16. We set the initial learning to 6e-5 and use a polynomial learning rate decay. The weight decay is set to 0.01. For
<table><tr><td rowspan="2">Method</td><td rowspan="2">#Param FLOPs</td><td rowspan="2"></td><td colspan="2">mini-val</td><td colspan="2">test-dev</td></tr><tr><td>Apb</td><td>APm</td><td>Apb</td><td>Apm</td></tr><tr><td>X101-64x4d [67]</td><td>155M</td><td>1033G 52.3</td><td></td><td>46.0</td><td></td><td></td></tr><tr><td>EfficientNet-D7 [54]</td><td>77M</td><td>410G</td><td>54.4</td><td>-</td><td>55.1</td><td>=</td></tr><tr><td>GCNet*[7]</td><td>-</td><td>1041G</td><td>51.8</td><td>44.7</td><td>52.3</td><td>45.4</td></tr><tr><td>ResNeSt-200 [75]</td><td>=</td><td></td><td>52.5</td><td>=</td><td>53.3</td><td>47.1</td></tr><tr><td>Copy-paste [28]</td><td>185M</td><td>1440G 55.9</td><td></td><td>47.2</td><td>56.0</td><td>47.4</td></tr><tr><td>BoTNet-200 [51]</td><td>-</td><td></td><td>49.7</td><td></td><td>-</td><td></td></tr><tr><td>SpineNet-190 [22]</td><td>164M</td><td>1885G 52.6</td><td></td><td></td><td>52.8</td><td></td></tr><tr><td>CenterNet2 [84]</td><td>-</td><td>=</td><td>-</td><td>-</td><td>56.4</td><td>=</td></tr><tr><td>Swin-L (HTC++) [43]</td><td>284M</td><td>1470G 57.1</td><td></td><td>49.5</td><td>57.7</td><td>50.2</td></tr><tr><td>Swin-L (DyHead)[17]</td><td>213M</td><td>965G</td><td>56.2</td><td>-</td><td>-</td><td>-</td></tr><tr><td>Swin-L† (HTC++) [43]</td><td>284M</td><td></td><td>58.0</td><td>50.4</td><td>58.7</td><td>51.1</td></tr><tr><td>Swin-L† (DyHead) [17]</td><td>213M</td><td></td><td>58.4</td><td>-</td><td>58.7</td><td></td></tr><tr><td>Swin-L† (QueryInst) [25]</td><td>-</td><td></td><td>56.1</td><td>1</td><td>56.1</td><td></td></tr><tr><td>Focal-L (HTC++) (Ours)</td><td>265M</td><td>1165G</td><td>57.0</td><td>49.9</td><td>-</td><td>=</td></tr><tr><td>Focal-L (DyHead) (Ours)</td><td>229M</td><td>1081G</td><td>56.4</td><td>-</td><td>-</td><td>=</td></tr><tr><td>Focal-L† (HTC++) (Ours)</td><td>265M</td><td>-</td><td>58.1</td><td>50.9</td><td>58.4</td><td>51.3</td></tr><tr><td>Focal-L† (DyHead) (Ours)</td><td>229M</td><td>-</td><td>58.7</td><td>-</td><td>59.0</td><td>-</td></tr></table>
Table 5: Comparison with state-of-the-art methods on COCO object detection and instance segmentation. The numbers are reported on 5K val set and test-dev. Augmented HTC [11] (denoted by $\mathrm { H T C + + }$ ) and DyHead [17] are used as the detection methods. † means multi-scale evaluation.
<table><tr><td>Backbone</td><td>Method</td><td>#Param FLOPs mIoU +MS</td><td></td><td></td><td></td></tr><tr><td>ResNet-101</td><td>DANet [45]</td><td>69M</td><td>1119G</td><td>45.3</td><td></td></tr><tr><td>ResNet-101</td><td>ACNet [26]</td><td>=</td><td>=</td><td>45.9</td><td></td></tr><tr><td>ResNet-101</td><td>DNL [69]</td><td>69M</td><td>1249G</td><td>46.0</td><td></td></tr><tr><td>ResNet-101</td><td>UperNet [65]</td><td>86M</td><td>1029G</td><td>44.9</td><td></td></tr><tr><td>HRNet-w48 [53]</td><td>OCRNet [73]</td><td>71M</td><td>664G</td><td>45.7</td><td>=</td></tr><tr><td>ResNeSt-200 [75]</td><td>DLab.v3+ [12]</td><td>88M</td><td>1381G</td><td>48.4</td><td>=</td></tr><tr><td>Swin-T[43]</td><td>UperNet [65]</td><td>60M</td><td>945G</td><td>44.5</td><td>45.8</td></tr><tr><td>Swin-S [43]</td><td>UperNet [65]</td><td>81M</td><td>1038G</td><td>47.6</td><td>49.5</td></tr><tr><td>Swin-B [43]</td><td>UperNet [65]</td><td>121M</td><td>1188G</td><td>48.1</td><td>49.7</td></tr><tr><td>Twins-SVT-L[15]</td><td>UperNet [65]</td><td>133M</td><td></td><td>48.8</td><td>50.2</td></tr><tr><td>MiT-B5 [66]</td><td>SegFormer [66]</td><td>85M</td><td></td><td>51.0</td><td>51.8</td></tr><tr><td>ViT-L/16+ [21]</td><td>SETR[80]</td><td>308M</td><td></td><td>50.3</td><td>=</td></tr><tr><td>Swin-L* [43]</td><td>UperNet [65]</td><td>234M</td><td>3230G</td><td>52.1</td><td>53.5</td></tr><tr><td>ViT-L/16 [21]</td><td>Segmenter [52]</td><td>334M</td><td>=</td><td>51.8</td><td>53.6</td></tr><tr><td>Swin-L‡ [43]</td><td>K-Net [77]</td><td>=</td><td></td><td>=</td><td>54.3</td></tr><tr><td>Swin-L‡ [43]</td><td>PatchDiverse [29]</td><td>234M</td><td></td><td>53.1</td><td>54.4</td></tr><tr><td>VOLO-D5 [72]</td><td>UperNet [65]</td><td>=</td><td></td><td>-</td><td>54.3</td></tr><tr><td>Focal-T (Ours)</td><td>UperNet [65]</td><td>62M</td><td>998G</td><td>45.8</td><td>47.0</td></tr><tr><td>Focal-S (Ours)</td><td>UperNet [65]</td><td>85M</td><td>1130G</td><td>48.0</td><td>50.0</td></tr><tr><td>Focal-B (Ours)</td><td>UperNet [65]</td><td>126M</td><td>1354G</td><td>49.0</td><td>50.5</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Focal-L‡ (Ours)</td><td>UperNet [65]</td><td>240M</td><td>3376G</td><td>54.0</td><td>55.4</td></tr></table>
Table 6: Comparison with SoTA methods for semantic segmentation on ADE20K [83] val set. Single- and multi-scale evaluations are reported in the last two columns. $^ \ddag$ means ImageNet-22K is used as the pretraining dataset.
<table><tr><td>Model</td><td> W-Size FLOPs Top-1(%) APb APm</td><td></td><td></td></tr><tr><td rowspan="2">Swin-Tiny</td><td>7</td><td>4.5</td><td>81.2 43.739.8</td></tr><tr><td>14</td><td>4.9</td><td>82.1 44.0 40.5</td></tr><tr><td rowspan="2">Focal-Tiny</td><td>7</td><td>4.9</td><td>82.2 44.941.1</td></tr><tr><td>14</td><td>5.2</td><td>82.3 45.5 41.5</td></tr></table>
Table 7: Impact of different window sizes (WSize). We alter the default size 7 to 14 and observe consistent improvements for both methods.
<table><tr><td>Model</td><td colspan="3"> W-Shift Top-1(%) APb APm</td></tr><tr><td>Swin-Tiny</td><td>√</td><td>80.2 81.2</td><td>38.8 43.7</td><td>36.4 39.8</td></tr><tr><td rowspan="2">Focal-Tiny</td><td></td><td>82.2</td><td>44.8</td><td>41.0</td></tr><tr><td>√</td><td>81.9</td><td>44.9</td><td>41.1</td></tr></table>
Table 8: Impact of window shift (W-Shift) on Swin Transformer and Focal Transformer. Tiny models are used.
multi-scale evaluation, we use the same scaling ratios [0.5, 0.75, 1.0, 1.25, 1.5, 1.75] as in previous works. The results in Table 6 show that Focal-Large achieves significantly better performance than Swin-Large. In both single-scale and multi-scale evaluations, Focal-Large leads to more than 1 point mIoU improvement, creating new SoTA for semantic segmentation on ADE20K.
# 4.4 Ablation studies
We conduct a series of ablation studies to inspect the model’s capacity from different aspects. We use Focal-Tiny and the image classification and object detection tasks.
Effect of varying the window size. We have demonstrated that it is crucial to model both short- and long-range interactions. Thus, a related question is whether increasing the window size helps as it leads to a larger receptive field. Table 7 shows the performance of Swin-Tiny and Focal-Tiny with window sizes 7 and 14. Clearly, a larger window size is beneficial for both methods measured in all three metrics, and Focal-Tiny consistently outperforms Swin-Tiny in both window sizes. Comparing the second and third row, we find that Focal-Tiny outperforms Swin-Tiny even with a smaller window size $( 7 \nu . s . \ 1 4 )$ . We suspect that the gain is attributed to our focal attention’s superior capability of capturing long-range dependencies among visual tokens.
The necessity of window shift. In Swin Transformer [43], window shift is proposed to capture crosswindow interactions between two successive layers. In contrast, visual tokens in Focal Transformers can always communicate with each other across windows at both fine- and coarse-grain. Thus, it is interesting to investigate whether adding window shift to Focal Transformers can lead to any improvement. To answer the question, we remove window shift from Swin Transformer while adding it to Focal Transformers. As shown in Table 8, Swin Transformer shows a severe degradation after removing the window shift. However, adding window shift to Focal Transformer hurts classification performance. The result indicates that window shift is unnecessary for Focal Transformers. While in
 Figure 5: Ablating Focal-Tiny model by adding local, global and both interactions, respectively. Blue bars are image classification results and orange bars object detection results. This figure is better viewed in color.
<table><tr><td colspan="6">Depths Model #Params. FLOPs Top-1(%) APb Apm</td></tr><tr><td rowspan="2">2-2-2-2</td><td>Swin</td><td>21.2</td><td>3.1</td><td>78.7</td><td>38.2 35.7</td></tr><tr><td>Focal</td><td>21.7</td><td>3.4</td><td>79.9</td><td>40.5 37.6</td></tr><tr><td rowspan="2">2-2-4-2</td><td>Swin</td><td>24.7</td><td>3.8</td><td>80.2</td><td>41.2 38.1</td></tr><tr><td>Focal</td><td>25.4</td><td>4.1</td><td>81.4</td><td>43.3 39.8</td></tr><tr><td rowspan="2">2-2-6-2</td><td>Swin</td><td>28.3</td><td>4.5</td><td>81.2</td><td>43.7 39.8</td></tr><tr><td>Focal</td><td>29.1</td><td>4.9</td><td>82.2</td><td>44.8 41.0</td></tr></table>
Table 9: Impact of the change of model depth. We gradually reduce the number of transformer layers at the third stage from original 6 to 4 and further 2. Our Focal Transformers has much slower drop rate than Swin Transformer.
Swin Transformers, there should always be an even number of layers in each stage for the alternative window shift operation, Focal Transformers do not have such a constraint.
Contributions of local and global interactions. To investigate the relative contributions of capturing local fine-grain and global coarse-grain interactions in Focal Transformers, we have developed several variants of Focal-Tiny: a) Focal-Tiny-Window merely performs attention inside each window; b) Focal-Tiny-Local attends the additional fine-grain surrounding tokens and c) Focal-Tiny-Global attends the extra coarse-grain summarized tokens. We train these models using the same setting as Focal-Tiny and report their performance on image classification and object detection using Mask R-CNN $1 \times$ schedule. As shown in Fig. 5, Focal-Tiny-Window suffers from a significant performance drop on both image classification $8 2 . 2 \substack { 8 0 . 1 }$ ) and object detection $\cdot 4 4 . 8 \mathrm { \ - } \to 3 8 . 3$ ). This is expected since the communication across windows is completely cut off at each Transformer layer. After we enable either the local fine-grain or global coarse-grain interactions (middle two columns), we observe significant performance boost. When we combine short- and long-range interactions, we observe additional improvements on both tasks. This implies that these two type of interactions are complementary and both are beneficial to model performance.
Model capacity against model depth. Focal attention allows a Transformer model to capture shortand long-range interactions at each Transformer layer. An interesting question is whether Focal Transformers need fewer layers to obtain a similar modeling capacity as the Transformer models that does not use focal attention, such as Swin Transformer. To answer this question, we conduct an experiment by training a series of Swin-Tiny and Focal-Tiny models by varying the number of Transformer layers at stage 3. As shown in Table 9, Focal-Tiny outperforms Swin-Tiny consistently with the same depth. More importantly, using fewer layers, Focal-Tiny can sometimes achieve comparable or even better performance than Swin Transformer. For example, Focal-Tiny with (2-2-4-2) achieves 81.4 on image classification which is better than Swin-Tiny with (2-2-6-2).
# 5 Conclusion
In this paper, we have presented a new focal attention mechanism that enables efficient long-range interactions in Vision Transformers. Different from previous works, it performs the local attention at fine-grain and global attention at coarse-grain, providing an effective way of capturing both shortand long-range context with a manageable computational cost. By applying focal attention into a multi-scale Transformer architecture, we propose Focal Transformers as general-purpose backbones for a wide range of dense vision tasks. A comprehensive empirical study shows that our Focal Transformers outperform the SoTA Vision Transformers on a range of vision tasks including image classification, object detection and segmentation.
Limitations and future work. Although our experiments show that focal attention can significantly boost the performance on image classification and dense prediction tasks, focal attention does introduce extra computational and memory cost, since each query token needs to attend more (summarized) tokens in addition to tokens inside a window. A cost-effective implementation of Focal Transformer is necessary to make it more applicable to many real-world scenarios. This study focuses on incorporating focal attention into multi-scale Vision Transformers for CV tasks. However, we notice that focal attention is an effective sparse attention mechanism that is widely applicable to all attention-based neural network models that are developed for processing natural language, images, videos etc. This is an exciting future direction.
References [1] Joshua Ainslie, Santiago Ontanon, Chris Alberti, Philip Pham, Anirudh Ravula, and Sumit Sanghai. Etc: Encoding long and structured data in transformers. arXiv preprint arXiv:2004.08483, 2020. [2] Irwan Bello, Barret Zoph, Ashish Vaswani, Jonathon Shlens, and Quoc V Le. Attention augmented convolutional networks. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 3286–3295, 2019. [3] Iz Beltagy, Matthew E Peters, and Arman Cohan. Longformer: The long-document transformer. arXiv preprint arXiv:2004.05150, 2020. [4] Maxim Berman, Hervé Jégou, Andrea Vedaldi, Iasonas Kokkinos, and Matthijs Douze. Multigrain: a unified image embedding for classes and instances. arXiv preprint arXiv:1902.05509, 2019. [5] Navaneeth Bodla, Bharat Singh, Rama Chellappa, and Larry S Davis. Soft-nms–improving object detection with one line of code. In Proceedings of the IEEE international conference on computer vision, pages 5561–5569, 2017. [6] Tom B Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. arXiv preprint arXiv:2005.14165, 2020. [7] Yue Cao, Jiarui Xu, Stephen Lin, Fangyun Wei, and Han Hu. Gcnet: Non-local networks meet squeezeexcitation networks and beyond. In Proceedings of the IEEE/CVF International Conference on Computer Vision Workshops, pages 0–0, 2019. [8] Nicolas Carion, Francisco Massa, Gabriel Synnaeve, Nicolas Usunier, Alexander Kirillov, and Sergey Zagoruyko. End-to-end object detection with transformers. In European Conference on Computer Vision, pages 213–229. Springer, 2020. [9] 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. [10] Shuning Chang, Pichao Wang, Fan Wang, Hao Li, and Jiashi Feng. Augmented transformer with adaptive graph for temporal action proposal generation. arXiv preprint arXiv:2103.16024, 2021. [11] Kai Chen, Jiangmiao Pang, Jiaqi Wang, Yu Xiong, Xiaoxiao Li, Shuyang Sun, Wansen Feng, Ziwei Liu, Jianping Shi, Wanli Ouyang, et al. Hybrid task cascade for instance segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 4974–4983, 2019. [12] Liang-Chieh Chen, Yukun Zhu, George Papandreou, Florian Schroff, and Hartwig Adam. Encoder-decoder with atrous separable convolution for semantic image segmentation. In Proceedings of the European conference on computer vision (ECCV), pages 801–818, 2018. [13] Xin Chen, Bin Yan, Jiawen Zhu, Dong Wang, Xiaoyun Yang, and Huchuan Lu. Transformer tracking. arXiv preprint arXiv:2103.15436, 2021. [14] Xinlei Chen, Saining Xie, and Kaiming He. An empirical study of training self-supervised visual transformers. arXiv preprint arXiv:2104.02057, 2021. [15] Xiangxiang Chu, Zhi Tian, Yuqing Wang, Bo Zhang, Haibing Ren, Xiaolin Wei, Huaxia Xia, and Chunhua Shen. Twins: Revisiting spatial attention design in vision transformers. arXiv preprint arXiv:2104.13840, 2021. [16] Xiangxiang Chu, Zhi Tian, Bo Zhang, Xinlong Wang, Xiaolin Wei, Huaxia Xia, and Chunhua Shen. Conditional positional encodings for vision transformers. Arxiv preprint 2102.10882, 2021. [17] Xiyang Dai, Yinpeng Chen, Bin Xiao, Dongdong Chen, Mengchen Liu, Lu Yuan, and Lei Zhang. Dynamic head: Unifying object detection heads with attentions. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 7373–7382, 2021. [18] Zhigang Dai, Bolun Cai, Yugeng Lin, and Junying Chen. Up-detr: Unsupervised pre-training for object detection with transformers. arXiv preprint arXiv:2011.09094, 2020. [19] Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pages 248–255. Ieee, 2009. [20] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. NAACL, 2019. [21] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. arXiv preprint arXiv:2010.11929, 2020. [22] Xianzhi Du, Tsung-Yi Lin, Pengchong Jin, Golnaz Ghiasi, Mingxing Tan, Yin Cui, Quoc V Le, and Xiaodan Song. Spinenet: Learning scale-permuted backbone for recognition and localization. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 11592–11601, 2020. [23] Haoqi Fan, Bo Xiong, Karttikeya Mangalam, Yanghao Li, Zhicheng Yan, Jitendra Malik, and Christoph Feichtenhofer. Multiscale vision transformers. arXiv preprint arXiv:2104.11227, 2021. [24] Hao-Shu Fang, Jianhua Sun, Runzhong Wang, Minghao Gou, Yong-Lu Li, and Cewu Lu. Instaboost: Boosting instance segmentation via probability map guided copy-pasting. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 682–691, 2019. [25] Yuxin Fang, Shusheng Yang, Xinggang Wang, Yu Li, Chen Fang, Ying Shan, Bin Feng, and Wenyu Liu. Instances as queries, 2021. [26] Jun Fu, Jing Liu, Yuhang Wang, Yong Li, Yongjun Bao, Jinhui Tang, and Hanqing Lu. Adaptive context network for scene parsing. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 6748–6757, 2019. [27] Jianfeng Gao, Patrick Pantel, Michael Gamon, Xiaodong He, and Li Deng. Modeling interestingness with deep neural networks. In Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP), pages 2–13, Doha, Qatar, October 2014. Association for Computational Linguistics. [28] Golnaz Ghiasi, Yin Cui, Aravind Srinivas, Rui Qian, Tsung-Yi Lin, Ekin D Cubuk, Quoc V Le, and Barret Zoph. Simple copy-paste is a strong data augmentation method for instance segmentation. arXiv preprint arXiv:2012.07177, 2020. [29] Chengyue Gong, Dilin Wang, Meng Li, Vikas Chandra, and Qiang Liu. Vision transformers with patch diversification, 2021. [30] Kai Han, Yunhe Wang, Hanting Chen, Xinghao Chen, Jianyuan Guo, Zhenhua Liu, Yehui Tang, An Xiao, Chunjing Xu, Yixing Xu, et al. A survey on visual transformer. arXiv preprint arXiv:2012.12556, 2020. [31] Kai Han, An Xiao, Enhua Wu, Jianyuan Guo, Chunjing Xu, and Yunhe Wang. Transformer in transformer, 2021. [32] 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. [33] 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. [34] Elad Hoffer, Tal Ben-Nun, Itay Hubara, Niv Giladi, Torsten Hoefler, and Daniel Soudry. Augment your batch: Improving generalization through instance repetition. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 8129–8138, 2020. [35] Jie Hu, Li Shen, and Gang Sun. Squeeze-and-excitation networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 7132–7141, 2018. [36] Salman Khan, Muzammal Naseer, Munawar Hayat, Syed Waqas Zamir, Fahad Shahbaz Khan, and Mubarak Shah. Transformers in vision: A survey. arXiv preprint arXiv:2101.01169, 2021. [37] Yann LeCun, Yoshua Bengio, et al. Convolutional networks for images, speech, and time series. The handbook of brain theory and neural networks, 3361(10):1995, 1995. [38] Bing Li, Cheng Zheng, Silvio Giancola, and Bernard Ghanem. Sctn: Sparse convolution-transformer network for scene flow estimation. arXiv preprint arXiv:2105.04447, 2021. [39] Chunyuan Li, Jianwei Yang, Pengchuan Zhang, Mei Gao, Bin Xiao, Xiyang Dai, Lu Yuan, and Jianfeng Gao. Efficient self-supervised vision transformers for representation learning. arXiv preprint arXiv:2106.09785, 2021. [40] Xiangyu Li, Yonghong Hou, Pichao Wang, Zhimin Gao, Mingliang Xu, and Wanqing Li. Trear: Transformer-based rgb-d egocentric action recognition. arXiv preprint arXiv:2101.03904, 2021. [41] 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. [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 ECCV, 2014. [43] Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. arXiv preprint arXiv:2103.14030, 2021. [44] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017. [45] Hyeonseob Nam, Jung-Woo Ha, and Jeonghee Kim. Dual attention networks for multimodal reasoning and matching. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 299–307, 2017. [46] R. Pappagari, P. Zelasko, J. Villalba, Y. Carmiel, and N. Dehak. Hierarchical transformers for long document classification. In 2019 IEEE Automatic Speech Recognition and Understanding Workshop (ASRU), pages 838–844, 2019. [47] Niki Parmar, Ashish Vaswani, Jakob Uszkoreit, Lukasz Kaiser, Noam Shazeer, Alexander Ku, and Dustin Tran. Image transformer. In International Conference on Machine Learning, pages 4055–4064. PMLR, 2018. [48] Boris T Polyak and Anatoli B Juditsky. Acceleration of stochastic approximation by averaging. SIAM journal on control and optimization, 30(4):838–855, 1992. [49] Jack W Rae, Anna Potapenko, Siddhant M Jayakumar, and Timothy P Lillicrap. Compressive transformers for long-range sequence modelling. arXiv preprint arXiv:1911.05507, 2019. [50] Prajit Ramachandran, Niki Parmar, Ashish Vaswani, Irwan Bello, Anselm Levskaya, and Jonathon Shlens. Stand-alone self-attention in vision models. arXiv preprint arXiv:1906.05909, 2019. [51] Aravind Srinivas, Tsung-Yi Lin, Niki Parmar, Jonathon Shlens, Pieter Abbeel, and Ashish Vaswani. Bottleneck transformers for visual recognition, 2021. [52] Robin Strudel, Ricardo Garcia, Ivan Laptev, and Cordelia Schmid. Segmenter: Transformer for semantic segmentation. arXiv preprint arXiv:2105.05633, 2021. [53] Ke Sun, Bin Xiao, Dong Liu, and Jingdong Wang. Deep high-resolution representation learning for human pose estimation. In CVPR, 2019. [54] Mingxing Tan and Quoc Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In International Conference on Machine Learning, pages 6105–6114. PMLR, 2019. [55] Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Hervé Jégou. Training data-efficient image transformers & distillation through attention. arXiv preprint arXiv:2012.12877, 2020. [56] Ashish Vaswani, Prajit Ramachandran, Aravind Srinivas, Niki Parmar, Blake Hechtman, and Jonathon Shlens. Scaling local self-attention for parameter efficient visual backbones. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 12894–12904, 2021. [57] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In NeurIPS, 2017. [58] Huiyu Wang, Yukun Zhu, Hartwig Adam, Alan Yuille, and Liang-Chieh Chen. Max-deeplab: End-to-end panoptic segmentation with mask transformers. arXiv preprint arXiv:2012.00759, 2020. [59] Ning Wang, Wengang Zhou, Jie Wang, and Houqaing Li. Transformer meets tracker: Exploiting temporal context for robust visual tracking. arXiv preprint arXiv:2103.11681, 2021. [60] Wenhai Wang, Enze Xie, Xiang Li, Deng-Ping Fan, Kaitao Song, Ding Liang, Tong Lu, Ping Luo, and Ling Shao. Pyramid vision transformer: A versatile backbone for dense prediction without convolutions. arXiv preprint arXiv:2102.12122, 2021. [61] Xiaolong Wang, Ross Girshick, Abhinav Gupta, and Kaiming He. Non-local neural networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 7794–7803, 2018. [62] Yuqing Wang, Zhaoliang Xu, Xinlong Wang, Chunhua Shen, Baoshan Cheng, Hao Shen, and Huaxia Xia. End-to-end video instance segmentation with transformers. arXiv preprint arXiv:2011.14503, 2020. [63] Sanghyun Woo, Jongchan Park, Joon-Young Lee, and In So Kweon. Cbam: Convolutional block attention module. In Proceedings of the European conference on computer vision (ECCV), pages 3–19, 2018. [64] Haiping Wu, Bin Xiao, Noel Codella, Mengchen Liu, Xiyang Dai, Lu Yuan, and Lei Zhang. Cvt: Introducing convolutions to vision transformers. arXiv preprint arXiv:2103.15808, 2021. [65] Tete Xiao, Yingcheng Liu, Bolei Zhou, Yuning Jiang, and Jian Sun. Unified perceptual parsing for scene understanding. In Proceedings of the European Conference on Computer Vision (ECCV), pages 418–434, 2018. [66] Enze Xie, Wenhai Wang, Zhiding Yu, Anima Anandkumar, Jose M. Alvarez, and Ping Luo. Segformer: Simple and efficient design for semantic segmentation with transformers, 2021. [67] Saining Xie, Ross Girshick, Piotr Dollár, Zhuowen Tu, and Kaiming He. Aggregated residual transformations for deep neural networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 1492–1500, 2017. [68] Jianwei Yang, Zhile Ren, Chuang Gan, Hongyuan Zhu, and Devi Parikh. Cross-channel communication networks. In Proceedings of the 33rd International Conference on Neural Information Processing Systems, pages 1297–1306, 2019. [69] Minghao Yin, Zhuliang Yao, Yue Cao, Xiu Li, Zheng Zhang, Stephen Lin, and Han Hu. Disentangled non-local neural networks. In European Conference on Computer Vision, pages 191–207. Springer, 2020. [70] Kun Yuan, Shaopeng Guo, Ziwei Liu, Aojun Zhou, Fengwei Yu, and Wei Wu. Incorporating convolution designs into visual transformers. arXiv preprint arXiv:2103.11816, 2021. [71] Li Yuan, Yunpeng Chen, Tao Wang, Weihao Yu, Yujun Shi, Francis EH Tay, Jiashi Feng, and Shuicheng Yan. Tokens-to-token vit: Training vision transformers from scratch on imagenet. arXiv preprint arXiv:2101.11986, 2021. [72] Li Yuan, Qibin Hou, Zihang Jiang, Jiashi Feng, and Shuicheng Yan. Volo: Vision outlooker for visual recognition. arXiv preprint arXiv:2106.13112, 2021. [73] Yuhui Yuan, Xilin Chen, and Jingdong Wang. Object-contextual representations for semantic segmentation. arXiv preprint arXiv:1909.11065, 2019. [74] Manzil Zaheer, Guru Guruganesh, Avinava Dubey, Joshua Ainslie, Chris Alberti, Santiago Ontanon, Philip Pham, Anirudh Ravula, Qifan Wang, Li Yang, et al. Big bird: Transformers for longer sequences. arXiv preprint arXiv:2007.14062, 2020. [75] Hang Zhang, Chongruo Wu, Zhongyue Zhang, Yi Zhu, Haibin Lin, Zhi Zhang, Yue Sun, Tong He, Jonas Mueller, R Manmatha, et al. Resnest: Split-attention networks. arXiv preprint arXiv:2004.08955, 2020. [76] Pengchuan Zhang, Xiyang Dai, Jianwei Yang, Bin Xiao, Lu Yuan, Lei Zhang, and Jianfeng Gao. Multiscale vision longformer: A new vision transformer for high-resolution image encoding. arXiv preprint arXiv:2103.15358, 2021. [77] Wenwei Zhang, Jiangmiao Pang, Kai Chen, and Chen Change Loy. K-net: Towards unified image segmentation, 2021. [78] Jiaojiao Zhao, Xinyu Li, Chunhui Liu, Shuai Bing, Hao Chen, Cees GM Snoek, and Joseph Tighe. Tuber: Tube-transformer for action detection. arXiv preprint arXiv:2104.00969, 2021. [79] Minghang Zheng, Peng Gao, Xiaogang Wang, Hongsheng Li, and Hao Dong. End-to-end object detection with adaptive clustering transformer. arXiv preprint arXiv:2011.09315, 2020. [80] Sixiao Zheng, Jiachen Lu, Hengshuang Zhao, Xiatian Zhu, Zekun Luo, Yabiao Wang, Yanwei Fu, Jianfeng Feng, Tao Xiang, Philip HS Torr, et al. Rethinking semantic segmentation from a sequence-to-sequence perspective with transformers. arXiv preprint arXiv:2012.15840, 2020. [81] Sixiao Zheng, Jiachen Lu, Hengshuang Zhao, Xiatian Zhu, Zekun Luo, Yabiao Wang, Yanwei Fu, Jianfeng Feng, Tao Xiang, Philip HS Torr, et al. Rethinking semantic segmentation from a sequence-to-sequence perspective with transformers. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 6881–6890, 2021. [82] Zhun Zhong, Liang Zheng, Guoliang Kang, Shaozi Li, and Yi Yang. Random erasing data augmentation. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pages 13001–13008, 2020. [83] Bolei Zhou, Hang Zhao, Xavier Puig, Sanja Fidler, Adela Barriuso, and Antonio Torralba. Scene parsing through ade20k dataset. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 633–641, 2017. [84] Xingyi Zhou, Vladlen Koltun, and Philipp Krähenbühl. Probabilistic two-stage detection. arXiv preprint arXiv:2103.07461, 2021. [85] Xizhou Zhu, Weijie Su, Lewei Lu, Bin Li, Xiaogang Wang, and Jifeng Dai. Deformable detr: Deformable transformers for end-to-end object detection. arXiv preprint arXiv:2010.04159, 2020.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611# WHAT ARE THE STATISTICAL LIMITS OF OFFLINE RL WITH LINEAR FUNCTION APPROXIMATION?
Ruosong Wang Carnegie Mellon University ruosongw@andrew.cmu.edu
Dean P. Foster University of Pennsylvania and Amazon dean@foster.net Sham M. Kakade University of Washington, Seattle and Microsoft Research sham@cs.washington.edu
# ABSTRACT
Offline reinforcement learning seeks to utilize offline (observational) data to guide the learning of (causal) sequential decision making strategies. The hope is that offline reinforcement learning coupled with function approximation methods (to deal with the curse of dimensionality) can provide a means to help alleviate the excessive sample complexity burden in modern sequential decision making problems. However, the extent to which this broader approach can be effective is not well understood, where the literature largely consists of sufficient conditions.
This work focuses on the basic question of what are necessary representational and distributional conditions that permit provable sample-efficient offline reinforcement learning. Perhaps surprisingly, our main result shows that even if: i) we have realizability in that the true value function of every policy is linear in a given set of features and 2) our off-policy data has good coverage over all features (under a strong spectral condition), any algorithm still (information-theoretically) requires a number of offline samples that is exponential in the problem horizon to nontrivially estimate the value of any given policy. Our results highlight that sampleefficient offline policy evaluation is not possible unless significantly stronger conditions hold; such conditions include either having low distribution shift (where the offline data distribution is close to the distribution of the policy to be evaluated) or significantly stronger representational conditions (beyond realizability).
# 1 INTRODUCTION
Offline methods (also known as off-policy methods or batch methods) are a promising methodology to alleviate the sample complexity burden in challenging reinforcement learning (RL) settings, particularly those where sample efficiency is paramount (Mandel et al., 2014; Gottesman et al., 2018; Wang et al., 2018; Yu et al., 2019). Off-policy methods are often applied together with function approximation schemes; such methods take sample transition data and reward values as inputs, and approximate the value of a target policy or the value function of the optimal policy. Indeed, many practical deep RL algorithms find their prototypes in the literature of offline RL. For example, when running on off-policy data (sometimes termed as “experience replay”), deep $Q$ -networks (DQN) (Mnih et al., 2015) can be viewed as an analog of Fitted $Q$ -Iteration (Gordon, 1999) with neural networks being the function approximators. More recently, there are an increasing number of both model-free (Laroche et al., 2019; Fujimoto et al., 2019; Jaques et al., 2020; Kumar et al., 2019; Agarwal et al., 2020) and model-based (Ross & Bagnell, 2012; Kidambi et al., 2020) offline RL methods, with steady improvements in performance (Fujimoto et al., 2019; Kumar et al., 2019; Wu et al., 2020; Kidambi et al., 2020).
However, despite the importance of these methods, the extent to which data reuse is possible, especially when off-policy methods are combined with function approximation, is not well understood. For example, deep $Q$ -network requires millions of samples to solve certain Atari games (Mnih et al., 2015). Also important is that in some safety-critical settings, we seek guarantees when offlinetrained policies can be effective (Thomas, 2014; Thomas et al., 2019). A basic question here is that if there are fundamental statistical limits on such methods, where sample-efficient offline RL is simply not possible without further restrictions on the problem.
In the context of supervised learning, it is well-known that empirical risk minimization is sampleefficient if the hypothesis class has bounded complexity. For example, suppose the agent is given a $d$ -dimensional feature extractor, and the ground truth labeling function is a (realizable) linear function with respect to the feature mapping. Here, it is well-known that a polynomial number of samples in $d$ suffice for a given target accuracy. Furthermore, in this realizable case, provided the training data has a good feature coverage, then we will have good accuracy against any test distribution.1
In the more challenging offline RL setting, it is unclear if sample-efficient methods are possible, even under analogous assumptions. This is our motivation to consider the following question:
# What are the statistical limits for offline RL with linear function approximation?
Here, one may hope that value estimation for a given policy is possible in the offline RL setting under the analogous set of assumptions that enable sample-efficient supervised learning, i.e., 1) (realizability) the features can perfectly represent the value functions and 2) (good coverage) the feature covariance matrix of our off-policy data has lower bounded eigenvalues.
The extant body of provable methods on offline RL either make representational assumptions that are far stronger than realizability or assume distribution shift conditions that are far stronger than having coverage with regards to the spectrum of the feature covariance matrix of the data distribution. For example, Szepesvari & Munos (2005) analyze offline RL methods by assuming a representational ´ condition where the features satisfy (approximate) closedness under Bellman updates, which is a far stronger representation condition than realizability. Recently, Xie & Jiang (2020a) propose a offline RL algorithm that only requires realizability as the representation condition. However, the algorithm in (Xie & Jiang, 2020a) requires a more stringent data distribution condition. Whether it is possible to design a sample-efficient offline RL method under the realizability assumption and a reasonable data coverage assumption — an open problem in (Chen & Jiang, 2019) — is the focus of this work.
Our Contributions. Perhaps surprisingly, our main result shows that, under only the above two assumptions, it is information-theoretically not possible to design a sample-efficient algorithm to non-trivially estimate the value of a given policy. The following theorem is an informal version of the result in Section 4.
Theorem 1.1 (Informal). In the offline RL setting, suppose the data distributions have (polynomially) lower bounded eigenvalues, and the $Q$ -functions of every policy are linear with respect to a given feature mapping. Any algorithm requires an exponential number of samples in the horizon $H$ to output a non-trivially accurate estimate of the value of any given policy $\pi$ , with constant probability.
This hardness result states that even if the $Q$ -functions of all polices are linear with respect to the given feature mapping, we still require an exponential number of samples to evaluate any given policy. Note that this representation condition is significantly stronger than assuming realizability with regards to only a single target policy; it assumes realizability for all policies. Regardless, even under this stronger representation condition, it is hard to evaluate any policy, as specified in our hardness result.
This result also formalizes a key issue in offline reinforcement learning with function approximation: geometric error amplification. To better illustrate the issue, in Section 5, we analyze the classical Least-Squares Policy Evaluation (LSPE) algorithm under the realizability assumption, which demonstrates how the error propagates as the algorithm proceeds. Here, our analysis shows that, if we only rely on the realizability assumption, then a far more stringent condition is required for sample-efficient offline policy evaluation: the off-policy data distribution must be quite close to the distribution induced by the policy to be evaluated.
Our results highlight that sample-efficient offline RL is simply not possible unless either the distribution shift condition is sufficiently mild or we have stronger representation conditions that go well beyond realizability. See Section 5 for more details.
Furthermore, our hardness result implies an exponential separation on the sample complexity between offline RL and supervised learning, since supervised learning (which is equivalent to offline RL with $H = 1$ ) is possible with polynomial number of samples under the same set of assumptions.
A few additional points are worth emphasizing with regards to our lower bound construction:
• Our results imply that Least-Squares Policy Evaluation (LSPE, i.e., using Bellman backups with linear regression) will fail. Interestingly, while LSPE will provide an unbiased estimator, our results imply that it will have exponential variance in the problem horizon. Our construction is simple and does not rely on having a large state or action space: the size of the state space is only $O ( d \cdot H )$ where $d$ is the feature dimension and $H$ is the planning horizon, and the size of the action space is only is 2. This stands in contrast to other RL lower bounds, which typically require state spaces that are exponential in the problem horizon (e.g. see (Du et al., 2020)). • We provide two hard instances, one with a sparse reward (and stochastic transitions) and another with deterministic dynamics (and stochastic rewards). These two hard instances jointly imply that both the estimation error on reward values and the estimation error on the transition probabilities could be geometrically amplified in offline RL. Of possibly broader interest is that our hard instances are, to our knowledge, the first concrete examples showing that geometric error amplification is real in RL problems (even with realizability). While this is a known concern in the analysis of RL algorithms, there have been no concrete examples exhibiting such behavior under only a realizability assumption.
# 2 RELATED WORK
We now survey prior work on offline RL, largely focusing on theoretical results. We also discuss results on the error amplification issue in RL. Concurrent to this work, Xie & Jiang (2020a) propose a offline RL algorithm under the realizability assumption, which requires stronger distribution shift conditions. We will discuss this work shortly.
Existing Algorithms and Analysis. Offline RL with value function approximation is closely related to Approximate Dynamic Programming (Bertsekas & Tsitsiklis, 1995). Existing work (Munos, 2003; Szepesvari & Munos, 2005; Antos et al., 2008; Munos & Szepesv ´ ari, 2008; Tosatto et al., ´ 2017; Xie & Jiang, 2020b; Duan & Wang, 2020) that analyze the sample complexity of approximate dynamic programming-based approaches usually make the following two categories of assumptions: (i) representation conditions that assume the function class approximates the value functions well and (ii) distribution shift conditions that assume the given data distribution has sufficient coverage over the state-action space. As mentioned in the introduction, the desired representation condition would be realizability, which only assumes the value function of the policy to be evaluated lies in the function class (for the case of offline policy evaluation) or the optimal value function lies in the function class (for the case of finding near-optimal policies), and existing works usually make stronger assumptions. For example, Szepesvari & Munos (2005); Duan & Wang (2020) assume (ap- ´ proximate) closedness under Bellman updates, which is much stronger than realizability. Whether it is possible to design a sample-efficient offline RL method under the realizability assumption and reasonable data coverage assumption, is left as an open problem in (Chen & Jiang, 2019).
To measure the coverage over the state-action space of the given data distribution, existing works assume the concentrability coefficient (introduced by Munos (2003)) to be bounded. The concentrability coefficient, informally speaking, is the largest possible ratio between the probability for a state-action pair $( s , a )$ to be visited by a policy, and the probability that $( s , a )$ appears on the data distribution. Since we work with linear function approximation in this work, we measure the distribution shift in terms of the spectrum of the feature covariance matrices (see Assumption 2), which is a well-known sufficient condition in the context of supervised learning and is much more natural for the case of linear function approximation.
Concurrent to this work, Xie & Jiang (2020a) propose an algorithm that works under the realizability assumption instead of other stronger representation conditions used in prior work. However, the algorithm in (Xie & Jiang, 2020a) requires a much stronger data distribution condition which assumes a stringent version of concentrability coefficient introduced by (Munos, 2003) to be bounded. In contrast, in this work we measure the distribution shift in terms of the spectrum of the feature covariance matrix of the data distribution, which is more natural than the concentrability coefficient for the case of linear function approximation.
Recently, there has been great interest in approaching offline policy evaluation (Precup, 2000) via importance sampling. For recent work on this topic, see (Dud´ık et al., 2011; Mandel et al., 2014; Thomas et al., 2015; Li et al., 2015; Jiang & Li, 2016; Thomas & Brunskill, 2016; Guo et al., 2017; Wang et al., 2017; Liu et al., 2018; Farajtabar et al., 2018; Xie et al., 2019; Kallus & Uehara, 2019; Liu et al., 2019; Uehara & Jiang, 2019; Kallus & Uehara, 2020; Jiang & Huang, 2020; Feng et al., 2020). Offline policy evaluation with importance sampling incurs exponential variance in the planning horizon when the behavior policy is significantly different from the policy to be evaluated. Bypassing such exponential dependency requires non-trivial function approximation assumptions (Jiang & Huang, 2020; Feng et al., 2020; Liu et al., 2018). Finally, Kidambi et al. (2020) provide a model-based offline RL algorithm, with a theoretical analysis based on hitting times.
Hardness Results. Algorithm-specific hardness results have been known for a long time in the literature of Approximate Dynamic Programming. See Chapter 4 in (Van Roy, 1994) and also (Gordon, 1995; Tsitsiklis & Van Roy, 1996). These works demonstrate that certain approximate dynamic programming-based methods will diverge on hard cases. However, such hardness results only hold for a restricted class of algorithms, and to demonstrate the fundamental difficulty of offline RL, it is more desirable to obtain information-theoretic lower bounds as initiated by Chen & Jiang (2019).
Existing (information-theoretic) exponential lower bounds (Krishnamurthy et al., 2016; Sun et al., 2017; Chen & Jiang, 2019) usually construct unstructured MDPs with an exponentially large state space. Du et al. (2020) prove an exponential lower bound under the assumption that the optimal $Q$ - function is approximately linear. The condition that the optimal $Q$ -function is only approximately linear is crucial for the hardness result in Du et al. (2020). The techniques in (Du et al., 2020) are later generalized to other settings (Kumar et al., 2020; Wang et al., 2020; Mou et al., 2020).
Error Amplification In RL. Error amplification induced by distribution shift and long planning horizon is a known issue in the theoretical analysis of RL algorithms. See (Gordon, 1995; 1996; Munos & Moore, 1999; Ormoneit & Sen, 2002; Kakade, 2003; Zanette et al., 2019) for papers on this topic and additional assumptions that mitigate this issue. Error amplification in offline RL is also observed in empirical works (see e.g. (Fujimoto et al., 2019)). In this work, we provide the first information-theoretic lower bound showing that geometric error amplification is real in offline RL.
# 3 THE OFFLINE POLICY EVALUATION PROBLEM
Throughout this paper, for a given integer $H$ , we use $[ H ]$ to denote the set $\{ 1 , 2 , \ldots , H \}$
Episodic Reinforcement Learning. Let $M = ( \mathcal { S } , \mathcal { A } , P , R , H )$ be a Markov Decision Process (MDP) where $s$ is the state space, $\mathcal { A }$ is the action space, $P : \mathcal { S } \times \mathcal { A } \Delta ( \mathcal { S } )$ is the transition operator which takes a state-action pair and returns a distribution over states, $\Dot { R : } \Dot { S } \times \mathcal { A } \Delta ( \mathbb { R } )$ is the reward distribution, $H \in \mathbb { Z } _ { + }$ is the planning horizon. For simplicity, we assume a fixed initial state $s _ { 1 } \in { \mathcal { S } }$ . A (stochastic) policy $\pi : S \Delta ( { \mathcal { A } } )$ chooses an action $a$ randomly based on the current state $s$ . The policy $\pi$ induces a (random) trajectory $s _ { 1 } , a _ { 1 } , r _ { 1 } , s _ { 2 } , a _ { 2 } , r _ { 2 } , \ldots , s _ { H } , a _ { H } , r _ { H }$ , where $a _ { 1 } \sim \pi _ { 1 } ( s _ { 1 } )$ , $r _ { 1 } \sim R ( s _ { 1 } , a _ { 1 } )$ , $s _ { 2 } \sim P ( s _ { 1 } , a _ { 1 } )$ , $a _ { 2 } \sim \pi _ { 2 } ( s _ { 2 } )$ , etc. To streamline our analysis, for each $h \in [ H ]$ , we use $S _ { h } \subseteq S$ to denote the set of states at level $h$ , and we assume $S _ { h }$ do not intersect with each other. We assume, almost surely, that $r _ { h } \in [ - 1 , 1 ]$ for all $h \in [ H ]$ .
Value Functions. Given a policy $\begin{array} { r } { \mathbb { E } \left[ \sum _ { h ^ { \prime } = h } ^ { H } r _ { h ^ { \prime } } \mid s _ { h } = s , a _ { h } = a , \pi \right] } \end{array}$ an d , $\textit { h } \in \ [ H ]$ $\begin{array} { r } { V _ { h } ^ { \pi } ( s ) = \mathbb { E } \left[ \sum _ { h ^ { \prime } = h } ^ { H } r _ { h ^ { \prime } } \mid s _ { h } = s , \pi \right] } \end{array}$ and $( s , a ) \in S _ { h } \times \mathcal { A }$ , define h. For a policy $Q _ { h } ^ { \pi } ( s , a ) \ =$ $\pi$ , we define $V ^ { \pi } = V _ { 1 } ^ { \pi } ( s _ { 1 } )$ to be the value of $\pi$ from the fixed initial state $s _ { 1 }$ .
Linear Function Approximation. When applying linear function approximation schemes, it is commonly assumed that the agent is given a feature extractor $\phi : \mathcal { S } \times \bar { \mathcal { A } } \mathbb { R } ^ { d }$ which can either be hand-crafted or a pre-trained neural network that transforms a state-action pair to a $d$ -dimensional embedding, and the $Q$ -functions can be predicted by linear functions of the features. In this paper, we are interested in the following realizability assumption.
Assumption 1 (Realizable Linear Function Approximation). For every policy $\pi : S \Delta ( { \mathcal { A } } )$ , there exists $\theta _ { 1 } ^ { \pi } , \ldots \theta _ { H } ^ { \pi } \in \mathbb { R } ^ { d }$ such that for all $( s , a ) \in S \times A$ and $h \in [ H ] , Q _ { h } ^ { \pi } ( s , a ) = \left( \theta _ { h } ^ { \pi } \right) ^ { \top } \phi ( s , a ) .$ .
Note that our assumption is much stronger than assuming realizability with regards to a single policy $\pi$ (say the policy that we wish to evaluate); our assumption imposes realizability for all policies.
Offline Reinforcement Learning. This paper is concerned with the offline RL setting. In this setting, thtributions $\{ \mu _ { h } \} _ { h = 1 } ^ { H }$ oes not have dirwhere for each $h \in [ H ]$ , $\mu _ { h } \in \Delta ( S _ { h } \times \mathcal { A } )$ stead is given access to data d. The inputs of the agent are $H$ datasets $\{ D _ { h } \} _ { h = 1 } ^ { H }$ 1 , and for each $h \in [ H ]$ , $D _ { h }$ consists i.i.d. samples of the form $( s , a , r , s ^ { \prime } ) \in$ $S _ { h } \times \mathcal { A } \times \mathbb { R } \times \mathcal { S } _ { h + 1 }$ tuples, where $( s , \dot { a } ) \stackrel { . } { \sim } \mu _ { h } , r \sim r ( s , a ) , s ^ { \prime } \sim \bar { P ( } s , a ) $ .
In this paper, we focus on the offline policy evaluation problem with linear function approximation: given a policy accurate estim $\pi : S \Delta ( { \mathcal { A } } )$ f $\pi$ d a fe(i.e., $V ^ { \pi }$ re extractor ) approxima $\phi : \mathcal { S } \times \mathcal { A } \mathbb { R } ^ { d }$ , the goal is toected datasets $\{ D _ { h } \} _ { h = 1 } ^ { H }$ with as few samples as possible.
Notation. For a vector $x \in \mathbb { R } ^ { d }$ , we use $\lVert x \rVert _ { 2 }$ to denote its $\ell _ { 2 }$ norm. For a positive semidefinite matrix $A$ , we use $\| A \| _ { 2 }$ to denote its operator norm, and $\sigma _ { \mathrm { m i n } } ( A )$ to denote its smallest eigenvalue. For two positive semidefinite matrices $A$ and $B$ , we write $A \succeq B$ to denote the Lowner partial ¨ ordering of matrices, i.e, $A \succeq B$ if and only if $A - B$ is positive semidefinite. For a policy $\pi : { \cal { S } } $ $\Delta \left( \mathcal { A } \right)$ , we use $\mu _ { h } ^ { \pi }$ to denote the marginal distribution of $s _ { h }$ under $\pi$ , i.e., $\mu _ { h } ^ { \pi } ( s ) = \operatorname* { P r } [ s _ { h } = s \mid \pi ]$ . For a vector $x \in \mathbb { R } ^ { d }$ and a positive semidefinite matrix $A \in \mathbb { R } ^ { d \times d }$ , we use $\| x \| _ { A }$ to denote $\sqrt { x ^ { \top } A x }$ .
# 4 THE LOWER BOUND: REALIZABILITY AND COVERAGE ARE INSUFFICIENT
We now present our main hardness result for offline policy evaluation with linear function approximation. It should be evident that without feature coverage in our dataset, realizability alone is clearly not sufficient for sample-efficient estimation. Here, we will make the strongest possible assumption, with regards to the conditioning of the feature covariance matrix.
Assumption 2 (Feature Coverage). For all $( s , a ) \in S \times A ,$ , assume our feature map is bounded such that $\| \phi ( s , a ) \| _ { 2 } \leq 1$ . Furthermore, suppose for each $h \in [ H ]$ , the data distributions $\mu _ { h }$ satisfy the following minimum eigenvalue condition: $\sigma _ { \mathrm { m i n } } \left( \mathbb { E } _ { ( s , a ) \sim \mu _ { h } } [ \dot { \phi } ( \dot { s } , a ) \phi ( s , a ) ^ { \top } ] \right) = 1 / d .$ . 2
Clearly, for the case where $H = 1$ , the realizability assumption (Assumption 1), and feature coverage assumption (Assumption 2) imply that the ordinary least squares estimator will accurately estimate $\theta _ { 1 }$ .3 Our main result now shows that these assumptions are not sufficient for offline policy evaluation for long horizon problems.
Theorem 4.1. Suppose Assumption 2 holds. Fix an algorithm that takes as input both a policy and $a$ feature mapping. There exists a (deterministic) MDP satisfying Assumption $^ { l }$ , such that for any policy $\pi : S \Delta ( { \mathcal { A } } )$ , the algorithm requires $\Omega ( ( d / 2 ) ^ { H } )$ samples to output the value of $\pi$ up to constant additive approximation error with probability at least 0.9.
Although we focus on offline policy evaluation in this work, our hardness result also holds for finding near-optimal policies under Assumption 1 in the offline RL setting. Below we give a simple reduction. At the initial state, if the agent chooses action $a _ { 1 }$ , then the agent receives a fixed reward value (say 0.5) and terminates. If the agent chooses action $a _ { 2 }$ , then the agent transits to our hard instance. In order to find a policy with suboptimality at most 0.5, the agent must evaluate the value of the optimal policy in our hard instance up to an error of 0.5, and hence the hardness result holds.
Remark 1 (The sparse reward case). As stated, the theorem uses a deterministic MDP (with stochastic rewards). See Appendix C for another hard case where the transition is stochastic and the reward is deterministic and sparse (only occurring at two states at $h = H$ ).
Remark 2 (Least-Squares Policy Evaluation (LSPE) has exponential variance). For offline policy evaluation with linear function approximation, the most na¨ıve algorithm here would be LSPE, i.e., using ordinary least squares (OLS) to estimate $\theta ^ { \pi }$ , starting at level $h = H$ and then proceeding backwards to level $h = 1$ , using the plug-in estimator from the previous level. Here, LSPE will provide an unbiased estimate (provided the feature covariance matrices are full rank, which will occur with high probability). As a direct corollary, the above theorem implies that LSPE has exponential variance in $H$ . See Section 5 for a more detailed discussion on LSPE. More generally, our theorem implies that there is no estimator that can avoid such exponential dependence in the offline setting.
Remark 3 (Least-Squares Value Iteration (LSVI) versus Least-Squares Policy Iteration (LSPI)). In the offline setting, under Assumptions 1 and 2, in order to find a near-optimal policy, the most na¨ıve algorithm would be LSVI, i.e., using ordinary least squares (OLS) to estimate $\theta ^ { * }$ , starting at level $h = H$ and then proceeding backwards to level $h = 1$ , using the plug-in estimator from the previous level and the bellman operator. The above theorem implies that LSVI will require an exponential number of samples to find a near-optimal policy. On the other hand, if the regression targets are collected by using rollouts (i.e. on-policy sampling) as in LSPI (Lagoudakis & Parr, 2003), then a polynomial number of samples suffice. See Section D in (Du et al., 2020) for an analysis. Thus, Theorem 4.1 implies an exponential separation on the sample complexity between LSVI and LSPI. Of course, LSPI requires adaptive data samples and thus does not work in the offline setting.
One may wonder if Theorem 4.1 still holds when the data distributions $\{ \mu _ { h } \} _ { h = 1 } ^ { H }$ are induced by a policy. In Appendix C, we prove another exponential sample complexity lower bound under the additional assumption that the data distributions are induced by a fixed policy $\pi$ . However, under such an assumption, it is impossible to prove a hardness result as strong as Theorem 4.1 (which shows that evaluating any policy is hard), since one can at least evaluate the policy $\pi$ that induces the data distributions. Nevertheless, we are able to prove the hardness of offline policy evaluation, under a weaker version of Assumption 1. See Appendix $\textrm { C }$ for more details.
In the remaining part of this section, we give the hard instance construction and the proof of Theorem 4.1. We use $d$ the denote the feature dimension, and we assume $d$ is even for simplicity. We use $\hat { d }$ to denote $d / 2$ for convenience. We also provide an illustration of the construction in Figure 1.
ac, Action Spcontains d Transtates or. and action space . For each $\mathcal { A } = \{ a _ { 1 } , a _ { 2 } \}$ . For each, for each $h \in [ H ]$ $S _ { h }$ $\hat { d } + 1$ $s _ { h } ^ { 1 } , s _ { h } ^ { 2 } , \ldots , s _ { h } ^ { \hat { d } }$ $s _ { h } ^ { \hat { d } + 1 }$ $h \in [ H - 1 ]$ $c \in \{ 1 , 2 , \ldots , \hat { d } + 1 \}$ , we have $P ( s _ { h } ^ { c } , a _ { 1 } ) = s _ { h + 1 } ^ { \hat { d } + 1 }$ and $P ( s _ { h } ^ { c } , a _ { 1 } ) = s _ { h + 1 } ^ { c }$ .
Reward Distributions. Let $0 \leq r _ { 0 } \leq \hat { d } ^ { - H / 2 }$ be a parameter to be determined. For each $( h , c ) \in$ $[ H - 1 ] \times [ \hat { d } ]$ and $a \in { \mathcal { A } }$ , we set $R ( s _ { h } ^ { c } , a ) = 0$ and $R ( s _ { h } ^ { \hat { d } + 1 } , a ) = r _ { 0 } \cdot ( \hat { d } ^ { 1 / 2 } - 1 ) \cdot \hat { d } ^ { ( H - h ) / 2 }$ . For the last level, for each $c \in [ \hat { d } ]$ and $a \in { \mathcal { A } }$ , we set $R ( s _ { H } ^ { c } , a ) = \left\{ \begin{array} { l l } { { 1 } } \\ { { - 1 } } \end{array} \right.$ with probability with probability $( 1 + r _ { 0 } ) / 2$ $( 1 - r _ { 0 } ) / 2$ so that $\mathbb { E } [ R ( s _ { H } ^ { c } , a ) ] = r _ { 0 }$ . Moreover, for all actions $a \in \mathcal { A } , R ( s _ { H } ^ { \hat { d } + 1 } , a ) = r _ { 0 } \cdot \hat { d } ^ { 1 / 2 }$ .
Feature Mapping. Let $e _ { 1 } , e _ { 2 } , \ldots , e _ { d }$ be a set of orthonormal vectors in $\mathbb { R } ^ { d }$ . Here, one possible choice is to set $e _ { 1 } , e _ { 2 } , \ldots , e _ { d }$ to be the standard basis vectors. For each $( h , c ) \in [ H ] \times [ \hat { d } ]$ , we set $\phi ( s _ { h } ^ { c } , a _ { 1 } ) = e _ { c } , \phi ( s _ { h } ^ { c } , a _ { 2 } ) = e _ { c + { \hat { d } } } $ , and $\begin{array} { r } { \phi ( s _ { h } ^ { \hat { d } + 1 } , a ) = \sum _ { c \in \hat { d } } e _ { c } / \hat { d } ^ { 1 / 2 } } \end{array}$ for all $a \in { \mathcal { A } }$ .
Verifying Assumption 1. The following lemma shows that Assumption 1 holds for our construction. The formal proof can be found in Appendix A.
Lemma 4.2. For every policy $\pi : S \Delta ( { \mathcal { A } } )$ , for each $h \in [ H ]$ , for all $( s , a ) \in S _ { h } \times \mathcal { A } ,$ , we have $Q _ { h } ^ { \pi } ( s , a ) = \left( \theta _ { h } ^ { \pi } \right) ^ { \top } \phi ( s , a )$ for some $\theta _ { h } ^ { \pi } \in \mathbb { R } ^ { d }$ .

Figure 1: An illustration of the hard instance. Recall that $\hat { d } = d / 2$ . States on the top are those in the first level $( h = 1 )$ ), while states at the bottom are those in the last level $h = H$ ). Solid line (with arrow) corresponds to transitions associated with action $a _ { 1 }$ , while dotted line (with arrow) corresponds to transitions associated with action $a _ { 2 }$ . For each level $h \in [ H ]$ , reward values and $Q$ -values associated with $s _ { h } ^ { 1 } , s _ { h } ^ { 2 } , \ldots , s _ { h } ^ { \hat { d } }$ are marked on the left, while reward values and $Q$ -values associated with $s _ { h } ^ { \hat { d } + 1 }$ are mark on the right. Rewards and transitions are all deterministic, except for the reward distributions associated with $s _ { H } ^ { 1 } , s _ { H } ^ { 2 } , \ldots , s _ { H } ^ { \hat { d } }$ . We mark the ex tation of the reward uniformly at random from those states in the dashed rectangle, i.e., $h \in [ H ]$ $\{ s _ { h } ^ { 1 } , s _ { h } ^ { 2 } , \ldots , s _ { h } ^ { \hat { d } } \}$ $\mu _ { h }$ , while the action is chosen uniformly at random from $\{ a _ { 1 } , a _ { 2 } \}$ . Suppose the initial state is $s _ { 1 } ^ { \hat { d } + 1 }$ . When $r _ { 0 } = 0$ , the value of the policy is 0. When $r _ { 0 } = \hat { d } ^ { - H / 2 }$ , the value of the policy is $r _ { 0 } \cdot \hat { d } ^ { H / 2 } = 1$ .
The Data Distributions. For each level $h \in [ H ]$ , the data distribution $\mu _ { h }$ is a uniform distribution over $\{ ( s _ { h } ^ { 1 } , a _ { 1 } ) , ( s _ { h } ^ { 1 } , a _ { 2 } ) , ( s _ { h } ^ { 2 } , a _ { 1 } ) , ( s _ { h } ^ { 2 } , a _ { 2 } ) , \ldots , ( s _ { h } ^ { \hat { d } } , a _ { 1 } ) , ( s _ { h } ^ { \hat { d } } , a _ { 2 } ) \}$ . Notice that $( s _ { h } ^ { \hat { d } + 1 } , a )$ is not in the hsupport of $\mu _ { h }$ hfor all $a \in { \mathcal { A } }$ h h. It can be seen that, $\begin{array} { r } { \mathbb { E } _ { ( s , a ) \sim \mu _ { h } } \left[ \phi ( s , a ) \phi ( s , a ) ^ { \top } \right] = \frac { 1 } { d } \sum _ { c = 1 } ^ { d } e _ { c } e _ { c } ^ { \top } = \frac { 1 } { d } I . } \end{array}$
The Lower Bound. We show that it is information-theoretically hard for any algorithm to distinguish the case $r _ { 0 } = 0$ and $r _ { 0 } = \hat { d } ^ { - H / 2 }$ . We fix the initial state to be $s _ { 1 } ^ { \hat { d } + 1 }$ , and consider any policy $\pi$ . When $r _ { 0 } = 0$ , all reward values will be zero, and thus the value of $\pi$ is zero. On the other hand, when $r _ { 0 } = \hat { d } ^ { - H / 2 }$ , the value of $\pi$ would be $r _ { 0 } \cdot \hat { d } ^ { H / 2 } = 1$ . Thus, if the algorithm approximates the value of the policy up to an error of $1 / 2$ , then it must distinguish the case that $r _ { 0 } = 0$ and $r _ { 0 } = \hat { d } ^ { - H / 2 }$ .
We first notice that for the case $r _ { 0 } = 0$ and $r _ { 0 } = \hat { d } ^ { - H / 2 }$ , the data distributions $\{ \mu _ { h } \} _ { h = 1 } ^ { H }$ , the feature mapping $\phi : \mathcal { S } \times \mathcal { A } \mathbb { R } ^ { d }$ , the policy $\pi$ to be evaluated and the transition operator $P$ are the same. Thus, in order to distinguish the case $r _ { 0 } = 0$ and $r _ { 0 } = \hat { d } ^ { - H / 2 }$ , the only way is to query the reward distribution by using sampling taken from the data distributions. For all state-action pairs $( s , a )$ in the support of the data distributions of the first $H - 1$ levels, the reward distributions will be identical. This is because for all $s \in \mathcal { S } _ { h } \setminus \{ s _ { h } ^ { \hat { d } + 1 } \}$ and $a \in { \mathcal { A } }$ , we have $R ( s , a ) = 0$ . For the case $r _ { 0 } = 0$ and $r _ { 0 } = \hat { d } ^ { - H / 2 }$ , for all state-action pairs $( s , a )$ in the support of the data distribution of the last level, $R ( s , a ) = \left\{ { 1 \atop - 1 } \right.$ with probability with probability $( 1 + r _ { 0 } ) / 2$ $\dot { ( 1 - r _ { 0 } ) / 2 }$ Therefore, to distinguish the case that $r _ { 0 } ~ = ~ 0$ and $r _ { 0 } ~ = ~ \hat { d } ^ { - H / 2 }$ , the agent needs to distinguish two reward distributions $r _ { 1 } = \left\{ { \begin{array} { l l } { 1 } & { { \mathrm { w i t h ~ p r o b a b i l i t y ~ } } 1 / 2 } \\ { - 1 } & { { \mathrm { w i t h ~ p r o b a b i l i t y ~ } } 1 / 2 } \end{array} } \right.$ and $r _ { 2 } = \left\{ \begin{array} { l l } { { \stackrel { - } { 1 } } } \\ { { - 1 } } \end{array} \right.$ with probability with probability $\begin{array} { c } { { ( 1 + \hat { d } ^ { - H / 2 } ) / 2 } } \\ { { ( 1 - \hat { d } ^ { - H / 2 } ) / 2 } } \end{array}$ . Now we invoke Lemma B.1 in Section B by setting $\varepsilon = \hat { d } ^ { - H / 2 } / 2$ and $\delta = 0 . 9$ . By Lemma B.1, in order to distinguish $r _ { 1 }$ and $r _ { 2 }$ with probability at least 0.9, any algorithm requires $\Omega ( \hat { d } ^ { H } )$ samples.
Algorithm 1 Least-Squares Policy Evaluation
<table><tr><td></td><td>1: Input: policy π to be evaluated, number of samples N, regularization parameter 入 > 0</td></tr><tr><td></td><td>2:Let QH+1(·,·)=O andVH+1(-)= 0</td></tr><tr><td></td><td>forh=H,H-1,...,1do</td></tr><tr><td>4:</td><td>Take samples (s,a)~ μh,rh ~ r(s,a) and sh ~P(s,a) for eachi∈ [N]</td></tr><tr><td>5:</td><td>LetAh=∑i∈[N](sn,an)(s,a)T+λI</td></tr><tr><td>6: 7:</td><td>LetOn=An1(∑N(s,)·(nh+V+1(3))</td></tr><tr><td></td><td>Let Qn(-,) = (.,·)TOn and Vh(.)=Q(·,π())</td></tr></table>
Remark 4. The key in our construction is the state sdˆ+h in each level, whose feature vector is defined to be $\textstyle \sum _ { c \in { \hat { d } } } e _ { c } / { \hat { d } } ^ { 1 / 2 }$ . In each level, $s _ { h } ^ { \hat { d } + 1 }$ amplifies the $Q$ -value by a $\hat { d } ^ { 1 / 2 }$ factor, due to the linearity of the $Q$ -function. After all the $H$ levels, the value will be amplified by a $\hat { d } ^ { H / 2 }$ factor. Since $s _ { h } ^ { \hat { d } + 1 }$ is not in the support of the data distribution, the only way to estimate the value of the policy istimate the expected reward value in the last level. Our construction forces the estimation error of the last level to be amplified exponentially and thus implies an exponential lower bound.
# 5 UPPER BOUNDS: LOW DISTRIBUTION SHIFT OR POLICY COMPLETENESS ARE SUFFICIENT
In order to illustrate the error amplification issue and discuss conditions that permit sample-efficient offline RL, in this section, we analyze Least-Squares Policy Evaluation when applied to the offline policy evaluation problem under the realizability assumption. The algorithm is presented in Algorithm 1. For simplicity here we assume the policy $\pi$ to be evaluated is deterministic.
Notation. For each $h \in [ H ]$ , define $\Lambda _ { h } = \mathbb { E } _ { ( s , a ) \sim \mu _ { h } } \left[ \phi ( s , a ) \phi ( s , a ) ^ { \top } \right]$ to be the feature covariance matrix at level $h$ . For each $h \in [ H - 1 ]$ , define $\overline { { \Lambda } } _ { h + 1 } = \mathbb { E } _ { ( s , a ) \sim \mu _ { h } , \overline { { s } } \sim P ( \cdot \vert s , a ) } \left[ \phi ( \overline { { s } } , \pi ( \overline { { s } } ) ) \phi ( \overline { { s } } , \pi ( \overline { { s } } ) ) ^ { \top } \right]$ to be the feature covariance matrix of the one-step lookahead distribution at level $h$ . Moreover, define $\overline { { \Lambda } } _ { 1 } = \phi ( s _ { 1 } , \pi ( s _ { 1 } ) ) \phi ( s _ { 1 } , \pi ( s _ { 1 } ) ) ^ { \top }$ . We define $\Phi _ { h }$ to be a $N \times d$ matrix, whose $i$ -th row is $\phi ( s _ { h } ^ { i } , a _ { h } ^ { i } )$ , and define $\overline { { \Phi } } _ { h + 1 }$ to be another $N \times d$ matrix whose $i$ -th row is $\phi ( \overline { { s } } _ { h } ^ { i } , \pi ( \overline { { s } } _ { h } ^ { i } ) )$ . For each $h \in [ H ]$ and $i \in [ N ]$ , define $\xi _ { h } ^ { i } = r _ { h } ^ { i } + V ( \overline { { s } } _ { h } ^ { i } ) - Q ( s _ { h } ^ { i } , a _ { h } ^ { i } )$ . We use $\xi _ { h }$ to denote a vector whose $i$ -th entry is $\xi _ { h } ^ { i }$ .
Now we present a general lemma that characterizes the estimation error of Algorithm 1 by an equality. The proof can be found in Appendix D. Later, we apply this general lemma to special cases.
Lemma 5.1. Suppose $\lambda > 0$ in Algorithm $^ { l }$ , and for the given policy $\pi$ , there exists $\theta _ { 1 } , \theta _ { 2 } , \ldots , \theta _ { d } \in$ $\mathbb { R } ^ { d }$ such that for each $h \in [ H ]$ , $Q _ { h } ^ { \bar { \pi } } ( s , a ) = \phi ( s , \bar { a } ) ^ { \top } \theta _ { h }$ for all $( s , a ) \in S _ { h } \times \mathcal { A }$ . Then we have
$$( Q ^ { \pi } ( s _ { 1 } , \pi ( s _ { 1 } ) ) - \hat { Q } ( s _ { 1 } , \pi ( s _ { 1 } ) ) ) ^ { 2 } = \displaystyle \left\| \sum _ { h = 1 } ^ { H } \hat { \Lambda } _ { 1 } ^ { - 1 } \Phi _ { 1 } ^ { \top } \overline { { \Phi } } _ { 2 } \hat { \Lambda } _ { 2 } ^ { - 1 } \Phi _ { 2 } ^ { \top } \cdot \cdot \cdot ( \hat { \Lambda } _ { h } ^ { - 1 } \Phi _ { h } ^ { \top } \xi _ { h } - \lambda \hat { \Lambda } _ { h } ^ { - 1 } \theta _ { h } ) \right\| _ { \overline { { \Lambda } } _ { 1 } } ^ { 2 } .$$
Now we consider two special cases where the estimation error in Equation (1) can be upper bounded.
Low Distribution Shift. The first special we focus on is the case where the distribution shift between the data distributions and the distribution induced by the policy to be evaluated is low. To measure the distribution shift formally, our main assumption is as follows.
Assumption 3. We assume that for each $h \in [ H ]$ , there exists $C _ { h } \geq 1$ such that $\overline { { \Lambda _ { h } } } \preceq C _ { h } \Lambda _ { h }$ .
Remark 5. For each Therefore, Assumptio $h \in [ H ]$ , if be r $\sigma _ { \mathrm { m i n } } ( \Lambda _ { h } ) \succeq \frac { 1 } { C _ { h } } I$ for some ssumption $C _ { h } \geq 1$ e . $\overline { { { \Lambda } } } _ { h } \preceq I \preceq C _ { h } \Lambda _ { h }$ $C _ { h } \Lambda _ { h } \succeq I$ to the original version of Assumption 3 as it gives a tighter characterization of the distribution shift.
Now we state the theoretical guarantee of Algorithm 1. The proof can be found in Appendix D.
Theorem 5.2. Suppose for the given policy $\pi$ , there exists $\theta _ { 1 } , \theta _ { 2 } , \ldots , \theta _ { d } \ \in \ \mathbb { R } ^ { d }$ such that for√ each $h \in [ H ] , Q _ { h } ^ { \pi } ( s , a ) \ : = \ : \phi ( s , a ) ^ { \top } \theta _ { h }$ for all $( s , a ) \ \in \ S _ { h } \times { \mathcal A }$ and $\| \theta _ { h } \| _ { 2 } ~ \le ~ H \sqrt { d } .$ 4 Let $\lambda = C H \sqrt { d \log ( d H / \delta ) N }$ for some $C > 0$ . With probability at least $1 - \delta$ , for some $c > 0$ , $\begin{array} { r } { ( Q _ { 1 } ^ { \pi } ( s _ { 1 } , \pi ( s _ { 1 } ) ) - \hat { Q } _ { 1 } ( s _ { 1 } , \pi ( s _ { 1 } ) ) ) ^ { 2 } \leq c \cdot \prod _ { h = 1 } ^ { H } C _ { h } \cdot d H ^ { 5 } \cdot \sqrt { d \log ( d H / \delta ) / N } } \end{array}$ .
Remark 6. The factor $\textstyle \prod _ { h = 1 } ^ { H } C _ { h }$ in Theorem 5.2 implies that the estimation error will be amplified geometrically. Now we discuss how the error is amplified when running Algorithm 1 on the instance in Section 4 to better illustrate the issue. If we run Algorithm 1 on the hard instance in Section 4, when $h = H$ , the estimation error on $V ( s _ { H } ^ { c } )$ would be roughly $N ^ { - 1 / 2 }$ for each $c \in [ \hat { d } ]$ . When using the linear predictor at level $H$ to predict the value of $s _ { H } ^ { * }$ , the error will be amplified by $\hat { d } ^ { 1 / 2 }$ . When $h = H - 1$ , the dataset contains only $s _ { H - 1 } ^ { c }$ for $c \in [ \hat { d } ]$ , and the estimation error on the value of $s _ { H - 1 } ^ { c }$ will be the same as that of $s _ { H } ^ { * }$ , which is roughly $( \hat { d } / N ) ^ { 1 / 2 }$ . Again, the estimation error on the value of $s _ { H - 1 } ^ { * }$ will be $( \hat { d } ^ { 2 } / N ) ^ { 1 / 2 }$ when using the linear predictor at level $H - 1$ . The error will eventually be amplified by a factor of $\hat { d } ^ { H / 2 }$ , which corresponds to the factor $\textstyle \prod _ { h = 1 } ^ { H } C _ { h }$ in Theorem 5.2.
Policy Completeness. In offline RL, another representation condition is closedness under Bellman update (Szepesvari & Munos, 2005; Duan & Wang, 2020), which is stronger than realizability. In ´ the context of offline policy evaluation, we have the following policy completeness assumption.
Assumption 4. For the given policy $\pi$ , for any $h > 1$ and $\theta _ { h } \in \mathbb { R } ^ { d }$ , there exists $\theta ^ { \prime } \in \mathbb { R } ^ { d }$ such that for any $\begin{array} { r } { ( s , a ) \in \mathcal S _ { h - 1 } \times \mathcal A , \mathbb E [ R ( s , a ) ] + \sum _ { s ^ { \prime } \in { \cal S } _ { h } } P ( s ^ { \prime } \mid s , a ) \phi ( s ^ { \prime } , \pi ( s ^ { \prime } ) ) ^ { \top } \theta _ { h } = \phi ( s , a ) ^ { \top } \theta ^ { \prime } . } \end{array}$ .
Under Assumption 4 and the assumption that $\sigma _ { \operatorname* { m i n } } ( \Lambda _ { h } ) \geq \lambda _ { 0 }$ for all $h \in [ H ]$ for some $\lambda _ { 0 } > 0$ , Duan & Wang (2020) have shown that for Algorithm 1, by taking $N = \mathrm { p o l } \bar { \mathrm { y } } ( \bar { H } , d , 1 / \varepsilon , 1 / \lambda _ { 0 } )$ , we have $( Q _ { 1 } ^ { \pi } ( s _ { 1 } , \pi ( s _ { 1 } ) ) - \hat { Q } _ { 1 } ( s _ { 1 } , \pi ( s _ { 1 } ) ) ) ^ { 2 } \leq \varepsilon$ . We refer interested readers to (Duan & Wang, 2020).
We remark that the above analysis again implies that geometric error amplification is a real issue in offline RL, and sample-efficient offline RL is impossible unless the distribution shift is sufficiently low, i.e., $\textstyle \prod _ { h = 1 } ^ { H } C _ { h }$ is bounded, or strong representation condition (e.g. policy completeness) holds.
# 6 CONCLUSION
While the extant body of provable results in the literature largely focus on sufficient conditions for sample-efficient offline RL, this work focuses on obtaining a better understanding of the necessary conditions, where we seek to understand to what extent mild assumptions can imply sample-efficient offline RL. This work shows that for off-policy evaluation, even if we are given a representation that can perfectly represent the value function of the given policy and the data distribution has good coverage over the features, any provable algorithm still requires an exponential number of samples to non-trivially approximate the value of the given policy. These results highlight that provable sample-efficient offline RL is simply not possible unless either the distribution shift condition is sufficiently mild or we have stronger representation conditions that go well beyond realizability.
# ACKNOWLEDGMENTS
The authors would like to thank Akshay Krishnamurthy, Alekh Agarwal, Wen Sun, and Nan Jiang for numerous helpful discussion. Sham M. Kakade gratefully acknowledges funding from the ONR award N00014-18-1-2247, and NSF Awards CCF-1703574 and CCF-1740551. Ruosong Wang was supported in part by the NSF IIS1763562, US Army W911NF1920104, and ONR Grant N000141812861. Research performed while Ruosong Wang was an intern at Microsoft Research.
# REFERENCES
Rishabh Agarwal, Dale Schuurmans, and Mohammad Norouzi. An optimistic perspective on offline reinforcement learning. In International Conference on Machine Learning, 2020.
Martin Anthony and Peter L Bartlett. Neural network learning: Theoretical foundations. cambridge university press, 2009.
Andras Antos, Csaba Szepesv ´ ari, and R ´ emi Munos. Learning near-optimal policies with bellman- ´ residual minimization based fitted policy iteration and a single sample path. Machine Learning, 71(1):89–129, 2008.
Keith Ball. An elementary introduction to modern convex geometry. Flavors of geometry, 31:1–58, 1997.
Dimitri P Bertsekas and John N Tsitsiklis. Neuro-dynamic programming: an overview. In Proceedings of 1995 34th IEEE Conference on Decision and Control, volume 1, pp. 560–564. IEEE, 1995.
Sebastien Bubeck, Nicol ´ o Cesa-Bianchi, and Sham M. Kakade. Towards minimax policies for \` online linear optimization with bandit feedback. In COLT 2012 - The 25th Annual Conference on Learning Theory, June 25-27, 2012, Edinburgh, Scotland, volume 23 of JMLR Proceedings, pp. 41.1–41.14, 2012.
Jinglin Chen and Nan Jiang. Information-theoretic considerations in batch reinforcement learning. In International Conference on Machine Learning, pp. 1042–1051, 2019.
Herman Chernoff. Sequential analysis and optimal design. SIAM, 1972.
Simon S. Du, Sham M. Kakade, Ruosong Wang, and Lin F. Yang. Is a good representation sufficient for sample efficient reinforcement learning? In International Conference on Learning Representations, 2020.
Yaqi Duan and Mengdi Wang. Minimax-optimal off-policy evaluation with linear function approximation. arXiv preprint arXiv:2002.09516, 2020.
Miroslav Dud´ık, John Langford, and Lihong Li. Doubly robust policy evaluation and learning. In Proceedings of the 28th International Conference on International Conference on Machine Learning, pp. 1097–1104, 2011.
Mehrdad Farajtabar, Yinlam Chow, and Mohammad Ghavamzadeh. More robust doubly robust off-policy evaluation. In International Conference on Machine Learning, pp. 1447–1456, 2018.
Yihao Feng, Tongzheng Ren, Ziyang Tang, and Qiang Liu. Accountable off-policy evaluation with kernel bellman statistics. arXiv preprint arXiv:2008.06668, 2020.
Scott Fujimoto, David Meger, and Doina Precup. Off-policy deep reinforcement learning without exploration. In International Conference on Machine Learning, pp. 2052–2062, 2019.
Geoffrey J Gordon. Stable function approximation in dynamic programming. In Machine Learning Proceedings 1995, pp. 261–268. Elsevier, 1995.
Geoffrey J Gordon. Stable fitted reinforcement learning. In Advances in neural information processing systems, pp. 1052–1058, 1996.
Geoffrey J Gordon. Approximate solutions to markov decision processes. Technical report, CARNEGIE-MELLON UNIV PITTSBURGH PA SCHOOL OF COMPUTER SCIENCE, 1999.
Omer Gottesman, Fredrik Johansson, Joshua Meier, Jack Dent, Donghun Lee, Srivatsan Srinivasan, Linying Zhang, Yi Ding, David Wihl, Xuefeng Peng, Jiayu Yao, Isaac Lage, Christopher Mosch, Li wei H. Lehman, Matthieu Komorowski, Matthieu Komorowski, Aldo Faisal, Leo Anthony Celi, David Sontag, and Finale Doshi-Velez. Evaluating reinforcement learning algorithms in observational health settings, 2018.
Zhaohan Guo, Philip S Thomas, and Emma Brunskill. Using options and covariance testing for long horizon off-policy policy evaluation. In Advances in Neural Information Processing Systems, pp. 2492–2501, 2017.
Daniel Hsu, Sham Kakade, Tong Zhang, et al. A tail inequality for quadratic forms of subgaussian random vectors. Electronic Communications in Probability, 17, 2012a.
Daniel Hsu, Sham M Kakade, and Tong Zhang. Random design analysis of ridge regression. In Conference on learning theory, pp. 9–1, 2012b.
Natasha Jaques, Asma Ghandeharioun, Judy Hanwen Shen, Craig Ferguson, Agata Lapedriza, Noah Jones, Shixiang Gu, and Rosalind Picard. Way off-policy batch deep reinforcement learning of human preferences in dialog, 2020. URL https://openreview.net/forum?id $=$ rJl5rRVFvH.
Nan Jiang and Jiawei Huang. Minimax confidence interval for off-policy evaluation and policy optimization. arXiv preprint arXiv:2002.02081, 2020.
Nan Jiang and Lihong Li. Doubly robust off-policy value evaluation for reinforcement learning. In International Conference on Machine Learning, pp. 652–661. PMLR, 2016.
Sham Machandranath Kakade. On the sample complexity of reinforcement learning. PhD thesis, University of London London, England, 2003.
Nathan Kallus and Masatoshi Uehara. Efficiently breaking the curse of horizon in off-policy evaluation with double reinforcement learning. arXiv preprint arXiv:1909.05850, 2019.
Nathan Kallus and Masatoshi Uehara. Double reinforcement learning for efficient off-policy evaluation in markov decision processes. Journal of Machine Learning Research, 21(167):1–63, 2020.
Emilie Kaufmann, Olivier Cappe, and Aur ´ elien Garivier. On the complexity of best-arm identifi- ´ cation in multi-armed bandit models. The Journal of Machine Learning Research, 17(1):1–42, 2016.
Rahul Kidambi, Aravind Rajeswaran, Praneeth Netrapalli, and Thorsten Joachims. Morel $:$ Modelbased offline reinforcement learning, 2020.
Akshay Krishnamurthy, Alekh Agarwal, and John Langford. Pac reinforcement learning with rich observations. In Advances in Neural Information Processing Systems, pp. 1840–1848, 2016.
Aviral Kumar, Justin Fu, Matthew Soh, George Tucker, and Sergey Levine. Stabilizing off-policy q-learning via bootstrapping error reduction. neural information processing systems, pp. 11761– 11771, 2019.
Aviral Kumar, Abhishek Gupta, and Sergey Levine. Discor: Corrective feedback in reinforcement learning via distribution correction. arXiv preprint arXiv:2003.07305, 2020.
Michail G Lagoudakis and Ronald Parr. Least-squares policy iteration. Journal of machine learning research, 4(Dec):1107–1149, 2003.
Romain Laroche, Paul Trichelair, and Remi Tachet des Combes. Safe policy improvement with ´ baseline bootstrapping. In Proceedings of the 36th International Conference on Machine Learning (ICML), 2019.
Lihong Li, Remi Munos, and Csaba Szepesvari. Toward minimax off-policy value estimation. In Artificial Intelligence and Statistics, pp. 608–616, 2015.
Qiang Liu, Lihong Li, Ziyang Tang, and Dengyong Zhou. Breaking the curse of horizon: Infinitehorizon off-policy estimation. In Advances in Neural Information Processing Systems, pp. 5356– 5366, 2018.
Yao Liu, Pierre-Luc Bacon, and Emma Brunskill. Understanding the curse of horizon in off-policy evaluation via conditional importance sampling. arXiv preprint arXiv:1910.06508, 2019.
Travis Mandel, Yun-En Liu, Sergey Levine, Emma Brunskill, and Zoran Popovic. Offline policy evaluation across representations with applications to educational games. In AAMAS, pp. 1077– 1084, 2014.
Shie Mannor and John N Tsitsiklis. The sample complexity of exploration in the multi-armed bandit problem. Journal of Machine Learning Research, 5(Jun):623–648, 2004.
Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Andrei A Rusu, Joel Veness, Marc G Bellemare, Alex Graves, Martin Riedmiller, Andreas K Fidjeland, Georg Ostrovski, et al. Human-level control through deep reinforcement learning. Nature, 518(7540):529, 2015.
Wenlong Mou, Zheng Wen, and Xi Chen. On the sample complexity of reinforcement learning with policy space generalization. arXiv preprint arXiv:2008.07353, 2020.
Remi Munos. Error bounds for approximate policy iteration. In ´ ICML, volume 3, pp. 560–567, 2003.
Remi Munos and Andrew W Moore. Barycentric interpolators for continuous space and time reinforcement learning. In Advances in neural information processing systems, pp. 1024–1030, 1999.
Remi Munos and Csaba Szepesv ´ ari. Finite-time bounds for fitted value iteration. ´ Journal of Machine Learning Research, 9(May):815–857, 2008.
Dirk Ormoneit and Saunak Sen. Kernel-based reinforcement learning. ´ Machine learning, 49(2-3): 161–178, 2002.
Doina Precup. Eligibility traces for off-policy policy evaluation. Computer Science Department Faculty Publication Series, pp. 80, 2000.
Stephane Ross and Drew Bagnell. Agnostic system identification for model-based reinforcement ´ learning. In Proceedings of the 29th International Conference on Machine Learning, ICML 2012, Edinburgh, Scotland, UK, June 26 - July 1, 2012. icml.cc / Omnipress, 2012.
Wen Sun, Arun Venkatraman, Geoffrey J Gordon, Byron Boots, and J Andrew Bagnell. Deeply aggrevated: Differentiable imitation learning for sequential prediction. In International Conference on Machine Learning, pp. 3309–3318, 2017.
Csaba Szepesvari and R ´ emi Munos. Finite time bounds for sampling based fitted value iteration. In ´ Proceedings of the 22nd international conference on Machine learning, pp. 880–887, 2005.
Philip Thomas and Emma Brunskill. Data-efficient off-policy policy evaluation for reinforcement learning. In International Conference on Machine Learning, pp. 2139–2148, 2016.
Philip S. Thomas. Safe reinforcement learning. PhD thesis, University of Massachusetts, Amherst, 2014.
Philip S Thomas, Georgios Theocharous, and Mohammad Ghavamzadeh. High-confidence offpolicy evaluation. In Twenty-Ninth AAAI Conference on Artificial Intelligence, 2015.
Philip S. Thomas, Bruno Castro da Silva, Andrew G. Barto, Stephen Giguere, Yuriy Brun, and Emma Brunskill. Preventing undesirable behavior of intelligent machines. Science, 366(6468): 999–1004, 2019. ISSN 0036-8075. doi: 10.1126/science.aag3311.
Samuele Tosatto, Matteo Pirotta, Carlo d’Eramo, and Marcello Restelli. Boosted fitted q-iteration. In International Conference on Machine Learning, pp. 3434–3443. PMLR, 2017.
Joel A Tropp. An introduction to matrix concentration inequalities. Foundations and Trends $\textsuperscript { \textregistered }$ in Machine Learning, 8(1-2):1–230, 2015.
J Tsitsiklis and B Van Roy. An analysis of temporal-difference learning with function approximation (technical report lids-p-2322). Laboratory for Information and Decision Systems, 1996.
Masatoshi Uehara and Nan Jiang. Minimax weight and q-function learning for off-policy evaluation. arXiv preprint arXiv:1910.12809, 2019.
Benjamin Van Roy. Feature-based methods for large scale dynamic programming. PhD thesis, Massachusetts Institute of Technology, 1994.
L. Wang, Wei Zhang, Xiaofeng He, and H. Zha. Supervised reinforcement learning with recurrent neural network for dynamic treatment recommendation. Proceedings of the 24th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, 2018.
Ruosong Wang, Simon S Du, Lin F Yang, and Ruslan Salakhutdinov. On reward-free reinforcement learning with linear function approximation. arXiv preprint arXiv:2006.11274, 2020.
Yu-Xiang Wang, Alekh Agarwal, and Miroslav Dudık. Optimal and adaptive off-policy evaluation in contextual bandits. In International Conference on Machine Learning, pp. 3589–3597. PMLR, 2017.
Yifan Wu, George Tucker, and Ofir Nachum. Behavior regularized offline reinforcement learning, 2020. URL https://openreview.net/forum?id ${ . } = { }$ BJg9hTNKPH.
Tengyang Xie and Nan Jiang. Batch value-function approximation with only realizability. arXiv preprint arXiv:2008.04990, 2020a.
Tengyang Xie and Nan Jiang. $Q ^ { \star }$ approximation schemes for batch reinforcement learning: A theoretical comparison. arXiv preprint arXiv:2003.03924, 2020b.
Tengyang Xie, Yifei Ma, and $\mathrm { Y u }$ -Xiang Wang. Towards optimal off-policy evaluation for reinforcement learning with marginalized importance sampling. In Advances in Neural Information Processing Systems, pp. 9668–9678, 2019.
C. Yu, G. Ren, and J. Liu. Deep inverse reinforcement learning for sepsis treatment. In 2019 IEEE International Conference on Healthcare Informatics (ICHI), pp. 1–3, 2019.
Andrea Zanette, Alessandro Lazaric, Mykel J Kochenderfer, and Emma Brunskill. Limiting extrapolation in linear approximate value iteration. In Advances in Neural Information Processing Systems, pp. 5616–5625, 2019.
# A PROOF OF LEMMA 4.2
Proof. We first verify $Q ^ { \pi }$ is linear for the first $H - 1$ levels. For each $( h , c ) \in [ H - 1 ] \times [ \hat { d } ]$ , we have
$$Q _ { h } ^ { \pi } ( s _ { h } ^ { c } , a _ { 1 } ) = R ( s _ { h } ^ { c } , a _ { 1 } ) + R ( s _ { h + 1 } ^ { \hat { d } + 1 } , a _ { 1 } ) + R ( s _ { h + 2 } ^ { \hat { d } + 1 } , a _ { 1 } ) + \ldots + R ( s _ { H } ^ { \hat { d } + 1 } , a _ { 1 } ) = r _ { 0 } \cdot \hat { d } ^ { ( H - h ) / 2 } .$$
Moreover, for all $a \in { \mathcal { A } }$ ,
$$\begin{array} { r } { \mathcal { Q } _ { h } ^ { \pi } ( s _ { h } ^ { \hat { d } + 1 } , a ) = R ( s _ { h } ^ { \hat { d } + 1 } , a ) + R ( s _ { h + 1 } ^ { \hat { d } + 1 } , a _ { 1 } ) + R ( s _ { h + 2 } ^ { \hat { d } + 1 } , a _ { 1 } ) + . . . + R ( s _ { H } ^ { \hat { d } + 1 } , a _ { 1 } ) = r _ { 0 } \cdot \hat { d } ^ { ( H - h + 1 ) / 2 } . } \end{array}$$
Therefore, if we define
$$\boldsymbol { \theta } _ { h } ^ { \pi } = \sum _ { c = 1 } ^ { \hat { d } } \boldsymbol { r } _ { 0 } \cdot \hat { d } ^ { ( H - h ) / 2 } \cdot \boldsymbol { e } _ { c } + \sum _ { c = 1 } ^ { \hat { d } } Q _ { h } ^ { \pi } ( s _ { h } ^ { c } , a _ { 2 } ) \cdot \boldsymbol { e } _ { c + \hat { d } } ,$$
then $Q _ { h } ^ { \pi } ( s , a ) = \left( \theta _ { h } ^ { \pi } \right) ^ { \top } \phi ( s , a )$ for all $( s , a ) \in S _ { h } \times \mathcal { A }$
Now we verify that the $Q$ -function is linear for the last level. Clearly, for all $c \in [ \hat { d } ]$ and $a \in { \mathcal { A } }$ , $Q _ { H } ^ { \pi } ( s _ { H } ^ { c } , a ) = r _ { 0 }$ and $Q _ { H } ^ { \pi } ( s _ { H } ^ { \hat { d } + 1 } , a ) = r _ { 0 } \cdot \sqrt { \hat { d } }$ . Thus by defining $\begin{array} { r } { \theta _ { H } ^ { \pi } = \sum _ { c = 1 } ^ { d } r _ { 0 } \cdot e _ { c } } \end{array}$ , we have $Q _ { H } ^ { \pi } ( s , a ) = \left( \theta _ { H } ^ { \pi } \right) ^ { \top } \phi ( s , a )$ for all $( s , a ) \in { \cal S } _ { H } \times \mathcal { A }$ .
# B A TECHNICAL LEMMA
We need the following lemma in the proof of our hardness results.
Lemma B.1. Let α be a random variable uniformly distributed on $\{ \alpha _ { + } , \alpha _ { - } \}$ , where $\alpha _ { - } = 1 / 2$ and $\alpha _ { + } = 1 / 2 + \varepsilon$ with $0 < \varepsilon < 1$ . Suppose that $\xi _ { 1 } , \xi _ { 2 } , \ldots , \xi _ { m }$ are i.i.d. $\{ + 1 , - 1 \}$ -valued random variables with $\operatorname* { P r } [ \xi _ { i } = + 1 ] = \alpha$ for all $i \in [ m ]$ . Let $f$ be a function from $\bar { \{ + 1 , - 1 \} } ^ { m }$ to $\{ \alpha _ { + } , \alpha _ { - } \}$ . Suppose $m \le C / \varepsilon ^ { 2 } \log ( 1 / \delta )$ for some fixed constant $C$ . Then
$$\operatorname* { P r } [ f ( \xi _ { 1 } , \xi _ { 2 } , \ldots , \xi _ { m } ) \neq \alpha ] > \delta .$$
To our best knowledge, Lemma B.1 was first proved in (Chernoff, 1972) and has enormous applications in statistical learning theory (see, e.g., Chapter 5 in (Anthony & Bartlett, 2009)) and bandits (Mannor & Tsitsiklis, 2004).
To prove Lemma B.1, one can first prove that the maximum likelihood estimator (MLE) is optimal and then show that MLE requires $\dot { \Omega ( 1 / \varepsilon ^ { 2 } \log ( 1 / \delta ) ) }$ samples to correctly output $\alpha$ with probability $1 - \delta$ by anti-concentration. Lemma B.1 can also be proved by using information theory. See, e.g., (Kaufmann et al., 2016) for such a proof.
# C ANOTHER HARD INSTANCE
In this section, we present another hard case under a weaker version of Assumption 1. Here the transition operator is stochastic and the reward is deterministic and sparse, meaning that the reward value is non-zero only for the last level. Moreover, the data distributions $\{ \mu _ { h } \} _ { h = 1 } ^ { H }$ are induced by a fixed policy $\pi _ { \mathrm { d a t a } }$ . We also illustrate the construction in Figure 2. Throughout this section, we use $d$ the denote the feature dimension, and we assume $d$ is an even integer for simplicity. We use $\hat { d }$ to denote $d / 2 - 1$ .
In this section, we adopt the following realizability assumption, which is a weaker version of Assumption 1.
Assumption 5 (Realizability). For the policy $\pi : { \mathcal { S } } \to \Delta ( { \mathcal { A } } )$ to be evaluated, there exists $\theta _ { 1 } , \ldots \theta _ { H } \in \mathbb { R } ^ { d }$ such that for all $( s , a ) \in S \times A$ and $h \in [ H ]$ ,
$$Q _ { h } ^ { \pi } ( s , a ) = \theta _ { h } ^ { \top } \phi ( s , a ) .$$
 Figure 2: An illustration of the hard instance. Recall that $\hat { d } = d / 2 - 1$ . States on the top are those in the first level $( h = 1 )$ ), while states at the bottom are those in the last level ( $h = H$ ). Dotted line (with arrow) corresponds to transitions associated with actions $a _ { 1 } , a _ { 2 } , \ldots , a _ { \hat { d } }$ , while solid line (with arrow) corresponds to transitions associated with actions $a _ { \hat { d } + 1 } , a _ { \hat { d } + 2 } , \dotsc , a _ { d }$ . We omit the transition associated with $a _ { 1 } , a _ { 2 } , \ldots , a _ { \hat { d } }$ in the figure if all actions give the same transition. For each level $h \in [ H ]$ , $Q$ -values associated with $s _ { h } ^ { 1 } , s _ { h } ^ { 2 } , \ldots , s _ { h } ^ { \hat { d } } , s _ { h } ^ { + } , s _ { h } ^ { - }$ , sdˆh, s+h , s−h are marked on the left, while transition distributions and $Q$ -values associated with + − $s _ { h } ^ { \hat { d } + 1 }$ are marked on the right. Rewards are all deterministic, and the only two states ) with non-zero reward values are marked in black and grey. Consider the fixed policy that returns $\mathit { a } _ { d }$ for all input states. When $r _ { 0 } = 0$ , the value of the policy is 0. When $r _ { 0 } = \hat { d } ^ { - ( \bar { H } - 2 ) / 2 }$ , the value of the policy $s = r _ { 0 } \hat { d } ^ { ( H - 2 ) / 2 } = 1$ .
State Space, Action Space and Transition Operator. In this hard case, the action space ${ \mathcal { A } } =$ $\{ a _ { 1 } , a _ { 2 } , \ldots , a _ { d } \}$ contains $d$ elements. $S _ { 1 }$ contains a single state $s _ { 1 }$ . For each $h \geq 2$ , $S _ { h }$ contains ${ \hat { d } } + 3$ states $s _ { h } ^ { 1 } , s _ { h } ^ { 2 } , \ldots , s _ { h } ^ { \hat { d } } , s _ { h } ^ { \hat { d } + 1 } , s _ { h } ^ { + }$ and $s _ { h } ^ { - }$ .
Let $0 \leq r _ { 0 } \leq \hat { d } ^ { - ( H - 2 ) / 2 }$ be a parameter to be determined. We first define the transition operator for the first level. We have
$$P ( s _ { 1 } , a ) = \left\{ \begin{array} { l l } { s _ { 2 } ^ { c } } & { a = a _ { c } , c \in [ \hat { d } ] } \\ { s _ { 2 } ^ { + } } & { a = a _ { \hat { d } + 1 } } \\ { s _ { 2 } ^ { - } } & { a = a _ { \hat { d } + 2 } } \\ { s _ { 2 } ^ { \hat { d } + 1 } } & { a \in \{ a _ { \hat { d } + 3 } , a _ { \hat { d } + 4 } , \dots , a _ { d } \} } \end{array} \right. .$$
Now we define the transition operator when $h \in \{ 2 , 3 , \ldots , H - 2 \}$ . For each $h \in \{ 2 , 3 , \ldots , H - 2 \}$ , $a \in { \mathcal { A } }$ and $c \in [ \hat { d } ]$ , we have $P ( s _ { h } ^ { c } , a ) = s _ { h + 1 } ^ { \hat { d } + 1 }$ , $P ( s _ { h } ^ { + } , a ) = s _ { h + 1 } ^ { + }$ and $P ( s _ { h } ^ { - } , a ) = s _ { h + 1 } ^ { - }$ . For each $h \in \{ 2 , 3 , \ldots , H - 2 \}$ and $c \in [ \hat { d } ]$ , we have $P ( s _ { h } ^ { \hat { d } + 1 } , a _ { c } ) = s _ { h + 1 } ^ { c }$ . For all $a \in \left\{ a _ { \hat { d } + 1 } , a _ { \hat { d } + 2 } , \dotsc , a _ { d } \right\}$ ,
we have
$$P \left( s _ { h } ^ { \hat { d } + 1 } , a \right) = \left\{ \begin{array} { l l } { s _ { h + 1 } ^ { + } } & { \mathrm { w i t h ~ p r o b a b i l i t y ~ } ( 1 + r _ { 0 } \cdot \hat { d } ^ { ( H - h ) / 2 } ) / 2 } \\ { s _ { h + 1 } ^ { - } } & { \mathrm { w i t h ~ p r o b a b i l i t y ~ } ( 1 - r _ { 0 } \cdot \hat { d } ^ { ( H - h ) / 2 } ) / 2 } \end{array} \right. .$$
Now we define the transition operator for the second last level. For all $c \in [ \hat { d } ]$ and $a \in { \mathcal { A } }$ , we have
$$P ( s _ { H - 1 } ^ { c } , a ) = \left\{ \begin{array} { l l } { s _ { H } ^ { + } } & { \mathrm { w i t h ~ p r o b a b i l i t y ~ } ( 1 + r _ { 0 } ) / 2 } \\ { s _ { H } ^ { - } } & { \mathrm { w i t h ~ p r o b a b i l i t y ~ } ( 1 - r _ { 0 } ) / 2 } \end{array} \right. .$$
For all $a \in { \mathcal { A } }$ , we have $P ( s _ { H - 1 } ^ { + } , a ) = s _ { H } ^ { + }$ and $P ( s _ { H - 1 } ^ { - } , a ) \ = \ s _ { H } ^ { - }$ . For each $c \in [ \hat { d } ]$ , we have $P ( s _ { H - 1 } ^ { \hat { d } + 1 } , a _ { c } ) = s _ { H } ^ { c }$ . For all $a \in \left\{ a _ { \hat { d } + 1 } , a _ { \hat { d } + 2 } , \dotsc , a _ { d } \right\}$ , we have
$$P ( s _ { H - 1 } ^ { \hat { d } + 1 } , a ) = \left\{ \begin{array} { l l } { s _ { H } ^ { + } } & { \mathrm { w i t h } \mathrm { p r o b a b i l i t y } \left( 1 + r _ { 0 } \cdot \sqrt { \hat { d } } \right) / 2 } \\ { s _ { H } ^ { - } } & { \mathrm { w i t h } \mathrm { p r o b a b i l i t y } \left( 1 - r _ { 0 } \cdot \sqrt { \hat { d } } \right) / 2 } \end{array} \right. .$$
Reward Values. In this hard case, all reward values are deterministic, and reward values can be non-zero only for the last level. Formally, we have
$$R ( s , a ) = \left\{ { \begin{array} { l l } { 1 } & { s = s _ { H } ^ { + } } \\ { - 1 } & { s = s _ { H } ^ { - } } \\ { 0 } & { { \mathrm { o t h e r w i s e } } } \end{array} } \right. .$$
Feature Mapping. As in the in hard instance in Section 4, let $e _ { 1 } , e _ { 2 } , \ldots , e _ { d }$ be a set of of orthonormal vectors in $\mathbb { R } ^ { d }$ . For the initial state, for each $c \in [ d ]$ , we have $\phi ( s _ { 1 } , a _ { c } ) = e _ { c }$ .
Now we define the feature mapping when $h \in \{ 2 , 3 , \ldots , H \}$ . For each $h \in \{ 2 , 3 , \ldots , H \}$ , $a \in { \mathcal { A } }$ and $c \in [ \hat { d } ] , \phi ( s _ { h } ^ { c } , a ) = e _ { c } , \phi ( s _ { h } ^ { + } , a ) = e _ { \hat { d } + 1 }$ and $\phi ( s _ { h } ^ { - } , a ) = e _ { \hat { d } + 2 }$ . Moreover, for all actions $a \in { \mathcal { A } }$ ,
$$\phi ( s _ { h } ^ { \hat { d } + 1 } , a ) = \left\{ { \begin{array} { l l } { e _ { \hat { d } + 2 + c } } & { a = a _ { c } , c \in [ { \hat { d } } ] } \\ { { \frac { 1 } { d ^ { 1 / 2 } } } \left( e _ { 1 } + e _ { 2 } + \ldots + e _ { \hat { d } } \right) } & { a \in \left\{ a _ { \hat { d } + 1 } , a _ { \hat { d } + 2 } , \ldots , a _ { d } \right\} } \end{array} } \right. .$$
Clearly, for all (s, a) ∈ S × A, $\| \phi ( s , a ) \| _ { 2 } \leq 1$ .
Verifying Assumption 5. Now we consider the deterministic policy $\pi : { \mathcal { S } } A$ , which is defined to be $\pi ( s ) = a _ { d }$ for all $s \in S$ . We show that Assumption 5 holds.
When $h = 1$ , define
$$\theta _ { 1 } = \sum _ { c = 1 } ^ { \hat { d } } r _ { 0 } \cdot \hat { d } ^ { ( H - 3 ) / 2 } \cdot e _ { c } + e _ { \hat { d } + 1 } - e _ { \hat { d } + 2 } + \sum _ { c = 1 } ^ { \hat { d } } r _ { 0 } \cdot \hat { d } ^ { ( H - 2 ) / 2 } \cdot e _ { \hat { d } + 2 + c } .$$
For each $h \in \{ 2 , 3 , \ldots , H - 2 \}$ , define
$$\theta _ { h } = \sum _ { c = 1 } ^ { \hat { d } } r _ { 0 } \cdot \hat { d } ^ { ( H - h - 1 ) / 2 } \cdot e _ { c } + e _ { \hat { d } + 1 } - e _ { \hat { d } + 2 } + \sum _ { c = 1 } ^ { \hat { d } } r _ { 0 } \cdot \hat { d } ^ { ( H - h - 2 ) / 2 } \cdot e _ { \hat { d } + 2 + c } .$$
For the second last level $h = H - 1$ , define
$$\theta _ { H - 1 } = \sum _ { c = 1 } ^ { \hat { d } } r _ { 0 } \cdot e _ { c } + e _ { \hat { d } + 1 } - e _ { \hat { d } + 2 } .$$
Finally, for the last level $h = H$ , define
$$\theta _ { H } = e _ { \hat { d } + 1 } - e _ { \hat { d } + 2 } .$$
It can be verified that for each $h \in [ H ]$ , $Q _ { h } ^ { \pi } ( s , a ) = \theta _ { h } ^ { \top } \phi ( s , a )$ for all $( s , a ) \in S _ { h } \times \mathcal { A }$ .
The Data Distributions. For the first level, the data distribution $\mu _ { 1 }$ is defined to be the uniform distribution over $\{ ( s _ { 1 } , a _ { c } ) ~ | ~ c ~ \in ~ [ d ] \}$ . For each $h \geq 2$ , the data distribution $\mu _ { h }$ is a uniform distribution over
$$\{ ( s _ { h } ^ { 1 } , a _ { 1 } ) , ( s _ { h } ^ { 2 } , a _ { 1 } ) , \ldots , ( s _ { h } ^ { \hat { d } } , a _ { 1 } ) , ( s _ { h } ^ { + } , a _ { 1 } ) , ( s _ { h } ^ { - } , a _ { 1 } ) , ( s _ { h } ^ { \hat { d } + 1 } , a _ { 1 } ) , ( s _ { h } ^ { \hat { d } + 1 } , a _ { 2 } ) , \ldots , ( s _ { h } ^ { \hat { d } + 1 } , a _ { \hat { d } } ) \} .$$
Notice that again $( s _ { h } ^ { \hat { d } + 1 } , a )$ is not in the support of $\mu _ { h }$ for all actions $a \in \left\{ a _ { \hat { d } + 1 } , a _ { \hat { d } + 2 } , \dotsc , a _ { d } \right\}$ . It can be seen that for all $h \in [ H ]$ ,
$$\mathbb { E } _ { ( s , a ) \sim \mu _ { h } } [ \phi ( s , a ) \phi ( s , a ) ^ { \top } ] = \frac { 1 } { d } \sum _ { c = 1 } ^ { d } e _ { c } e _ { c } ^ { \top } = \frac { 1 } { d } I .$$
Moreover, by defining
$$\pi _ { \operatorname* { d a t a } } ( s ) = \left\{ \begin{array} { l l } { \operatorname { U n i f o r m } ( A ) } & { s = s _ { 1 } } \\ { a _ { 1 } } & { s \in \{ s _ { h } ^ { c } \mid h \in \{ 2 , 3 , \ldots , H \} , c \in [ \hat { d } ] \} } \\ { a _ { 1 } } & { s \in \{ s _ { h } ^ { + } \mid h \in \{ 2 , 3 , \ldots , H \} \} } \\ { a _ { 1 } } & { s \in \{ s _ { h } ^ { - } \mid h \in \{ 2 , 3 , \ldots , H \} \} } \\ { \operatorname { U n i f o r m } ( \{ a _ { 1 } , a _ { 2 } , \ldots , a _ { \hat { d } } \} ) } & { s \in \{ s _ { h } ^ { \hat { d } + 1 } \mid h \in \{ 2 , 3 , \ldots , H \} \} } \end{array} \right. ,$$
we have $\mu _ { h } = \mu _ { h } ^ { \pi _ { \mathrm { d a t a } } }$ for all $h \in [ H ]$
The Lower Bound. Now we show that it is information-theoretically hard for any algorithm to distinguish the case $r _ { 0 } = 0$ and $r _ { 0 } = \hat { d } ^ { - ( H - 2 ) / 2 }$ in the offline setting by taking samples from the data distributions $\{ \mu _ { h } \} _ { h = 1 } ^ { H }$ . Here we consider the above policy $\pi$ defined above which returns action $a _ { d }$ for all input states. Notice that when $r _ { 0 } = 0$ , the value of the policy would be zero. On the other hand, when $\stackrel { \cdot } { r } _ { 0 } = \hat { d } ^ { - ( H - 2 ) / 2 }$ , the value of the policy would be $r _ { 0 } \cdot \hat { d } ^ { ( \overleftarrow { H } - 2 ) / 2 } = 1 .$ . Therefore, if the algorithm approximates the value of the policy up to an approximation error of $1 / 2$ , then it must distinguish the case that $r _ { 0 } = 0$ and $r _ { 0 } = \hat { d } ^ { - ( H - 2 ) / 2 }$ .
We first notice that for the case $r _ { 0 } = 0$ and $r _ { 0 } = \hat { d } ^ { - ( H - 2 ) / 2 }$ , the data distributions $\{ \mu _ { h } \} _ { h = 1 } ^ { H }$ , the feature mapping $\phi : \mathcal { S } \times \mathcal { A } \mathbb { R } ^ { d }$ , the policy $\pi$ to be evaluated and the reward distributions $R$ are the same. Thus, in order to distinguish the case $r _ { 0 } = 0$ and $r _ { 0 } = \hat { d } ^ { - ( H - 2 ) / 2 }$ , the only way is to query the transition operator $P$ by using sampling taken from the data distributions.
Now, for all state-action pairs $( s , a )$ in the support of the data distributions of the first $H - 2$ lev elsing amely only $\mu _ { 1 } , \mu _ { 2 } , \ldots , \mu _ { H - 2 } )$ , the transition opeion distributions of ang-, and $r _ { 0 }$ $( s _ { h } ^ { \hat { d } + 1 } , a _ { \hat { d } + 1 } ) , ( s _ { h } ^ { \hat { d } + 1 } , a _ { \hat { d } + 2 } ) , \dots , ( s _ { h } ^ { \hat { d } + 1 } , a _ { d } )$ support of in the supp f of $h ~ \in ~ [ H \mathrm { ~ - ~ } 2 ]$ . Moreover, for anyso be identical no mat $( s , a ) \in \{ s _ { H - 1 } ^ { + } , s _ { H - 1 } ^ { - } , s _ { H - 1 } ^ { \hat { d } + 1 } \} \times \mathcal { A }$ $\mu _ { H - 1 }$ $P ( s , a )$ ter $r _ { 0 } = 0$ or $r _ { 0 } = \hat { d } ^ { - ( H - 2 ) / 2 }$ . For those state-action pairs $( s , a )$ in the support of $\mu _ { H - 1 }$ with $s \not \in \{ s _ { H - 1 } ^ { + } , s _ { H - 1 } ^ { - } , s _ { H - 1 } ^ { \hat { d } + 1 } \}$ , we have
$$P ( s , a ) = \left\{ \begin{array} { l l } { s _ { H } ^ { + } } & { \mathrm { w i t h } \ p r o b a b i l i t y \ ( 1 + r _ { 0 } ) / 2 } \\ { s _ { H } ^ { - } } & { \mathrm { w i t h } \ p r o b a b i l i t y \ ( 1 - r _ { 0 } ) / 2 } \end{array} \right. .$$
Again, this is because $( s _ { H - 1 } ^ { \hat { d } + 1 } , a )$ is not in the support of $\mu _ { H - 1 }$ for all $a \in \left\{ a _ { \hat { d } + 1 } , a _ { \hat { d } + 2 } , \dotsc , a _ { d } \right\}$
Therefore, in order to distinguish the case $r _ { 0 } = 0$ and $r _ { 0 } = \hat { d } ^ { - ( H - 2 ) / 2 }$ , the agent needs distinguish two transition distributions
$$p _ { 1 } = { \left\{ \begin{array} { l l } { s _ { H } ^ { + } } & { { \mathrm { w i t h ~ p r o b a b i l i t y ~ } } 1 / 2 } \\ { s _ { H } ^ { - } } & { { \mathrm { w i t h ~ p r o b a b i l i t y ~ } } 1 / 2 } \end{array} \right. }$$
and
$$p _ { 2 } = \left\{ s _ { H } ^ { + } \quad \mathrm { w i t h } \mathrm { p r o b a b i l i t y } ( 1 + \hat { d } ^ { - ( H - 2 ) / 2 } ) / 2 \right.$$
Again, by Lemma B.1, in order to distinguish $p _ { 1 }$ and $p _ { 2 }$ with probability at least 0.9, one needs $\Omega ( \hat { d } ^ { H - 2 } )$ samples. Formally, we have the following theorem.
Theorem C.1. Suppose Assumption 2 holds, and rewards are deterministic and could be nonezero only for state-action pairs in the last level. Fix an algorithm that takes as input both a policy and a feature mapping. There exists an MDP satisfying Assumption 5, such that for a fixed policy $\pi : { \mathcal { S } } A$ , the algorithm requires $\Omega ( ( d / 2 - 1 ) ^ { H / 2 } )$ samples to output the value of π up to constant additive approximation error with probability at least 0.9.
# D ANALYSIS OF ALGORITHM 1
D.1 PROOF OF LEMMA 5.1
Clearly,
For the first te
$$\begin{array} { r l } & { \frac { 1 } { \sqrt { 3 } } \sum _ { k \geq 0 , k \leq 1 } \bar { \zeta } _ { k } \bigg ( \frac { 1 } { 2 } \eta _ { k } ^ { 2 } \bigg ( \mathbb { E } _ { k } \| \hat { \zeta } _ { k } \| ^ { 2 } \eta _ { k } ^ { 2 } \bigg ( \mathbb { E } _ { k } \| \hat { \zeta } _ { k } \| ^ { 2 } \eta _ { k } ^ { 2 } \bigg ) \bigg ) } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & & \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \end{array}$$
Therefore,
$$\begin{array} { l } { \displaystyle \hat { \theta } _ { 1 } - \theta _ { 1 } = ( \hat { \Lambda } _ { 1 } ^ { - 1 } \Phi _ { 1 } \xi _ { 1 } - \lambda \hat { \Lambda } _ { 1 } ^ { - 1 } \theta _ { 1 } ) + \hat { \Lambda } _ { 1 } ^ { - 1 } \Phi _ { 1 } ^ { \top } \overline { { \Phi } } _ { 2 } ( \theta _ { 2 } - \hat { \theta } _ { 2 } ) } \\ { \displaystyle = ( \hat { \Lambda } _ { 1 } ^ { - 1 } \Phi _ { 1 } \xi _ { 1 } - \lambda \hat { \Lambda } _ { 1 } ^ { - 1 } \theta _ { 1 } ) + \hat { \Lambda } _ { 1 } ^ { - 1 } \Phi _ { 1 } ^ { \top } \overline { { \Phi } } _ { 2 } ( \hat { \Lambda } _ { 2 } ^ { - 1 } \Phi _ { 2 } ^ { \top } \xi _ { 2 } - \lambda \hat { \Lambda } _ { 2 } ^ { - 1 } \theta _ { 2 } ) } \\ { \displaystyle \quad \quad + \hat { \Lambda } _ { 1 } ^ { - 1 } \Phi _ { 1 } ^ { \top } \overline { { \Phi } } _ { 2 } \hat { \Lambda } _ { 2 } ^ { - 1 } \Phi _ { 2 } ^ { \top } \overline { { \Phi } } _ { 3 } ( \theta _ { 3 } - \hat { \theta } _ { 3 } ) } \\ { \displaystyle \quad = \ldots } \\ { \displaystyle \quad = \sum _ { h = 1 } ^ { H } \hat { \Lambda } _ { 1 } ^ { - 1 } \Phi _ { 1 } ^ { \top } \overline { { \Phi } } _ { 2 } \hat { \Lambda } _ { 2 } ^ { - 1 } \Phi _ { 2 } ^ { \top } \overline { { \Phi } } _ { 3 } \ldots ( \hat { \Lambda } _ { h } ^ { - 1 } \Phi _ { h } ^ { \top } \xi _ { h } - \lambda \hat { \Lambda } _ { h } ^ { - 1 } \theta _ { h } ) . } \end{array}$$
Also note that
$$\begin{array} { r } { ( Q ^ { \pi } ( s _ { 1 } , \pi ( s _ { 1 } ) ) - \hat { Q } ( s _ { 1 } , \pi ( s _ { 1 } ) ) ) ^ { 2 } = \| \theta _ { 1 } - \hat { \theta } _ { 1 } \| _ { \bar { \Lambda } _ { 1 } } ^ { 2 } . } \end{array}$$
# D.2 PROOF OF THEOREM 5.2
By matrix concentration inequality (Tropp, 2015), we have the following lemma.
Lemma D.1. For each $h \in [ H ]$ , with probability $1 - \delta / ( 4 H )$ , for some universal constant $C$ , we have
$$\left\| \frac { 1 } { N } \Phi _ { h } ^ { \top } \Phi _ { h } - \Lambda _ { h } \right\| _ { 2 } \leq C \sqrt { d \log ( d H / \delta ) / N } .$$
and
$$\left\| \frac { 1 } { N } \overline { { \Phi } } _ { h + 1 } \overline { { \Phi } } _ { h + 1 } - \overline { { \Lambda } } _ { h + 1 } \right\| _ { 2 } \leq C \sqrt { d \log ( d H / \delta ) / N } .$$
Therefore, since $\lambda = C H \sqrt { d \log ( d H / \delta ) N }$ , with probability $1 - \delta / ( 4 H )$ , we have
$$\hat { \Lambda } _ { h } = \Phi _ { h } ^ { \top } \Phi _ { h } + \lambda I \succeq N \Lambda _ { h } .$$
Note that
$$\begin{array} { l } { \displaystyle ( { \mathcal Q } ^ { \pi } ( s _ { 1 } , \pi ( s _ { 1 } ) ) - \hat { Q } ( s _ { 1 } , \pi ( s _ { 1 } ) ) ) ^ { 2 } } \\ { \displaystyle \leq H \cdot \left( \sum _ { h = 1 } ^ { H } \left\| \hat { \Lambda } _ { 1 } ^ { - 1 } \Phi _ { 1 } ^ { \top } \overline { { \Phi } } _ { 2 } \hat { \Lambda } _ { 2 } ^ { - 1 } \Phi _ { 2 } ^ { \top } \overline { { \Phi } } _ { 3 } \cdot \cdot \cdot ( \hat { \Lambda } _ { h } ^ { - 1 } \Phi _ { h } ^ { \top } \xi _ { h } - \lambda \hat { \Lambda } _ { h } ^ { - 1 } \theta _ { h } ) \right\| _ { \overline { { \Lambda } } _ { 1 } } ^ { 2 } \right) } \\ { \displaystyle \leq 2 H \cdot \left( \sum _ { h = 1 } ^ { H } \left\| \hat { \Lambda } _ { 1 } ^ { - 1 } \Phi _ { 1 } ^ { \top } \overline { { \Phi } } _ { 2 } \hat { \Lambda } _ { 2 } ^ { - 1 } \Phi _ { 2 } ^ { \top } \overline { { \Phi } } _ { 3 } \cdot \cdot \cdot \hat { \Lambda } _ { h } ^ { - 1 } \Phi _ { h } ^ { \top } \xi _ { h } \right\| _ { \overline { { \Lambda } } _ { 1 } } ^ { 2 } + \sum _ { h = 1 } ^ { H } \left\| \hat { \Lambda } _ { 1 } ^ { - 1 } \Phi _ { 1 } ^ { \top } \overline { { \Phi } } _ { 2 } \hat { \Lambda } _ { 2 } ^ { - 1 } \Phi _ { 2 } ^ { \top } \overline { { \Phi } } _ { 3 } \cdot \cdot \cdot \cdot \lambda \hat { \Lambda } _ { h } ^ { - 1 } \theta _ { h } \right\| _ { \overline { { \Lambda } } _ { 1 } } ^ { 2 } \right) } \end{array}$$
For each $h \in [ H ]$ ,
$$\begin{array} { r l } & { \quad \| \hat { \Lambda } _ { 1 } ^ { - 1 } \Phi _ { 1 } ^ { \top } \overline { { \Phi } } _ { 2 } \hat { \Lambda } _ { 2 } ^ { - 1 } \Phi _ { 2 } ^ { \top } \overline { { \Phi } } _ { 3 } \cdots \hat { \Lambda } _ { h } ^ { - 1 } \Phi _ { h } ^ { \top } \xi _ { h } \| _ { \overline { { \Lambda } } _ { 1 } } ^ { 2 } } \\ & { \leq \| \Phi _ { 1 } \hat { \Lambda } _ { 1 } ^ { - 1 } \overline { { \Lambda } } _ { 1 } \hat { \Lambda } _ { 1 } ^ { - 1 } \Phi _ { 1 } ^ { \top } \| _ { 2 } \cdot \| \overline { { \Phi } } _ { 2 } \hat { \Lambda } _ { 2 } ^ { - 1 } \Phi _ { 2 } ^ { \top } \overline { { \Phi } } _ { 3 } \cdots \hat { \Lambda } _ { h } ^ { - 1 } \Phi _ { h } ^ { \top } \xi _ { h } \| _ { 2 } ^ { 2 } } \\ & { \leq \| \hat { \Lambda } _ { 1 } ^ { - 1 / 2 } \overline { { \Lambda } } _ { 1 } \hat { \Lambda } _ { 1 } ^ { - 1 / 2 } \| _ { 2 } \cdot \| \Phi _ { 1 } \hat { \Lambda } _ { 1 } ^ { - 1 } \Phi _ { 1 } ^ { \top } \| _ { 2 } \cdot \| \overline { { \Phi } } _ { 2 } \hat { \Lambda } _ { 2 } ^ { - 1 } \Phi _ { 2 } ^ { \top } \overline { { \Phi } } _ { 2 } \cdot \cdot \hat { \Lambda } _ { h } ^ { - 1 } \Phi _ { h } ^ { \top } \xi _ { h } \| _ { 2 } ^ { 2 } } \\ & \leq \| \hat { \Lambda } _ { 1 } ^ { - 1 / 2 } \overline { { \Lambda } } _ { 1 } \hat { \Lambda } _ { 1 } ^ { - 1 / 2 } \| _ { 2 } \cdot \displaystyle \prod _ { h ^ { \prime } = 1 } ^ { h - 1 } \Big ( \| \Phi _ { h ^ { \prime } } \hat { \Lambda } _ { h ^ { \prime } } ^ { - 1 } \Phi _ { h ^ { \prime } } ^ { \top } \| _ { 2 } \cdot \| \hat { \Phi } _ { h ^ { \prime } + 1 } ^ { - 1 / 2 } ( \overline { { \Phi } } _ { h ^ { \prime } + 1 } ^ { \top } \overline { { \Phi } } _ { h ^ { \prime } + 1 } ) \hat { \Lambda } _ h ^ { \prime } \end{array}$$
Similarly,
$$\begin{array} { r l } & { \quad \| \hat { \boldsymbol { \Lambda } } _ { 1 } ^ { - 1 } \Phi _ { 1 } ^ { \top } \overline { { \Phi } } _ { 2 } \hat { \boldsymbol { \Lambda } } _ { 2 } ^ { - 1 } \Phi _ { 2 } ^ { \top } \overline { { \Phi } } _ { 3 } \cdot \cdot \lambda \hat { \boldsymbol { \Lambda } } _ { h } ^ { - 1 } \theta _ { h } \| _ { \overline { { \boldsymbol { \Lambda } } } _ { 1 } } ^ { 2 } } \\ & { \leq \| \hat { \boldsymbol { \Lambda } } _ { 1 } ^ { - 1 / 2 } \overline { { \boldsymbol { \Lambda } } } _ { 1 } \hat { \boldsymbol { \Lambda } } _ { 1 } ^ { - 1 / 2 } \| _ { 2 } \cdot \displaystyle \prod _ { h ^ { \prime } = 1 } ^ { h - 1 } \Big ( \| \Phi _ { h ^ { \prime } } \hat { \boldsymbol { \Lambda } } _ { h ^ { \prime } } ^ { - 1 } \Phi _ { h ^ { \prime } } ^ { \top } \| _ { 2 } \cdot \| \hat { \boldsymbol { \Lambda } } _ { h ^ { \prime } + 1 } ^ { - 1 / 2 } ( \overline { { \Phi } } _ { h ^ { \prime } + 1 } ^ { \top } \overline { { \Phi } } _ { h ^ { \prime } + 1 } ) \hat { \boldsymbol { \Lambda } } _ { h + 1 } ^ { - 1 / 2 } \| _ { 2 } \Big ) \cdot \lambda ^ { 2 } \cdot \| \theta _ { h } \| _ { \hat { \boldsymbol { \Lambda } } _ { h } ^ { - 1 } } ^ { 2 } } \\ & { \leq \| \hat { \boldsymbol { \Lambda } } _ { 1 } ^ { - 1 / 2 } \overline { { \boldsymbol { \Lambda } } } _ { 1 } \hat { \boldsymbol { \Lambda } } _ { 1 } ^ { - 1 / 2 } \| _ { 2 } \cdot \displaystyle \prod _ { h ^ { \prime } = 1 } ^ { h - 1 } \Big ( \| \Phi _ { h ^ { \prime } } \hat { \boldsymbol { \Lambda } } _ { h ^ { \prime } } ^ { - 1 } \Phi _ { h ^ { \prime } } ^ { \top } \| _ { 2 } \cdot \| \hat { \boldsymbol { \Lambda } } _ { h ^ { \prime } + 1 } ^ { - 1 / 2 } ( \overline { { \Phi } } _ { h ^ { \prime } + 1 } ^ { \top } \overline { { \Phi } } _ { h ^ { \prime } + 1 } ) \hat { \boldsymbol { \Lambda } } _ { h ^ { \prime } + 1 } ^ { - 1 / 2 } \| _ { 2 } \cdot \lambda \cdot H ^ { 2 } d . } \end{array}$$
For all $h \in [ H ]$ , we have
$$\| \Phi _ { h } \hat { \Lambda } _ { h } ^ { - 1 } \Phi _ { h } ^ { \top } \| _ { 2 } \leq 1$$
and
$$\begin{array} { r } { \lVert \hat { \Lambda } _ { h } ^ { - 1 / 2 } ( \overline { { \Phi } } _ { h } ^ { \top } \overline { { \Phi } } _ { h } ) \hat { \Lambda } _ { h } ^ { - 1 / 2 } \rVert _ { 2 } \leq \lVert N \hat { \Lambda } _ { h } ^ { - 1 / 2 } \overline { { \Lambda } } _ { h } \hat { \Lambda } _ { h } ^ { - 1 / 2 } \rVert _ { 2 } + \lVert \hat { \Lambda } _ { h } ^ { - 1 / 2 } ( \overline { { \Phi } } _ { h } ^ { \top } \overline { { \Phi } } _ { h } - N \overline { { \Lambda } } _ { h } ) \hat { \Lambda } _ { h } ^ { - 1 / 2 } \rVert _ { 2 } . } \end{array}$$
Conditioned on the event in Lemma D.1,
$$\hat { \Lambda } _ { h } \succeq N \Lambda _ { h } \succeq \frac { N } { C _ { h } } \overline { { \Lambda } } _ { h } ,$$
which implies $\| N \hat { \Lambda } _ { h } ^ { - 1 / 2 } \overline { { \Lambda } } _ { h } \hat { \Lambda } _ { h } ^ { - 1 / 2 } \| \le C _ { h }$ . Moreover, conditioned on the event in Lemma D.1,
$$\begin{array} { r } { \| \hat { \boldsymbol { \Lambda } } _ { h } ^ { - 1 / 2 } ( \overline { { \Phi } } _ { h } ^ { \top } \overline { { \Phi } } _ { h } - N \overline { { \boldsymbol { \Lambda } } } _ { h } ) \hat { \boldsymbol { \Lambda } } _ { h } ^ { - 1 / 2 } \| _ { 2 } \leq C \sqrt { d \log ( d H / \delta ) N } / \lambda . } \end{array}$$
Thus,
$$\| \hat { \boldsymbol { \Lambda } } _ { 1 } ^ { - 1 / 2 } \overline { { \boldsymbol { \Lambda } } } _ { 1 } \hat { \boldsymbol { \Lambda } } _ { 1 } ^ { - 1 / 2 } \| _ { 2 } \leq C _ { 1 } / N .$$
and
$$\begin{array} { r } { \| \hat { \boldsymbol \Lambda } _ { h } ^ { - 1 / 2 } ( \overline { { \Phi } } _ { h } ^ { \top } \overline { { \Phi } } _ { h } ) \hat { \boldsymbol \Lambda } _ { h } ^ { - 1 / 2 } \| _ { 2 } \leq C _ { h } + C \sqrt { d \log ( d H / \delta ) N } / \lambda . } \end{array}$$
Finally, by Theorem 1.2 in (Hsu et al., 2012a), with probability $1 - \delta / ( 4 H )$ , for some constant $C ^ { \prime }$ , we have
$$\begin{array} { r } { \| \xi _ { h } \| _ { \Phi _ { h } \hat { \Lambda } _ { h } ^ { - 1 } \Phi _ { h } ^ { \top } } ^ { 2 } \le C ^ { \prime } H ^ { 2 } d \log ( H / \delta ) . } \end{array}$$
Therefore,
$$\begin{array} { r l } & { \quad \quad \left\| \hat { \Lambda } _ { 1 } ^ { - 1 } \Phi _ { 1 } ^ { \top } \overline { { \Phi } } _ { 2 } \hat { \Lambda } _ { 2 } ^ { - 1 } \Phi _ { 2 } ^ { \top } \overline { { \Phi } } _ { 3 } \cdots \hat { \Lambda } _ { h } ^ { - 1 } \Phi _ { h } ^ { \top } \xi _ { h } \right\| _ { \overline { { \Lambda } } _ { 1 } } ^ { 2 } + \left\| \hat { \Lambda } _ { 1 } ^ { - 1 } \Phi _ { 1 } ^ { \top } \overline { { \Phi } } _ { 2 } \hat { \Lambda } _ { 2 } ^ { - 1 } \Phi _ { 2 } ^ { \top } \overline { { \Phi } } _ { 3 } \cdots \lambda \hat { \Lambda } _ { h } ^ { - 1 } \theta _ { h } \right\| _ { \overline { { \Lambda } } _ { 1 } } ^ { 2 } } \\ & { \leq \frac { C _ { 1 } } { N } ( C _ { 2 } + C \sqrt { d \log ( d / \delta ) N } / \lambda ) \times \cdots \times ( C _ { h } + C \sqrt { d \log ( d / \delta ) N } / \lambda ) \times ( C ^ { \prime } H ^ { 2 } d \log ( H / \delta ) + \lambda H } \\ & { \leq \frac { C _ { 1 } } { N } ( C _ { 2 } + 1 / H ) \times \cdots \times ( C _ { h } + 1 / H ) \times ( C ^ { \prime } H ^ { 2 } d \log ( H / \delta ) + \lambda H ^ { 2 } d ) } \\ & { \leq \frac { e } { N } C _ { 1 } \times C _ { 2 } \times \cdots \times C _ { h } \times ( C ^ { \prime } H ^ { 2 } d \log ( H / \delta ) + C d H ^ { 3 } \sqrt { d \log ( d H / \delta ) N } ) . } \end{array}$$
Let $c > 0$ be a large enough constant. We now have
$$\mathbb { E } _ { s _ { 1 } } [ ( Q _ { 1 } ^ { \pi } ( s _ { 1 } , \pi ( s _ { 1 } ) ) - \hat { Q } _ { 1 } ( s _ { 1 } , \pi ( s _ { 1 } ) ) ) ^ { 2 } ] \leq c \cdot \left( \prod _ { h = 1 } ^ { H } C _ { h } \right) \cdot d H ^ { 5 } \cdot \sqrt { \frac { d \log ( d H / \delta ) } { N } } .$$123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356# On Training Implicit Models
Zhengyang Geng1,2∗ Xin-Yu Zhang2∗ Shaojie Bai4 Yisen Wang2,3 Zhouchen Lin2,3,5†
1Zhejiang Lab, China 2Key Lab. of Machine Perception, School of AI, Peking University 3Institute for Artificial Intelligence, Peking University 4Carnegie Mellon University 5Pazhou Lab, China
# Abstract
This paper focuses on training implicit models of infinite layers. Specifically, previous works employ implicit differentiation and solve the exact gradient for the backward propagation. However, is it necessary to compute such an exact but expensive gradient for training? In this work, we propose a novel gradient estimate for implicit models, named phantom gradient, that 1) forgoes the costly computation of the exact gradient; and 2) provides an update direction empirically preferable to the implicit model training. We theoretically analyze the condition under which an ascent direction of the loss landscape could be found, and provide two specific instantiations of the phantom gradient based on the damped unrolling and Neumann series. Experiments on large-scale tasks demonstrate that these lightweight phantom gradients significantly accelerate the backward passes in training implicit models by roughly $1 . 7 \times$ , and even boost the performance over approaches based on the exact gradient on ImageNet.
# 1 Introduction
Conventional neural networks are typically constructed by explicitly stacking multiple linear and non-linear operators in a feed-forward manner. Recently, the implicitly-defined models [1, 2, 3, 4, 5] have attracted increasing attentions and are able to match the state-of-the-art results by explicit models on several vision [3, 6], language [2] and graph [4] tasks. These works treat the evolution of the intermediate hidden states as a certain form of dynamics, such as fixed-point equations [2, 3] or ordinary differential equations (ODEs) [1, 7], which represents infinite latent states. The forward passes of implicit models are therefore formulated as solving the underlying dynamics, by either black-box ODE solvers [1, 7] or root-finding algorithms [2, 3]. As for the backward passes, however, directly differentiating through the forward pass trajectories could induce a heavy memory overhead [8, 9]. To this end, researchers have developed memory-efficient backpropagation via implicit differentiation, such as solving a Jacobian-based linear fixed-point equation for the backward pass of deep equilibrium models (DEQs) [2], which eventually makes the backpropagation trajectories independent of the forward passes. This technique allows one to train implicit models with essentially constant memory consumption, as we only need to store the final output and the layer itself without saving any intermediate states. However, in order to estimate the exact gradient by implicit differentiation, implicit models have to rely on expensive black-box solvers for backward passes, e.g., ODE solvers or root-solving algorithms. These black-box solver usually makes the gradient computation very costly in practice, even taking weeks to train state-of-the-art implicit models on ImageNet [10] with 8 GPUs.
This work investigates fast approximate gradients for training implicit models. We found that a firstorder oracle that produces good gradient estimates is enough to efficiently and effectively train implicit models, circumventing laboriously computing the exact gradient as in prior arts [2, 3, 4, 11, 12]. We develop a framework in which a balanced trade-off is made between the precision and conditioning of the gradient estimate. Specifically, we provide the general condition under which the phantom gradient can provide an ascent direction of the loss landscape. We further propose two instantiations of phantom gradients in the context of DEQ models, which are based on the the damped fixed-point unrolling and the Neumann series, respectively. Importantly, we show that our proposed instantiations satisfy the theoretical condition, and that the stochastic gradient descent (SGD) algorithm based on the phantom gradient enjoys a sound convergence property as long as the relevant hyperparameters, e.g., the damping factor, are wisely selected. Note that our method only affects, and thus accelerates, the backward formulation of the implicit models, leaving the forward pass formulation (i.e., the root-solving process) and the inference behavior unchanged so that our method is applicable to a wide range of implicit models, forward solvers, and inference strategies. We conduct an extensive set of synthetic, ablation, and large-scale experiments to both analyze the theoretical properties of the phantom gradient and validate its speedup and performances on various tasks, such as ImageNet [10] classification and Wikitext-103 [13] language modeling.
Overall, our results suggest that: 1) the phantom gradient estimates an ascent direction; 2) it is applicable to large-scale tasks and is capable of achieving a strong performance which is comparable with or even better than that of the exact gradient; and 3) it significantly shortens the total training time needed for implicit models roughly by a factor of $1 . 4 \sim 1 . 7 \times$ , and even accelerates the backward passes by astonishingly $1 2 \times$ on ImageNet. We believe that our results provide strong evidence for effectively training implicit models with the lightweight phantom gradient.
# 2 Method
# 2.1 Inspection of Implicit Differentiation
In this work, we primarily focus on the formulation of implicit models based on root-solving, represented by the DEQ models [2]. The table of notations is arranged in Appendix A. Specifically, given an equilibrium module $\mathcal { F }$ , the output of the implicit model is characterized by the solution $h ^ { * }$ to the following fixed-point equation:
$$\begin{array} { r } { \begin{array} { r } { h ^ { * } = \mathcal { F } ( h ^ { * } , z ) , } \end{array} } \end{array}$$
where $\boldsymbol { z } \in \mathbb { R } ^ { d _ { \boldsymbol { u } } + d _ { \boldsymbol { \theta } } }$ is the union of the module’s input $\pmb { u } \in \mathbb { R } ^ { d _ { u } }$ and parameters $\pmb { \theta } \in \mathbb { R } ^ { d _ { \pmb { \theta } } }$ , i.e., $z ^ { \top } =$ $[ \boldsymbol { u } ^ { \top } , \boldsymbol { \theta } ^ { \top } ]$ . Here, $\textbf { \em u }$ is usually a projection of the original data point $\boldsymbol { x } \in \mathbb { R } ^ { d _ { x } }$ , e.g., $\pmb { u } = \mathcal { M } ( \pmb { x } )$ . In this section, we assume $\mathcal { F }$ is a contraction mapping w.r.t. $^ { h }$ so that its Lipschitz constant $L _ { h } \ w . r . t . \ h$ is less than one, i.e., $L _ { h } < 1$ , a setting that has been analyzed in recent works $[ 1 4 , 1 5 ] ^ { 1 }$ .
To differentiate through the fixed point by Eq. (1), we need to calculate the gradient of $h ^ { \ast } w . r . t .$ the input $_ z$ . By Implicit Function Theorem (IFT), we have
$$\frac { \partial { \pmb h } ^ { * } } { \partial z } = \left. \frac { \partial \mathcal { F } } { \partial z } \right| _ { { \pmb h } ^ { * } } \left( { \pmb I } - \left. \frac { \partial \mathcal { F } } { \partial { \pmb h } } \right| _ { { \pmb h } ^ { * } } \right) ^ { - 1 } .$$
Here, $( \partial \pmb { a } / \partial b ) _ { i j } = \partial \pmb { a } _ { j } / \partial b _ { i }$ . The equilibrium point $h ^ { * }$ of Eq. (1) is then passed to a post-processing function $\mathcal { G }$ to obtain a prediction $\hat { y } = \mathcal G ( h ^ { * } )$ . In the generic learning scenario, the training objective is the following expected loss:
$$\begin{array} { r } { \mathcal { R } ( \pmb { \theta } ) = \mathbb { E } _ { ( \pmb { x } , \pmb { y } ) \sim \mathcal { P } } \left[ \mathcal { L } ( \hat { \pmb { y } } ( \pmb { x } ; \pmb { \theta } ) , \pmb { y } ) \right] , } \end{array}$$
where $\textbf { { y } }$ is the groundtruth corresponding to the training example $_ { \textbf { \em x } }$ , and $\mathcal { P }$ is the data distribution. Here, we omit the parameters of $\mathcal { G }$ , because given the output $h ^ { * }$ of the implicit module $\mathcal { F }$ , training the post-processing part $\mathcal { G }$ is the same as training explicit neural networks. The most crucial component is the gradient of the loss function $\mathcal { L } w . r . t .$ the input vector $z ^ { \top } = [ \pmb { u } ^ { \top } , \pmb { \theta } ^ { \top } ]$ , which is used to train both the implicit module $\mathcal { F }$ and the input projection module $\mathcal { M }$ . Using Eq. (2) with the condition $h = h ^ { * }$ , we have
$$\frac { \partial \mathcal { L } } { \partial u } = \frac { \partial \mathcal { F } } { \partial u } \left( I - \frac { \partial \mathcal { F } } { \partial h } \right) ^ { - 1 } \frac { \partial \mathcal { L } } { \partial h } , \quad \frac { \partial \mathcal { L } } { \partial \theta } = \frac { \partial \mathcal { F } } { \partial \theta } \left( I - \frac { \partial \mathcal { F } } { \partial h } \right) ^ { - 1 } \frac { \partial \mathcal { L } } { \partial h } .$$
The gradients in Eq. (4) are in the same form w.r.t. $\textbf { \em u }$ and $\pmb \theta$ . Without loss of generality, we only discuss the gradient w.r.t. $\pmb { \theta }$ in the following sections.
# 2.2 Motivation
The most intriguing part lies in the Jacobian-inverse term, i.e., $\left( I - \partial \mathcal { F } / \partial h \right) ^ { - 1 }$ . Computing the inverse term by brute force is intractable due to the $\mathcal { O } ( n ^ { 3 } )$ complexity. Previous implicit models [2] approach this by solving a linear system involving a Jacobian-vector product iteratively via a gradient solver, introducing over 30 Broyden [16] iterations in the backward pass. However, the scale of the Jacobian matrix can exceed $\mathrm { 1 0 ^ { 6 } \times 1 0 ^ { 6 } }$ in the real scenarios, leading to a prohibitive cost in computing the exact gradient. For example, training a small-scale state-of-the-art implicit model on ImageNet can consume weeks using 8 GPUs while training explicit models usually takes days, demonstrating that pursuing the exact gradient severely slows down the training process of implicit models compared with explicit models.
Secondly, because of the inversion operation, we cast doubt on the conditioning of the gradient and the stability of training process from the numerical aspect. The Jacobian-inverse can be numerically unstable when encountering the ill-conditioning issue. The conditioning problem might further undermine the training stability, as studied in the recent work [17].
Plus, the inexact gradient [9, 18, 19, 20, 21, 22] is widely applied in the previous learning protocol, like linear propagation [23] and synthetic gradient [24]. Here, the Jacobian-inverse is used to calculate the exact gradient which is not always optimal for model training. Moreover, previous research has used a moderate gradient noise as a regularization approach [25], which has been shown to play a central role in escaping poor local minima and improving generalization ability [26, 27, 28].
The concerns and observations motivate us to rethink the possibility of replacing the Jacobian-inverse term in the standard implicit differentiation with a cheaper and more stable counterpart. We believe that an exact gradient estimate is not always required, especially for a black-box layer like those in the implicit models. Hence this work designs an inexact, theoretically sound, and practically efficient gradient for training implicit models under various settings. We name the proposed gradient estimate as the phantom gradient.
Suppose the Jacobian ${ { \partial } { h } ^ { * } } / { { \partial } { \theta } }$ is replaced with a matrix $\pmb { A }$ , and the corresponding phantom gradient is defined as
$${ \widehat { \frac { \partial { \mathcal { L } } } { \partial \theta } } } : = A \ { \frac { \partial { \mathcal { L } } } { \partial h } } .$$
Next, we give the general condition on $\pmb { A }$ so that the phantom gradient can be guaranteed valid for optimization (Sec. 2.3), and provide two concrete instantiations of $\pmb { A }$ based on either damped fixed-point unrolling or the Neumann series (Sec. 2.4). The proofs of all our theoretical results are presented in Appendix C.
# 2.3 General Condition on the Phantom Gradient
Previous research on theoretical properties for the inexact gradient include several aspects, such as the gradient direction [22], the unbiasedness of the estimator [29], and the convergence theory of the stochastic algorithm [19, 30]. The following theorem formulates a sufficient condition that the phantom gradient gives an ascent direction of the loss landscape.
Theorem 1. Suppose the exact gradient and the phantom gradient are given by Eq. (4) and (5), respectively. Let $\sigma _ { m a x }$ and $\sigma _ { m i n }$ be the maximal and minimal singular value of $\partial \mathcal { F } / \partial \theta$ . If
$$\left\| A \left( I - \frac { \partial \mathcal { F } } { \partial h } \right) - \frac { \partial \mathcal { F } } { \partial \theta } \right\| < \frac { \sigma _ { m i n } ^ { 2 } } { \sigma _ { m a x } } ,$$
then the phantom gradient provides an ascent direction of the function $\mathcal { L }$ , i.e.,
$$\left. { \widehat { \frac { \partial { \mathcal { L } } } { \partial \theta } } } , { \frac { \partial { \mathcal { L } } } { \partial \theta } } \right. > 0 .$$
Remark 1. Suppose only the $\left( I - \partial \mathcal { F } / \partial h \right) ^ { - 1 }$ term is replaced with a matrix $_ { D }$ , namely, $A =$ $( \partial \mathcal { F } / \partial \pmb { \theta } ) \pmb { D }$ . Then, the condition in (6) can be reduced into
$$\left\| D \left( I - \frac { \partial \mathcal { F } } { \partial h } \right) - I \right\| < \frac { 1 } { \kappa ^ { 2 } } ,$$
where $\kappa$ is the condition number of $\partial \mathcal { F } / \partial \theta$ . (See Appendix C.1 for the derivation.)
# 2.4 Instantiations of the Phantom Gradient
In this section, we present two practical instantiations of the phantom gradient. We also verify that the general condition in Theorem 1 can be satisfied if the hyperparameters in our instantiations are wisely selected.
Suppose we hope to differentiate through implicit dynamics, e.g., either a root-solving process or an optimization problem. In the context of hyperparameter optimization (HO), previous solutions include differentiating through the unrolled steps of the dynamics [19] or employing the Neumann series of the Jacobian-inverse term [9]. In our case, if we solve the root of Eq. (1) via the fixed-point iteration:
$$\pmb { h } _ { t + 1 } = \mathcal { F } ( \pmb { h } _ { t } , z ) , \quad t = 0 , 1 , \cdots , T - 1 ,$$
then by differentiating through the unrolled steps of Eq. (9), we have
$$\frac { \partial { \pmb h } _ { T } } { \partial { \pmb \theta } } = \sum _ { t = 0 } ^ { T - 1 } \left. \frac { \partial \mathcal { F } } { \partial { \pmb \theta } } \right| _ { { \pmb h } _ { t } ~ s = t + 1 } \left. \frac { \partial \mathcal { F } } { \partial { \pmb h } } \right| _ { { \pmb h } _ { s } } .$$
Besides, the Neumann series of the Jacobian-inverse $\left( I - \partial \mathcal { F } / \partial h \right) ^ { - 1 }$ is
$$\pmb { I } + \frac { \partial \mathcal { F } } { \partial \pmb { h } } + \left( \frac { \partial \mathcal { F } } { \partial \pmb { h } } \right) ^ { 2 } + \left( \frac { \partial \mathcal { F } } { \partial \pmb { h } } \right) ^ { 3 } + \cdots .$$
Notably, computing the Jacobian $\partial \pmb { h } ^ { * } / \partial \pmb { \theta }$ using the Neumann series in (11) is equivalent to differentiating through the unrolled steps of Eq. (9) at the exact equilibrium point $h ^ { * }$ and taking the limit of infinite steps [9].
Without altering the root of Eq. (1), we consider a damped variant of the fixed-point iteration:
$$\begin{array} { r } { h _ { t + 1 } = \mathscr { F } _ { \lambda } ( h _ { t } , z ) = \lambda \mathscr { F } ( h _ { t } , z ) + ( 1 - \lambda ) h _ { t } , \quad t = 0 , 1 , \cdots , T - 1 . } \end{array}$$
Differentiating through the unrolled steps of Eq. (12), Eq. (10) is adapted as
$$\frac { \partial h _ { T } } { \partial \pmb { \theta } } = \lambda \sum _ { t = 0 } ^ { T - 1 } \frac { \partial \mathcal { F } } { \partial \pmb { \theta } } | _ { h _ { t } } \prod _ { s = t + 1 } ^ { T - 1 } ( \lambda \frac { \partial \mathcal { F } } { \partial h } | _ { h _ { s } } + ( 1 - \lambda ) \pmb { I } ) .$$
The Neumann series of $\left( I - \partial \mathcal { F } / \partial h \right) ^ { - 1 }$ is correspondingly adapted as
$$\lambda \left( I + B + B ^ { 2 } + B ^ { 3 } + \cdots \right) , \quad \mathrm { w h e r e ~ } B = \lambda \frac { \partial \mathcal { F } } { \partial h } + ( 1 - \lambda ) I .$$
The next theorem shows that under mild conditions, the Jacobian from the damped unrolling in Eq. (13) converges to the exact Jacobian and the Neumann series in (14) converges to the Jacobianinverse $( I - \partial \mathcal { F } / \partial h ) ^ { - 1 }$ as well.
Theorem 2. Suppose the Jacobian $\partial \mathcal { F } / \partial h$ is a contraction mapping. Then,
(i) the Neumann series in (14) converges to the Jacobian-inverse $\left( I - \partial \mathcal { F } / \partial h \right) ^ { - 1 }$ ; and
(ii) if the function $\mathcal { F }$ is continuously differentiable w.r.t. both $^ { h }$ and $\pmb \theta$ , the sequence in Eq. (13) converges to the exact Jacobian $\partial \pmb { h } ^ { * } / \partial \pmb { \theta }$ as $T \to \infty$ , i.e.,
$$\operatorname* { l i m } _ { T \infty } \frac { \partial h _ { T } } { \partial \pmb { \theta } } = \frac { \partial \mathcal { F } } { \partial \pmb { \theta } } | _ { h ^ { \ast } } ( \pmb { I } - \frac { \partial \mathcal { F } } { \partial h } | _ { h ^ { \ast } } ) ^ { - 1 } .$$
However, as discussed in Sec. 2.2, it is unnecessary to compute the exact gradient with infinite terms. In the following context, we introduce two instantiations of the phantom gradient based on the finite-term truncation of Eq. (13) or (14).
Unrolling-based Phantom Gradient (UPG). In the unrolling form, the matrix $\pmb { A }$ is defined as
$$A _ { k , \lambda } ^ { \mathrm { u n r } } = \lambda \sum _ { t = 0 } ^ { k - 1 } \frac { \partial \mathcal { F } } { \partial \pmb { \theta } } | _ { h _ { t } } \prod _ { s = t + 1 } ^ { k - 1 } ( \lambda \frac { \partial \mathcal { F } } { \partial h } | _ { h _ { s } } + ( 1 - \lambda ) \pmb { I } ) .$$
Neumann-series-based Phantom Gradient (NPG). In the Neumann form, the matrix $\pmb { A }$ is defined as
$$\pmb { A } _ { k , \lambda } ^ { \mathrm { n e u } } = \lambda \left. \frac { \partial \mathcal { F } } { \partial \pmb { \theta } } \right| _ { h ^ { * } } \left( I + \pmb { B } + \pmb { B } ^ { 2 } + \cdots + \pmb { B } ^ { k - 1 } \right) , \quad \mathrm { w h e r e } \ \pmb { B } = \lambda \left. \frac { \partial \mathcal { F } } { \partial h } \right| _ { h ^ { * } } + ( 1 - \lambda ) I .$$
Note that both the initial point of the fixed-point iteration (i.e., $h _ { 0 }$ in Eq. (16)) and the point at which the Neumann series is evaluated (i.e., $h ^ { * }$ in (17)) are the solution of the root-finding solver. (See Appendix B for implementation of the phantom gradient.)
According to Theorem 2, the matrix $\pmb { A }$ defined by either Eq. (16) or (17) converges to the exact Jacobian ${ \bar { \partial } } h ^ { * } / \partial \theta$ as $k \to \infty$ for any $\lambda \in ( 0 , 1 ]$ . Therefore, by Theorem 2, the condition in (6) can be satisfied if a sufficiently large step $k$ is selected, since
$$\left\| A \left( I - { \frac { \partial { \mathcal { F } } } { \partial h } } \right) - { \frac { \partial { \mathcal { F } } } { \partial \theta } } \right\| \leq \left( 1 + L _ { h } \right) \left\| A - { \frac { \partial { \mathcal { F } } } { \partial \theta } } \left( I - { \frac { \partial { \mathcal { F } } } { \partial h } } \right) ^ { - 1 } \right\| .$$
Next, we characterize the impact of the two hyperparameters, i.e., $k$ and $\lambda$ , on the precision and conditioning of $\pmb { A }$ . Take the NPG (Eq. (17)) as an example.
(i) On the precision of the phantom gradient,
• a large $k$ makes the gradient estimate more accurate, as higher-order terms of the Neumann series are included, while • a small $\lambda$ slows down the convergence of the Neumann series because the norm $\| B \|$ increases as $\lambda$ decreases.
(ii) On the conditioning of the phantom gradient,
• a large $k$ impairs the conditioning of $\pmb { A }$ since the condition number of $B ^ { k }$ grows exponentially as $k$ increases, while • a small $\lambda$ helps maintain a small condition number of $\pmb { A }$ because the singular values of $\partial \mathcal { F } / \partial h$ are “smoothed” by the identity matrix.
In a word, a large $k$ is preferable for a more accurate $\pmb { A }$ , while a small $\lambda$ contributes to the wellconditioning of $\pmb { A }$ . Practically, these hyperparameters should be selected in consideration of a balanced trade-off between the precision and conditioning of $\pmb { A }$ . See Sec. 3 for experimental results.
# 2.5 Convergence Theory
In this section, we provide the convergence guarantee of the SGD algorithm using the phantom gradient. We prove that under mild conditions, if the approximation error of the phantom gradient is sufficiently small, the SGD algorithm converges to an $\epsilon$ -approximate stationary point in the expectation sense. We will discuss the feasibility of our assumptions in Appendix C.3.
Theorem 3. Suppose the loss function $\mathcal { R }$ in Eq. (3) is $\ell$ -smooth, lower-bounded, and has bounded gradient almost surely in the training process. Besides, assume the gradient in Eq. (4) is an unbiased estimator of $\nabla \mathcal { R } ( \theta )$ with a bounded covariance. If the phantom gradient in Eq. (5) is an $\epsilon$ -approximation to the gradient in Eq. (4), i.e.,
$$\left\| { \widehat { \frac { \partial { \mathcal { L } } } { \partial \theta } } } - { \frac { \partial { \mathcal { L } } } { \partial \theta } } \right\| \leq \epsilon , \quad a l m o s t s u r e l y ,$$
then using Eq. (5) as a stochastic first-order oracle with a step size of $\eta _ { n } = \mathcal { O } ( 1 / \sqrt { n } )$ to update $\pmb \theta$ with gradient descent, it follows after $N$ iterations that
$$\begin{array} { r } { \mathbb { E } \left[ \frac { \sum _ { n = 1 } ^ { N } \eta _ { n } \left\| \nabla \mathcal { R } \left( \pmb { \theta } _ { n } \right) \right\| ^ { 2 } } { \sum _ { n = 1 } ^ { N } \eta _ { n } } \right] \le \mathcal { O } \left( \epsilon + \frac { \log N } { \sqrt { N } } \right) . } \end{array}$$
Remark 2. Consider the condition in (19):
$$\left\| \widehat { \frac { \partial \mathcal { L } } { \partial \theta } } - \frac { \partial \mathcal { L } } { \partial \theta } \right\| \leq \left\| A - \frac { \partial \mathcal { F } } { \partial \theta } \left( I - \frac { \partial \mathcal { F } } { \partial h } \right) ^ { - 1 } \right\| \left\| \frac { \partial \mathcal { L } } { \partial h } \right\| .$$
Suppose the gradient $\partial \mathcal { L } / \partial h$ is almost surely bounded. By Theorem 2, the condition in (19) can be guaranteed as long as a sufficiently large $k$ is selected.
 Figure 1: Cosine similarity between the phantom gradient and the exact gradient in the synthetic setting.
# 3 Experiments
In this section, we aim to answer the following questions via empirical results: (1) How precise is the phantom gradient? (2) What is the difference between the unrolling-based and the Neumannseries-based phantom gradients? (3) How is the phantom gradient influenced by the hyperparameters $k$ and $\lambda ?$ (4) How about the computational cost of the phantom gradient compared with implicit differentiation? (5) Can the phantom gradient work at large-scale settings for various tasks?
We have provided some theoretical analysis and intuitions to (1), (2), and (3) in Sec. 2.4. Now we answer (1) and (2) and demonstrate the performance curves under different hyperparameters $k$ and $\lambda$ on CIFAR-10 [31]. Besides, we also study other factors that have potential influences on the training process of the state-of-the-art implicit models [2, 3] like pretraining. For (4) and (5), we conduct experiments on large-scale datasets to highlight the ultra-fast speed and competitive performances, including image classification on ImageNet [10] and language modeling on Wikitext-103 [13].
We start by introducing two experiment settings. We adopt a single-layer neural network with spectral normalization [32] as the function $\mathcal { F }$ and fixed-point iterations as the equilibrium solver, which is the synthetic setting. Moreover, on the CIFAR-10 dataset, we use the MDEQ-Tiny model [3] (170K parameters) as the backbone model, denoted as the ablation setting. Additional implementation details and experimental results are presented in Appendix $\mathsf { D } ^ { 2 }$ .
Precision of the Phantom Gradient. The precision of the phantom gradient is measured by its angle against the exact gradient, indicated by the cosine similarity between the two. We discuss its precision in both the synthetic setting and the ablation setting. The former is under the static and randomly generated weights, while the latter provides characterization of the training dynamics.
In the synthetic setting, the function $\mathcal { F }$ is restricted to be a contraction mapping. Specifically, we directly set the Lipschitz constant of $\mathcal { F }$ as $L _ { h } = 0 . 9$ , and use 100 fixed-point iterations to solve the root $h ^ { * }$ of Eq. (1) until the relative error satisfies $\| h - \mathcal { F } ( h , z ) \| / \| h \| ^ { - } 1 0 ^ { - 5 }$ . Here, the exact gradient is estimated by backpropagation through the fixed-point iterations, and cross-validated by implicit differentiation solved with 20 iterations of the Broyden’s method [16]. In our experiment, the cosine similarity between these two gradient estimates consistently succeeds 0.9999, indicating the gradient estimate is quite accurate when the relative error of forward solver is minor. The cosine similarity between phantom gradients and exact gradients is shown in Fig. 1. It shows that the cosine similarity tends to increase as $k$ grows and that a small $\lambda$ tends to slow down the convergence of the phantom gradient, allowing it to explore in a wider range regarding the angle against the exact gradient.
In the ablation setting, the precision of the phantom gradient during the training process is shown in Fig. 2. The model is trained by implicit differentiation under the official schedule3. It shows that the phantom gradient still provides an ascent direction in the real training process, as indicated by the considerable cosine similarity against the exact gradient. Interestingly, the cosine similarity slightly decays as the training progresses, which implies a possibility to construct an adaptive gradient solver for implicit models.
 Figure 2: Cosine similarity between the phantom gradient and the exact gradient in the real scenario. The horizontal axis corresponds to the cosine similarity, and the vertical axis to the training step.
To Pretrain, or not to Pretrain? To better understand the components of the implicit models’ training schedule, we first illustrate a detailed ablation study of the baseline model in the ablation setting. The average accuracy with standard deviation is reported in Tab. 1.
The MDEQ model employs a pretraining stage in which the model $\mathcal { F }$ is unrolled as a recurrent network. We study the impact of the pretraining stage, the Dropout [33] operation, and the optimizer separately. It can be seen that the unrolled pretraining stabilizes the training of the MDEQ model. Removing the pretraining stage leads to a severe performance drop and apparent training instability among different trials because the solver cannot obtain an accurate fixed point $h ^ { * }$ when the model is not adequately trained. This ablation study also suggests that the MDEQ model is a strong baseline for our method to compare with.
Table 1: Ablation settings on CIFAR-10.
<table><tr><td>Method</td><td>Acc. (%)</td></tr><tr><td>Implicit Differentiation</td><td>85.0± 0.2</td></tr><tr><td>w/o Pretraining</td><td>82.3± 1.3</td></tr><tr><td>w/o Dropout Adam →SGD</td><td>83.7± 0.1</td></tr><tr><td> SGD w/o Pretraining</td><td>84.5 ± 0.3</td></tr><tr><td>UPG (A5,0.5, W/o Dropout)</td><td>82.9 ± 1.5</td></tr><tr><td>NPG (A5,0.5, w/o Dropout)</td><td>85.8±0.5</td></tr><tr><td>UPG (A9.0.5, w/ Dropout)</td><td>85.6± 0.5 86.1±0.5</td></tr></table>
However, pretraining is not always indispensable for training implicit models. It introduces an extra hyperparameter, i.e., how many steps should be involved in the pretraining stage. Next, we discuss how the UPG could circumvent this issue.
Trade-offs between Unrolling and Neumann. For an exact fixed point $h ^ { * }$ , i.e., $\begin{array} { r } { \begin{array} { r } { h ^ { * } = \mathcal { F } ( h ^ { * } , z ) } \end{array} } \end{array}$ , there is no difference between UPG and NPG. However, when the numerical error exists in solving $h ^ { * }$ , i.e., $\| h ^ { * } - \mathcal { F } ( h ^ { * } , z ) \| > 0$ , these two instatiations of the phantom gradient can behave differently.
We note that a particular benefit of the UPG is its ability to automatically switch between the pretraining and training stages for implicit models. When the model is not sufficiently trained and the solver converges poorly (see [3]), the UPG defines a forward computation graph that is essentially equivalent to a shallow weight-tied network to refine the coarse equilibrium states. In this stage, the phantom gradient serves as a backpropagation through time (BPTT) algorithm and hence behaves as in the pretraining stage. Then, as training progresses, the solver becomes more stable and converges to the fixed point $h ^ { * }$ better. This makes the UPG behave more like the NPG. Therefore, the unrolled pretraining is gradually transited into the regular training phase based on implicit differentiation, and the hyperparameter tuning of pretraining steps can be waived. We argue that such an ability to adaptively switch training stages is benign to the implicit models’ training protocol, which is also supported by the performance gain in Tab. 1.
Table 2: Complexity comparison. Mem means the memory cost, and $K$ and $k$ denote the solver’s steps and the unrolling/Neumann steps, respectively. Here, $K \gg k \approx 1$ .
<table><tr><td>Method</td><td>Time</td><td>Mem</td><td>Peak Mem</td></tr><tr><td>Implicit</td><td>O(K)</td><td>0(1)</td><td>O(k)</td></tr><tr><td>UPG</td><td>O(k)</td><td>O(k)</td><td>O(k)</td></tr><tr><td>NPG</td><td>(k)</td><td>0(1)</td><td>0(1)</td></tr></table>
Although the UPG requires higher memory overhead than implicit differentiation or the NPG, it does not surpass the peak memory usage in the entire training protocol by implicit differentiation due to the pretraining stage. In the ablation setting, the MDEQ model employs a 10-layer unrolling for pretraining, which actually consumes double memory compared with a 5-step unrolling scheme, e.g., $A _ { 5 , 0 . 5 }$ in Tab. 1. In Tab. 2, we also demonstrate the time and memory complexity for implicit differentiation and the two forms of phantom gradient.
 Figure 3: Ablation studies on (a) the hyperparameters $\lambda$ and $k$ , and (b) two forms of phantom gradient.
In addition, leaving the context of approximate and exact gradient aside, we also develop insights into understanding the subtle differences between UPG and NPG in terms of the state-dependent and state-free gradient. Actually, the UPG is state-dependent, which means it corresponds to the “exact” gradient of a computational sub-graph. Both the NPG and the gradient solved by implicit differentiation, however, do not exactly match the gradient of any forward computation graph unless the numerical error is entirely eliminated in both the forward and the backward passes for implicit differentiation or the one-step gradient [34, 21, 30, 22] is used for the NPG, i.e., $k =$ 1. Interestingly, we observe that models trained on the state-dependent gradient demonstrate an additional training stability regarding the Jacobian spectral radius, compared with those trained on the state-free counterpart. We empirically note that it can be seen as certain form of implicit Jacobian regularization for implicit models as a supplement to the explicit counterpart [17], indicated by the stable estimated Jacobian spectral radius during training, i.e., $\rho ( \partial \mathcal { F } _ { \lambda } / \partial h ) \approx 1$ .
The experimental results also cohere with our insight. The performance curves in Fig. 3 demonstrate the influence of $\lambda$ and $k$ and further validate that the UPG is more robust to a wide range of steps $k$ than the NPG. In fact, when the Jacobian spectral radius $\rho ( \partial \mathcal { F } / \partial h )$ increases freely without proper regularization, the exploding high-order terms in the NPG could exert a negative impact on the overall direction of the phantom gradient, leading to performance degradation when a large $k$ is selected (see Fig. 3(b)). We also observe a surging of the estimated Jacobian spectral radius as well as the gradient explosion issue in the NPG experiments. On the contrary, the UPG can circumvent these problems thanks to its implicit Jacobian regularization.
Table 3: Experiments using DEQ [2] and MDEQ [3] on vision and language tasks. Metrics stand for accuracy $( \% ) \uparrow$ for image classification on CIFAR-10 and ImageNet, and perplexity↓ for language modeling on Wikitext-103. JR stands for Jacobian Regularization [17]. $\dagger$ indicates additional steps in the forward equilibrium solver.
<table><tr><td>Datasets</td><td>Model</td><td>Method</td><td>Params</td><td>Metrics</td><td>Speed</td></tr><tr><td>CIFAR-10</td><td>MDEQ</td><td>Implicit</td><td>10M</td><td>93.8 ± 0.17</td><td>1.0×</td></tr><tr><td>CIFAR-10</td><td>MDEQ</td><td>UPG A5,0.5</td><td>10M</td><td>95.0 ± 0.16</td><td>1.4×</td></tr><tr><td>ImageNet</td><td>MDEQ</td><td>Implicit</td><td>18M</td><td>75.3</td><td>1.0×</td></tr><tr><td>ImageNet</td><td>MDEQ</td><td>UPG A5.0.6</td><td>18M</td><td>75.7</td><td>1.7×</td></tr><tr><td>Wikitext-103</td><td>DEQ (PostLN)</td><td>Implicit</td><td>98M</td><td>24.0</td><td>1.0×</td></tr><tr><td>Wikitext-103</td><td>DEQ( (PostLN)</td><td>UPG A5,0.8</td><td>98M</td><td>25.7</td><td>1.7×</td></tr><tr><td>Wikitext-103</td><td>DEQ (PreLN)</td><td>JR + Implicit</td><td>98M</td><td>24.5</td><td>1.7×</td></tr><tr><td>Wikitext-103</td><td>DEQ (PreLN)</td><td>JR + UPG A5,0.8</td><td>98M</td><td>24.4</td><td>2.2×</td></tr><tr><td>Wikitext-103</td><td>DEQ (PreLN)</td><td>JR + UPG A5,0.8</td><td>98M</td><td>24.0t</td><td>1.7×</td></tr></table>
Phantom Gradient at Scale. We conduct large-scale experiments to verify the advantages of the phantom gradient on vision, graph, and language benchmarks. We adopt the UPG in the large-scale experiments. The results are illustrated in Tab. 3 and Tab. 4. Our method matches or surpasses the implicit differentiation training protocol on the state-of-the-art implicit models with a visible reduction on the training time. When only considering the backward pass, the acceleration for MDEQ can be remarkably $1 2 \times$ on ImageNet classification.
Table 4: Experiments using IGNN [4] on graph tasks. Metrics stand for accuracy $( \% ) \uparrow$ for graph classification on COX2 and PROTEINS, Micro- $\mathrm { F l } ( \% ) \uparrow$ for node classification on PPI.
<table><tr><td>Datasets</td><td>Model</td><td>Method</td><td>Params</td><td>Metrics (%)</td></tr><tr><td>COX2</td><td>IGNN</td><td>Implicit</td><td>38K</td><td>84.1 ± 2.9</td></tr><tr><td>COX2</td><td>IGNN</td><td>UPG A5,0.5</td><td>38K</td><td>83.9 ± 3.0</td></tr><tr><td>COX2</td><td>IGNN</td><td>UPG A5,0.8</td><td>38K</td><td>83.9 ± 2.7</td></tr><tr><td>COX2</td><td>IGNN</td><td>UPG A5,1.0</td><td>38K</td><td>83.0 ± 2.9</td></tr><tr><td>PROTEINS</td><td>IGNN</td><td>Implicit</td><td>34K</td><td>78.6 ± 4.1</td></tr><tr><td>PROTEINS</td><td>IGNN</td><td>UPG A5,0.5</td><td>34K</td><td>78.4 ± 4.2</td></tr><tr><td>PROTEINS</td><td>IGNN</td><td>UPG A5,0.8</td><td>34K</td><td>78.6 ± 4.2</td></tr><tr><td>PROTEINS</td><td>IGNN</td><td>UPG A5,1.0</td><td>34K</td><td>78.8± 4.2</td></tr><tr><td>PPI</td><td>IGNN</td><td>Implicit</td><td>4.7M</td><td>97.6</td></tr><tr><td>PPI</td><td>IGNN</td><td>UPG A5,0.5</td><td>4.7M</td><td>98.2</td></tr><tr><td>PPI</td><td>IGNN</td><td>UPG A5,0.8</td><td>4.7M</td><td>97.4</td></tr><tr><td>PPI</td><td>IGNN</td><td>UPG A5,1.0</td><td>4.7M</td><td>96.2</td></tr></table>
# 4 Related Work
Implicit Models. Implicit models generalize the recursive forward/backward rules of neural networks and characterize their internal mechanism by some pre-specified dynamics. Based on the dynamics, the implicit mechanisms can be broadly categorized into three classes: ODE-based [1, 7], root-solving-based [2, 3, 4, 5, 11], and optimization-based [35, 36, 37] implicit models.
The ODE-based implicit models [1, 7] treat the iterative update rules of residual networks as the Euler discretization of an ODE, which could be solved by any black-box ODE solver. The gradient of the differential equation is calculated using the adjoint method [38], in which the adjoint state is obtained by solving another ODE. The root-solving-based implicit models [2, 5, 3, 4, 6, 11, 22] characterize layers of neural networks by solving fixed-point equations. The equations are solved by either the black-box root-finding solver [2, 3] or the fixed-point iteration [4, 22]. The optimization-based implicit models [35, 36, 37, 39, 34, 21, 40, 41] leverage the optimization programs as layers of neural networks. Previous works have studied differentiable layers of quadratic programming [35], submodular optimization [36], maximum satisfiability (MAXSAT) problems [37], and structured decomposition [21]. As for the backward passes, implicit differentiation is applied to the problemdefining equations of the root-solving-based models [2, 3] or the KKT conditions of the optimizationbased models [35]. As such, the gradient can be obtained from solving the backward linear system.
In this work, we focus on the root-solving-based implicit models. Theoretical works towards root-solving-based implicit models include the well-posedness [5, 4], monotone operators [11], global convergence [42, 41], and Lipschitz analysis [15]. We look into the theoretical aspect of the gradient-based algorithm in training implicit models and the efficient practice guidance. With these considerations, we show that implicit models of the same architecture could enjoy faster training speed and strong generalization in practical applications by using the phantom gradient.
Non-End-to-End Optimization in Deep Learning. Non-end-to-end optimization aims to replace the standard gradient-based training of deep architectures with modular or weakly modular training without the entire forward and backward passes. Currently, there are mainly three research directions in this field, namely, the auxiliary variable methods [43, 44, 45, 46, 47, 48, 49], target propagation [50, 51, 52], and synthetic gradient [24, 53, 54]. The auxiliary variable methods [43, 44, 45, 46, 47, 48, 49] formulate the optimization of neural networks as constrained optimization problems, in which the layer-wise activations are considered as trainable auxiliary variables. Then, the equality constraints are relaxed as penalty terms added to the objectives so that the parameters and auxiliary variables can be divided into blocks and thus optimized in parallel. The target propagation method [50, 51, 52] trains each module by having its activations regress to the pre-assigned targets, which are propagated backwards from the downstream modules. Specifically, the auto-encoder architecture is used to reconstruct targets at each layer. Finally, the synthetic gradient method [24, 53, 54] estimates the local gradient of neural networks using auxiliary models, and employ the synthetic gradient in place of the exact gradient to perform parameter update. In this way, the forward and backward passes are decoupled and can be executed in an asynchronous manner.
Our work is in line with the non-end-to-end optimization research since we also aims to decouple the forward and backward passes of neural networks. However, we show that finding a reasonable “target” or a precise gradient estimate is not always necessary in training deep architectures. Our paper paves a path that an inexact but well-conditioned gradient estimate can contribute to both fast training and competitive generalization of implicit models.
Differentiation through Implicit Dynamics. Differentiation through certain implicit dynamics is an important aspect in a wide range of research fields, including bilevel optimization [19, 9], metalearning [18, 55, 30], and sensitivity analysis [56]. Since the gradient usually cannot be computed analytically, researchers have to implicitly differentiate the dynamics at the converged point. The formula of the gradient typically contains a term of Jacobian-inverse (or Hessian-inverse), which is computationally prohibitive for large-scale models. (See Eq. (2) in our case.) Herein, several techniques have been developed to approximate the matrix inverse in the previous literature.
An intuitive solution is to differentiate through the unrolled steps of a numerical solver of the dynamics [57, 58, 8]. In particular, if a single step is unrolled, it reduces to the well-known one-step gradient [59, 18, 60, 34, 30, 21, 22], in which the inverse of Jacobian/Hessian is simply approximated by an identity matrix. On the contrary, unrolling a small number of steps may induce a bias [9], while the memory and computational cost grows linearly as the number of unrolled steps increases. Towards this issue, Shaban et al. [19] propose to truncate the long-term dependencies and differentiate through only the last $L$ steps. In fact, if the dynamics have converged to a stationary point, the finite-term truncation in Shaban et al. [19] is exactly the Neumann approximation of the Jacobian-inverse with the first $L$ terms. Based on this, Lorraine et al. [9] directly use the truncated Neumann series as an approximation of the Jacobian-inverse. Besides the unrolling-based methods, optimization-based approaches [61, 55] have been studied in this field as well. Since the Jacobian-inverse-vector product can be viewed as solution of a linear system, algorithms like the conjugate gradient method can be used to solve it.
# 5 Limitation and Future Work
The main limitation of this work lies in the hyperparameter tuning of the phantom gradient, especially for the damping factor $\lambda$ , which directly controls the gradient’s precision and conditioning, the implicit Jacobian regularization for UPG, the stability for NPG, and the final generalization behaviors. However, it has not been a hindrance to the application of phantom gradients in training implicit models as one can tune the hyperparameter according to the validation loss in the early training stage.
Regarding future works, we would like to highlight the following aspects: (1) eliminating the bias of the current phantom gradient, (2) constructing an adaptive gradient solver for implicit models, (3) analyzing the damping factor to provide practical guidance, (4) investigating the implicit Jacobian regularization, and (5) understanding how different noises in the gradients can impact the training of implicit models under different loss landscapes.
# 6 Conclusion
In this work, we explore the possibility of training implicit models via the efficient approximate phantom gradient. We systematically analyze the general condition of a gradient estimate so that the implicit model can be guaranteed to converge to an approximate stationary point of the loss function. Specifically, we give a sufficient condition under which a first-order oracle could always find an ascent direction of the loss landscape in the training process. Moreover, we introduce two instantiations of the proposed phantom gradient, based on either the damped fixed-point unrolling or the Neumann series. The proposed method shows a $1 . 4 \sim 1 . 7 \times$ acceleration with comparable or better performances on large-scale benchmarks. Overall, this paper provides a practical perspective on training implicit models with theoretical guarantees.
# Acknowledgments
Zhouchen Lin was supported by the NSF China (No.s 61625301 and 61731018), NSFC Tianyuan Fund for Mathematics (No. 12026606) and Project 2020BD006 supported by PKU-Baidu Fund. Yisen Wang was partially supported by the National Natural Science Foundation of China under Grant 62006153, and Project 2020BD006 supported by PKU-Baidu Fund. Shaojie Bai was sponsored by a grant from the Bosch Center for Artificial Intelligence.
# References
[1] Ricky T. Q. Chen, Yulia Rubanova, Jesse Bettencourt, and David K Duvenaud. Neural Ordinary Differential Equations. In Neural Information Processing Systems (NeurIPS), 2018. 1, 9 [2] Shaojie Bai, J. Zico Kolter, and Vladlen Koltun. Deep Equilibrium Models. In Neural Information Processing Systems (NeurIPS), 2019. 1, 2, 3, 6, 8, 9 [3] Shaojie Bai, Vladlen Koltun, and J. Zico Kolter. Multiscale Deep Equilibrium Models. In Neural Information Processing Systems (NeurIPS), pages 5238–5250, 2020. 1, 2, 6, 7, 8, 9 [4] Fangda Gu, Heng Chang, Wenwu Zhu, Somayeh Sojoudi, and Laurent El Ghaoui. Implicit Graph Neural Networks. In Neural Information Processing Systems (NeurIPS), pages 11984– 11995, 2020. 1, 2, 9 [5] Laurent El Ghaoui, Fangda Gu, Bertrand Travacca, Armin Askari, and Alicia Tsai. Implicit Deep Learning. SIAM Journal on Mathematics of Data Science, 3(3):930–958, 2021. 1, 2, 9 [6] Tiancai Wang, Xiangyu Zhang, and Jian Sun. Implicit Feature Pyramid Network for Object Detection. arXiv preprint arXiv:2012.13563, 2020. 1, 9 [7] Emilien Dupont, Arnaud Doucet, and Yee Whye Teh. Augmented Neural ODEs. In Neural Information Processing Systems (NeurIPS), 2019. 1, 9 [8] Luca Franceschi, Michele Donini, Paolo Frasconi, and Massimiliano Pontil. Forward and Reverse Gradient-Based Hyperparameter Optimization. In International Conference on Machine Learning (ICML), pages 1165–1173, 2017. 1, 10 [9] Jonathan Lorraine, Paul Vicol, and David Duvenaud. Optimizing Millions of Hyperparameters by Implicit Differentiation. In International Conference on Artificial Intelligence and Statistics (AISTATS), pages 1540–1552, 2020. 1, 3, 4, 10 [10] Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, Alexander C. Berg, and Li Fei-Fei. ImageNet: Large Scale Visual Recognition Challenge. International Journal on Computer Vision (IJCV), 115(3):211–252, 2015. 1, 2, 6 [11] Ezra Winston and J. Zico Kolter. Monotone operator equilibrium networks. In Neural Information Processing Systems (NeurIPS), pages 10718–10728, 2020. 2, 9 [12] Cheng Lu, Jianfei Chen, Chongxuan Li, Qiuhao Wang, and Jun Zhu. Implicit Normalizing Flows. In International Conference on Learning Representations (ICLR), 2021. 2 [13] Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. Pointer Sentinel Mixture Models. In International Conference on Learning Representations (ICLR), 2017. 2, 6 [14] Chirag Pabbaraju, Ezra Winston, and J. Zico Kolter. Estimating Lipschitz constants of monotone deep equilibrium models. In International Conference on Learning Representations (ICLR), 2021. 2 [15] Max Revay, Ruigang Wang, and Ian R Manchester. Lipschitz Bounded Equilibrium Networks. arXiv:2010.01732, 2020. 2, 9 [16] Charles G Broyden. A Class of Methods for Solving Nonlinear Simultaneous Equations. Mathematics of computation, 19(92):577–593, 1965. 3, 6 [17] Shaojie Bai, Vladlen Koltun, and J. Zico Kolter. Stabilizing Equilibrium Models by Jacobian Regularization. In International Conference on Machine Learning (ICML), 2021. 3, 8 [18] Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-Agnostic Meta-Learning for Fast Adaptation of Deep Networks. In International Conference on Machine Learning (ICML), pages 1126–1135, 2017. 3, 10 [19] Amirreza Shaban, Ching-An Cheng, Nathan Hatch, and Byron Boots. Truncated Backpropagation for Bilevel Optimization. In International Conference on Artificial Intelligence and Statistics (AISTATS), pages 1723–1732, 2019. 3, 4, 10 [20] Jens Behrmann, David Kristjanson Duvenaud, and Jörn-Henrik Jacobsen. Invertible Residual Networks. In International Conference on Machine Learning (ICML), 2019. 3 [21] Zhengyang Geng, Meng-Hao Guo, Hongxu Chen, Xia Li, Ke Wei, and Zhouchen Lin. Is Attention Better Than Matrix Decomposition? In International Conference on Learning Representations (ICLR), 2021. 3, 8, 9, 10 [22] Samy Wu Fung, Howard Heaton, Qiuwei Li, Daniel McKenzie, Stanley J. Osher, and Wotao Yin. Fixed Point Networks: Implicit Depth Models with Jacobian-Free Backprop. arXiv preprint arXiv:2103.12803, 2021. 3, 8, 9, 10 [23] Mehrdad Yazdani. Linear Backprop in non-linear networks. In Neural Information Processing Systems Workshops, 2018. 3 [24] Max Jaderberg, Wojciech Marian Czarnecki, Simon Osindero, Oriol Vinyals, Alex Graves, David Silver, and Koray Kavukcuoglu. Decoupled Neural Interfaces using Synthetic Gradients. In International Conference on Machine Learning (ICML), pages 1627–1635, 2017. 3, 9, 10 [25] Xavier Gastaldi. Shake-Shake Regularization. arXiv preprint arXiv:1705.07485, 2017. 3 [26] Guozhong An. The Effects of Adding Noise During Backpropagation Training on a Generalization Performance. Neural Computation, 8(3):643–674, 1996. 3 [27] Zhanxing Zhu, Jingfeng Wu, Bing Yu, Lei Wu, and Jinwen Ma. The Anisotropic Noise in Stochastic Gradient Descent: Its Behavior of Escaping from Sharp Minima and Regularization Effects. In International Conference on Machine Learning (ICML), pages 7654–7663, 2019. 3 [28] Jingfeng Wu, Wenqing Hu, Haoyi Xiong, Jun Huan, Vladimir Braverman, and Zhanxing Zhu. On the Noisy Gradient Descent that Generalizes as SGD. In International Conference on Machine Learning (ICML), pages 10367–10376, 2020. 3 [29] Ricky TQ Chen, Jens Behrmann, David K Duvenaud, and Joern-Henrik Jacobsen. Residual Flows for Invertible Generative Modeling. Neural Information Processing Systems (NeurIPS), pages 9916–9926, 2019. 3 [30] Xin-Yu Zhang, Taihong Xiao, Haolin Jia, Ming-Ming Cheng, and Ming-Hsuan Yang. SemiSupervised Learning with Meta-Gradient. In International Conference on Artificial Intelligence and Statistics (AISTATS), pages 73–81, 2021. 3, 8, 10 [31] Alex Krizhevsky. Learning Multiple Layers of Features from Tiny Images. Technical report, Citeseer, 2009. 6 [32] Takeru Miyato, Toshiki Kataoka, Masanori Koyama, and Yuichi Yoshida. Spectral Normalization for Generative Adversarial Networks. In International Conference on Learning Representations (ICLR), 2018. 6 [33] Geoffrey E Hinton, Nitish Srivastava, Alex Krizhevsky, Ilya Sutskever, and Ruslan R Salakhutdinov. Improving neural networks by preventing co-adaptation of feature detectors. arXiv preprint arXiv:1207.0580, 2012. 7 [34] Bryan Wilder, Eric Ewing, Bistra Dilkina, and Milind Tambe. End to end learning and optimization on graphs. In Neural Information Processing Systems (NeurIPS), pages 4672– 4683, 2019. 8, 9, 10 [35] Brandon Amos and J. Zico Kolter. OptNet: Differentiable Optimization as a Layer in Neural Networks. In International Conference on Machine Learning (ICML), pages 136–145, 2017. 9 [36] Josip Djolonga and Andreas Krause. Differentiable Learning of Submodular Models. Neural Information Processing Systems (NeurIPS), pages 1013–1023, 2017. 9 [37] Po-Wei Wang, Priya Donti, Bryan Wilder, and Zico Kolter. SATNet: Bridging deep learning and logical reasoning using a differentiable satisfiability solver. In International Conference on Machine Learning (ICML), pages 6545–6554, 2019. 9 [38] VG Boltyanskiy, Revaz V Gamkrelidze, YEF Mishchenko, and LS Pontryagin. Mathematical theory of optimal processes. 1962. 9 [39] Marin Vlastelica, Anselm Paulus, Vít Musil, Georg Martius, and Michal Rolínek. Differentiation of Blackbox Combinatorial Solvers. In International Conference on Learning Representations (ICLR), 2020. 9 [40] Stephen Gould, Richard Hartley, and Dylan Campbell. Deep Declarative Networks. IEEE Transactions on Pattern Recognition and Machine Intelligence (PAMI), 2021. 9 [41] Xingyu Xie, Qiuhao Wang, Zenan Ling, Xia Li, Yisen Wang, Guangcan Liu, and Zhouchen Lin. Optimization Induced Equilibrium Networks. arXiv preprint arXiv:2105.13228, 2021. 9 [42] Kenji Kawaguchi. On the Theory of Implicit Deep Learning: Global Convergence with Implicit Layers. In International Conference on Learning Representations (ICLR), 2020. 9 [43] Miguel Carreira-Perpinan and Weiran Wang. Distributed Optimization of Deeply Nested Systems. In International Conference on Artificial Intelligence and Statistics (AISTATS), pages 10–19, 2014. 9 [44] Gavin Taylor, Ryan Burmeister, Zheng Xu, Bharat Singh, Ankit Patel, and Tom Goldstein. Training Neural Networks Without Gradients: A Scalable ADMM Approach. In International Conference on Machine Learning (ICML), pages 2722–2731, 2016. 9 [45] Ziming Zhang, Yuting Chen, and Venkatesh Saligrama. Efficient Training of Very Deep Neural Networks for Supervised Hashing. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 1487–1495, 2016. 9 [46] Ziming Zhang and Matthew Brand. Convergent Block Coordinate Descent for Training Tikhonov Regularized Deep Neural Networks. In Neural Information Processing Systems (NeurIPS), 2017. 9 [47] Jinshan Zeng, Shikang Ouyang, Tim Tsz-Kit Lau, Shaobo Lin, and Yuan Yao. Global Convergence in Deep Learning with Variable Splitting via the Kurdyka-Łojasiewicz Property. arXiv preprint arXiv:1803.00225, 2018. 9 [48] Jia Li, Cong Fang, and Zhouchen Lin. Lifted Proximal Operator Machines. In Association for the Advancement of Artificial Intelligence (AAAI), pages 4181–4188, 2019. 9 [49] Fangda Gu, Armin Askari, and Laurent El Ghaoui. Fenchel Lifted Networks: A Lagrange Relaxation of Neural Network Training. In International Conference on Artificial Intelligence and Statistics (AISTATS), pages 3362–3371, 2020. 9 [50] Yoshua Bengio. How Auto-Encoders Could Provide Credit Assignment in Deep Networks via Target Propagation. arXiv preprint arXiv:1407.7906, 2014. 9 [51] Dong-Hyun Lee, Saizheng Zhang, Asja Fischer, and Yoshua Bengio. Difference Target Propagation. In International Conference on Learning Representations (ICLR), pages 498–515, 2015. 9 [52] Alexander Meulemans, Francesco Carzaniga, Johan Suykens, João Sacramento, and Benjamin F. Grewe. A Theoretical Framework for Target Propagation. In Neural Information Processing Systems (NeurIPS), pages 20024–20036, 2020. 9 [53] Wojciech Marian Czarnecki, Grzegorz Swirszcz, Max Jaderberg, Simon Osindero, Oriol Vinyals, ´ and Koray Kavukcuoglu. Understanding Synthetic Gradients and Decoupled Neural Interfaces. In International Conference on Machine Learning (ICML), pages 904–912, 2017. 9, 10 [54] Benjamin James Lansdell, Prashanth Ravi Prakash, and Konrad Paul Kording. Learning to solve the credit assignment problem. In International Conference on Learning Representations (ICLR), 2020. 9, 10 [55] Aravind Rajeswaran, Chelsea Finn, Sham M Kakade, and Sergey Levine. Meta-Learning with Implicit Gradients. In Neural Information Processing Systems (NeurIPS), 2019. 10 [56] J Frédéric Bonnans and Alexander Shapiro. Perturbation analysis of optimization problems. Springer Science & Business Media, 2013. 10 [57] Justin Domke. Generic Methods for Optimization-Based Modeling. In International Conference on Artificial Intelligence and Statistics (AISTATS), pages 318–326, 2012. 10 [58] Dougal Maclaurin, David Duvenaud, and Ryan Adams. Gradient-based Hyperparameter Optimization through Reversible Learning. In International Conference on Machine Learning (ICML), pages 2113–2122, 2015. 10 [59] Jelena Luketina, Mathias Berglund, Klaus Greff, and Tapani Raiko. Scalable Gradient-Based Tuning of Continuous Regularization Hyperparameters. In International Conference on Machine Learning (ICML), pages 2952–2960, 2016. 10 [60] Hanxiao Liu, Karen Simonyan, and Yiming Yang. DARTS: Differentiable Architecture Search. International Conference on Learning Representations (ICLR), 2018. 10 [61] Fabian Pedregosa. Hyperparameter Optimization with Approximate Gradient. In International Conference on Machine Learning (ICML), pages 737–746, 2016. 10123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389# DUAL CONTRADISTINCTIVE GENERATIVE AUTOENCODER
Anonymous authors Paper under double-blind review
# ABSTRACT
We present a new generative autoencoder model with dual contradistinctive losses to improve generative autoencoder that performs simultaneous inference (reconstruction) and synthesis (generation). We name our model dual contradistinctive generative autoencoder (DC-VAE) that integrates an instance-level discriminative loss (maintaining the instance-level fidelity for the reconstruction/synthesis) with a set-level adversarial loss (encouraging the set-level fidelity for the reconstruction/synthesis), both being contradistinctive. There also exists a mathematical connection between the instance-based classification and instance-level conditional distribution. DC-VAE achieves competitive results in three tasks, including image synthesis, image reconstruction, and representation learning. DC-VAE is applicable to various tasks in computer vision and machine learning.
 (a) DC-VAE (ours) Reconstruction results. Left: $1 2 8 \times 1 2 8$ . Right: $5 1 2 \times 5 1 2$ .
 (b) DC-VAE (ours) Sampling results. Left: $1 2 8 \times 1 2 8$ . Right: $5 1 2 \times 5 1 2$ Figure 1: DC-VAE Reconstruction (top) and Sampling (bottom) on LSUN Bedroom $\mathrm { Y u }$ et al. (2015) at resolution $1 2 8 \times 1 2 8$ (left) and CelebA-HQ (Karras et al., 2018) at resolution $5 1 2 \times 5 1 2$ (right).
# 1 INTRODUCTION
Tremendous progress has been made in deep learning for the development of various learning frameworks (Krizhevsky et al., 2012; He et al., 2016; Goodfellow et al., 2014; Vaswani et al., 2017). Autoencoder (AE) (LeCun, 1987; Hinton & Zemel, 1994) aims to compactly represent and faithfully reproduce the original input signal by concatenating an encoder and a decoder in an end-to-end learning framework. The goal of AE is to make the encoded representation semantically efficient and sufficient to reproduce the input signal by its decoder. Autoencoder’s generative companion, variational autoencoder (VAE) (Kingma & Welling, 2014), additionally learns a variational model for the latent variables to capture the underlying sample distribution. For the encoder and decoder models separately, tremendous progress has been made in image classification with deep convolutional neural network (CNN) (Krizhevsky et al., 2012; He et al., 2016) (an encoder) and in image generation with generative adversarial network (GAN) (Goodfellow et al., 2014) (a decoder).
The key objective for a generative autoencoder is to maintain two types of fidelities: (1) an instancelevel fidelity to make the reconstruction/synthesis faithful to the individual input data sample, and (2) a set-level fidelity to make the reconstruction/synthesis of the decoder faithful to the entire input data set. The VAE/GAN algorithm (Larsen et al., 2016) combines a reconstruction loss with an adversarial loss. However, the result of VAE/GAN is sub-optimal, as shown in Table 1.
The pixel-wise reconstruction loss in the standard VAE (Kingma & Welling, 2014) typically results in blurry images with degenerated semantics. A possible solution to resolving the above conflict lies in two aspects: (1) turning the measure in the pixel space into induced feature space that is more semantically meaningful; (2) changing the L2 distance (per-pixel) into a learned instance-level distance function for the entire image (akin to generative adversarial networks which learn set-level distance functions). Taking these two steps allows us to design an instance-level classification loss that is aligned with the adversarial loss in the GAN model enforcing set-level fidelity. Motivated by the above observations, we develop a new generative autoencoder model with dual contradistinctive losses by adopting a discriminative loss performing instance-level classification (enforcing the instance-level fidelity), which is rooted in metric learning (Kulis et al., 2012) and contrastive learning (Hadsell et al., 2006; Wu et al., 2018; van den Oord et al., 2018). Combined with the adversarial losses for the set-level fidelity, both terms are formulated in the induced feature space performing contradistinction: (1) the instance-level contrastive loss considers each input instance (image) itself as a class, and (2) the set-level adversarial loss treats the entire input set as a positive class. We name our method dual contradistinctive generative autoencoder (DC-VAE) and make the following contributions.
• We develop a new algorithm, dual contradistinctive generative autoencoder (DC-VAE), by combining instance-level and set-level classification losses in the VAE framework, and systematically show the significance of these two loss terms in DC-VAE. • The effectiveness of DC-VAE is illustrated in three tasks altogether, including image synthesis, image reconstruction, and representation learning.
# 2 RELATED WORK
Related work can be roughly divided into three categories: (1) generative autoencoder, (2) deep generative model, and (3) contrastive learning.
Variational autoencoder (VAE) (Kingma & Welling, 2014) points to an exciting direction of generative models by developing an Evidence Lower BOund (ELBO) objective (Higgins et al., 2017; Ding et al., 2020). However, the VAE reconstruction/synthesis is known to be blurry. To improve the image quality, a sequence of VAE based models have been developed (Larsen et al., 2016; Dumoulin et al., 2017; Huang et al., 2018; Brock et al., 2018; Zhang et al., 2019). VAE/GAN (Larsen et al., 2016) adopts an adversarial loss to improve the quality of the image, but its output for both reconstruction and synthesis (new samples) is still unsatisfactory. IntroVAE Huang et al. (2018) adds a loop from the output back to the input and is able to attain image quality that is on par with some modern GANs in some aspects. However, its full illustration for both reconstruction and synthesis is unclear. PGA (Zhang et al., 2019) adds a constraint to the latent variables.
Pioneering works of (Tu, 2007; Gutmann & Hyvärinen, 2012) alleviate the difficulty of learning densities by approximating likelihoods via classification (real (positive) samples vs. fake (pseudonegative or adversarial) samples). Generative adversarial network (GAN) (Goodfellow et al., 2014) builds on neural networks and amortized sampling (a decoder network that maps a noise into an image). The subsequent development after GAN (Radford et al., 2016; Arjovsky et al., 2017; Gulrajani et al., 2017; Karras et al., 2018; Gong et al., 2019; Dumoulin et al., 2017; Donahue et al., 2017) has led to a great leap forward in building decoder-based generative models. It has been widely observed that the adversarial loss in GANs contributes significantly to the improved quality of image synthesis. Energy-based generative models (Salakhutdinov & Hinton, 2009; Xie et al., 2016; Jin et al., 2017; Lee et al., 2018) — which aim to directly model data density — are making a steady improvement for a simultaneously generative and discriminative single model.
From another angle, contrastive learning (Hadsell et al., 2006; Wu et al., 2018; He et al., 2020; Chen et al., 2020) has lately shown its particular advantage in unsupervised training of CNN features. It overcomes the limitation in unsupervised learning where class label is missing by turning each image instance into one class. Thus, the softmax function in the standard discriminative classification training can be applied. Contrastive learning can be connected to metric learning (Bromley et al., 1993; Chopra et al., 2005; Chechik et al., 2010).
In this paper, we aim to improve VAE (Kingma & Welling, 2014) by introducing a contrastive loss (van den Oord et al., 2018) to address instance-level fidelity between the input and the reconstruction in the induced feature space. Unlike in self-supervised representation learning methods (van den Oord et al., 2018; He et al., 2020; Chen et al., 2020), where self-supervision requires generating a transformed input (via data augmentation operations), the reconstruction naturally fits into the contrastive term that encourages the matching between the reconstruction and the input image instance, while pushing the reconstruction away from the rest of the images in the entire training set. Thus, the instance-level and set-level contradistinctive terms collaborate with each to encourage the high fidelity of the reconstruction and synthesis. In Figure 3, we systematically show the significance of with and without the instance-level and the set-level contradistinctive terms. In addition, we explore multi-scale contrastive learning via two schemes in Section 4.1: 1) deep supervision for contrastive learning in different convolution layers, and 2) patch-based contrastive learning for fine-grained data fidelity. In the experiments, we show competitive results for the proposed dual contradistinctive generative autoencoder (DC-VAE) in a number of benchmarks for three tasks, including image synthesis, image reconstruction, and representation learning.
# 3 PRELIMINARIES: VAE AND VAE/GAN
Variational autoencoder (VAE) Assume a given training set $S = \{ \mathbf { x } _ { i } \} _ { i = 1 } ^ { n }$ where each $\mathbf { x } _ { i } \in \mathbb { R } ^ { m }$ We suppose that each $\mathbf { x } _ { i }$ is sampled from a generative process $p ( \mathbf { x } | \mathbf { z } )$ . In the literature, vector $\mathbf { z }$ refers to latent variables. In practice, latent variables $\mathbf { z }$ and the generative process $p ( \mathbf { x } | \mathbf { z } )$ are unknown. The objectives of a variational autoencoder (VAE) (Kingma & Welling, 2014) is to simultaneously train an inference network $q _ { \phi } ( \mathbf { z } | \mathbf { x } )$ and a generator network $p _ { \pmb { \theta } } ( \mathbf { x } | \mathbf { z } )$ . In VAE (Kingma $\&$ Welling, 2014), the inference network is a neural network that outputs parameters for Gaussian distribution $q _ { \phi } ( \mathbf { z } | \mathbf { x } ) = \mathcal { N } ( \mu _ { \phi } ( \mathbf { x } ) , \Sigma _ { \phi } ( \mathbf { x } ) )$ . The generator is a deterministic neural network $f _ { \pmb \theta } ( \mathbf z )$ parameterized by $\pmb { \theta }$ . Generative density $p _ { \pmb { \theta } } ( \mathbf { x } | \mathbf { z } )$ is assumed to be subject to a Gaussian distribution: $p _ { \pmb { \theta } } ( \mathbf { x } | \mathbf { z } ) = \dot { \mathcal { N } } ( f _ { \pmb { \theta } } ( \mathbf { z } ) , \sigma ^ { 2 } I )$ . These models can be trained by minimizing the negative of evidence lower bound (ELBO) in Eq. (1) below.
$$\begin{array} { r } { \mathcal { L } _ { \mathrm { E L B O } } ( \pmb { \theta } , \phi ; \mathbf { x } ) = - \mathbb { E } _ { \mathbf { z } \sim q _ { \phi } ( \mathbf { z } | \mathbf { x } ) } [ \mathrm { l o g } ( p _ { \theta } ( \mathbf { x } | \mathbf { z } ) ) ] + K L [ q _ { \phi } ( \mathbf { z } | \mathbf { x } ) | | p ( \mathbf { z } ) ] } \end{array}$$
where $p ( \mathbf { z } )$ is the prior, which is assumed to be $\mathcal { N } ( 0 , I )$ . The first term $- \mathbb { E } _ { q _ { \phi } ( \mathbf { z } | \mathbf { x } ) } [ \log ( p _ { \pmb { \theta } } ( \mathbf { x } | \mathbf { z } ) ) ]$ reduces to standard pixel-wise reconstruction loss $\mathbb { E } _ { q _ { \phi } ( \mathbf { z } | \mathbf { x } ) } [ | | \mathbf { x } - f _ { \theta } ( \mathbf { z } ) | | _ { 2 } ^ { 2 } ]$ (up to a constant) due to the Gaussian assumption. The second term is the regularization term, which prevents the conditional $q _ { \phi } ( \mathbf { z } | \mathbf { x } )$ from deviating from the Gaussian prior $\mathcal { N } ( 0 , I )$ . The inference network and generator network are jointly optimized over training samples by:
$$\operatorname* { m i n } _ { \theta , \phi } \operatorname* { \mathbb { E } } _ { \mathbf { x } \sim p _ { \mathrm { d a t a } } ( \mathbf { x } ) } \mathcal { L } _ { \mathrm { E L B O } } ( \theta , \phi ; \mathbf { x } ) .$$
where $p _ { \mathrm { d a t a } }$ is the distribution induced by the training set $S$ .
VAE has an elegant formulation. However, it relies on a pixel-wise reconstruction loss, which is known not ideal to be reflective of perceptual realism (Johnson et al., 2016; Isola et al., 2017), often resulting in blurry images. From another viewpoint, it can be thought of as using a kernel density estimator (with an isotropic Gaussian kernel) in the pixel space. Although allowing efficient training and inference, such a non-parametric approach is overly simplistic for modeling the semantics and perception of natural images.
VAE/GAN Generative adversarial networks (GANs) (Goodfellow et al., 2014) and its variants (Radford et al., 2016), on the other hand, are shown to be producing highly realistic images. The success was largely attributed to learning a fidelity function (often referred to as a discriminator) that measures how realistic the generated images are. This can be achieved by learning to contrast (classify) the set of training images with the set of generated images (Tu, 2007; Gutmann & Hyvärinen, 2012; Goodfellow et al., 2014).
VAE/GAN (Larsen et al., 2016) augments the ELBO objective (Eq. (2)) with the GAN objective. Specifically, the objective of VAE/GAN consists of two terms, namely the modified ELBO (Eq. (3))
and the GAN objective. To make the notations later consistent, we now define the set of given training images as ${ \cal { S } } = \{ { \bf { x } } _ { i } \} _ { i = 1 } ^ { n }$ in which a total number of $n$ unlabeled training images are present. For each input image $\mathbf { x } _ { i }$ , the modified ELBO computes the reconstruction loss in the feature space of the discriminator instead of the pixel space:
$$\mathcal { L } _ { \mathrm { E L B O } } ( \theta , \phi , D ; \mathbf { x } _ { i } ) = \mathbb { E } _ { \mathbf { z } \sim q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { i } ) } [ | | F _ { D } ( \mathbf { x } _ { i } ) - F _ { D } ( f _ { \theta } ( \mathbf { z } ) ) | | _ { 2 } ^ { 2 } ] + K L [ q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { i } ) | | p ( \mathbf { z } ) ]$$
where $F _ { D } ( \cdot )$ denotes the feature embedding from the discriminator $D$ . Feature reconstruction loss (also referred to as perceptual loss), similar to that in style transfer (Johnson et al., 2016). The modified GAN objective considers both reconstructed images (latent code from $q _ { \phi } ( \mathbf { z } | \mathbf { x } ) )$ and sampled images (latent code from the prior $p ( \mathbf { z } ) .$ ) as its fake samples:
$$\begin{array} { r } { \mathcal { L } _ { \mathrm { G A N } } ( \pmb { \theta } , \phi , D ; \mathbf { x } _ { i } ) = \log D ( \mathbf { x } _ { i } ) + \mathbb { E } _ { \mathbf { z } \sim q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { i } ) } \log ( 1 - D ( f _ { \theta } ( \mathbf { z } ) ) + \mathbb { E } _ { \mathbf { z } \sim p ( \mathbf { z } ) } \log ( 1 - D ( f _ { \theta } ( \mathbf { z } ) ) . } \end{array}$$
The VAE/GAN objective becomes:
$$\operatorname* { m i n } _ { \theta , \phi } \operatorname* { m a x } _ { D } \sum _ { i = 1 } ^ { n } \left[ \mathcal { L } _ { \mathrm { E L B O } } ( \theta , \phi , D ; \mathbf { x } _ { i } ) + \mathcal { L } _ { \mathrm { G A N } } ( \theta , \phi , D ; \mathbf { x } _ { i } ) \right] .$$
# 4 DUAL CONTRADISTINCTIVE GENERATIVE AUTOENCODER (DC-VAE)
Here we want to address a question: Is the degeneration of the synthesized images by VAE always the case once the decoder is joined with an encoder? Can the problem be remedied by using a more informative loss?
Although improving the image qualities of VAE by integrating a set-level contrastive loss (GAN objective of Eq. (4)), VAE/GAN still does not accurately model instance-level fidelity. Inspired by the literature on instance-level classification (Malisiewicz et al., 2011), approximating likelihood by classification (Tu, 2007), and contrastive learning (Hadsell et al., 2006; Wu et al., 2018; He et al., 2020), we propose to model instance-level fidelity by contrastive loss (commonly referred to as InfoNCE loss) (van den Oord et al., 2018). In DC-VAE, we perform the following minimization and loosely call each term a loss.
$$\mathcal { L } _ { \mathrm { i n s t a n c e } } ( \pmb { \theta } , \phi , D ; i , \{ \mathbf { x } _ { j } \} _ { j = 1 } ^ { n } ) \triangleq - \mathbb { E } _ { \mathbf { z } \sim q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { i } ) } \left[ \log \frac { e ^ { h ( \mathbf { x } _ { i } , f _ { \pmb { \theta } } ( \mathbf { z } ) ) } } { \sum _ { j = 1 } ^ { n } e ^ { h ( \mathbf { x } _ { j } , f _ { \pmb { \theta } } ( \mathbf { z } ) ) } } \right] ,$$
where $i$ is an index for a training sample (instance), $\{ { \bf x } _ { j } \} _ { j = 1 } ^ { n }$ is the union of positive samples and negative samples, $h ( \mathbf x , \mathbf y )$ is the critic function that measures compatibility between $\mathbf { x }$ and $\mathbf { y }$ . Following the popular choice from (He et al., 2020), $h ( \mathbf x , \mathbf y )$ is the cosine similarity between the embeddings of $\mathbf { x }$ and y: $\begin{array} { r } { h ( \mathbf { x } , \mathbf { y } ) = \frac { F _ { D } ( \mathbf { x } ) ^ { \top } F _ { D } ( \mathbf { y } ) } { | | F _ { D } ( \mathbf { x } ) | | _ { 2 } | | F _ { D } ( \mathbf { y } ) | | _ { 2 } } } \end{array}$ . Note that unlike in contrastive self-supervised learning methods (van den Oord et al., 2018; He et al., 2020; Chen et al., 2020) where two views (independent augmentations) of an instance constitutes a positive pair, an input instance $\mathbf { x } _ { i }$ and its reconstruction $f _ { \pmb \theta } ( \mathbf z )$ comprises a positive pair in DC-VAE. Likewise, the reconstruction $f _ { \pmb \theta } ( \mathbf z )$ and any instance that is not $\mathbf { x } _ { i }$ can be a negative pair.
To bridge the gap between the instance-level contrastive loss (Eq. (6)) and log-likelihood in ELBO term (Eq. (1)), we show the following observation.
Theorem 1 (From (Ma & Collins, 2018; Poole et al., 2019)) The following objective is minimized, i.e., the optimal critic $h$ is achieved, when $h ( f _ { \pmb \theta } ( \mathbf { z } ) , \mathbf { x } ) = \log { p ( \mathbf { x } | \mathbf { z } ) } + \overset { \cdot } { c } ( \mathbf { x } )$ where $c ( \mathbf { x } )$ is any function that does not depend on $\mathbf { z }$ .
$$I _ { N C E } \triangleq \mathbb { E } _ { { \mathbf { x } } _ { 1 } , \cdots { \mathbf { x } } _ { K } } \mathbb { E } _ { i } \big [ \mathcal { L } _ { i n s t a n c e } ( \pmb { \theta } , \phi , D ; i , \{ { \mathbf { x } } _ { j } \} _ { j = 1 } ^ { n } ) \big ] .$$
From Theorem 1, we see that the contrastive loss of Eq. (6) implicitly estimates the log-likelihood $\log p _ { \theta } ( \mathbf { x } | \mathbf { z } )$ required for the evidence lower bound (ELBO). Hence, we modify the ELBO objective of Eq. (1) as follows and name it as implicit ELBO (IELBO):
$$\mathcal { L } _ { \mathrm { I E L B O } } ( \pmb { \theta } , \phi , D ; \mathbf { x } _ { i } ) = \mathcal { L } _ { \mathrm { i n s t a n c e } } ( \pmb { \theta } , \phi , D ; i , \{ \mathbf { x } _ { j } \} _ { j = 1 } ^ { n } ) + K L [ q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { i } ) | | p ( \mathbf { z } ) ] .$$
 Figure 2: Model architecture for the proposed DC-VAE algorithm.
Finally, the combined objective for the proposed DC-VAE algorithm becomes:
$$\operatorname* { m i n } _ { \theta , \phi } \operatorname* { m a x } _ { D } \sum _ { i = 1 } ^ { n } \left[ \mathcal { L } _ { \mathrm { I E L B O } } ( \theta , \phi , D ; \mathbf { x } _ { i } ) + \mathcal { L } _ { \mathrm { G A N } } ( \theta , \phi , D ; \mathbf { x } _ { i } ) \right] .$$
The definition of $\mathcal { L } _ { \mathrm { G A N } }$ follows Eq. (4). Note here we also consider the term in Eq. (4) as contrasdistinctive since it tries to minimize the difference/discriminative classification between the input (“real”) image set and the reconstructed/generated (“fake”) image set. Below we highlight the significance of the two contradistinctive terms. Figure 2 shows the model architecture.
• Instance-level fidelity. The first item in Eq. (8) is an instance-level fidelity term encouraging the reconstruction to be as close as possible to the input image while being different from all the rest of the images. A key advantage of the contrastive loss in Eq. (8) over the standard reconstruction loss in Eq. (3) is its relaxed and background instances aware formulation. In general, the reconstruction in Eq. (3) wants a perfect match between the reconstruction and the input, whereas the contrastive loss in Eq. (8) requests for being the most similar one among the training samples. This way, the contrastive loss becomes more cooperative with less conflict to the GAN loss, compared with the reconstruction loss. The introduction of the contrastive loss results in a significant improvement over VAE and VAE/GAN in which only matching the reconstruction, and the input instance is enforced.
• Set-level fidelity. The second item in Eq. (9) is a set-level fidelity term encouraging the entire set of synthesized images to be non distinguishable from the input image set. Having this term (Eq. (4)) is still important since the instance contrastive loss alone (Eq. (9)) will also lead to a degenerated situation: the input image and its reconstruction can be projected to the same point in the new feature space, but without a guarantee that the reconstruction itself lies on the valid “real” image manifold.
As shown in Figure 3 and Table 1 for the comparison with and without the individual terms in Eq. (9). We observe evident effectiveness of the proposed DC-VAE combining both the instance-level fidelity term (Eq. (6)) and the set-level fidelity term (Eq. (4)), compared with VAE (using pixel-wise reconstruction loss without the GAN objective), VAE-GAN (using feature reconstruction loss and the GAN objective), and VAE contrastive (using contrastive loss but without the GAN objective).
In the experiments, we show that both terms required to achieve faithful reconstruction (captured by InfoNCE loss) with perceptual realism (captured by the GAN loss).
# 4.1 MULTI SCALE CONTRASTIVE LEARNING
Inspired by (Lee et al., 2015), we utilize information from feature maps at different scales. In addition to contrasting on the last layer of $D$ in Equation 9, we add contrastive objective on $f _ { l } ( \mathbf { z } )$ where $f _ { l }$ is some function on top of an intermediate layer $l$ of D. We do it in two different ways.
1. Deep supervision: We use $1 \times 1$ convolution to reduce the dimension channel-wise, and use a linear layer to obtain $f _ { l }$ . 2. Local patch: We use a random location across channel at layer $l$ (size: $1 \times 1 \times \mathrm { d }$ , where d is the channel depth).
The intuition for the second is that in a convolutional neural network, one location at a feature map corresponds to a receptive area (patch) in the original image. Thus, by contrasting locations across channels in the same feature maps, we are encouraging the original image and the reconstruction to image have locally similar content, while encouraging them to have locally dissimilar content in other images. We use deep supervision for initial training, and add local patch after certain iterations.
# 5 EXPERIMENTS
 Figure 3: Qualitative results of CIFAR-10 (Krizhevsky et al., 2009) images (resolution $3 2 \times 3 2$ ) for experiments in Table 1 (Krizhevsky et al., 2009).
# 5.1 IMPLEMENTATION
Datasets To validate our method, we train our method on several different datasets — CIFAR-10 (Krizhevsky et al., 2009), STL-10 (Coates et al., 2011), CelebA (Liu et al., 2015), CelebA-HQ (Karras et al., 2018), and LSUN bedroom (Yu et al., 2015). See the appendix for more detailed descriptions.
Network architecture For $3 2 \times 3 2$ resolution, we design the encoder and decoder subnetworks of our model in a similar way to the discriminator and generator found through neural architecture search in AutoGAN (Gong et al., 2019). For the higher resolution experiments $1 2 8 \times 1 2 8$ and $5 1 2 \times 5 1 2$ resolution), we use Progressive GAN (Karras et al., 2018) as the backbone. Network architecture diagram is available in the appendix.
Training details The number of negative samples for contrastive learning is 8096 for all datasets. The latent dimension for the VAE decoder is 128 for CIFAR-10, STL-10, and 512 for CelebA, CelebA-HQ and LSUN Bedroom. Learning rate is 0.0002 with Adam parameters of $( \beta _ { 1 } , \beta _ { 2 } ) = ( 0 . 0 , 0 . 9 )$ and a batch size of 128 for CIFAR-10 and STL-10. For CelebA, CelebA-HQ, LSUN Bedroom datasets, we use the optimizer parameters given in (Karras et al., 2018). The contrastive embedding dimension used is 16 for each of the experiments.
# 5.2 ABLATION STUDY
Table 1: Ablation studies on CIFAR-10 for the proposed DC-VAE algorithm. We follow (Johnson et al., 2016) and measure perceptual distance in an relu4_3 layer of a pretrained VGG network. $\downarrow$ means lower is better. ↑ means higher is better.
<table><tr><td>Method</td><td>FID↓/IS↑ Sampling</td><td>FID↓/IS↑ Reconstruction</td><td>Pixel↓ Distance</td><td>Perceptual↓ Distance</td></tr><tr><td>VAE</td><td>115.8 /3.8</td><td>108.4/4.3</td><td>21.8</td><td>65.8</td></tr><tr><td>VAE/GAN</td><td>39.8 /7.4</td><td>29.0 /7.6</td><td>62.7</td><td>57.2</td></tr><tr><td>VAE-Contrastive</td><td>240.4 /1.8</td><td>242 /1.9</td><td>53.6</td><td>104.2</td></tr><tr><td>DC-VAE</td><td>17.9 /8.2</td><td>21.4 / 7.9</td><td>45.9</td><td>52.9</td></tr></table>
To demonstrate the necessity of the GAN loss (Eq. 4) and contrastive loss (Eq. 8), we conduct four experiments with the same backbone. These experiments are: VAE (No GAN, no Contrastive),
VAE/GAN (with GAN, no Contrastive), VAE-Contrastive (No GAN, with Contrastive, and ours (With GAN, with Contrastive). Here, GAN denotes Eq. 4, and Contrastive denotes Eq. 8.
Qualitative analysis From Figure 3, we see that without GAN and contrastive, images are blurry; Without GAN, the contrastive head can classify images, but not on the image manifold; Without Contrastive, reconstruction images are on the image manifold because of the discriminator, but they are different from input images. These experiments show that it is necessary to combine both instance-level and set-level fidelity, and in a contradistinctive manner.
Quantitative analysis In Table 1 we observe the same trend. VAE generates blurry images; thus the FID/IS (Inception Score) is not ideal. VAE-Contrastive does not generate images on the natural manifold; thus FID/IS is poor. VAE/GAN combines set-level and instance-level information. However the L2 objective is not ideal; thus the FID/IS is sub-optimal. For both reconstruction and sampling tasks, DC-VAE generates high fidelity images and has a favorable FID and Inception score. This illustrates the advantange of having a contradistinctive objective on both set level and instance level. To measure the faithfulness of the reconstructed image we compute the pixelwise L2 distance and the perceptual distance (Johnson et al. (2016)). For the pixel distance, VAE has the lowest value because it directly optimizes this distance during training; our pixel-wise distance is better than VAE/GAN and VAE-Contrastive. For perceptual distance, our method outperforms other three, which confirms that using contrastive learning helps reconstruct images semantically.
Table 2: Comparison on CIFAR-10 and STL-10. Average Inception scores (Salimans et al., 2016) and FID scores (Heusel et al., 2017). Results derived from (Gong et al., 2019). Table style derived from (Lee et al., 2019). †Result from Aneja et al. (2020). ∗Result from (Dieng et al., 2019).
<table><tr><td rowspan="2">Method</td><td colspan="2">CIFAR-10</td><td colspan="2">STL-10</td></tr><tr><td>Inception Score↑</td><td>FID↓</td><td>Inception Score↑</td><td>FID↓</td></tr><tr><td>Methods based on GAN:</td><td></td><td></td><td></td><td></td></tr><tr><td>DCGAN (Radford et al.,2016)</td><td>6.6</td><td></td><td></td><td>-</td></tr><tr><td>ProbGAN (He et al.,2019)</td><td>7.8</td><td>24.6</td><td>8.9</td><td>46.7</td></tr><tr><td>WGAN-GP ResNet (Gulrajani et al.,2017)</td><td>7.9</td><td>-</td><td>-</td><td>-</td></tr><tr><td>RaGAN (Jolicoeur-Martineau,2018)</td><td>=</td><td>23.5</td><td>=</td><td>■</td></tr><tr><td>SN-GAN (Miyato et al., 2018)</td><td>8.2</td><td>21.7</td><td>9.1</td><td>40.1</td></tr><tr><td>MGAN (Hoang et al., 2018)</td><td>8.3</td><td>26.7</td><td>-</td><td>-</td></tr><tr><td>Progressive GAN (Karras et al.,2018)</td><td>8.8</td><td>-</td><td>■</td><td>=</td></tr><tr><td>Improving MMD GAN(Wang et al.,2019)</td><td>8.3</td><td>16.2</td><td>9.3</td><td>37.6</td></tr><tr><td>PULSGAN (Guo et al., 2020)</td><td>■</td><td>22.3</td><td>=</td><td>-</td></tr><tr><td>AutoGAN (Gong et al., 2019)</td><td>8.6</td><td>12.4</td><td>9.2</td><td>31.0</td></tr><tr><td>MethodsbasedonVAE:</td><td></td><td></td><td></td><td></td></tr><tr><td>VAE</td><td>3.8</td><td>115.8</td><td></td><td></td></tr><tr><td>VAE/GAN</td><td>7.4</td><td>39.8</td><td></td><td></td></tr><tr><td>VEEGAN* (Srivastava et al.,2017)</td><td>-</td><td>95.2</td><td></td><td></td></tr><tr><td>WAE-GAN (Tolstikhin et al., 2017)</td><td></td><td>93.1</td><td></td><td></td></tr><tr><td>NVAE†(Vahdat & Kautz,202O) Sampling</td><td></td><td>50.8</td><td></td><td></td></tr><tr><td>NVAE† (Vahdat & Kautz,2020) Reconstruction</td><td>=</td><td>2.67</td><td>=</td><td></td></tr><tr><td>DC-VAE Sampling (ours)</td><td>8.2</td><td>17.9</td><td>8.1</td><td>41.9</td></tr><tr><td>DC-VAE Reconstruction (ours)</td><td>7.9</td><td>21.4</td><td>8.4</td><td>43.6</td></tr></table>
# 5.3 COMPARISON TO EXISTING GENERATIVE MODELS
Table 2 gives a comparison of quantitative measurement for CIFAR-10 and STL-10 dataset. In general, there is a large difference in terms of FID and IS between GAN family and VAE family of models. Our model has state-of-the-art results in VAE family, and is comparable to state-of-the-art GAN models on CIFAR-10. Similarly Table 4 shows that DC-VAE is able to generate images that are comparable to GAN based methods even on higher resolution datasets.
# 5.4 LATENT SPACE REPRESENTATION: IMAGE AND STYLE INTERPOLATION
We further validate the effectiveness of DC-VAE for representation learning. One benefit of having an AE/VAE framework compared with just a decoder as in GAN Goodfellow et al. (2014) is to be able to directly obtain the latent representation from the input images. The encoder and decoder modules in VAE allows us to readily perform image/style interpolation by mixing the latent variables of different images and reconstruct/synthesize new ones. We demonstrate qualitative results on image interpolation (Fig. 5, Appendix Fig. 9), style interpolation (Appendix Fig. 10) and image editing (Fig. 6). We directly use the trained DC-VAE model without disentanglement learning Karras et al. (2019). Additional latent space analysis and the method used for interpolation and editing is provided in the Appendix. We also quantitatively compare the latent space disentanglement through the perceptual path length (PPL) (Karras et al., 2019) (Table 6). We observe that DC-VAE learns a more disentangled latent space representation than the backbone Progressive GAN (Karras et al., 2018) and StyleALAE (Pidhorskyi et al., 2020) that uses a much more capable StyleGAN (Karras et al., 2019) backbone.
 (c) DC-VAE Reconstruction (ours, $5 1 2 \times 5 1 2$ ) Figure 4: Comparison of DC-VAE (resolution $5 1 2 \times 5 1 2$ ) with IntroVAE (Huang et al., 2018) (resolution $1 0 2 4 \times 1 0 2 4 )$ ).
Table 3: Quality of image generation (FID) comparison on LSUN Bedrooms. $^ \dag 1 2 8 \times 1 2 8$ resolution. $^ \dag 2 5 6 \times 2 5 6$ resolution. $\downarrow$ means lower is better.
<table><tr><td>Method</td><td>FID↓</td></tr><tr><td>Progressive GAN‡ (Karras et al.,2018)</td><td>8.3</td></tr><tr><td>SNGANt (Miyato et al.,2018)(from (Chen et al.,2019))</td><td>16.0</td></tr><tr><td>SSGANt(Chen et al., 2019)</td><td>13.3</td></tr><tr><td>StyleALAE(Pidhorskyi et al.,202O) Reconstruction</td><td>15.92</td></tr><tr><td>StyleALAE(Pidhorskyi et al.,2020) Sampling</td><td>17.13</td></tr><tr><td>DC-VAEt (ours) Reconstruction</td><td>10.57</td></tr><tr><td>DC-VAEt (ours) Sampling</td><td>14.3</td></tr></table>
Table 4: FID on CelebA. $^ { * } 6 4 \times 6 4$ resolution.
<table><tr><td>Method</td><td>FID↓</td></tr><tr><td>Methods based on GAN:</td><td></td></tr><tr><td>PresGAN*(Dieng et al., 2019)</td><td>29.1</td></tr><tr><td>LSGAN(Mao et al.,2017) (from (Hoshen et al.,2019))</td><td>53.9</td></tr><tr><td>COCO-GAN† (Lin et al., 2019)</td><td>5.7</td></tr><tr><td>PGANt (Karras et al.,2018)(from (Lin et al.,2019))</td><td>7.30</td></tr><tr><td>MethodsbasedonVAE:</td><td></td></tr><tr><td>VEE-GAN† (Srivastava et al.,2017) (from (Dieng et al.,2019))</td><td>46.2</td></tr><tr><td>WAE-GAN*(Tolstikhin et al.,2017)</td><td>42</td></tr><tr><td>DC-VAEt (ours) Reconstruction</td><td>14.3</td></tr><tr><td>DC-VAEt (ours) Sampling</td><td>19.9</td></tr></table>
 Figure 5: Interpolation results generated by DC-VAE (ours) on CelebA-HQ (Karras et al., 2018) images $( 5 \bar { 1 } 2 \times 5 1 2$ , left) and LSUN Bedroom Yu et al. (2015) images $1 2 8 \times 1 2 8$ , right). More images can be seen in Appendix Figure 9. (Zoom in for a better visualization.)
# 5.5 LATENT SPACE REPRESENTATION: CLSSIFICATION
To show that our model learns a good representation, we measure the performance on the downstream MNIST classification task (Ding et al., 2020). The VAE models were trained on MNIST dataset (LeCun, 1998). We feed input images into our VAE encoder and get the latent representation. Then we train a linear classifier on the latent representation to classify the classes of the input images. Results in Table 5 show that our model gives the lowest classification error in most cases. This experiment demonstrates that our model not only gains the ability to do faithful synthesis and reconstruction, but also gains better representation ability on the VAE side.
 Figure 6: Image editing on CelebA-HQ (Karras et al., 2018) validation set images (resolution $5 1 2 \times 5 1 2$ ). The method used to generate these is outlined in Appendix A.2.
Table 5: Comparison to prior VAE-based representation learning methods. Classification error on MNIST dataset. ↓: lower is better. $9 5 \ \%$ confidence intervals are from 5 trials. Results derived from (Ding et al., 2020). Table 6: PPL Comparison of on CelebA-HQ Karras et al. (2018)
<table><tr><td>Method</td><td>dz=16↓</td><td>dz=32↓</td><td>dz=64↓</td></tr><tr><td>VAE (Kingma&Welling,2014)</td><td>2.92%±0.12</td><td>3.05%±0.42</td><td>2.98%±0.14</td></tr><tr><td>β-VAE(β=2) (Higgins et al.,2017)</td><td>4.69%±0.18</td><td>5.26%±0.22</td><td>5.40%±0.33</td></tr><tr><td>FactorVAE(y=5) (Kim& Mnih,2018)</td><td>6.07%±0.05</td><td>6.18%±0.20</td><td>6.35%±0.48</td></tr><tr><td>β-TCVAE (α=1,β=5,γ=1) (Chen et al.,2018)</td><td>1.62%±0.07</td><td>1.24%±0.05</td><td>1.32%±0.09</td></tr><tr><td>Guided-VAE (Ding et al.,2020)</td><td>1.85%±0.08</td><td>1.60%±0.08</td><td>1.49%±0.06</td></tr><tr><td>Guided-β-TCVAE (Ding et al.,2020)</td><td>1.47%±0.12</td><td>1.10%±0.03</td><td>1.31%±0.06</td></tr><tr><td>DC-VAE (Ours)</td><td>1.30% ±0.035</td><td>1.27%±0.037</td><td>1.29%±0.034</td></tr><tr><td colspan="4"></td></tr><tr><td>Method</td><td colspan="2">Backbone</td></tr><tr><td>StyleALAE (Pidhorskyi et al., 2020)</td><td colspan="2">StyleGAN</td></tr><tr><td>Progressive GAN (Karras et al., 2018)</td><td colspan="2">Progressive GAN</td></tr><tr><td>DC-VAE (ours)</td><td colspan="2">Progressive GAN</td></tr></table>
# 6 CONCLUSION
In this paper, we have proposed dual contradistinctive generative autoencoder (DC-VAE), a new framework that integrates an instance-level discriminative loss (InfoNCE) with a set-level adversarial loss (GAN) into a single variational autoencoder framework. Our experiments show competitive results for a single model in several tasks, including image synthesis, image reconstruction, representation learning for image interpolation, and representation learning for classification. DC-VAE points to a encouraging direction that attains high-quality synthesis (decoding) and inference (encoding).
# REFERENCES
Jyoti Aneja, Alexander Schwing, Jan Kautz, and Arash Vahdat. Ncp-vae: Variational autoencoders with noise contrastive priors, 2020.
Martin Arjovsky, Soumith Chintala, and Léon Bottou. Wasserstein generative adversarial networks. In ICML, 2017.
Andrew Brock, Jeff Donahue, and Karen Simonyan. Large scale gan training for high fidelity natural image synthesis. arXiv preprint arXiv:1809.11096, 2018.
Jane Bromley, Isabelle Guyon, Yann LeCun, Eduard Säckinger, and Roopak Shah. Signature verification using a “siamese” time delay neural network. In Neural Information Processing Systems, 1993.
Gal Chechik, Varun Sharma, Uri Shalit, and Samy Bengio. Large scale online learning of image similarity through ranking. J. Mach. Learn. Res., 11:1109–1135, March 2010. ISSN 1532-4435.
Tian Qi Chen, Xuechen Li, Roger B Grosse, and David K Duvenaud. Isolating sources of disentanglement in variational autoencoders. In Advances in Neural Information Processing Systems, 2018.
Ting Chen, Xiaohua Zhai, Marvin Ritter, Mario Lucic, and Neil Houlsby. Self-supervised gans via auxiliary rotation loss. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 12154–12163, 2019.
Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. arXiv:2002.05709, 2020.
Sumit Chopra, Raia Hadsell, and Yann LeCun. Learning a similarity metric discriminatively, with application to face verification. In CVPR, pp. 539–546, 2005. ISBN 0769523722.
Adam Coates, Andrew $\mathrm { N g }$ , and Honglak Lee. An analysis of single-layer networks in unsupervised feature learning. In AISTATS, pp. 215–223, 2011.
Adji B Dieng, Francisco JR Ruiz, David M Blei, and Michalis K Titsias. Prescribed generative adversarial networks. arXiv:1910.04302, 2019.
Zheng Ding, Yifan Xu, Weijian Xu, Gaurav Parmar, Yang Yang, Max Welling, and Zhuowen Tu. Guided variational autoencoder for disentanglement learning. In CVPR, 2020.
Jeff Donahue, Philipp Krähenbühl, and Trevor Darrell. Adversarial feature learning. In ICLR, 2017.
Vincent Dumoulin, Ishmael Belghazi, Ben Poole, Alex Lamb, Martin Arjovsky, Olivier Mastropietro, and Aaron Courville. Adversarially learned inference. In ICLR, 2017.
Xinyu Gong, Shiyu Chang, Yifan Jiang, and Zhangyang Wang. Autogan: Neural architecture search for generative adversarial networks. In ICCV, 2019.
Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. In Advances in neural information processing systems, 2014.
Ishaan Gulrajani, Faruk Ahmed, Martin Arjovsky, Vincent Dumoulin, and Aaron C Courville. Improved training of wasserstein gans. In Advances in neural information processing systems, 2017.
T. Guo, C. Xu, J. Huang, Y. Wang, B. Shi, C. Xu, and D. Tao. On positive-unlabeled classification in gan. In 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 8382–8390, Los Alamitos, CA, USA, jun 2020. IEEE Computer Society. doi: 10.1109/CVPR42600.2020.00841. URL https://doi.ieeecomputersociety.org/ 10.1109/CVPR42600.2020.00841.
Michael U. Gutmann and Aapo Hyvärinen. Noise-contrastive estimation of unnormalized statistical models, with applications to natural image statistics. J. Mach. Learn. Res., 13(null):307–361, February 2012. ISSN 1532-4435.
Raia Hadsell, Sumit Chopra, and Yann LeCun. Dimensionality reduction by learning an invariant mapping. In CVPR, 2006.
Hao He, Hao Wang, Guang-He Lee, and Yonglong Tian. Probgan: Towards probabilistic gan with theoretical guarantees. In ICLR, 2019.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, 2016.
Kaiming He, Haoqi Fan, Yuxin Wu, Saining Xie, and Ross Girshick. Momentum contrast for unsupervised visual representation learning. In CVPR, 2020.
Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and Sepp Hochreiter. Gans trained by a two time-scale update rule converge to a local nash equilibrium. In Advances in Neural Information Processing Systems, 2017.
Irina Higgins, Loic Matthey, Arka Pal, Christopher Burgess, Xavier Glorot, Matthew Botvinick, Shakir Mohamed, and Alexander Lerchner. beta-vae: Learning basic visual concepts with a constrained variational framework. In ICLR, 2017.
Geoffrey E Hinton and Richard S Zemel. Autoencoders, minimum description length and helmholtz free energy. In Advances in neural information processing systems, 1994.
Quan Hoang, Tu Dinh Nguyen, Trung Le, and Dinh Phung. Mgan: training generative adversarial nets with multiple generators. In ICLR, 2018.
Yedid Hoshen, Ke Li, and Jitendra Malik. Non-adversarial image synthesis with generative latent nearest neighbors. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 5811–5819, 2019.
Huaibo Huang, Ran He, Zhenan Sun, Tieniu Tan, et al. Introvae: Introspective variational autoencoders for photographic image synthesis. In Advances in Neural Information Processing Systems, pp. 52–63, 2018.
Phillip Isola, Jun-Yan Zhu, Tinghui Zhou, and Alexei A Efros. Image-to-image translation with conditional adversarial networks. CVPR, 2017.
Long Jin, Justin Lazarow, and Zhuowen Tu. Introspective classification with convolutional nets. In Advances in Neural Information Processing Systems, 2017.
Justin Johnson, Alexandre Alahi, and Li Fei-Fei. Perceptual losses for real-time style transfer and super-resolution. In ECCV, 2016.
Alexia Jolicoeur-Martineau. The relativistic discriminator: a key element missing from standard gan. arXiv preprint arXiv:1807.00734, 2018.
Tero Karras, Timo Aila, Samuli Laine, and Jaakko Lehtinen. Progressive growing of gans for improved quality, stability, and variation. In ICLR, 2018.
Tero Karras, Samuli Laine, and Timo Aila. A style-based generator architecture for generative adversarial networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 4401–4410, 2019.
Hyunjik Kim and Andriy Mnih. Disentangling by factorising. In ICML, 2018.
Diederik P Kingma and Max Welling. Auto-encoding variational bayes. In ICLR, 2014.
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, 2012.
Brian Kulis et al. Metric learning: A survey. Foundations and trends in machine learning, 5(4): 287–364, 2012.
Anders Boesen Lindbo Larsen, Søren Kaae Sønderby, Hugo Larochelle, and Ole Winther. Autoencoding beyond pixels using a learned similarity metric. In ICML, 2016.
Yann LeCun. Modeles connexionnistes de lapprentissage. PhD thesis, PhD thesis, These de Doctorat, Universite Paris 6, 1987.
Yann LeCun. The mnist database of handwritten digits. http://yann. lecun. com/exdb/mnist/, 1998.
Chen-Yu Lee, Saining Xie, Patrick Gallagher, Zhengyou Zhang, and Zhuowen Tu. Deeply-supervised nets. In Artificial intelligence and statistics, pp. 562–570, 2015.
Kwonjoon Lee, Weijian Xu, Fan Fan, and Zhuowen Tu. Wasserstein introspective neural networks. In CVPR, 2018.
Kwonjoon Lee, Subhransu Maji, Avinash Ravichandran, and Stefano Soatto. Meta-learning with differentiable convex optimization. In CVPR, 2019.
Chieh Hubert Lin, Chia-Che Chang, Yu-Sheng Chen, Da-Cheng Juan, Wei Wei, and Hwann-Tzong Chen. Coco-gan: generation by parts via conditional coordinating. In Proceedings of the IEEE International Conference on Computer Vision, pp. 4512–4521, 2019.
Ziwei Liu, Ping Luo, Xiaogang Wang, and Xiaoou Tang. Deep learning face attributes in the wild. In ICCV, 2015.
Zhuang Ma and Michael Collins. Noise contrastive estimation and negative sampling for conditional models: Consistency and statistical efficiency. In EMNLP, 2018.
Tomasz Malisiewicz, Abhinav Gupta, and Alexei A. Efros. Ensemble of exemplar-svms for object detection and beyond. In ICCV, 2011.
Xudong Mao, Qing Li, Haoran Xie, Raymond YK Lau, Zhen Wang, and Stephen Paul Smolley. Least squares generative adversarial networks. In Proceedings of the IEEE international conference on computer vision, pp. 2794–2802, 2017.
Takeru Miyato, Toshiki Kataoka, Masanori Koyama, and Yuichi Yoshida. Spectral normalization for generative adversarial networks. In ICLR, 2018.
Stanislav Pidhorskyi, Donald Adjeroh, and Gianfranco Doretto. Adversarial latent autoencoders, 2020.
Ben Poole, Sherjil Ozair, Aaron Van Den Oord, Alex Alemi, and George Tucker. On variational bounds of mutual information. In ICML, 2019.
Alec Radford, Luke Metz, and Soumith Chintala. Unsupervised representation learning with deep convolutional generative adversarial networks. In ICLR, 2016.
Ruslan Salakhutdinov and Geoffrey Hinton. Deep boltzmann machines. In David van Dyk and Max Welling (eds.), AISTATS, volume 5, pp. 448–455, 16–18 Apr 2009.
Tim Salimans, Ian Goodfellow, Wojciech Zaremba, Vicki Cheung, Alec Radford, and Xi Chen. Improved techniques for training gans. In Advances in Neural Information Processing Systems, 2016.
Akash Srivastava, Lazar Valkov, Chris Russell, Michael U Gutmann, and Charles Sutton. Veegan: Reducing mode collapse in gans using implicit variational learning. In Advances in Neural Information Processing Systems, pp. 3308–3318, 2017.
Ilya Tolstikhin, Olivier Bousquet, Sylvain Gelly, and Bernhard Schoelkopf. Wasserstein auto-encoders. arXiv preprint arXiv:1711.01558, 2017.
Zhuowen Tu. Learning generative models via discriminative approaches. In CVPR, 2007. Arash Vahdat and Jan Kautz. NVAE: A deep hierarchical variational autoencoder. In Neural Information Processing Systems (NeurIPS), 2020. Aäron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. CoRR, abs/1807.03748, 2018. URL http://arxiv.org/abs/1807.03748. Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in Neural Information Processing Systems, 2017. Wei Wang, Yuan Sun, and Saman Halgamuge. Improving mmd-gan training with repulsive loss function. In ICLR, 2019. Zhirong Wu, Yuanjun Xiong, Stella X Yu, and Dahua Lin. Unsupervised feature learning via non-parametric instance discrimination. In CVPR, pp. 3733–3742, 2018. Jianwen Xie, Yang Lu, Song-Chun Zhu, and Yingnian Wu. A theory of generative convnet. In ICML, 2016. Fisher Yu, Yinda Zhang, Shuran Song, Ari Seff, and Jianxiong Xiao. Lsun: Construction of a largescale image dataset using deep learning with humans in the loop. arXiv preprint arXiv:1506.03365, 2015. Zijun Zhang, Ruixiang Zhang, Zongpeng Li, Yoshua Bengio, and Liam Paull. Perceptual generative autoencoders. In ICLR, 2019.
A APPENDIX
# A.1 Additional reconstruction results
 Figure 7: Additional CelebA-HQ (Karras et al., 2018) reconstruction images (resolution $5 1 2 \times 5 1 2$ ) generated by DC-VAE (ours)
 Figure 8: Additional LSUN Bedroom (Yu et al., 2015) reconstruction images (resolution $1 2 8 \times 1 2 8$
# A.2 Analysing the latent space
In this section we analyse the smoothness of the latent space learnt by DC-VAE. In Figure 9 we qualitatively show the high resolution $( 5 1 2 \times 5 1 2 )$ CelebA-HQ Karras et al. (2018) images generated by an evenly spaced linear blending between two latent vectors. In Fig. 6 we show that DC-VAE is able to perform meaningful attribute editing on images while retaining the original identity. To perform image editing, we first need to compute the direction vector in the latent space that correspond to a desired attribute (e.g. has glasses, has blonde hair, is a woman, has facial hair). We compute these attribute direction vectors by selecting 20 images that have the attribute and 20 images that do not have the attribute, obtaining the corresponding pairs of 20 latent vectors, and calculating the difference of the mean. The results in Fig. 6 show that these direction vectors can be added to a latent vector to add a diverse combination of desired image attributes while retaining the original identity of the individual.
Additionally we corroborate the above qualitative results quantitatively by inspecting the Perceptual Path Length (PPL) Karras et al. (2019) of our learn DC-VAE Decoder (Tab. 6) to measures the disentanglement of the latent space. We note that although ProgressiveGAN (ours base model) has a better FID score, DC-VAE has a lower PPL score which indicated that the latent space learnt is more disentangled.
 Figure 9: Additional latent space interpolations on CelebA-HQ (Karras et al., 2018) (resolution $5 1 \bar { 2 } \times 5 1 2 $ )
# Source A
 Figure 10: Latent Mixing results on CelebA-HQ Karras et al. (2018). Each combined image in the grid is generated by replacing an arbitrary subset of Source A latent with the corresponding Source B latent.
# A.3 Effect of negative samples
In this section we analyse the effect of varying the number of negative samples used for contrastive learning. The figure 11 shows the reconstruction error on the CIFAR-10 Krizhevsky et al. (2009) test set as the negative samples is varied. We observe that a higher number of negative samples results in better reconstruction. We choose 8096 for all of our experiments because of memory constraints.
# A.4 Datasets used
CIFAR-10 comprises 50,000 training images and 10,000 test images with a spatial resolution of $3 2 \times 3 2$ . STL-10 is a similar dataset that contains 5,000 training images and 100,000 unlabeled images at $9 6 \times 9 6$ resolution. We follow the procedure in AutoGAN(Gong et al., 2019) and resize the STL-10 images to $3 2 \times 3 2$ . The CelebA dataset has 162,770 training images and 19,962 testing images, CelebA-HQ contains 29,000 training images with 1,000 test images of size $1 0 2 4 \times 1 0 2 4$ and LSUN Bedroom has approximately 3M images. We resize all images progressively in these three datasets from $\left( 4 \times 4 \right)$ to $( 5 1 2 \times 5 1 2 )$ for the progressive training.
 Figure 11: Pixel reconstruction error on CIFAR-10 Krizhevsky et al. (2009) test set for varying number of negative samples
# A.5 Network architecture diagrams
In Figures 15 we show the detailed network architecture of DC-VAE for input resolutions of $3 2 \times 3 2$ Note that the comparison results shown in Figure 3 and Table 1 in the main paper, for VAE, VAE/GAN, VAE w/o GAN, and our proposed DC-VAE are all based on the same network architecture (shown in Figure 15 here), for a fair comparison.
The network architectures shown in Figure 15 are adapted closely from the networks discovered by (Gong et al., 2019) through Neural Architecture Search. The DC-VAE developed in our paper is not tied to any particular CNN architecture. We choose the AutoGAN architecture (Gong et al., 2019) to start with a strong baseline. The decoder in Figure 15 matches the generator in (Gong et al., 2019). The encoder is built by modifying the output shape of the final linear layer in the discriminator of AutoGAN (Gong et al., 2019) to match the latent dimension and adding spectral normalization. The discriminator is used both for classifying real/fake images, and contrastive learning. For each layer we choose, we first apply 1x1 convolution and a linear layer, and then use this feature as an input to the contrastive module. For experiments at $3 2 \times 3 2$ , we pick two different positions: the output of second residual conv block (lower level) and the output of the first linear layer (higher level). For experiments on higher resolution datasets we use a Progressive GAN (Karras et al., 2018) Generator and Discriminator as our backbone and apply similar modifications as described above.
# A.6 Training infrastructure
# .7 Further details about the representation learning experiments
As seen in Table 4 in the main paper, we show the representation capability of DC-VAE following the procedure outlined in (Ding et al., 2020). We train our model on the MNIST dataset (LeCun, 1998) and measure the transferability though a classification task on the latent embedding vector. Specifically, we first pretrain the DC-VAE model on the training split of the MNIST dataset. Following that we freeze the DC-VAE model and train a linear classifier that takes latent embedding vector as the input and predicts the class label of the original image.
 Figure 12: Visualization of the effect of adding each instance level and set level objectives. Table 1 and Figure 3 contain FID (Heusel et al., 2017) results and qualitative comparisons on the CIFAR-10 (Krizhevsky et al., 2009) that correspond to these settings.
 Figure 13: DC-VAE synthesis images on LSUN images (Yu et al., 2015) (resolution $1 2 8 \times 1 2 8$ )
 Figure 14: DC-VAE reconstruction (a) and synthesis results (b) on STL10 (Coates et al., 2011) images (resolution $3 2 \times 3 2 ,$ ). In (a) the top two rows are input images and the bottom two rows are the corresponding reconstruction images.
 Figure 15: Network architecture of DC-VAE for resolution $3 2 \times 3 2$ for CIFAR-10 (Krizhevsky et al., 2009) and STL-10 (Coates et al., 2011). (a) is the Encoder. (b) is the Decoder. (c) is the Discriminator.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318# Nested Graph Neural Networks
Muhan Zhang1,2,∗ Pan Li3,† 1Institute for Artificial Intelligence, Peking University 2Beijing Institute for General Artificial Intelligence 3Department of Computer Science, Purdue University
# Abstract
Graph neural network (GNN)’s success in graph classification is closely related to the Weisfeiler-Lehman (1-WL) algorithm. By iteratively aggregating neighboring node features to a center node, both 1-WL and GNN obtain a node representation that encodes a rooted subtree around the center node. These rooted subtree representations are then pooled into a single representation to represent the whole graph. However, rooted subtrees are of limited expressiveness to represent a nontree graph. To address it, we propose Nested Graph Neural Networks (NGNNs). NGNN represents a graph with rooted subgraphs instead of rooted subtrees, so that two graphs sharing many identical subgraphs (rather than subtrees) tend to have similar representations. The key is to make each node representation encode a subgraph around it more than a subtree. To achieve this, NGNN extracts a local subgraph around each node and applies a base GNN to each subgraph to learn a subgraph representation. The whole-graph representation is then obtained by pooling these subgraph representations. We provide a rigorous theoretical analysis showing that NGNN is strictly more powerful than 1-WL. In particular, we proved that NGNN can discriminate almost all $r$ -regular graphs, where 1-WL always fails. Moreover, unlike other more powerful GNNs, NGNN only introduces a constantfactor higher time complexity than standard GNNs. NGNN is a plug-and-play framework that can be combined with various base GNNs. We test NGNN with different base GNNs on several benchmark datasets. NGNN uniformly improves their performance and shows highly competitive performance on all datasets.
# 1 Introduction
Graph is an important tool to model relational data in the real world. Representation learning over graphs has become a popular topic of machine learning in recent years. While network embedding methods, such as DeepWalk [1], can learn node representations well, they fail to generalize to whole-graph representations, which are crucial for applications such as graph classification, molecule modeling, and drug discovery. On the contrary, although traditional graph kernels [2–7] can be used for graph classification, they define graph similarity often in a heuristic way, which is not parameterized and lacks some flexibility to deal with features.
In this context, graph neural networks (GNNs) have regained people’s attention and become the state-of-the-art graph representation learning tool [8–17]. GNNs use message passing to propagate features between connected nodes. By iteratively aggregating neighboring node features to the center node, GNNs learn node representations encoding their local structure and feature information. These node representations can be further pooled into a graph representation, enabling graph-level tasks such as graph classification. In this paper, we will use message passing GNNs to denote this class of GNNs based on repeated neighbor aggregation [18], in order to distinguish them from some high-order GNN variants [19–21] where the effective message passing happens between high-order node tuples instead of nodes.
 Figure 1: The two original graphs $G _ { 1 }$ and $G _ { 2 }$ are non-isomorphic. $G _ { 1 }$ is composed of two triangles, while $G _ { 2 }$ is a hexagon. However, both 1-WL and message passing GNNs cannot differentiate them, since all nodes in the two graphs share identical rooted subtrees at any height (see the rooted subtrees around $v _ { 1 }$ and $v _ { 2 }$ in the middle block for example). In comparison, we can discriminate the two graphs by comparing their height-1 rooted subgraphs around any nodes. For example, the height-1 rooted subgraph around $v _ { 1 }$ is a closed triangle, but the height-1 rooted subgraph around $v _ { 2 }$ is an open triangle (see the red boxes in the right block).
GNNs’ message passing scheme mimics the 1-dimensional Weisfeiler-Lehman (1-WL) algorithm [22], which iteratively refines a node’s color according to its current color and the multiset of its neighbors’ colors. This procedure essentially encodes a rooted subtree around each node into its final color, where the rooted subtree is constructed by recursively expanding the neighbors of the root node. One critical reason for GNN’s success in graph classification is because two graphs sharing many identical or similar rooted subtrees are more likely classified into the same class, which actually aligns with the inductive bias that two graphs are similar if they have many common substructures [23].
Despite this, rooted subtrees are still limited in terms of expressing all possible substructures that can appear in a graph. It is likely that two graphs, despite sharing a lot of identical rooted subtrees, are not similar at all because their other substructure patterns are not similar. Take the two graphs $G _ { 1 }$ and $G _ { 2 }$ in Figure 1 as an example. If we apply 1-WL or a message passing GNN to them, the two graphs will always have the same representation no matter how many iterations/layers we use. This is because all nodes in the two graphs have identical rooted subtrees across all tree heights. However, the two graphs are quite different from a holistic perspective. $G _ { 1 }$ is composed of two triangles, while $G _ { 2 }$ is a hexagon. The intrinsic reason for such a failure is that rooted subtrees have limited expressiveness for representing general graphs, especially those with cycles.
To address this issue, we propose Nested Graph Neural Networks (NGNNs). The core idea is, instead of encoding a rooted subtree, we want the final representation of a node to encode a rooted subgraph (local $h$ -hop subgraph) around it. The subgraph is not restricted to be of any particular graph type such as tree, but serves as a general description of the local neighborhood around a node. Rooted subgraphs offer much better representation power than rooted subtrees, e.g., we can easily discriminate the two graphs in Figure 1 by only comparing their height-1 rooted subgraphs.
To represent a graph with rooted subgraphs, NGNN uses two levels of GNNs: base (inner) GNNs and an outer GNN. By extracting a local rooted subgraph around each node, NGNN first applies a base GNN to each node’s subgraph independently. Then, a subgraph pooling layer is applied to each subgraph to aggregate the intermediate node representations into a subgraph representation. This subgraph representation is used as the final representation of the root node. Rather than encoding a rooted subtree, this final node representation encodes the local subgraph around it, which contains more information than a subtree. Finally, all the final node representations are further fed into an outer GNN to learn a representation for the entire graph. Figure 2 shows one NGNN implementation using message passing GNNs as the base GNNs and a simple graph pooling layer as the outer GNN.
One may wonder that the base GNN seems to still learn only rooted subtrees if it is message-passingbased. Then why is NGNN more powerful than GNN? One key reason lies in the subgraph pooling layer. Take the height-1 rooted subgraphs (marked with red boxes) around $v _ { 1 }$ and $v _ { 2 }$ in Figure 1 as an example. Although $v _ { 1 }$ and $v _ { 2 }$ ’s height-1 rooted subtrees are still the same, their neighbors (labeled by 1 and 2) have different height-1 rooted subtrees. Thus, applying a one-layer message passing GNN plus a subgraph pooling as the base GNN is sufficient to discriminate $G _ { 1 }$ and $G _ { 2 }$ .
 Figure 2: A particular implementation of the NGNN framework. It first extracts (copies) a rooted subgraph (height=1) around each node from the original graph, and then applies a base GNN with a subgraph pooling layer to each rooted subgraph independently to learn a subgraph representation. The subgraph representation is used as the root node’s final representation in the original graph. Then, a graph pooling layer is used to summarize the final node representations into a graph representation.
The NGNN framework has multiple exclusive advantages. Firstly, it allows freely choosing the base GNN, and can enhance the base GNN’s representation power in a plug-and-play fashion. Theoretically, we proved that NGNN is more powerful than message passing GNNs and 1-WL by being able to discriminate almost all $r$ -regular graphs (where 1-WL always fails). Secondly, by extracting rooted subgraphs, NGNN allows augmenting the initial features of a node with subgraphspecific structural features such as distance encoding [24] to improve the quality of the learned node representations. Thirdly, unlike other more powerful graph neural networks, especially those based on higher-order WL tests [19–21, 25], NGNN still has linear time and space complexity w.r.t. graph size like standard message passing GNNs, thus maintaining good scalability. We demonstrate the effectiveness of the NGNN framework in various synthetic/real-world graph classification/regression datasets. On synthetic datasets, NGNN demonstrates higher-than-1-WL expressive power, matching very well with our theorem. On real-world datasets, NGNN consistently enhances a wide range of base GNNs’ performance, achieving highly competitive results on all datasets.
# 2 Preliminaries
# 2.1 Notation and problem definition
We consider the graph classification/regression problem. Given a graph $G = ( V , E )$ where $V =$ $\{ 1 , 2 , \ldots n \}$ is the node set and $E \subseteq V \times V$ is the edge set, we aim to learn a function mapping $G$ to its class or target value $y$ . The nodes and edges in $G$ can have feature vectors associated with them, denoted by $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ (for node $i$ ) and $e _ { i j }$ (for edge $( i , j ) )$ , respectively.
# 2.2 Weisfeiler-Lehman test
The Wesfeiler-Lehman (1-WL) test [22] is a popular algorithm for graph isomorphism checking. The classical 1-WL works as follows. At first, all nodes receive a color 1. Each node collects its neighbors’ colors into a multiset. Then, 1-WL will update each node’s color so that two nodes get the same new color if and only if their current colors are the same and they have identical multisets of neighbor colors. Repeat this process until the number of colors does not increase between two iterations. Then, 1-WL will return that two graphs are non-isomorphic if their node colors are different at some iteration, or fail to determine whether they are non-isomorphic. See [7, 26] for more details.
1-WL essentially encodes the rooted subtrees around each node at different heights into its color representations. Figure 1 middle shows the rooted subtrees around $v _ { 1 }$ and $v _ { 2 }$ . Two nodes will have the same color at iteration $h$ if and only if their height- $h$ rooted subtrees are the same.
# 3 Nested Graph Neural Network
In this section, we introduce our Nested Graph Neural Network (NGNN) framework and theoretically demonstrate its higher representation power than message passing GNNs.
# 3.1 Limitations of the message passing GNNs
Most existing GNNs follow the message passing framework [18]: given a graph $G$ , each node’s hidden state $\bar { h } _ { v } ^ { t + 1 }$ is updated based on its previous state $\boldsymbol { h } _ { v } ^ { t }$ and the messages $m _ { v } ^ { \overline { { t } } + \tilde { 1 } }$ from its neighbors
$$\pmb { h } _ { v } ^ { t + 1 } = U _ { t } ( \pmb { h } _ { v } ^ { t } , \pmb { m } _ { v } ^ { t + 1 } ) , \mathrm { ~ w h e r e ~ } \pmb { m } _ { v } ^ { t + 1 } = \sum _ { u \in N ( v | G ) } M _ { t } ( \pmb { h } _ { v } ^ { t } , \pmb { h } _ { u } ^ { t } , \pmb { e } _ { v u } ) .$$
Here $M _ { t } , U _ { t }$ are the message and update functions at time stamp $t$ , $e _ { v u }$ is the feature of edge $( v , u )$ , and $N ( v | G )$ is the set of $v$ ’s neighbors in graph $G$ . The initial hidden states $h _ { v } ^ { 0 }$ are given by the raw node features $\scriptstyle { \mathbf { { \mathit { x } } } } _ { \mathit { v } }$ . After $T$ time stamps (iterations), the final node representations $h _ { v } ^ { T }$ are summarized into a whole-graph representation with a readout (pooling) function $R$ (e.g., mean or sum):
$$\begin{array} { r } { h _ { G } = R ( \{ h _ { v } ^ { T } | v \in G \} ) . } \end{array}$$
Such a message passing (or neighbor aggregation) scheme iteratively aggregates neighbor information into a center node’s hidden state, making it encode a local rooted subtree around the node. The final node representations will contain both the local structure and feature information around nodes, enabling node-level tasks such as node classification. After a pooling layer, these node representations can be further summarized into a graph representation, enabling graph-level tasks. When there is no edge feature and the node features are from a countable space, it is shown that message passing GNNs are at most as powerful as the 1-WL test for discriminating non-isomorphic graphs [27, 19].
For an $h$ -layer message passing GNN, it will give two nodes the same final representation if they have identical height- $h$ rooted subtrees (i.e., both the structures and the features on the corresponding nodes/edges are the same). If two graphs have a lot of identical (or similar) rooted subtrees, they will also have similar graph representations after pooling. This insight is crucial for the success of modern GNNs in graph classification, because it aligns with the inductive bias that two graphs are similar if they have many common substructures. Such insight has also been used in designing the WL subtree kernel [7], a state-of-the-art graph classification method before GNNs.
However, message passing GNNs have several limitations. Firstly, rooted subtree is only one specific substructure. It is not general enough to represent arbitrary subgraphs, especially those with cycles due to the natural restriction of tree structure. Secondly, using rooted subtree as the elementary substructure results in a discriminating power bounded by the 1-WL test. For example, all $n$ -node $r$ -regular graphs cannot be discriminated by message passing GNNs. Thirdly, standard message passing GNNs do not allow using root-node-specific structural features (such as the distance between a node and the root node) to improve the quality of the learned root node’s representation. We might need to break through such limitations in order to design more powerful GNNs.
# 3.2 The NGNN framework
To address the above limitations, we propose the Nested Graph Neural Network (NGNN) framework. NGNN no longer aims to encode a rooted subtree around each node. Instead, in NGNN, each node’s final representation encodes the general local subgraph information around it more than a subtree, so that two graphs sharing a lot of identical or similar rooted subgraphs will have similar representations.
Definition 1. (Rooted subgraph) Given a graph $G$ and a node v, the height-h rooted subgraph $G _ { v } ^ { h }$ of v is the subgraph induced from $G$ by the nodes within h hops of v (including $h$ -hop nodes).
To make a node’s final representation encode a rooted subgraph, we need to compute a subgraph representation. To achieve this, we resort to an arbitrary GNN, which we call the base GNN of NGNN. For example, the base GNN can be simply a message passing GNN, which performs message passing within each rooted subgraph to learn an intermediate representation for every node of the subgraph, and then uses a pooling layer to summarize a subgraph representation from the intermediate node representations. This subgraph representation is used as the final representation of the root node in the original graph. Take root node $w$ as an example. We first perform $T$ rounds of message passing within node $w$ ’s rooted subgraph $G _ { w } ^ { h }$ . Let $v$ be any node appearing in $G _ { w } ^ { h }$ . We have
$$h _ { v , G _ { w } ^ { h } } ^ { t + 1 } = U _ { t } ( h _ { v , G _ { w } ^ { h } } ^ { t } , m _ { v , G _ { w } ^ { h } } ^ { t + 1 } ) , ~ \mathrm { w h e r e } ~ m _ { v , G _ { w } ^ { h } } ^ { t + 1 } = \sum _ { u \in N ( v | G _ { w } ^ { h } ) } M _ { t } ( h _ { v , G _ { w } ^ { h } } ^ { t } , h _ { u , G _ { w } ^ { h } } ^ { t } , e _ { v u } ) .$$
Here $M _ { t } , U _ { t }$ are the message and update functions of the base GNN at time stamp $t$ , $N ( v | G _ { w } ^ { h } )$ denonode s th’s hi set of den st $v$ ’s neighbors within e and message spec $w$ ’s rooted subgraph to rooted subgrap $G _ { w } ^ { h }$ and at ti $h _ { v , G _ { w } ^ { h } } ^ { t + 1 }$ anmp $m _ { v , G _ { w } ^ { h } } ^ { t + 1 }$ denoteote that $v$ $G _ { w } ^ { h }$ $t + 1$ $v$ different. This is in contrast to standard GNNs where a node’s hidden state and message at time $t$ is the same regardless of which root node it contributes to. For example, $\boldsymbol { h } _ { v } ^ { t + 1 }$ and $m _ { v } ^ { t + 1 }$ in Eq. 1 do not depend on any particular rooted subgraph.
After $T$ rounds of message passing, we apply a subgraph pooling layer to summarize a subgraph representation $h _ { G _ { w } ^ { h } }$ from the intermediate node representations $\{ h _ { v , G _ { w } ^ { h } } ^ { T } | v \in G _ { w } ^ { h } \}$ .
$$\pmb { h _ { w } } : = \pmb { h } _ { G _ { w } ^ { h } } = R _ { 0 } \big ( \{ \pmb { h } _ { v , G _ { w } ^ { h } } ^ { T } | v \in G _ { w } ^ { h } \} \big ) ,$$
where $R _ { 0 }$ is the subgraph pooling layer. This subgraph representation $h _ { G _ { w } ^ { h } }$ will be used as root node $w$ ’s final representation $h _ { w }$ in the original graph. Note that the base GNNs are simultaneously applied to all nodes’ rooted subgraphs to return a final node representation for every node in the original graph, and all the base GNNs share the same parameters. With such node representations, NGNN uses an outer GNN to further process and aggregate them into a graph representation of the whole graph. For simplicity, we let the outer GNN be simply a graph pooling layer denoted by $R _ { 1 }$ :
$$\begin{array} { r } { h _ { G } : = R _ { 1 } ( \{ h _ { w } | w \in G \} ) . } \end{array}$$
The Nested GNN framework can be understood as a two-level GNN, or a GNN of GNNs—the inner subgraph-level GNNs (base GNNs) are used to learn node representations from their rooted subgraphs, while the outer graph-level GNN is used to return a whole-graph representation from the inner GNNs’ outputs. The inner GNNs all share the same parameters which are trained end-to-end with the outer GNN. Figure 2 depicts the implementation of the NGNN framework described above.
Compared to message passing GNNs, NGNN changes the “receptive field” of each node from a rooted subtree to a rooted subgraph, in order to capture better local substructure information. The rooted subgraph is read by a base GNN to learn a subgraph representation. Finally, the outer GNN reads the subgraph representations output by the base GNNs to return a graph representation.
Note that, when we apply the base GNN to a rooted subgraph, this rooted subgraph is extracted (copied) out of the original graph and treated as a completely independent graph from the other rooted subgraphs and the original graph. This allows the same node to have different representations within different rooted subgraphs. For example, in Figure 2, the same node $B$ appears in four different rooted subgraphs. Sometimes it is the root node, while other times it is a 1-hop neighbor of the root node. NGNN enables learning different representations for the same node when it appears in different rooted subgraphs, in contrast to standard GNNs where a node only has one single representation at one time stamp (Eq. 1). Similarly, NGNN also enables using different initial features for the same node when it appears in different rooted subgraphs. This allows us to customize a node’s initial features based on its structural role within a rooted subgraph, as opposed to using the same initial features for a node across all rooted subgraphs. For example, we can optionally augment node $B$ ’s initial features with the distance between node $B$ and the root—when node $B$ is the root node, we give it an additional feature 0; and when $B$ is a $k$ -hop neighbor of the root, we give it an additional feature $k$ . Such feature augmentation may help better capture a node’s structural role within a rooted subgraph. It is an exclusive advantage of NGNN and is not possible in standard GNNs.
# 3.3 The representation power of NGNN
We theoretically characterize the additional expressive power of NGNN (using message passing GNNs as base GNNs) as opposed to standard message passing GNNs. We focus on the ability to discriminate regular graphs because they form an important category of graphs which standard GNNs cannot represent well. Using 1-WL or message passing GNNs, any two $n$ -sized $r$ -regular graphs will have the same representation, unless discriminative node features are available. In contrast, we prove that NGNN can distinguish almost all pairs of $n$ -sized $r$ -regular graphs regardless of node features.
Definition 2. If the message passing (Eq. 3) and the two-level graph pooling (Eqs. 4,5) are all injective given input from a countable space, then the NGNN is called proper.
A proper NGNN always exists due to the representation power of fully-connected neural networks used for message passing and Deep Set for graph pooling [28]. For all pairs of graphs that 1-WL can discriminate, there always exists a proper NGNN that can also discriminate them, because two graphs discriminated by 1-WL means they must have different multisets of rooted subtrees at some height $h$ , while a rooted subtree is always included in a rooted subgraph with the same height.
Now we present our main theorem.
Theorem 1. Consider all pairs of $n$ -sized $r$ -regular graphs, where $3 \leq r < ( 2 \log n ) ^ { 1 / 2 }$ . For any small constant $\epsilon > 0$ , there exists a proper NGNN using at most $\begin{array} { r } { \lceil ( \frac { 1 } { 2 } + \epsilon ) \frac { \log n } { \log ( r - 1 - \epsilon ) } \rceil } \end{array}$ -height rooted subgraphs and $\left\lceil \epsilon \frac { \log n } { \log ( r - 1 - \epsilon ) } \right\rceil$ -layer message passing, which distinguishes almost all $( 1 - o ( 1 ) ,$ ) such pairs of graphs.
We include the proof in Appendix A. Theorem 1 has three implications. Firstly, since NGNN can discriminate almost all $r$ -regular graphs where 1-WL always fails, it is strictly more powerful than 1-WL and message passing GNNs. Secondly, it implies that NGNN does not need to extract subgraphs with a too large height (abou t 12 log nlog (r−1) ) to be more powerful. Moreover, NGNN is already powerful with very few layers, i.e., an arbitrarily small constant $\epsilon$ times $\frac { \log n } { \log ( r - 1 ) }$ (as few as 1 layer). This benefit comes from the subgraph pooling (Eq. 4), freeing us from using deep base GNNs. We further conduct a simulation experiment in Appendix D to verify Theorem 1 by testing how well NGNN discriminates $r$ -regular graphs in practice. The results match almost perfectly with our theory.
Although NGNN is strictly more powerful than 1-WL and 2-WL (1-WL and 2-WL have the same discriminating power [20]), it is unclear whether NGNN is more powerful than 3-WL. Our early-stage analysis shows both NGNN and 3-WL cannot discriminate strongly regular graphs with the same parameters [29]. We leave the exact comparison between NGNN and 3-WL to future work.
# 3.4 Discussion
Base GNN. NGNN is a general plug-and-play framework to increase the power of a base GNN. For the base GNN, we are not restricted to message passing GNNs as described in Section 3.2. For example, we can also use GNNs approximating the power of higher-dimensional WL tests, such as 1-2-3-GNN [19] and PPGN/Ring-GNN [20, 21], as the base GNN. In fact, one limitation of these high-order GNNs is their $\mathcal { O } ( n ^ { 3 } )$ complexity. Using the NGNN framework we can greatly alleviate this by applying the higher-order GNN to multiple small rooted subgraphs instead of the whole graph. Suppose a rooted subgraph has at most $c$ nodes, then by applying a high-order GNN to all $n$ rooted subgraphs, we can reduce the time complexity from $\dot { \mathcal { O } ( n ^ { 3 } ) }$ to $\bar { \mathcal { O } } \bar { ( n c ^ { 3 } ) }$ .
Complexity. We compare the time complexity of NGNN (using message passing GNNs as base GNNs) with a standard message passing GNN. Suppose the graph has $n$ nodes with a maximum degree $d$ , and the maximum number of nodes in a rooted subgraph is $c$ . Each message passing iteration in a standard message passing GNN takes $\mathcal { O } ( n d )$ operations. In NGNN, we need to perform message passing over all $n$ nodes’ rooted subgraphs, which takes $O ( n \cdot c d )$ . We will keep $c$ small (which can be achieved by using a small $h$ ) to improve NGNN’s scalability. Additionally, a small $c$ enables the base GNN to focus on learning local subgraph patterns.
In Appendix B, we discuss some other design choices of NGNN.
# 4 Related work
Understanding GNN’s representation power is a fundamental problem in GNN research. Xu et al. [27] and Morris et al. [19] first proved that the discriminating power of message passing GNNs is bounded by the 1-WL test, namely they cannot discriminate two non-isomorphic graphs that 1-WL fails to discriminate (such as $r$ -regular graphs). Since then, there is increasing effort in enhancing GNN’s discriminating power beyond 1-WL [19, 21, 20, 30, 24, 31–33, 25]. Many GNNs have been proposed to mimic higher-dimensional WL tests, such as 1-2-3-GNN [19], Ring-GNN [21] and PPGN [20]. However, these models generally require learning the representations of all node tuples of certain cardinality (e.g., node pairs, node triples and so on), thus cannot leverage the sparsity of graph structure and are difficult to scale to large graphs. Some works study the universality of GNNs for approximating any invariant or equivariant functions over graphs [34, 21, 35–37]. However, reaching universality would require polynomial $( n )$ -order tensors, which hold more theoretical value than practical applicability. Dasoulas et al. [38] propose to augment nodes of identical attributes with different colors, which requires exhausting all the coloring choices to reach universality. Similarly, Relational Pooling (RP) [30] uses the ensemble of permutation-aware functions over graphs to reach universality, which requires exhausting all $n !$ permutations to achieve its theoretical power. Its local version Local Relational Pooling (LRP) [39] applies RP over subgraphs around nodes, which is similar to our work yet still requires exhausting node permutations in local subgraphs and even more loses RP’s theoretical power. In contrast, NGNN maintains a controllable cost by only applying a message passing GNN to local subgraphs, and is guaranteed to be more powerful than 1-WL.
Because of the high cost of mimicking high-dimensional WL tests, several works have been proposed to increase GNN’s representation power within the message passing framework. Observing that different neighbors are indistinguishable during neighbor aggregation, some works propose to add one-hot node index features or random features to GNNs [40, 41]. These methods work well when nodes naturally have distinct identities irrespective of the graph structure. However, although making GNNs more discriminative, they also lose some of GNNs’ generalization ability by not being able to guarantee nodes with identical neighborhoods to have the same embedding; the resulting models are also no longer permutation invariant. Repeating random initialization helps with avoiding such an issue but gets much slower convergence [42]. An exception is structural message-passing (SMP) [43], which propagates one-hot node index features to learn a global $n \times d$ feature matrix for each node. The feature matrix is further pooled to learn a permutation-invariant node representation.
On the contrary, some works propose to use structural features to augment GNNs without hurting the generalization ability of GNNs. SEAL [44, 45], IGMC [46] and DE [24] use distance-based features, where a distance vector w.r.t. the target node set to predict is calculated for each node as its additional features. Our NGNN framework is naturally compatible with such distance-based features due to its independent rooted subgraph processing. GSN [31] uses the count of certain substructures to augment node/edge features, which also surpasses 1-WL theoretically. However, GSN needs a properly defined substructure set to incorporate domain-specific inductive biases, while NGNN aims to learn arbitrary substructures around nodes without the need to predefine a substructure set.
Concurrent to our work, You et al. [32] propose Identity-aware GNN (ID-GNN). ID-GNN uses different weight parameters between each root node and its context nodes during message passing. It also extracts a rooted subgraph around each node, and thus can be viewed as a special case of NGNN with: 1) the number of message passing layers equivalent to the subgraph height, 2) directly using the root node’s intermediate representation as its final representation without subgraph pooling, and 3) augmenting initial node features with 0/1 “identity”. However, the extra power of ID-GNN only comes from the “identity” feature, while the power of NGNN comes from the subgraph pooling— without using any node features, NGNN is still provably more discriminative than 1-WL. Another similar work to ours is natural graph network (NGN) [47]. NGN argues that graph convolution weights need not be shared among all nodes but only (locally) isomorphic nodes. If we view our distance-based node features as refining the graph convolution weights so that nodes within a center node’s neighborhood are no longer treated symmetrically, then our NGNN reduces to an NGN.
The idea of independently performing message passing within $k$ -hop neighborhood is also explored in $k$ -hop GNN [48] and MixHop [49]. However, MixHop directly concatenates the aggregation results of neighbors at different hops as the root representation, which ignores the connections between other nodes in the rooted subgraph. $k$ -hop GNN sequentially performs message passing for $k$ -hop, $k - 1$ -hop, ..., and 0-hop node (the update of $( i - 1 )$ -hop nodes depend on the updated states of $i$ -hop nodes), while NGNN simultaneously performs message passing for all nodes in the subgraph thus is more parallelizable. Both MixHop and $k$ -hop GNN directly use the root node’s representation as its final node representation. In contrast, NGNN uses a subgraph pooling to summarize all node representations within the subgraph as the final root representation, which distinguishes NGNN from other $k$ -hop models. As Theorem 1 shows, the subgraph pooling enables using a much smaller number of message passing layers $l$ (as small as 1) than the depth $k$ of the subgraph, while MixHop and $k$ -hop GNN always require $l \geq k$ . MixHop and $k$ -hop GNN also do not have the strong theoretical power of NGNN to discriminate $r$ -regular graphs. Like SEAL and $k$ -hop GNN, G-Meta [50] is another work extracting subgraphs around nodes/links. It focuses specifically on a meta-learning setting.
Table 1: Statistics and evaluation metrics of the QM9 and OGB datasets.
<table><tr><td>Dataset</td><td>#Graphs</td><td>Avg. #nodes</td><td>Avg.#edges</td><td>Split ratio</td><td>#Tasks</td><td>Task type</td><td>Metric</td></tr><tr><td>QM9</td><td>129,433</td><td>18.0</td><td>18.6</td><td>80/10/10</td><td>12</td><td>Regression</td><td>MAE</td></tr><tr><td>ogbl-molhiv</td><td>41,127</td><td>25.5</td><td>27.5</td><td>80/10/10</td><td>1</td><td>Classification</td><td>ROC-AUC</td></tr><tr><td>ogbl-molpcba</td><td>437,929</td><td>26.0</td><td>28.1</td><td>80/10/10</td><td>128</td><td>Classification</td><td>AP</td></tr></table>
# 5 Experiments
In this section, we study the effectiveness of the NGNN framework for graph classification and regression tasks. In particular, we want to answer the following questions:
Q1 Can NGNN reach its theoretical power to discriminate 1-WL-indistinguishable graphs? Q2 How often and how much does NGNN improve the performance of a base GNN? Q3 How does NGNN perform in comparison to state-of-the-art GNN methods in open benchmarks? Q4 How much extra computation time does NGNN incur?
We implement the NGNN framework based on the PyTorch Geometric library [51]. Our code is available at https://github.com/muhanzhang/NestedGNN.
# 5.1 Datasets
To answer Q1, we use a simulation dataset of $r$ -regular graphs and the EXP dataset [42] containing 600 pairs of 1-WL-indistinguishable but non-isomorphic graphs. To answer Q2, we use the QM9 dataset [52, 53] and the TU datasets [54]. QM9 contains $1 3 0 \mathrm { K }$ small molecules. The task here is to perform regression on twelve targets representing energetic, electronic, geometric, and thermodynamic properties, based on the graph structure and node/edge features. TU contains five graph classification datasets including D&D [55], MUTAG [56], PROTEINS [55], PTC_MR [57], and ENZYMES [58]. We used the datasets provided by PyTorch Geometric [51], where for QM9 we performed unit conversions to match the units used by [19]. The evaluation metric is Mean Absolute Error (MAE) for QM9 and Accuracy $( \% )$ for TU. To answer Q3, we use two Open Graph Benchmark (OGB) datasets [59], ogbg-molhiv and ogbg-molpcba. The ogbg-molhiv dataset contains 41K small molecules, the task of which is to classify whether a molecule inhibits HIV virus or not. ROC-AUC is used for evaluation. The ogbg-molpcba dataset contains 438K molecules with 128 classification tasks. The evaluation metric is Average Precision (AP) averaged over all the tasks. We include the statistics for QM9 and OGB datasets in Table 1.
# 5.2 Models
QM9. We use 1-GNN, 1-2-GNN, 1-3-GNN, and 1-2-3-GNN from [19] as both the baselines and the base GNNs of NGNN. Among them, 1-GNN is a standard message passing GNN with 1-WL power. 1-2-GNN is a GNN mimicking 2-WL, where message passing happens among 2-tuples of nodes. 1-3-GNN and 1-2-3-GNN mimic 3-WL, where message passing happens among 3-tuples of nodes. 1-2-GNN and 1-3-GNN use features computed by 1-GNN as initial node features, and 1-2-3-GNN uses the concatenated features from 1-2-GNN and 1-3-GNN. We additionally include numbers provided by [53] and Deep LRP [39] as baselines. Note that we omit more recent methods [60–62] using advanced physical representations calculated from angles, atom coordinates, and quantum mechanics, which may obscure the comparison of models’ pure graph representation power. For NGNN, we uniformly use height-3 rooted subgraphs. For a fair comparison, the base GNNs in NGNN use exactly the same hyperparameters as when they are used alone, except for 1-GNN where we increase the number of message passing layers from 3 to 5 to make the number of layers larger than the subgraph height, similar to [63]. For subgraph pooling and graph pooling layers, we uniformly use mean pooling. All other settings follow [19].
TU. We use four widely adopted GNNs as the baselines and the base GNNs of NGNN: GCN [12], GraphSAGE [64], GIN [27], and GAT [15]. Since TU datasets suffer from inconsistent evaluation standards [65], we uniformly use the 10-fold cross validation framework provided by PyTorch Geomtric [66] for all the models to ensure a fair comparison. For GNNs, we search the number of message passing layers in $\{ 2 , 3 , 4 , 5 \}$ . For NGNNs, we similarly search the subgraph height $h$ in $\{ 2 , 3 , 4 , 5 \}$ , so that both NGNNs and GNNs can have equal-depth local receptive fields. For NGNNs, we always use $h + 1$ message passing layers instead of searching it together with $h$ , because that will make NGNNs have more hyperparameters to tune. All models have 32 hidden dimensions, and are trained for 100 epochs with a batch size of 128. For each fold, we record the test accuracy with the hyperparameters chosen based on the best validation performance of this fold. Finally, we report the average test accuracy across all the 10 folds.
OGB. We use GNNs achieving top places on the OGB graph classification leaderboard3 (at the time of submission) as the baselines, including GCN [12], GIN [27], DeeperGCN [67], Deep LRP [39], PNA [68], DGN [33], GINE [69], and PHC-GNN [70]. Note that those high-order GNNs [19–21, 25] are not included here, because despite being theoretically more discriminative, these GNNs are not among the GNNs with the best empirical performance on modern large-scale graph benchmarks, and their $\bar { \mathcal { O } } ( n ^ { 3 } )$ complexity also raises a scalability issue. For NGNN, we use GIN as the base GNN (although GIN is not among the strongest baselines here). Some baselines additionally use the virtual node technique [18, 11, 71], which are marked by $\therefore$ . For NGNN, we search the subgraph height $h$ in $\{ 3 , 4 , 5 \}$ , and the number of layers in $\{ 4 , 5 , 6 \}$ . We train the NGNN models for 100 and 150 epochs for ogbg-molhiv and ogbg-molpcba, respectively, and report the validation and test scores at the best validation epoch. We also find that our models are subject to high performance variance across epochs, likely due to the increased expressiveness. Thus, we save a model checkpoint every 10 epochs, and additionally report the ensemble performance by averaging the predictions from all checkpoints. The final hyperparameter choices and more details about the experimental settings are included in Appendix C. All results are averaged over 10 independent runs.
In the following, we uniformly use “Nested GNN” to denote an NGNN model using “GNN” as the base GNN. For example, Nested GIN denotes an NGNN model using GIN [27] as the base GNN. For the NGNN models in QM9, TU and OGB datasets, we augment the initial features of a node with Distance Encoding (DE) [24], which uses the (generalized) distance between a node and the root as its additional feature, due to DE’s successful applications in link-level tasks [44, 46]. Note that such feature augmentation is not applicable to the baseline models as discussed in Section 3.2. An ablation study on the effects of the DE features is included in Appendix E.
# 5.3 Results and discussion
To answer Q1, we first run a simulation to test NGNN’s power for discriminating $r$ -regular graphs. The results are presented in Appendix D. They match almost perfectly with Theorem 1, demonstrating that a practical NGNN can fulfil its theoretical power for discriminating $r$ -regular graphs.
Table 2: Results $( \% )$ on EXP.
<table><tr><td>Method</td><td>Test Accuracy</td></tr><tr><td>GCN-RNI [42]</td><td>98.0±1.85</td></tr><tr><td>PPGN [20]</td><td>50.0±0.00</td></tr><tr><td>1-2-3-GNN [19]</td><td>50.0±0.00</td></tr><tr><td>3-GCN[42]</td><td>99.7±0.004</td></tr><tr><td>Nested GIN</td><td>99.9±0.26</td></tr></table>
We also test NGNN’s expressive power using the EXP dataset provided by [42], which contains 600 carefully constructed 1-WL indistinguishable but non-isomorphic graph pairs. Each pair of graphs have different labels, thus a standard message passing GNN cannot predict them both correctly, resulting in an expected classification accuracy of only $50 \%$ . We exactly follow the experimental settings and copy the baseline results in [42]. In Table 2, our Nested GIN model achieves a $9 9 . 9 \%$ classification accuracy, which outperforms all the baselines and distinguishes almost all the 1-WL indistinguishable graph pairs. These results verified that NGNN’s expressive power is indeed beyond 1-WL and message passing GNNs.
To answer Q2, we adopt the QM9 and TU datasets. We show the QM9 results in Table 3. If the Nested version of a base GNN achieves a better result than the base GNN itself, we color that cell with light green. As we can see, NGNN brings performance gains to all base GNNs on most targets, sometimes by large margins. We also show the results on TU in Table 4. NGNNs also show improvement over their base GNNs in most cases. These results indicate that NGNN is a general framework for improving a GNN’s power. We further compute the maximum reduction of MAE for QM9 and maximum improvement of accuracy for TU before and after applying NGNN. NGNN reduces the MAE by up to 7.9 times for QM9, and increases the accuracy by up to $1 4 . 3 \%$ for TU. These results answer Q2, indicating that NGNN can bring steady and significant improvement to base GNNs.
To answer Q3, we compare Nested GIN with leading methods on the OGB leaderboard. The results are shown in Table 5. Nested GIN achieves highly competitive performance with these leading GNN models, albeit using a relatively weak base GNN (GIN). Compared to GIN alone, Nested GIN shows clear performance gains. It achieves test scores up to 79.86 and 30.07 on ogbg-molhiv and ogbg-molpcba, respectively, which outperform all the baselines. In particular, for the challenging ogbg-molpcba, our Nested GIN can achieve 30.07 and 28.32 test AP with and without ensemble, respectively, outperforming the plain GIN model (with 27.03 test AP) significantly. These results demonstrate the great empirical performance and potential of NGNN even compared to heavily tuned open leaderboard models, despite using only GIN as the base GNN.
Table 3: MAE results on QM9 (smaller the better). A colored cell means NGNN is better than the base GNN.
<table><tr><td rowspan="2">Target</td><td colspan="10">Method (Ne. forNested)</td></tr><tr><td>DTNN</td><td>MPNN</td><td>Deep LRP</td><td>1-GNN1-2-GNN</td><td></td><td>1-3-GNN</td><td></td><td></td><td></td><td></td><td></td><td>1-2-3-GNN|Ne.1-GNN Ne.1-2-GNN Ne.1-3-GNN Ne.1-2-3-GNN|Max.reduction</td></tr><tr><td>μ</td><td>0.244</td><td>0.358</td><td>0.364</td><td>0.493</td><td>0.493</td><td>0.473</td><td>0.476</td><td>0.428</td><td>0.437</td><td>0.436</td><td>0.433</td><td>1.2×</td></tr><tr><td>α</td><td>0.95</td><td>0.89</td><td>0.298</td><td>0.78</td><td>0.27</td><td>0.46</td><td>0.27</td><td>0.29</td><td>0.278</td><td>0.261</td><td>0.265</td><td>2.7×</td></tr><tr><td>εHOMO</td><td>0.00388</td><td>0.00541</td><td>0.00254</td><td>0.00321</td><td>0.00331</td><td>0.00328</td><td>0.00337</td><td>0.00265</td><td>0.00275</td><td>0.00265</td><td>0.00279</td><td>1.2×</td></tr><tr><td>εLUMO</td><td>0.00512</td><td>0.00623</td><td>0.00277</td><td>0.00355</td><td>0.00350</td><td>0.00354</td><td>0.00351</td><td>0.00297</td><td>0.00271</td><td>0.00269</td><td>0.00276</td><td>1.3×</td></tr><tr><td>△</td><td>0.0112</td><td>0.0066</td><td>0.00353</td><td>0.0049</td><td>0.0047</td><td>0.0046</td><td>0.0048</td><td>0.0038</td><td>0.0039</td><td>0.0039</td><td>0.0039</td><td>1.8×</td></tr><tr><td>(R²)</td><td>17.0</td><td>28.5</td><td>19.3</td><td>34.1</td><td>21.5</td><td>25.8</td><td>22.9</td><td>20.5</td><td>20.4</td><td>20.2</td><td>20.1</td><td>1.7×</td></tr><tr><td>ZPVE</td><td>0.00172</td><td>0.00216</td><td>0.00055</td><td>0.00124</td><td>0.00018</td><td>0.00064</td><td>0.00019</td><td>0.00020</td><td>0.00017</td><td>0.00017</td><td>0.00015</td><td>6.2×</td></tr><tr><td>Uo</td><td>2.43</td><td>2.05</td><td>0.413</td><td>2.32</td><td>0.0357</td><td>0.6855</td><td>0.0427</td><td>0.295</td><td>0.252</td><td>0.291</td><td>0.205</td><td>7.9×</td></tr><tr><td>U</td><td>2.43</td><td>2.00</td><td>0.413</td><td>2.08</td><td>0.107</td><td>0.686</td><td>0.111</td><td>0.361</td><td>0.265</td><td>0.278</td><td>0.200</td><td>5.8×</td></tr><tr><td>H</td><td>2.43</td><td>2.02</td><td>0.413</td><td>2.23</td><td>0.070</td><td>0.794</td><td>0.0419</td><td>0.305</td><td>0.241</td><td>0.267</td><td>0.249</td><td>7.3×</td></tr><tr><td>G</td><td>2.43</td><td>2.02</td><td>0.413</td><td>1.94</td><td>0.140</td><td>0.587</td><td>0.0469</td><td>0.489</td><td>0.272</td><td>0.287</td><td>0.253</td><td>4.0×</td></tr><tr><td>C</td><td>0.27</td><td>0.42</td><td>0.129</td><td>0.27</td><td>0.0989</td><td>0.158</td><td>0.0944</td><td>0.174</td><td>0.0891</td><td>0.0879</td><td>0.0811</td><td>1.8×</td></tr></table>
Table 4: Accuracy results $( \% )$ on TU datasets.
<table><tr><td>#Graphs</td><td>D&D 1178</td><td>MUTAG 188</td><td>PROTEINS 1113</td><td>PTC_MR 344</td><td>ENZYMES 600</td></tr><tr><td>Avg. #nodes</td><td>284.32</td><td>17.93</td><td>39.06</td><td>14.29</td><td>32.63</td></tr><tr><td>GCN GraphSAGE</td><td>71.6±2.8 71.6±3.0</td><td>73.4±10.8</td><td>71.7±4.7</td><td>56.4±7.1 57.0±5.5</td><td>27.3±5.5 30.7±6.3</td></tr><tr><td></td><td>70.5±3.9</td><td>74.0±8.8</td><td>71.2±5.2</td><td></td><td></td></tr><tr><td>GIN GAT</td><td>71.0±4.4</td><td>84.5±8.9 73.9±10.7</td><td>70.6±4.3 72.0±3.3</td><td>51.2±9.2 57.0±7.3</td><td>38.3±6.4 30.2±4.2</td></tr><tr><td>Nested GCN</td><td>76.3±3.8</td><td></td><td></td><td></td><td></td></tr><tr><td></td><td>77.4±4.2</td><td>82.9±11.1</td><td>73.3±4.0</td><td>57.3±7.7</td><td>31.2±6.7</td></tr><tr><td>Nested GraphSAGE Nested GIN</td><td>77.8±3.9</td><td>83.9±10.7 87.9±8.2</td><td>74.2±3.7 73.9±5.1</td><td>57.0±5.9 54.1±7.7</td><td>30.7±6.3 29.0±8.0</td></tr><tr><td>Nested GAT</td><td>76.0±4.4</td><td>81.9±10.2</td><td>73.7±4.8</td><td>56.7±8.1</td><td>29.5±5.7</td></tr><tr><td>Max. improvement</td><td>10.4%</td><td>13.4%</td><td>4.7%</td><td>5.7%</td><td>14.3%</td></tr></table>
Table 5: Results $( \% )$ on OGB datasets (\* virtual node).
<table><tr><td></td><td colspan="2">ogbg-molhiv (AUC)</td><td colspan="2">ogbg-molpcba (AP)</td></tr><tr><td>Method</td><td>Validation</td><td>Test</td><td>Validation</td><td>Test</td></tr><tr><td>CCN*</td><td>83.84±0.91</td><td>75.99±1.19</td><td>24.95±0.42</td><td>24.24±0.34</td></tr><tr><td>GIN*</td><td>84.79±0.68</td><td>77.07±1.49</td><td>27.98±0.25</td><td>27.03±0.23</td></tr><tr><td>Deep LRP</td><td>82.09±1.16</td><td>77.19±1.40</td><td></td><td></td></tr><tr><td>DeeperGCN*</td><td></td><td></td><td>29.20±0.25</td><td>27.81±0.38</td></tr><tr><td>HIMP</td><td></td><td>78.80±0.82</td><td></td><td></td></tr><tr><td>PNA</td><td>85.19±0.99</td><td>79.05±1.32</td><td></td><td></td></tr><tr><td>DGN</td><td>84.70±0.47</td><td>79.70±0.97-</td><td></td><td></td></tr><tr><td>GINE*</td><td></td><td></td><td>30.65±0.30</td><td>29.17±0.15</td></tr><tr><td>PHC-GNN</td><td>82.17±0.89</td><td>79.34±1.16</td><td>30.68±0.25</td><td>29.47±0.26</td></tr><tr><td>Nested GIN*</td><td>83.17±1.99</td><td>78.34±1.86</td><td>29.15±0.35</td><td>28.32±0.41</td></tr><tr><td>NestedGIN* (ens)</td><td>80.80±2.78</td><td>79.86±1.05</td><td>30.59±0.56</td><td>30.07±0.37</td></tr></table>
To answer Q4, we report the training time per epoch for GIN and Nested GIN on OGB datasets. On ogbg-molhiv, GIN takes 54s per epoch, while Nested GIN takes 183s. On ogbg-molpcba, GIN takes 10min per epoch, while Nested GIN takes $2 0 \mathrm { { m i n } }$ . This verifies that NGNN has comparable time complexity with message passing GNNs. The extra complexity comes from independently learning better node representations from rooted subgraphs, which is a trade-off for the higher expressivity.
In summary, our experiments have firmly shown that NGNN is a theoretically sound method which brings consistent gains to its base GNNs in a plug-and-play way. Furthermore, NGNN still maintains a controllable time complexity compared to other more powerful GNNs.
Finally, we point out one memory limitation of the current NGNN implementation. Currently, NGNN does not scale to graph datasets with a large average node number (such as REDDIT-BINARY) or datasets with a large average node degree (such as ogbg-ppa) due to copying a rooted subgraph for each node to the GPU memory. Reducing batch size or subgraph height helps, but at the same time leads to performance degradation. One may wonder why materializing all the subgraphs into GPU memory is necessary. The reason is that we want to batch-process all the subgraphs simultaneously. Otherwise, we have to sequentially extract subgraphs on the fly, which results in a much higher latency. We leave the exploration of memory efficient NGNN to the future work.
# 6 Conclusions
We have proposed Nested Graph Neural Network (NGNN), a general framework for improving GNN’s representation power. NGNN learns node representations encoding rooted subgraphs instead of rooted subtrees. Theoretically, we prove NGNN can discriminate almost all $r$ -regular graphs where 1-WL always fails. Empirically, NGNN consistently improves the performance of various base GNNs across different datasets without incurring the $\mathcal { O } ( \bar { n } ^ { 3 } )$ complexity like other more powerful GNNs.
# Acknowledge
The authors greatly thank the actionable suggestions from the reviewers to improve the manuscript. Li is partly supported by the 2021 JP Morgan Faculty Award and the National Science Foundation (NSF) award HDR-2117997.
References [1] Bryan Perozzi, Rami Al-Rfou, and Steven Skiena. Deepwalk: Online learning of social representations. In Proceedings of the 20th ACM SIGKDD international conference on Knowledge discovery and data mining, pages 701–710. ACM, 2014. [2] David Haussler. Convolution kernels on discrete structures. Technical report, Citeseer, 1999. [3] Nino Shervashidze, SVN Vishwanathan, Tobias Petri, Kurt Mehlhorn, and Karsten M Borgwardt. Efficient graphlet kernels for large graph comparison. In AISTATS, volume 5, pages 488–495, 2009. [4] Risi Kondor, Nino Shervashidze, and Karsten M Borgwardt. The graphlet spectrum. In Proceedings of the 26th Annual International Conference on Machine Learning, pages 529–536. ACM, 2009. [5] Karsten M Borgwardt and Hans-Peter Kriegel. Shortest-path kernels on graphs. In 5th IEEE International Conference on Data Mining, pages 8–pp. IEEE, 2005. [6] Marion Neumann, Roman Garnett, Christian Bauckhage, and Kristian Kersting. Propagation kernels: efficient graph kernels from propagated information. Machine Learning, 102(2): 209–245, 2016. [7] Nino Shervashidze, Pascal Schweitzer, Erik Jan van Leeuwen, Kurt Mehlhorn, and Karsten M Borgwardt. Weisfeiler-lehman graph kernels. Journal of Machine Learning Research, 12(Sep): 2539–2561, 2011. [8] Franco Scarselli, Marco Gori, Ah Chung Tsoi, Markus Hagenbuchner, and Gabriele Monfardini. The graph neural network model. IEEE Transactions on Neural Networks, 20(1):61–80, 2009. [9] Joan Bruna, Wojciech Zaremba, Arthur Szlam, and Yann LeCun. Spectral networks and locally connected networks on graphs. arXiv preprint arXiv:1312.6203, 2013. [10] David K Duvenaud, Dougal Maclaurin, Jorge Iparraguirre, Rafael Bombarell, Timothy Hirzel, Alán Aspuru-Guzik, and Ryan P Adams. Convolutional networks on graphs for learning molecular fingerprints. In Advances in neural information processing systems, pages 2224– 2232, 2015. [11] Yujia Li, Daniel Tarlow, Marc Brockschmidt, and Richard Zemel. Gated graph sequence neural networks. arXiv preprint arXiv:1511.05493, 2015. [12] Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. arXiv preprint arXiv:1609.02907, 2016. [13] Michaël Defferrard, Xavier Bresson, and Pierre Vandergheynst. Convolutional neural networks on graphs with fast localized spectral filtering. In Advances in Neural Information Processing Systems, pages 3837–3845, 2016. [14] Hanjun Dai, Bo Dai, and Le Song. Discriminative embeddings of latent variable models for structured data. In Proceedings of The 33rd International Conference on Machine Learning, pages 2702–2711, 2016. [15] Petar Velickovi ˇ c, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Lio, and Yoshua ´ Bengio. Graph attention networks. arXiv preprint arXiv:1710.10903, 2017. [16] Muhan Zhang, Zhicheng Cui, Marion Neumann, and Yixin Chen. An end-to-end deep learning architecture for graph classification. In AAAI, pages 4438–4445, 2018. [17] Zhitao Ying, Jiaxuan You, Christopher Morris, Xiang Ren, Will Hamilton, and Jure Leskovec. Hierarchical graph representation learning with differentiable pooling. In Advances in Neural Information Processing Systems, pages 4800–4810, 2018. [18] Justin Gilmer, Samuel S Schoenholz, Patrick F Riley, Oriol Vinyals, and George E Dahl. Neural message passing for quantum chemistry. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pages 1263–1272. JMLR. org, 2017.
[19] Christopher Morris, Martin Ritzert, Matthias Fey, William L Hamilton, Jan Eric Lenssen, Gaurav Rattan, and Martin Grohe. Weisfeiler and leman go neural: Higher-order graph neural networks. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pages 4602–4609, 2019.
[20] Haggai Maron, Heli Ben-Hamu, Hadar Serviansky, and Yaron Lipman. Provably powerful graph networks. In Advances in Neural Information Processing Systems, pages 2156–2167, 2019.
[21] Zhengdao Chen, Soledad Villar, Lei Chen, and Joan Bruna. On the equivalence between graph isomorphism testing and function approximation with gnns. In Advances in Neural Information Processing Systems, pages 15894–15902, 2019.
[22] Boris Weisfeiler and AA Lehman. A reduction of a graph to a canonical form and an algebra arising during this reduction. Nauchno-Technicheskaya Informatsia, 2(9):12–16, 1968.
[23] S Vichy N Vishwanathan, Nicol N Schraudolph, Risi Kondor, and Karsten M Borgwardt. Graph kernels. Journal of Machine Learning Research, 11(Apr):1201–1242, 2010.
[24] Pan Li, Yanbang Wang, Hongwei Wang, and Jure Leskovec. Distance encoding–design provably more powerful gnns for structural representation learning. arXiv preprint arXiv:2009.00142, 2020.
[25] Christopher Morris, Gaurav Rattan, and Petra Mutzel. Weisfeiler and leman go sparse: Towards scalable higher-order graph embeddings. 2020.
[26] Muhan Zhang and Yixin Chen. Weisfeiler-lehman neural machine for link prediction. In Proceedings of the 23rd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pages 575–583. ACM, 2017.
[27] Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural networks? arXiv preprint arXiv:1810.00826, 2018.
[28] Manzil Zaheer, Satwik Kottur, Siamak Ravanbakhsh, Barnabas Poczos, Russ R Salakhutdinov, and Alexander J Smola. Deep sets. In Advances in Neural Information Processing Systems, pages 3391–3401, 2017.
[29] Andries E Brouwer and Willem H Haemers. Strongly regular graphs. In Spectra of Graphs, pages 115–149. Springer, 2012.
[30] Ryan Murphy, Balasubramaniam Srinivasan, Vinayak Rao, and Bruno Ribeiro. Relational pooling for graph representations. In International Conference on Machine Learning, pages 4663–4673. PMLR, 2019.
[31] Giorgos Bouritsas, Fabrizio Frasca, Stefanos Zafeiriou, and Michael M Bronstein. Improving graph neural network expressivity via subgraph isomorphism counting. arXiv preprint arXiv:2006.09252, 2020.
[32] Jiaxuan You, Jonathan Gomes-Selman, Rex Ying, and Jure Leskovec. Identity-aware graph neural networks. arXiv preprint arXiv:2101.10320, 2021.
[33] Dominique Beaini, Saro Passaro, Vincent Létourneau, William L Hamilton, Gabriele Corso, and Pietro Liò. Directional graph networks. arXiv preprint arXiv:2010.02863, 2020.
[34] Haggai Maron, Heli Ben-Hamu, Nadav Shamir, and Yaron Lipman. Invariant and equivariant graph networks. arXiv preprint arXiv:1812.09902, 2018.
[35] Haggai Maron, Ethan Fetaya, Nimrod Segol, and Yaron Lipman. On the universality of invariant networks. In International conference on machine learning, pages 4363–4371. PMLR, 2019.
[36] Nicolas Keriven and Gabriel Peyré. Universal invariant and equivariant graph neural networks. arXiv preprint arXiv:1905.04943, 2019.
[37] Waïss Azizian and Marc Lelarge. Characterizing the expressive power of invariant and equivariant graph neural networks. arXiv preprint arXiv:2006.15646, 2020.
[38] George Dasoulas, Ludovic Dos Santos, Kevin Scaman, and Aladin Virmaux. Coloring graph neural networks for node disambiguation. arXiv preprint arXiv:1912.06058, 2019.
[39] Zhengdao Chen, Lei Chen, Soledad Villar, and Joan Bruna. Can graph neural networks count substructures? Advances in neural information processing systems, 2020.
[40] Andreas Loukas. What graph neural networks cannot learn: depth vs width. arXiv preprint arXiv:1907.03199, 2019.
[41] Ryoma Sato, Makoto Yamada, and Hisashi Kashima. Random features strengthen graph neural networks. arXiv preprint arXiv:2002.03155, 2020.
[42] Ralph Abboud, ˙Ismail ˙Ilkan Ceylan, Martin Grohe, and Thomas Lukasiewicz. The surprising power of graph neural networks with random node initialization. arXiv preprint arXiv:2010.01179, 2020.
[43] Clément Vignac, Andreas Loukas, and Pascal Frossard. Building powerful and equivariant graph neural networks with structural message-passing. arXiv e-prints, pages arXiv–2006, 2020.
[44] Muhan Zhang and Yixin Chen. Link prediction based on graph neural networks. In Advances in Neural Information Processing Systems, pages 5165–5175, 2018.
[45] Muhan Zhang, Pan Li, Yinglong Xia, Kai Wang, and Long Jin. Revisiting graph neural networks for link prediction. arXiv preprint arXiv:2010.16103, 2020.
[46] Muhan Zhang and Yixin Chen. Inductive matrix completion based on graph neural networks. In International Conference on Learning Representations, 2020. URL https://openreview. net/forum?id $\equiv$ ByxxgCEYDS.
[47] Pim de Haan, Taco Cohen, and Max Welling. Natural graph networks. arXiv preprint arXiv:2007.08349, 2020.
[48] Giannis Nikolentzos, George Dasoulas, and Michalis Vazirgiannis. k-hop graph neural networks. Neural Networks, 130:195–205, 2020.
[49] Sami Abu-El-Haija, Bryan Perozzi, Amol Kapoor, Nazanin Alipourfard, Kristina Lerman, Hrayr Harutyunyan, Greg Ver Steeg, and Aram Galstyan. Mixhop: Higher-order graph convolutional architectures via sparsified neighborhood mixing. In international conference on machine learning, pages 21–29. PMLR, 2019.
[50] Kexin Huang and Marinka Zitnik. Graph meta learning via local subgraphs. Advances in Neural Information Processing Systems, 33, 2020.
[51] Matthias Fey and Jan Eric Lenssen. Fast graph representation learning with pytorch geometric. arXiv preprint arXiv:1903.02428, 2019.
[52] Raghunathan Ramakrishnan, Pavlo O Dral, Matthias Rupp, and O Anatole Von Lilienfeld. Quantum chemistry structures and properties of 134 kilo molecules. Scientific data, 1(1):1–7, 2014.
[53] Zhenqin Wu, Bharath Ramsundar, Evan N Feinberg, Joseph Gomes, Caleb Geniesse, Aneesh S Pappu, Karl Leswing, and Vijay Pande. Moleculenet: a benchmark for molecular machine learning. Chemical science, 9(2):513–530, 2018.
[54] Kristian Kersting, Nils M. Kriege, Christopher Morris, Petra Mutzel, and Marion Neumann. Benchmark data sets for graph kernels, 2016. URL http://graphkernels.cs. tu-dortmund.de.
[55] Paul D Dobson and Andrew J Doig. Distinguishing enzyme structures from non-enzymes without alignments. Journal of molecular biology, 330(4):771–783, 2003.
[56] Asim Kumar Debnath, de Compadre RL Lopez, Gargi Debnath, Alan J Shusterman, and Corwin Hansch. Structure-activity relationship of mutagenic aromatic and heteroaromatic nitro compounds. correlation with molecular orbital energies and hydrophobicity. Journal of medicinal chemistry, 34(2):786–797, 1991. [57] Hannu Toivonen, Ashwin Srinivasan, Ross D King, Stefan Kramer, and Christoph Helma. Statistical evaluation of the predictive toxicology challenge 2000–2001. Bioinformatics, 19(10): 1183–1193, 2003. [58] Ida Schomburg, Antje Chang, Christian Ebeling, Marion Gremse, Christian Heldt, Gregor Huhn, and Dietmar Schomburg. Brenda, the enzyme database: updates and major new developments. Nucleic acids research, 32(suppl_1):D431–D433, 2004. [59] Weihua Hu, Matthias Fey, Marinka Zitnik, Yuxiao Dong, Hongyu Ren, Bowen Liu, Michele Catasta, and Jure Leskovec. Open graph benchmark: Datasets for machine learning on graphs. arXiv preprint arXiv:2005.00687, 2020. [60] Brandon Anderson, Truong-Son Hy, and Risi Kondor. Cormorant: Covariant molecular neural networks. arXiv preprint arXiv:1906.04015, 2019. [61] Johannes Klicpera, Janek Groß, and Stephan Günnemann. Directional message passing for molecular graphs. arXiv preprint arXiv:2003.03123, 2020. [62] Zhuoran Qiao, Matthew Welborn, Animashree Anandkumar, Frederick R Manby, and Thomas F Miller III. Orbnet: Deep learning for quantum chemistry using symmetry-adapted atomic-orbital features. The Journal of Chemical Physics, 153(12):124111, 2020. [63] Hanqing Zeng, Muhan Zhang, Yinglong Xia, Ajitesh Srivastava, Andrey Malevich, Rajgopal Kannan, Viktor Prasanna, Long Jin, and Ren Chen. Deep graph neural networks with shallow subgraph samplers. arXiv preprint arXiv:2012.01380, 2020. [64] Will Hamilton, Zhitao Ying, and Jure Leskovec. Inductive representation learning on large graphs. In Advances in Neural Information Processing Systems, pages 1025–1035, 2017. [65] Federico Errica, Marco Podda, Davide Bacciu, and Alessio Micheli. A fair comparison of graph neural networks for graph classification. arXiv preprint arXiv:1912.09893, 2019. [66] Matthias Fey and Jan E. Lenssen. Fast graph representation learning with PyTorch Geometric. In ICLR Workshop on Representation Learning on Graphs and Manifolds, 2019. [67] Guohao Li, Chenxin Xiong, Ali Thabet, and Bernard Ghanem. Deepergcn: All you need to train deeper gcns. arXiv preprint arXiv:2006.07739, 2020. [68] Gabriele Corso, Luca Cavalleri, Dominique Beaini, Pietro Liò, and Petar Velickovi ˇ c. Principal ´ neighbourhood aggregation for graph nets. arXiv preprint arXiv:2004.05718, 2020. [69] Rémy Brossard, Oriel Frigo, and David Dehaene. Graph convolutions that can finally model local structure. arXiv preprint arXiv:2011.15069, 2020. [70] Tuan Le, Marco Bertolini, Frank Noé, and Djork-Arné Clevert. Parameterized hypercomplex graph neural networks for graph classification. arXiv preprint arXiv:2103.16584, 2021. [71] Katsuhiko Ishiguro, Shin-ichi Maeda, and Masanori Koyama. Graph warp module: an auxiliary module for boosting the power of graph neural networks. arXiv preprint arXiv:1902.01020, 2019. [72] Hongyang Gao and Shuiwang Ji. Graph u-nets. arXiv preprint arXiv:1905.05178, 2019. [73] Douglas J Klein and Milan Randic. Resistance distance. ´ Journal of Mathematical Chemistry, 12(1):81–95, 1993.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346# REVISITING GRAPH NEURAL NETWORKS FOR LINK PREDICTION
Anonymous authors Paper under double-blind review
# ABSTRACT
Graph neural networks (GNNs) have achieved great success in recent years. Three most common applications include node classification, link prediction, and graph classification. While there is rich literature on node classification and graph classification, GNNs for link prediction is relatively less studied and less understood. Two representative classes of methods exist: GAE and SEAL. GAE (Graph Autoencoder) first uses a GNN to learn node embeddings for all nodes, and then aggregates the embeddings of the source and target nodes as their link representation. SEAL extracts a subgraph around the source and target nodes, labels the nodes in the subgraph, and then uses a GNN to learn a link representation from the labeled subgraph. In this paper, we thoroughly discuss the differences between these two classes of methods, and conclude that simply aggregating node embeddings does not lead to effective link representations, while learning from properly labeled subgraphs around links provides highly expressive and generalizable link representations. Experiments on the recent large-scale OGB link prediction datasets show that SEAL has up to $19 5 \%$ performance gains over GAE methods, achieving new state-of-the-art results on 3 out of 4 datasets.
# 1 INTRODUCTION
Link prediction is to predict potential or missing links connecting pairwise nodes in a network. It has wide applications in various fields, such as friend recommendation in social networks (Adamic & Adar, 2003), movie recommendation in Netflix (Bennett et al., 2007), protein-protein interaction prediction (Qi et al., 2006), and knowledge graph completion (Nickel et al., 2015), etc.
Traditional link prediction approaches include heuristic methods, embedding methods, and featurebased methods. Heuristic methods compute some heuristic node similarity scores as the likelihood of links (Liben-Nowell & Kleinberg, 2007), such as common neighbors, preferential attachment (Barabasi & Albert, 1999), and Katz index (Katz, 1953), which can be regarded as some ´ predefined graph structure features. Embedding methods, including matrix factorization (MF) and Node2vec (Grover & Leskovec, 2016), learn free-parameter node embeddings from the observed network transductively, thus do not generalize to unseen nodes and networks. Feature-based methods only use explicit node features yet do not consider the graph structure. Recently, graph neural networks (GNNs) emerged to be powerful tools for learning over graph-structured data (Scarselli et al., 2009; Bruna et al., 2013; Duvenaud et al., 2015; Li et al., 2015; Kipf & Welling, 2016a; Niepert et al., 2016; Dai et al., 2016), and have been successfully used in link prediction as well (Kipf & Welling, 2016b; Zhang & Chen, 2018; You et al., 2019; Chami et al., 2019; Li et al., 2020).
There are two main types of GNN-based link prediction methods. One is Graph Autoencoder (Kipf & Welling, 2016b), where a GNN is first applied to the entire network to learn an embedding vector for each node. Then the embeddings of the source and target nodes are aggregated to predict the target link. The second type is SEAL (Zhang & Chen, 2018; Li et al., 2020), where an enclosing subgraph is extracted around each target link. Then the nodes in each enclosing subgraph are labeled differently according to their distances to the source and target nodes. Finally a GNN is applied to each enclosing subgraph to learn a link representation for link prediction. At first glance, both methods seem to learn graph structure features associated with the target link, and leverage these structure features for link prediction. However, as we will see, the two methods have fundamentally different power in terms of learning the structural representations of links.
 Figure 1: The structural roles of link $( v _ { 1 } , v _ { 2 } )$ and link $( v _ { 1 } , v _ { 3 } )$ are different, but GAE will assign equal probabilities to them.
We first show that by individually learning source and target node embeddings, GAE methods cannot differentiate links with different structural roles. To intuitively understand this, we give an example in Figure 1. In this graph, nodes $v _ { 2 }$ and $v _ { 3 }$ have the same structural roles (symmetric/isomorphic to each other). A GAE will learn the same node embeddings for $v _ { 2 }$ and $v _ { 3 }$ , thus giving the same predicted probabilities for link $( v _ { 1 } , v _ { 2 } )$ and link $( v _ { 1 } , v _ { 3 } )$ . However, the structural roles of link $( v _ { 1 } , v _ { 2 } )$ and link $( v _ { 1 } , v _ { 3 } )$ are apparently different – $v _ { 1 }$ intuitively should have unequal probabilities connecting to $v _ { 2 }$ and $v _ { 3 }$ . Next, we propose a labeling trick, which gives a label to each node as its additional feature, where the source and target nodes are labeled differently from the rest. We show that combined with the labeling trick, a sufficiently expressive GNN can learn the same representations for two links if and only if their structural roles are the same within the graph. This way, $( v _ { 1 } , v _ { 2 } )$ and $( v _ { 1 } , v _ { 3 } )$ will be predicted differently in Figure 1. We further show that SEAL is such an example. Finally, we give a more practical definition of isomorphism, called local isomorphism, which defines two nodes/links as isomorphic if their local neighborhood subgraphs are isomorphic. We argue that GNNs for link prediction should target on local-isomorphism-discriminating.
We conduct a thorough comparison among different link prediction methods, including SEAL and various GAE and embedding methods, on the recent large-scale Open Graph Benchmark (OGB) datasets (Hu et al., 2020). We show that SEAL with the labeling trick has up to $19 5 \%$ higher Hits $@ 1 0 0$ than GAE methods, achieving new state-of-the-art results on 3 out of 4 datasets.
# 2 PRELIMINARIES
In this section, we formally define the notions of graph, permutation, isomorphism, and GNN.
Definition 1. (Graph). We consider an undirected graph $\mathcal { G } = ( V , E , \pmb { \Delta } )$ , where $V = \{ 1 , 2 , \dots , n \}$ is the set of n vertices, $E \subseteq V \times V$ is the set of edges, and $\pmb { \mathsf { A } } \in \mathbb { R } ^ { n \times n \times k }$ contains the node and edge features with its diagonal components $\mathsf { \pmb { A } } _ { i , i } ,$ : denoting node attributes and off-diagonal components $\mathsf { \pmb { A } } _ { i , j } ,$ : denoting edge attributes. We further use $\pmb { A } \in \mathsf { \bar { \{ 0 , 1 \} } } ^ { n \times n }$ to denote the adjacency matrix of $\mathcal { G }$ with $A _ { i , j } = 1$ iff $( i , j ) \in E$ . If there are no node/edge features, we let $\pmb { \mathsf { A } } = \pmb { A }$ . Otherwise, $\pmb { A }$ can be regarded as the first slice of $\pmb { \mathsf { A } }$ , i.e., $A = \pmb { \mathsf { A } } _ { : , : , 1 }$ .
Definition 2. (Permutation) $A$ node permutation $\pi$ is a bijective mapping from $\{ 1 , 2 , \ldots , n \}$ to $\{ 1 , 2 , \ldots , n \}$ . All $n$ ! possible $\pi$ ’s constitute the permutation group $\Pi _ { n }$ . We define $\pi ( S ) = \{ \pi ( i ) | i \in$ $S \}$ when $S$ is a subset of $\{ 1 , 2 , \ldots , n \}$ . We further define the permutation of $\pmb { \mathsf { A } }$ as $\pi ( \pmb { \mathsf { A } } )$ , where $\pi ( \pmb { \ A } ) _ { \pi ( i ) , \pi ( j ) , : } = \pmb { \ A } _ { i , j , : }$ . In other words, $\pi ( \mathbf { A } ) _ { i , j , : } = \pmb { \Delta } _ { \pi ^ { - 1 } ( i ) , \pi ^ { - 1 } ( j ) , }$ : .
Definition 3. (Set isomorphism) Given two $n$ -node graphs $\mathcal { G } = ( V , E , \pmb { \Delta } )$ , $\mathcal { G } ^ { \prime } = ( V ^ { \prime } , E ^ { \prime } , \pmb { \Delta } ^ { \prime } )$ , and two node sets $S \subseteq V$ , $S ^ { \prime } \subseteq V ^ { \prime }$ , we say $( S , \pmb { \mathsf { A } } )$ and $( S ^ { \prime } , { \pmb { \mathsf { A } } } ^ { \prime } )$ are isomorphic (denoted by $( S , \pmb { \mathsf { A } } ) \simeq ( S ^ { \prime } , \pmb { \mathsf { A } } ^ { \prime } ) )$ ) $i f \exists \pi \in \Pi _ { n }$ such that $S = \pi ( S ^ { \prime } )$ and $\pmb { \mathsf { A } } = \pi ( \pmb { \mathsf { A } } ^ { \prime } )$ .
When $( V , \pmb { \mathsf { A } } ) \simeq ( V ^ { \prime } , \pmb { \mathsf { A } } ^ { \prime } )$ , we say two graphs $\mathcal { G }$ and $\mathcal { G } ^ { \prime }$ are isomorphic (abbreviated as $\mathsf { \pmb { A } } \simeq \mathsf { \pmb { A } } ^ { \prime }$ because $V = \pi ( V ^ { \prime } )$ for any $\pi$ ). Note that set isomorphism is more strict than graph isomorphism, because it not only requires graph isomorphism, but also requires the permutation maps a specific subset $S$ to another subset $S ^ { \bar { \prime } }$ . When $S \subset V$ and $S ^ { \prime } \subset V ^ { \prime }$ , we are often more concerned with the case of $\pmb { \mathsf { A } } = \pmb { \mathsf { A } } ^ { \prime }$ , where we are to find isomorphic node sets in the same graph (automorphism). For example, when $S = \{ i \} , S ^ { \prime } = \{ j \}$ (single node case) and $( i , \pmb { \mathsf { A } } ) , ( j , \pmb { \mathsf { A } } )$ are isomorphic, it means $i$ and $j$ are on the same orbit of graph $\pmb { \mathsf { A } }$ (i.e., they have symmetric positions/same structural roles within the graph). An example is $v _ { 2 }$ and $v _ { 3 }$ in Figure 1.
Definition 4. (Invariant function) A function $f$ defined over the space of $( S , \pmb { \mathsf { A } } )$ is invariant if $\forall \pi \in \Pi _ { n }$ , $f ( S , \mathbf { A } ) = f ( \pi ( S ) , \pi ( \mathbf { A } ) )$ .
Definition 5. (GNN) $A$ GNN is an invariant function mapping from the space of $( S , \pmb { \mathsf { A } } )$ to $\mathbb { R } ^ { d }$ . More specifically, a GNN first performs multiple invariant message passing operations to compute a node embedding $z _ { i } = \mathbf { G N N } ( i , \mathbf { A } )$ for all $i \in S$ , and then performs a set aggregation (pooling) over $\{ z _ { i } | i \in S \}$ , written as $\mathrm { A G G } ( \{ z _ { i } | i \in S \} )$ , as the set $S$ ’s representation $\mathrm { G N N } ( S , \pmb { \mathsf { A } } )$ .
Note that, when $| S | = 1$ , the set aggregation is often an identity mapping. In graph classification $S = V )$ , we use a graph pooling layer over node embeddings to compute the graph representation.
# 3 GAE AND STRUCTURAL LINK REPRESENTATION
In this section, we review how GAE methods predict links, and show that simply aggregating node embeddings learned by a GNN cannot lead to effective link representations. We use $\pmb { \mathsf { A } }$ to denote the incomplete network to perform link prediction.
# 3.1 GAE FOR LINK PREDICTION
Graph Autoencoder (GAE) methods (Kipf & Welling, 2016b) first use a GNN to compute a node embedding $z _ { i }$ for each node $i$ , and then use $f ( z _ { i } , z _ { j } )$ to predict the link $( i , j )$ :
$$\hat { A } _ { i , j } = f ( z _ { i } , z _ { j } ) , \mathrm { w h e r e } z _ { i } = \mathrm { G N N } ( i , \mathsf { A } ) , z _ { j } = \mathrm { G N N } ( j , \mathsf { A } )$$
where $\hat { A } _ { i , j }$ is the predicted score for link $( i , j )$ . The model is trained to maximize the likelihood of reconstructing the true adjacency matrix. The original GAE uses a two-layer GCN (Kipf & Welling, 2016a) as the GNN, and let $f ( z _ { i } , z _ { j } ) : = \sigma ( z _ { i } ^ { \top } z _ { j } )$ . In principle, we can replace GCN with any message passing neural network (Gilmer et al., 2017), and use an MLP over the aggregation of $z _ { i }$ and $z _ { j }$ as the $f ( z _ { i } , z _ { j } )$ . Popular aggregation functions include concatenation, mean and Hadamard product, etc. In the following, we will use GAE to denote a general class of GNN-based link prediction methods, without differentiating the specific choices of GNN and $f$ .
# 3.2 GAE CAN LEARN STRUCTURAL NODE REPRESENTATIONS
Following (Srinivasan & Ribeiro, 2020; Li et al., 2020), we first define most expressive structural representations for nodes and links. Then we relate them to GAE-learned node embeddings and show that GAE is not capable of learning structural link representations.
Definition 6. Given an invariant function $\Gamma ( \cdot )$ , $\Gamma ( S , \pmb { \mathsf { A } } )$ is a most expressive structural representation for $( S , \pmb { \mathsf { A } } )$ if $\forall ( S , \pmb { \mathsf { A } } , S ^ { \prime } , \pmb { \mathsf { A } } ^ { \prime } )$ , $\Gamma ( S , \pmb { \mathsf { A } } ) = \Gamma ( S ^ { \prime } , \pmb { \mathsf { A } } ^ { \prime } ) \Leftrightarrow ( S , \pmb { \mathsf { A } } ) \simeq ( S ^ { \prime } , \pmb { \mathsf { A } } ^ { \prime } ) .$ .
For simplicity, we will briefly use “structural representation” to denote most expressive structural representation in the rest of the paper. We will omit $\pmb { \mathsf { A } }$ if it is clear from context. We call $\Gamma ( i , \pmb { \mathsf { A } } )$ a structural node representation for $i$ , and call $\Gamma ( \{ i , j \} , \mathbf { A } )$ a structural link representation for $( i , j )$ .
The above definition indicates that two node sets have the same structural representations if and only if they are isomorphic to each other. In the same graph $\pmb { \mathsf { A } }$ , structural representations uniquely mark the structural roles of nodes or node sets. This is in contrast to positional node embeddings such as DeepWalk (Perozzi et al., 2014) and matrix factorization (Mnih & Salakhutdinov, 2008), where two isomorphic nodes can have different node embeddings (Ribeiro et al., 2017).
So why do we need to define structural representations? From a node classification point of view, it is because two isomorphic nodes in a network are perfectly symmetric to each other, and should be indistinguishable using any labeling functions on graphs (i.e., they should have the same ground truth $y$ ). Learning a structural node representation can guarantee that isomorphic nodes are always classified into the same class.
Then, a natural question to ask is, do GNNs learn structural node representations? The answer is no. Recall that $( { \dot { i } } , \mathbf { A } ) \simeq ( j , \mathbf { A } ^ { \prime } ) \Rightarrow \mathbf { A } \simeq \mathbf { A } ^ { \prime }$ . If a GNN can learn structural node representations, we can always use it for graph isomorphism test by checking whether there exist two nodes in two graphs sharing the same structural node representation. In fact, existing GNNs’ graph discriminating power is bounded by the Weisfeiler-Lehman (WL) test (Morris et al., 2019; Maron et al., 2019), which provably fails to distinguish certain non-isomorphic graphs (Cai et al., 1992). Despite this, GNNs/WL are still powerful enough to learn representations that can distinguish almost all nonisomorphic nodes and graphs (Babai & Kucera, 1979).
For easy analysis, we assume there exists a node-most-expressive GNN that can output structural node representations thus able to distinguish all non-isomorphic nodes. Despite this, the techniques we will present are not limited to node-most-expressive GNNs, but also benefit practical GNNs.
Definition 7. A GNN is node-most-expressive if $\forall ( i , \mathsf { \pmb A } , j , \mathsf { \pmb A } ^ { \prime } )$ , $\mathrm { G N N } ( i , \pmb { \mathsf { A } } ) = \mathrm { G N N } ( j , \pmb { \mathsf { A } } ^ { \prime } ) \Leftrightarrow$ $( i , \mathsf { \pmb A } ) \simeq ( j , \mathsf { \pmb A } ^ { \prime } )$ .
Recall that GAE first uses a GNN to compute node embeddings. Therefore, GAE with a node-mostexpressive GNN is able to leverage structural node representations for link prediction.
# 3.3 GAE CANNOT LEARN STRUCTURAL LINK REPRESENTATIONS
The next question to ask is whether GAE learns structural link representations. That is, does the aggregation of structural node representations of $i$ and $j$ result in a structural link representation of $( i , j ) ^ { \prime }$ ? The answer is no, as shown in previous works (Srinivasan & Ribeiro, 2020; Zhang & Chen, 2020). We have also illustrated it in the introduction. In Figure 1, we have two isomorphic nodes $v _ { 2 }$ and $v _ { 3 }$ , thus $v _ { 2 }$ and $v _ { 3 }$ will have the same structural node representation. By aggregating structural node representations as link representations, GAE will assign $( v _ { 1 } , v _ { 2 } )$ and $( v _ { 1 } , v _ { 3 } )$ the same link representation and predict them to have equal probabilities of forming a link. However, $( v _ { 1 } , v _ { 2 } )$ and $( v _ { 1 } , v _ { 3 } )$ apparently have different structural link representations, which indicates that
Proposition 1. Even with a node-most-expressive GNN, GAE cannot learn structural link representations.
The root cause of this problem is that GAE learns representations for the source and target nodes individually, without considering their relative positions and associations. For example, although $v _ { 2 }$ and $v _ { 3 }$ are perfectly symmetric in the graph, when considering the source node $v _ { 1 }$ to predict link from, $v _ { 2 }$ and $v _ { 3 }$ ’s positions w.r.t. $v _ { 1 }$ are no longer symmetric.
# 4 HOW TO LEARN STRUCTURAL LINK REPRESENTATIONS?
In this section, we discuss how to enable GNNs to learn structural link representations with a simple labeling trick, and show that SEAL is a valid example to learn structural link representations.
# 4.1 LABELING TRICK
We first introduce the labeling trick.
Definition 8. (Labeling trick) Given $( S , \pmb { \mathsf { A } } )$ , we stack a diagonal labeling matrix $\pmb { I } ^ { ( S ) } \in \mathbb { R } ^ { n \times n }$ in the third dimension of $\pmb { \mathsf { A } }$ to get a new $\tilde { \textbf { A } } \in \mathbb { R } ^ { n \times n \times ( k + 1 ) }$ , where $\pmb { I }$ satisfies: $\forall \pi \ \in \ \Pi _ { n }$ , (1) $\pmb { I } ^ { ( S ) } = \pi ( \pmb { I } ^ { ( S ^ { \prime } ) } ) \Rightarrow S = \pi ( S ^ { \prime } )$ , and (2) $S = \pi ( S ^ { \prime } ) , \pmb { \mathrm { A } } = \pi ( \pmb { \mathrm { A } } ^ { \prime } ) \Rightarrow \pmb { I } ^ { ( S ) } = \pi ( \pmb { I } ^ { ( S ^ { \prime } ) } )$ . A simplest labeling trick is to let $I _ { i i } ^ { ( S ) } = 1$ if $i \in S$ otherwise $O$ .
Note that the notation $\tilde { \pmb { A } }$ should actually depend on $S$ . For convenience, we omit such dependence on $S$ and infer it from the context. The first condition in Definition 8 requires the labeling matrix to identify the target node set $S$ ; and the second condition requires the labeling trick to be permutation equivariant, i.e., when $( S , A )$ and $( S ^ { \prime } , A ^ { \prime } )$ are isomorphic under $\pi$ , the corresponding nodes $i = \pi ( j )$ always have the same label. Essentially, the labeling trick distinguishes nodes in $S$ from the rest nodes. It can be as simple as only giving label 1 to nodes in $S$ and otherwise 0. Next, we show that with the labeling trick, a node-most-expressive GNN can learn structural link representations.
Theorem 1. If a GNN is node-most-expressive, then with an injective set aggregation function AGG in Definition 5, $\mathrm { G N N } ( S , { \tilde { \mathbf { A } } } ) = \mathrm { G N N } ( S ^ { \prime } , { \tilde { \mathbf { A } } } ^ { \prime } ) \Leftrightarrow ( S , \mathbf { A } ) \simeq ( S ^ { \prime } , \mathbf { A } ^ { \prime } )$ for any $S , \pmb { \mathsf { A } } , S ^ { \prime } , \pmb { \mathsf { A } } ^ { \prime }$ .
We include all the proofs in the appendix. Theorem 1 implies that $\mathbf { G N N } ( S , \tilde { \mathbf { A } } )$ is a structural representation for $( S , \pmb { \mathsf { A } } )$ . Recall Definition 5 defines $\mathrm { G N N } ( S , \tilde { \mathbf { A } } ) = \mathrm { A G G } ( \{ \mathrm { G N N } ( i , \tilde { \mathbf { A } } ) | i \in S \} )$ ). The above theorem indicates that although directly aggregating structural node representations learned from the original graph $\pmb { \mathsf { A } }$ does not lead to structural link representations, an injective aggregation over the structural node representations learned from the labeled graph $\tilde { \pmb { A } }$ does lead to structural link representations. How intuitively is it possible? Let’s return to the example in Figure 1. When we want to predict link $( v _ { 1 } , v _ { 2 } )$ , we can mark $v _ { 1 } , v _ { 2 }$ with a different label from the rest nodes, as shown by the different color in Figure 2 left. With the source and target nodes labeled, when the GNN is computing $v _ { 2 }$ ’s embedding, it is also “aware” of the source node $v _ { 1 }$ , instead of the previous agnostic way that treats $v _ { 1 }$ the same as other nodes. And when we want to predict link $( v _ { 1 } , v _ { 3 } )$ , we can again mark $v _ { 1 } , v _ { 3 }$ with a different label, as shown in Figure 2 right. This way, $v _ { 2 }$ and $v _ { 3 }$ ’s structural node representations are no longer the same in the two differently labeled graphs because of their different relative positions w.r.t. $v _ { 1 }$ , and we are able to give different predictions to $( v _ { 1 } , v _ { 2 } )$ and $( v _ { 1 } , v _ { 3 } )$ .
 Figure 2: When we predict $( v _ { 1 } , v _ { 2 } )$ , we will label these two nodes differently from the rest, so that a GNN is aware of the target link when computing $v _ { 1 }$ and $v _ { 2 }$ ’s embeddings. Similarly, when predicting $( v _ { 1 } , v _ { 3 } )$ , nodes $v _ { 1 } , v _ { 3 }$ will be labeled differently. The aggregated embedding of $v _ { 1 } , v _ { 2 }$ in the left graph will be different from the aggregated embedding of $v _ { 1 } , v _ { 3 }$ in the right graph, enabling GNNs to predict $( v _ { 1 } , v _ { 2 } )$ and $( v _ { 1 } , v _ { 3 } )$ differently.
# 4.2 SEAL CAN LEARN STRUCTURAL LINK REPRESENTATIONS
In this section, we will review SEAL (Zhang & Chen, 2018; Li et al., 2020), and show that SEAL exactly uses a valid labeling trick that is able to learn structural link representations.
SEAL first extracts an enclosing subgraph ( $h$ -hop ego-network) around the link to predict.
Definition 9. (Enclosing subgraph) Given $( S , \pmb { \mathsf { A } } )$ , the $h$ -hop enclosing subgraph ${ \pmb { \mathsf { A } } } _ { S } ^ { ( h ) }$ of $S$ is the subgraph induced from A by $\cup _ { i \in S } \{ j | d ( j , i ) \leq h \}$ , where $d ( j , i )$ is the shortest path distance between nodes $j$ and $i$ .
Then, SEAL applies a Double Radius Node Labeling (DRNL) to give an integer label to each node within the enclosing subgraph. DRNL assigns different labels to nodes with different distances w.r.t. both the source and target nodes, where the source and target nodes are always labeled 1, and nodes farther away from the source and target nodes get larger labels (starting from 2). For example, nodes with distances 1 and 1 to the source and target nodes will get label 2, and nodes with distances 1 and 2 to the source and target nodes will get label 3. So on and so forth. Finally the labeled enclosing subgraph is fed to a GNN to learn the link representation and output the probability of link existence.
It can be easily proved that DRNL satisfies the definition of the labeling trick, because node distances are invariant under permutation. DRNL not only differentiates the source and target nodes from the rest, but also differentiates nodes of different distances to the source and target nodes. The DRNL-labeled graphs also satisfy Theorem 1 and thus can enable a node-most-expressive GNN to learn structural link representations. Moreover, SEAL’s distance-based node labeling scheme is formalized into distance encoding, or $D E$ , in (Li et al., 2020), which theoretically shows that encoding distances between nodes can increase the representation power of normal GNNs.
SEAL only uses a subgraph ${ \pmb { \mathsf { A } } } _ { S } ^ { ( h ) }$ within $h$ hops from the source and target nodes instead of using the whole graph. This is for practical concerns (just like GAE typically uses less than 3 message passing layers in practice), and will be discussed in detail in Section 5. When $h \infty$ , SEAL can also leverage the entire graph and learn structural representations for $( S , \pmb { \mathsf { A } } )$ :
Proposition 2. When $h \infty$ , SEAL can learn structural link representations with a node-mostexpressive GNN.
Note that although we show a node-most-expressive GNN combining with the labeling trick is able to learn structural link representations, even without a node-most-expressive GNN, the labeling trick can still benefit most link representation learning tasks. For example, in Figure 2, as long as a normal GNN can give different embeddings to $v _ { 2 }$ and $v _ { 3 }$ in the left and right graphs (which is easy for most GNNs), we can still differentiate link $( v _ { 1 } , v _ { 2 } )$ from link $( v _ { 1 } , v _ { 3 } )$ . And this is not possible for GAE.
Despite the power, the labeling trick introduces extra computational complexity. The reason is that for every link $( i , j )$ to predict, we need to relabel the graph according to $( i , j )$ . The same node $i$ will be labeled differently depending on the target link, and will be given a different node embedding by the GNN when it appears in different links’ labeled graphs. This is different from GAE, where we do not relabel the graph and each node only has a single embedding vector. For a graph with $n$ nodes and $m$ links to predict, GAE needs to apply the GNN ${ \mathcal { O } } ( n )$ times to compute an embedding for each node, while SEAL needs to apply the GNN $\mathcal { O } ( m )$ times for all links. When $m \gg n$ , SEAL has worse time complexity than GAE, which is a trade-off for learning structural link representations.
In the previous analysis, we have assumed there exists a node-most-expressive GNN that can discriminate non-isomorphic nodes. Although a practical GNN can also discriminate almost all nonisomorphic nodes, there is little research discussing how to reach this discriminating power. In this section, we analyze GNNs for link prediction from a more practical point of view.
Practical GNNs usually simulate the 1-dimensional Weisfeiler-Lehman (1-WL) test (Weisfeiler & Lehman, 1968) to iteratively update each node’s hidden state by aggregating its neighbors’ states (we call them 1-WL-GNN). One most powerful 1-WL-GNN is the Graph Isomorphism Network (GIN) (Xu et al., 2018), which achieves theoretically the same discriminating power as 1-WL.
Although showing 1-WL-GNN’s maximum discriminating power, previous GNN research has not discussed how many message passing layers are required to reach this theoretical power. We therefore introduce the following lemma.
Lemma 1. Given a graph with n nodes, a most powerful 1-WL-GNN takes up to ${ \mathcal { O } } ( n )$ message passing layers to discriminate all non-isomorphic nodes that 1-WL can discriminate.
Lemma 1 suggests that 1-WL-GNN needs a number of message passing layers of the same order as the number of nodes in the graph to reach its maximum discriminating power. However, practical GNNs usually only use a small number of message passing layers (such as 1 or 2) while still achieving good performance. This perhaps suggests that in practice, we do not necessarily need to find nodes/links that are exactly isomorphic to each other. Instead, nodes/links which are locally isomorphic could even more strongly suggest they should be classified into the same class.
Definition 10. (Local $h$ -isomorphism) $\forall ( S , \pmb { \mathsf { A } } , S ^ { \prime } , \pmb { \mathsf { A } } ^ { \prime } )$ , $( S , \pmb { \mathsf { A } } )$ and $( S ^ { \prime } , { \pmb { \mathsf { A } } } ^ { \prime } )$ are locally $h$ -isomorphic to each other if $\mathbf { \Sigma } ( S , \mathbf { A } _ { S } ^ { ( h ) } ) \simeq ( S ^ { \prime } , \mathbf { A ^ { \prime } } _ { S ^ { \prime } } ^ { ( h ) } )$ .
For two sets $S , S ^ { \prime }$ , if their tuples with their $h$ -hop enclosing subgraphs $( S , \pmb { \mathsf { A } } _ { S } ^ { ( h ) } )$ and $( S ^ { \prime } , \pmb { A } _ { S ^ { \prime } } ^ { \prime ( h ) } )$ are isomorphic, then we say they are locally -isomorphic. We argue that this is a more useful definition than isomorphism, because isomorphism requires the entire graph looks identical from two sets’ separate views, which is often too strict in practice. If we use the strict definition of isomorphism, we may fail to identify a lot of nodes/links that actually have very similar neighborhood structures. In fact, Babai & Kucera (1979) prove that at least $\left( n - \log n \right)$ nodes in almost all $n$ -node graphs are non-isomorphic to each other. Therefore, it is less meaningful to only assign the same representations to nodes/links when they are strictly isomorphic, and GNNs targeting on isomorphismdiscriminating tend to overfit. In comparison, local $h$ -isomorphism only cares about whether the $h$ -hop neighborhoods are isomorphic, which is more realistic and allows better generalizability.
With local $h$ -isomorphism, all our previous conclusions using the standard isomorphism definition still apply. For example, GAE with a node-most-expressive GNN can be used to identify locally $h$ -isomorphic nodes, but cannot discriminate locally $h$ -non-isomorphic links. And a node-mostexpressive GNN with the labeling trick (SEAL) can identify locally $h$ -isomorphic node sets, etc. To enable a GNN to focus on local $h$ -isomorphism-discriminating, all we need to do is to set a boundary between the $h$ -hop enclosing subgraph and the rest of the graph, and apply the GNN only to the extracted subgraph within the boundary (possibly use more than $h$ message passing layers).
Finally, we want to answer a question: in what chance node local $h$ -isomorphism also indicates link local $h$ -isomorphism? If in a graph, two nodes being locally $h$ -isomorphic almost always indicates their links with a third node are locally $h$ -isomorphic, then learning structural link representations with SEAL may no longer be necessary, and using GAE to learn structural node representations may already be enough. In other words, we are interested in how often examples like Figure 1 appear in graphs. Fortunately, we have the following theorem, which shows that there are enough links where only identifying locally $h$ -isomorphic nodes is not enough.
Theorem 2. In any graphs with n nodes and without node/edge features, if the degree of each node in the graph is between 1 and $\mathcal { O } ( \log ^ { \frac { 1 - \epsilon } { 2 h } } n )$ for any constant $\epsilon > 0$ , then there exists $\omega ( n ^ { 2 \epsilon } )$ many pairs of nodes $u , v$ such that u and $v$ are locally $h$ -isomorphic while there exists another node $w$ such that $( u , w )$ and $( v , w )$ are not locally $h$ -isomorphic.
Table 1: Statistics and evaluation metrics of OGB link prediction datasets.
<table><tr><td>Dataset</td><td>#Nodes</td><td>#Edges</td><td>Avg. node deg.</td><td>Density</td><td>Split ratio</td><td>Metric</td></tr><tr><td>ogbl-ppa</td><td>576,289</td><td>30,326,273</td><td>73.7</td><td>0.018%</td><td>70/20/10</td><td>Hits @100</td></tr><tr><td>ogbl-collab</td><td>235,868</td><td>1,285,465</td><td>8.2</td><td>0.0046%</td><td>92/4/4</td><td>Hits@50</td></tr><tr><td>ogbl-ddi</td><td>4,267</td><td>1,334,889</td><td>500.5</td><td>14.67%</td><td>80/10/10</td><td>Hits @20</td></tr><tr><td>ogbl-citation</td><td>2,927,963</td><td>30,561,187</td><td>20.7</td><td>0.00036%</td><td>98/1/1</td><td>MRR</td></tr></table>
# 6 RELATED WORK
There are emerging interests in studying the expressive power of graph neural networks recently. Xu et al. (2018) and Morris et al. (2019) first show that the discriminating power of GNNs performing neighbor aggregation is bounded by the 1-WL test. Many works have since been proposed to increase the power of GNNs by simulating higher-order WL tests (Morris et al., 2019; Maron et al., 2019; Chen et al., 2019). However, most previous works focus on improving GNN’s graph representation power. Little work has been done to analyze GNN’s node/link representation power. Srinivasan & Ribeiro (2020) first formally studied the difference between structural representations of nodes and links. Although showing that structural node representations alone cannot perform link prediction, their way of learning structural link representations is to give up GNNs and instead use Monte Carlo samples of node embeddings learned by network embedding methods. In this paper, we show that GNNs combined with a simple labeling trick can as well learn structural link representations, which reassures using GNNs for link prediction.
Many works have implicitly assumed that if a model can learn node embeddings well, then combining the pairwise node embeddings can also lead to good link representations (Grover & Leskovec, 2016; Kipf & Welling, 2016b; Hamilton et al., 2017). However, we argue in this paper that by considering the source and target nodes explicitly with the labeling trick, we can aggregate better link representations from node embeddings. Li et al. (2020) studied one particular form of the labeling trick based on distance, and proved that distance encoding can improve 1-WL-GNNs’ expressive power, enabling them to distinguish almost all $( S , \pmb { \mathsf { A } } )$ tuples sampled from r-regular graphs. In this paper, we do not focus on improving 1-WL-GNNs’ expressive power, but focus on how to enable a sufficiently expressive GNN to learn structural link representations in any graphs. We also provide a general definition of the labeling trick, and argue that a labeling trick as simple as only giving the source and target nodes 1 and other nodes 0 suffices to enable structural link representation learning.
# 7 EXPERIMENTS
In this section, we compare SEAL, GAE methods, and network embedding methods on the Open Graph Benchmark (OGB) (Hu et al., 2020) datasets. We use all the four link prediction datasets in OGB: ogbl-ppa, ogbl-collab, ogbl-ddi, and ogbl-citation. These datasets adopt realistic train/validation/test splitting methods, such as by resource cost in laboratory (ogbl-ppa), by time (ogbl-collab and ogbl-citation), and by drug target in the body (ogbl-ddi). They are also large-scale (up to 2.9M nodes and $3 0 . 6 \mathbf { M }$ edges), open-sourced, and have standard evaluation metrics, thus providing an ideal place to benchmark an algorithm’s realistic link prediction power. The evaluation metrics include Hits $@ K$ and MRR. Hits $@ K$ counts the ratio of positive edges ranked at the K-th place or above against all the negative edges. MRR (Mean Reciprocal Rank) computes the reciprocal rank of the true target node against 1,000 negative candidates, averaged over all the true source nodes. Both metrics are higher the better. The statistics are in Table 1.
Baselines. We consider the following representative models. Except SEAL, all models first compute node embeddings from the original graph and use the Hadamard product between pairwise node embeddings as link representations. The link representations are fed to an MLP for final prediction.
• MLP: Input node features are directly used as the node embeddings. • Node2vec (Perozzi et al., 2014; Grover & Leskovec, 2016): The node embeddings are the concatenation of node features and Node2vec embeddings. • MF: Use free-parameter node embeddings trained end-to-end as the node embeddings. • GraphSAGE (Hamilton et al., 2017): A GAE method with GraphSAGE as the GNN. • GCN (Kipf & Welling, 2016b): A GAE method with GCN as the GNN. • GCN+LRGA (Puny et al., 2020): A GAE method with LRGA-module-enhanced GCN. • SEAL (Zhang & Chen, 2018): Learn link representations from labeled subgraphs via a GNN.
Table 2: Results for ogbl-ppa, ogbl-collab, ogbl-ddi and ogbl-citation.
<table><tr><td></td><td colspan="2">ogbl-ppa Hits @100 (%)</td><td colspan="2">ogbl-collab Hits @50 (%)</td><td colspan="2">ogbl-ddi Hits @20 (%)</td><td colspan="2">ogbl-citation MRR (%)</td></tr><tr><td>Method</td><td>Validation</td><td>Test</td><td>Validation</td><td>Test</td><td>Validation</td><td>Test</td><td>Validation</td><td>Test</td></tr><tr><td>MLP</td><td>0.46±0.00</td><td>0.46±0.00</td><td>24.02±1.45</td><td>19.27±1.29</td><td></td><td></td><td>28.98±0.14</td><td>29.04±0.13</td></tr><tr><td>Node2vec</td><td>22.53±0.88</td><td>22.26±0.88</td><td>57.03±0.52</td><td>48.88±0.54</td><td>32.92±1.21</td><td>23.26±2.09</td><td>59.44±0.11</td><td>59.64±0.11</td></tr><tr><td>MF</td><td>32.28±4.28</td><td>32.29±0.94</td><td>48.96±0.29</td><td>38.86±0.29</td><td>33.70±2.64</td><td>13.68±4.75</td><td>53.11±5.65</td><td>53.16±5.65</td></tr><tr><td>GraphSAGE</td><td>17.24±2.64</td><td>16.55±2.40</td><td>56.88±0.77</td><td>48.10±0.81</td><td>62.62±0.37</td><td>53.90±4.74</td><td>82.17±0.86</td><td>82.28±0.84</td></tr><tr><td>GCN</td><td>18.45±1.40</td><td>18.67±1.32</td><td>52.63±1.15</td><td>44.75±1.07</td><td>55.50±2.08</td><td>37.07±5.07</td><td>84.49±1.08</td><td>84.56±1.10</td></tr><tr><td>GCN+LRGA</td><td>25.75±2.82</td><td>26.12±2.35</td><td>60.88±0.59</td><td>52.21±0.72</td><td>66.75±0.58</td><td>62.30±9.12</td><td>65.05±0.22</td><td>65.05±0.22</td></tr><tr><td>SEAL</td><td>51.25±2.52</td><td>48.80±3.16</td><td>63.89±0.49</td><td>53.71±0.47</td><td>28.49±2.69</td><td>30.56±3.86</td><td>85.09±0.88</td><td>85.27±0.91</td></tr></table>
All the GAE methods’ GNNs have 3 message passing layers with 256 hidden dimensions, with a tuned dropout ratio in $\{ 0 , 0 . 5 \}$ . The GNN in SEAL follows the original paper, which has 3 GCN layers with 32 hidden dimensions each, with a tuned subgraph hop $h$ in $\{ 1 , 2 \}$ . The ogbl-ddi graph contains no node features, so MLP is omitted, and the GAE methods here use free-parameter node embeddings as the GNN input node features and trained them together with the GNN parameters. For SEAL, the DRNL node labels are input to an embedding layer and then concatenated with the node features (if any) as the GNN input. More details are in Appendix D.
Results and discussion. We compare the baselines’ link prediction performance on ogbl-ppa, ogbl-collab, ogbl-ddi, and ogbl-citation. Among them, ogbl-ppa is a proteinprotein association graph where the task is to predict biologically meaningful associations between proteins. ogbl-collab is an author collaboration graph, where the task is to predict future collaborations. ogbl-ddi is a drug-drug interaction network, where each edge represents an interaction between drugs which indicates the join effect of taking the two drugs together is considerably different from their independent effects. ogbl-citation is a paper citation network, where the task is to predict missing citations. We present the ten-time average results in Table 2. The results show that SEAL achieves the best performance on 3 out of 4 datasets. It outperforms GAE and network embedding methods, sometimes by surprisingly large margins. For example, in the challenging ogbl-ppa graph, SEAL achieves an $\operatorname { H i t s } @ 1 0 0$ of 48.80, which is over $50 \%$ higher than the second-best baseline MF which only has an Hits $@ 1 0 0$ of 32.29. In comparison, all GAE methods achieve Hits $@ 1 0 0$ lower than 30. SEAL has $8 7 \% . 1 9 5 \%$ improvement over GAE methods in this dataset, which demonstrates the superiority of learning structural link representations over structural node representations for link prediction. SEAL also improves the state-of-the-art results for ogbl-collab and ogbl-citation in both validation and test performance.
Nevertheless, we observe that SEAL does not perform well on ogbl-ddi. ogbl-ddi is considerably denser than the other graphs. It only has 4,267 nodes, but has 1,334,889 edges, which results in an average node degree of 500.5 and density of $1 4 . 6 7 \%$ . Interestingly, although SEAL is able to beat MF and Node2vec, it falls behind GAE methods with free-parameter node embeddings. One possible reason is that the nodes in ogbl-ddi are so densely connected that a practical GNN with limited expressive power is hard to inductively learn any meaningful structural patterns. In comparison, the free-parameter node embeddings make GAE methods transductive and no longer focus on learning structural patterns, but focus on optimizing node embeddings. An interesting topic is thus how to improve structural representation learning on dense graphs, which we leave for future work.
# 8 CONCLUSIONS
In this paper, we have revisited the topic of using graph neural networks for link prediction. We reviewed two popular classes of methods, GAE and SEAL. We first showed that GAE methods cannot learn structural link representations by aggregating individually learned node embeddings. We further showed that combining with a simple labeling trick, a node-most-expressive GNN can learn structural link representations, and SEAL is such an example. Experiments on 4 large-scale OGB datasets demonstrate the superiority of learning structural link representations with SEAL.
# REFERENCES
Lada A Adamic and Eytan Adar. Friends and neighbors on the web. Social networks, 25(3):211–230, 2003.
Laszl ´ o Babai and Ludik Kucera. Canonical labelling of graphs in linear average time. In ´ 20th Annual Symposium on Foundations of Computer Science (sfcs 1979), pp. 39–46. IEEE, 1979.
Albert-Laszl ´ o Barab ´ asi and R ´ eka Albert. Emergence of scaling in random networks. ´ science, 286 (5439):509–512, 1999.
James Bennett, Stan Lanning, et al. The netflix prize. In Proceedings of KDD cup and workshop, volume 2007, pp. 35. New York, 2007.
Joan Bruna, Wojciech Zaremba, Arthur Szlam, and Yann LeCun. Spectral networks and locally connected networks on graphs. arXiv preprint arXiv:1312.6203, 2013.
Jin-Yi Cai, Martin Furer, and Neil Immerman. An optimal lower bound on the number of variables ¨ for graph identification. Combinatorica, 12(4):389–410, 1992.
Ines Chami, Zhitao Ying, Christopher Re, and Jure Leskovec. Hyperbolic graph convolutional neural ´ networks. In Advances in neural information processing systems, pp. 4868–4879, 2019.
Zhengdao Chen, Soledad Villar, Lei Chen, and Joan Bruna. On the equivalence between graph isomorphism testing and function approximation with gnns. In Advances in Neural Information Processing Systems, pp. 15894–15902, 2019.
Hanjun Dai, Bo Dai, and Le Song. Discriminative embeddings of latent variable models for structured data. In Proceedings of The 33rd International Conference on Machine Learning, pp. 2702– 2711, 2016.
David K Duvenaud, Dougal Maclaurin, Jorge Iparraguirre, Rafael Bombarell, Timothy Hirzel, Alan´ Aspuru-Guzik, and Ryan P Adams. Convolutional networks on graphs for learning molecular fingerprints. In Advances in neural information processing systems, pp. 2224–2232, 2015.
Matthias Fey and Jan Eric Lenssen. Fast graph representation learning with pytorch geometric. arXiv preprint arXiv:1903.02428, 2019.
Justin Gilmer, Samuel S Schoenholz, Patrick F Riley, Oriol Vinyals, and George E Dahl. Neural message passing for quantum chemistry. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pp. 1263–1272. JMLR. org, 2017.
Aditya Grover and Jure Leskovec. node2vec: Scalable feature learning for networks. In Proceedings of the 22nd ACM SIGKDD international conference on Knowledge discovery and data mining, pp. 855–864. ACM, 2016.
Will Hamilton, Zhitao Ying, and Jure Leskovec. Inductive representation learning on large graphs. In Advances in Neural Information Processing Systems, pp. 1025–1035, 2017.
Weihua Hu, Matthias Fey, Marinka Zitnik, Yuxiao Dong, Hongyu Ren, Bowen Liu, Michele Catasta, and Jure Leskovec. Open graph benchmark: Datasets for machine learning on graphs. arXiv preprint arXiv:2005.00687, 2020.
Leo Katz. A new status index derived from sociometric analysis. Psychometrika, 18(1):39–43, 1953.
Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. arXiv preprint arXiv:1609.02907, 2016a.
Thomas N Kipf and Max Welling. Variational graph auto-encoders. arXiv preprint arXiv:1611.07308, 2016b.
Pan Li, Yanbang Wang, Hongwei Wang, and Jure Leskovec. Distance encoding–design provably more powerful gnns for structural representation learning. arXiv preprint arXiv:2009.00142, 2020.
Yujia Li, Daniel Tarlow, Marc Brockschmidt, and Richard Zemel. Gated graph sequence neural networks. arXiv preprint arXiv:1511.05493, 2015.
David Liben-Nowell and Jon Kleinberg. The link-prediction problem for social networks. Journal of the American society for information science and technology, 58(7):1019–1031, 2007.
Haggai Maron, Heli Ben-Hamu, Hadar Serviansky, and Yaron Lipman. Provably powerful graph networks. In Advances in Neural Information Processing Systems, pp. 2156–2167, 2019.
Andriy Mnih and Ruslan R Salakhutdinov. Probabilistic matrix factorization. In Advances in neural information processing systems, pp. 1257–1264, 2008.
Christopher Morris, Martin Ritzert, Matthias Fey, William L Hamilton, Jan Eric Lenssen, Gaurav Rattan, and Martin Grohe. Weisfeiler and leman go neural: Higher-order graph neural networks. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pp. 4602–4609, 2019.
Maximilian Nickel, Kevin Murphy, Volker Tresp, and Evgeniy Gabrilovich. A review of relational machine learning for knowledge graphs. arXiv preprint arXiv:1503.00759, 2015.
Mathias Niepert, Mohamed Ahmed, and Konstantin Kutzkov. Learning convolutional neural networks for graphs. In Proceedings of the 33rd annual international conference on machine learning. ACM, 2016.
Bryan Perozzi, Rami Al-Rfou, and Steven Skiena. Deepwalk: Online learning of social representations. In Proceedings of the 20th ACM SIGKDD international conference on Knowledge discovery and data mining, pp. 701–710. ACM, 2014.
Omri Puny, Heli Ben-Hamu, and Yaron Lipman. From graph low-rank global attention to 2-fwl approximation. arXiv preprint arXiv:2006.07846, 2020.
Yanjun Qi, Ziv Bar-Joseph, and Judith Klein-Seetharaman. Evaluation of different biological data and computational classification methods for use in protein interaction prediction. Proteins: Structure, Function, and Bioinformatics, 63(3):490–500, 2006.
Leonardo FR Ribeiro, Pedro HP Saverese, and Daniel R Figueiredo. struc2vec: Learning node representations from structural identity. In Proceedings of the 23rd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pp. 385–394. ACM, 2017.
Franco Scarselli, Marco Gori, Ah Chung Tsoi, Markus Hagenbuchner, and Gabriele Monfardini. The graph neural network model. IEEE Transactions on Neural Networks, 20(1):61–80, 2009.
Balasubramaniam Srinivasan and Bruno Ribeiro. On the equivalence between positional node embeddings and structural graph representations. In International Conference on Learning Representations, 2020. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } }$ SJxzFySKwH.
Boris Weisfeiler and AA Lehman. A reduction of a graph to a canonical form and an algebra arising during this reduction. Nauchno-Technicheskaya Informatsia, 2(9):12–16, 1968.
Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural networks? arXiv preprint arXiv:1810.00826, 2018.
Jiaxuan You, Rex Ying, and Jure Leskovec. Position-aware graph neural networks. arXiv preprint arXiv:1906.04817, 2019.
Muhan Zhang and Yixin Chen. Link prediction based on graph neural networks. In Advances in Neural Information Processing Systems, pp. 5165–5175, 2018.
Muhan Zhang and Yixin Chen. Inductive matrix completion based on graph neural networks. In International Conference on Learning Representations, 2020. URL https://openreview. net/forum?id $=$ ByxxgCEYDS.
Muhan Zhang, Zhicheng Cui, Marion Neumann, and Yixin Chen. An end-to-end deep learning architecture for graph classification. In AAAI, pp. 4438–4445, 2018.
# A PROOF OF THEOREM 1
Recall Definition 5 defines:
$$\mathrm { G N N } ( S , \tilde { \mathbf { A } } ) = \mathrm { A G G } ( \{ \mathrm { G N N } ( i , \tilde { \mathbf { A } } ) | i \in S \} ) .$$
Thus, we only need to show $\mathrm { A G G } ( \{ \mathrm { G N N } ( i , \tilde { \mathbf { A } } ) | i \in S \} ) = \mathrm { A G G } ( \{ \mathrm { G N N } ( i , \tilde { \mathbf { A } } ^ { \prime } ) | i \in S ^ { \prime } \} )$ iff $( S , \pmb { \mathsf { A } } ) \simeq$ $( S ^ { \prime } , { \pmb { \mathsf { A } } } ^ { \prime } )$ .
To prove the first direction, we notice that with an injective AGG,
$$\begin{array} { r l } & { ~ \mathrm { A G G } ( \{ \mathrm { G N N } ( i , \tilde { \mathbf { A } } ) | i \in S \} ) = \mathrm { A G G } ( \{ \mathrm { G N N } ( i , \tilde { \mathbf { A } } ^ { \prime } ) | i \in S ^ { \prime } \} ) } \\ & { \implies \exists v _ { 1 } \in S , v _ { 2 } \in S ^ { \prime } , \mathrm { ~ s u c h ~ t h a t ~ G N N } ( v _ { 1 } , \tilde { \mathbf { A } } ) = \mathrm { G N N } ( v _ { 2 } , \tilde { \mathbf { A } } ^ { \prime } ) } \\ & { \implies ( v _ { 1 } , \tilde { \mathbf { A } } ) \simeq \left( v _ { 2 } , \tilde { \mathbf { A } } ^ { \prime } \right) \quad ( \mathrm { b e c a u s e ~ G N N ~ i s ~ n o d e - m o s t - e x p r e s s i v e } , } \\ & { \implies \exists \pi \in \Pi _ { n } , \mathrm { ~ s u c h ~ t h a t ~ } v _ { 1 } = \pi ( v _ { 2 } ) , \tilde { \mathbf { A } } = \pi ( \tilde { \mathbf { A } } ^ { \prime } ) . } \end{array}$$
Remember $\tilde { \pmb { A } }$ is constructed by stacking $\pmb { \mathsf { A } }$ and $\pmb { I } ^ { ( S ) }$ in the third dimension, where $\pmb { I } ^ { ( S ) }$ is a diagonal matrix satisfying: $\forall \pi \in \Pi _ { n }$ , (1) $\pmb { I } ^ { ( S ) } = \pi ( \pmb { I } ^ { ( S ^ { \prime } ) } ) \Rightarrow S = \pi ( S ^ { \prime } )$ , and (2) $S = \pi ( S ^ { \prime } ) , \pmb { \mathbb { A } } = \pi ( \pmb { \mathbb { A } } ^ { \prime } ) \Rightarrow$ $\pmb { I } ^ { ( S ) } = \pi ( \pmb { I } ^ { ( S ^ { \prime } ) } )$ . With $\tilde { \pmb { \mathsf { A } } } = \pi ( \tilde { \pmb { \mathsf { A } } } ^ { \prime } )$ , we have both
$$\mathbf { A } = \pi ( \mathbf { A } ^ { \prime } ) , I ^ { ( S ) } = \pi ( I ^ { ( S ^ { \prime } ) } ) .$$
Because $\pmb { I } ^ { ( S ) } = \pi ( \pmb { I } ^ { ( S ^ { \prime } ) } ) \Rightarrow S = \pi ( S ^ { \prime } )$ , we have
$$\begin{array} { r l } & { \quad \mathrm { A G G } ( \{ \mathrm { G N N } ( i , \tilde { \mathbf { A } } ) | i \in S \} ) = \mathrm { A G G } ( \{ \mathrm { G N N } ( i , \tilde { \mathbf { A } } ^ { \prime } ) | i \in S ^ { \prime } \} ) } \\ & { \implies \exists \pi \in \Pi _ { n } , \mathrm { ~ s u c h ~ t h a t ~ } S = \pi ( S ^ { \prime } ) , \mathbf { A } = \pi ( \mathbf { A } ^ { \prime } ) } \\ & { \implies ( S , \mathbf { A } ) \simeq ( S ^ { \prime } , \mathbf { A } ^ { \prime } ) . } \end{array}$$
Now we prove the second direction. We have:
$$\begin{array} { r l } & { \qquad ( S , \boldsymbol { \mathsf { A } } ) \simeq ( S ^ { \prime } , \boldsymbol { \mathsf { A } } ^ { \prime } ) } \\ & { \Longrightarrow \exists \pi \in \Pi _ { n } , \mathrm { ~ s u c h ~ t h a t } S = \pi ( S ^ { \prime } ) , \boldsymbol { \mathsf { A } } = \pi ( \boldsymbol { \mathsf { A } } ^ { \prime } ) } \\ & { \Longrightarrow \exists \pi \in \Pi _ { n } , \mathrm { ~ s u c h ~ t h a t } S = \pi ( S ^ { \prime } ) , I ^ { ( S ) } = \pi ( I ^ { ( S ^ { \prime } ) } ) , \boldsymbol { \mathsf { A } } = \pi ( \boldsymbol { \mathsf { A } } ^ { \prime } ) } \\ & { \Longrightarrow \exists \pi \in \Pi _ { n } , \mathrm { ~ s u c h ~ t h a t } S = \pi ( S ^ { \prime } ) , \tilde { \boldsymbol { \mathsf { A } } } = \pi ( \boldsymbol { \mathsf { A } } ^ { \prime } ) } \\ & { \Longrightarrow \forall v _ { 1 } \in S , v _ { 2 } \in S ^ { \prime } , v _ { 1 } = \pi ( v _ { 2 } ) , \mathrm { ~ w e ~ h a v e ~ G N N } ( v _ { 1 } , \tilde { \boldsymbol { \mathsf { A } } } ) = \mathrm { G N N } ( v _ { 2 } , \tilde { \boldsymbol { \mathsf { A } } } ^ { \prime } ) } \\ & { \Longrightarrow \boldsymbol { \mathsf { A } } \mathrm { G G } ( \{ \mathrm { G N N } ( v _ { 1 } , \tilde { \boldsymbol { \mathsf { A } } } ) | v _ { 1 } \in S \} ) = \boldsymbol { \mathsf { A } } \mathrm { G G } ( \{ \mathrm { G N N } ( v _ { 2 } , \tilde { \boldsymbol { \mathsf { A } } } ^ { \prime } ) | v _ { 2 } \in S ^ { \prime } \} ) , } \end{array}$$
which concludes the proof.
# B PROOF OF LEMMA 1
We first note that for a most powerful 1-WL-GNN, after a message passing layer, gives different embeddings to any two nodes that 1-WL gives different colors to after one iteration. So we only need to show how many iterations 1-WL takes to converge in any graph.
Note that if two nodes are given different colors by 1-WL at some iteration (they are discriminated by 1-WL), their colors are always different in any future iteration. And if at some iteration, all nodes’ colors are the same as their colors in the last iteration, then 1-WL will stop (1-WL fails to discriminate any more nodes and has converged). Therefore, before termination, 1-WL will increase its total number of colors by at least 1 after every iteration. Because there are at most $n$ different final colors given an $n$ -node graph, 1-WL takes at most $n - 1 = { \mathcal { O } } ( n )$ iterations before assigning all nodes different colors.
Now it suffices to show that there exists a $n$ -node graph that 1-WL takes ${ \mathcal { O } } ( n )$ iterations to converge. Suppose there is a linked list of $n$ nodes (a path). Then by simple calculation, it takes $\lceil n / 2 \rceil$ iterations for 1-WL to converge, which concludes the proof.
# C PROOF OF THEOREM 2
Our proof has two steps. First, we would like to show that there are $\omega ( n ^ { \epsilon } )$ nodes that are locally $h$ -isomorphic to each other. Then, we prove that among these nodes, there are at least $\omega ( n ^ { 2 \epsilon } )$ pairs of nodes such that there exists another node constructing locally $h$ non-isomorphic links with either of the two nodes in each node pair.
Step 1. Consider an arbitrary node $v$ and denote the subgraph induced by the nodes that are at most $h$ -hop away from $v$ as $G _ { v } ^ { ( h ) }$ (the $h$ -hop enclosing subgraph of $v$ ). As each node is with degree $d = \mathcal { O } ( \log ^ { \frac { 1 - \epsilon } { 2 h } } n )$ , then the number of nodes in $G _ { v } ^ { ( h ) }$ , denoted by $| V ( G _ { v } ^ { ( h ) } ) |$ , satisfies
$$| V ( G _ { v } ^ { ( h ) } ) | \leq \sum _ { i = 0 } ^ { h } d ^ { i } = \mathcal { O } ( d ^ { h } ) = \mathcal { O } ( \log ^ { \frac { 1 - \epsilon } { 2 } } n ) .$$
We set the max $K = \operatorname* { m a x } _ { v \in V } | V ( G _ { v } ^ { ( h ) } ) |$ and thus $K = \mathcal { O } ( \log ^ { \frac { 1 - \epsilon } { 2 } } n )$
Now we expand subgraphs $G _ { v } ^ { ( h ) }$ to $\bar { G } _ { v } ^ { ( h ) }$ by adding $K - | V ( G _ { v } ^ { ( h ) } ) |$ independent nodes for each node $v \in V$ . Then, all $\bar { G } _ { v } ^ { ( h ) }$ have the same number of nodes, which is $K$ , though they may not be connected graphs.
Next, we consider the number of non-isomorphic graphs over $K$ nodes. Actually, the number of nonisomorphic graph structures over $K$ nodes is bounded by $2 ^ { \binom { K } { 2 } } = \exp ( \mathcal { O } ( \log ^ { 1 - \epsilon } n ) ) = o ( n ^ { 1 - \epsilon } )$ .
Therefore, due to the pigeonhole principle, there exist $n / o ( n ^ { 1 - \epsilon } ) = \omega ( n ^ { \epsilon } )$ many nodes $v$ whose $\bar { G } _ { v } ^ { ( h ) }$ are isomorphic to each other. Denote the set of these nodes as $V _ { i s o }$ , which consist of nodes that are all locally $h$ -isomorphic to each other. Next, we focus on looking for other nodes to form locally $h$ -non-isomorphic links with nodes $V _ { i s o }$ .
Step 2. Let us partition $V _ { i s o } = \cup _ { i = 1 } ^ { q } V _ { i }$ so that for all nodes in $V _ { i }$ , they share the same first-hop neighbor sets. Then, consider any pair of nodes $u , v$ such that $u , v$ are from different $V _ { i }$ ’s. Then, we may pick one $u$ ’s first-hop neighbor $w$ that is not $v$ ’s first-hop neighbor. We know such $w$ exists because of the definition of $V _ { i }$ . As $w$ is $u$ ’s first-hop neighbor and is not $v$ ’s first-hop neighbor, $( u , w )$ and $( v , w )$ are not locally 1-isomorphic and thus not locally $h$ -isomorphic. Therefore, based on this partition, we know the number of node pairs $u , v$ such that there exists another node $w$ making $( u , w )$ and $( v , w )$ not locally $h$ -isomorphic is at least
$$Y \geq \prod _ { \substack { i , j = 1 , i \neq j } } ^ { q } | V _ { i } | | V _ { j } | = \frac { 1 } { 2 } \left[ ( \sum _ { i = 1 } ^ { q } | V _ { i } | ) ^ { 2 } - \sum _ { i = 1 } ^ { q } | V _ { i } | ^ { 2 } \right] .$$
Because of the definitions of the partition, $\begin{array} { r } { \sum _ { i = 1 } ^ { q } | V _ { i } | = | V _ { i s o } | = \omega ( n ^ { \epsilon } ) } \end{array}$ and the size of each $V _ { i }$ satisfies
$$1 \leq | V _ { i } | \leq d _ { w } = \mathcal { O } ( \log ^ { \frac { 1 - \epsilon } { 2 h } } n ) ,$$
where $w$ is one of the common first-hop neighbors shared by all nodes in $V _ { i }$ and $d _ { w }$ is its degree.
By plugging in the range of $| V _ { i } |$ , Eq.12 leads to
$$Y \ge \frac { 1 } { 2 } ( \omega ( n ^ { 2 \epsilon } ) - \omega ( n ^ { \epsilon } ) \mathcal { O } ( \log ^ { \frac { 1 - \epsilon } { 2 h } } n ) ) = \omega ( n ^ { 2 \epsilon } ) ,$$
which concludes the proof.
# D MORE DETAILS ABOUT BASELINES
We include baselines achieving top performances on the OGB Link Prediction Leaderboard1. All the methods have their open-sourced code and paper available from the leaderboard. We adopt the numbers published on the leaderboard if available, otherwise we run the method ourselves using the open-sourced code. For the baseline GCN+LRGA, its default hyperparameters result in out of GPU memory on ogbl-citation, even we use an NVIDIA V100 GPU with 32GB memory. Thus, we have to reduce its hidden dimension to 16 and matrix rank to 10. It is possible that it can achieve better performance with a larger hidden dimension and larger matrix rank using a GPU with a larger memory. Despite this, GCN+LRGA generally performs second to best among all methods.
We implemented SEAL using the PyTorch Geometric (Fey & Lenssen, 2019) package. Following the original paper (Zhang & Chen, 2018), we adopt a SortPooling layer (Zhang et al., 2018) after the GCN layers to readout the subgraph. For all datasets, SEAL only used a fixed $1 \%$ to $10 \%$ of all the available training edges as the positive training links, and sampled an equal number of negative training links randomly. SEAL showed excellent performance even without using the full training data, which indicates its strong inductive learning ability. Due to using different labeled subgraphs for different links, SEAL generally has longer running time than GAE methods. On the largest ogbl-citation graph, SEAL takes about 7 hours to finishing its training of 10 epochs, and takes another 28 hours to evaluate the validation and test MRR each. For ogbl-ppa, SEAL takes about 20 hours to train for 20 epochs and takes about 4 hours for evaluation. The other two datasets are finished within hours. We will release all our code for reproducing the experimental results.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396# LEARNING REPRESENTATIONS AND GENERATIVE MODELS FOR 3D POINT CLOUDS
Panos Achlioptas ,\* Department of Computer Science Stanford University, USA
Olga Diamanti Department of Computer Science Stanford University, USA
Ioannis Mitliagkas Department of Computer Science and Operations Research University of Montréal, Canada
Leonidas Guibas Department of Computer Science Stanford University, USA
# ABSTRACT
Three-dimensional geometric data offer an excellent domain for studying representation learning and generative modeling. In this paper, we look at geometric data represented as point clouds. We introduce a deep autoencoder (AE) network with state-of-the-art reconstruction quality and generalization ability. The learned representations outperform existing methods on 3D recognition tasks and enable basic shape editing via simple algebraic manipulations, such as semantic part editing, shape analogies and shape interpolation. We perform a thorough study of different generative models including: GANs operating on the raw point clouds, significantly improved GANs trained in the fixed latent space of our AEs and, Gaussian mixture models (GMM). For our quantitative evaluation we propose measures of sample fidelity and diversity based on matchings between sets of point clouds. Interestingly, our careful evaluation of generalization, fidelity and diversity reveals that GMMs trained in the latent space of our AEs produce the best results.
# 1 INTRODUCTION
Three-dimensional (3D) representations of real-life objects are a core tool for vision, robotics, medicine, augmented and virtual reality applications. Recent encodings like view-based projections, volumetric grids and graphs, complement more traditional shape representations such as 3D meshes, level set functions, curve-based CAD models and constructive solid geometry (Botsch et al., 2010). These encodings, while effective in their respective domains (e.g. acquisition or rendering), are often poor in semantics. For example, naïvely interpolating between two different cars in a view-based representation does not yield a representation of an “intermediate” car. Furthermore, these raw, high-dimensional representations are typically not well suited for the design of generative models via classic statistical methods. As such, editing and designing new objects with such representations frequently involves the construction and manipulation of complex, object-specific parametric models that link the semantics to the representation. This may require significant expertise and effort.
Recent advances in deep learning bring the promise of a data-driven approach. In domains where data is plentiful, deep learning tools have eliminated the need for hand-crafting features and models. Deep learning architectures like autoencoders (AEs) (Rumelhart et al., 1988; Kingma & Welling, 2013) and Generative Adversarial Networks (GANs) (Goodfellow et al., 2014; Radford et al., 2015; Denton et al., 2015; Che et al., 2016) are successful at learning complex data representations and generating realistic samples from complex underlying distributions. Recently, deep learning architectures for view-based projections (Su et al., 2015; Wei et al., 2016; Kalogerakis et al., 2016), volumetric grids (Qi et al., 2016b; Wu et al., 2015; Hegde & Zadeh, 2016) and graphs (Bruna et al., 2013; Henaff et al., 2015; Defferrard et al., 2016; Yi et al., 2016b) have appeared in the 3D machine learning literature.
In this paper we focus on point clouds, a relatively unexplored 3D modality. Point clouds provide a homogeneous, expressive and compact representation of surface geometry, easily amenable to geometric operations. These properties make them attractive from a learning point of view. In addition, they come up as the output of common range-scanning acquisition pipelines used in devices like the Kinect and iPhone’s recent face identification feature. Only a handful of deep architectures for 3D point clouds exist in the literature: PointNet (Qi et al., 2016a; 2017) successfully tackled classification and segmentation tasks; Kalogerakis et al. (2016) used point-clouds as an intermediate step in their pipeline; Fan et al. (2016) used pointclouds as the underlying representation to extract 3D information from 2D images. We provide the first results that use deep architectures with the focus of learning representations and generative models for point clouds.
Generative models have garnered increased attention recently in the deep learning community with the introduction of GANs (Goodfellow et al., 2014). An issue with GAN-based generative pipelines is that training them is notoriously hard and unstable (Salimans et al., 2016). More importantly, there is no universally accepted way to evaluate generative models. In evaluating generative models one is interested in both fidelity, i.e. how much the generated points resemble the actual data, and coverage, i.e. what fraction of the data distribution a generated sample represents. The latter is especially important given the tendency of certain GANs to exhibit mode collapse. We provide simple methods to deal with both issues (training and evaluation) in our target domain. Our specific contributions are:
• We design a new AE architecture—inspired by recent architectures used for classification (Qi et al., 2016a)—that is capable of learning compact representations of point clouds with excellent reconstruction quality even on unseen samples. The learned representations are (i) good for classification via simple methods (SVM), improving on the state of the art (Wu et al., 2016); (ii) suitable for meaningful interpolations and semantic operations. We create the first set of generative models which (i) can generate point clouds measurably similar to the training data and held-out test data; (ii) provide good coverage of the training and test dataset. We argue that jointly learning the representation and training the GAN is unnecessary for our modality. We propose a workflow that first learns a representation by training an AE with a compact bottleneck layer, then trains a plain GAN in that fixed latent representation. Intuitively, training a GAN inside a compact, low-dimensional representation is easier. We point to theory (Arjovsky & Bottou, 2017) that supports this idea, and verify it empirically. Latent GANs are much easier to train than monolithic (raw) GANs and achieve superior reconstruction with much better coverage. Somewhat surprisingly, GMMs trained in the latent space of fixed AEs achieve the best performance across the board. We show that multi-class GANs work almost on par with dedicated GANs trained per-objectcategory, as long as they are trained in the latent space. To support our qualitative evaluation, we perform a careful study of various old and new metrics, in terms of their applicability (i) as objectives for learning good representations; (ii) for the evaluation of generated samples. We find that a commonly used point cloud metric, Chamfer distance, fails to discriminate certain pathological cases from good examples. We also propose fidelity and coverage metrics for our generative models, based on an optimal matching between two different samples, e.g. a set of point clouds generated by the model and a held-out test set.
The rest of this paper is organized as follows: Section 2 outlines the necessary background and building blocks for our work and introduces our evaluation metrics. Section 3 introduces our models for latent representations and generation of point clouds. In Section 4, we evaluate all of our models both quantitatively and qualitatively, and analyze their behaviour. Further results and evaluation can be found in the appendix. The code for all our models is publicly available 1.
# 2 BACKGROUND
Autoencoders. Autoencoders (AE - inset) are deep architectures that aim to reproduce their input. They are especially useful, when they contain a narrow bottleneck layer between input and output. Upon successful training, the bottleneck layer corresponds to a lowdimensional representation, a code for the dataset. The Encoder (E) learns to compress a data point $_ { \textbf { \em x } }$ into its latent representation, $_ z$ . The Decoder (D) can then reproduce $_ { \textbf { \em x } }$ from its encoded version $_ { z }$ .

Generative Adversarial Networks. GANs are state-of-the-art generative models. The basic architecture (inset) is based on a adversarial game between a generator (G) and a discriminator (D). The generator aims to synthesize samples that look indistinguishable from real data (drawn from $\begin{array} { r } { \mathbf { \boldsymbol { x } } \sim p _ { \mathrm { d a t a } } , } \end{array}$ ) by passing a randomly drawn sample $z \sim p _ { z }$ through the generator function $G$ . The discriminator tries to tell synthesized from real samples. The most commonly used losses for the discriminator and generator networks are:

$$\begin{array} { r c l } { { J ^ { ( D ) } ( { \pmb \theta } ^ { ( D ) } , { \pmb \theta } ^ { ( G ) } ) } } & { { = } } & { { - \mathbb { E } _ { { \pmb x } \sim p _ { \mathrm { d a t a } } } \log D ( { \pmb x } ) - \mathbb { E } _ { { \pmb z } \sim p _ { z } } \log \left( 1 - D \left( G ( { \pmb z } ) \right) \right) , } } \\ { { J ^ { ( G ) } ( { \pmb \theta } ^ { ( D ) } , { \pmb \theta } ^ { ( G ) } ) } } & { { = } } & { { - \mathbb { E } _ { { \pmb z } \sim p _ { z } } \log D ( G ( { \pmb z } ) ) , } } \end{array}$$
where $\pmb \theta ^ { ( D ) } , \pmb \theta ^ { ( G ) }$ are the parameters for the discriminator and the generator network respectively. In addition to the classical GAN formulation, we also use the improved Wasserstein GAN (Gulrajani et al., 2017), which has shown improved stability during training.
Challenges specific to point cloud geometry. Point clouds as an input modality present a unique set of challenges when building a network architecture. As an example, the convolution operator – now ubiquitous in image-processing pipelines – requires the signal (in our case, geometry) to be defined on top of an underlying grid-like structure. Such a structure is not available in raw point clouds, which renders them significantly more difficult to encode than e.g. images or voxel grids. Recent classification work on point clouds (PointNet – Qi et al. (2016a)) bypasses this issue by circumventing 2D convolutions. Another issue with point clouds as a representation is that they are unordered - any permutation of a point set still describes the same shape. This complicates comparisons between two point sets, typically needed to define a loss function. This unorderedness of point clouds also creates the need for making the encoded feature permutation invariant.
Point-set distances. Two permutation-invariant metrics for comparing unordered point sets have been proposed in the literature (Fan et al., 2016). On the one hand, the Earth Mover’s distance (EMD) (Rubner et al., 2000) is the solution of a transportation problem which attempts to transform one set to the other. For two equally sized subsets $S _ { 1 } \subseteq \bar { R ^ { 3 } } , S _ { 2 } \subseteq R ^ { 3 }$ , their EMD is defined by $d _ { E M D } ( S _ { 1 } , S _ { 2 } ) \ = \ \operatorname* { m i n } _ { \phi : S _ { 1 } \to S _ { 2 } } \sum _ { x \in S _ { 1 } } \| x - \phi ( x ) \| _ { 2 }$ where $\phi$ is a bijection. Interpreted as a loss, EMD is differentiable almost everywhere. On the other hand, the Chamfer (pseudo)-distance (CD) measures the squared distance between each point in one set to its nearest neighbor in the other set: $d _ { C H } ( S _ { 1 } , S _ { 2 } ) = \sum _ { x \in S _ { 1 } } \operatorname* { m i n } _ { y \in S _ { 2 } } \| x - y \| _ { 2 } ^ { 2 } + \sum _ { y \in S _ { 2 } } \operatorname* { m i n } _ { x \in S _ { 1 } } \| x - y \| _ { 2 } ^ { 2 } .$ . It is still differentiable but more computationally efficient.
Evaluation Metrics for representations and generative models. In the remainder of the paper, we will frequently need to compare a given set (distribution) of points clouds, whether reconstructed or synthesized, to its ground truth counterpart. For example, one might want to assess the quality of a representation model, in terms of how well it matches the training set or a held-out test set. Such a comparison might be done to evaluate the faithfulness and/or diversity of a generative model, and measure potential mode-collapse. To measure how well a point-cloud distribution $A$ matches a ground truth distribution $G$ , we use the following metrics:
Coverage. For each point-cloud in $A$ we find its closest neighbor in $G$ ; closeness can be computed using either CD or EMD, thus yielding two different metrics, COV-CD and COV-EMD. Coverage is measured as the fraction of the point-clouds in $G$ that were matched to point-clouds in $A$ . A high coverage score typically indicates that most of $G$ is roughly represented within $A$ .
Minimum Matching Distance (MMD). Coverage is not representative of the fidelity of $A$ with respect to $G$ as matched elements need not be close. To capture fidelity, we match every point cloud of $G$ to the one in $A$ with the minimum distance (MMD) and report the average of distances in the matching. Either of the structural distances can be used, yielding MMD-CD and MMD-EMD. MMD measures the distances in the pairwise matchings, so it correlates with how realistic the elements of $A$ are.
Jensen-Shannon Divergence (JSD). The Jensen-Shannon divergence between marginal distributions defined over the euclidean 3D space. Assuming point cloud data that are axis-aligned and a canonical voxel grid in the ambient space; one can measure the degree to which point clouds of $A$ tend to occupy similar locations as those of $B$ . To that end, we count the number of points lying within each voxel across all point clouds of $A$ , and correspondingly for $B$ and report the JSD between the obtained empirical distributions.
# 3 REPRESENTATION AND GENERATIVE MODELS
In this section we describe the architectures of our representation and generative models for point clouds, starting from our autoencoder design. Later, we introduce a GAN architecture tailored to point-cloud data, followed by a more efficient pipeline that first learns an AE and the trains a much smaller GAN in the learned latent space, and a simpler generative model based on Gaussian Mixtures.
# 3.1 LEARNING REPRESENTATIONS OF 3D POINT CLOUDS
The input to our AE network is a point cloud with 2048 points $( 2 0 4 8 \times 3$ matrix), representing a 3D shape. The encoder architecture follows the principle of Qi et al. (2016a): 1-D convolutional layers with kernel size 1 and increasing number of features, ending with a "symmetric" function. This approach encodes every point independently and uses a permutation-invariant (symmetric) function to make a joint representation. In our implementation we use 5 1-D conv layers, each followed by a ReLU and a batch-norm layer. The output of the last 1-D conv layer is passed to a feature-wise maximum to produce a $k$ -dimensional vector which is the basis for our latent space. The decoder transforms the latent vector with 3 fully connected layers, the first two having ReLUs, to produce a $2 0 4 8 \times 3$ output. For a permutation invariant objective, we explore both the efficient EMD-distance approximation (Fan et al., 2016) and the Chamfer-Distance as our structural losses; this yields two distinct AE models, referred to as AE-EMD and AE-CD (detailed architecture parameters can be found in Appendix A). To determine an appropriate size for the latent-space, we constructed 8 (otherwise architecturally identical) AEs with bottleneck sizes $k \in \{ 4 , 8 \ldots , 5 1 2 \}$ and trained them with point-clouds of a single object class, under the two losses. We repeated this procedure with pseudo-random weight initializations three times (see appendix, Fig. 15) and found that $k = 1 2 8$ had the best generalization error on the test data, while achieving minimal reconstruction error on the train split.
# 3.2 GENERATIVE MODELS FOR POINT CLOUDS
Raw point cloud GAN (r-GAN). The first version of our generative model operates directly on the raw $2 0 4 8 \times 3$ point set input – to the best of our knowledge this work is the first to present a GAN for point clouds. The architecture of the discriminator is identical to the AE (modulo the filter-sizes and the number of neurons), without any batch-norm and with leaky ReLUs (Maas et al., 2013) instead or ReLUs. The output of the last fully connected layer is fed into a sigmoid neuron. The generator takes as input a 128-dimensional noise vector and maps it to a $2 0 4 8 \times 3$ output by 5 FC-ReLU layers.
Latent-space GAN (l-GAN). In our l-GAN, instead of operating on the raw point cloud input, we pass the data through our pre-trained autoencoder, trained separately for each object class with the EMD (or Chamfer) loss function. Both the generator and the discriminator of the GAN then operate on the 128- dimensional bottleneck variable of the AE. Finally, once the GAN training is over, the output of the generator is decoded to a point cloud via the AE decoder. The architecture for the l-GAN is significantly simpler than the one of the r-GAN. We found that very shallow designs for both the generator and discriminator (in our case, one hidden FC layer for the generator and two FC for the discriminator) are sufficient to produce realistic results.

Gaussian Mixture Model. In addition to the l-GANs, we also train a family of Gaussian Mixture Models (GMMs) on the latent spaces learned by our AEs. We fitted GMMs with varying numbers of Gaussian components, and experimented with both diagonal and full covariance matrices for the Gaussians. The GMMs can be turned into point-cloud generators by first sampling the latent-space from the GMM distribution and accordingly using the AE’s decoder, similarly to the l-GANs.
 Figure 1: Reconstructions of unseen shapes from the test split of the input data. The leftmost image of each pair shows the ground truth shape, the rightmost the shape produced after encoding and decoding using our class-specific AEs.
# 4 EVALUATION AND RESULTS
Our source for shapes is the ShapeNet repository (Chang et al., 2015); we pre-center all shapes into a sphere of diameter 1. Unless otherwise stated, we train specific per-class models, and split the models in each class into training/testing/validation set using a $8 5 \% - 5 \% - 1 0 \%$ split.
# 4.1 EVALUATING THE LATENT REPRESENTATION
Classification. A common technique for evaluating the quality of unsupervised representation learning algorithms is to apply them as feature extractors on supervised datasets and evaluate the performance of linear models fitted on top of these features. We use this technique to evaluate the performance of the latent “features” computed by our AE. For this experiment to be meaningful, the AE was trained across all different shape categories: we used 57,000 models from ShapeNet from 55 categories of man-made objects. Exclusively for this experiment, we used a bigger bottleneck of 512, increased the number of neurons and applied batch-norm to the decoder as well. To obtain features for an input 3D shape, we feed forward to the network its point-cloud and extract the 512-dimensional bottleneck layer vector. This feature is then processed by a linear classification SVM trained on the de-facto 3D classification benchmark of ModelNet (Wu et al., 2015). Table 1 shows comparative results. Note that previous state of the art (Wu et al., 2016) uses several layers of a GAN to derive a 7168-long feature; our 512-dimensional feature is more intuitive and parsimonious.
<table><tr><td>Dataset</td><td>SPH[1]</td><td>LFD[2]</td><td>T-L-Net[3]</td><td>VConv-DAE[4]</td><td>3D-GAN[5]</td><td>ours - EMD</td><td>ours - CD</td></tr><tr><td>MN10</td><td>79.8%</td><td>79.9%</td><td>-</td><td>80.5%</td><td>91.0%</td><td>95.4%</td><td>95.4%</td></tr><tr><td>MN40</td><td>68.2%</td><td>75.5%</td><td>74.4%</td><td>75.5%</td><td>83.3%</td><td>84.0%</td><td>84.5%</td></tr></table>
Table 1: Classification performance on ModelNet40 and ModelNet10. All methods train a linear SVM with features derived in an unsupervised manner. Comparing to [1] Kazhdan et al. (2003), [2] Chen et al. (2003), [3] Girdhar et al. (2016a), [4] Sharma et al. (2016), [5] Wu et al. (2016).
The decoupling of latent representation from generation allows flexibly choosing the AE loss, which can effect the learned feature. On ModelNet10, which includes primarily larger objects and fewer categories than ModelNet40, the EMD and CD losses perform equivalently. On the other hand, when the variation within the collection increases, CD produces better results. This is perhaps due to its more local and less smooth nature, which allows it to understand rough edges and some high frequency geometric details. Finally, note that since our AEs were not trained on ModelNet, this experiment also demonstrates the domain-robustness of our learned features.
Qualitative Evaluation. To visually assess the quality of the learned representation, we show some reconstruction results in Fig. 1. Here, we use our AEs to encode samples from the test split of the ground truth dataset (the leftmost of each pair of images) and then decode them and compare them visually to the input (the rightmost image). These results show the ability of our learned representation to generalize to unseen shapes. In addition to reconstruction, our learned latent representation enables a number of interesting shape editing applications, including shape interpolations (Fig. 2), part editing and shape analogies. More results are showcased in Appendix F.
Generalization Ability. Our AEs are able to reconstruct unseen shapes; this is highlighted not only in the results of Figure 1, but also in quantitative measurements of the fidelity and coverage of the reconstructed ground truth datasets (see appendix, Table 6) and by the comparable reconstruction quality on the training vs. test splits (see appendix, Figure 15).
 Figure 2: Interpolating between different point clouds, using our latent space representation.
# 4.2 EVALUATING THE GENERATIVE MODELS
We train and compare a total of five generative models on the data distribution of point-clouds of the chair category. We begin by establishing the two AEs with the 128-dimensional bottleneck, trained with the CD or EMD loss respectively – referred to as AE-CD and AE-EMD. Both AEs were stopped at the epoch at which the average reconstruction error with respect to our validation dataset was minimized. We train an l-GAN in each of the AE-CD and AE-EMD latent spaces. In the space associated only with the AE-EMD we train a further two models: an identical (architecture-wise) l-GAN that utilizes the Wasserstein objective with gradient-penalty (Gulrajani et al., 2017), and a family of GMMs. Lastly, we also train an r-GAN directly on the point cloud data.
Model Selection. All GANs are trained for maximally 2000 epochs; for each GAN, we select one of its training epochs to obtain the “final” model, based on how well the synthetic results match the ground-truth distribution. Specifically, at a given epoch, we use the GAN to generate a set of synthetic point clouds, and measure the distance between this set and the validation set (Section 2). We avoid measuring this distance using MMD-EMD, given the high computational cost of EMD. Instead, we use either the JSD or MMD-CD metrics to compare the synthetic dataset to the validation dataset. To further reduce the computational cost of model selection, we only check every 100 epochs (50 for r-GAN). The epochs at which the various models were selected using the JSD criterion are shown in Table 3. Using the same criterion, we also select the number and covariance type of Gaussian components for the GMM, and obtain the optimal value of 32 components. GMMs performed much better with full (as opposed to diagonal) covariance matrices, suggesting strong correlations between the latent dimensions (see appendix Fig. 17). When using MMD-CD as the selection criterion, we obtain models of similar quality and at similar stopping epochs (see appendix, Table 13); the optimal number of Gaussians in this case was 40.
Table 2: Evaluating 5 generators on train-split of chair dataset on epochs/models selected via minimal JSD on the validation-split. We also compare against the volumetric approach of Wu et al. (2016). Note that the average classification score attained by the ground-truth point clouds was $8 4 . 7 \%$ .
<table><tr><td>Metric</td><td>r-GAN</td><td>Wu et al. (2016)</td><td>1-GAN (AE-CD)</td><td>1-GAN (AE-EMD)</td><td>1-WGAN (AE-EMD)</td><td>GMM (AE-EMD)</td></tr><tr><td>JSD</td><td>0.1660</td><td>0.1705</td><td>0.0372</td><td>0.0188</td><td>0.0077</td><td>0.0048</td></tr><tr><td>Classification</td><td>84.10</td><td>87.00</td><td>96.10</td><td>94.53</td><td>89.35</td><td>87.40</td></tr><tr><td>MMD-CD</td><td>0.0017</td><td>0.0042</td><td>0.0015</td><td>0.0018</td><td>0.0015</td><td>0.0014</td></tr></table>
Quantitative Evaluation. Upon selection of the models, we compare them with respect to their capacity to generate synthetic samples. In two different sets of experiments, we measure how well the distribution of the generated samples resembles both the train and test splits of the ground truth distribution, by using our models to generate a set of synthetic point clouds and employing the metrics from Section 2 to compare against the train or test set distributions respectively. The train split results are reported in Table 2. We also show the average classification probability for those samples being recognized as a chair using the PointNet classifier (Qi et al., 2016a), which is state of the art for classifying point clouds. A similar experiment is ran to measure how well the synthetic samples match the test split dataset; here, we repeat the experiment with three pseudo-random seeds and report the average measurements in Table 3, for various comparison metrics. Perhaps surprisingly, training a simple Gaussian mixture model in the latent space of the EMD-based AE yields the best results in terms of both fidelity and coverage. Furthermore, GMMs are particularly easy to train. Additionally, the achieved fidelity and coverage are very close to the reconstruction baseline, namely, the lower bounds for the JSD and MMD achieved by the AE on which the generative models operate (see appendix, Table 6). For example, the AE-EMD achieved an MMD-EMD of 0.05 with respect to the ground truth training data , which is comparable with the MMD-EMD value of 0.06 achieved by the GMMs with respect to the test data. Finally, by comparing Table 2 and Table 3 we can again establish the generalization ability of our models, since their performance for the training vs. testing splits is comparable. This is highlighted in more detail in Fig. 16 in the appendix.
Table 3: Evaluating 5 generators on test-split of chair dataset on epochs/models selected via minimal JSD on the validation-split. The reported scores are averages of 3 pseudo-random repetitions. GMM32-F stands for a GMM with 32 Gaussian components with full covariances.
<table><tr><td>Method</td><td>Epoch</td><td>JSD</td><td>MMD-CD</td><td>MMD-EMD</td><td>COV-EMD</td><td>COV-CD</td></tr><tr><td>r-GAN</td><td>1700</td><td>0.1764</td><td>0.0020</td><td>0.1230</td><td>19.0</td><td>52.3</td></tr><tr><td>1-GAN (AE-CD)</td><td>300</td><td>0.0486</td><td>0.0020</td><td>0.0796</td><td>32.2</td><td>59.4</td></tr><tr><td>1-GAN (AE-EMD)</td><td>100</td><td>0.0308</td><td>0.0023</td><td>0.0697</td><td>57.1</td><td>59.3</td></tr><tr><td>1-WGAN (AE-EMD)</td><td>1800</td><td>0.0227</td><td>0.0019</td><td>0.0660</td><td>66.9</td><td>67.6</td></tr><tr><td>GMM-32-F (AE-EMD)</td><td>-</td><td>0.0202</td><td>0.0018</td><td>0.0651</td><td>67.4</td><td>68.9</td></tr></table>
Note: The number of synthetic point clouds we generate for the train split experiment is equal to the size of the train dataset. For the test split experiment, as well as for the validation split comparisons done for model selection, we generate synthetic datasets that are three times bigger than the ground truth dataset (the test resp. validation set); this is possible due to the relatively small size of the test resp. validation sets, and helps reduce sampling bias. This is only necessary when measuring MMD or Coverage statistics.
Fidelity of metrics. In Table 3 we note that the MMD-CD distance to the test set appears to be relatively small for the r-GANs. This seeming advantage of the r-GANs is counter to what a qualitative inspection of the results yields. We attribute this effect to the inadequacy of the chamfer distance to distinguish pathological cases. Some examples of such behaviour are showcased in Fig. 3. We show two triplets of images: in each triplet, an r-GAN and an l-GAN is used to generate a synthetic set of point clouds; the left triplet shows an l-GAN on the AE-CD and the right an l-GAN on the AE-EMD. For a given ground truth point cloud from the test set (leftmost image of each triplet), we find its nearest neighbor in each synthetic set under the chamfer distance - the middle image in each triplet shows the nearest neighbor in the synthetic results of the r-GAN and the right most image the nearest neighbor in the l-GAN set. We report the distances between these nearest neighbors and the ground truth using both CD and EMD (in-image numbers). Note that the CD values miss the fact that the r-GAN results are visibly of lesser quality. The underlying reason appears to be that r-GANs tend to generate clouds with many points concentrated in the areas that are most likely to be occupied in the underlying shape class (e.g. the seat of chairs in the figure). This implies that one of the two terms in the CD –namely, the one going from the synthetic point cloud to the ground truth– is likely to be very small for r-GAN results. The “blindness” of the CD metric to only partial matches between shapes has the additional interesting side-effect that the CD-based coverage metric is consistently bigger than that reported by EMD, as noted in Table 3. Instead, the EMD distance promotes a one-to-one mapping and thus correlates more strongly to visual quality; this means that it heavily penalizes the r-GAN result both in terms of MMD and coverage.
Training trends. We performed extensive measurements during training of our models, to understand their behavior during training, as shown in Fig. 4. On the left, we plot the JSD distance between the ground truth test set and synthetic datasets generated by the various models at various epochs of training. On the right, we also plot the EMD-based MMD and Coverage between the same two sets, where larger marker symbols denote a higher epoch. In general, r-GAN struggles to provide good coverage of the test set no matter the metric used; which alludes to the well-established fact that end-to-end GANs are generally difficult to train. The l-GAN (AE-CD) performs better in terms of fidelity with much fewer epochs as measured by JSD/MMD-EMD, but its coverage remains low. We attribute this to the CD promoting unnatural topologies – cf. Fig. 3 that visually shows this phenomenon. Switching to an EMD-based AE for the representation and otherwise using the same latent GAN architecture (l-GAN, AE-EMD), yields a dramatic improvement in coverage and fidelity. Both l-GANs though suffer from the known issue of mode collapse: Half-way through training, first coverage starts dropping with fidelity still at good levels, which implies that they are overfitting a small subset of the data. Later on, this is followed by a more catastrophic collapse, with coverage dropping as low as $0 . 5 \%$ . Switching to a latent WGAN largely eliminates this collapse, as expected.
 Figure 3: The CD distance is less faithful than EMD to visual quality of synthetic results; in this case it favors r-GAN results, due to the presence of high-density areas in the synthesized point sets.
 Figure 4: Training trends for the various generative models, in terms of coverage / fidelity to the ground truth test dataset. On the right, the curve markers indicate epochs 1, 10, 100, 200, 400, 1000, 1500, 2000, with larger symbols denoting higher epochs. See text for more details.
Comparisons to voxel-based methods. To the best of our knowledge we are the first to propose GANs on point-cloud data. To find out how our models fare against other 3D generative methods, in Table 2 and Fig. 4 we compare to a recent voxel-grid based approach (Wu et al., 2016) in terms of the JSD on the training set of the chair category - other shape categories can be found in the appendix (Table 10). We convert their voxel grid output into a point-set with 2048 points by performing farthest-point-sampling on the isosurface of the grid values. Per the authors’ suggestion, we used an isovalue parameter of 0.1 and isolated the largest connected component from the isosurface. Since Wu et al. (2016) do not use any train/test split, we perform 5 rounds of sampling 1k synthetic results from their models and report the best values of the respective evaluation metrics. The r-GAN mildly outperforms Wu et al. (2016) in terms of its diversity (as measured by JSD/MMD), while also creating realistic-looking results, as shown by the classification score. The l-GANs perform even better, both in terms of classification and diversity, with less training epochs. Note also that the training time for one epoch of the l-GAN is more than an order of magnitude smaller than for the r-GAN, due to its much smaller architecture and dimensionality. For fairness, we acknowledge that since Wu et al. (2016) operates on voxel grids, it is not necessarily on equal standing when it comes to generating point clouds.
Qualitative evaluation. In Fig. 5, we show some synthetic results produced by our l-GANs (top row) and the 32-component GMM, both trained on the AE-EMD latent space. We notice high quality results from either model - this highlights the strength of our learned representation, which makes it possible for the simple GMM model to perform well. The shapes (after decoding) corresponding to the 32 means of the Gaussian components can be found in the appendix (Fig. 18), as well as results using the r-GAN (see appendix, Fig. 14). The l-GAN produces crisper and less noisy results than the r-GAN, demonstrating an advantage of using a good structural loss on the decoupled, pre-trained AE.
 Figure 5: Synthetic point clouds generated by samples produced with l-GAN (top) and 32-component GMM (bottom), both trained on the latent space of an AE using the EMD loss.
Extensions to multiple classes We have performed experiments with an AE-EMD trained on a mixed set containing point clouds from 5 categories (chair, airplane, car, table, sofa). The training and testing datasets for this AE were constructed by randomly picking and adding models from each class; 2K models per class for the training set, 200 models for testing and 100 for validation. The multi-class AE has the same bottleneck size of 128 and was trained for 1000 epochs. We compare against the class-specific AEs with the 85-5-10 train-val-test-split, which we trained for 500 epochs. The precise AE model in all cases was selected based on the minimal reconstruction loss on the the respective validation set. On top of all six AEs, we train six l-WGANs for 2K epochs, and evaluate their fidelity/coverage using the MMD-CD between the respective testing sets and a synthesized dataset of $3 \mathbf { x }$ the size, as above. It turns out that the l-WGANs based on the multi-class AE perform similarly to the dedicated class-specifically trained ones (Table 4). A qualitative comparison (Fig. 6) also reveals that by using a multi-class AE-EMD we do not sacrifice much in terms of visual quality compared to the dedicated AEs.
 Figure 6: Synthetic point clouds generated by samples produced with l-WGANs trained in the latent space of an AE-EMD trained on a multi-class dataset.
<table><tr><td></td><td>airplane</td><td>car</td><td>chair</td><td>sofa</td><td>table</td><td>average</td><td>multi-class</td></tr><tr><td>train</td><td>0.0004</td><td>0.0006</td><td>0.0015</td><td>0.0011</td><td>0.0013</td><td>0.0010</td><td>0.0011</td></tr><tr><td>test</td><td>0.0006</td><td>0.0007</td><td>0.0019</td><td>0.0014</td><td>0.0017</td><td>0.0013</td><td>0.0014</td></tr></table>
Table 4: MMD-CD measurements for l-WGANs stopped at the two-thousand epoch and trained on the latent spaces of dedicated (left 5 columns) and multi-class EMD-AEs (right column). The “average” measurement is computed as the weighted average of the per-class values, using the number of train resp. test examples for each class as weights.
Limitations. Fig. 7 shows some failure cases of our models. Chairs with rare geometries (left two images) are sometimes not faithfully decoded. Additionally, the AEs may miss high-frequency geometric details, e.g. a hole in the back of a chair (middle), thus altering the style of the input shape. Finally, the r-GAN often struggles to create realistic-looking shapes (right) for some shape classes – while the r-GAN chairs that are easily visually recognizable, it has a harder time on cars. Designing more robust raw-GANs for point clouds remain an interesting avenue for future work.
# 5 RELATED WORK
A number of recent works (Wu et al. (2016), Wang et al. (2016), Girdhar et al. (2016b), Brock et al. (2016), Maimaitimin et al. (2017), Zhu et al. (2016)) have explored generative and discriminative representations for geometry. They operate on different modalities, typically voxel grids or view-based image projections. To the best of our knowledge, our work is the first to study such representations for point clouds.
 Figure 7: Limitations: The AEs might fail to reconstruct shapes of uncommon/overly detailed geometry (left four images). The r-GAN may synthesize noisy/unrealistic results, cf. a car (right).
Training Gaussian mixture models (GMM) in the latent space of an autoencoder is closely related to VAEs (Kingma & Welling, 2013). One documented issue with VAEs is over-regularization: the regularization term associated with the prior, is often so strong that reconstruction quality suffers (Bowman et al., 2015; Sønderby et al., 2016; Kingma et al., 2016; Dilokthanakul et al., 2016). The literature contains methods that start only with a reconstruction penalty and slowly increase the weight of the regularizer. In our case, we find that fixing the AE before we train our generative models yields good results.
# 6 CONCLUSION
We presented a novel set of architectures for 3D point-cloud representation learning and generation. Our results show good generalization to unseen data and our representations encode meaningful semantics. In particular our generative models are able to produce faithful samples and cover most of the ground truth distribution without memorizing a few examples. Interestingly, we see that the best-performing generative model in our experiments is a GMM trained in the fixed latent space of an AE. While, this might not be a universal result, it suggests that simple classic tools should not be dismissed. A thorough investigation on the conditions under which simple latent GMMs are as powerful as adversarially trained models would be of significant interest.
# REFERENCES
Martin Arjovsky and Léon Bottou. Towards principled methods for training generative adversarial networks. In NIPS 2016 Workshop on Adversarial Training. In review for ICLR, volume 2016, 2017.
Mario Botsch, Leif Kobbelt, Mark Pauly, Pierre Alliez, and Br uno Levy. Polygon Mesh Processing. AK Peters, 2010. ISBN 978-1-56881-426-1.
Samuel R Bowman, Luke Vilnis, Oriol Vinyals, Andrew M Dai, Rafal Jozefowicz, and Samy Bengio. Generating sentences from a continuous space. arXiv preprint arXiv:1511.06349, 2015.
André Brock, Theodore Lim, James M. Ritchie, and Nick Weston. Generative and discriminative voxel modeling with convolutional neural networks. CoRR, 2016.
Joan Bruna, Wojciech Zaremba, Arthur Szlam, and Yann LeCun. Spectral networks and locally connected networks on graphs. CoRR, abs/1312.6203, 2013.
Angel X. Chang, Thomas A. Funkhouser, Leonidas J. Guibas, Pat Hanrahan, Qi-Xing Huang, Zimo Li, Silvio Savarese, Manolis Savva, Shuran Song, Hao Su, Jianxiong Xiao, Li Yi, and Fisher Yu. Shapenet: An information-rich 3d model repository. CoRR, abs/1512.03012, 2015.
Tong Che, Yanran Li, Athul Paul Jacob, Yoshua Bengio, and Wenjie Li. Mode regularized generative adversarial networks. arXiv preprint arXiv:1612.02136, 2016.
Ding-Yun Chen, Xiao-Pei Tian, Yu-Te Shen, and Ming Ouhyoung. On Visual Similarity Based 3D Model Retrieval. Computer Graphics Forum, 2003. ISSN 1467-8659. doi: 10.1111/1467-8659. 00669.
Michaël Defferrard, Xavier Bresson, and Pierre Vandergheynst. Convolutional neural networks on graphs with fast localized spectral filtering. In Advances in Neural Information Processing Systems 29: Annual Conference on Neural Information Processing Systems 2016, December 5-10, 2016, Barcelona, Spain, pp. 3837–3845, 2016.
Emily L Denton, Soumith Chintala, Rob Fergus, et al. Deep generative image models using a laplacian pyramid of adversarial networks. In Advances in neural information processing systems, pp. 1486–1494, 2015.
Nat Dilokthanakul, Pedro AM Mediano, Marta Garnelo, Matthew CH Lee, Hugh Salimbeni, Kai Arulkumaran, and Murray Shanahan. Deep unsupervised clustering with gaussian mixture variational autoencoders. arXiv preprint arXiv:1611.02648, 2016.
Haoqiang Fan, Hao Su, and Leonidas J. Guibas. A point set generation network for 3d object reconstruction from a single image. CoRR, abs/1612.00603, 2016.
Rohit Girdhar, David F. Fouhey, Mikel Rodriguez, and Abhinav Gupta. Learning a Predictable and Generative Vector Representation for Objects, pp. 484–499. Springer International Publishing, Cham, 2016a. ISBN 978-3-319-46466-4. doi: 10.1007/978-3-319-46466-4_29.
Rohit Girdhar, David F Fouhey, Mikel Rodriguez, and Abhinav Gupta. Learning a predictable and generative vector representation for objects. In European Conference on Computer Vision, pp. 484–499. Springer, 2016b.
Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. In Z. Ghahramani, M. Welling, C. Cortes, N. D. Lawrence, and K. Q. Weinberger (eds.), Advances in Neural Information Processing Systems 27, pp. 2672–2680. Curran Associates, Inc., 2014.
Ishaan Gulrajani, Faruk Ahmed, Martín Arjovsky, Vincent Dumoulin, and Aaron C. Courville. Improved training of wasserstein gans. CoRR, abs/1704.00028, 2017.
Vishakh Hegde and Reza Zadeh. Fusionnet: 3d object classification using multiple data representations. arXiv preprint arXiv:1607.05695, 2016.
Mikael Henaff, Joan Bruna, and Yann LeCun. Deep convolutional networks on graph-structured data. CoRR, 2015.
Evangelos Kalogerakis, Melinos Averkiou, Subhransu Maji, and Siddhartha Chaudhuri. 3d shape segmentation with projective convolutional networks. CoRR, abs/1612.02808, 2016.
Michael Kazhdan, Thomas Funkhouser, and Szymon Rusinkiewicz. Rotation invariant spherical harmonic representation of 3d shape descriptors. In Proceedings of the 2003 Eurographics/ACM SIGGRAPH Symposium on Geometry Processing, SGP ’03, pp. 156–164, Aire-la-Ville, Switzerland, Switzerland, 2003. Eurographics Association. ISBN 1-58113-687-0.
Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. CoRR, abs/1412.6980, 2014.
Diederik P Kingma and Max Welling. Auto-encoding variational bayes. arXiv preprint arXiv:1312.6114, 2013.
Diederik P Kingma, Tim Salimans, and Max Welling. Improving variational inference with inverse autoregressive flow. arXiv preprint arXiv:1606.04934, 2016.
Thomas Lewiner, Helio Lopes, Antonio Wilson Vieira, and Geovan Tavares. Efficient implementation of marching cubes’ cases with topological guarantees, 2003.
Andrew L. Maas, Awni Y. Hannun, and Andrew Y. Ng. Rectifier nonlinearities improve neural network acoustic models. In Proceedings of the 30 th International Conference on Ma- chine Learning (ICML-13), 2013.
Maierdan Maimaitimin, Keigo Watanabe, and Shoichi Maeyama. Stacked convolutional autoencoders for surface recognition based on 3d point cloud data. Artificial Life and Robotics, pp. 1–6, 2017. ISSN 1614-7456. doi: 10.1007/s10015-017-0350-9.
Charles R Qi, Hao Su, Kaichun Mo, and Leonidas J Guibas. Pointnet: Deep learning on point sets for 3d classification and segmentation. arXiv preprint arXiv:1612.00593, 2016a.
Charles Ruizhongtai Qi, Hao Su, Matthias Nießner, Angela Dai, Mengyuan Yan, and Leonidas J. Guibas. Volumetric and multi-view cnns for object classification on 3d data. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2016, Las Vegas, NV, USA, June 27-30, 2016, pp. 5648–5656, 2016b. doi: 10.1109/CVPR.2016.609.
Charles Ruizhongtai Qi, Li Yi, Hao Su, and Leonidas J. Guibas. Pointnet++: Deep hierarchical feature learning on point sets in a metric space. CoRR, abs/1706.02413, 2017.
Alec Radford, Luke Metz, and Soumith Chintala. Unsupervised representation learning with deep convolutional generative adversarial networks. arXiv preprint arXiv:1511.06434, 2015.
Yossi Rubner, Carlo Tomasi, and Leonidas J. Guibas. The earth mover’s distance as a metric for image retrieval. International Journal of Computer Vision, (2):99–121, 2000. ISSN 1573-1405. doi: 10.1023/A:1026543900054.
David E Rumelhart, Geoffrey E Hinton, and Ronald J Williams. Learning representations by back-propagating errors. Cognitive modeling, 5(3):1, 1988.
Raif M. Rustamov, Maks Ovsjanikov, Omri Azencot, Mirela Ben-Chen, Frédéric Chazal, and Leonidas Guibas. Map-based exploration of intrinsic shape differences and variability. ACM Trans. Graph., 32(4):72:1–72:12, July 2013. ISSN 0730-0301. doi: 10.1145/2461912.2461959.
Tim Salimans, Ian Goodfellow, Wojciech Zaremba, Vicki Cheung, Alec Radford, and Xi Chen. Improved techniques for training gans. In Advances in Neural Information Processing Systems, pp. 2226–2234, 2016.
Abhishek Sharma, Oliver Grau, and Mario Fritz. Vconv-dae: Deep volumetric shape learning without object labels. In Geometry Meets Deep Learning Workshop at European Conference on Computer Vision (ECCV-W), 2016.
Casper Kaae Sønderby, Tapani Raiko, Lars Maaløe, Søren Kaae Sønderby, and Ole Winther. How to train deep variational autoencoders and probabilistic ladder networks. arXiv preprint arXiv:1602.02282, 2016.
Hang Su, Subhransu Maji, Evangelos Kalogerakis, and Erik G. Learned-Miller. Multi-view convolutional neural networks for 3d shape recognition. In 2015 IEEE International Conference on Computer Vision, ICCV 2015, Santiago, Chile, December 7-13, 2015, pp. 945–953, 2015. doi: 10.1109/ICCV.2015.114.
Maxim Tatarchenko, Alexey Dosovitskiy, and Thomas Brox. Octree generating networks: Efficient convolutional architectures for high-resolution 3d outputs. arXiv preprint arXiv:1703.09438, 2017.
Yueqing Wang, Zhige Xie, Kai Xu, Yong Dou, and Yuanwu Lei. An efficient and effective convolutional auto-encoder extreme learning machine network for 3d feature learning. Neurocomputing, 174:988–998, 2016.
Lingyu Wei, Qixing Huang, Duygu Ceylan, Etienne Vouga, and Hao Li. Dense human body correspondences using convolutional networks. In 2016 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2016, Las Vegas, NV, USA, June 27-30, 2016, pp. 1544–1553, 2016. doi: 10.1109/CVPR.2016.171.
Jiajun Wu, Chengkai Zhang, Tianfan Xue, Bill Freeman, and Josh Tenenbaum. Learning a probabilistic latent space of object shapes via 3d generative-adversarial modeling. In D. D. Lee, M. Sugiyama, U. V. Luxburg, I. Guyon, and R. Garnett (eds.), Advances in Neural Information Processing Systems 29, pp. 82–90. Curran Associates, Inc., 2016.
Zhirong Wu, Shuran Song, Aditya Khosla, Fisher Yu, Linguang Zhang, Xiaoou Tang, and Jianxiong Xiao. 3d shapenets: A deep representation for volumetric shapes. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2015, Boston, MA, USA, June 7-12, 2015, pp. 1912–1920, 2015. doi: 10.1109/CVPR.2015.7298801.
Li Yi, Vladimir G. Kim, Duygu Ceylan, I-Chao Shen, Mengyan Yan, Hao Su, Cewu Lu, Qixing Huang, Alla Sheffer, and Leonidas J. Guibas. A scalable active framework for region annotation in 3d shape collections. ACM Trans. Graph., (6):210:1–210:12, 2016a.
Li Yi, Hao Su, Xingwen Guo, and Leonidas J. Guibas. Syncspeccnn: Synchronized spectral CNN for 3d shape segmentation. CoRR, 2016b.
Zhuotun Zhu, Xinggang Wang, Song Bai, Cong Yao, and Xiang Bai. Deep learning representation using autoencoder for 3d shape retrieval. 2016.
# A AE DETAILS
The encoding layers of our AEs were implemented as 1D-convolutions with ReLUs, with kernel size of 1 and stride of 1, i.e. treating each 3D point independently. Their decoding layers, were MLPs built with FC-ReLUs. We used Adam (Kingma & Ba, 2014) with initial learning rate of 0.0005, $\beta _ { 1 }$ of 0.9 and a batch size of 50 to train all AEs.
# A.1 AE USED FOR SVM-BASED EXPERIMENTS
For the AE mentioned in the beginning of Section 4.1 and which was used for the SVM-related experiments, we used an encoder with 128, 128, 256 and 512 filters in each of its layers and a decoder with 1024, 2048, $2 0 4 8 \times 3$ neurons, respectively. Batch normalization was used between every layer. We also used online data augmentation by applying random rotations along the gravity- $\mathbf { \tau } ( \mathbf { Z } )$ -axis to the input point-clouds of each batch. We trained this AE for 1000 epochs with the CD loss and for 1100 with the EMD.
# A.2 ALL OTHER AES
For all other AEs, the encoder had 64, 128, 128, 256 and $k$ filters at each layer, with $k$ being the bottle-neck size. The decoder was comprised by 3 FC-ReLU layers with 256, 256, $2 0 4 8 \times 3$ neurons each. We trained these AEs for a maximum of 500 epochs when using single class data and 1000 epochs for the sole experiment involving 5 shape classes (end of Section 4.2)
Remark. Different AE setups (denoising/regularised) brought no noticeable advantage over our “vanilla” architecture. Adding drop-out layers resulted in worse reconstructions and using batch-norm on the encoder only, sped up training and gave us slightly better generalization error when the AE was trained with single-class data.
# B R-GAN DETAILS
The discriminator’s first 5 layers are 1D-convolutions with stride/kernel of size 1 and $\{ 6 4 , 1 2 8 , 2 5 6 , 2 5 6 , 5 1 2 \}$ filters each; interleaved with leaky-ReLU. They are followed by a featurewise max-pool. The last 2 FC-leaky-ReLU layers have $\{ 1 2 8 , 6 4 \}$ , neurons each and they lead to single sigmoid neuron. We used 0.2 units of leak.
The generator consists of 5 FC-ReLU layers with $\{ 6 4 , 1 2 8 , 5 1 2 , 1 0 2 4 , 2 0 4 8 \times 3 \}$ neurons each. We trained r-GAN with Adam with an initial learning rate of 0.0001, and $b e t a _ { 1 }$ of 0.5 in batches of size 50. The noise vector was drawn by a spherical Gaussian of 128 dimensions with zero mean and 0.2 units of standard deviation.
# C L-GAN DETAILS
The discriminator consists of 2 FC-ReLU layers with $\{ 2 5 6 , 5 1 2 \}$ neurons each and a final FC layer with a single sigmoid neuron. The generator consists of 2 FC-ReLUs with $\{ 1 2 8 , k = 1 2 8 \}$ neurons each. When used the l-Wasserstein-GAN, we used a gradient penalty regularizer $\lambda = 1 0$ and trained the critic for 5 iterations per one iteration of the generator. The training parameters (learning rate, batch size) and the generator’s noise distribution were the same as those used for the r-GAN.
# D SVM PARAMETERS FOR AUTOENCODER EVALUATION
For the classification experiments of Section 4.1 we used a one-versus-rest linear SVM classifier with an $l _ { 2 }$ norm penalty and balanced class weights. The exact optimization parameters can be found in Table 5.
<table><tr><td rowspan=2 colspan=1>Structural Loss</td><td rowspan=1 colspan=3>ModelNet40</td><td rowspan=1 colspan=3>ModelNet10</td></tr><tr><td rowspan=1 colspan=1>C-penalty</td><td rowspan=1 colspan=1>intercept</td><td rowspan=1 colspan=1>loss</td><td rowspan=1 colspan=1>C-penalty</td><td rowspan=1 colspan=1>intercept</td><td rowspan=1 colspan=1>loss</td></tr><tr><td rowspan=1 colspan=1>EMD</td><td rowspan=1 colspan=1>0.09</td><td rowspan=1 colspan=1>0.5</td><td rowspan=1 colspan=1>hinge</td><td rowspan=1 colspan=1>0.02</td><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1>squared-hinge</td></tr><tr><td rowspan=1 colspan=1>CD</td><td rowspan=1 colspan=1>0.25</td><td rowspan=1 colspan=1>0.4</td><td rowspan=1 colspan=1>squared-hinge</td><td rowspan=1 colspan=1>0.05</td><td rowspan=1 colspan=1>0.2</td><td rowspan=1 colspan=1>squared-hinge</td></tr></table>
Table 5: Training parameters of SVMs used in each dataset with each structural loss of the AE. $C$ -penalty: term controlling the trade-off between the size of the learned margin and the misclassification’s rate; intercept: extra dimension appended on the input features to center them; loss: svm’s optimization loss function.
# E AE RECONSTRUCTION QUALITY
Table 6 shows the reconstruction quality of the two AEs (CD- and EMD-based), in terms of the JSD of the reconstructed datasets with respect to their ground truth counterparts. Note that, in general, the quality of reconstruction is comparable between the training and test datasets, indicating that the AEs are indeed able to generalize.
<table><tr><td>Method</td><td>JSD (Tr)</td><td>JSD (Te)</td><td>MMD-CD (Tr)</td><td>MMD-EMD(Tr)</td></tr><tr><td>AE-CD</td><td>0.0216</td><td>0.0243</td><td>0.0004</td><td>0.0753</td></tr><tr><td>AE-EMD</td><td>0.0028</td><td>0.0067</td><td>0.0005</td><td>0.0527</td></tr></table>
Table 6: Effect of loss-type for AE reconstructions. The EMD loss gives rise to reconstructions with significantly better JSD compared to Chamfer. MMD-measurements favor the AE that was trained with the same loss under which the MMD measurement is computed. (Tr: Train split, Te: Test split)
# F APPLICATIONS OF THE LATENT SPACE REPRESENTATION
For shape editing applications, we use the embedding we learned with the AE-EMD trained across all 55 object classes, not separately per-category. This showcases its ability to encode features for different shapes, and enables interesting applications involving different kinds of shapes.
 Figure 8: Editing parts in point clouds using vector arithmetic on the AE latent space. Left to right: tuning the appearance of cars towards the shape of convertibles, adding armrests to chairs, removing handle from mug.
Editing shape parts. We use the shape annotations of $\mathrm { Y i }$ et al.Yi et al. (2016a) as guidance to modify shapes. As an example, assume that a given object category (e.g. chairs) can be further subdivided into two sub-categories $\mathcal { A }$ and $\boldsymbol { B }$ : every object $A \in { \mathcal { A } }$ possesses a certain structural property (e.g. has armrests, is four-legged, etc.) and objects $B \in B$ do not. Using our latent representation we can model this structural difference between the two sub-categories by the difference between their average latent representations $\mathbf { x } _ { B } - \mathbf { x } _ { A }$ , where $\mathbf { x } _ { \mathcal { A } } = \sum _ { A \in \mathcal { A } } \mathbf { x } _ { A } , \mathbf { x } _ { \mathcal { B } } = \sum _ { B \in \mathcal { B } } \mathbf { x } _ { B }$ . Then, given an object $A \ \in \ A$ , we can change its property by transforming its latent representation: $x _ { A ^ { \prime } } = x _ { A } + \mathbf { x } _ { B } - \mathbf { x } _ { A }$ , and decode $\mathbf { x } _ { \ r { A ^ { \prime } } }$ to obtain $A ^ { \prime } \in B$ . This process is shown in Figure 8. Note that the height of chairs with armrests is on average $13 \%$ smaller than the chairs without, which is reflected in the output of this process.
 Figure 9: Interpolating between different point clouds, using our latent space representation. Note the interpolation between structurally and topologically different shapes.
Interpolating shapes. By linearly interpolating between the latent representations of two shapes and decoding the result we obtain intermediate variants between the two shapes. This produces a “morph-like” sequence with the two shapes at its end points (Fig. 2, 9). Our latent representation is powerful enough to support removing and merging shape parts, which enables morphing between shapes of significantly different appearance. Our cross-category latent representation enables morphing between shapes of different classes, cfg. the second row for an interpolation between a bench and a sofa.
Shape analogies. Another demonstration of the euclidean nature of the latent space is demonstrated by finding “analogous” shapes by a combination of linear manipulations and euclidean nearestneighbor searching. Concretely, we find the difference vector between $A$ and $A ^ { \prime }$ , we add it to shape $B$ and search in the latent space for the nearest-neighbor of that result, which yields shape $B ^ { \prime }$ . We demonstrate the finding in Fig. 10 with images taken from the meshes used to derive the underlying point-clouds to help the visualization. Finding shape analogies has been of interest recently in the geometry processing community Rustamov et al. (2013).
# G MORE COMPARISONS WITH VOXEL-BASED METHODS
In this section we include preliminary results of point-cloud generators that work in conjunction with voxel-based AEs. We followed the same strategy as we did with the l-GAN but instead of using a point-cloud autoencoder we learned the latent space by an AE that works with occupancy grids of 3D shapes. For generation we used a full-GMM model with 32 centers, which was established as our best model in our previous experiments. We tried two different grid resolutions: $3 2 ^ { 3 }$ and $6 4 ^ { 3 }$ on ShapeNet’s chair class. To compare with our established “pure” point-cloud generators we converted the generated voxel-grids into 2048 points by first extracting a mesh from the grids using isosurfacing and then sampling points on the mesh using uniform area-wise sampling. We also compare against Wu et al.’s Wu et al. (2016) voxel-based GANs, which represent the “raw” GAN architecture for the case of voxel grids. For quantitative results and more details see Table 7.
Discussion. First, we see that the latent AE-based GMM models outperform Wu et al.’s “raw” GAN architecture by a big margin. In terms of coverage, using the latent representation (voxel GMM)
 Figure 10: Shape Analogies using our learned representation. Shape $B ^ { \prime }$ relates to $B$ in the same way that shape $A ^ { \prime }$ relates to $A$ .
provides a vast improvement over the “raw” voxel GAN architecture (Wu et al.). This indicates an advantage of using latent representations for generation in the voxel modality as well. Second, we note that the performance of the $6 4 ^ { 3 }$ voxel-based GMM is comparable to the one operating at $3 2 ^ { 3 }$ resolution. This suggests that the main factor affecting fidelity of the results is not the lack of high-frequency details in the ground-truth data. Third, our point-cloud-based models outperform voxel-based models in terms of the fidelity between their output and the ground truth, as measured by the MMD.
The bigger coverage boost of the voxel-based latent-space models compared to the MMD, is likely due to the way the coverage metric is computed: one matches all generated shapes against the ground truth, regardless of the quality of the generated shape. Voxel-based models frequently produce shapes with missing components (see Fig. 11); even extremely partial instances (“outliers”) will be matched (however poorly) to an arbitrary ground truth model. This effect likely artificially increases the coverage. The histogram in Figure 12 shows distances between the GMM-generated samples and their closest matches in the ground truth. The heavier “tail” for the voxel-based method indicates the presence of such poor quality matchings. Qualitative inspection of the ground truth models that were covered by the voxel-based output but not by the point-cloud output confirmed that the covering came mostly from very poor quality partial shapes.
<table><tr><td>Metric</td><td>“raw” 64³-voxel GAN Wu et al. (2016)</td><td>latent 323-voxel GMM-32</td><td>latent 643-voxel GMM-32</td><td>latent 1283-octtree GMM-32</td><td>latent point-cloud GMM-32</td></tr><tr><td>MMD-CD</td><td>0.0046</td><td>0.0025</td><td>0.0025</td><td>0.0024</td><td>0.0018</td></tr><tr><td>MMD-EMD</td><td>0.0915</td><td>0.0742</td><td>0.0729</td><td>0.0750</td><td>0.0651</td></tr><tr><td>COV-CD</td><td>19.6</td><td>63.5</td><td>60.3</td><td>60.9</td><td>68.9</td></tr><tr><td>COV-EMD</td><td>22.4</td><td>66.6</td><td>64.8</td><td>64.7</td><td>67.4</td></tr></table>
Table 7: MMD and Coverage metrics evaluated on the output of voxel-based methods at resolutions $3 2 ^ { 3 }$ and $6 4 ^ { 3 }$ and (oct-tree based) $1 2 8 ^ { 3 }$ , matched against the chair test set, using the same protocol as in Table 3 of the main paper. Our volumetric models use GMMs with full covariances and 32 centers and 64 or 256-dimensional latent codes (for the $3 2 ^ { 3 }$ , $6 4 ^ { 3 }$ and $1 2 8 ^ { 3 }$ respectively). For the mesh conversion we used the marching cubes algorithm ((Lewiner et al., 2003)) with an iso-surface value of 0.5. The rightmost column shows the results with our point-cloud based GMM.
# G.1 VOXEL AE DETAILS
Our voxel-based AEs are fully-convolutional with the encoders consisting of 3D-Conv-ReLU layers and the decoders of 3D-Conv-Relu-transpose layers. Below, we list the parameters of consecutive layers, listed left-to-right. The layer parameters are denoted in the following manner: (number of filters, filter size). Each conv/conv-tranpose has a stride of 2 except the last layer of the $3 2 ^ { 3 }$ decoder which has 4. In the last layer of the decoders we do not use a non-linearity. The abbreviation "bn" stands for batch-normalization.
 Figure 11: Point clouds extracted from synthetic voxel-based results, after isosurfacing and point sampling. Note the missing components and appearance of noise.
 Figure 12: Histograms of MMD-distances: EMD (left) and Chamfer (right), for a purely point-cloudbased generative model (GMM with 32 full-covariance components, in orange) and a voxel-based model (a latent-GAN trained on a voxel-based AE of resolution $6 4 ^ { 3 }$ , in blue). Note the larger MMD values for the voxel based approach, indicating results of lower fidelity.
• $3 2 ^ { 3 }$ - model Encoder: Input $ ( 3 2 , 6 ) ( 3 2 , 6 ) \mathrm { b n } ( 6 4 , 4 ) ( 6 4 , 2 ) \mathrm { b n } ( 6 4 , 2 )$ Decoder: (6 $4 , 2 ) ( 3 2 , 4 ) \mathrm { b n } ( 3 2 , 6 ) ( 1 , 8 ) \mathrm { C }$ utput • $6 4 ^ { 3 }$ - model Encoder: $\mathrm { I n p u t } \to ( 3 2 , 6 ) \to ( 3 2 , 6 ) \to \mathrm { b n } \to ( 6 4 , 4 ) \to ( 6 4 , 4 ) \to \mathrm { b n } \to ( 6 4 , 2 )$ $ ( 6 4 , 2 )$ Decoder: $( 6 4 , 2 ) ( 3 2 , 4 ) \mathrm { b n } ( 3 2 , 6 ) ( 3 2 , 6 ) \mathrm { b n } ( 3 2 , 8 ) ( 1 , 8 )$ Output
We train each AE for 100 epochs with Adam under the binary cross-entropy loss. The learning rate was 0.001, the $\beta _ { 1 } 0 . 9$ and the batch size 64. To validate our voxel AE architectures, we compared them in terms of reconstruction quality to the state-of-the-art method of Tatarchenko et al. (2017) and obtained comparable results, as demonstrated in Table 8.
<table><tr><td>Voxel Resolution</td><td>32</td><td>64</td></tr><tr><td>Ours</td><td>92.7</td><td>88.4</td></tr><tr><td>(Tatarchenko et al., 2017)</td><td>93.9</td><td>90.4</td></tr></table>
Table 8: Reconstruction quality statistics for our dense voxel-based AE and the one of Tatarchenko et al. (2017) for the ShapeNetCars dataset. Both approaches use a 0.5 occupancy threshold and the train-test split of Tatarchenko et al. (2017). Reconstruction quality is measured by measuring the intersection-over-union between the input and synthesized voxel grids, namely the ratio between the volume in the voxel grid that is 1 in both grids divided by the volume that is 1 in at least one grid.
# H MEMORIZATION BASELINE
Here we compare our GMM-generator against a model that memorizes the training data of the chair class. To do this, we either consider the entire training set or randomly sub-sample it, to create sets of different sizes. We then evaluate our metrics between these ”memorized” sets and the point-clouds of test split (see Table 9). The coverage/fidelity obtained by our generative models (last row) is slightly lower than the equivalent in size case (third row) as expected: memorizing the training set produces good coverage/fidelity with respect to the test set when they are both drawn from the same population. This speaks for the validity of our metrics. Naturally, the advantage of using a learned representation lies in learning the structure of the underlying space instead of individual samples, which enables compactly representing the data and generating novel shapes as demonstrated by our interpolations. In particular, note that while some mode collapse is present in our generative results, as indicated by the $\sim 1 0 \%$ drop in coverage, the achieved MMD of our generative models is almost identical to that of the memorization case, indicating excellent fidelity.
<table><tr><td>Sample Set Size</td><td>COV-CD</td><td>MMD-CD</td><td>COV-EMD</td><td>MMD-EMD</td></tr><tr><td>Entire |Trainl</td><td>97.3</td><td>0.0013</td><td>98.2</td><td>0.0545</td></tr><tr><td>1 × ITestl</td><td>54.0</td><td>0.0023</td><td>51.9</td><td>0.0699</td></tr><tr><td>3 × ITestl</td><td>79.4</td><td>0.0018</td><td>78.6</td><td>0.0633</td></tr><tr><td>Full-GMM/32 (3 × ITestl)</td><td>68.9</td><td>0.0018</td><td>67.4</td><td>0.0651</td></tr></table>
Table 9: Quantitative results of a baseline sampling/memorizing model, for different sizes of sets sampled from the training set and evaluated against the test split. The first three rows show results of a memorizing model, while the third row corresponds to our generative model. The first row shows the results of memorizing the entire training chair dataset. The second and third rows show the averages of three repetitions of the sub-sampling procedure with different random seeds.
# I MORE COMPARISONS WITH WU ET AL.
In Tables 10, 11, 12 we provide more comparisons with Wu et al. (2015) for the major ShapeNet classes for which the authors have made publicly available their models. In Table 10 we provide JSD-based comparisons for two of our models (see details in main paper 4.2.) In Tables 11, 12 we provide MMD/Coverage comparisons on the test split following the same protocol as in Table 3.
<table><tr><td rowspan="2">Class</td><td rowspan="2">Wu et al. (2016) train+test</td><td colspan="2">L-GAN (AE-EMD)</td><td colspan="2">Full GMM/32 (AE-EMD)</td></tr><tr><td>train</td><td>test</td><td>train</td><td>test</td></tr><tr><td>airplane</td><td>1</td><td>0.0149</td><td>0.0268</td><td>0.0065</td><td>0.0191</td></tr><tr><td>car</td><td>0.1890</td><td>0.0081</td><td>0.0109</td><td>0.0063</td><td>0.0108</td></tr><tr><td>rifle</td><td>0.2012</td><td>0.0212</td><td>0.0364</td><td>0.0092</td><td>0.0214</td></tr><tr><td>sofa</td><td>0.1812</td><td>0.0102</td><td>0.0102</td><td>0.0102</td><td>0.0101</td></tr><tr><td>table</td><td>0.2472</td><td>0.0058</td><td>0.0177</td><td>0.0035</td><td>0.0143</td></tr></table>
Table 10: JSD-based comparison between Wu et al. (2016) and our generative models. Full GMM/32 stands for a GM model trained on the latent space of our AE with the EMD structural loss. Note that the l-GAN here uses the same “vanilla” adversarial objective as Wu et al. (2016).
Table 11: EMD based MMD and Coverage comparison between Wu et al. (2016) and our generative model on the test split of each class. Full GMM/32 stands for a GM model trained on the latent space of our AE with the EMD structural loss. Note that Wu et al. used all models of each class for training.
<table><tr><td rowspan="2">Class</td><td colspan="2">MMD-EMD</td><td colspan="2">COV-EMD</td></tr><tr><td>Wu et al. (2016)</td><td>Full GMM/32</td><td>Wu et al. (2016)</td><td>Full GMM/32</td></tr><tr><td>airplane</td><td>■</td><td>0.0387</td><td>=</td><td>69.6</td></tr><tr><td>car</td><td>0.0591</td><td>0.0418</td><td>28.6</td><td>65.3</td></tr><tr><td>rifle</td><td>0.0512</td><td>0.0459</td><td>69.0</td><td>74.8</td></tr><tr><td>sofa</td><td>0.0773</td><td>0.0554</td><td>52.53</td><td>66.6</td></tr><tr><td>table</td><td>0.1038</td><td>0.0615</td><td>18.35</td><td>71.1</td></tr></table>
Table 12: CD based MMD and Coverage comparison between Wu et al. (2016) and our generative model on the test split of each class. Full GMM/32 stands for a GM model trained on the latent space of our AE with the EMD structural loss. Note that Wu et al. used all models of each class for training.
<table><tr><td rowspan="2">Class</td><td colspan="2">MMD-CD</td><td colspan="2">COV-CD</td></tr><tr><td>Wu et al. (2016)</td><td>Full GMM/32</td><td>Wu et al. (2016)</td><td>Full GMM/32</td></tr><tr><td>airplane</td><td>1</td><td>0.0005</td><td>1</td><td>71.1</td></tr><tr><td>car</td><td>0.0015</td><td>0.0007</td><td>22.9</td><td>63.0</td></tr><tr><td>rifle</td><td>0.0008</td><td>0.0005</td><td>56.7</td><td>71.7</td></tr><tr><td>sofa</td><td>0.0027</td><td>0.0013</td><td>42.40</td><td>75.5</td></tr><tr><td>table</td><td>0.0058</td><td>0.0016</td><td>16.7</td><td>71.7</td></tr></table>
# J FURTHER EVALUATION AND RESULTS
 Figure 13: Confusion matrix for the SVM-based classification of Section 4.1, for the Chamfer loss on ModelNet40. The class pairs most confused by the classifier are dresser/nightstand, flower pot/plant. Better viewed in the electronic version.
 Figure 14: Synthetic results produced by the r-GAN. From left to right: airplanes, car, chairs, sofas.
 Figure 15: The optimal bottleneck size was fixed at 128 by observing the reconstruction loss of the AEs, shown here for various bottleneck sizes.
 Figure 16: Generalization error of the various GAN models, at various training epochs. Generalization is estimated using the JSD (left) and MMD-CD (right) metrics, which measure closeness of the synthetic results to the training resp. test ground truth distributions. The plots show the measurements of various GANs.
 Figure 17: GMM model selection. GMMs with a varying number of Gaussians and covariance type are trained on the latent space learned by and AE trained with EMD and a bottleneck of 128. Models with a full covariance matrix achieve significantly smaller JSD than models trained with diagonal covariance. For those with full covariance, 30 or more clusters seem sufficient to achieve minimal JSD. On the right, the values in a typical covariance matrix of a Gaussian component are shown in pseudocolor - note the strong off-diagonal components.
 Figure 18: The 32 centers of the GMM fitted to the latent codes, and decoded using the decoder of the AE-EMD.
Table 13: Evaluation of five generators on test-split of chair data on epochs/models that were selected via minimal MMD-CD on the validation-split. The reported scores are averages of three pseudo-random repetitions. Compare this with Table 3. Note that the overall quality of the selected models remains the same, irrespective of the metric used for the selection. GMM-40-F stands for a GMM with 40 Gaussian components with full covariances.
<table><tr><td>Method</td><td>Epoch</td><td>JSD</td><td>MMD-CD</td><td>MMD-EMD</td><td>COV-EMD</td><td>COV-CD</td></tr><tr><td>r-GAN</td><td>1350</td><td>0.1893</td><td>0.0020</td><td>0.1265</td><td>19.4</td><td>54.7</td></tr><tr><td>1-GAN (AE-CD)</td><td>300</td><td>0.0463</td><td>0.0020</td><td>0.0800</td><td>32.6</td><td>58.2</td></tr><tr><td>1-GAN (AE-EMD)</td><td>200</td><td>0.0319</td><td>0.0022</td><td>0.0684</td><td>57.6</td><td>58.7</td></tr><tr><td>1-WGAN (AE-EMD)</td><td>1700</td><td>0.0240</td><td>0.0020</td><td>0.0664</td><td>64.2</td><td>64.7</td></tr><tr><td>GMM-40-F (AE-EMD)</td><td>-</td><td>0.0182</td><td>0.0018</td><td>0.0646</td><td>68.6</td><td>69.3</td></tr></table>
 Figure 19: Training trends in terms of the MMD-CD metric for the various GANs. Here, we sample a set of synthetic point-clouds for each model, of size 3x the size of the ground truth test dataset, and measure how well this synthetic dataset matches the ground truth in terms of MMD-CD. This plot complements Fig. 4 (left), where a different evaluation measure was used - note the similar behavior.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169# CHARACTER LEVEL BASED DETECTION OF DGA DOMAIN NAMES
Anonymous authors Paper under double-blind review
# ABSTRACT
Recently several different deep learning architectures have been proposed that take a string of characters as the raw input signal and automatically derive features for text classification. Few studies are available that compare the effectiveness of these approaches for character based text classification with each other. In this paper we perform such an empirical comparison for the important cybersecurity problem of DGA detection: classifying domain names as either benign vs. produced by malware (i.e., by a Domain Generation Algorithm). Training and evaluating on a dataset with 2M domain names shows that there is surprisingly little difference between various convolutional neural network (CNN) and recurrent neural network (RNN) based architectures in terms of accuracy, prompting a preference for the simpler architectures, since they are faster to train and less prone to overfitting.
# 1 INTRODUCTION
Malware is software that infects computers in order to perform unauthorized malicious activities. In order to successfully achieve its goals, the malware needs to be able to connect to a command and control (C&C) center. To this end, both the controller behind the C&C center (hereafter called botmaster) and the malware on the infected machines can run a Domain Generation Algorithm (DGA) that generates hundreds or even thousands of domains automatically. The malware then attempts at resolving each one of these domains with its local DNS server. The botmaster will have registered one or a few of these automatically generated domains. For these domains that have been actually registered, the malware will obtain a valid IP address and will be able to communicate with the C&C center.
The binary text classification task that we address in this paper is: given a domain name string as input, classify it as either malicious, i.e. generated by a DGA, or as benign. Deep neural networks have recently appeared in the literature on DGA detection Woodbridge et al. (2016); Saxe & Berlin (2017); Yu et al. (2017). They significantly outperform traditional machine learning methods in accuracy, at the price of increasing the complexity of training the model and requiring larger datasets. Independent of the work on deep networks for DGA detection, other deep learning approaches for character based text classification have recently been proposed, including deep neural network architectures designed for processing and classification of tweets (Dhingra et al. (2016); Vosoughi et al. (2016)) as well as general natural language text (Zhang et al. (2015)). No systematic study is available that compares the predictive accuracy of all these different character based deep learning architectures, leaving one to wonder which one works best for DGA detection.
To answer this open question, in this paper we compare the performance of five different deep learning architectures for character based text classification (see Table 1) for the problem of detecting DGAs. They all rely on character-level embeddings, and they all use a deep learning architecture based on convolutional neural network (CNN) layers, recurrent neural network (RNN) layers, or a combination of both. Our most important finding is that for DGA detection, which can be thought of as classification of short character strings, despite of vast differences in the deep network architectures, there is remarkably little difference among the methods in terms of accuracy and false positive rates, while they all comfortably outperform a random forest trained on human engineered features. This finding is of practical value for the design of deep neural network based classifiers for short text classification in industry and academia: it provides evidence that one can select an architecture that is faster to train, without loss of accuracy. In the context of DGA detection, optimizing the training time is of particular importance, as the models need to be retrained on a regular basis to stay current with respect to new, emerging malware.
Table 1: High level overview of recent deep learning approaches for character based text classification
<table><tr><td rowspan=1 colspan=1>Name</td><td rowspan=1 colspan=1>Architecture</td><td rowspan=1 colspan=1>Reference</td></tr><tr><td rowspan=1 colspan=1>Endgame</td><td rowspan=1 colspan=1>single LSTMlayer</td><td rowspan=1 colspan=1>Woodbridge et al. (2016)</td></tr><tr><td rowspan=1 colspan=1>Invincea</td><td rowspan=1 colspan=1>parallel CNN layers</td><td rowspan=1 colspan=1>Saxe&Berlin (2017)</td></tr><tr><td rowspan=1 colspan=1>CMU</td><td rowspan=1 colspan=1>forward LSTM layer+ backward LSTMlayer</td><td rowspan=1 colspan=1>Dhingra et al. (2016)</td></tr><tr><td rowspan=1 colspan=1>MIT</td><td rowspan=1 colspan=1> stacked CNN layers + single LSTM layer</td><td rowspan=1 colspan=1>Vosoughi et al. (2016)</td></tr><tr><td rowspan=1 colspan=1>NYU</td><td rowspan=1 colspan=1>stacked CNNlayers</td><td rowspan=1 colspan=1>Zhang et al. (2015)</td></tr></table>
# 2 BACKGROUND
Malware controllers, or botmasters, use malware for all kinds of unauthorized malicious activities. These activities range from stealing information, to exploiting the victims’ computing resources to mine bitcoin. They can also include launching a distributed denial of service attack from the victims’s computers or encrypting the victims hard drive (ransomware). In order to successfully achieve its goals, it is vital that the malware be able to connect to a command and control (C&C) center. This communication can serve many purposes. The malware can use it to send stolen information (such as passwords or access credentials) to the malware designer behind the C&C center, it can use this communication channel to receive instructions or even to update itself to a newer version.
Initially, botmasters established such a communication channel to the C&C center by hard-coding an IP address inside the malware. This approach has obvious shortcomings from the botmasters’ perspective: once the malware is reversed engineered, the IP address is discovered and shut down. Over time, malware designers came up with a much more effective strategy: Domain Generation Algorithms (DGAs). Domain Generation Algorithms work by having the malware accessing some available source of randomness and inputting it into an algorithm that generates hundreds or even thousands of domains automatically. The malware then attempts at resolving each one of these domains with its local DNS server (a DNS server runs a protocol that translates domain names into IP addresses; it is a vital piece of the Internet). The botmaster will have registered one or a few of these automatically generated domains. For these domains that have been actually registered, the malware will obtain a valid IP address and will be able to communicate with the C&C center. For all the other domains that were automatically generated but not registered, the malware obtains a message stating that these domains could not have been resolved and ignores them.
DGAs make blacklisting of domains extremely difficult, since by changing the initial randomness (while keeping the same algorithm) the malware can potentially generate completely different domains. This technique has been used by high-profile malware such as Conficker, Stuxnet (the malware designed to attack Iran nuclear facilities) and Flame. Catching domain names generated by malware has become a central topic in information security, leading to a recent interest in detecting DGA domains using machine learning techniques. Models that classify domain names as benign or malicious based solely on the domain name string are of particular interest for their generality, as context information beyond the domain name string might be unavailable or expensive to acquire. Traditional machine learning methods for DGA detection based on the domain name string rely on extraction of predefined, human engineered lexical features, see e.g. Antonakakis et al. (2012); Schiavoni et al. (2014). Whenever human engineered features are used, it is obvious that this opens the door for an adversary to carefully craft its DGA to avoid detection by using the aforementioned features. This makes maintaining such machine learning systems labor intensive. Recently proposed deep learning techniques for detecting DGAs learn features automatically, thereby offering the potential to bypass the human effort of feature engineering (Woodbridge et al. (2016); Saxe & Berlin (2017); Yu et al. (2017)). In addition these deep learning approaches outperform the traditional machine learning techniques with human engineered features in terms of accuracy and false positive rates. The choice of deep network architecture in these recent works appears fairly arbitrary, and it is unclear whether they would perform better or worse than other deep neural networks approaches for text classification that have been introduced recently, in particular character-level methods for processing and classification of tweets (Dhingra et al. (2016); Vosoughi et al. (2016)) and for general natural language text (Zhang et al. (2015)). In this paper, we provide the first comparative study of all these different methods, showing that, despite of vast differences in the architectures, they can be easily tuned to result in the same predictive accuracy.
The problem of adversarial examples, i.e. instances that have intentionally been designed to cause the model to make a mistake, are a well known problem in machine learning. The scenario sketched above — in which a malware designer exploits knowledge about the lexical features used by a random forest to craft his DGA to avoid detection — is a prime example of this. Deep neural networks are famously not immune to adversarial examples either, and generative adversarial networks (GANs) can be trained to generate them automatically (see e.g. Goodfellow et al. (2014a;b)). Specifically in the context of DGA detection, Anderson et al. (2016) have used a character-based generative adversarial network (GAN) to augment training sets in order to harden other machine learning models (like a random forest) against yet-to-be-observed DGAs. It is highly unlikely for attackers to use GANs themselves, because DGA algorithms must be light enough to be embedded inside malware code. Furthermore, generating domain names that look like a benign domain is not enough for an effective DGA. Ideally, every domain produced by a DGA must not have been registered yet or must have a low likelihood of being registered already – if a domain produced by a DGA has already been taken, it is useless for the botmaster. Combining all these requirements is essential for a serious study of adversarial generated domains and outside the scope of this paper.
# 3 METHODS
We compare five different deep learning methods for short string classification, when applied to the problem of DGA detection specifically. For each of the methods, we start from the original proposals as can be found in the references in Table 1 and only make modifications when they improve the predictive accuracy for the classification of domain names. Below we give an overview of the methods and the adaptations made. A Keras1 code snippet for each method is included in Appendix A.
The strings that we give as input to all classifiers consist of a second level domain (SLD) and a top level domain (TLD), separated by a dot, as in e.g. wikipedia.org. Following Woodbridge et al. (2016), we set the maximum length at 75 characters, padded with zeros on the left for domains whose length is less than 75.2 We convert each domain name string to lower case, since domain names are case insensitive, and encode it as an ASCII code sequence of length 128, effectively representing each domain name string as a 75 by 128 matrix in which each character corresponds to a column.
# 3.1 RNN BASED ARCHITECTURES
Endgame Model Long short-term memory networks (LSTMs), a special kind of recurrent neural networks (RNNs) have recently attracted a lot of attention because of their successful application to problems that involve processing of sequences (Hochreiter & Schmidhuber (1997)). Since domain names can be thought of as sequences of characters, LSTMs are a natural kind of classifiers to apply. The LSTM network proposed by Woodbridge et al. (2016) was designed specifically for DGA detection, so we stay very close to the original model. The network is comprised of an embedding layer, an LSTM layer (128 LSTM cells with default Tanh activation), and a single node output layer with sigmoid activation. Instead of using RMSProp as the optimization algorithm, as was done in Woodbridge et al. (2016), we switched to Adam (Kingma & Ba (2014)) because it resulted in better loss convergence results (see Section 4). The Endgame model includes dropout, a technique to improve model performance and overcome over-fitting by randomly excluding nodes during training, which serves to break up complex co-adaptations in the network Srivastava et al. (2014). This is confined to the training phase; all nodes are active during testing and deployment.
The role of the embedding layer is to learn to represent each character that can occur in a domain name by a 128-dimensional numerical vector. This vector is different from the original 128- dimensional ASCII encoding. The embedding maps semantically similar characters to similar vectors, where the notion of similarity is implicitly derived (learned) based on the classification task at hand. As will become clear in the remainder of this section, all five deep neural network architectures under study start with such an embedding layer. To allow for a fair comparison, we have made the parameter choices for the embedding layer, such as the dimensionality of the embedding space, identical for all five models. In addition, for comparison purposes, in Section 4 we also present the results of a “baseline neural network model” consisting only of an embedding layer as its hidden layer.
CMU Model Bidirectional RNNs extend regular RNNs by processing the input string in two ways. In a forward layer, the input sequence is processed from the left to the right, as in a traditional RNN, while in a backward layer, the processing happens from the right to the left. The output from the forward and the backward layer is then combined and passed on to further layers. Bidirectional LSTMs for character level text processing have been proposed in Ling et al. (2015), and, following up on that, very similar bidirectional GRUs (gated recurrent units) have been applied in a “Tweet2Vec” model for tweet classification (predicting hashtags of tweets) by Dhingra et al. (2016). We use an adaptation of the latter; see Listing 2 in Appendix A. Including dropout or replacing LSTM by GRU did not cause a significant change in predictive accuracy, although the latter did result in a decrease of training runtime.
# 3.2 CNN BASED ARCHITECTURES
NYU Model Convolutional neural networks (CNNs) are known for their ability to process input data with a grid like topology, such as images consisting of a grid of pixels. To the best of our knowledge, Zhang et al. (2015) were the first to apply 1-dimensional or “temporal” CNNs successfully to text classification at character level. Their proposed deep network architecture, which is intended to process full-blown natural language text such as news articles or reviews, includes 6 stacked CNN layers, with each subsequent layer consuming the output from the previous layer. In contrast to natural language text, domain names are very short and they do not have an internal grammatical structure, naturally resulting the original architectures from Zhang et al. (2015) to overfit on our data. We therefore reduced the number of stacked CNN layers to two, and decreased the size and the number of filters on the CNN layers (see Listing 3).
Invincea Model Saxe & Berlin (2017) proposed a CNN based classifier that takes generic short character strings as its input and learns to detect whether they are indicators of malicious behavior. The short character strings can be e.g. URLs, file paths, or registry keys. The fundamental difference between the Invincea model versus the NYU model described above, is that in the Invincea model the CNN layers are parallel instead of stacked, and that pooling always happens over the entire domain name instead of within a small pooling window. That means that the Invincea model is only detecting the presence or absence of patterns in the domain names, and does not retain any information on where exactly in the domain name string these patterns occur. In the Invincea model, the embedding layer is followed by a convolutional layer with 1024 filters, namely 256 filters for each of the sizes 2, 3, 4, and 5. Each of these filters learns to detect the soft presence of an interesting soft $n$ -gram (with $n = 2 , 3 , 4 , 5$ ). The output of the convolutional layer is consumed by two dense hidden layers, each with 1024 nodes, before reaching a single node output layer with sigmoid activation. Out of all the models that we compared, this one has the most extensive architecture.
# 3.3 HYBRID CNN/RNN BASED ARCHITECTURE
MIT Model The MIT model proposed by Vosoughi et al. (2016) is an extension of the NYU model, where the stacked CNN layers are followed by an LSTM layer. Similarly as with the NYU model, the use of multiple stacked CNN layers (which worked well for tweets in Vosoughi et al. (2016)) resulted in the models to overfit on our data. For this reason, we reduced the MIT model architecture to the minimum that preserves its spirit: one CNN layer followed by one LSTM layer.
 Figure 1: Training and validation loss curves. The vertical axis in Figure (f) has a different scale than the other figures, related to the fact that the “Embedding only” baseline model has a much higher loss than the other models.
# 4 RESULTS AND LEARNED REPRESENTATIONS
We trained and evaluated the models on a dataset with 1 million DGA domain names from Bambenek3 (positive examples) and the top 1 million domain names from Alexa4 (negative examples). Alexa ranks websites based on their popularity in terms of number of page views and number of unique visitors. It only retains the websites’ SLD and TLD, aggregating across any subdomains. For example, according to Alexa, the five highest ranked domain names in terms of popularity on 2017-10-26 are google.com, youtube.com, facebook.com baidu.com, and wikipedia.org. For our experiments, we assume that the top 1 million domain names in this ranking are benign domain names, although it is possible that the bottom of the ranking may contain some noise.
In addition to these benign domain names, we collected 1 million DGA domain names from the Bambenek Consulting feeds for 3 different days, namely Jun 24, Jul 22, Jul 23, 2017. These feeds contain DGA domain names from specific malware families that were observed in real traffic on those days. Such domain names can be collected by reverse engineering a known malware family, generating lists of domain names with the reverse engineered malware, and checking which of these domain names also occur in real traffic. Note that our goal in this paper is the development of a neural network classifier that can detect DGAs without the need to reverse engineer malware families. An important advantage of such a classifier is that it can also be used against new and previously unknown malware families.
Table 2: Results on test data from July 2017. Accuracy, TPR, FPR are w.r.t. a threshold that gives a FPR of 0.001 on the validation data.
<table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=2>Architecture</td><td rowspan=1 colspan=1>Acc</td><td rowspan=1 colspan=1>TPR</td><td rowspan=1 colspan=1>FPR</td><td rowspan=1 colspan=1>AUC@1%</td></tr><tr><td rowspan=1 colspan=1>RF</td><td rowspan=1 colspan=2>Lexical features</td><td rowspan=1 colspan=1>91.51%</td><td rowspan=1 colspan=1>83.15%</td><td rowspan=1 colspan=1>0.00128</td><td rowspan=1 colspan=1>84.77%</td></tr><tr><td rowspan=1 colspan=1>MLP</td><td rowspan=1 colspan=2>Lexical features</td><td rowspan=1 colspan=1>73.74%</td><td rowspan=1 colspan=1>47.61%</td><td rowspan=1 colspan=1>0.00091</td><td rowspan=1 colspan=1>58.81%</td></tr><tr><td rowspan=1 colspan=1>Embedding</td><td rowspan=1 colspan=2></td><td rowspan=1 colspan=1>84.29%</td><td rowspan=1 colspan=1>68.69%</td><td rowspan=1 colspan=1>0.00108</td><td rowspan=1 colspan=1>80.88%</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>LSTM</td><td rowspan=1 colspan=1>CNN</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>Endgame</td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>98.72%</td><td rowspan=1 colspan=1>97.55%</td><td rowspan=1 colspan=1>0.00102</td><td rowspan=1 colspan=1>98.03%</td></tr><tr><td rowspan=1 colspan=1>Invincea</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1>98.95%</td><td rowspan=1 colspan=1>98.01%</td><td rowspan=1 colspan=1>0.00109</td><td rowspan=1 colspan=1>97.47%</td></tr><tr><td rowspan=1 colspan=1>CMU</td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>98.54%</td><td rowspan=1 colspan=1>97.18%</td><td rowspan=1 colspan=1>0.00108</td><td rowspan=1 colspan=1>98.25%</td></tr><tr><td rowspan=1 colspan=1>MIT</td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1>98.70%</td><td rowspan=1 colspan=1>97.49%</td><td rowspan=1 colspan=1>0.00099</td><td rowspan=1 colspan=1>97.55%</td></tr><tr><td rowspan=1 colspan=1>NYU</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1>98.58%</td><td rowspan=1 colspan=1>97.27%</td><td rowspan=1 colspan=1>0.00116</td><td rowspan=1 colspan=1>97.93%</td></tr></table>
We randomly split the data into $80 \%$ for training, $10 \%$ for validation, and $10 \%$ for testing. Figure 1 shows the training and validation loss curves for each of the models described in Section 3. The displayed epochs indicate where we stopped the training to obtain the models used to produce the final results in Table 2 and 5. The training loss is higher than the validation loss in the pictures in Figure 1 because the loss against the training data is computed in an average way across batches (the batch size is 100) while dropout is being applied, whereas performance on the validation set is determined at the end of each epoch with dropout disabled. Figure 1(f) displays the loss curves for training a simple neural network consisting of only an embedding layer. We include the performance of this network in our results as a baseline.
The accuracy of each of the trained models when applied to the test data is recorded in Table 2. In addition to accuracy, this table includes the true positive rate (TPR) and false positive rate (FPR) for each of the models. Recall that $\mathrm { T P R } = \mathrm { T P } / ( \mathrm { T P } { + } \mathrm { F N } )$ and $\mathrm { F P R } = \mathrm { F P } / ( \mathrm { F P + T N } )$ where TP, FP, TN, and FN are the number of true positives, false positives, true negatives, and false negatives respectively. A low false positive rate is very important in deployed DGA detection systems, because blocking legitimate traffic is highly undesirable. All classifiers in Table 2 output a probability that a given instance belongs to the positive class, so we can tune a threshold probability at which to consider a prediction positive. For each model, we choose this threshold such that the model trained over the training data has a 0.001 FPR over the validation data. Then we report the accuracy, TPR and FPR obtained with this classification threshold over the test data. Finally, we also report AUC $@1 \%$ FPR, which is the integral of the ROC curve from $\mathrm { { F P R } = 0 }$ to $\mathrm { { F P R } = 0 . 0 1 }$ on the test data.
For comparison purposes, Table 2 also contains results for a Random Forest (RF) and a Multilayer Perceptron (MLP) trained on the following 11 features, extracted from each domain name string (see Yu et al. (2014; 2016)): ent (normalized entropy of characters); nl2 (median of 2-gram); nl3 (median of 3-gram); naz (symbol character ratio); hex (hex character ratio); vwl (vowel character ratio); len (domain label length); gni (gini index of characters); cer (classification error of characters); tld (top level domain hash); dgt (first character digit). The Random Forest consists of 100 trees. The MLP has a single hidden layer with 128 nodes; see Listing 7 in Appendix A. Like the deep networks in this paper, this MLP was trained with batch size 100. The values of the 11 features are normalized so that they are all on the same scale before presenting them to the MLP.
As expected, the FPR of all classifiers is around 0.001. There is a clear variation in the TPR that the classifiers achieve against that small FPR. While the Random Forest is only able to “catch” $83 \%$ of the malicious domain names, all the deep neural network architectures achieve a recall of 97- $98 \%$ . The baseline neural network consisting of only an embedding layer as its hidden layer clearly performs the worst with a TPR of less than $69 \%$ , highlighting that it is advantageous to extend the network architecture with one or more LSTM or CNN layers. Interestingly, there is little to no variation among the five deep neural network architectures in terms of TPR.
Table 3 contains examples of domain names that were randomly selected among those misclassified by either the Random Forest or by all five deep neural networks. Inspecting the column of the benign domain names, i.e. the Alexa domain names, it is interesting to note that most of those misclassified by the deep neural networks (bottom left in the table) come across as gibberish that a human annotator would likely also classify as malicious. As also evident from the top right of Table 3, the deep neural networks have become very good at considering such gibberish-looking domain names to be malicious, even though they were never explicitly told to do so (unlike the Random Forest, which explicitly includes a normalized entropy of characters feature). The fact that the malicious domain names at the bottom right of Table 3 were missed by the deep neural networks might be due to our deliberate choice to tune the classification threshold to achieve a very low FPR. This makes all the classifiers hold back from labeling a domain name as malicious if they are not almost completely certain. As explained above, a low FPR is very important in deployed DGA detection systems, as blocking legitimate traffic is highly undesirable. Note that if a deployed DGA detection system would rely on the Random Forest classifier, it would block all domain names from the first row in Table 3, whereas, if it would rely on any of the deep neural network classifiers, it would block all domain names from the second row in Table 3. The domain names from the first column would have been unjustly blocked. For those negatively affected by this, it would be easier to “understand” (and perhaps forgive) the decisions made by the deep neural network classifiers, as they are more in line with decisions that a human would make when confronted with these domain name strings.
Table 3: Examples of domain names that were either misclassified by the Random Forest or by the deep neural networks. For the malicious domain names, the name of the malware family is shown between parentheses.
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>benign</td><td rowspan=1 colspan=1>malicious</td></tr><tr><td rowspan=1 colspan=1>misclassifiedby RF&correctlyclassifiedby all fivedeep networks</td><td rowspan=1 colspan=1>kosmetikosdnr.ltjobrankingcommittee.comnaturalandhealthytips.compokemonrubysapphire.comturkcehdpornoizle.combollywoodparksdubai.com</td><td rowspan=1 colspan=1>mowvcssclilpomqi.com (murofet)ntearasildeafeninguvuc.com (banjori)raklloblmuppono.info (cryptolocker)5alolch3wvn5olcc.org (chinad)ldjucxqhivnaperisusb.ga (necurs)daeontibyxgask.cc (ranbyus)</td></tr><tr><td rowspan=1 colspan=1>misclassifiedby all fivedeep networks &correctlyclassified by RF</td><td rowspan=1 colspan=1>rfembassy.kz 4553t5pugtt1qslvsnmpc0tpfz5fo.xyz9odyefocculgririlemjijbab.topa5rtngpo9840oyd.commydwnldsghtfv.com</td><td rowspan=1 colspan=1>doycsnramt.com (qakbot)gypjuytopleh.com (ramnit)zamdazhocs.com (nymaim)mxdsbbnxmogo.online (tinba)pelkbazgro.info (pykspa)</td></tr></table>
The results in Table 2 are for DGA domain names that appeared at the same time in real traffic as the training data used to construct the classifiers, namely July 2017. To evaluate how well the trained models hold up against DGA domain names that appear at a later point, we collected an additional 100K DGA domain names from the Bambenek Consulting feeds for Dec 6, Dec 9, and Dec 10, 2017. Table 4 contains results for this “prospective” dataset. The only difference between the experimental setup for Table 2 and Table 4 are the 100K DGA domain names used in the test set. The training dataset, the validation dataset, and the 100K Alexa domain names used in the test set are kept the same. As can be seen when comparing the results in Table 2 and Table 4, the to be expected drop in TPR is minor.
As Table 5 shows there is a substantial distinction among the different models in terms of complexity (number of parameters that have to be learned during the training process) and required training time per epoch. The platform used for training is an AWS virtual machine with access to multiple GPUs. Both the number of epochs needed to train a network, and the number of seconds required per epoch, are contributing factors to the overall training runtime. The NYU model took less than 8 minutes to train, while the CMU model took as much as 10 hours. The last column in Table 5 shows the time needed to classify 200K domain names with an already trained model. The ranking of the deep networks in terms of this “scoring time” coincides with the ranking in terms of training time. Given that all deep networks achieve a similar accuracy (TPR), the NYU model with it short training and scoring time comes out as the winner.
Table 4: Results on test data from December 2017. Accuracy, TPR, FPR are w.r.t. a threshold that gives a FPR of 0.001 on the validation data.
<table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=2>Architecture</td><td rowspan=1 colspan=1>Acc</td><td rowspan=1 colspan=1>TPR</td><td rowspan=1 colspan=1>FPR</td><td rowspan=1 colspan=1>AUC@1%</td></tr><tr><td rowspan=1 colspan=1>RF</td><td rowspan=1 colspan=2>Lexical features</td><td rowspan=1 colspan=1>91.57%</td><td rowspan=1 colspan=1>83.26%</td><td rowspan=1 colspan=1>0.00128</td><td rowspan=1 colspan=1>84.47%</td></tr><tr><td rowspan=1 colspan=1>MLP</td><td rowspan=1 colspan=2>Lexical features</td><td rowspan=1 colspan=1>78.87%</td><td rowspan=1 colspan=1>57.86%</td><td rowspan=1 colspan=1>0.00091</td><td rowspan=1 colspan=1>67.23%</td></tr><tr><td rowspan=1 colspan=1>Embedding</td><td rowspan=1 colspan=2></td><td rowspan=1 colspan=1>86.75%</td><td rowspan=1 colspan=1>73.61%</td><td rowspan=1 colspan=1>0.00108</td><td rowspan=1 colspan=1>82.93%</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>LSTM</td><td rowspan=1 colspan=1>CNN</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>Endgame</td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>98.22%</td><td rowspan=1 colspan=1>96.54%</td><td rowspan=1 colspan=1>0.00102</td><td rowspan=1 colspan=1>97.53%</td></tr><tr><td rowspan=1 colspan=1>Invincea</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1>98.44%</td><td rowspan=1 colspan=1>97.00%</td><td rowspan=1 colspan=1>0.00109</td><td rowspan=1 colspan=1>97.07%</td></tr><tr><td rowspan=1 colspan=1>CMU</td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>98.06%</td><td rowspan=1 colspan=1>96.23%</td><td rowspan=1 colspan=1>0.00108</td><td rowspan=1 colspan=1>97.46%</td></tr><tr><td rowspan=1 colspan=1>MIT</td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1>98.21%</td><td rowspan=1 colspan=1>96.52%</td><td rowspan=1 colspan=1>0.00099</td><td rowspan=1 colspan=1>97.52%</td></tr><tr><td rowspan=1 colspan=1>NYU</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1>98.12%</td><td rowspan=1 colspan=1>96.35%</td><td rowspan=1 colspan=1>0.00116</td><td rowspan=1 colspan=1>97.10%</td></tr></table>
Table 5: Comparison of complexity and efficiency of classifiers for DGA detection. The complexity refers to the number of parameters that have to be learned in the deep learning architectures. The training time is reported in terms of seconds needed for an epoch times the number of epochs. The scoring time is the time in seconds needed to label 200K domain names by an already trained model.
<table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=2>Architecture</td><td rowspan=1 colspan=1>Complexity</td><td rowspan=1 colspan=1>Training'Time</td><td rowspan=1 colspan=1>Scoring time</td></tr><tr><td rowspan=1 colspan=1>RF</td><td rowspan=1 colspan=2>Lexical features</td><td rowspan=1 colspan=1>100 trees</td><td rowspan=1 colspan=1>1,800s</td><td rowspan=1 colspan=1>5s</td></tr><tr><td rowspan=1 colspan=1>MLP</td><td rowspan=1 colspan=2>Lexical features</td><td rowspan=1 colspan=1>1,665 par</td><td rowspan=1 colspan=1>10s× 40= 400s</td><td rowspan=1 colspan=1>1s</td></tr><tr><td rowspan=1 colspan=1>Embedding</td><td rowspan=1 colspan=2></td><td rowspan=1 colspan=1>25,985 par</td><td rowspan=1 colspan=1>15s × 40= 600s</td><td rowspan=1 colspan=1>3s</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>LSTM</td><td rowspan=1 colspan=1>CNN</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>Endgame</td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>148,097 par</td><td rowspan=1 colspan=1>430s × 10= 4,300s</td><td rowspan=1 colspan=1>13s</td></tr><tr><td rowspan=1 colspan=1>Invincea</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1>2,576,385 par</td><td rowspan=1 colspan=1>105s × 40= 4,200s</td><td rowspan=1 colspan=1>7s</td></tr><tr><td rowspan=1 colspan=1>CMU</td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>115,329 par</td><td rowspan=1 colspan=1>1200s ×30= 36,000s</td><td rowspan=1 colspan=1>26s</td></tr><tr><td rowspan=1 colspan=1>MIT</td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1>115,137 par</td><td rowspan=1 colspan=1>800s ×15= 12,000s</td><td rowspan=1 colspan=1>10s</td></tr><tr><td rowspan=1 colspan=1>NYU</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1>254,337 par</td><td rowspan=1 colspan=1>45s ×10= 450s</td><td rowspan=1 colspan=1>5s</td></tr></table>
# 5 CONCLUSION
DGA detection, i.e. the classification task of distinguishing between benign domain names and those generated by malware (Domain Generation Algorithms), has become a central topic in information security. In this paper we have compared five different deep neural network architectures that perform this classification task based purely on the domain name string, given as a raw input signal at character level. All five models, i.e. two RNN based architectures, two CNN based architectures, and one hybrid RNN/CNN architecture perform equally well, catching around $9 7 . 9 8 \%$ of malicious domain names against a false positive rate of 0.001. This roughly means that for every 970 malicious domain names that the deep networks catch, they flag only one benign domain name erroneously as malicious. A Random Forest based on human defined linguistic features achieves a recall of only $83 \%$ against the same 0.001 false positive rate when trained and tested on the same data that was used for the deep networks. The use of a deep neural network that automatically learns features is attractive in a cybersecurity setting because it is a lot harder to craft malware to avoid detection by a system that relies on automatically learned features instead of on human engineered features. An interesting direction for future work is to test the trained deep networks more extensively on domain names generated by new and previously unseen malware families.
# REFERENCES
Hyrum S Anderson, Jonathan Woodbridge, and Bobby Filar. Deepdga: Adversarially-tuned domain generation and detection. In Proceedings of the 2016 ACM Workshop on Artificial Intelligence and Security, pp. 13–21, 2016.
Manos Antonakakis, Roberto Perdisci, Yacin Nadji, Nikolaos Vasiloglou II, Saeed Abu-Nimeh, Wenke Lee, and David Dagon. From throw-away traffic to bots: Detecting the rise of DGA-based malware. In USENIX Security Symposium, volume 12, 2012.
Bhuwan Dhingra, Zhong Zhou, Dylan Fitzpatrick, Michael Muehl, and William Cohen. Tweet2vec: Character-based distributed representations for social media. In Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics, volume 2, pp. 269–274, 2016.
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, 2014a.
Ian J Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. arXiv preprint arXiv:1412.6572, 2014b.
Sepp Hochreiter and Jurgen Schmidhuber. Long short-term memory. ¨ Neural Computation, 9(8): 1735–1780, 1997.
Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. preprint arXiv:1412.6980, 2014.
Wang Ling, Tiago Lu´ıs, Lu´ıs Marujo, Ramon Fernandez Astudillo, Silvio Amir, Chris Dyer, Alan W ´ Black, and Isabel Trancoso. Finding function in form: Compositional character models for open vocabulary word representation. arXiv preprint arXiv:1508.02096, 2015.
Joshua Saxe and Konstantin Berlin. eXpose: A character-level convolutional neural network with embeddings for detecting malicious urls, file paths and registry keys. arXiv preprint arXiv:1702.08568, 2017.
Stefano Schiavoni, Federico Maggi, Lorenzo Cavallaro, and Stefano Zanero. Phoenix: DGA-based botnet tracking and intelligence. In International Conference on Detection of Intrusions and Malware, and Vulnerability Assessment, pp. 192–211, 2014.
Nitish Srivastava, Geoffrey E Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. Dropout: a simple way to prevent neural networks from overfitting. Journal of Machine Learning Research, 15(1):1929–1958, 2014.
Soroush Vosoughi, Prashanth Vijayaraghavan, and Deb Roy. Tweet2vec: Learning tweet embeddings using character-level cnn-lstm encoder-decoder. In Proceedings of the 39th International ACM SIGIR conference on Research and Development in Information Retrieval, pp. 1041–1044, 2016.
Jonathan Woodbridge, Hyrum S Anderson, Anjum Ahuja, and Daniel Grant. Predicting domain generation algorithms with long short-term memory networks. preprint arXiv:1611.00791, 2016.
Bin Yu, Les Smith, and Mark Threefoot. Semi-supervised time series modeling for real-time flux domain detection on passive DNS traffic. In Proc. of the 10th International Conference on Machine Learning and Data Mining, pp. 258–271, 2014.
Bin Yu, Les Smith, Mark Threefoot, and Femi Olumofin. Behavior analysis based DNS tunneling detection with big data technologies. In Proc. of the International Conference on Internet of Things and Big Data, pp. 284–290, 2016.
Bin Yu, Daniel Gray, Jie Pan, Martine De Cock, and Anderson Nascimento. Inline dga detection with deep networks. In Proceedings of Data Mining for Cyber Security (DMCS2017), workshop at ICDM2017 (IEEE International Conference on Data Mining), 2017.
Xiang Zhang, Junbo Zhao, and Yann LeCun. Character-level convolutional networks for text classification. In Advances in Neural Information Processing Systems, volume 28, pp. 649–657, 2015.
# A KERAS CODE FOR DEEP NETWORKS
main input $=$ Input (shape $: =$ (75, ) , dtype $z '$ int32 ’, name $\mathbf { \equiv }$ ’main input’) embedding $=$ Embedding(input dim ${ \tt 1 2 8 }$ , output dim ${ \tt 1 2 8 }$ , input length $= 7 5$ )(main input ) lstm $=$ LSTM(128, return sequence $\vDash$ False) (embedding) drop $=$ Dropout(0.5) ( lstm ) output $=$ Dense(1, activation $= ^ { \mathrm { i } }$ ’sigmoid’) (drop) model $=$ Model(inputs $\mathbf { \sigma } =$ main input, outputs $=$ output) model.compile( ${ \mathrm { l o s s } } = { \ ' }$ binary crossentropy ’, optimizer $= ^ { \ ' }$ adam’) main input $=$ Input (shape=(75, ) , dtype=’int32 ’, name $u = { \mathrm { i } }$ ’main input’) embedding $=$ Embedding(input dim ${ \tt 1 2 8 }$ , output dim ${ \tt 1 2 8 }$ , input length $= 7 5$ )(main input ) bi lstm $=$ Bidirectional ( layer =LSTM(64, return sequence $\mathrm { ~ \sigma ~ } \mathrm { ~ \sigma ~ } \mathrm { ~ \sigma ~ } \mathrm { ~ \sigma ~ }$ False) , merge mode=’concat’)(embedding) output $=$ Dense(1, activation $= ^ { \overrightarrow { { \mathbf { \Gamma } } } }$ ’sigmoid’) ( bi lstm ) model $=$ Model(inputs main input, outputs $=$ output) model.compile( ${ \mathrm { l o s s } } = { \ ' }$ binary crossentropy ’, optimizer $= ^ { \ ' }$ adam’) main input $=$ Input (shape $: = 1$ (75, ) , dtype $= ^ { \ ' }$ int32 ’, name $z '$ ’main input’) embedding $=$ Embedding(input dim ${ \tt 1 2 8 }$ , output dim ${ \tt 1 2 8 }$ , input length $= 7 5$ )(main input ) conv1 $=$ Conv1D( filters ${ } = 1 2 8$ , kernel size $^ { = 3 }$ , padding $= ^ { \ast }$ ’same’, strides $^ { = 1 }$ )(embedding) thresh1 $=$ ThresholdedReLU(1e−6)(conv1) max pool1 $=$ MaxPooling1D(pool size $^ { = 2 }$ , padding=’same’)(thresh1 ) conv $\ ? =$ Conv1D( filters ${ } = 1 2 8$ , kernel size $^ { = 2 }$ , padding $= ^ { \overrightarrow { } }$ ’same’, strides $^ { = 1 }$ )(max pool1) thresh2 $=$ ThresholdedReLU(1e−6)(conv2) max pool2 $=$ MaxPooling1D(pool size $^ { = 2 }$ , padding=’same’)(thresh2 ) flatten $=$ Flatten () (max pool2) fc $=$ Dense(64)( flatten ) thresh fc $=$ ThresholdedReLU(1e−6)(fc) drop $=$ Dropout(0.5) ( thresh fc ) output $=$ Dense(1, activation $= ^ { \overrightarrow { { \mathbf { \Gamma } } } }$ ’sigmoid’) (drop) model $=$ Model(inputs=main input, outputs $=$ output) model.compile( ${ \mathrm { l o s s } } = { \ ' }$ binary crossentropy ’, optimizer $= ^ { \ ' }$ adam’)
def getconvmodel( self , kernel size , filters ) : model $=$ Sequential () model.add( Conv1D( filters $=$ filters , input shape $=$ (128, 128), kernel size $=$ kernel size , padding=’same’, activation $= ^ { \ ' }$ relu ’, strides $\mathbf { \tau } = 1 \dot { }$ )) model.add(Lambda(lambda x: K.sum(x, axi $^ { - 1 }$ ), output shape $=$ ( filters , ) ) ) model.add(Dropout(0.5) ) return model
middle $=$ Dropout(0.5) (middle)
<table><tr><td rowspan=1 colspan=1>output = Dense(1,activation ='sigmoid')(middle)model = Model(inputs=main_input, outputs =output)model.compile(loss='binary_crossentropy’,optimizer='adam')</td></tr><tr><td rowspan=1 colspan=1>Listing 4: Invincea CNN model with parallel CNN layers,adapted from Saxe & Berlin (2017)</td></tr><tr><td rowspan=1 colspan=1>main_input = Input(shape=(75,),dtype=' int32’,name='main_input')embedding =Embedding(input_dim=128,output_dim=128,input_length=75)(main_input)conv = Conv1D(filters =128,kernel_size =3,padding='same',activation ='relu’,strides=1)(embedding)max_pool = MaxPooling1D(pool_size=2, padding='same')(conv)encode = LSTM(64, return_sequences=False)(max-pool)output = Dense(1, activation ='sigmoid')(encode)model= Model(inputs=main_input, outputs =output)model.compile(loss=’ binary_crossentropy’, optimizer='adam')</td></tr><tr><td rowspan=1 colspan=1>Listing 5: MIT model with a stacked CNN and LSTM layer,adapted from Vosoughi et al. (2016)</td></tr><tr><td rowspan=1 colspan=1>main_input = Input(shape=(75,),dtype=' int32’,name='main_input')embedding =Embedding(input_dim=128,output_dim=128,input_length=75)(main_input)flatten = Flatten ((embedding)output = Dense(1, activation ='sigmoid')( flatten )model = Model(inputs=main_input, outputs =output)print (model.summaryO)model.compile(loss=' binary_crossentropy’,optimizer='adam')</td></tr><tr><td rowspan=1 colspan=1>Listing 6: Baseline Model with only Embedding Layer</td></tr><tr><td rowspan=1 colspan=1>main_input = Input(shape=(11,),name='main_input')dense = Dense(128,activation ='relu ')(main_input)output = Dense(1, activation ='sigmoid')(dense)model = Model(inputs=main_input, outputs =output)print (model.summaryO)model.compile(loss='binary_crossentropy’,optimizer='adam')</td></tr></table>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599# THE INCREDIBLE SHRINKING NEURAL NETWORK: NEW PERSPECTIVES ON LEARNING REPRESENTATIONS THROUGH THE LENS OF PRUNING
Nikolas Wolfe, Aditya Sharma & Bhiksha Raj School of Computer Science Carnegie Mellon University Pittsburgh, PA 15213, USA {nwolfe, bhiksha}@cs.cmu.edu, adityasharma@cmu.edu
Lukas Drude Universitat Paderborn drude@nt.upb.de
# ABSTRACT
How much can pruning algorithms teach us about the fundamentals of learning representations in neural networks? A lot, it turns out. Neural network model compression has become a topic of great interest in recent years, and many different techniques have been proposed to address this problem. In general, this is motivated by the idea that smaller models typically lead to better generalization. At the same time, the decision of what to prune and when to prune necessarily forces us to confront our assumptions about how neural networks actually learn to represent patterns in data. In this work we set out to test several long-held hypotheses about neural network learning representations and numerical approaches to pruning. To accomplish this we first reviewed the historical literature and derived a novel algorithm to prune whole neurons (as opposed to the traditional method of pruning weights) from optimally trained networks using a second-order Taylor method. We then set about testing the performance of our algorithm and analyzing the quality of the decisions it made. As a baseline for comparison we used a first-order Taylor method based on the Skeletonization algorithm and an exhaustive brute-force serial pruning algorithm. Our proposed algorithm worked well compared to a first-order method, but not nearly as well as the brute-force method. Our error analysis led us to question the validity of many widely-held assumptions behind pruning algorithms in general and the trade-offs we often make in the interest of reducing computational complexity. We discovered that there is a straightforward way, however expensive, to serially prune $40 \%$ of the neurons in a trained network with minimal effect on the learning representation and without any re-training.
# 1 INTRODUCTION
In this work we propose and evaluate a novel algorithm for pruning whole neurons from a trained neural network without any re-training and examine its performance compared to two simpler methods. We then analyze the kinds of errors made by our algorithm and use this as a stepping off point to launch an investigation into the fundamental nature of learning representations in neural networks. Our results corroborate an insightful though largely forgotten observation by Mozer & Smolensky (1989a) concerning the nature of neural network learning. This observation is best summarized in a quotation from Segee & Carter (1991) on the notion of fault-tolerance in multilayer perceptron networks:
Contrary to the belief widely held, multilayer networks are not inherently fault tolerant. In fact, the loss of a single weight is frequently sufficient to completely disrupt a learned function approximation. Furthermore, having a large number of weights does not seem to improve fault tolerance. [Emphasis added]
Essentially, Mozer & Smolensky (1989b) observed that during training neural networks do not distribute the learning representation evenly or equitably across hidden units. What actually happens is that a few, elite neurons learn an approximation of the input-output function, and the remaining units must learn a complex interdependence function which cancels out their respective influence on the network output. Furthermore, assuming enough units exist to learn the function in question, increasing the number of parameters does not increase the richness or robustness of the learned approximation, but rather simply increases the likelihood of overfitting and the number of noisy parameters to be canceled during training. This is evinced by the fact that in many cases, multiple neurons can be removed from a network with no re-training and with negligible impact on the quality of the output approximation. In other words, there are few bipartisan units in a trained network. A unit is typically either part of the (possibly overfit) input-output function approximation, or it is part of an elaborate noise cancellation task force. Assuming this is the case, most of the compute-time spent training a neural network is likely occupied by this arguably wasteful procedure of silencing superfluous parameters, and pruning can be viewed as a necessary procedure to “trim the fat.”
We observed copious evidence of this phenomenon in our experiments, and this is the motivation behind our decision to evaluate the pruning algorithms in this study on the simple criteria of their ability to trim neurons without any re-training. If we were to employ re-training as part of our evaluation criteria, we would arguably not be evaluating the quality of our algorithm’s pruning decisions per se but rather the ability of back-propagation trained networks to recover from faults caused by non-ideal pruning decisions, as suggested by the conclusions of Segee & Carter (1991) and Mozer & Smolensky (1989a). Moreover, as Fahlman & Lebiere (1989) discuss, due to the “herd effect” and “moving target” phenomena in back-propagation learning, the remaining units in a network will simply shift course to account for whatever error signal is re-introduced as a result of a bad pruning decision or network fault. So long as there are enough critical parameters to learn the function in question, a network can typically recover faults with additional training. This limits the conclusions we can draw about the quality of our pruning criteria when we employ re-training.
In terms of removing units without re-training, what we discovered is that predicting the behavior of a network when a unit is to be pruned is very difficult, and most of the approximation techniques put forth in existing pruning algorithms do not fare well at all when compared to a brute-force search. To begin our discussion of how we arrived at our algorithm and set up our experiments, we review of the existing literature.
# 2 LITERATURE REVIEW
Pruning algorithms, as comprehensively surveyed by Reed (1993), are a useful set of heuristics designed to identify and remove elements from a neural network which are either redundant or do not significantly contribute to the output of the network. This is motivated by the observed tendency of neural networks to overfit to the idiosyncrasies of their training data given too many trainable parameters or too few input patterns from which to generalize, as stated by Chauvin (1990).
Network architecture design and hyperparameter selection are inherently difficult tasks typically approached using a few well-known rules of thumb, e.g. various weight initialization procedures, choosing the width and number of layers, different activation functions, learning rates, momentum, etc. Some of this “black art” appears unavoidable. For problems which cannot be solved using linear threshold units alone, Baum & Haussler (1989) demonstrate that there is no way to precisely determine the appropriate size of a neural network a priori given any random set of training instances. Using too few neurons seems to inhibit learning, and so in practice it is common to attempt to overparameterize networks initially using a large number of hidden units and weights, and then prune or compress them afterwards if necessary. Of course, as the old saying goes, there’s more than one way to skin a neural network.
# 2.1 NON-PRUNING BASED GENERALIZATION & COMPRESSION TECHNIQUES
The generalization behavior of neural networks has been well studied, and apart from pruning algorithms many heuristics have been used to avoid overfitting, such as dropout (Srivastava et al.
(2014)), maxout (Goodfellow et al. (2013)), and cascade correlation (Fahlman & Lebiere (1989)), among others. Of course, while cascade correlation specifically tries to construct of minimal networks, many techniques to improve network generalization do not explicitly attempt to reduce the total number of parameters or the memory footprint of a trained network per se.
Model compression often has benefits with respect to generalization performance and the portability of neural networks to operate in memory-constrained or embedded environments. Without explicitly removing parameters from the network, weight quantization allows for a reduction in the number of bytes used to represent each weight parameter, as investigated by Balzer et al. (1991), Dundar & Rose (1994), and Hoehfeld & Fahlman (1992).
A recently proposed method for compressing recurrent neural networks (Prabhavalkar et al. (2016)) uses the singular values of a trained weight matrix as basis vectors from which to derive a compressed hidden layer. Øland & Raj (2015) successfully implemented network compression through weight quantization with an encoding step while others such as Han et al. (2016) have tried to expand on this by adding weight-pruning as a preceding step to quantization and encoding.
In summary, we can say that there are many different ways to improve network generalization by altering the training procedure, the objective error function, or by using compressed representations of the network parameters. But these are not, strictly speaking, examples of techniques to reduce the number of parameters in a network. For this we must employ some form of pruning criteria.
# 2.2 PRUNING TECHNIQUES
If we wanted to continually shrink a neural network down to minimum size, the most straightforward brute-force way to do it is to individually switch each element off and measure the increase in total error on the training set. We then pick the element which has the least impact on the total error, and remove it. Rinse and repeat. This is extremely computationally expensive, given a reasonably large neural network and training set. Alternatively, we might accomplish this using any number of much faster off-the-shelf pruning algorithms, such as Skeletonization (Mozer & Smolensky (1989a)), Optimal Brain Damage (LeCun et al. (1989)), or later variants such as Optimal Brain Surgeon (Hassibi & Stork (1993)). In fact, we borrow much of our inspiration from these algorithms, with one major variation: Instead of pruning individual weights, we prune entire neurons, thereby eliminating all of their incoming and outgoing weight parameters in one go, resulting in more memory saved, faster.
The algorithm developed for this paper is targeted at reducing the total number of neurons in a trained network, which is one way of reducing its computational memory footprint. This is often a desirable criteria to minimize in the case of resource-constrained or embedded devices, and also allows us to probe the limitations of pruning down to the very last essential network elements. In terms of generalization as well, we can measure the error of the network on the test set as each element is sequentially removed from the network. With an oracle pruning algorithm, what we expect to observe is that the output of the network remains stable as the first few superfluous neurons are removed, and as we start to bite into the more crucial members of the function approximation, the error should start to rise dramatically. In this paper, the brute-force approach described at the beginning of this section serves as a proxy for an oracle pruning algorithm.
One reason to choose to rank and prune individual neurons as opposed to weights is that there are far fewer elements to consider. Furthermore, the removal of a single weight from a large network is a drop in the bucket in terms of reducing a network’s core memory footprint. If we want to reduce the size of a network as efficiently as possible, we argue that pruning neurons instead of weights is more efficient computationally as well as practically in terms of quickly reaching a hypothetical target reduction in memory consumption. This approach also offers downstream applications a realistic expectation of the minimal increase in error resulting from the removal of a specified percentage of neurons. Such trade-offs are unavoidable, but performance impacts can be limited if a principled approach is used to find the best candidate neurons for removal.
It is well known that too many free parameters in a neural network can lead to overfitting. Regardless of the number of weights used in a given network, as Segee & Carter (1991) assert, the representation of a learned function approximation is almost never evenly distributed over the hidden units, and thus the removal of any single hidden unit at random can actually result in a network fault. Mozer & Smolensky (1989b) argue that only a subset of the hidden units in a neural network actually latch on to the invariant or generalizing properties of the training inputs, and the rest learn to either mutually cancel each other’s influence or begin overfitting to the noise in the data. We leverage this idea in the current work to rank all neurons in pre-trained networks based on their effective contributions to the overall performance. We then remove the unnecessary neurons to reduce the network’s footprint. Through our experiments we not only concretely validate the theory put forth by Mozer & Smolensky (1989b) but we also successfully build on it to prune networks to 40 to 60 $\%$ of their original size without any major loss in performance.
# 3 PRUNING NEURONS TO SHRINK NEURAL NETWORKS
As discussed in Section 1 our aim is to leverage the highly non-uniform distribution of the learning representation in pre-trained neural networks to eliminate redundant neurons, without focusing on individual weight parameters. Taking this approach enables us to remove all the weights (incoming and outgoing) associated with a non-contributing neuron at once. We would like to note here that in an ideal scenario, based on the neuron interdependency theory put forward by Mozer & Smolensky (1989a), one would evaluate all possible combinations of neurons to remove (one at a time, two at a time, three at a time and so forth) to find the optimal subset of neurons to keep. This is computationally unacceptable, and so we will only focus on removing one neuron at a time and explore more “greedy” algorithms to do this in a more efficient manner.
The general approach taken to prune an optimally trained neural network here is to create a ranked list of all the neurons in the network based off of one of the 3 proposed ranking criteria: a brute force approximation, a linear approximation and a quadratic approximation of the neuron’s impact on the output of the network. We then test the effects of removing neurons on the accuracy and error of the network. All the algorithms and methods presented here are easily parallelizable as well.
One last thing to note here before moving forward is that the methods discussed in this section involve some non-trivial derivations which are beyond the scope of this paper. We are more focused on analyzing the implications of these methods on our understanding of neural network learning representations. However, a complete step-by-step derivation and proof of all the results presented is provided in the Supplementary Material as an Appendix.
# 3.1 BRUTE FORCE REMOVAL APPROACH
This is perhaps the most naive yet the most accurate method for pruning the network. It is also the slowest and hence possibly unusable on large-scale neural networks with thousands of neurons. This method explicitly evaluates each neuron in the network. The idea is to manually check the effect of every single neuron on the output. This is done by running a forward propagation on the validation set $K$ times (where $K$ is the total number of neurons in the network), turning off exactly one neuron each time (keeping all other neurons active) and noting down the change in error. Turning a neuron off can be achieved by simply setting its output to 0. This results in all the outgoing weights from that neuron being turned off. This change in error is then used to generate the ranked list.
# 3.2 TAYLOR SERIES REPRESENTATION OF ERROR
Let us denote the total error from the optimally trained neural network for any given validation dataset by $E$ . $E$ can be seen as a function of $O$ , where $O$ is the output of any general neuron in the network. This error can be approximated at a particular neuron’s output (say $O _ { k }$ ) by using the 2nd order Taylor Series as,
$$\hat { E } ( \boldsymbol { O } ) \approx E ( \boldsymbol { O } _ { k } ) + ( \boldsymbol { O } - \boldsymbol { O } _ { k } ) \cdot \left. \frac { \partial E } { \partial \boldsymbol { O } } \right| _ { \boldsymbol { O } _ { k } } + 0 . 5 \cdot ( \boldsymbol { O } - \boldsymbol { O } _ { k } ) ^ { 2 } \cdot \left. \frac { \partial ^ { 2 } E } { \partial \boldsymbol { O } ^ { 2 } } \right| _ { \boldsymbol { O } _ { k } } ,$$
When a neuron is pruned, its output $O$ becomes 0.
Replacing $O$ by $O _ { k }$ in equation 1 shows us that the error is approximated perfectly by equation 1 at $O _ { k }$ . So:
$$\Delta E _ { k } = \hat { E } ( 0 ) - \hat { E } ( O _ { k } ) = - O _ { k } \cdot \left. \frac { \partial E } { \partial O } \right| _ { O _ { k } } + 0 . 5 \cdot O _ { k } ^ { 2 } \cdot \left. \frac { \partial ^ { 2 } E } { \partial O ^ { 2 } } \right| _ { O _ { k } } ,$$
where $\Delta E _ { k }$ is the change in the total error of the network when exactly one neuron $( k )$ is turned off. Most of the terms in this equation are fairly easy to compute, as we have $O _ { k }$ already from the activations of the hidden units and we already compute $\frac { \partial E } { \partial O } \big | _ { O _ { k } } ^ { \star }$ for each training instance during backpropagation. The ∂2E∂O2 |Ok terms are a little more difficult to compute. This is derived in the appendix and summarized in the sections below.
# 3.2.1 LINEAR APPROXIMATION APPROACH
We can use equation 2 to get the linear error approximation of the change in error due to the $k$ th neuron being turned off and represent it as $\Delta E _ { k } ^ { 1 }$ as follows:
$$\Delta E _ { k } ^ { 1 } = - O _ { k } \cdot \left. \frac { \partial E } { \partial O } \right| _ { O _ { k } }$$
The derivative term above is the first-order gradient which represents the change in error with respect to the output a given neuron. This term can be collected during back-propagation. As we shall see further in this section, linear approximations are not reliable indicators of change in error but they provide us with an interesting basis for comparison with the other methods discussed in this paper.
# 3.2.2 QUADRATIC APPROXIMATION APPROACH
As above, we can use equation 2 to get the quadratic error approximation of the change in error due to the $k$ th neuron being turned off and represent it as $\Delta E _ { k } ^ { 2 }$ as follows:
$$\Delta E _ { k } ^ { 2 } = - O _ { k } \cdot \left. \frac { \partial E } { \partial O } \right| _ { O _ { k } } + 0 . 5 \cdot O _ { k } ^ { 2 } \cdot \left. \frac { \partial ^ { 2 } E } { \partial O ^ { 2 } } \right| _ { O _ { k } }$$
The additional second-order gradient term appearing above represents the quadratic change in error with respect to the output of a given neuron. This term can be generated by performing backpropagation using second order derivatives. Collecting these quadratic gradients involves some non-trivial mathematics, the entire step-by-step derivation procedure of which is provided in the Supplementary Material as an Appendix.
# 3.3 PROPOSED PRUNING ALGORITHM
Figure 1 shows a random error function plotted against the output of any given neuron. Note that this figure is for illustration purposes only. The error function is minimized at a particular value of the neuron output as can be seen in the figure. The process of training a neural network is essentially the process of finding these minimizing output values for all the neurons in the network. Pruning this particular neuron (which translates to getting a zero output from it will result in a change in the total overall error. This change in error is represented by distance between the original minimum error (shown by the dashed line) and the top red arrow. This neuron is clearly a bad candidate for removal since removing it will result in a huge error increase.
The straight red line in the figure represents the first-order approximation of the error using Taylor Series as described before while the parabola represents a second-order approximation. It can be clearly seen that the second-order approximation is a much better estimate of the change in error.
One thing to note here is that it is possible in some cases that there is some thresholding required when trying to approximate the error using the 2nd order Taylor Series expansion. These cases might arise when the parabolic approximation undergoes a steep slope change. To take into account such cases, mean and median thresholding were employed, where any change above a certain threshold was assigned a mean or median value respectively.
 Figure 1: The intuition behind 1st & 2nd order neuron pruning decisions
Two pruning algorithms are proposed here. They are different in the way the neurons are ranked but both of them use $\Delta E _ { k }$ , the approximation of the change in error as the basis for the ranking. $\Delta E _ { k }$ can be calculated using the Brute Force method, or one of the two Taylor Series approximations discussed previously.
The first step in both the algorithms is to decide a stopping criterion. This can vary depending on the application but some intuitive stopping criteria can be: maximum number of neurons to remove, percentage scaling needed, maximum allowable accuracy drop etc.
# 3.3.1 ALGORITHM I: SINGLE OVERALL RANKING
The complete algorithm is shown in Algorithm 1. The idea here is to generate a single ranked list based on the values of $\Delta E _ { k }$ . This involves a single pass of second-order back-propagation (without weight updates) to collect the gradients for each neuron. The neurons from this rank-list (with the lowest values of $\Delta E _ { k }$ ) are then pruned according to the stopping criterion decided. We note here that this algorithm is intentionally naive and is used for comparison only.
Data: optimally trained network, training set Result: A pruned network initialize and define stopping criterion ; perform forward propagation over the training set ; perform second-order back-propagation without updating weights and collect linear and quadratic gradients ; rank the remaining neurons based on $\Delta E _ { k }$ ; while stopping criterion is not met do remove the last ranked neuron ; end
Algorithm 1: Single Overall Ranking
# 3.3.2 ALGORITHM II: ITERATIVE RE-RANKING
In this greedy variation of the algorithm (Algorithm 2), after each neuron removal, the remaining network undergoes a single forward and backward pass of second-order back-propagation (without weight updates) and the rank list is formed again. Hence, each removal involves a new pass through the network. This method is computationally more expensive but takes into account the dependencies the neurons might have on one another which would lead to a change in error contribution every time a dependent neuron is removed.
Data: optimally trained network, training set Result: A pruned network initialize and define stopping criterion ; while stopping criterion is not met do perform forward propagation over the training set ; perform second-order back-propagation without updating weights and collect linear and quadratic gradients ; rank the remaining neurons based on $\Delta E _ { k }$ ; remove the worst neuron based on the ranking ; end
Algorithm 2: Iterative Re-Ranking
# 4 EXPERIMENTAL RESULTS
# 4.1 EXAMPLE REGRESSION PROBLEM
This problem serves as a quick example to demonstrate many of the phenomena described in previous sections. We trained two networks to learn the cosine function, with one input and one output. This is a task which requires no more than 11 sigmoid neurons to solve entirely, and in this case we don’t care about overfitting because the cosine function has a precise definition. Furthermore, the cosine function is a good toy example because it is a smooth continuous function and, as demonstrated by Nielsen (2015), if we were to tinker directly with the weights and bias parameters of the network, we could allocate individual units within the network to be responsible for constrained ranges of inputs, similar to a basis spline function with many control points. This would distribute the learned function approximation evenly across all hidden units, and thus we have presented the network with a problem in which it could productively use as many hidden units as we give it. In this case, a pruning algorithm would observe a fairly consistent increase in error after the removal of each successive unit. In practice however, regardless of the number of experimental trials, this is not what happens. The network will always use 10-11 hidden units and leave the rest to cancel each other’s influence.
 Figure 2: Degradation in squared error after pruning a two-layer network trained to compute the cosine function (Left Network: 2 layers, 10 neurons each, 1 output, logistic sigmoid activation, starting test accuracy: 0.9999993, Right Network: 2 layers, 50 neurons each, 1 output, logistic sigmoid activation, starting test accuracy: 0.9999996)
Figure 2 shows two graphs. Both graphs demonstrate the use of the iterative re-ranking algorithm and the comparative performance of the brute-force pruning method (in blue), the first order method (in green), and the second order method (in red). The graph on the left shows the performance of these algorithms starting from a network with two layers of 10 neurons (20 total), and the graph on the right shows a network with two layers of 50 neurons (100 total).
In the left graph, we see that the brute-force method shows a graceful degradation, and the error only begins to rise sharply after $50 \%$ of the total neurons have been removed. The error is basically constant up to that point. In the first and second order methods, we see evidence of poor decision making in the sense that both made mistakes early on, which disrupted the output function approximation. The first order method made a large error early on, though we see after a few more neurons were removed this error was corrected somewhat (though it only got worse from there). This is direct evidence of the lack of fault tolerance in a trained neural network. This phenomenon is even more starkly demonstrated in the second order method. After making a few poor neuron removal decisions in a row, the error signal rose sharply, and then went back to zero after the 6th neuron was removed. This is due to the fact that the neurons it chose to remove were trained to cancel each others’ influence within a localized part of the network. After the entire group was eliminated, the approximation returned to normal. This can only happen if the output function approximation is not evenly distributed over the hidden units in a trained network.
This phenomenon is even more starkly demonstrated in the graph on the right. Here we see the first order method got “lucky” in the beginning and made decent decisions up to about the 40th removed neuron. The second order method had a small error in the beginning which it recovered from gracefully and proceeded to pass the 50 neuron point before finally beginning to unravel. The brute force method, in sharp contrast, shows little to no increase in error at all until $90 \%$ of the neurons in the network have been obliterated. Clearly first and second order methods have some value in that they do not make completely arbitrary choices, but the brute force method is far better at this task.
This also demonstrates the sharp dualism in neuron roles within a trained network. These networks were trained to near-perfect precision and each pruning method was applied without any re-training of any kind. Clearly, in the case of the brute force or oracle method, up to $90 \%$ of the network can be completely extirpated before the output approximation even begins to show any signs of degradation. This would be impossible if the learning representation were evenly or equitably distributed. Note, for example, that the degradation point in both cases is approximately the same. This example is not a real-world application of course, but it brings into very clear focus the kind of phenomena we will discuss in the following sections.
# 4.2 RESULTS ON MNIST DATASET
For all the results presented in this section, the MNIST database of Handwritten Digits by LeCun & Cortes (2010) was used. It is worth noting that due to the time taken by the brute force algorithm we rather used a 5000 image subset of the MNIST database in which we have normalized the pixel values between 0 and 1.0, and compressed the image sizes to $2 0 \mathrm { x } 2 0$ images rather than $2 8 \mathbf { x } 2 8$ , so the starting test accuracy reported here appears higher than those reported by LeCun et al. We do not believe that this affects the interpretation of the presented results because the basic learning problem does not change with a larger dataset or input dimension.
# 4.3 PRUNING A 1-LAYER NETWORK
The network architecture in this case consisted of 1 layer, 100 neurons, 10 outputs, logistic sigmoid activations, and a starting test accuracy of 0.998.
# 4.3.1 SINGLE OVERALL RANKING ALGORITHM
We first present the results for a single-layer neural network in Figure 3, using the Single Overall algorithm (Algorithm 1) as proposed in Section 3. (We again note that this algorithm is intentionally naive and is used for comparison only. Its performance should be expected to be poor.) After training, each neuron is assigned its permanent ranking based on the three criteria discussed previously: A brute force “ground truth” ranking, and two approximations of this ranking using first and second order Taylor estimations of the change in network output error resulting from the removal of each neuron.
An interesting observation here is that with only a single layer, no criteria for ranking the neurons in the network (brute force or the two Taylor Series variants) using Algorithm 1 emerges superior, indicating that the 1st and 2nd order Taylor Series methods are actually reasonable approximations of the brute force method under certain conditions. Of course, this method is still quite bad in terms of the rate of degradation of the classification accuracy and in practice we would likely follow Algorithm 2 which is takes into account Mozer & Smolensky (1989a)’s observations stated in the Related Work section. The purpose of the present investigation, however, is to demonstrate how much of a trained network can be theoretically removed without altering the network’s learned parameters in any way.
 Figure 3: Degradation in squared error (left) and classification accuracy (right) after pruning a single-layer network using The Single Overall Ranking algorithm (Network: 1 layer, 100 neurons, 10 outputs, logistic sigmoid activation, starting test accuracy: 0.998)
 4.3.2 ITERATIVE RE-RANKING ALGORITHM Figure 4: Degradation in squared error (left) and classification accuracy (right) after pruning a single-layer network the iterative re-ranking algorithm (Network: 1 layer, 100 neurons, 10 outputs, logistic sigmoid activation, starting test accuracy: 0.998)
In Figure 4 we present our results using Algorithm 2 (The iterative re-ranking Algorithm) in which all remaining neurons are re-ranked after each successive neuron is switched off. We compute the same brute force rankings and Taylor series approximations of error deltas over the remaining active neurons in the network after each pruning decision. This is intended to account for the effects of cancelling interactions between neurons.
There are 2 key observations here. Using the brute force ranking criteria, almost $60 \%$ of the neurons in the network can be pruned away without any major loss in performance. The other noteworthy observation here is that the 2nd order Taylor Series approximation of the error performs consistently better than its 1st order version, in most situations, though Figure 21 is a poignant counter-example.
# 4.3.3 VISUALIZATION OF ERROR SURFACE & PRUNING DECISIONS
As explained in Section 3, these graphs are a visualization of the error surface of the network output with respect to the neurons chosen for removal using each of the 3 ranking criteria, represented in intervals of 10 neurons. In each graph, the error surface of the network output is displayed in log space (left) and in real space (right) with respect to each candidate neuron chosen for removal. We create these plots during the pruning exercise by picking a neuron to switch off, and then multiplying its output by a scalar gain value $\alpha$ which is adjusted from 0.0 to 10.0 with a step size of 0.001. When the value of $\alpha$ is 1.0, this represents the unperturbed neuron output learned during training. Between 0.0 and 1.0, we are graphing the literal effect of turning the neuron off $( \alpha = 0$ ), and when $\alpha > 1 . 0$ we are simulating a boosting of the neuron’s influence in the network, i.e. inflating the value of its outgoing weight parameters.
We graph the effect of boosting the neuron’s output to demonstrate that for certain neurons in the network, even doubling, tripling, or quadrupling the scalar output of the neuron has no effect on the overall error of the network, indicating the remarkable degree to which the network has learned to ignore the value of certain parameters. In other cases, we can get a sense of the sensitivity of the network’s output to the value of a given neuron when the curve rises steeply after the red 1.0 line. This indicates that the learned value of the parameters emanating from a given neuron are relatively important, and this is why we should ideally see sharper upticks in the curves for the later-removed neurons in the network, that is, when the neurons crucial to the learning representation start to be picked off. Some very interesting observations can be made in each of these graphs.
Remember that lower is better in terms of the height of the curve and minimal (or negative) horizontal change between the vertical red line at 1.0 (neuron on, $\alpha = 1 . 0$ ) and 0.0 (neuron off, $\alpha = 0 . 0$ ) is indicative of a good candidate neuron to prune, i.e. there will be minimal effect on the network output when the neuron is removed.
 4.3.4 VISUALIZATION OF BRUTE FORCE PRUNING DECISIONS Figure 5: Error surface of the network output in log space (left) and real space (right) with respect to each candidate neuron chosen for removal using the brute force criterion; (Network: 1 layer, 100 neurons, 10 outputs, logistic sigmoid activation, starting test accuracy: 0.998)
In Figure ??, we notice how low to the floor and flat most of the curves are. It’s only until the 90th removed neuron that we see a higher curve with a more convex shape (clearly a more sensitive, influential piece of the network).
# 4.3.5 VISUALIZATION OF 1ST ORDER APPROXIMATION PRUNING DECISIONS
It can be seen in Figure 6 that most choices seem to have flat or negatively sloped curves, indicating that the first order approximation seems to be pretty good, but examining the brute force choices shows they could be better.
# 4.3.6 VISUALIZATION OF 2ND ORDER APPROXIMATION PRUNING DECISIONS
The method in Figure 7 looks similar to the brute force method choices, though clearly not as good (they’re more spread out). Notice the difference in convexity between the 2nd and 1st order method
 Figure 6: Error surface of the network output in log space (left) and real space (right) with respect to each candidate neuron chosen for removal using the 1st order Taylor Series error approximation criterion; (Network: 1 layer, 100 neurons, 10 outputs, logistic sigmoid activation, starting test accuracy: 0.998)
 Figure 7: Error surface of the network output in log space (left) and real space (right) with respect to each candidate neuron chosen for removal using the 2nd order Taylor Series error approximation criterion; (Network: 1 layer, 100 neurons, 10 outputs, logistic sigmoid activation, starting test accuracy: 0.998)
choices. It’s clear that the first order method is fitting a line and the 2nd order method is fitting a parabola in their approximation.
# 4.4 PRUNING A 2-LAYER NETWORK
The network architecture in this case consisted of 2 layers, 50 neurons per layer, 10 outputs, logistic sigmoid activations, and a starting test accuracy of 1.000.
# 4.4.1 SINGLE OVERALL RANKING ALGORITHM
Figure 8 shows the pruning results for Algorithm 1 on a 2-layer network. The ranking procedure is identical to the one used to generate Figure 3. (We again note that this algorithm is intentionally naive and is used for comparison only. Its performance should be expected to be poor.)
Unsurprisingly, a 2-layer network is harder to prune because a single overall ranking will never capture the interdependencies between neurons in different layers. It makes sense that this is worse
 Figure 8: Degradation in squared error (left) and classification accuracy (right) after pruning a 2- layer network using the Single Overall Ranking algorithm; (Network: 2 layers, 50 neurons/layer, 10 outputs, logistic sigmoid activation, starting test accuracy: 1.000)
than the performance on the 1-layer network, even if this method is already known to be bad, and we’d likely never use it in practice.
# 4.4.2 ITERATIVE RE-RANKING ALGORITHM
 Figure 9: Degradation in squared error (left) and classification accuracy (right) after pruning a 2- layer network using the iterative re-ranking algorithm; (Network: 2 layers, 50 neurons/layer, 10 outputs, logistic sigmoid activation, starting test accuracy: 1.000)
Figure 9 shows the results from using Algorithm 2 on a 2-layer network. We compute the same brute force rankings and Taylor series approximations of error deltas over the remaining active neurons in the network after each pruning decision used to generate Figure 4. Again, this is intended to account for the effects of cancelling interactions between neurons.
It is clear that it becomes harder to remove neurons 1-by-1 with a deeper network (which makes sense because the neurons have more interdependencies in a deeper network), but we see an overall better performance with 2nd order method vs. 1st order, except for the first $20 \%$ of the neurons (but this doesn’t seem to make much difference for classification accuracy.)
Perhaps a more important observation here is that even with a more complex network, it is possible to remove up to $40 \%$ of the neurons with no major loss in performance which is clearly illustrated by the brute force curve. This shows the clear potential of an ideal pruning technique and also shows how inconsistent 1st and 2nd order Taylor Series approximations of the error can be as ranking criteria.
# 4.4.3 VISUALIZATION OF ERROR SURFACE & PRUNING DECISIONS
As seen in the case of a single layered network, these graphs are a visualization the error surface of the network output with respect to the neurons chosen for removal using each algorithm, represented in intervals of 10 neurons.
 4.4.4 VISUALIZATION OF BRUTE FORCE PRUNING DECISIONS Figure 10: Error surface of the network output in log space (left) and real space (right) with respect to each candidate neuron chosen for removal using the brute force criterion; (Network: 2 layers, 50 neurons/layer, 10 outputs, logistic sigmoid activation, starting test accuracy: 1.000)
In Figure 10, it is clear why these neurons got chosen, their graphs clearly show little change when neuron is removed, are mostly near the floor, and show convex behaviour of error surface, which argues for the rationalization of using 2nd order methods to estimate difference in error when they are turned off.
 4.4.5 VISUALIZATION OF 1ST ORDER APPROXIMATION PRUNING DECISIONS Figure 11: Error surface of the network output in log space (left) and real space (right) with respect to each candidate neuron chosen for removal using the 1st order Taylor Series error approximation criterion; (Network: 2 layers, 50 neurons/layer, 10 outputs, logistic sigmoid activation, starting test accuracy: 1.000)
Drawing a flat line at the point of each neurons intersection with the red vertical line (no change in gain) shows that the 1st derivative method is actually accurate for estimation of change in error in these cases, but still ultimately leads to poor decisions.
 Figure 12: Error surface of the network output in log space (left) and real space (right) with respect to each candidate neuron chosen for removal using the 2nd order Taylor Series error approximation criterion; (Network: 2 layers, 50 neurons/layer, 10 outputs, logistic sigmoid activation, starting test accuracy: 1.000)
Clearly these neurons are not overtly poor candidates for removal (error doesn’t change much between 1.0 & zero-crossing left-hand-side), but could be better (as described above in the brute force Criterion discussion).
# 4.5 INVESTIGATION OF PRUNING PERFORMANCE WITH IMPERFECT STARTING CONDITIONS
In our experiments thus far we have tacitly assumed that we start with a network which has learned an “optimal” representation of the training objective, i.e. it has been trained to the point where we accept its performance on the test set. Here we explore what happens when we prune with a sub-optimal starting network.
If the assumptions of this paper regarding the nature of neural network learning are correct, we expect that two processes are essentially at work during back-propagation training. First, we expect that the neurons which directly participate in the fundamental learning representation (even if redundantly) work together to reduce error on the training data. Second, we expect that neurons which do not directly participate in the learning representation work to cancel each other’s negative influence. Furthermore, we expect that these two groups are essentially distinct, as evinced by the fact that multiple neurons can often be removed as a group with little to no effect on the network output. Some non-trivial portion of the training time, then, is spent doing work which has nothing intrinsically to do with the learning representation and essentially functions as noise cancellation.
If this is the case, when we attempt to prune a network which has not fully canceled the noisy influence of extraneous or redundant units, we might expect to see the error actually improve after removing a few bad apples. This is in fact what we observe, as demonstrated in the following experiments.
For each experiment in this section we trained with the full MNIST training set (LeCun & Cortes (2010)), uncompressed and without any data normalization. We trained three different networks to learn to distinguish a single handwritten digit from the rest of the data. The network architectures were each composed of 784 inputs, 1 hidden layer with 100 neurons, and 2 soft-max outputs; one to say yes, and the other to say no. These networks were trained to distinguish the digits 0, 1, and 2, and their respective starting accuracies were a sub-optimal 0.9757, 0.9881, and 0.9513. Finally, we only consider the iterative re-ranking algorithm, as the single overall ranking algorithm is clearly nonviable.
# 4.5.1 MNIST SINGLE DIGIT CLASSIFICATION: DIGIT 0
Figure 13 shows the degradation in squared error after removing neurons from a network trained to distinguish the digit 0. What we observe is that the first and second order methods both fail in different ways, though clearly the second order method makes better decisions overall. The first order method explodes spectacularly in the first few iterations. The brute force method, in stark contrast, actually improves in the first few iterations, and remains essentially flat until around the $60 \%$ mark, at which point it begins to gradually increase and meet the other curves.
 Figure 13: Degradation in squared error after pruning a single-layer network trained to do a oneversus-all classification of the digit 0 using the iterative re-ranking algorithm
The behavior of the brute force method here demonstrates that the network was essentially working to cancel the effect of a few bad neurons when the training convergence criteria were met, i.e. the network was no longer able to make progress on the training set. After removing these neurons during pruning, the output improved. We can investigate this by looking at the error surface with respect to the neurons chosen for removal by each method in turn. Below in Figure 14 is the graph of the brute force method.
 Figure 14: Error surface of the network output in log space (left) and real space (right) with respect to each candidate neuron chosen for removal using the brute force iterative re-ranking removal criterion
Figure 14 shows an interesting phenomenon, which we will see in later experiments as well. The high blue curve corresponding to neuron 0 is negatively sloped in the beginning and clearly after removing this neuron, the output will improve. The rest of the curves, in correspondence with the squared error degradation curve above, are mostly flat and tightly layered together, indicating that they are good neurons to remove.
In Figure 15 below, we observe a stark contrast to this. The curves corresponding to neurons 0 and 10 are mostly flat, and fairly lower than the rest, though clearly a mistake was made early on and the rest of the curves are clearly bad choices. In all of these cases however, we see that the curves are easily approximated with a straight line and so the first order method may have been fairly accurate in its predictions, even though it still made poor decisions.
 Figure 15: Error surface of the network output in log space (left) and real space (right) with respect to each candidate neuron chosen for removal using the first-order iterative re-ranking removal criterion
Figure 15 is an example of how things can go south once a few bad mistakes are made at the outset. Figure 16 shows a much better set of choices made by the second order method, though clearly not as good as the brute force method. The log-space plots make it a bit easier to see the difference between the brute force and second order methods in Figures 14 and 16, respectively.
 Figure 16: Error surface of the network output in log space (left) and real space (right) with respect to each candidate neuron chosen for removal using the second-order iterative re-ranking removal criterion
# 4.5.2 MNIST SINGLE DIGIT CLASSIFICATION: DIGIT 1
Examining Figure 17, we see a much starker example of the previous phenomenon, in which the brute force method continues to improve the performance of the network after removing $80 \%$ of the neurons in the network. The first and second order methods fail early and proceed in fits and starts (clearly demonstrating evidence of interrelated groups of noise-canceling neurons), and never fully recover. It should be noted that it would be impossible to see curves like this if neural networks evenly distributed the learning representation evenly or equitably over their hidden units.
One of the most striking things about the blue curve in Figure 17 is the fact that the network never drops below its starting error until it crosses the $80 \%$ mark, indicating that only $20 \%$ of the neurons in this network are actually essential to the learning the training objective. In this sense, we can only wonder how much of the training time was spent winnowing the error out of the remaining $80 \%$ of the network.
 Figure 17: Degradation in squared error after pruning a single-layer network trained to do a oneversus-all classification of the digit 1 using the iterative re-ranking algorithm
 Figure 18: Error surface of the network output in log space (left) and real space (right) with respect to each candidate neuron chosen for removal using the brute force iterative re-ranking removal criterion
In Figures 18, 19 and 20 we can examine the choices made by the respective methods. The brute force method serves as our example of a near-optimal pruning regimen, and the rest are first and second order approximations of this. Small differences, clearly, can lead to large effects on the network output as shown in Figure 17.
# 4.5.3 MNIST SINGLE DIGIT CLASSIFICATION: DIGIT 2
Figure 21 is an interesting case because it shatters our confidence in the reliability of the second order method to make good pruning decisions, and further demonstrates the phenomenon of how much the error can improve if the right neurons are removed after training gets stuck. In this case, though still a poor performance overall, the first order method vastly outperforms the second order method.
Figure 22 shows us a clear example of the first element to remove having a negative error slope, and improving the output as a result. The rest of the pruning decisions are reasonable. Comparing with the blue curve in Figure 21, we see the correspondence between the first pruning decision improving the output, and the remaining pruning decisions keeping the output fairly flat. Clearly, however, there isn’t much room to get worse given our starting point with a sub-optimal network, and we see that the ending sum of squared errors is not much higher than the starting point. At the same time, we can still see the contrast in performance if we make optimal pruning decisions, and most of the neurons in this network were clearly doing nothing.
 Figure 19: Error surface of the network output in log space (left) and real space (right) with respect to each candidate neuron chosen for removal using the first-order iterative re-ranking removal criterion
 Figure 20: Error surface of the network output in log space (left) and real space (right) with respect to each candidate neuron chosen for removal using the second-order iterative re-ranking removal criterion
 Figure 21: Degradation in squared error after pruning a single-layer network trained to do a oneversus-all classification of the digit 2 using the iterative re-ranking algorithm
In Figure 23, we see a mixed bag in which the decisions are clearly sub-optimal, though much better than Figure 24, in which we can observe how a bad first decision essentially ruined the network for good. The jagged edges of the red curve in Figure 21 correspond with the positive and negative slopes of the cluster of bad pruning decisions in 24. Once again, these are not necessarily bad decisions, but the starting point is already bad and this cannot be recovered without re-training the network.
 Figure 22: Error surface of the network output in log space (left) and real space (right) with respect to each candidate neuron chosen for removal using the brute force iterative re-ranking removal criterion
 Figure 23: Error surface of the network output in log space (left) and real space (right) with respect to each candidate neuron chosen for removal using the first-order iterative re-ranking removal criterion
# 4.5.4 ASIDE: IMPLICATIONS OF THIS EXPERIMENT
From the three examples above, we see that in each case, starting from a sub-optimal network, a brute force removal technique consistently improves performance for the first few pruning iterations, and the sum of squared errors does not degrade beyond the starting point until around $60 \%$ of the neurons have been removed. This is only possible if we have an essentially strict dichotomy between the roles of different neurons during training. If the network needs only $20 \%$ of the neurons it began with, the training process is essentially dominated by the task of canceling the residual noise of redundant neurons. Furthermore, the network can get stuck in training with redundant units and distort the final output. This is strong evidence of our thesis that the learning representation is neither equitably nor evenly distributed and that most of the neurons which do not directly participate in the learning representation can be removed without any retraining.
# 4.6 EXPERIMENTS ON TOY DATASETS
As can be seen from the experiments on MNIST, even though the 2nd-order approximation criterion is consistently better than 1st-order, its performance is not nearly as good as brute force based ranking, especially beyond the first layer. What is interesting to note is that from some other experiments conducted on toy datasets (predicting whether a given point would lie inside a given shape on the Cartesian plane), the performance of the 2nd-order method was found to be exceptionally good and produced results very close to the brute force method. The 1st-order method, as expected, performed poorly here as well. Some of these results are illustrated in Figure 25.
 Figure 24: Error surface of the network output in log space (left) and real space (right) with respect to each candidate neuron chosen for removal using the second-order iterative re-ranking removal criterion
 Figure 25: Degradation in squared error (left) and classification accuracy (right) after pruning a 2- layer network using the iterative re-ranking algorithm on a toy “diamond” shape dataset (top) and a toy “random shape” dataset (below); (Network: 2 layers, 50 neurons/layer, 10 outputs, logistic sigmoid activation, starting test accuracy: 0.992(diamond); 0.986(random shape)
# 5 CONCLUSIONS & FUTURE WORK
In conclusion, we must first re-assert that we do not present this work as a bench-marking study of the algorithm we derived and tested. We have merely used this algorithm as a jumping off point to investigate the nature of learning representations in neural networks. What we discovered is that first and second order methods do not make particularly good pruning decisions, and can get hopelessly lost after making a bad pruning decision resulting in a network fault. Furthermore, the brute-force algorithm does surprisingly well, despite being computationally expensive. This method does so well in fact, we argue that further investigation is warranted to make this algorithm computationally tractable, though we do not speculate on how that should be done here.
We also observed strong evidence for the hypotheses of Mozer & Smolensky (1989a) regarding the “dualist” nature of hidden units, i.e. that learning representations are divided between units which either participate in the output approximation or learn to cancel each others influence. This suggests that neural networks may in fact learn a minimal network implicitly, though we cannot say for sure that this is the case without further investigation. A necessary experiment to this end would be to compare the size of network constructed using cascade correlation (Fahlman & Lebiere (1989)) and compare it to the results described herein.
We have presented a novel algorithm for pruning whole neurons from a trained neural network using a second-order Taylor series approximation of the change in error resulting from the removal a given neuron as a pruning criteria. We compared this method to a first order method and a bruteforce serial removal method which exhaustively found the next best single neuron to remove at each stage. Our algorithm relies on a combination of assumptions similar to the ones made by Mozer & Smolensky (1989a) and LeCun et al. (1989) in the formulation of the Skeletonization and Optimal Brain Damage algorithms.
First, we assumed that the error function with respect to each individual neuron can be approximated with a straight line or more precisely with a parabola. Second, for second derivative terms we consider only the diagonal elements of the Hessian matrix, i.e. we assume that each neuron-weight connection can be treated independently of the other elements in the network. Third, we assumed that pruning could be done in a serial fashion in which we find the single least productive element in the network, remove it, and move on. We found that all of these assumptions are deeply flawed in the sense that the true relevance of a neuron can only be partially approximated by a first or second order method, and only at certain stages of the pruning process.
For most problems, these methods can usually remove between $10 { - } 3 0 \%$ of the neurons in a trained network, but beyond this point their reliability breaks down. For certain problems, none of the described methods seem to perform very well, though for obvious reasons the brute-force method always exhibits the best results. The reason for this is that the error function with respect to each hidden unit is more complex than a simple second-order Taylor series can approximate. Furthermore, we have not directly taken into account the interdependence of elements within a network, though the work of Hassibi & Stork (1993) could provide some guidance in this regard. This is another critical issue to investigate in the future.
Re-training may help in this regard. We freely admit that our algorithm does not use re-training to recover from errors made in pruning decisions. We argue that evaluating a network pruning algorithm using re-training does not allow us to make fair comparisons between the kinds of decisions made by these algorithms. Neural networks are very good at recovering from the removal of individual elements with re-training and so this compensates for sub-optimal pruning criteria.
We have observed that pruning whole neurons from an optimally trained network without major loss in performance is not only possible but also enables compressing networks to $40 \%$ of their original size, which is of great importance in constrained memory environments like embedded devices. We cite the results of our experiments using the brute force criterion as evidence of this conclusion. However expensive, it would be extremely easy to parallelize this method, or potentially approximate it using a subset of the training data to decide which neurons to prune. This avoids the problem of trying to approximate the importance of a unit and potentially making a mistake.
It would also be interesting to see how these methods perform on deeper networks and on some other popular and real world datasets. In our case, on the MNIST dataset, we observed that it was more difficult to prune neurons from a deeper network than from one with a single layer. We should expect this trend to continue as networks get deeper and deeper, which also calls into further question the reliability of the described first and second order methods. We did investigate the order in which neurons were plucked from each layer of the networks and we found that the brute force method primarily removes neurons from the deepest layer of the network first, but there was no obvious pattern in layer preference for the other two methods.
Our experiments using the visualization of error surfaces and pruning decisions concretely establish the fact that not all neurons in a network contribute to its performance in the same way, and the observed complexity of these functions demonstrates limitations of the approximations we used.
Finally, we encourage the readers of this work to take these results into consideration when making decisions as to which methods to use to improve network generalization or compress their models. It should be remembered that various heuristics may perform well in practice for reasons which are in fact orthogonal to the accepted justifications given by their proponents.
# REFERENCES
Wolfgang Balzer, Masanobu Takahashi, Jun Ohta, and Kazuo Kyuma. Weight quantization in boltzmann machines. Neural Networks, 4(3):405–409, 1991.
Eric B Baum and David Haussler. What size net gives valid generalization? Neural computation, 1 (1):151–160, 1989.
Yves Chauvin. Generalization performance of overtrained back-propagation networks. In Neural Networks, pp. 45–55. Springer, 1990.
Gunhan Dundar and Kenneth Rose. The effects of quantization on multilayer neural networks. IEEE transactions on neural networks/a publication of the IEEE Neural Networks Council, 6(6): 1446–1451, 1994.
Scott E Fahlman and Christian Lebiere. The cascade-correlation learning architecture. 1989.
Ian J Goodfellow, David Warde-Farley, Mehdi Mirza, Aaron Courville, and Yoshua Bengio. Maxout networks. arXiv preprint arXiv:1302.4389, 2013.
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.00149v5, 2016.
Babak Hassibi and David G Stork. Second order derivatives for network pruning: Optimal brain surgeon. Morgan Kaufmann, 1993.
Markus Hoehfeld and Scott E Fahlman. Learning with limited numerical precision using the cascade-correlation algorithm. IEEE Transactions on Neural Networks, 3(4):602–611, 1992.
Yann LeCun and Corinna Cortes. MNIST handwritten digit database. 2010.
Yann LeCun, John S Denker, Sara A Solla, Richard E Howard, and Lawrence D Jackel. Optimal brain damage. In NIPs, volume 89, 1989.
Michael C Mozer and Paul Smolensky. Skeletonization: A technique for trimming the fat from a network via relevance assessment. In Advances in neural information processing systems, pp. 107–115, 1989a.
Michael C Mozer and Paul Smolensky. Using relevance to reduce network size automatically. Connection Science, 1(1):3–16, 1989b.
Michael A Nielsen. Neural networks and deep learning. http://neuralnetworksanddeeplearning.com/chap4.html.(visited: 01.11. 2014), 2015.
URL:
Anders Øland and Bhiksha Raj. Reducing communication overhead in distributed learning by an order of magnitude (almost). In IEEE International Conference on Acoustics, Speech and Signal Processing, pp. 2219–2223, 2015.
Rohit Prabhavalkar, Ouais Alsharif, Antoine Bruguier, and Lan McGraw. On the compression of recurrent neural networks with an application to lvcsr acoustic modeling for embedded speech recognition. In 2016 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 5970–5974. IEEE, 2016.
Russell Reed. Pruning algorithms-a survey. Neural Networks, IEEE Transactions on, 4(5):740–747, 1993.
Bruce E Segee and Michael J Carter. Fault tolerance of pruned multilayer networks. In Neural Networks, 1991., IJCNN-91-Seattle International Joint Conference on, volume 2, pp. 447–452. IEEE, 1991.
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.
# APPENDIX
# A SECOND DERIVATIVE BACK-PROPAGATION
 Figure 26: A computational graph of a simple feed-forward network illustrating the naming of different variables, where $\sigma ( \cdot )$ is the nonlinearity, MSE is the mean-squared error cost function and $E$ is the overall loss.
Name and network definitions:
$$E = { \frac { 1 } { 2 } } \sum _ { i } ( o _ { i } ^ { ( 0 ) } - t _ { i } ) ^ { 2 } \quad o _ { i } ^ { ( m ) } = \sigma ( x _ { i } ^ { ( m ) } ) \quad x _ { i } ^ { ( m ) } = \sum _ { j } w _ { j i } ^ { ( m ) } o _ { j } ^ { ( m + 1 ) } \quad c _ { j i } ^ { ( m ) } = w _ { j i } ^ { ( m ) } o _ { j } ^ { ( m + 1 ) }$$
Superscripts represent the index of the layer of the network in question, with 0 representing the output layer. $E$ is the squared-error network cost function. $o _ { i } ^ { ( m ) }$ is the $i$ th output in layer $m$ generated by the activation function $\sigma$ , which in this paper is is the standard logistic sigmoid . x(m)i i s the weighted sumneuron in the puts to the ith neuron in the layer to the input of the ith $m$ th layer, and ron in the m $c _ { j i } ^ { ( m ) }$ is the contribution of the er. $j$ th $m + 1$
# A.1 FIRST AND SECOND DERIVATIVES
The first and second derivatives of the cost function with respect to the outputs:
$$\frac { \partial E } { \partial o _ { i } ^ { ( 0 ) } } = o _ { i } ^ { ( 0 ) } - t _ { i }$$
$$\frac { \partial ^ { 2 } E } { \partial o _ { i } ^ { ( 0 ) ^ { 2 } } } = 1$$
The first and second derivatives of the sigmoid function in forms depending only on the output:
$$\begin{array} { l } { { \sigma ^ { \prime } ( x ) = \sigma ( x ) \left( 1 - \sigma ( x ) \right) } } \\ { { \sigma ^ { \prime \prime } ( x ) = \sigma ^ { \prime } ( x ) \left( 1 - 2 \sigma ( x ) \right) } } \end{array}$$
The second derivative of the sigmoid is easily derived from the first derivative:
$${ \begin{array} { l } { \displaystyle \sigma ^ { \prime } ( x ) = \sigma ( x ) \left( 1 - \sigma ( x ) \right) } \\ { \displaystyle \sigma ^ { \prime \prime } ( x ) = { \frac { \mathrm { d } } { \mathrm { d } x } } { \frac { \sigma ( x ) } { f ( x ) } } { \frac { \left( 1 - \sigma ( x ) \right) } { g ( x ) } } } \\ { \displaystyle \sigma ^ { \prime \prime } ( x ) = f ^ { \prime } ( x ) g ( x ) + f ( x ) g ^ { \prime } ( x ) } \\ { \displaystyle \sigma ^ { \prime \prime } ( x ) = \sigma ^ { \prime } ( x ) \left( 1 - \sigma ( x ) \right) - \sigma ( x ) \sigma ^ { \prime } ( x ) } \\ { \displaystyle \sigma ^ { \prime \prime } ( x ) = \sigma ^ { \prime } ( x ) - 2 \sigma ( x ) \sigma ^ { \prime } ( x ) } \\ { \displaystyle \sigma ^ { \prime \prime } ( x ) = \sigma ^ { \prime } ( x ) \left( 1 - 2 \sigma ( x ) \right) } \end{array} }$$
And for future convenience:
$$\begin{array} { l } { { \displaystyle { \frac { \mathrm { d } { \partial _ { i } ^ { ( m ) } } } { \mathrm { d } x _ { i } ^ { ( m ) } } = \frac { \mathrm { d } } { \mathrm { d } x _ { i } ^ { ( m ) } } \left( \sigma _ { i } ^ { ( m ) } = \sigma ( x _ { i } ^ { ( m ) } ) \right) } } } \\ { { \displaystyle { \phantom { \frac { \mathrm { d } { \partial _ { i } ^ { ( m ) } } } { \mathrm { d } x _ { i } ^ { ( m ) } } = \left( \sigma _ { i } ^ { ( m ) } \right) \left( 1 - \sigma _ { i } ^ { ( m ) } \right) } } } } \\ { { \displaystyle { \phantom { \frac { \mathrm { d } { \partial _ { i } ^ { ( m ) } } } { \mathrm { d } x _ { i } ^ { ( m ) } } = \sigma ^ { \prime } \left( x _ { i } ^ { ( m ) } \right) } \left( \frac { \mathrm { d } { \partial _ { i } ^ { ( m ) } } } { \mathrm { d } x _ { i } ^ { ( m ) } } = \left( \sigma _ { i } ^ { ( m ) } \right) \left( 1 - \sigma _ { i } ^ { ( m ) } \right) \right) } } } \\ { { \displaystyle { \phantom { \frac { \mathrm { d } { \partial _ { i } ^ { ( m ) } } } { \mathrm { d } x _ { i } ^ { ( m ) } } = \frac { \mathrm { d } } { \mathrm { d } x _ { i } ^ { ( m ) } } \left( \frac { \mathrm { d } { \partial _ { i } ^ { ( m ) } } } { \mathrm { d } x _ { i } ^ { ( m ) } } = \left( \sigma _ { i } ^ { ( m ) } \right) \left( 1 - 2 \sigma _ { i } ^ { ( m ) } \right) \right) } } } } \\ { \displaystyle { \phantom { \frac { \mathrm { d } { \partial _ { i } ^ { ( m ) } } } { \mathrm { d } x _ { i } ^ { ( m ) } } = \left( \sigma _ { i } ^ { ( m ) } \left( 1 - \sigma _ { i } ^ { ( m ) } \right) \right) \left( 1 - 2 \sigma _ { i } ^ { ( m ) } \right) } } } \\ { \displaystyle { \phantom { \frac { \mathrm { d } { \partial _ { i } ^ { ( m ) } } } { \mathrm { d } x _ { i } ^ { ( m ) } } = \sigma ^ { \prime } \left( x _ { i } ^ { ( m ) } \right) } } } \end{array}$$
Derivative of the error with respect to the ith neuron’s input $x _ { i } ^ { ( 0 ) }$ in the output layer:
$$\begin{array} { r l } & { \frac { \partial E } { \partial x _ { i } ^ { ( 0 ) } } = \frac { \partial E } { \partial \sigma _ { i } ^ { ( 0 ) } } \frac { \partial \sigma _ { i } ^ { ( 0 ) } } { \partial x _ { i } ^ { ( 0 ) } } } \\ & { \qquad = \underbrace { \left( \sigma _ { i } ^ { ( 0 ) } - t _ { i } \right) } _ { \mathrm { f r o m ~ ( 6 ) } } \underbrace { \sigma \left( x _ { i } ^ { ( 0 ) } \right) \left( 1 - \sigma \left( x _ { i } ^ { ( 0 ) } \right) \right) } _ { \mathrm { f r o m ~ ( 8 ) } } } \\ & { \qquad = \left( \sigma _ { i } ^ { ( 0 ) } - t _ { i } \right) \left( \sigma _ { i } ^ { ( 0 ) } \left( 1 - \sigma _ { i } ^ { ( 0 ) } \right) \right) } \\ & { \qquad = \left( \sigma _ { i } ^ { ( 0 ) } - t _ { i } \right) \sigma ^ { \prime } \left( x _ { i } ^ { ( 0 ) } \right) } \end{array}$$
Second derivative of the error with respect to the ith neuron’s input $x _ { i } ^ { ( 0 ) }$ in the output layer:
$$\begin{array} { r l r } { { \frac { \partial ^ { 2 } E } { \partial x _ { i } ^ { ( 0 ) ^ { 2 } } } = \frac { \partial } { \partial x _ { i } ^ { ( 0 ) } } ( \frac { \partial E } { \partial \sigma _ { i } ^ { ( 0 ) } } \frac { \partial \sigma _ { i } ^ { ( 0 ) } } { \partial x _ { i } ^ { ( 0 ) } } ) } } \\ & { } & { = \frac { \partial ^ { 2 } E } { \partial x _ { i } ^ { ( 0 ) } \partial \sigma _ { i } ^ { ( 0 ) } } \frac { \partial \sigma _ { i } ^ { ( 0 ) } } { \partial x _ { i } ^ { ( 0 ) } } + \frac { \partial E } { \partial \sigma _ { i } ^ { ( 0 ) } } \frac { \partial ^ { 2 } \sigma _ { i } ^ { ( 0 ) } } { \partial x _ { i } ^ { ( 0 ) ^ { 2 } } } } \\ & { } & { = \frac { \partial ^ { 2 } E } { \partial x _ { i } ^ { ( 0 ) } \partial \sigma _ { i } ^ { ( 0 ) } } \underbrace { ( \frac { \sigma _ { i } ^ { ( 0 ) } } { i } ( 1 - \sigma _ { i } ^ { ( 0 ) } ) ) } _ { \mathrm { f r o m ~ ( 8 ) } } + \underbrace { ( \sigma _ { i } ^ { ( 0 ) } - t _ { i } ) } _ { \mathrm { f r o m ~ ( 6 ) } } \underbrace { ( \sigma _ { i } ^ { ( 0 ) } ( 1 - \sigma _ { i } ^ { ( 0 ) } ) ) ( 1 - 2 \sigma _ { i } ^ { ( 0 ) } ) } _ { \mathrm { f r o m ~ ( 9 ) } } } \end{array}$$
$$\left( \frac { \partial ^ { 2 } E } { \partial x _ { i } ^ { ( 0 ) } \partial \sigma _ { i } ^ { ( 0 ) } } \right) = \frac { \partial } { \partial x _ { i } ^ { ( 0 ) } } \frac { \partial E } { \partial \sigma _ { i } ^ { ( 0 ) } } = \frac { \partial } { \partial x _ { i } ^ { ( 0 ) } } \underbrace { \left( \sigma _ { i } ^ { ( 0 ) } - t _ { i } \right) } _ { \left( \partial x _ { i } ^ { ( 0 ) } \right) } = \frac { \partial \sigma _ { i } ^ { ( 0 ) } } { \partial x _ { i } ^ { ( 0 ) } } = \underbrace { \left( \sigma _ { i } ^ { ( 0 ) } \left( 1 - \sigma _ { i } ^ { ( 0 ) } \right) \right) } _ { \left( \partial x _ { i } ^ { ( 0 ) } \right) }$$
$$\begin{array} { c } { { \displaystyle { \frac { \partial ^ { 2 } E } { \partial { x _ { i } ^ { ( 0 ) } } ^ { 2 } } = \left( o _ { i } ^ { ( 0 ) } \left( 1 - o _ { i } ^ { ( 0 ) } \right) \right) ^ { 2 } + \left( o _ { i } ^ { ( 0 ) } - t _ { i } \right) \left( o _ { i } ^ { ( 0 ) } \left( 1 - o _ { i } ^ { ( 0 ) } \right) \right) \left( 1 - 2 o _ { i } ^ { ( 0 ) } \right) } } } \\ { { \mathrm { } } } \\ { { \displaystyle { = \left( \sigma ^ { \prime } \left( x _ { i } ^ { ( 0 ) } \right) \right) ^ { 2 } + \left( o _ { i } ^ { ( 0 ) } - t _ { i } \right) \sigma ^ { \prime \prime } \left( x _ { i } ^ { ( 0 ) } \right) } } } \end{array}$$
First derivative of the error with respect to a single input contribution $c _ { j i } ^ { ( 0 ) }$ from neuron $j$ to neuron i with weight w(0)ji in the output layer:
$$\begin{array} { r l r } { { \frac { \partial E } { \partial c _ { j i } ^ { ( 0 ) } } = \frac { \partial E } { \partial o _ { i } ^ { ( 0 ) } } \frac { \partial o _ { i } ^ { ( 0 ) } } { \partial x _ { i } ^ { ( 0 ) } } \frac { \partial x _ { i } ^ { ( 0 ) } } { \partial c _ { j i } ^ { ( 0 ) } } } } \\ & { } & { = \underbrace { ( o _ { i } ^ { ( 0 ) } - t _ { i } ) } _ { \mathrm { f r o m ~ ( 6 ) } } \underbrace { ( o _ { i } ^ { ( 0 ) } ( 1 - o _ { i } ^ { ( 0 ) } ) ) } _ { \mathrm { f r o m ~ ( 8 ) } } \frac { \partial x _ { i } ^ { ( 0 ) } } { \partial c _ { j i } ^ { ( 0 ) } } } \end{array}$$
$$\begin{array} { r l } & { \left( \displaystyle \frac { \partial x _ { i } ^ { ( m ) } } { \partial c _ { j i } ^ { ( m ) } } \right) = \displaystyle \frac { \partial } { \partial c _ { j i } ^ { ( m ) } } \left( x _ { i } ^ { ( m ) } = \sum _ { j } w _ { j i } ^ { ( m ) } o _ { j } ^ { ( m + 1 ) } \right) = \displaystyle \frac { \partial } { \partial c _ { j i } ^ { ( m ) } } \left( c _ { j i } ^ { ( m ) } + k \right) = 1 } \\ & { \qquad \displaystyle \frac { \partial E } { \partial c _ { j i } ^ { ( 0 ) } } = \left( o _ { i } ^ { ( 0 ) } - l _ { i } \right) \left( o _ { i } ^ { ( 0 ) } \left( 1 - o _ { i } ^ { ( 0 ) } \right) \right) } \\ & { \qquad \displaystyle = \underbrace { \left( o _ { i } ^ { ( 0 ) } - t _ { i } \right) \sigma ^ { \prime } \left( x _ { i } ^ { ( 0 ) } \right) } _ { \mathrm { t r o m ~ ( 2 5 ) } } } \\ & { \qquad \displaystyle \frac { \partial E } { \partial c _ { j i } ^ { ( 0 ) } } = \frac { \partial E } { \partial x _ { i } ^ { ( 0 ) } } } \end{array}$$
Second derivative of the error with respect to a single input contribution $c _ { j i } ^ { ( 0 ) }$ :
$$\begin{array} { r l } { \frac { \partial ^ { 2 } E } { \partial t _ { 3 } ^ { ( 0 ) } } ^ { 2 } = \frac { \partial } { \partial t _ { 3 } ^ { ( 0 ) } } \frac { \partial } { \partial t _ { 3 } ^ { ( 0 ) } } ( \frac { \partial E } { \partial x _ { 3 } ^ { ( 0 ) } } ^ { 2 } = \underbrace { ( \alpha ^ { ( 0 ) } - i \delta ) \sigma ^ { \prime } ( x _ { 3 } ^ { ( 0 ) } ) } _ { i \mathrm { m i n } ( \infty ( s ) ) } ) } & { } \\ { = \frac { \partial } { \partial t _ { 3 } ^ { ( 0 ) } } ( ( \varepsilon ( \frac { i \delta } { s } ) ^ { 2 } ) - i _ { z } ) \sigma ^ { \prime } ( \overline { { \alpha } } _ { i } ^ { ( 0 ) } ) } & { } \\ { = \frac { \partial } { \partial t _ { 3 } ^ { ( 0 ) } } ( \tau ( \sum _ { s } w _ { i } ^ { ( 0 ) } , \sigma _ { i j } ^ { ( 0 ) } + 1 ) - \kappa _ { k } ) \sigma ^ { \prime } ( \sum _ { s } w _ { i } ^ { ( 0 ) } , \sigma _ { j i } ^ { ( 0 + 1 ) } ) } & { } \\ { = \frac { \partial } { \partial t _ { 3 } ^ { ( 0 ) } } ( \tau ( \sum _ { s } w _ { i } ^ { ( 0 ) } ) - i _ { z } ) \sigma ^ { \prime } ( \sum _ { s } w _ { i } ^ { ( 0 ) } ) } & { } \\ { = \frac { \partial } { \partial t _ { 3 } ^ { ( 0 ) } } ( \frac { \partial } { \partial t _ { 3 } ^ { ( 0 ) } } ( \frac { \partial \sigma ( x _ { i j } ^ { ( 0 ) } + k ) } { \partial t _ { 3 } ^ { ( 0 ) } } - 1 ) \sigma ^ { \prime } ( \sum _ { s } w _ { i } ^ { ( 0 ) } ) } & { } \\ = \frac { \partial } { \partial t _ { 3 } ^ { ( 0 ) } } \frac { \partial } { \partial t _ { 3 } ^ { ( 0 ) } } ( \frac { \partial \sigma ( x _ { i j } ^ { ( 0 ) } + k ) } { \partial t _ { 3 } ^ { ( 0 ) } ( \varepsilon ( x _ { i j } ^ { ( 0 ) } ) } - 1 ) \sigma ^ { \prime } ( \sum _ { s } w _ { i } ^ \end{array}$$
We now make use of the abbreviations $f$ and $g$ :
$$\begin{array} { r l } & { \quad = \bar { f } \left( \mathcal { L } _ { \beta } ^ { ( 0 ) } \right) g \left( c _ { \beta \gamma } ^ { ( 0 ) } \right) + \bar { f } \left( c _ { \beta \gamma } ^ { ( 0 ) } \right) g ^ { \prime } \left( c _ { \beta \gamma } ^ { ( 0 ) } \right) } \\ & { \quad = \sigma ^ { \prime } \left( c _ { \beta \gamma } ^ { ( 0 ) } + k \right) \sigma ^ { \prime } \left( c _ { \beta \gamma } ^ { ( 0 ) } + k \right) + \left( \sigma \left( c _ { \beta \gamma } ^ { ( 0 ) } + k \right) - l _ { \downarrow } \right) \sigma ^ { \prime \prime } \left( c _ { \beta \gamma } ^ { ( 0 ) } + k \right) } \\ & { \quad = \sigma ^ { \prime } \left( c _ { \beta \gamma } ^ { ( 0 ) } + k \right) ^ { 2 } + \left( \sigma _ { \downarrow } ^ { ( 0 ) } - t _ { \downarrow } \right) \sigma ^ { \prime \prime } \left( c _ { \beta \gamma } ^ { ( 0 ) } + k \right) } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \frac { \partial ^ { 2 } F } { \partial c _ { \beta \gamma } ^ { ( 0 ) } } } \\ & { \quad \quad \quad \quad \quad \frac { \partial ^ { 2 } F } { \partial c _ { \beta \gamma } ^ { ( 0 ) } } ^ { 2 } = \underbrace { \left( \sigma ^ { \prime } \left( x _ { \langle } ^ { ( 0 ) } \right) \right) ^ { 2 } + \left( \sigma _ { \downarrow } ^ { ( 0 ) } - t _ { \downarrow } \right) \sigma ^ { \prime \prime } \left( c _ { \downarrow } ^ { ( 0 ) } \right) } _ { \mathrm { e m ~ \ c a l ~ \lambda \mit t } } } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \end{array}$$
# A.1.1 SUMMARY OF OUTPUT LAYER DERIVATIVES
$$\frac { \partial E } { \partial o _ { i } ^ { ( 0 ) } } = o _ { i } ^ { ( 0 ) } - t _ { i } \quad \quad \quad \quad \quad \frac { \partial ^ { 2 } E } { { \partial o _ { i } ^ { ( 0 ) } } ^ { 2 } } = 1$$
$$\frac { \partial E } { \partial x _ { i } ^ { ( 0 ) } } = \left( o _ { i } ^ { ( 0 ) } - t _ { i } \right) \sigma ^ { \prime } \left( x _ { i } ^ { ( 0 ) } \right) \quad \quad \frac { \partial ^ { 2 } E } { \partial { x _ { i } ^ { ( 0 ) } } ^ { 2 } } = \left( \sigma ^ { \prime } \left( x _ { i } ^ { ( 0 ) } \right) \right) ^ { 2 } + \left( o _ { i } ^ { ( 0 ) } - t _ { i } \right) \sigma ^ { \prime \prime } \left( x _ { i } ^ { ( 0 ) } \right)$$
$${ \frac { \partial E } { \partial c _ { j i } ^ { ( 0 ) } } } = { \frac { \partial E } { \partial x _ { i } ^ { ( 0 ) } } } \qquad { \frac { \partial ^ { 2 } E } { \partial c _ { j i } ^ { ( 0 ) ^ { 2 } } } } = { \frac { \partial ^ { 2 } E } { \partial { x _ { i } ^ { ( 0 ) } } ^ { 2 } } }$$
# A.1.2 HIDDEN LAYER DERIVATIVES
The first derivative of the error with respect to a neuron with output $o _ { j } ^ { ( 1 ) }$ in the first hidden layer, summing over all partial derivative contributions from the output layer:
$$\frac { \partial E } { \partial o _ { j } ^ { ( 1 ) } } = \sum _ { i } \frac { \partial E } { \partial o _ { i } ^ { ( 0 ) } } \frac { \partial o _ { i } ^ { ( 0 ) } } { \partial x _ { i } ^ { ( 0 ) } } \frac { \partial x _ { i } ^ { ( 0 ) } } { \partial c _ { j i } ^ { ( 0 ) } } \frac { \partial c _ { j i } ^ { ( 0 ) } } { \partial o _ { j } ^ { ( 1 ) } } = \sum _ { i } \underbrace { \left( o _ { i } ^ { ( 0 ) } - t _ { i } \right) \sigma ^ { \prime } \left( x _ { i } ^ { ( 0 ) } \right) } _ { \textit { i } } w _ { j i } ^ { ( 0 ) }$$
$$\begin{array} { c } { { \displaystyle { \frac { \partial c _ { j i } ^ { ( m ) } } { \partial o _ { j } ^ { ( m + 1 ) } } = \frac { \partial } { \partial o _ { j } ^ { ( m + 1 ) } } \left( c _ { j i } ^ { ( m ) } = w _ { j i } ^ { ( m ) } o _ { j } ^ { ( m + 1 ) } \right) = w _ { j i } ^ { ( m ) } } } } \\ { { \displaystyle { \frac { \partial E } { \partial o _ { j } ^ { ( 1 ) } } = \sum _ { i } \frac { \partial E } { \partial x _ { i } ^ { ( 0 ) } } w _ { j i } ^ { ( 0 ) } } } } \end{array}$$
Note that this equation does not depend on the specific form o f ∂E∂x(0) , whether it involves a sigmoid or any other activation function. We can therefore replace the specific indexes with general ones, and use this equation in the future.
$$\frac { \partial E } { \partial o _ { j } ^ { ( m + 1 ) } } = \sum _ { i } \frac { \partial E } { \partial x _ { i } ^ { ( m ) } } w _ { j i } ^ { ( m ) }$$
The second derivative of the error with respect to a neuron with output $o _ { j } ^ { ( 1 ) }$ in the first hidden layer:
$$\begin{array} { l } { { \displaystyle { \frac { \partial ^ { 2 } E } { \partial { o _ { j } ^ { ( 1 ) } } ^ { 2 } } = \frac { \partial } { \partial { o _ { j } ^ { ( 1 ) } } } \frac { \partial E } { \partial { o _ { j } ^ { ( 1 ) } } } } } } \\ { { \displaystyle { \ = \frac { \partial } { \partial { o _ { j } ^ { ( 1 ) } } } \sum _ { i } \frac { \partial E } { \partial { x _ { i } ^ { ( 0 ) } } } w _ { j i } ^ { ( 0 ) } } } } \\ { { \displaystyle { \ = \frac { \partial } { \partial { o _ { j } ^ { ( 1 ) } } } \sum _ { i } \left( o _ { i } ^ { ( 0 ) } - t _ { i } \right) \sigma ^ { \prime } \left( { x _ { i } ^ { ( 0 ) } } \right) w _ { j i } ^ { ( 0 ) } } } } \end{array}$$
If we now make use of the fact, that $\begin{array} { r } { o _ { i } ^ { ( 0 ) } = \sigma \left( x _ { i } ^ { ( 0 ) } \right) = \sigma \left( \sum _ { j } \left( w _ { j i } ^ { ( 0 ) } o _ { j } ^ { ( 1 ) } \right) \right) } \end{array}$ , we can evaluate the expression further.
$$\begin{array} { r l } { \frac { \partial \hat { \mathcal { F } } ( R ) } { \partial \theta _ { 0 } ^ { ( 1 ) } } = \frac { \partial } { \partial \theta _ { 0 } ^ { ( 1 ) } } \sum _ { t } ( \underbrace { \sigma ( \sum _ { s } \alpha _ { 0 } ^ { ( 0 , 0 , 1 ) } \alpha _ { 0 } ^ { ( 1 ) } ) } _ { t \in \mathcal { N } _ { 1 } ^ { ( 0 , 1 ) } } - \nu _ { s } ) \cdot ( \sum _ { s } \gamma _ { s } \alpha _ { 0 } ^ { ( 0 , 0 , 0 ) } ) \frac { \alpha _ { 0 } ^ { ( 1 ) } } { s ! } } & { = } \\ & { \quad - \sum _ { s } ( \mathcal { C } ( \frac { \partial ^ { ( 0 , 0 ) } } { \partial s } ) \alpha _ { 0 } ^ { ( 0 , 0 ) } ) - f ( \alpha _ { 0 } ^ { ( 1 ) } - 1 ) \cdot \sqrt { ( \alpha _ { 0 } ^ { ( 0 , 1 ) } ) } } & { = } \\ & { \quad - \sum _ { s ^ { \prime } } ( ( \sum _ { s } \alpha _ { 0 } ^ { ( 0 , 0 ) } \beta _ { 0 } ^ { ( 1 ) } ) \alpha _ { 0 } ^ { ( 0 , 0 ) } - f ( \sum _ { s } \alpha _ { 0 } ^ { ( 1 ) } ) ) \cdot ( \alpha _ { 0 } ^ { ( 0 , 1 ) } ) } \\ & { \quad \sum _ { s ^ { \prime } } ( \varepsilon ( \sum _ { s } \gamma _ { s } ^ { ( 0 , 0 , 1 ) } ) \alpha _ { 0 } ^ { ( 1 ) } - \varepsilon ( \sum _ { s } \alpha _ { 0 } ^ { ( 0 , 0 ) } \beta _ { 0 } ^ { ( 1 ) } ) ) \frac { \alpha _ { 0 } ^ { ( 1 ) } } { s ^ { 2 } } + \dots } \\ & \quad \sum _ { s ^ { \prime } } ( \varepsilon ( \sum _ { s } \gamma _ { s } ^ { ( 0 , 0 , 1 ) } ) - ( \sum _ { s } \gamma _ { s } ^ { ( 0 , 0 , 0 ) } \varepsilon ) \frac { \alpha _ { 0 } ^ { ( 1 ) } } { s ^ { 2 } } ) \cdot ( \sum _ { s } \alpha _ { 0 } ^ { ( 1 ) } \varepsilon ) \frac { \partial ^ { ( 0 , 0 ) } } { \partial s ^ { \prime } } ) ( \varepsilon ( \frac { \partial ^ { ( 0 , 0 ) } } \end{array}$$
Summing up, we obtain the more general expression:
$$\frac { \partial ^ { 2 } E } { { \partial o _ { j } ^ { ( 1 ) } } ^ { 2 } } = \sum _ { i } \frac { \partial ^ { 2 } E } { { \partial x _ { i } ^ { ( 0 ) } } ^ { 2 } } \left( w _ { j i } ^ { ( 0 ) } \right) ^ { 2 }$$
Note that the equation in (65) does not depend on the form o f ∂2E∂x(0)x 2 , which means we can replace the specific indexes with general ones:
$$\frac { \partial ^ { 2 } E } { \partial o _ { j } ^ { ( m + 1 ) ^ { 2 } } } = \sum _ { i } \frac { \partial ^ { 2 } E } { \partial x _ { i } ^ { ( m ) ^ { 2 } } } \left( w _ { j i } ^ { ( m ) } \right) ^ { 2 }$$
At this point we are beginning to see the recursion in the form of the 2nd derivative terms which can be thought of analogously to the first derivative recursion which is central to the back-propagation algorithm. The formulation above which makes specific reference to layer indexes also works in the general case.
Consider the $i$ th neuron in any layer $m$ with output $o _ { i } ^ { ( m ) }$ and input $x _ { i } ^ { ( m ) }$ . The first and second derivatives of the error $E$ with respect to this neuron’s input are:
$$\frac { \partial E } { \partial x _ { i } ^ { ( m ) } } = \frac { \partial E } { \partial o _ { i } ^ { ( m ) } } \frac { \partial o _ { i } ^ { ( m ) } } { \partial x _ { i } ^ { ( m ) } }$$
$$\begin{array} { r l } & { \frac { \partial ^ { 2 } E } { \partial z _ { 2 } ^ { ( \mathrm { i n k } ) } } = \frac { \partial } { \partial z _ { 2 } ^ { ( \mathrm { i n k } ) } } \frac { \partial E } { \partial x _ { 1 } ^ { ( \mathrm { i n k } ) } } } \\ & { \phantom { \frac { \partial ^ { 2 } E } { \partial z _ { 2 } ^ { ( \mathrm { i n k } ) } } = } - \frac { \partial ^ { 2 } E } { \partial z _ { 2 } ^ { ( \mathrm { i n k } ) } } \frac { \partial E } { \partial x _ { 1 } ^ { ( \mathrm { i n k } ) } } } \\ & { \phantom { \frac { \partial ^ { 2 } E } { \partial z _ { 2 } ^ { ( \mathrm { i n k } ) } } = } - \frac { \partial ^ { 2 } E } { \partial z _ { 2 } ^ { ( \mathrm { i n k } ) } } ( \frac { \partial ^ { 2 } E } { \partial z _ { 1 } ^ { ( \mathrm { i n k } ) } } \frac { \partial ^ { 2 } E ^ { ( \mathrm { i n k } ) } } { \partial z _ { 1 } ^ { ( \mathrm { i n k } ) } } ) } \\ & { \phantom { \frac { \partial ^ { 2 } E } { \partial z _ { 2 } ^ { ( \mathrm { i n k } ) } } = } - \frac { \partial ^ { 2 } E } { \partial z _ { 2 } ^ { ( \mathrm { i n k } ) } } \frac { \partial ^ { 2 } E } { \partial z _ { 1 } ^ { ( \mathrm { i n k } ) } } \frac { \partial ^ { 2 } E } { \partial z _ { 2 } ^ { ( \mathrm { i n k } ) } } } \\ & { \phantom { \frac { \partial ^ { 2 } E } { \partial z _ { 2 } ^ { ( \mathrm { i n k } ) } } = } \frac { \partial ^ { 2 } E } { \partial z _ { 2 } ^ { ( \mathrm { i n k } ) } \partial z _ { 1 } ^ { ( \mathrm { i n k } ) } } \frac { \partial ^ { 2 } E } { \partial z _ { 2 } ^ { ( \mathrm { i n k } ) } } \frac { \partial ^ { 2 } E } { \partial z _ { 2 } ^ { ( \mathrm { i n k } ) } } } \\ & \phantom \frac { \partial ^ { 2 } E } { \partial z _ { 2 } ^ { ( \mathrm { i n k } ) } } = \frac { \partial ^ { 2 } E } { \partial z _ { 2 } ^ { ( \mathrm { i n k } ) } } ( \frac { \partial ^ { 2 } E } { \partial z _ { 1 } ^ { ( \mathrm { i n k } ) } } - \frac { \partial ^ { 2 } E } \partial z _ { 1 } ^ ( \ \end{array}$$
Note the form of this equation is the general form of what was derived for the output layer in (31). Both of the above first and second terms are easily computable and can be stored as we propagate back from the output of the network to the input. With respect to the output layer, the first and second derivative terms have already been derived above. In the case of the $m + 1$ hidden layer during back propagation, there is a summation of terms calculated in the mth layer. For the first derivative, we have this from (55).
$$\frac { \partial E } { \partial o _ { j } ^ { ( m + 1 ) } } = \sum _ { i } \frac { \partial E } { \partial x _ { i } ^ { ( m ) } } w _ { j i } ^ { ( m ) }$$
And the second derivative for the $j$ th neuron in the $m + 1$ layer:
$$\frac { \partial ^ { 2 } E } { \partial x _ { j } ^ { ( m + 1 ) ^ { 2 } } } = \frac { \partial ^ { 2 } E } { \partial o _ { j } ^ { ( m + 1 ) ^ { 2 } } } \left( \sigma ^ { \prime } \left( x _ { j } ^ { ( m + 1 ) } \right) \right) ^ { 2 } + \frac { \partial E } { \partial o _ { j } ^ { ( m + 1 ) } } \sigma ^ { \prime \prime } \left( x _ { j } ^ { ( m + 1 ) } \right)$$
We can replace both derivative terms with the forms which depend on the previous layer:
$$\frac { \partial ^ { 2 } E } { \partial x _ { j } ^ { ( m + 1 ) ^ { 2 } } } = \underbrace { \sum _ { i } \frac { \partial ^ { 2 } E } { \partial x _ { i } ^ { ( 0 ) ^ { 2 } } } \left( w _ { j i } ^ { ( 0 ) } \right) ^ { 2 } } _ { \mathrm { f r o m ~ ( 6 6 ) } } \left( \sigma ^ { \prime } \left( x _ { j } ^ { ( m + 1 ) } \right) \right) ^ { 2 } + \underbrace { \sum _ { i } \frac { \partial E } { \partial x _ { i } ^ { ( m ) } } w _ { j i } ^ { ( m ) } } _ { \mathrm { f r o m ~ ( 5 5 ) } } \sigma ^ { \prime \prime } \left( x _ { j } ^ { ( m + 1 ) } \right)$$
And this horrible mouthful of an equation gives you a general form for any neuron in the $j$ th position of the $m + 1$ layer. Taking very careful note of the indexes, this can be more or less translated painlessly to code. You are welcome, world.
# A.1.3 SUMMARY OF HIDDEN LAYER DERIVATIVES
$$\frac { \partial E } { \partial \sigma _ { j } ^ { ( m + 1 ) } } = \sum _ { i } \frac { \partial E } { \partial x _ { i } ^ { ( m ) } } w _ { j i } ^ { ( m ) } \qquad \frac { \partial ^ { 2 } E } { \partial \sigma _ { j } ^ { ( m + 1 ) ^ { 2 } } } = \sum _ { i } \frac { \partial ^ { 2 } E } { \partial x _ { i } ^ { ( m ) ^ { 2 } } } \left( w _ { j i } ^ { ( m ) } \right) ^ { 2 }$$
$$\begin{array} { r l r } { { \frac { \partial E } { \partial x _ { i } ^ { ( m ) } } = \frac { \partial E } { \partial o _ { i } ^ { ( m ) } } \frac { \partial o _ { i } ^ { ( m ) } } { \partial x _ { i } ^ { ( m ) } } } } \\ & { \frac { \partial ^ { 2 } E } { \partial x _ { j } ^ { ( m + 1 ) ^ { 2 } } } = \frac { \partial ^ { 2 } E } { \partial o _ { j } ^ { ( m + 1 ) ^ { 2 } } } ( \sigma ^ { \prime } ( x _ { j } ^ { ( m + 1 ) } ) ) ^ { 2 } + \frac { \partial E } { \partial o _ { j } ^ { ( m + 1 ) } } \sigma ^ { \prime \prime } ( x _ { j } ^ { ( m + 1 ) } ) } \end{array}$$123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234# IMPROVING FEDERATED LEARNING PERSONALIZATION VIA MODEL AGNOSTIC META LEARNING
Anonymous authors Paper under double-blind review
# ABSTRACT
Federated Learning (FL) refers to learning a high quality global model based on decentralized data storage, without ever copying the raw data. A natural scenario arises with data created on mobile phones by the activity of their users. Given the typical data heterogeneity in such situations, it is natural to ask how can the global model be personalized for every such device, individually. In this work, we point out that the setting of Model Agnostic Meta Learning (MAML), where one optimizes for a fast, gradient-based, few-shot adaptation to a heterogeneous distribution of tasks, has a number of similarities with the objective of personalization for FL. We present FL as a natural source of practical applications for MAML algorithms, and make the following observations. 1) The popular FL algorithm, Federated Averaging (McMahan et al., 2017), can be interpreted as a meta learning algorithm. 2) Careful fine-tuning can yield a global model with higher accuracy, which is at the same time easier to personalize. However, solely optimizing for the global model accuracy yields a weaker personalization result. 3) A model trained using a standard datacenter optimization method is much harder to personalize, compared to one trained using Federated Averaging, supporting the first claim. These results raise new questions for FL, MAML, and broader ML research.
# 1 INTRODUCTION
In recent years, the growth of machine learning applications was driven by aggregation of large amounts of data in a datacenter, where a model can be trained using large scale distributed system (Dean et al., 2012; LeCun et al., 2015). Both the research community and general public are becoming increasingly aware that there is a variety of scenarios where this kind of data collection comes with significant risks, mainly related to notions of privacy and trust.
In the presence of user generated data, such as activity on mobile phones, Federated Learning (FL) (McMahan & Ramage, 2017) proposes an alternative approach for training a high quality global model without ever sending raw data to the cloud. The FL system proposed by Google (Bonawitz et al., 2019) selects a sample of available devices and sends them a model to be trained. The devices compute an update to the model based on an optimization procedure with locally available data, and the central system aggregates the updates from different devices. Such iteration is repeated many times until the model has converged. The users’ training data does not leave their devices. The basic FL algorithm, Federated Averaging (FedAvg) (McMahan et al., 2017), has been used in production applications, for instance for next word prediction in mobile keyboard (Hard et al., 2018), which shows that Federated Learning can outperform the best model trained in a datacenter. Successful algorithmic extensions to the central idea include training a differential private model (McMahan et al., 2018), compression (Konecnˇ y et al., 2016b; Caldas et al., 2018a), secure ´ aggregation (Bonawitz et al., 2017), and a smaller number of always-participating nodes (Yang et al., 2019).
FL applications generally face non-i.i.d and unbalanced data available to devices, which makes it challenging to ensure good performance across different devices with a FL-trained global model. Theoretical guarantees are only available under restrictive assumptions and for convex objectives, cf. Li et al. (2019b). In this work, we are interested in personalization methods that adapt the model for data available on each device, individually. We refer to a trained global model as the initial model, and the locally adapted model as the personalized model. Existing FL personalization work directly takes a converged initial model and conducts personalization evaluation via gradient descent (Beaufays et al., 2019). However, in this approach, the training and personalization procedures are completely disconnected, which results in potentially suboptimal personalized models.
Meta Learning optimizes the performance after adaptation given few-shot adaptation examples on heterogeneous tasks, and has increasing applications in the context of Supervised Learning and Reinforcement Learning. Model Agnostic Meta Learning (MAML) introduced by Finn et al. (2017) is a solely gradient-based Meta Learning algorithm, which runs in two connected stages; metatraining and meta-testing. Meta-training learns a sensitive initial model which can conduct fast adaptation on a range of tasks, and meta-testing adapts the initial model for a particular task.
Both tasks for MAML, and clients for FL, are heterogeneous. For each task in MAML and client in FL, existing algorithms use a variant of gradient descent locally, and send an overall update to a coordinator to update the global model. If we present the FL training process as meta-training in the MAML language, and the FL personalization via gradient descent as meta-testing, we show in Section 2 that FedAvg (McMahan et al., 2017) and Reptile (Nichol et al., 2018), two popular FL and MAML algorithms, are very similar to each other; see also Khodak et al. (2019).
In order to make FL personalization useful in practice, we propose that the following objectives must all be addressed, simultaneously.
(1) Improved Personalized Model – for a large majority of the clients. (2) Solid Initial Model – some clients have limited or even no data for personalization. (3) Fast Convergence – reach a high quality model in small number of training rounds.
Typically, the MAML algorithms only focus on objective (1); that was the original motivation in Finn et al. (2017). Existing FL works usually focus on objectives (2) and (3), and take the personalized performance as secondary. This is largely due to the fact that it was not obvious that getting a solid initial model is feasible or practical if devices are available occasionally and with limited resources.
In this work, we study these three objectives jointly, and our main contributions are:
• We point out the connection between two widely used FL and MAML algorithms, and interpret existing FL algorithm in the light of existing MAML algorithms. We propose a novel modification of FedAvg, with two stages of training and fine-tuning, for optimizing the three above objectives. We empirically demonstrate that FedAvg is already a meta learning algorithm, optimizing for personalized performance, as opposed to quality of the global model. Furthermore, we show that the fine tuning stage enables better and more stable personalized performance. • We observe that different global models with the same accuracy, can exhibit very different capacity for personalization. • We highlight that these results challenge the existing objectives in the FL literature, and motivate new problems for the broader Machine Learning research community.
# 2 INTERPRETING FEDAVG AS A META LEARNING ALGORITHM
In this section, we highlight the similarities between the FL and MAML algorithms and interpret FedAvg as a linear combination of a naive baseline and a collection of existing MAML methods.
Algorithm 1 presents a conceptual algorithm with nested structure (left column), of which the MAML meta-training algorithm, Reptile (middle column), and FL-training algorithm, FedAvg (right column), are particular instances. We assume that $L$ is a loss function common to all of the following arguments. In each iteration, a MAML algorithm trains across a random batch of tasks $\{ T _ { i } \}$ . For each task $T _ { i }$ , it conducts an inner-loop update, and aggregates gradients from each sampled task with an outer-loop update. In each training round, FL uses a random selection of clients $\{ T _ { i } \}$ . For each client $T _ { i }$ and its weight $w _ { i }$ , it runs an optimization procedure for a number of epochs over the local data, and sends the update to the server, which aggregates the updates to form a new global model. If we simplify the setting and assume all clients have the same amount of data, causing the weights $w _ { i }$ to be identical, Reptile and FedAvg in fact become the same algorithms. Several other MAML algorithms (Finn et al., 2017; Antoniou et al., 2018), or other non-MAML/FL methods (Zhang et al., 2019), can also be viewed as instances of the conceptual method in left column of Algorithm 1.
<table><tr><td colspan="3">Algorithm1 Connects FL and MAML (left),Reptile Batch Version(middle),and FedAvg (right).</td></tr><tr><td>OuterLoop/Server learning rate α</td><td>Require::Reptile Step K.</td><td>Require:FedAvg Local Epoch E.</td></tr><tr><td>InnerLoop/Client learning rate β</td><td>functionInnerLoop(0,Ti,β)</td><td>function ClientUpdate(0,T,β)</td></tr><tr><td>Initial model parameters θ</td><td>SampleK-shot data Di,k from Ti.</td><td>Split local dataset into batches B</td></tr><tr><td>while not done do</td><td>0=0</td><td>0=θ</td></tr><tr><td>Sample batch of tasks/clients {Ti}</td><td>for each local step ifrom1to Kdo</td><td>for each local epoch i from 1 to E do</td></tr><tr><td>for Sampled task/client Ti do if FL then</td><td>0=0i-βVθL(0,Di,k)</td><td>for batch b ∈Bdo 0=0-βVθL(0,b)</td></tr><tr><td>gi,Wi= ClientUpdate(0,Ti,β)</td><td></td><td>end for</td></tr><tr><td>else if MAML then</td><td>end for</td><td>end for</td></tr><tr><td>gi=InnerLoop(0,T,β)</td><td>Returngi=0-0</td><td>Return gi=0-0</td></tr><tr><td>end if</td><td>end function</td><td>end function</td></tr><tr><td>end for</td><td>Require::Meta Batch Size M.</td><td>Require:Clients per training round M.</td></tr><tr><td>if FL then</td><td>function OuterLoop(0,{gi},α)</td><td>function ServerUpdate(0,{gi,wi},α</td></tr><tr><td>0= ServerUpdate(0,{gi,wi},α)</td><td></td><td></td></tr><tr><td>else if MAML then 0=OuterLoop(0,{gi},α)</td><td></td><td></td></tr><tr><td>end if</td><td>Return 0</td><td>Return 0</td></tr><tr><td>end while</td><td>end function</td><td>end function</td></tr></table>
In the following, we rearrange the summands comprising the update formula of FedAvg/Reptile algorithm to reveal the connection with other existing methods – a linear combination of the Federated SGD (FedSGD) (McMahan et al., 2017) and First Order MAML (FOMAML) algorithms (Finn et al., 2017) with different number of steps. For clarity, we assume identical weights $w _ { i }$ in FedAvg.
Consider $T$ participating clients and let $\theta$ be parameters of the relevant model. For each client $i$ define its local loss function as $L _ { i } ( \theta )$ , and let $\bar { \boldsymbol { g } } _ { j } ^ { i }$ be the gradient computed in $j ^ { t h }$ iteration during a local gradient-based optimization process.
FedSGD was proposed as a naive baseline against which to compare FL algorithms. For each client, it simply takes a single gradient step based on the local data, which is sent back to the server. It is a sensible baseline because it is a variant of what a traditional optimization method would do if we were to collect all the data in a central location, albeit inefficient in the FL setting. That means that FedSGD optimizes the performance of the initial model, as is the usual objective in datacenter training. The local update produced by FedSGD, $g _ { F e d S G D }$ , can be written as
$$g _ { F e d S G D } = \frac { - \beta } { T } \sum _ { i = 1 } ^ { T } \frac { \partial L _ { i } ( \theta ) } { \partial \theta } = \frac { 1 } { T } \sum _ { i = 1 } ^ { T } g _ { 1 } ^ { i } .$$
Next, we derive the update of FOMAML in similar terms. Assuming client learning rate $\beta$ , the personalized model of client $i$ , obtained after $K$ -step gradient update is $\theta _ { K } ^ { i } = U _ { K } ^ { i } ( \theta ) = \theta -$ $\begin{array} { r } { \beta \sum _ { j = 1 } ^ { K } g _ { j } ^ { i } = \theta - \beta \sum _ { j = 1 } ^ { K } \frac { \partial L _ { i } ( \theta _ { j } ) } { \partial \theta } } \end{array}$ 1 ∂Li(θj )∂θ . Differentiating the client update formula, we get
$$\frac { \partial U _ { K } ^ { i } ( \boldsymbol { \theta } ) } { \partial \boldsymbol { \theta } } = I - \beta \frac { \partial \sum _ { j = 1 } ^ { K } g _ { j } ^ { i } } { \partial \boldsymbol { \theta } } = I - \beta \sum _ { j = 1 } ^ { K } \frac { \partial ^ { 2 } L _ { i } ( \theta _ { j } ) } { \partial \theta ^ { 2 } } .$$
Directly optimizing the current model for the personalized performance after locally adapting $K$ gradient steps, results in the general MAML update proposed by Finn et al. (2017).
$$g _ { M A M L } = \frac { \partial L _ { M A M L } } { \partial \theta } = \frac { 1 } { T } \sum _ { i = 1 } ^ { T } \frac { \partial L _ { i } ( U _ { K } ^ { i } ( \theta ) ) } { \partial \theta } = \frac { 1 } { T } \sum _ { i = 1 } ^ { T } L _ { i } ^ { \prime } ( U _ { K } ^ { i } ( \theta ) ) ( I - \beta \sum _ { j = 1 } ^ { K } \frac { \partial ^ { 2 } L _ { i } ( \theta _ { j } ) } { \partial \theta ^ { 2 } } ) .$$
MAML requires to compute 2nd-order gradients, which can be computationally expensive and creates potentially infeasible memory requirements. To avoid computing the 2nd-order term, FOMAML simply ignores it, resulting in a first-order approximation of the objective (Finn et al., 2017). $F O M A M L ( K )$ then uses the $( K + 1 ) ^ { t h }$ gradient as the local update, after $K$ gradient steps.
$$g _ { F O M A M L } ( K ) = \frac { 1 } { T } \sum _ { i = 1 } ^ { T } L _ { i } ^ { \prime } ( U _ { K } ^ { i } ( \theta ) ) I = \frac { 1 } { T } \sum _ { i = 1 } ^ { T } L _ { i } ^ { \prime } ( \theta _ { K } ^ { i } ) = \frac { 1 } { T } \sum _ { i = 1 } ^ { T } g _ { K + 1 } ^ { i } .$$
Now we have derived the building blocks of the FedAvg. As presented in Algorithm 1, the update of FedAvg, $g _ { F e d A v g }$ , is the average of client updates, which are the sums of local gradient updates. Rearranging the terms presents its interpretation as a linear combination of the above ideas.
$$g _ { F e d A v g } = \frac { 1 } { T } \sum _ { i = 1 } ^ { T } \sum _ { j = 1 } ^ { K } g _ { j } ^ { i } = \frac { 1 } { T } \sum _ { i = 1 } ^ { T } g _ { 1 } ^ { i } + \sum _ { j = 1 } ^ { K - 1 } \frac { 1 } { T } \sum _ { i = 1 } ^ { T } g _ { j + 1 } ^ { i } = g _ { F e d S G D } + \sum _ { j = 1 } ^ { K - 1 } g _ { F O M A M L } ( j )$$
Note that interpolating to special case, $g _ { F e d S G D }$ can be seen as $g _ { F O M A M L } ( 0 ) -$ optimizing the performance after 0 local updates, i.e., the current model. This sheds light onto the existing Federated Averaging algorithm, as the linear combination of algorithms optimizing personalized performance after a range of local updates. Note, however, this does not mean that FedAvg optimizes for the linear combination of the objectives of the respective algorithms. Nevertheless, we show in the following section that using $K = 1$ results in a model hard to personalize, and increasing $K$ significantly improves the personalization performance, up until a certain point where the performance of initial model becomes unstable.
# 3 PERSONALIZED FEDAVG
In this section, we present Personalized FedAvg algorithm, which is the result of experimental adaptation of the core FedAvg algorithm to improve the three objectives proposed in the introduction.
We denote $F e d A v g ( E )$ the Federated Averaging method from Algorithm 1, right, run for $E$ local epochs, weighting the updates proportionally to the amount of data available locally. We denote $R e p t i l e ( K )$ the method from Algorithm 1, middle, run in the FL setting for $K$ local steps, irrespective of the amount of data available locally. Based on a variety of experiments we explored, we propose Personalized FedAvg in Algorithm 2.
# Algorithm 2 Personalized FedAvg
1: Run $F e d A v g ( E )$ with momentum SGD as server optimizer and a relatively larger $E$ 2: Switch to $R e p t i l e ( K )$ with Adam as server optimizer to fine-tune the initial model. 3: Conduct personalization with the same client optimizer used during training.
In general, FedAvg training with several local epochs ensures reasonably fast convergence in terms of number of communication rounds. Due to complexity of production system, this measure was studied as the proxy for convergence speed of FL algorithms. We find that this method with momentum SGD as the server optimizer already optimizes for the personalized model – objective (1) form the introduction – while the initial model – objective (2) – is relatively unstable. Based on prior work, the recommendation to address this problem would be to decrease $E$ or the local learning rate, stabilizing initial model at the cost of slowing down convergence (McMahan et al., 2017; Wang & Joshi, 2018) – objective (3).
We propose a fine-tuning stage using $R e p t i l e ( K )$ with small $K$ and Adam as the server optimizer, to improve the initial model, while preserving and stabilizing the personalized model. We observed that Adam yields better results than other optimizers, see Table 3 in Appendix A.1, and makes the best personalized performance achievable with broader set of hyperparameters, see Figure 2. The subsequent deployment and personalization is conducted using the same client optimizer as used for training, as we observe that this choice yields the best results for FedAvg/Reptile-trained models.
Experimental setup. We use the EMNIST-62 dataset as our primary benchmark (Caldas et al., 2018b). It is the original source of the MNIST dataset, which comes with author id, and noticable variations in style, pen width, size, etc., making it a suitable source for simulated FL experiments. The dataset contains 3400 users, each with a train/test data split, with a total of 671, 585 train and 77, 483 test images. We choose the first 2, 500 users as the initial training clients, leaving the remaining 900 clients for evaluation of personalization; these clients are not touched during training. The evaluation metrics are the initial and personalized accuracy, uniformly averaged among all of the FL-personalization clients. This is preferred to a weighted average, as in a production system we care about the future performance on each device, regardless of the amount of data available for personalization. Unless specified otherwise, we use the baseline convolutional model available in TensorFlow Federated (Ingerman & Ostrowski, 2019)1, using SGD with learning rate 0.02 and batch size of 20 as the client optimizer, and SGD with momentum of 0.9 and learning rate 1.0 as the server optimizer. Each experiment was repeated 9 times with random initialization, and the mean and standard deviation of initial and personalized accuracies are reported. We also use the shakespeare dataset for next-character prediction, split in a similar manner with first 500 clients used for training and remaining 215 for evaluation of personalization.
# 3.1 CONVERGENCE OF FEDAVG
In Figure 1, left, we present the convergence of both initial and personalized model during training using the Federated Averaging algorithm. The results correspond to training with $E$ being 2 and 10, with visualization of the empirical mean and variance observed in the 9 replicas of the experiment. Detailed values about performance after 500 rounds of training, and the number of rounds to reach $8 0 \%$ accuracy, are provided in Table 1. These results provide a number of valuable insights.
 Figure 1: Training Convergence on EMNIST-62 (left) and Shakespeare (right).
First, the personalized accuracy converges significantly higher than the initial accuracy. This clearly validates the EMNIST-62 as an interesting simulated dataset to use to study Federated Learning, with significantly non-i.i.d. data available to each client.
Second, it provides empirical support to the claim made in Section 2, that Federated Averaging is already a Meta Learning algorithm. The personalized accuracy not only converges faster and higher, but the results are also of much smaller variance than those of the initial accuracy.
Third, the personalized accuracy after training with $E = 1 0$ is significantly higher than the personalized accuracy after training with $E = 2$ . This is despite the fact that the gap in the initial accuracy between these two variants is somewhat smaller. Moreover, the variance of personalized accuracy is nearly 3-times smaller for training with $E = 1 0$ , compared to $E = 2$ , despite the variance of the initial accuracy being smaller for the $E = 2$ case. This supports the insight from Equation 5, that Federated Averaging with more gradient steps locally should emphasize the personalized accuracy more, potentially at the cost of initial accuracy.
Finally, this challenges the objectives in the existing literature focusing on the setting of Federated Learning. FedAvg was presented as optimizing the performance of a shared, global model, while in fact it might achieve this only as a necessary partial step towards optimizing the personalized performance. We argue that in the presence of non-i.i.d. data available to different clients, the objective of Federated Learning should also be the personalized performance. Consequently, the recommendations that in order to stabilize the convergence, one might decrease the number of local epochs or the local learning rate (McMahan et al., 2017; Wang & Joshi, 2018), are in some scenarios misguided. In this experiment, even though the initial accuracy is very noisy and roughly constant at a suboptimal level, the personalized accuracy keeps increasing.
To evaluate the convergence speed more closely, Table 1 measures the accuracies after 500 rounds of training and the average number of communication rounds where the initial and personalized accuracy first time reaches $8 0 \%$ . While Figure 1 shows results using 5 clients per round, the table below also shows the same experiment with 20 clients per round, which in general provides even better and more stable personalized accuracy. The common pattern is that increasing $E$ initially helps, until a certain threshold. From this experiment, $E$ in the range of $5 - 1 0$ seems to be the best.
We conduct a similar experiment with the Shakespeare data. The result is in Figure 1, right, but does not provide any interesting insights, as the personalized performance shows only a small positive improvement. We conjecture that this is due to the nature of the objective – even though the data is non-i.i.d., the next-character prediction is mostly focused on a local structure of the language in general, and is similar across all users.2 We thus do not study this problem further in this paper. It is likely that for a next-word prediction task, personalization would make a more significant difference.
<table><tr><td>EMNIST-625clients</td><td>Initial Acc</td><td>Personalized Acc</td><td>Epochs to O.8 (init/pers)</td></tr><tr><td>FedAvg E=2 FedAvg E=5</td><td>0.7473(0.0260) 0.8028 (0.0512)</td><td>0.8292 (0.0061) 0.8712 (0.0049)</td><td>310.0/63.6 111.1/33.9</td></tr><tr><td>FedAvg E=10</td><td>0.7879(0.0316)</td><td>0.8820 (0.0023)</td><td>137.5/30.0</td></tr><tr><td>FedAvg E=20</td><td>0.7430(0.0309)</td><td>0.8782 (0.0021)</td><td>152.5/32.2</td></tr><tr><td>EMNIST-62 20 clients</td><td></td><td></td><td></td></tr><tr><td>FedAvg E=2</td><td>0.8403 (0.0173)</td><td>0.8957 (0.0011)</td><td>82.5/50.0</td></tr><tr><td>FedAvg E=5</td><td>0.8471 (0.0084)</td><td>0.9057 (0.0017)</td><td>65.6/31.25</td></tr><tr><td>FedAvg E=10</td><td>0.8480 (0.0036)</td><td>0.9032 (0.0017)</td><td>68.7/25.0</td></tr><tr><td>FedAvg E=20</td><td>0.8391 1(0.0081)</td><td></td><td></td></tr><tr><td></td><td></td><td>0.8953 (0.0022)</td><td>82.1/46.4</td></tr></table>
Table 1: EMNIST-62 performance for 5 and 20 clients per communication round.
# 3.2 BEHAVIOR OF PERSONALIZATION
In this section, we study the ability of models to personalize more closely. In particular, we look at the personalization performance as a function of the number of local epochs spent personalizing, and the effect of both local personalization optimizer and the optimizer used to train the initial model.
In Figure 2, left, we study the performance of three different models, personalized using different local optimizers. The models we test here are: one randomly chosen from the models trained with $E = 1 0$ in the previous section, with initial accuracy of $7 4 . 4 1 \%$ . The other two models are the results of fine-tuning that specific model with Reptile(1) and Reptile(10) and Adam as the server optimizer for further 200 communication rounds, again using 5 clients per round. For all three models, we show the results of personalization using Adam with default parameters and using SGD with learning rate of 0.02 and batch size of 100.
 Figure 2: Personalized accuracy as a function of local update epochs. Federated initial models (left), initial models trained by centralizing data and using default Adam optimizer (right).
In all three cases, Adam produces reasonable personalized result, but inferior to the result of SGD. We tried SGD with a range of other learning rates, and in all cases we observed this value to work the best. Note that this is the same local optimizer that was used during training and fine tuning, which is similar to the MAML works, where the same algorithm is user for meta-training and meta-testing.
The effect of fine-tuning is very encouraging. Using Reptile(10), we get a model with better initial accuracy, which also gets to a slightly improved personalized accuracy. Most importantly, it gets to roughly the same performance for a wide range of local personalization epochs. Such property is of immense value for pracical deployment, as only limited tools for model quality validation can be available on the devices where personalization happens. Using Reptile(1) significantly improves the initial accuracy, but the personalized accuracy actually drops! Even though the Equation 5 suggests that this algorithm should not take into account the personalized performance, it is not clear that such result should be intuitively expected – it does not mean it actively supresses personalization, either, and it is only fine tuning of a model already trained for the personalized performance.
We note that this can be seen as an analogous observation to those of Nichol et al. (2018), where Reptile(1) yields a model with clearly inferior personalized performance.
Motivated by this somewhat surprising result, we ask the following question: If the training data were available in a central location, and an initial model was trained using standard optimization algorithms, how would the personalization change? We train such “centralized initial model” using Adam with default settings, and evaluate the personalization performance of a model snapshot after 10 and 50 training epochs. These two models have similar initial accuracies as the two models fine tuned with Reptile(10) and Reptile(1), respectively. The results are in Figure 2, right.
The main message is that it is significantly harder to personalize these centralized initial models. Using SGD with learning rate of 0.02 is not good – a significantly smaller learning rate is needed to prevent the models from diverging, and then the personalization improvement is relatively small. In this case, using Adam does provide a better result, but still below the fine tuning performance in Figure 2, left. It is worth noting that the personalized performance of this converged model is similar to that of the model we get after fine tuning with Reptile(1), although using different personalization optimizer. At the moment, we are unable to suggest a sound explanation for this similarity.
At the start of the Section 3, we recommended using Adam as the server optimizer for fine tuning, and here we only presented such results. We did try different optimizers, and found them to yield worse results with higher variance, especially in terms of the initial accuracy. See Appendix A.1 for more details, where we see that all of the optimizers can deliver higher initial accuracy at the cost of slightly lower personalized accuracy.
To strengthen the above observations, we look at the distribution of the initial and personalized accuracies of fine tuned models over multiple experiments. In Figure 3, we look at the same three models as in Figure 2. It is clear that the initial model has a large variance in the initial accuracy, the results are in the range of $1 2 \%$ , but the personalized accuracies are only within the range of $1 \%$ . We chose one model, as indicated by the arrows3, to be fine tuned with $R e p t i l e ( 1 0 )$ and Reptile(1). In both cases, fine tuning results in a more consistent results in both the initial and personalized accuracy. Moreover, the best personalized accuracy with Reptile(1) is worse than the worst personalized accuracy with Reptile(10).
 Figure 3: Distribution of initial and personalized accuracies of fine tuned models.
In Appendix A.2, we look at a similar visualization on a per-client basis for a given model. Studying this distribution is of great importance, as in practical deployment, even a small degradation in a user’s experience might incur disproportionate cost, relative to the benefit of a comparable improvement in the model quality. We do not study this question deeper in this work, though.
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Initial Acc</td><td rowspan=1 colspan=1>Personalized Acc</td></tr><tr><td rowspan=1 colspan=1>Reptile(1) Finetuned test clientsReptile(1) Finetuned train clients</td><td rowspan=1 colspan=1>0.8320 (0.0133)0.8577 (0.0019)</td><td rowspan=1 colspan=1>0.8764 (0.0017)0.8927 (0.0015)</td></tr><tr><td rowspan=1 colspan=1>Reptile(1O) Finetuned test clientsReptile(1O) Finetuned train clients</td><td rowspan=1 colspan=1>0.8116 (0.0148)0.8612 (0.0020)</td><td rowspan=1 colspan=1>0.8858 (0.0014)0.9028(0.0009)</td></tr></table>
Table 2: Test performance on clients seen and unseen during FL-training
Finally, we look at the performance of fine tuned models discussed above on both train and test clients. Table 2 shows that if we only looked at the initial accuracy, basic ML principles would suggest the Reptile(10) models are over-fitting, due to larger gap between the train and test clients. However, the personalized accuracy tells a different story - the gap is roughly the same for both model types, and for both train and test clients, Reptile(10) provides significantly better personalized accuracy, suggesting we need a novel way to predict the generalization of personalized models.
# 4 DISCUSSION AND FUTURE WORK
It this work, we argue that in the context of Federated Learning, the accuracy of the global model after personalization should be of much greater interest than it has been. Investigation of the topic reveals close similarities between the fields of Federated Learning and Model Agnostic Meta Learning, and raises new questions for these areas, as well as for the broader Machine Learning community.
Challenges for Federated Learning. Framing papers in the area of Federated Learning (McMahan et al., 2017; Konecnˇ y et al., 2016a; Li et al., 2019a), formulate the objective as training of a ´ shared global model, based on a decentralized data storage where each node / client has access to a non-i.i.d sample from the overall distribution. The objective is identical to one the broader ML community would optimize for, had all the data been available in a centralized location.
We argue that in this setting, the primary objective should be the adaptation to the statistical heterogeneity present at different data nodes, and demonstrate that the popular FL algorithm, Federated Averaging, does in fact optimize the personalized performance, and while doing so, also improves the performance of the global model. Experiments we perform demonstrate that the algorithm used to train the model has major influence on its capacity to personalize. Moreover, solely optimizing the accuracy of the global model tends to have negative impact on its capacity to personalize, which further questions the correctness of the commonly presented objectives of Federated Learning.
Challenges for Model Agnostic Meta Learning. The objectives in the Model Agnostic Meta Learning literature are usually only the model performance after adaptation to given task (Finn et al., 2017). In this work, we present the setting of Federated Learning as a good source of practical applications for MAML algorithms. However, to have impact in FL, these methods need to also consider the performance of the initial model,4 as in practice there will be many clients without data available for personalization. In addition, the connectivity constraints in a production deployment emphasize the importance of fast convergence in terms of number of communication rounds. We suggest these objectives become the subject of MAML works, in addition to the performance after adaptation, and to consider the datasets with a natural user/client structure being established for Federated Learning (Caldas et al., 2018b) as the source of experiments for supervised learning.
Challenges for broader Machine Learning. The empirical evaluation in this work raises a number of questions of relevance to Machine Learning research in general. In particular, Figure 2 clearly shows that models with similar initial accuracy can have very different capacity to personalize to a task of the same type as it was trained on. This observation raises obvious questions for which we currently cannot provide an answer. How does the training algorithm impact personalization ability of the trained model? Is there something we can measure that will predict the adaptability of the model? Is it something we can directly optimize for, potentially leading to novel optimization methods? These questions can relate to a gap highlighted in Table 2. While the common measures could suggest the global model is overfitting the training data, this is not true of the personalized model.
Transfer Learning is another technique for which our result could inspire a novel solution. It is very common for machine learning practitioners to take a trained model from the research community, replace the final layer with a different output class of interest, and retrain for the new task (Oquab et al., 2014). We conjecture that the algorithms proposed in the FL and MAML communities, could yield base models for which this kind of domain adaptation would yield better results.
Finally, we believe that a systematic analysis of optimization algorithms of the inner-outer structure presented in Algorithm 1 could provide novel insights into the connections between optimization and generalization. Apart from the FL and MAML algorithms, Zhang et al. (2019) recently proposed a method that can be interpreted as outer optimizer in the general algorithm, which improves the stability of a variety of existing optimization methods used as the inner optimizer.
# REFERENCES
Antreas Antoniou, Harrison Edwards, and Amos Storkey. How to train your maml. arXiv preprint arXiv:1810.09502, 2018.
Francoise Beaufays, Khe Chai Sim, and Petr Zadrazil. An investigation into on-device personalization of end-to-end automatic speech recognition models. In Interspeech, 2019.
Keith Bonawitz, Vladimir Ivanov, Ben Kreuter, Antonio Marcedone, H Brendan McMahan, Sarvar Patel, Daniel Ramage, Aaron Segal, and Karn Seth. Practical secure aggregation for privacypreserving machine learning. In Proceedings of the 2017 ACM SIGSAC Conference on Computer and Communications Security, pp. 1175–1191. ACM, 2017.
Keith Bonawitz, Hubert Eichner, Wolfgang Grieskamp, Dzmitry Huba, Alex Ingerman, Vladimir Ivanov, Chloe Kiddon, Jakub Kone ´ cnˇ y, Stefano Mazzocchi, H Brendan McMahan, Timon ´ Van Overveldt, David Petrou, Daniel Ramage, and Jason Roselander. Towards federated learning at scale: System design. 2019.
Sebastian Caldas, Jakub Konecnˇ y, H Brendan McMahan, and Ameet Talwalkar. Expanding ´ the reach of federated learning by reducing client resource requirements. arXiv preprint arXiv:1812.07210, 2018a.
Sebastian Caldas, Peter Wu, Tian Li, Jakub Konecnˇ y, H Brendan McMahan, Virginia Smith, and ´ Ameet Talwalkar. Leaf: A benchmark for federated settings. arXiv preprint arXiv:1812.01097, 2018b.
Jeffrey Dean, Greg Corrado, Rajat Monga, Kai Chen, Matthieu Devin, Mark Mao, Marc’aurelio Ranzato, Andrew Senior, Paul Tucker, Ke Yang, et al. Large scale distributed deep networks. In Advances in neural information processing systems, pp. 1223–1231, 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 LearningVolume 70, pp. 1126–1135. JMLR. org, 2017.
Andrew Hard, Kanishka Rao, Rajiv Mathews, Franc¸oise Beaufays, Sean Augenstein, Hubert Eichner, Chloe Kiddon, and Daniel Ramage. Federated learning for mobile keyboard prediction. ´ arXiv preprint arXiv:1811.03604, 2018.
Alex Ingerman and Krzys Ostrowski. Introducing tensorflow federated, 2019. URL https://medium.com/tensorflow/ introducing-tensorflow-federated-a4147aa20041.
Mikhail Khodak, Maria Florina-Balcan, and Ameet Talwalkar. Adaptive gradient-based metalearning methods. arXiv preprint arXiv:1906.02717, 2019.
Jakub Konecnˇ y, H Brendan McMahan, Daniel Ramage, and Peter Richt ´ arik. Federated optimization: ´ Distributed machine learning for on-device intelligence. arXiv preprint arXiv:1610.02527, 2016a.
Jakub Konecnˇ y, H Brendan McMahan, Felix X Yu, Peter Richt´ arik, Ananda Theertha Suresh, and´ Dave Bacon. Federated learning: Strategies for improving communication efficiency. arXiv preprint arXiv:1610.05492, 2016b.
Brenden M Lake, Ruslan Salakhutdinov, and Joshua B Tenenbaum. Human-level concept learning through probabilistic program induction. Science, 350(6266):1332–1338, 2015.
Yann LeCun, Yoshua Bengio, and Geoffrey Hinton. Deep learning. nature, 521(7553):436, 2015.
Tian Li, Anit Kumar Sahu, Ameet Talwalkar, and Virginia Smith. Federated learning: Challenges, methods, and future directions. arXiv preprint arXiv:1908.07873, 2019a.
Xiang Li, Kaixuan Huang, Wenhao Yang, Shusen Wang, and Zhihua Zhang. On the convergence of fedavg on non-iid data. arXiv preprint arXiv:1907.02189, 2019b.
Brendan McMahan, Eider Moore, Daniel Ramage, Seth Hampson, and Blaise Aguera y Arcas. Communication-efficient learning of deep networks from decentralized data. In Artificial Intelligence and Statistics, pp. 1273–1282, 2017. H Brendan McMahan and Daniel Ramage. Federated learning: Collaborative machine learning without centralized training data, 2017. https://ai.googleblog.com/2017/04/ federated-learning-collaborative.html. H Brendan McMahan, Daniel Ramage, Kunal Talwar, and Li Zhang. Learning differentially private recurrent language models. In International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ BJ0hF1Z0b. Alex Nichol, Joshua Achiam, and John Schulman. On first-order meta-learning algorithms. arXiv preprint arXiv:1803.02999, 2018. Maxime Oquab, Leon Bottou, Ivan Laptev, and Josef Sivic. Learning and transferring mid-level image representations using convolutional neural networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 1717–1724, 2014. Jianyu Wang and Gauri Joshi. Adaptive communication strategies to achieve the best error-runtime trade-off in local-update sgd. arXiv preprint arXiv:1810.08313, 2018. Qiang Yang, Yang Liu, Tianjian Chen, and Yongxin Tong. Federated machine learning: Concept and applications. ACM Transactions on Intelligent Systems and Technology (TIST), 10(2):12, 2019. Michael R Zhang, James Lucas, Geoffrey Hinton, and Jimmy Ba. Lookahead optimizer: k steps forward, 1 step back. arXiv preprint arXiv:1907.08610, 2019.
# A APPENDIX
This Appendix contains further details referenced from the main body of the paper.
# A.1 FINE TUNING OPTIMIZERS
Table 3 summarizes the attempts at fine tuning the model user in main body with different server optimizers. We see that comparing the same client optimizers, Adam consistently provides better and more stable results in terms of initial accuracy.
Table 3: Fine-tuning Result of EMNIST-62 with different server optimizers.
<table><tr><td rowspan=1 colspan=1>EMNIST-62 Model</td><td rowspan=1 colspan=1>Initial Acc</td><td rowspan=1 colspan=1>Pers Acc</td></tr><tr><td rowspan=1 colspan=1>FedAvg E=10 w/o finetuning Momentum(lr=1.0, 0.9)</td><td rowspan=1 colspan=1>0.7441</td><td rowspan=1 colspan=1>0.8842</td></tr><tr><td rowspan=1 colspan=1>Finetune with FedSGD (Reptile(1)) AdamFinetune with Reptile(5) AdamFinetune with Reptile(10) Adam</td><td rowspan=1 colspan=1>0.8320 (0.0133)0.8265 (0.0160)0.8116 (0.0148)</td><td rowspan=1 colspan=1>0.8764 (0.0017)0.8807 (0.0020)0.8858 (0.0014)</td></tr><tr><td rowspan=1 colspan=1>Finetune with Reptile(1) SGD(lr=0.1)Finetune with Reptile(1) Momentum(lr=0.01, 0.9)</td><td rowspan=1 colspan=1>0.8260 (0.0161)0.8279 (0.0119)</td><td rowspan=1 colspan=1>0.8758 (0.0020)0.8745 (0.0014)</td></tr><tr><td rowspan=1 colspan=1>Finetune with Reptile(5) SGD(lr=0.1)Finetune with Reptile(5) Momentum(lr=0.01, 0.9)</td><td rowspan=1 colspan=1>0.8148 (0.0280)0.8005 (0.0329)</td><td rowspan=1 colspan=1>0.8829 (0.0012)0.8828 (0.0015)</td></tr><tr><td rowspan=1 colspan=1>Finetune with Reptile(10) SGD(lr=0.1)Finetune with Reptile(10) Momentum(lr=0.01, 0.9)</td><td rowspan=1 colspan=1>0.8074 (0.0294)0.8140 (0.0246)</td><td rowspan=1 colspan=1>0.8855 (0.0012)0.8860 (0.0009)</td></tr></table>
# A.2 PER-CLIENT PERSONALIZATION RESULTS
Figure 4 visualizes the distribution of initial and personalized accuracies on a per-client basis. Each dot represents a random sample of the test clients used for personalization experiments. Studying this distribution is of great importance, as in practical deployment, degrading a user’s experience might incur disproportionate cost, compared to the benefit of comparable improvement. Designing methods that robustly identify the clients below the diagonal line and at least revert to the initial model is worth of future investigation.
 Figure 4: Performance for sample of test clients for EMNIST-62 (left) and Shakespeare (right)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292# NeuS: Learning Neural Implicit Surfaces by Volume Rendering for Multi-view Reconstruction
Peng Wang†, Lingjie $\mathbf { L i u } ^ { \ddagger * }$ , Yuan $\mathbf { L i u } ^ { \dagger }$ , Christian Theobalt‡, Taku Komura†, Wenping Wang∗
†The University of Hong Kong ‡Max Planck Institute for Informatics Texas A&M University †{pwang3,yliu,taku}@cs.hku.hk ‡{lliu,theobalt}@mpi-inf.mpg.de wenping@tamu.edu
# Abstract
We present a novel neural surface reconstruction method, called NeuS, for reconstructing objects and scenes with high fidelity from 2D image inputs. Existing neural surface reconstruction approaches, such as DVR [Niemeyer et al., 2020] and IDR [Yariv et al., 2020], require foreground mask as supervision, easily get trapped in local minima, and therefore struggle with the reconstruction of objects with severe self-occlusion or thin structures. Meanwhile, recent neural methods for novel view synthesis, such as NeRF [Mildenhall et al., 2020] and its variants, use volume rendering to produce a neural scene representation with robustness of optimization, even for highly complex objects. However, extracting high-quality surfaces from this learned implicit representation is difficult because there are not sufficient surface constraints in the representation. In NeuS, we propose to represent a surface as the zero-level set of a signed distance function (SDF) and develop a new volume rendering method to train a neural SDF representation. We observe that the conventional volume rendering method causes inherent geometric errors (i.e. bias) for surface reconstruction, and therefore propose a new formulation that is free of bias in the first order of approximation, thus leading to more accurate surface reconstruction even without the mask supervision. Experiments on the DTU dataset and the BlendedMVS dataset show that NeuS outperforms the state-of-the-arts in high-quality surface reconstruction, especially for objects and scenes with complex structures and self-occlusion.
# 1 Introduction
Reconstructing surfaces from multi-view images is a fundamental problem in computer vision and computer graphics. 3D reconstruction with neural implicit representations has recently become a highly promising alternative to classical reconstruction approaches [35, 8, 2] due to its high reconstruction quality and its potential to reconstruct complex objects that are difficult for classical approaches, such as non-Lambertian surfaces and thin structures. Recent works represent surfaces as signed distance functions (SDF) [46, 49, 17, 22] or occupancy [29, 30]. To train their neural models, these methods use a differentiable surface rendering method to render a 3D object into images and compare them against input images for supervision. For example, IDR [46] produces impressive reconstruction results, but it fails to reconstruct objects with complex structures that causes abrupt depth changes. The cause of this limitation is that the surface rendering method used in IDR only considers a single surface intersection point for each ray. Consequently, the gradient only exists at this single point, which is too local for effective back propagation and would get optimization stuck in a poor local minimum when there are abrupt changes of depth on images. Furthermore, object masks are needed as supervision for converging to a valid surface. As illustrated in Fig. 1 (a) top, with the radical depth change caused by the hole, the neural network would incorrectly predict the points near the front surface to be blue, failing to find the far-back blue surface. The actual test example in Fig. 1 (b) shows that IDR fails to correctly reconstruct the surfaces near the edges with abrupt depth changes.
Recently, NeRF [28] and its variants have explored to use a volume rendering method to learn a volumetric radiance field for novel view synthesis. This volume rendering approach samples multiple points along each ray and perform $\alpha$ -composition of the colors of the sampled points to produce the output pixel colors for training purposes. The advantage of the volume rendering approach is that it can handle abrupt depth changes, because it considers multiple points along the ray and so all the sample points, either near the surface or on the far surface, produce gradient signals for back propagation. For example, referring Fig. 1 (a) bottom, when the near surface (yellow) is found to have inconsistent colors with the input image, the volume rendering approach is capable of training the network to find the far-back surface to produce the correct scene representation. However, since it is intended for novel view synthesis rather than surface reconstruction, NeRF only learns a volume density field, from which it is difficult to extract a high-quality surface. Fig. 1 (b) shows a surface extracted as a level-set surface of the density field learned by NeRF. Although the surface correctly accounts for abrupt depth changes, it contains conspicuous noise in some planar regions.
 Figure 1: (a) Illustration of the surface rendering and volume rendering. (b) A toy example of bamboo planter, where there are occlusions on the top of the planter. Compared to the state-of-the-art methods, our approach can handle the occlusions and achieve better reconstruction quality.
In this work, we present a new neural rendering scheme, called NeuS, for multi-view surface reconstruction. NeuS uses the signed distance function (SDF) for surface representation and uses a novel volume rendering scheme to learn a neural SDF representation. Specifically, by introducing a density distribution induced by SDF, we make it possible to apply the volume rendering approach to learning an implicit SDF representation and thus have the best of both worlds, i.e. an accurate surface representation using a neural SDF model and robust network training in the presence of abrupt depth changes as enabled by volume rendering. Note that simply applying a standard volume rendering method to the density associated with SDF would lead to discernible bias (i.e. inherent geometric errors) in the reconstructed surfaces. This is a new and important observation that we will elaborate later. Therefore we propose a novel volume rendering scheme to ensure unbiased surface reconstruction in the first-order approximation of SDF. Experiments on both DTU dataset and BlendedMVS dataset demonstrated that NeuS is capable of reconstructing complex 3D objects and scenes with severe occlusions and delicate structures, even without foreground masks as supervision. It outperforms the state-of-the-art neural scene representation methods, namely IDR [46] and NeRF [28], in terms of reconstruction quality.
# 2 Related Works
Classical Multi-view Surface and Volumetric Reconstruction. Traditional multi-view 3D reconstruction methods can be roughly classified into two categories: point- and surface-based reconstruction [2, 8, 9, 35] and volumetric reconstruction [6, 3, 36]. Point- and surface-based reconstruction methods estimate the depth map of each pixel by exploiting inter-image photometric consistency [8] and then fuse the depth maps into a global dense point cloud [25, 48]. The surface reconstruction is usually done as a post processing with methods like screened Poisson surface reconstruction [16]. The reconstruction quality heavily relies on the quality of correspondence matching, and the difficulties in matching correspondence for objects without rich textures often lead to severe artifacts and missing parts in the reconstruction results. Alternatively, volumetric reconstruction methods circumvent the difficulty of explicit correspondence matching by estimating occupancy and color in a voxel grid from multi-view images and evaluating the color consistency of each voxel. Due to limited achievable voxel resolution, these methods cannot achieve high accuracy.
Neural Implicit Representation. Some methods enforce 3D understanding in a deep learning framework by introducing inductive biases. These inductive biases can be explicit representations, such as voxel grids [13, 5, 44], point cloud [7, 24, 18], meshes [41, 43, 14], and implicit representations. The implicit representations encoded by a neural network has gained a lot of attention recently, since it is continuous and can achieve high spatial resolution. This representation has been applied successfully to shape representation [26, 27, 31, 4, 1, 10, 47, 32], novel view synthesis [38, 23, 15, 28, 21, 33, 34, 40, 37] and multi-view 3D reconstruction [46, 29, 17, 12, 22].
Our work mainly focuses on learning implicit neural representation encoding both geometry and appearance in 3D space from 2D images via classical rendering techniques. Limited in this scope, the related works can be roughly categorized based on the rendering techniques used, i.e. surface rendering based methods and volume rendering based methods. Surface rendering based methods [29, 17, 46, 22] assume that the color of ray only relies on the color of an intersection of the ray with the scene geometry, which makes the gradient only backpropagated to a local region near the intersection. Therefore, such methods struggle with reconstructing complex objects with severe self-occlusions and sudden depth changes. Furthermore, they usually require object masks as supervision. On the contrary, our method performs well for such challenging cases without the need of masks.
Volume rendering based methods, such as NeRF[28], render an image by $\alpha$ -compositing colors of the sampled points along each ray. As explained in the introduction, it can handle sudden depth changes and synthesize high-quality images. However, extracting high-fidelity surface from the learned implicit field is difficult because the density-based scene representation lacks sufficient constraints on its level sets. In contrast, our method combines the advantages of surface rendering based and volume rendering based methods by constraining the scene space as a signed distance function but applying volume rendering to train this representation with robustness. UNISURF [30], a concurrent work, also learns an implicit surface via volume rendering. It improves the reconstruction quality by shrinking the sample region of volume rendering during the optimization. Our method differs from UNISURF in that UNISURF represents the surface by occupancy values, while our method represents the scene by an SDF and thus can naturally extract the surface as the zero-level set of it, yielding better reconstruction accuracy than UNISURF, as will be seen later in the experiment section.
# 3 Method
Given a set of posed images $\{ \mathcal { T } _ { k } \}$ of a 3D object, our goal is to reconstruct the surface $s$ of it. The surface is represented by the zero-level set of a neural implicit SDF. In order to learn the weights of the neural network, we developed a novel volume rendering method to render images from the implicit SDF and minimize the difference between the rendered images and the input images. This volume rendering approach ensures robust optimization in NeuS for reconstructing objects of complex structures.
# 3.1 Rendering Procedure
Scene representation. With NeuS, the scene of an object to be reconstructed is represented by two functions: $f : \mathbb { R } ^ { 3 } \mathbb { R }$ that maps a spatial position $\mathbf { x } \in \mathbb { R } ^ { 3 }$ to its signed distance to the object, and $c : \mathbb { R } ^ { 3 } \times \mathbb { S } ^ { \breve { 2 } } \to \mathbb { R } ^ { 3 }$ that encodes the color associated with a point $\bar { \mathbf { x } } \in \mathbb { R } ^ { 3 }$ and a viewing direction $\mathbf { v } \in \mathbb { S } ^ { 2 }$ . Both functions are encoded by Multi-layer Perceptrons (MLP). The surface $s$ of the object is represented by the zero-level set of its SDF, that is,
$$\begin{array} { r } { S = \left\{ { \bf x } \in \mathbb { R } ^ { 3 } | f ( { \bf x } ) = 0 \right\} . } \end{array}$$
In order to apply a volume rendering method to training the SDF network, we first introduce a probability density function $\phi _ { s } ( f ( \mathbf { x } ) )$ , called $s$ -density, where $f ( \mathbf { x } )$ , $\mathbf { x } \in \mathbb { R } ^ { 3 }$ , is the signed distance function and $\phi _ { s } ( x ) = s e ^ { - s x } / ( 1 + e ^ { - s x } ) ^ { 2 }$ , commonly known as the logistic density distribution, is the derivative of the Sigmoid function $\dot { \Phi } _ { s } ( x ) = ( 1 \dot { + } e ^ { - s x } ) ^ { - 1 }$ , i.e., $\bar { \phi _ { s } } ( x ) = \Phi _ { s } ^ { \prime } ( x )$ . In principle $\phi _ { s } ( x )$ can be any unimodal (i.e. bell-shaped) density distribution centered at 0; here we choose the logistic density distribution for its computational convenience. Note that the standard deviation of $\phi _ { s } ( x )$ is given by $1 / s$ , which is also a trainable parameter, that is, $1 / s$ approaches to zero as the network training converges.
Intuitively, the main idea of NeuS is that, with the aid of the S-density field $\phi _ { s } ( f ( \mathbf { x } ) )$ , volume rendering is used to train the SDF network with only 2D input images as supervision. Upon successful minimization of a loss function based on this supervision, the zero-level set of the network-encoded SDF is expected to represent an accurately reconstructed surface $s$ , with its induced S-density $\phi _ { s } ( f ( \mathbf { x } ) )$ assuming prominently high values near the surface.
Rendering. To learn the parameters of the neural SDF and color field, we advise a volume rendering scheme to render images from the proposed SDF representation. Given a pixel, we denote the ray emitted from this pixel as $\{ \mathbf { p } ( t ) = \mathbf { \bar { o } } + t \mathbf { v } | t \geq 0 \}$ , where $\mathbf { o }$ is the center of the camera and $\mathbf { v }$ is the unit direction vector of the ray. We accumulate the colors along the ray by
$$C ( \mathbf { o } , \mathbf { v } ) = \int _ { 0 } ^ { + \infty } w ( t ) c ( \mathbf { p } ( t ) , \mathbf { v } ) \mathrm { d } t ,$$
where $C ( \mathbf { o } , \mathbf { v } )$ is the output color for this pixel, $w ( t )$ a weight for the point $\mathbf { p } ( t )$ , and $c ( \mathbf { p } ( t ) , \mathbf { v } )$ the color at the point $\mathbf { p }$ along the viewing direction $\mathbf { v }$ .
Requirements on weight function. The key to learn an accurate SDF representation from 2D images is to build an appropriate connection between output colors and SDF, i.e., to derive an appropriate weight function $w ( t )$ on the ray based on the SDF $f$ of the scene. In the following, we list the requirements on the weight function $w ( t )$ .
1. Unbiased. Given a camera ray $\mathbf { p } ( t ) , w ( t )$ attains a locally maximal value at a surface intersection point $\mathbf { p } ( t ^ { * } )$ , i.e. with $f ( \mathbf { p } ( t ^ { * } ) ) = 0$ , that is, the point $\mathbf { p } ( t ^ { * } )$ is on the zero-level set of the SDF $\mathbf { \rho } ( \mathbf { x } )$ . 2. Occlusion-aware. Given any two depth values $t _ { 0 }$ and $t _ { 1 }$ satisfying $f ( t _ { 0 } ) = f ( t _ { 1 } )$ , $w ( t _ { 0 } ) >$ 0, $w ( t _ { 1 } ) > 0$ , and $t _ { 0 } < t _ { 1 }$ , there is $w ( t _ { 0 } ) > w ( t _ { 1 } )$ . That is, when two points have the same SDF value (thus the same SDF-induced S-density value), the point nearer to the view point should have a larger contribution to the final output color than does the other point.
An unbiased weight function $w ( t )$ guarantees that the intersection of the camera ray with the zero-level set of SDF contributes most to the pixel color. The occlusion-aware property ensures that when a ray sequentially passes multiple surfaces, the rendering procedure will correctly use the color of the surface nearest to the camera to compute the output color.
Next, we will first introduce a naive way of defining the weight function $w ( t )$ that directly using the standard pipeline of volume rendering, and explain why it is not appropriate for reconstruction before introducing our novel construction of $w ( t )$ .
 Figure 2: Illustration of (a) weight bias of naive solution, and (b) the weight function defined in our solution, which is unbiased in the first-order approximation of SDF.
Naive solution. To make the weight
function occlusion-aware, a natural solution is based on the standard volume rendering formulation [28] which defines the weight function by
$$w ( t ) = T ( t ) \sigma ( t ) ,$$
where $\sigma ( t )$ is the so-called volume density in classical volume rendering and $\begin{array} { r l } { T ( t ) } & { { } = } \end{array}$ $\begin{array} { r } { \exp ( - \int _ { 0 } ^ { t } \sigma ( u ) \mathrm { d } u ) } \end{array}$ here denotes the accumulated transmittance along the ray. To adopt the standard volume density formulation [28], here $\sigma ( t )$ is set to be equal to the S-density value, i.e. $\sigma ( t ) = \phi _ { s } ( f ( \mathbf { p } ( t ) ) )$ and the weight function $w ( t )$ is computed by Eqn. 3. Although the resulting weight function is occlusion-aware, it is biased as it introduces inherent errors in the reconstructed surfaces. As illustrated in Fig. 2 (a), the weight function $w ( t )$ attains a local maximum at a point before the ray reaches the surface point $\mathbf { p } ( t ^ { * } )$ , satisfying $f ( \dot { \mathbf { p } } ( t ^ { * } ) ) = 0$ . This fact will be proved in the supplementary material.
Our solution. To introduce our solution, we first introduce a straightforward way to construct an unbiased weight function, which directly uses the normalized S-density as weights
$$w ( t ) = \frac { \phi _ { s } ( f ( \mathbf { p } ( t ) ) ) } { \int _ { 0 } ^ { + \infty } \phi _ { s } ( f ( \mathbf { p } ( u ) ) ) \mathrm { d } u } .$$
This construction of weight function is unbiased, but not occlusion-aware. For example, if the ray penetrates two surfaces, the SDF function $f$ will have two zero points on the ray, which leads to two peaks on the weight function $w ( t )$ and the resulting weight function will equally blend the colors of two surfaces without considering occlusions.
To this end, now we shall design the weight function $w ( t )$ that is both occlusion-aware and unbiased in the first-order approximation of SDF, based on the aforementioned straightforward construction. To ensure an occlusion-aware property of the weight function $w ( t )$ , we will still follow the basic framework of volume rendering as Eqn. 3. However, different from the conventional treatment as in naive solution above, we define our function $w ( t )$ from the S-density in a new manner. We first define an opaque density function $\rho ( t )$ , which is the counterpart of the volume density $\sigma$ in standard volume rendering. Then we compute the new weight function $w ( t )$ by
$$w ( t ) = T ( t ) \rho ( t ) , \mathrm { w h e r e } T ( t ) = \exp \left( - \int _ { 0 } ^ { t } \rho ( u ) \mathrm { d } u \right) .$$
How we derive opaque density $\rho$ . We will first consider a simple case where there is only one surface intersection, and the surface is simply a plane. Since Eqn. 4 indeed satisfies the above requirements under this assumption, we derive the underlying opaque density $\rho$ corresponding to the weight definition of Eqn. 4 using the framework of volume rendering. Then we will generalize this opaque density to the general case of multiple surface intersections.
Specifically, in the simple case of a single plane intersection, it is easy to see that the signed distance function $\dot { f ( \mathbf { p } ( t ) ) }$ is $- | \mathrm { { { c o s } } } ( \theta ) | \cdot ( t - t ^ { * } )$ , where $f ( \mathbf { p } ( t ^ { * } ) ) = 0$ , and $\theta$ is the angle between the view direction $\mathbf { v }$ and the outward surface normal vector $\mathbf { n }$ . Because the surface is assumed locally, $| \cos ( \theta ) |$ is a constant. It follows from Eqn. 4 that
$$\begin{array} { r l } & { w ( t ) = \frac { \phi _ { s } \left( f \left( \mathbf { p } ( t ) \right) \right) } { \int _ { - \infty } ^ { + \infty } \phi _ { s } \left( f \left( \mathbf { p } ( u ) \right) \right) \mathrm { d } u } } \\ & { \quad = \frac { \phi _ { s } \left( f \left( \mathbf { p } ( t ) \right) \right) } { \int _ { - \infty } ^ { + \infty } \phi _ { s } \left( - | \cos ( \theta ) | \cdot \left( u - t ^ { * } \right) \right) \mathrm { d } u } } \\ & { \quad = \frac { \phi _ { s } \left( f \left( \mathbf { p } ( t ) \right) \right) } { | \cos ( \theta ) | ^ { - 1 } \cdot \int _ { - \infty } ^ { + \infty } \phi _ { s } \left( u - t ^ { * } \right) \mathrm { d } u } } \\ & { \quad = | \cos ( \theta ) | \phi _ { s } \left( f ( \mathbf { p } ( t ) ) \right) . } \end{array}$$
Recall that the weight function within the framework of volume rendering is given by $w ( t ) =$ $T ( t ) \rho ( t )$ , where $\begin{array} { r } { T ( t ) = \exp ( - \int _ { 0 } ^ { t } \rho ( u ) \mathrm { d } u ) } \end{array}$ denotes the accumulated transmittance. Therefore, to derive $\rho ( t )$ , we have
$$T ( t ) \rho ( t ) = | \cos ( \theta ) | \phi _ { s } ( f ( \mathbf { p } ( t ) ) ) .$$
Since $\begin{array} { r } { T ( t ) = \exp ( - \int _ { 0 } ^ { t } \rho ( u ) \mathrm { d } u ) } \end{array}$ , it is easy to verify that $\begin{array} { r } { T ( t ) \rho ( t ) = - \frac { \mathrm { d } T } { \mathrm { d } t } ( t ) } \end{array}$ . Further, note that $\begin{array} { r } { | \cos ( \theta ) | \phi _ { s } ( f ( \mathbf { p } ( t ) ) ) = - \frac { \mathrm { d } \Phi _ { s } } { \mathrm { d } t } ( f ( \mathbf { p } ( t ) ) ) } \end{array}$ . It follows that $\begin{array} { r } { \frac { \mathrm { d } T } { \mathrm { d } t } ( t ) = \frac { \mathrm { d } \Phi _ { s } } { \mathrm { d } t } ( f ( \mathbf { p } ( t ) ) ) } \end{array}$ . Integrating both sides of this equation yields
$$T ( t ) = \Phi _ { s } ( f ( \mathbf { p } ( t ) ) ) .$$
Taking the logarithm and then differentiating both sides, we have
$$\begin{array} { r l r } { { \int _ { - \infty } ^ { t } \rho ( u ) \mathrm { d } u = - \ln ( \Phi _ { s } ( f ( \mathbf { p } ( t ) ) ) ) } } \\ & { } & { \Rightarrow \rho ( t ) = \frac { - \frac { \mathrm { d } \Phi _ { s } } { \mathrm { d } t } ( f ( \mathbf { p } ( t ) ) ) } { \Phi _ { s } ( f ( \mathbf { p } ( t ) ) ) } . } \end{array}$$
This is the formula of the opaque density $\rho ( t )$ in case of single plane intersection. The weight function $w ( t )$ induced by $\rho ( t )$ is shown in Figure 2(b). Now we generalize the opaque density to the general case where there are multiple surface intersections along the ray $\mathbf { p } ( t )$ . In this case, $\begin{array} { r l } { - \frac { \mathrm { d } \Phi _ { s } } { \mathrm { d } t _ { * } } ( f ( \mathbf { p } ( t ) ) ) } & { { } } \end{array}$ becomes negative on the segment of the ray with increasing SDF values. Thus we clip it against zero to ensure that the value of $\rho$ is always non-negative. This gives the following opaque density function $\bar { \rho } ( t )$ in general cases.
$$\rho ( t ) = \mathrm { m a x } \left( \frac { - \frac { \mathrm { d } \Phi _ { s } } { \mathrm { d } t } ( f ( \mathbf { p } ( t ) ) ) } { \Phi _ { s } ( f ( \mathbf { p } ( t ) ) ) } , 0 \right) .$$
 Figure 3: Illustration of weight distribution in case of multiple surface intersection.
Based on this equation, the weight function $w ( t )$ can be computed with standard volume rendering as in Eqn. 5. The illustration in the case of multiple surface intersection is shown in Figure 3.
The following theorem states that in general cases (i.e., including both single surface intersection and multiple surface intersections) the weight function defined by Eqn. 10 and Eqn. 5 is unbiased in the first-order approximation of SDF. The proof is given in the supplementary material.
Theorem 1 Suppose that a smooth surface $\mathbb { S }$ is defined by the zero-level set of the signed distance function $f ( \mathbf { x } ) = 0$ , and a ray $\mathbf { p } ( t ) = \mathbf { o } + t \mathbf { v }$ enters the surface $\mathbb { S }$ from outside to inside, with the intersection point at $\mathbf { p } ( t ^ { * } )$ , that is, $f ( \mathbf { p } ( t ^ { * } ) ) = 0$ and there exists an interval $[ t _ { l } , t _ { r } ]$ such that $t ^ { * } \in [ t _ { l } , t _ { r } ]$ and $f ( \mathbf { p } ( t ) )$ is monotonically decreasing in $[ t _ { l } , t _ { r } ]$ . Suppose that in this local interval $[ t _ { l } , t _ { r } ]$ , the surface can be tangentially approximated by a sufficiently small planar patch, i.e., ∇f is regarded as fixed. Then, the weight function $w ( t )$ computed by Eqn. 10 and Eqn. 5 in $[ t _ { l } , t _ { r } ]$ attains its maximum at $t ^ { * }$ .
Discretization. To obtain discrete counterparts of the opacity and weight function, we adopt the same approximation scheme as used in NeRF [28], This scheme samples $n$ points $\{ { \bf p } _ { i } = { \bf o } + t _ { i } { \bf v } | i =$ $1 , . . . , n , t _ { i } < t _ { i + 1 } \}$ along the ray to compute the approximate pixel color of the ray as
$$\hat { C } = \sum _ { i = 1 } ^ { n } T _ { i } \alpha _ { i } c _ { i } ,$$
where $T _ { i }$ is the discrete accumulated transmittance defined by $\begin{array} { r } { T _ { i } = \prod _ { j = 1 } ^ { i - 1 } ( 1 - \alpha _ { j } ) } \end{array}$ , and $\alpha _ { i }$ is discrete opacity values defined by
$$\alpha _ { i } = 1 - \exp \left( - \int _ { t _ { i } } ^ { t _ { i + 1 } } \rho ( t ) \mathrm { d } t \right) ,$$
which can further be shown to be
$$\alpha _ { i } = \operatorname* { m a x } \left( \frac { \Phi _ { s } ( f ( \mathbf { p } ( t _ { i } ) ) ) - \Phi _ { s } ( f ( \mathbf { p } ( t _ { i + 1 } ) ) ) } { \Phi _ { s } ( f ( \mathbf { p } ( t _ { i } ) ) ) } , 0 \right) .$$
The detailed derivation of this formula for $\alpha _ { i }$ is given in the supplementary material.
# 3.2 Training
To train NeuS, we minimize the difference between the rendered colors and the ground truth colors, without any 3D supervision. Besides colors, we can also utilize the masks for supervision if provided.
Specifically, we optimize our neural networks and inverse standard deviation $s$ by randomly sampling a batch of pixels and their corresponding rays in world space $P = \{ C _ { k } , M _ { k } , \mathbf { o } _ { k } , \mathbf { \bar { v } } _ { k } \}$ , where $C _ { k }$ is its pixel color and $M _ { k } \in \{ 0 , 1 \}$ is its optional mask value, from an image in every iteration. We assume the point sampling size is $n$ and the batch size is $m$ . The loss function is defined as
$$\mathcal { L } = \mathcal { L } _ { c o l o r } + \lambda \mathcal { L } _ { r e g } + \beta \mathcal { L } _ { m a s k } .$$
The color loss $\mathcal { L } _ { c o l o r }$ is defined as
$$\mathcal { L } _ { c o l o r } = \frac { 1 } { m } \sum _ { k } \mathcal { R } ( \hat { C } _ { k } , C _ { k } ) .$$
Same as IDR[46], we empirically choose $\mathcal { R }$ as L1 loss, which in our observation is robust to outliers and stable in training.
We add an Eikonal term [10] on the sampled points to regularize the SDF of $f _ { \theta }$ by
$$\mathcal { L } _ { r e g } = \frac { 1 } { n m } \sum _ { k , i } ( \| \nabla f ( \hat { \mathbf { p } } _ { k , i } ) \| _ { 2 } - 1 ) ^ { 2 } .$$
The optional mask loss $\mathcal { L } _ { m a s k }$ is defined as
$$\mathcal { L } _ { m a s k } = \mathbf { B C E } ( M _ { k } , \hat { O } _ { k } ) ,$$
where $\begin{array} { r } { \hat { O } _ { k } = \sum _ { i = 1 } ^ { n } T _ { k , i } \alpha _ { k , i } } \end{array}$ is the sum of weights along the camera ray, and BCE is the binary cross entropy loss.
Hierarchical sampling. In this work, we follow a similar hierarchical sampling strategy as in NeRF [28]. We first uniformly sample the points on the ray and then iteratively conduct importance sampling on top of the coarse probability estimation. The difference is that, unlike NeRF which simultaneously optimizes a coarse network and a fine network, we only maintain one network, where the probability in coarse sampling is computed based on the S-density $\phi _ { s } ( f ( \mathbf { x } ) )$ with fixed standard deviations while the probability of fine sampling is computed based on $\phi _ { s } ( f ( \mathbf { x } ) )$ with the learned $s$ Details of hierarchical sampling strategy are provided in supplementary materials.
# 4 Experiments
# 4.1 Experimental settings
Datasets. To evaluate our approach and baseline methods, we use 15 scenes from the DTU dataset [11], same as those used in IDR [46], with a wide variety of materials, appearance and geometry, including challenging cases for reconstruction algorithms, such as non-Lambertian surfaces and thin structures. Each scene contains 49 or 64 images with the image resolution of $1 6 0 0 \times 1 2 0 0$ Each scene was tested with and without foreground masks provided by IDR [46]. We further tested on 7 challenging scenes from the low-res set of the BlendedMVS dataset [45](CC-4 License). Each scene has $3 1 - 1 4 3$ images at $7 6 8 \times 5 7 6$ pixels and masks are provided by the BlendedMVS dataset. We further captured two thin objects with 32 input images to test our approach on thin structure reconstruction.
Baselines. (1) The state-of-the-art surface rendering approach – IDR [46]: IDR can reconstruct surface with high quality but requires foreground masks as supervision; Since IDR has demonstrated superior quality compared to another surface rendering based method – DVR [29], we did not conduct a comparison with DVR. (2) The state-of-the-art volume rendering approach – NeRF [28]: We use a threshold of 25 to extract mesh from the learned density field. We validate this choice in the supplementary material. (3) A widely-used classical MVS method – COLMAP [35]: We reconstruct a mesh from the output point cloud of COLMAP with Screened Poisson Surface Reconstruction [16]. (4) The concurrent work which unifies surface rendering and volume rendering with an occupancy field as scene representation – UNISURF [30]. More details of the baseline methods are included in the supplementary material.
Implementation details. We assume the region of interest is inside a unit sphere. We sample 512 rays per batch and train our model for $3 0 0 \mathrm { k }$ iterations for 14 hours (for the ‘w/ mask’ setting) and 16 hours (for the ‘w/o mask’ setting) on a single NVIDIA RTX2080Ti GPU. For the ‘w/o mask’ setting, we model the background by $_ \mathrm { N e R F + + }$ [50]. Our network architecture and initialization scheme are similar to those of IDR [46]. More details of the network architecture and training parameters can be found in the supplementary material.
# 4.2 Comparisons
Table 1: Quantitative evaluation on DTU dataset. COLMAP results are achieved by $\mathrm { { t r i m } = 0 }$ .
<table><tr><td></td><td colspan="3">w/mask</td><td colspan="4">w/omask</td></tr><tr><td>ScanID</td><td>IDR</td><td>NeRF</td><td>Ours</td><td>COLMAP</td><td>NeRF</td><td>UNISURF</td><td>Ours</td></tr><tr><td>scan24</td><td>1.63</td><td>1.83</td><td>0.83</td><td>0.81</td><td>1.90</td><td>1.32</td><td>1.00</td></tr><tr><td>scan37</td><td>1.87</td><td>2.39</td><td>0.98</td><td>2.05</td><td>1.60</td><td>1.36</td><td>1.37</td></tr><tr><td>scan40</td><td>0.63</td><td>1.79</td><td>0.56</td><td>0.73</td><td>1.85</td><td>1.72</td><td>0.93</td></tr><tr><td>scan55</td><td>0.48</td><td>0.66</td><td>0.37</td><td>1.22</td><td>0.58</td><td>0.44</td><td>0.43</td></tr><tr><td>scan63</td><td>1.04</td><td>1.79</td><td>1.13</td><td>1.79</td><td>2.28</td><td>1.35</td><td>1.10</td></tr><tr><td>scan65</td><td>0.79</td><td>1.44</td><td>0.59</td><td>1.58</td><td>1.27</td><td>0.79</td><td>0.65</td></tr><tr><td>scan69</td><td>0.77</td><td>1.50</td><td>0.60</td><td>1.02</td><td>1.47</td><td>0.80</td><td>0.57</td></tr><tr><td>scan83</td><td>1.33</td><td>1.20</td><td>1.45</td><td>3.05</td><td>1.67</td><td>1.49</td><td>1.48</td></tr><tr><td>scan97</td><td>1.16</td><td>1.96</td><td>0.95</td><td>1.40</td><td>2.05</td><td>1.37</td><td>1.09</td></tr><tr><td>scan105</td><td>0.76</td><td>1.27</td><td>0.78</td><td>2.05</td><td>1.07</td><td>0.89</td><td>0.83</td></tr><tr><td>scan106</td><td>0.67</td><td>1.44</td><td>0.52</td><td>1.00</td><td>0.88</td><td>0.59</td><td>0.52</td></tr><tr><td>scan110</td><td>0.90</td><td>2.61</td><td>1.43</td><td>1.32</td><td>2.53</td><td>1.47</td><td>1.20</td></tr><tr><td>scan114</td><td>0.42</td><td>1.04</td><td>0.36</td><td>0.49</td><td>1.06</td><td>0.46</td><td>0.35</td></tr><tr><td>scan118</td><td>0.51</td><td>1.13</td><td>0.45</td><td>0.78</td><td>1.15</td><td>0.59</td><td>0.49</td></tr><tr><td>scan122</td><td>0.53</td><td>0.99</td><td>0.45</td><td>1.17</td><td>0.96</td><td>0.62</td><td>0.54</td></tr><tr><td>mean</td><td>0.90</td><td>1.54</td><td>0.77</td><td>1.36</td><td>1.49</td><td>1.02</td><td>0.84</td></tr></table>
We conducted the comparisons in two settings,
with mask supervision (w/ mask) and without mask supervision (w/o mask). We measure the reconstruction quality with the Chamfer distances in the same way as UNISURF [30] and IDR [46] and report the scores in Table 1. The results show that our approach outperforms the baseline methods on the DTU dataset in both settings – w/ and w/o mask in terms of the Chamfer distance. Note that the reported scores of IDR in the setting of w/ mask and NeRF and UNISURF in the w/o mask setting are from IDR [46] and UNISURF [30].
We conduct the qualitative comparisons on the DTU dataset and the BlendedMVS dataset in both settings, w/ mask and w/o mask, in Figure 4 and Figure 5, respectively. As shown in Figure 4 for the setting of w/ mask, IDR shows limited performance for reconstructing thin metals parts in Scan 37 (DTU), and fails to handle sudden depth changes in Stone (BlendedMVS) due to the local optimization process in surface rendering. The extracted meshes of NeRF are noisy since the volume density field has not sufficient constraint on its 3D geometry. Regarding the w/o mask setting, we visually compare our method with NeRF and COLMAP in the setting of w/o mask in Figure 5, which shows our reconstructed surfaces are with more fidelity than baselines. We further show a comparison with UNISURF [30] on two examples in the w/o mask setting. Note that we use the qualitative results of UNISURF reported their paper for comparison. Our method works better for the objects with abrupt depth changes. More qualitative images are included in the supplementary material.
 Figure 4: Comparions on surface reconstruction with mask supervision.
 Figure 5: Comparions on surface reconstruction without mask supervision.
# 4.3 Analysis
# Ablation study.
To evaluate the effect of the weight calculation, we test three different kinds of weight constructions described in Sec. 3.1: (a) Naive Solution. (b) Straightforward Construction as shown in Eqn. 4. (e) Full Model. As shown in Figure 6, the quantitative result of naive solution is worse than our weight choice (e) in terms of the Chamfer distance. This is because it introduces a bias to the surface reconstruction. If direct construction is used, there are severe artifacts.

We also studied the effect of Eikonal regularization [10] and geometric initialization [1]. Without Eikonal regularization or geometric initialization, the result on Chamfer distance is on par with that of the full model. However, neither of them can correctly output a signed distance function. This is indicated by the MAE(mean absolute error) between the SDF predictions and corresponding ground-truth SDF, as shown in the bottom line of Figure 6. The MAE is computed on uniformly-sampled points in the object’s bounding sphere. Qualitative results of
 Figure 7: Visual comparisons with UNISURF.
SDF predictions are provided in the supplementary material.
Thin structures. We additionally show results on two challenging thin objects with 32 input images. The plane with rich texture under the object is used for camera calibration. As shown in Fig. 8, our method is able to accurately reconstruct these thin structures, especially on the edges with abrupt depth changes. Furthermore, different from the methods [39, 19, 42, 20] which only target at high-quality thin structure reconstruction, our method can handle the scenes which have a mixture of thin structures and general objects.
 Figure 8: Comparison on scenes with thin structure objects. Left half is the depth map while right half is the reconstructed surface.
# 5 Conclusion
We have proposed NeuS, a new approach to multiview surface reconstruction that represents 3D surfaces as neural SDF and developed a new volume rendering method for training the implicit SDF representation. NeuS produces high-quality reconstruction and successfully reconstructs objects with severe occlusions and complex structures. It outperforms the state-of-the-arts both qualitatively and quantitatively. One limitation of our method is that although our method does not heavily rely on correspondence matching of texture features, the performance would still degrade for textureless objects (we show the failure cases in the supplementary material). Moreover, NeuS has only a single scale parameter $s$ that is used to model the standard deviation of the probability distribution for all the spatial location. Hence, an interesting future research topic is to model the probability with different variances for different spatial locations together with the optimization of scene representation, depending on different local geometric characteristics. Negative societal impact: like many other learning-based works, our method requires a large amount of computational resources for network training, which can be a concern for global climate change.
# Acknowlegements
We thank Michael Oechsle for providing the results of UNISURF. Christian Theobalt was supported by ERC Consolidator Grant 770784. Lingjie Liu was supported by Lise Meitner Postdoctoral Fellowship. Computational resources are mainly provided by HKU GPU Farm.
# References
[1] Matan Atzmon and Yaron Lipman. Sal: Sign agnostic learning of shapes from raw data. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 2565–2574, 2020. [2] Connelly Barnes, Eli Shechtman, Adam Finkelstein, and Dan B Goldman. Patchmatch: A randomized correspondence algorithm for structural image editing. ACM Trans. Graph., 28(3):24, 2009. [3] Adrian Broadhurst, Tom W Drummond, and Roberto Cipolla. A probabilistic framework for space carving. In Proceedings Eighth IEEE International Conference on Computer Vision. ICCV 2001, volume 1, pages 388–393. IEEE, 2001. [4] Z. Chen and H. Zhang. Learning implicit fields for generative shape modeling. In 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 5932–5941, 2019. [5] Christopher B Choy, Danfei Xu, JunYoung Gwak, Kevin Chen, and Silvio Savarese. 3d-r2n2: A unified approach for single and multi-view 3d object reconstruction. In European conference on computer vision, pages 628–644. Springer, 2016. [6] Jeremy S De Bonet and Paul Viola. Poxels: Probabilistic voxelized volume reconstruction. In Proceedings of International Conference on Computer Vision (ICCV), pages 418–425, 1999. [7] Haoqiang Fan, Hao Su, and Leonidas J Guibas. A point set generation network for 3d object reconstruction from a single image. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 605–613, 2017. [8] Yasutaka Furukawa and Jean Ponce. Accurate, dense, and robust multiview stereopsis. IEEE transactions on pattern analysis and machine intelligence, 32(8):1362–1376, 2009. [9] Silvano Galliani, Katrin Lasinger, and Konrad Schindler. Gipuma: Massively parallel multiview stereo reconstruction. Publikationen der Deutschen Gesellschaft für Photogrammetrie, Fernerkundung und Geoinformation e. V, 25(361-369):2, 2016. [10] Amos Gropp, Lior Yariv, Niv Haim, Matan Atzmon, and Yaron Lipman. Implicit geometric regularization for learning shapes. arXiv preprint arXiv:2002.10099, 2020. [11] Rasmus Jensen, Anders Dahl, George Vogiatzis, Engil Tola, and Henrik Aanæs. Large scale multi-view stereopsis evaluation. In 2014 IEEE Conference on Computer Vision and Pattern Recognition, pages 406–413, 2014. [12] Yue Jiang, Dantong Ji, Zhizhong Han, and Matthias Zwicker. Sdfdiff: Differentiable rendering of signed distance fields for 3d shape optimization. In The IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), June 2020. [13] Abhishek Kar, Christian Häne, and Jitendra Malik. Learning a multi-view stereo machine. arXiv preprint arXiv:1708.05375, 2017. [14] Hiroharu Kato, Yoshitaka Ushiku, and Tatsuya Harada. Neural 3d mesh renderer. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 3907–3916, 2018. [15] Srinivas Kaza et al. Differentiable volume rendering using signed distance functions. PhD thesis, Massachusetts Institute of Technology, 2019. [16] Michael Kazhdan and Hugues Hoppe. Screened poisson surface reconstruction. ACM Trans. Graph., 32(3), July 2013. [17] Petr Kellnhofer, Lars Jebe, Andrew Jones, Ryan Spicer, Kari Pulli, and Gordon Wetzstein. Neural lumigraph rendering. arXiv preprint arXiv:2103.11571, 2021. [18] Chen-Hsuan Lin, Chen Kong, and Simon Lucey. Learning efficient point cloud generation for dense 3d object reconstruction. In proceedings of the AAAI Conference on Artificial Intelligence, volume 32, 2018. [19] Lingjie Liu, Duygu Ceylan, Cheng Lin, Wenping Wang, and Niloy J. Mitra. Image-based reconstruction of wire art. 36(4):63:1–63:11, 2017. [20] Lingjie Liu, Nenglun Chen, Duygu Ceylan, Christian Theobalt, Wenping Wang, and Niloy J. Mitra. Curvefusion: Reconstructing thin structures from rgbd sequences. 37(6), 2018. [21] Lingjie Liu, Jiatao Gu, Kyaw Zaw Lin, Tat-Seng Chua, and Christian Theobalt. Neural sparse voxel fields. Advances in Neural Information Processing Systems, 33, 2020. [22] Shaohui Liu, Yinda Zhang, Songyou Peng, Boxin Shi, Marc Pollefeys, and Zhaopeng Cui. Dist: Rendering deep implicit signed distance function with differentiable sphere tracing. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 2019–2028, 2020. [23] Stephen Lombardi, Tomas Simon, Jason Saragih, Gabriel Schwartz, Andreas Lehrmann, and Yaser Sheikh. Neural volumes: Learning dynamic renderable volumes from images. ACM Transactions on Graphics (TOG), 38(4):65, 2019. [24] Priyanka Mandikal, K L Navaneet, Mayank Agarwal, and R Venkatesh Babu. 3D-LMNet: Latent embedding matching for accurate and diverse 3d point cloud reconstruction from a single image. In Proceedings of the British Machine Vision Conference (BMVC), 2018. [25] Paul Merrell, Amir Akbarzadeh, Liang Wang, Philippos Mordohai, Jan-Michael Frahm, Ruigang Yang, David Nistér, and Marc Pollefeys. Real-time visibility-based fusion of depth maps. pages 1–8, 01 2007. [26] Lars Mescheder, Michael Oechsle, Michael Niemeyer, Sebastian Nowozin, and Andreas Geiger. Occupancy networks: Learning 3d reconstruction in function space. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 4460–4470, 2019. [27] Mateusz Michalkiewicz, Jhony K. Pontes, Dominic Jack, Mahsa Baktashmotlagh, and Anders Eriksson. Implicit surface representations as layers in neural networks. In The IEEE International Conference on Computer Vision (ICCV), October 2019. [28] Ben Mildenhall, Pratul P Srinivasan, Matthew Tancik, Jonathan T Barron, Ravi Ramamoorthi, and Ren Ng. Nerf: Representing scenes as neural radiance fields for view synthesis. In European Conference on Computer Vision, pages 405–421. Springer, 2020. [29] Michael Niemeyer, Lars Mescheder, Michael Oechsle, and Andreas Geiger. Differentiable volumetric rendering: Learning implicit 3d representations without 3d supervision. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 3504–3515, 2020. [30] Michael Oechsle, Songyou Peng, and Andreas Geiger. Unisurf: Unifying neural implicit surfaces and radiance fields for multi-view reconstruction. arXiv preprint arXiv:2104.10078, 2021. [31] Jeong Joon Park, Peter Florence, Julian Straub, Richard Newcombe, and Steven Lovegrove. Deepsdf: Learning continuous signed distance functions for shape representation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 165–174, 2019. [32] Songyou Peng, Michael Niemeyer, Lars M. Mescheder, Marc Pollefeys, and Andreas Geiger. Convolutional occupancy networks. ArXiv, abs/2003.04618, 2020. [33] Shunsuke Saito, Zeng Huang, Ryota Natsume, Shigeo Morishima, Angjoo Kanazawa, and Hao Li. Pifu: Pixel-aligned implicit function for high-resolution clothed human digitization. ICCV, 2019. [34] Shunsuke Saito, Tomas Simon, Jason Saragih, and Hanbyul Joo. Pifuhd: Multi-level pixelaligned implicit function for high-resolution 3d human digitization. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 84–93, 2020. [35] Johannes L Schönberger, Enliang Zheng, Jan-Michael Frahm, and Marc Pollefeys. Pixelwise view selection for unstructured multi-view stereo. In European Conference on Computer Vision, pages 501–518. Springer, 2016. [36] Steven M Seitz and Charles R Dyer. Photorealistic scene reconstruction by voxel coloring. International Journal of Computer Vision, 35(2):151–173, 1999. [37] Vincent Sitzmann, Justus Thies, Felix Heide, Matthias Nießner, Gordon Wetzstein, and Michael Zollhofer. Deepvoxels: Learning persistent 3d feature embeddings. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 2437–2446, 2019. [38] Vincent Sitzmann, Michael Zollhöfer, and Gordon Wetzstein. Scene representation networks: Continuous 3d-structure-aware neural scene representations. In Advances in Neural Information Processing Systems, pages 1119–1130, 2019. [39] A. Tabb. Shape from silhouette probability maps: Reconstruction of thin objects in the presence of silhouette extraction and calibration error. pages 161–168, June 2013. [40] Alex Trevithick and Bo Yang. Grf: Learning a general radiance field for 3d scene representation and rendering. arXiv preprint arXiv:2010.04595, 2020. [41] Nanyang Wang, Yinda Zhang, Zhuwen Li, Yanwei Fu, Wei Liu, and Yu-Gang Jiang. Pixel2mesh: Generating 3d mesh models from single rgb images. In Proceedings of the European Conference on Computer Vision (ECCV), pages 52–67, 2018. [42] Peng Wang, Lingjie Liu, Nenglun Chen, Hung-Kuo Chu, Christian Theobalt, and Wenping Wang. Vid2curve: Simultaneous camera motion estimation and thin structure reconstruction from an rgb video. ACM Trans. Graph., 39(4), July 2020. [43] Chao Wen, Yinda Zhang, Zhuwen Li, and Yanwei Fu. Pixel2mesh++: Multi-view 3d mesh generation via deformation. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 1042–1051, 2019. [44] Haozhe Xie, Hongxun Yao, Xiaoshuai Sun, Shangchen Zhou, and Shengping Zhang. Pix2vox: Context-aware 3d reconstruction from single and multi-view images. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 2690–2698, 2019. [45] Yao Yao, Zixin Luo, Shiwei Li, Jingyang Zhang, Yufan Ren, Lei Zhou, Tian Fang, and Long Quan. Blendedmvs: A large-scale dataset for generalized multi-view stereo networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 1790–1799, 2020. [46] Lior Yariv, Yoni Kasten, Dror Moran, Meirav Galun, Matan Atzmon, Basri Ronen, and Yaron Lipman. Multiview neural surface reconstruction by disentangling geometry and appearance. Advances in Neural Information Processing Systems, 33, 2020. [47] Wang Yifan, Shihao Wu, Cengiz Oztireli, and Olga Sorkine-Hornung. Iso-points: Optimizing neural implicit surfaces with hybrid representations. arXiv preprint arXiv:2012.06434, 2020. [48] Christopher Zach, Thomas Pock, and Horst Bischof. A globally optimal algorithm for robust tv-l1 range image integration. In 2007 IEEE 11th International Conference on Computer Vision, pages 1–8, 2007. [49] Kai Zhang, Fujun Luan, Qianqian Wang, Kavita Bala, and Noah Snavely. Physg: Inverse rendering with spherical gaussians for physics-based material editing and relighting. arXiv preprint arXiv:2104.00674, 2021. [50] Kai Zhang, Gernot Riegler, Noah Snavely, and Vladlen Koltun. Nerf++: Analyzing and improving neural radiance fields. arXiv preprint arXiv:2010.07492, 2020.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329# DEEP EVOLUTIONARY LEARNING FOR MOLECULAR DESIGN
Anonymous authors Paper under double-blind review
# ABSTRACT
In this paper, we propose a deep evolutionary learning (DEL) process that integrates fragment-based deep generative model and multi-objective evolutionary computation for molecular design. Our approach enables (1) evolutionary operations in the latent space of the generative model, rather than the structural space, to generate novel promising molecular structures for the next evolutionary generation, and (2) generative model fine-tuning using newly generated highquality samples. Thus, DEL implements a data-model co-evolution concept which improves both sample population and generative model learning. Experiments on two public datasets indicate that sample population obtained by DEL exhibits improved property distributions, and dominates samples generated by multiobjective Bayesian optimization algorithms.
# 1 INTRODUCTION
A drug is a molecule that binds to a target (e.g. protein) to inhibit or activate specific pathways in pathogens or host cells that cause abnormal phenotype. Drug discovery and development is a costly and time-consuming process, which is compounded by personalized medicines development for cancer or other complex and rare diseases. Computational drug discovery has been shown to accelerate the whole discovery process using simulations and machine intelligence. However, challenge remains in this field by demands for a robust and unbiased feature representation theories for molecules and their corresponding receptors, and efficient search algorithms. The rise of AI and data science provides us with a unique opportunity to reevaluate the problem and develop fast intelligent search or design approaches (Gromski et al., 2019; Chen et al., 2018). These new technologies claim differences from the traditional ones in two aspects: (1) features can be automatically learned using embedding techniques on a large number of training samples, and (2) high-level relationships (in supervised case) and complex distributions (in unsupervised case) can be captured using appropriate deep architectures. Recently, new representation theories and architectures have been proposed in the domain of molecular generation. There exist two new major methods to present a molecule for a machine learning algorithm. The first method converts a molecule structure to a string, such as the simplified molecular-input line-entry system (SMILES) string (Weininger, 1988), and adopt natural language processing (NLP) methods for supervised or unsupervised learning. The second uses an undirected graph to present a molecular structure and applies graph convolutional neural networks (Duvenaud et al., 2015). Three major families of AI algorithms have been developed for novel drug discovery: deep generative models (DGMs), reinforcement learning, and the combination of both.
As one family of major neural probabilistic models for data modelling, generative autoencoders (e.g. variational autoencoder (VAE) (Kingma & Welling, 2014)) have been adopted to learn on either SMILES strings (Romez-Bombarelli et al., 2018) or molecular graphs (Simonovsky & Komodakis, 2018) with corresponding physical and biochemical properties for molecular generation. By integrating the generative adversarial nets and autoencoders, adversarial autoencoders (AAEs) have also been well applied to molecular design (Kadurin et al., 2017). The advantage of using generative autoencoders is that, molecules, as discrete objects in our world, are mapped to the continuous latent space, whose landscape can be organized by their properties, which helps generate new structures with preferred property values. However, critical problems remain due to imperfect representation methods. When SMILES strings are used in VAE, the model suffers from imbalance of tokens in embedding, generation of invalid structures, and the problem where two almost identical molecules have markedly different canonical SMILES strings. When using graph as molecular representation in VAE, a technical difficulty is to design an effective graph decoder. In addition to other heuristic methods, a SMILES decoder can be used to pair with a graph encoder. While DGMs offer convenience of searching in latent space, reinforcement learning algorithms can directly search in the molecules’ structural space by adding or deleting bounds and atoms (Zhou et al., 2019). In the Markov decision process (MDP) for drug design, the agent is a molecular generator, the molecular structure indicates the state, the actions are modifications to the current structure, and a simulator (e.g. surrogate model) is often used as the environment to provide reward. Furthermore, generative and predictive models can be integrated in MDP to form deep reinforcement learning (DRL) methods, where the generative model is trained as a policy approximation and the predictive model can be used as a value function approximation (You et al., 2018; Popova et al., 2018). Search in the discrete input space and inefficient learning are arguable concerns to be addressed when applying reinforcement-learning-based solutions for compound design.
Interestingly, as an old peer of reinforcement learning for black-box optimizations, evolutionary computation (EC) methods (Eiben & Smith, 2015) have been catching up with promising performances in modern optimization, design and modelling problems. Besnard et al. (2012) present a strategy for evolution of ligands along multiple properties in the structural space, where a library of knowledge-based chemical structural transformation is used as the mutation operator. Interactions between EC and neural networks have mainly focused on network evolution and neural surrogate models for fitness functions. For examples, EC has been used at a large scale for neuroevolution that leads to evolution of neural network architectures (Stanley et al., 2019); feedforward neural network is commonly used as fitness function in EC (Mandal et al., 2019). Furthermore, it has been recently discovered that evolutionary strategy (ES) can perform competitively with reinforcement learning in game AI (Salimans et al., 2017). ES (Wierstra et al., 2014) and estimation of distribution algorithms (EDA) (Hauschild & Pelikan, 2011) build parameterized search distributions over promising points and either employ gradient information or sample from such a probabilistic model to find better points. Both probabilistic strategies from EC can potentially be used as alternatives to Bayesian optimization (BO) in (continuous) black-box optimizations. A single-objective BO has been recently applied to molecule optimization in the latent space of VAE (Romez-Bombarelli et al., 2018).
Since model learning is essentially parameter estimation from the statistical modelling perspective, the quality of data in deep learning is crucial for model performance. Data augmentation is becoming a new strategy in deep learning to improve the training of a model. For example, in computer vision, transformations (such as rotation and flipping) of images are used to increase the sample size when the original data set is insufficient (Perez & Wang, 2017; Cubuk et al., 2019; Shorten & Khoshgoftaar, 2019). In NLP, a text dataset can be augmented using tricks such as replacing words or phrases with their synonyms (Wei & Zou, 2019), and resorting aids from other language models (e.g. word embedding and neural machine translations) (Sennrich et al., 2016; Wei & Zou, 2019). Basically, these methods either increase the data by transforming existing information which can only alleviate the limit of certain techniques (e.g. convolution), or indirectly borrow new information from other sources (e.g. methods in NLP).
In summary, even though modern machine learning, evolutionary computation, and data science methods have been applied to molecular design and achieved promising results, we are still challenged by three chief issues. (1) An effective representation method for compound structures, that is encoding-decoding friendly and invariant to multimorphic forms, is still missing. (2) New ideas are expected for effective representation and coding of discrete structures in EC. And, (3) quality of data can be further improved as current data augmentation tricks only increase the number of samples but does not specifically address data quality. In this paper, we propose a novel deep evolutionary learning (DEL) process that combines the merits of deep generative model and multi-objective evolutionary computation together for molecular design. Specifically, our work has three major contributions. (1) In our approach, latent representations of phenotypic samples in a population serve as genotypic codes for evolutionary operations.This approach differs from traditional evolutionary algorithms that search in the original space of a problem. Specifically, our framework’s DGM encoder projects molecular structures in a population from discrete space to continuous latent space where evolutionary operations are applied to help explore the latent representation space. Subsequently, the DGM decoder maps the genotypic representation to the phenotypic space for generating new molecules with desired property values. (2) In each evolutionary generation, the newly formed population containing novel competitive molecules can be used to further fine-tune the DGM. This approach is an innovative data augmentation strategy that enriches training data with novel highquality samples. The whole DEL process implements a new learning paradigm that co-evolves data and model alternatingly through multiple evolutionary generations. (3) Our comprehensive experiments demonstrate that DEL is able to produce populations of novel samples with improved values of properties and outperforms state-of-the-art multi-objective BO algorithms (MOBO).
# 2 METHOD
The proposed deep evolutionary learning (DEL) process combines deep learning and multi-objective EC through the latent representation space of molecules. One of the theoretical innovations of our approach is that it demonstrates that EC methods are extendable to corresponding deep versions. The main idea is illustrated in Figure 1a and formally presented in Algorithm 1 (see Appendix A.1). This algorithm consists of the following steps. (a) A VAE (as molecule modeller) and a multilayer perceptron neural network (MLP, property predictor as regularizer) are pretrained using all the original training data to start the first evolutionary generation, or, if not in the first generation, using samples from the previous population. (b) Training samples (if first generation) or population samples (otherwise) are projected to the latent space using the encoder of the VAE. (c) Based on non-dominated ranking and crowding distances of samples with respect to multiple properties, evolutionary operations (selection, recombination/crossover and mutation) are conducted on the latent representations of the samples. (d) Given these new latent codes after evolutionary operations, new molecule samples are generated by the decoder of the VAE. (e) Properties of these generated samples are obtained using a simulator (e.g. RDKit (Landrum, 2006) in our experiment). (f) New samples with good desired properties and good samples from the previous generation form the new population. (g) Steps (b-f) are iterated for multiple generations. (h) The final population is returned.
 Figure 1: Deep evolutionary learning process and deep generative model integrated in DEL.
The major advantages of our DEL algorithm over existing interactions between EC and neural networks can be explained as follows. (a) We directly evolve a collection of data rather than many neural network structures and parameters. Data evolution tends to be more efficient than direct evolution of model structures and parameters. (b) The single neural network model (i.e. DGM in DEL) can be indirectly improved through learning on the evolved data with modern gradient-based variational learning and inference algorithms. Thus, the improvement of populations along evolutionary generations can be viewed as an effective data augmentation strategy that includes novel and highquality samples for further training of the neural network. (c) The continuous latent representation space established by the encoder of DGM can be naturally used as encoding (genotypic) space for evolutionary computation. Thus, evolutionary operations are carried out in the latent space instead of the discrete structural input space, allowing more efficient and smooth exploration, because the latent space is often multimodal and can be organized by properties (regularized by the property predictor) and evolutionary operations in this space can help the search escape from local regions and explore new regions of interest. (d) The multi-objective operations - non-dominated sorting and crowding distance, can help identify competitive and diverse parent samples to breed offspring. In summary, DEL takes advantages of both multi-objective EC and probabilistic neural model learning. The DGM, multi-objective components (non-dominated sorting and crowding distance), evolutionary operations, formation of new populations are discussed in details as below.
# 2.1 FRAGVAE FOR FRAGMENT-BASED MOLECULAR MODELLING
In our DEL process, we adopted a VAE model originally for fragment-based molecular generation (Podda et al., 2020). The concept of fragment-based drug design (FBDD) was introduced in (Shuker et al., 1996). In FBDD-based approaches, small organic molecules that bind to proximal subsites of a protein are identified, optimized, and linked together to produce high-affinity ligands. Wet-lab approaches for FBDD include $\mathrm { X }$ -ray crystallography and NMR spectroscopy. Compared to atom-based drug design, FBDD has the following advantages (Erlanson, 2011). (1) The search space in FBDD is much smaller $1 0 ^ { 7 }$ versus $1 0 ^ { 6 0 }$ ). (2) Identifying a fragment with certain affinity to the target may mean finding a pharmacophore. (3) Fragment-based synthesis could be more efficient than high-throughput screening. Majority fragmentation methods, which break a molecule into parts, are based on synthetic accessibility. For examples, RECAP (retrosynthetic combinatorial analysis procedure) is a method that breaks bonds formed by chemical reactions (Lewell et al., 1998); BRICS (breaking of retrosynthetically interesting chemical substructures) generates a more elaborated set of fragmentation rules along synthetically accessible bonds and generates more fragments than RECAP (Degen et al., 2008). BRICS is used in (Podda et al., 2020) to chop a SMILES string into several fragments. Then, fragment embeddings are produced using Word2Vec (Mikolov et al., 2013). Next, the sequences of fragments are modelled by a GRU-based VAE. In our work, a multi-head feedforward neural network component for predicting values of properties is added to the original model such that the latent representations can be regularized by properties of interest. Additionally, we normalize the three loss terms using batch size, and allow tuning of the weights among the loss terms. A crucial implementation bug in the original VAE model was also corrected (see Appendix A.2). Hereafter, we name this modified VAE model for fragments as FragVAE whose architecture is displayed in Figure 1b.
We denote the encoder parameter by $\phi$ , the decoder parameter by $\pmb { \theta }$ , and the property predictor network by $f _ { \psi } ( z )$ parameterized by $\psi$ . The objective (to be minimized) of this DGM employed in DEL is a weighted combination of three terms:
$$\begin{array} { r } { l _ { \phi , \theta , \psi } = - \mathrm { E } _ { q _ { \phi } ( z | x ) } [ \log p _ { \theta } ( x | h ) ] + \beta \mathrm { K L } \big ( q _ { \phi } ( z | x ) | | p _ { \theta } ( z ) \big ) + \alpha \mathrm { E } _ { q _ { \phi } ( z | x ) } \big [ \mathrm { M S E } ( f _ { \psi } ( z ) , y ) \big ] , } \end{array}$$
where the first term is to reduce the reconstruction error, the second term is to regularize the posterior latent distribution with a simple prior, and the third term uses mean squared error of property prediction to further regularize the posterior distribution of latent codes. Previous studies unveil that VAE can easily fail on modelling text data because of the training imbalance between the reconstruction error (difficult to reduce once the KL divergence becomes very small) and the KL divergence (easy to diminish to zero). Thus, proper trade-off between the reconstruction error and KL divergence through $\beta$ -VAE (Higgins et al., 2017) is vital in text generation and molecular generation (Yan et al., 2020; Bowman et al., 2016). In practice, the value of $\beta$ should be smaller than 1. To look for a suitable value of $\beta$ , we design a versatile function, called $\beta$ -function, as formulated below,
$$\beta ( t ) = \operatorname* { m i n } \Big \{ \operatorname* { m a x } \big \{ a e ^ { k ( 1 - \frac { T } { t } ) } , l \big \} , u \Big \} ,$$
where $T$ represents the total number of epochs, $t \in \{ 1 , 2 , \cdots , T \}$ indicates the current index of epoch, $k$ controls the incremental speed, $a$ defines the amplitude, $l$ and $u$ serve as lower and upper bounds respectively for the value of $\beta$ . With different settings, a variety of curves of this function are shown in Figure 6 (see Appendix A.7). The value of $\alpha$ can be set similarly in FragVAE.
# 2.2 NON-DOMINATION RANK AND CROWDING DISTANCE
To get non-domination rank and crowding distance of a feasible solution for guiding the sample selection (Section 2.3) and the population merging (Section 2.4), the fast non-dominated sort and crowding comparison methods are adopted from the classic NSGA-II algorithm for multi-objective optimization (Deb et al., 2002). The properties in molecular design are treated as objectives. In an optimization problem with $K$ objectives $\bar { f } ( z ) = \{ f _ { 1 } ( z ) , \cdot \cdot \cdot , f _ { K } ( \bar { z } ) \}$ , feasible solution $z _ { 1 }$ is said to dominate $z _ { 2 }$ (denoted by $z _ { 1 } \prec z _ { 2 } ,$ ), if $\forall k \in \{ 1 , \cdots , K \}$ : $f _ { k } ( z _ { 1 } ) \leq f _ { k } ( z _ { 2 } )$ and $\exists k \in \{ 1 , \cdots , K \}$ : $f _ { k } ( z _ { 1 } ) < f _ { k } ( z _ { 2 } )$ . Using this concept of domination, all feasible solutions in a collection can be sorted to form Pareto frontiers (or fronts, ranks) $\mathcal { F } = \{ \mathcal { F } _ { 1 } , \mathcal { F } _ { 2 } , \cdot \cdot \cdot \}$ . Samples in the same frontier do not dominate each other. Frontier ${ \mathcal { F } } _ { i }$ dominates ${ \mathcal { F } } _ { j }$ for $j > i$ . Thus, we define function $F ( z )$ to retrieve the rank (i.e. frontier index) of any feasible solution $_ { z }$ in the population.
The crowding distance of a feasible solution is computed as the normalized perimeter of the cuboid formed by its immediate neighbours along all objective axes. To compute the crowding distance of $z _ { i }$ , the normalized distance between its nearest neighbours above (denoted by $z _ { a }$ ) and below (denoted by $z _ { b }$ ) it w.r.t. the $k$ -th objective axis is calculated using $\begin{array} { r } { d _ { k } ( z _ { i } ) = \frac { f _ { k } ( z _ { a } ) - f _ { k } ( z _ { b } ) } { f _ { k } ^ { \operatorname* { m a x } } - f _ { k } ^ { \operatorname* { m i n } } } } \end{array}$ , where $f _ { k } ^ { \mathrm { m a x } }$ and idual $f _ { k } ^ { \mathrm { m i n } }$ are respectively the maximal and minimal values ots are summed up to form the crowding distance of h: $k$ these. The $z _ { i }$ $\begin{array} { r } { d ( z _ { i } ) = \sum _ { k = 1 } ^ { K } d _ { k } ( z _ { i } ) } \end{array}$
Using the two concepts, partial order can be defined. We say $z _ { 1 } \prec _ { n } z _ { 2 }$ if either (1) $z _ { \mathrm { 1 } } \prec z _ { \mathrm { 2 } }$ (that is $F ( z _ { 1 } ) < F ( z _ { 2 } ) )$ , or (2) $F ( z _ { 1 } ) = F ( z _ { 2 } )$ and $d ( z _ { 1 } ) > d ( z _ { 2 } )$ . When two solutions have same rank, the one with larger crowding distance is preferred because it helps maintain a diverse population.
# 2.3 EVOLUTIONARY OPERATIONS
The evolutionary operations include parent selection, recombination and mutation to produce new offspring in the evolutionary process. Binary tournament selection is applied to select one out of two randomly drawn samples from the current population. In such a selection process, let us suppose $z _ { 1 }$ and $z _ { 2 }$ are randomly taken from the population and $z _ { 1 } \prec _ { n } z _ { 2 }$ . Sample $z _ { 1 }$ will be selected with selection probability $p _ { s }$ which is close to one, and $z _ { 2 }$ will be selected with a small chance $1 - p _ { s }$ . This selection process is repeated $M$ times to thus find $M$ parents where $M$ is the fixed population size. A pair of such parents will produce two children through recombination and mutation operations. Given two parents’ latent representation $z _ { p 1 }$ and $z _ { p 2 }$ , there are two recombination options - linear and discrete methods, to produce their new children $\hat { z } _ { 1 }$ and $\hat { z } _ { 2 }$ . For linear recombination, $\hat { z } _ { 1 } =$ $z _ { p 1 } + r _ { 1 } \big ( z _ { p 2 } - z _ { p 1 } \big )$ and $\hat { z } _ { 2 } = z _ { p 1 } + r _ { 2 } ( z _ { p 2 } - z _ { p 1 } )$ where $r _ { 1 } = - d \substack { + ( 1 + 2 d ) \alpha _ { 1 } }$ , $r _ { 2 } = - d \ t ( 1 \tplus d ) \alpha _ { 2 }$ , $d = 0 . 2 5$ , and $\alpha _ { 1 } , \alpha _ { 2 } \sim \mathrm { U n i f o r m } ( 0 , 1 )$ . For discrete method, supposing a latent representation vector is of length $L$ , an integer $l$ is randomly drawn from $\{ 1 , \cdots , L - 1 \}$ such that $\begin{array} { r } { \hat { z } _ { 1 } ^ { \ast } = \left[ z _ { p 1 } [ 1 : \right. } \end{array}$ $l ] , z _ { p 2 } [ l + 1 : L ] ]$ and $\hat { z } _ { 2 } ~ = ~ \big [ z _ { p 2 } [ 1 ~ : ~ l ] , z _ { p 1 } [ l ~ + ~ 1 ~ : ~ L ] \big ]$ . After crossover, a new sample $\hat { z } _ { m }$ $( m \in \{ 1 , \cdots , M \} )$ will have a small mutation probability $p _ { m }$ (say 0.01) of getting mutation. For $\hat { z } _ { m }$ , a random value $r$ is drawn from $\mathrm { U n i f o r m } ( 0 , 1 )$ . If $r < p _ { m }$ , then a random integer $l$ is randomly selected from $\{ 1 , \cdots , L \}$ such that the $l$ -th position of $\hat { z } _ { m }$ is replaced with a value drawn from standard Gaussian distribution: $\hat { z } _ { m , l } \sim \mathcal { N } ( 0 , 1 )$ .
# 2.4 FORMING NEW POPULATION
Ideally we need to maintain excellent and diverse populations. After possible mutation operations, all $M$ genotypic coding vectors will pass through the decoder of the DGM to produce phenotypic samples. All valid samples (supposed in set $\hat { \mathcal { P } } _ { t + 1 } \mathrm { ~ . ~ }$ ) will be kept to merge with the previous population (denoted by $\mathcal { P } _ { t }$ ) to produce a new generation (denoted by $\mathcal { P } _ { t + 1 }$ ). To implement it, all samples in $\hat { \mathcal { P } } _ { t + 1 } + \mathcal { P } _ { t }$ are sorted based on their non-domination ranks first and then on their crowding distances. Finally, only the top $M$ samples are taken from them to form the new population.
# 3 EXPERIMENTS
The performance of DEL was investigated on the ZINC (Irwin & Shoichet, 2005) and PCBA (Wang et al., 2016) datasets. These data were processed in the work of Podda et al. (2020). ZINC and PCBA are respectively composed of 227,945 and 383,790 molecules with two or more fragments. More statistics of both data can be found in (Podda et al., 2020). We comprehensively investigated the empirical performance of FragVAE and DEL. Three properties (QED: quantitative estimation of drug-likeness, SAS: synthetic accessibility score, and logP: water-octanol partition coefficient) are selected as objectives in DEL. Molecules with large QED, low SAS, and small logP values are prioritized. Incorporation of other properties (e.g. binding affinity, structure-property relationship, and ADME) will be considered in future work. QED, a scalarization of eight molecular properties (including logP) (Bickerton et al., 2012), is an adequate initial screening step for drug candidates. As we dive into more specific applications, selective properties can be tailored for subsequent screening. Thus, explicit usage of logP as one objective in DEL can help better assess lipophilicity, a key factor in drug design for some diseases, e.g. kidney and heart problems.
# 3.1 EVALUATION OF FRAGVAE
As FragVAE is a significant modification of the original model used in (Podda et al., 2020), we investigated the impact of $\beta$ value to the performance of FragVAE in terms of loss function values through Figure 7 (see Appendix A.7). Other hyperparameter values can be found in Appendix A.3. One can see that a large $\beta$ value can quickly reduce the KL loss to near zero which leads to stagnant reductions of reconstruction error and property regression error – the notorious posterior collapse problem (Goyal et al., 2017), because it is much easier to reduce the KL divergence than the reconstruction error in complex sequence modelling. Using a suitable small value of $\beta$ would allow the continuous decrease of the reconstruction error and property regression error. This observation is consistent with discoveries in language generative models (Yan et al., 2020; Bowman et al., 2016).
Table 2 (see Appendix A.6) shows the validity, novelty and diversity of 20,000 samples generated from trained FragVAEs using standard Normal prior to sample $_ { z }$ followed by the decoder. Results of previous language-model-based and graph-based methods are also given for comparison. In general, the validity is defined as the ratio of number of valid generated samples to total number of generated samples. To clarify, the perfect validity reported in Podda et al. (2020) is actually calculated as the ratio of valid generated SMILES strings after discarding invalid fragment sequences versus total number of valid fragment sequences, i.e. Validity (SMILES) in Table 2. We found that this ratio is always 1 in fragment-based models. To have a better understanding about the model, we hence computed the validity of fragment sequences as the percentage of number of valid fragment sequences to total number of generated fragment sequences, i.e. Validity (Fragments) in Table 2. The novelty is defined as the ratio of number of generated novel valid molecules that do not exist in the training data versus total number of generated valid samples. The diversity is calculated as the percentage of generated unique valid samples among total number of generated valid samples. When the value of $\beta$ is very small (0.01), the posterior $p ( \boldsymbol { z } | \boldsymbol { x } )$ is highly different from the simple standard Normal prior $p ( z )$ . Thus, it is reasonable to see relatively low diversity in samples derived using standard Normal distribution. However, it does not imply that FragVAE with a very small value of $\beta$ is poor at learning latent representation. In fact, previous work in $\beta$ -VAE shows that small values of $\beta$ tend to encourage disentangled representations and form latent clusters (Li et al., 2020).
The property distributions of generated samples can be important indicators to the proximity of generated samples with actual samples. Figure 2 shows the distributions of QED, SAS and logP in samples generated using standard Normal prior. Large $\beta$ value can lead to the sample SAS distribution appearing at the right side of the actual SAS distribution. Interestingly, the property distributions when using $\beta = 0 . 0 1$ do not resemble actual data, implying that using a very small value of $\beta$ would lead to latent representations that deviate from standard normal distributions. To summarize, $\beta \leq 0 . 1$ can prevent the model training from posterior collapse and can form structured latent representation space which is useful for latent space exploration using optimization techniques.
 Figure 2: Property and structural feature distributions over 20K randomly sampled molecules.
# 3.2 DEL PERFORMANCE
We executed DEL processes using fixed or annealed loss trade-off weights: (1) $\beta = 0 . 1$ and $\alpha = 1$ , (2) $\beta = 0 . 0 1$ and $\alpha = 1$ , (3) $\beta = 0 . 1$ and $\alpha = 1$ in the initial training of FragVAE, then annealing $\beta$ to 0.4 and $\alpha$ to 4 in the second generation of DEL (denoted by $\beta = 0 . 1 0 . 4$ , $\alpha = 1 4$ ), and similarly (4) $\beta = 0 . 0 1 0 . 4$ , $\alpha = 1 4$ . Other hyperparameter values can be found in Appendix A.4. The change of losses is shown in Figure 8. We observe that (1) all settings lead to similar reconstruction error convergence, (2) smaller values of $\beta$ tend to obtain smaller property prediction error, (3) annealing can help reduce the KL divergence compared to the corresponding fixed settings.
Figure 3 shows population validity, novelty and diversity in different DEL processes. In this chart, validity (SMILES) is the validity of SMILES strings in the population; validity (fragments) is the validity of fragment sequences sampled using FragVAE after evolutionary operations; novelty is the ratio of population samples that are not in the training data against the population size; and diversity is the ratio of unique population samples against the population size. We observe that almost all samples in the populations are novel; and the population samples in the last generation are quite diverse, ranging from 0.798 to 0.988. Table 9 lists the increasing numbers of high-quality novel molecules discovered along the DEL processes. In contrast to the training molecules visualized in Figures 9 and 10 (Appendix), DEL is able to discover novel and diverse high-quality molecules (see Figures 11-18 in Appendix). Furthermore, the distributions of properties and structural features of samples along the evolutionary process are compared in Figure 4 (and Figures 19-21 in Appendix). It can be seen that the process can be quite different from the actual data distribution and is able to gradually improve the distributions of QED, SAS and logP in population samples towards the preferred goals. Interestingly, samples randomly generated using standard Normal prior do not clearly show this trend (Figures 22-25 in Appendix).
 Figure 3: Population validity, novelty and diversity during DEL processes.
 Figure 4: Property & structural feature distributions of DEL populations $\mathrm { \beta } = 0 . 0 1 \to 0 . 4$ , $\alpha { = } 1 4$ ).
# 3.3 COMPARISON WITH MULTI-OBJECTIVE BAYESIAN OPTIMIZATION
DEL was compared with two MOBO methods: q-Pareto Efficient Global Optimization (qParEGO) and $\mathbf { q }$ -Expected Hypervolume Improvement (qEHVI) (Daulton et al., 2020). These MOBO methods were run in the latent space of FragVAE trained in the first generation of DEL using all training samples. Hyperparameter settings of these algorithms are listed in Appendix A.5. Figure 26 shows the hypervolumes of both algorithms and the quasi-random baseline which selects candidates from a scrambled Sobol sequence along batches. Hypervolumes obtained using these models are plotted in Figure 26. It shows that qParEGO and qEHVI work better with $\beta = 0 . 0 1$ than that with $\beta = 0 . 1$ .
To qualitatively compare DEL with the MOBO algorithms, the first five Pareto fronts obtained using DEL and last five batches obtained using qParEGO and qEHVI are visualized in Figure 5 and Figure 27 in Appendix. We can see that the solutions from qParEGO and qEHVI are behind the Pareto fronts from DEL. To quantitatively compare DEL with qParEGO and qEHVI, we conducted nondominated sorting on the combination of the first Pareto front of DEL and the last six batches of qParEGO and qEHVI and report the results in Table 1. It shows that all solutions from the DEL Pareto front stay in the new integrated Pareto front, while almost all solutions from qParEGO and qEHVI are behind the integrated Pareto front. Furthermore, as indicated in Table 3 in Appendix,
DEL runs more efficiently than these MOBO algorithms, even though the population size (20,000) of DEL is much larger than the batch sizes (8) of MOBO algorithms. It has been a well-known challenge to scale up BO algorithms.
 Figure 5: Pareto fronts of DEL and MOBO algorithms $\beta = 0 . 0 1 0 . 4$ ). In the legend, the last batch of qParEGO or qEHVI is written as Front 1.
Table 1: Non-dominated sorting of combination of DEL, qParEGO and qEHVI Pareto fronts.
<table><tr><td colspan="2"></td><td colspan="3">Pareto Front Size for Comparison</td><td colspan="3">In New Pareto Front</td></tr><tr><td>Data</td><td>DELHyperparameter</td><td>DEL</td><td>qParEGO</td><td>qEHVI</td><td>DEL</td><td>qParEGO</td><td>qEHVI</td></tr><tr><td>ZINC</td><td>β=0.1→0.4</td><td>243</td><td>46</td><td>45</td><td>243 (100%)</td><td>0(0%)</td><td>0(0%)</td></tr><tr><td>ZINC</td><td>β= 0.01→ 0.4</td><td>200</td><td>46</td><td>40</td><td>200 (100%)</td><td>0(0%)</td><td>1(2.5%)</td></tr><tr><td>PCBA</td><td>β=0.1→0.4</td><td>228</td><td>46</td><td>36</td><td>228 (100%)</td><td>0 (0%)</td><td>0(0%)</td></tr><tr><td>PCBA</td><td>β= 0.01→ 0.4</td><td>183</td><td>46</td><td>43</td><td>183 (100%)</td><td>1(2.17%)</td><td>2 (4.65%)</td></tr></table>
# 3.4 ABLATION STUDIES
By default, DEL uses the property predictor for latent representation regularization, fine-tunes FragVAE using new population data in each generation, forms new child latent codes using the linear crossover method, and fixes the population size to 20K. Variants were created by (1) disabling the property predictor, (2) disabling finetuning, (3) using the discrete crossover method, and (4) allowing a much larger population size (100K). While it is difficult to compare these variants in terms of validity, novelty and diversity of population samples (see Figure 28 in Appendix), it turns out that non-dominated sorting is an informative method for comparison. Table 4, in Appendix A.6, indicates that DEL with the property predictor outperforms the variant without it. Table 5 shows that FragVAE finetuning in DEL can help obtain better Pareto fronts. Table 6 implies that both linear and discrete crossover operations behave well in DEL. Also, DEL with larger population size can form better Pareto fronts (see Table 7). Additionally, we applied non-dominated sorting to compare the quality of Pareto fronts obtained using different values of $\beta$ on DEL, and found that the integrated Pareto front consists of samples relatively evenly from all settings (Table 8).
# 4 CONCLUSION
In this paper, we presented our DEL framework where a fragment-based VAE is integrated such that evolutionary exploration is conducted in the continuous latent representation space rather than the discrete structural space. Our intensive experiments show that DEL is able to generate novel populations of molecules with improved properties, and outperforms state-of-the-art multi-objective Bayesian optimization algorithms. Applications of DEL are certainly not restricted to design of small molecules. As future work, DEL will be tested on different datasets, other design problems, and more specific applications. Other types of DGMs and search strategies will be explored to further enhance DEL. New MOBO algorithms for latent-space based optimization need to be studied further to address issues such as scalability, unknown invalid domains in latent space, and the curse of dimensionality. Github link of our PyTorch and BoTorch implementation will be available.
REFERENCES TJ. Besnard, G.F. Ruda, V. Setola, K. Abecassis, R.M. Rodriguiz, X. Huang, S. Norval, M.F. Sassano, A.I. Shin, L.A. Webster, F.R.C. Simeons, L. Stojanovski, A. Prat, N.G. Seidah, D.B. Constam, G.R. Bickerton, K.D. Read, W.C. Wetsel, I.H. Gilbert, B.L. Roth, and A.L. Hopkins. Automated design of ligands to polypharmacological profiles. Nature, 412:215–220, 2012. G.R. Bickerton, G.V. Paolini, J. Besnard, S. Muresan, and A.L. Hopkins. Quantifying the chemical beauty of drugs. Nature Chemistry, 4:90–98, 2012. S.R. Bowman, L. Vilnis, O. Vinyals, A.M. Dai, R. Jozefowicz, and S. Bengio. Generating sentences from a continuous space. In SIGNLL Conference on Computational Natural Language Learning (CoNLL), pp. 10–21, 2016. H. Chen, O. Engkvist, Y. Wang, M. Olivecrona, and T. Blaschke. The rise of deep learning in drug discovery. Drug Discovery Today, 23(6):1241–1259, 2018. E.D. Cubuk, B. Zoph, D. Mane, V. Vasudevan, and Q.V. Le. AutoAugment: Learning augmentation strategies from data. In CVPR, 2019. S. Daulton, M. Balandat, and E. Bakshy. Differentiable expected hypervolume improvement for parallel multi-objective Bayesian optimization. arXiv Preprint, pp. arXiv:2006.05078, 2020. K. Deb, A. Pratap, S. Agarwal, and T. Meyarivan. A fast and elitist multiobjective genetic algorithm: NSGA-II. IEEE Transactions on Evolutionary Computation, 6(2):182–197, 2002. J. Degen, C. Wegscheid-Gerlach, A. Zaliani, and M. Rarey. On the art of compiling and using ‘drug-like’ chemical fragment spaces. ChemMedChem, 3(10):1503–1507, 2008. D. Duvenaud, D. Maclaurin, J. Aguilera-Iparraguirre, R. Bombarell, T. Hirzel, A. Aspuru-Guzik, and R.P. Adams. Convolutional networks on graphs for learning molecular fingerprints. In NIPS, 2015. A.E. Eiben and J. Smith. From evolutionary computation to the evolution of things. Nature, 521 (2014):476–482, 2015. D.A. Erlanson. Introduction to fragment-based drug discovery. Topics in Current Chemistry, 317: 1–32, 2011. A. Goyal, A. Sordoni, M. Cote, N.R. Ke, and Y. Bengio. Z-Forcing: Training stochastic recurrent networks. In NIPS, 2017. P.S. Gromski, A.B. Henson, J.M. Granda, and L. Cronin. How to explore chemical space using algorithms and automation. Nature Review Chemistry, 3:119–128, 2019. M. Hauschild and M. Pelikan. An introduction and survey of estimation of distribution algorithms. Swarm and Evolutionary Computation, 1(3):111–128, 2011. I. Higgins, L. Matthey, A. Pal, C. Burgess, X. Glorot, M. Botvinick, S. Mohamed, and A. Lerchner. beta-VAE: Learning basic visual concepts with a constrained variational framework. In ICLR, 2017. J.J. Irwin and B.K. Shoichet. ZINC - a free database of commercially available compounds for virtual screening. Journal of Chemical Information and Modeling, 45(1):177–182, 2005. A. Kadurin, S. Nikolenko, K. Khrabrov, A. Aliper, and A. Zhavoronkov. druGAN: An advanced generative adversarial autoencoder model for de novo generation of new molecules with desired molecular properties in silico. Molecular Pharmaceutics, 14:3098–3104, 2017. D.P. Kingma and M. Welling. Auto-encoding variational Bayes. In International Conference on Learning Representations, 2014. G. Landrum. RDKit: Open-source cheminformatics, 2006. URL http://www.rdkit.org. X.Q. Lewell, D.B. Judd, S.P. Watson, and M.M. Hann. RECAP - retrosynthetic combinatorial analysis procedure: a powerful new technique for identifying privileged molecular fragments with useful applications in combinatorial chemistry. Journal of Chemical Information and Computer Sciences, 38(3):511–522, 1998. X. Li, I. Kiringa, T. Yeap, X. Zhu, and Y. Li. Anomaly detection based on unsupervised disentangled representation learning in combination with manifold learning. In International Joint Conference on Neural Networks, 2020. S. Mandal, T.A. Anderson, J. Gottschlich, S. Zhou, and A. Muzahid. Learning fitness functions for genetic algorithms. arXiv Preprint, pp. arXiv:1908.08783, 2019. T. Mikolov, K. Chen, G.S. Corrado, and J. Dean. Efficient estimation of word representations in vector space. In International Conference on Learning Representations, 2013. L. Perez and J. Wang. The effectiveness of data augmentation in image classification using deep learning. arXiv Preprint, pp. arXiv:1712.04621, 2017. M. Podda, D. Bacciu, and A. Micheli. A deep generative model for fragment-based molecule generation. In International Conference on Artificial Intelligence and Statistics, pp. 2240–2250, 2020. M. Popova, O. Isayev, and A. Tropsha. Deep reinforcement learning for de novo drug design. Science Advances, 4:eaap7885, 2018. R. Romez-Bombarelli, J.N. Wei, D. Duvenaud, J.M. Hernarndez-Lobato, B. Sanchez-Lengeling, D. Sheberla, J. Aguilera-Iparraguirre, T.D. Hirzel, R.P. Adams, and A. Aspuru-Guzik. Automatic chemical design using a data-driven continuous representation of molecules. ACS Central Science, 4:268–276, 2018. T. Salimans, J. Ho, X. Chen, S. Sidor, and I. Sutskever. Evolution strategies as a scalable alternative to reinforcement learning. arXiv Reprint, pp. arXiv:1703.03864, 2017. R. Sennrich, B. Haddow, and A. Birch. Improving neural machine translation models with monolingual data. In ACL, 2016. C. Shorten and T.M. Khoshgoftaar. A survey on image data augmentation for deep learning. Journal of Big Data, 6:60, 2019. S.B. Shuker, P.J. Hajduk, R.P. Meadows, and S.W. Fesik. Discovering high-affinity ligands for proteins: SAR by NMR. Science, 274(5292):11531–1534, 1996. M. Simonovsky and N. Komodakis. GraphVAE: Towards generation of small graphs using variational autoencoders. In ICANN, pp. 412–422, 2018. K.O. Stanley, J. Clune, J. Lehman, and R. Miikkulainen. Designing neural networks through neuroevolution. Nature Machine Intelligence, 1:24–30, 2019. Y. Wang, S.H. Bryant, T. Cheng, J. Wang, A. Gindulyte, B.A. Shoemaker, P.A. Thiessen, S. He, and J. Zhang. PubChem BioAssay: 2017 update. Nucleic Acids Research, 45(D1):D955–D963, 2016. J. Wei and K. Zou. EDA: Easy data augmentation techniques for boosting performance on text classification tasks. In EMNLP-IJCNLP, 2019. D. Weininger. SMILES, a chemical language and information system. 1. introduction to methodology and encoding rules. Journal of Chemical Information and Computer Sciences, 28(1):31–36, 1988. D. Wierstra, T. Schaul, T. Glasmachers, Y. Sun, J. Peters, and J. Schmidhuber. Natural evolution strategies. Journal of Machine Learning Research, 15(2014):949–980, 2014. C. Yan, S. Wang, J. Yang, T. Xu, and J. Huang. Re-balancing variational autoencoder loss for molecule sequence generation. arXiv Preprint, pp. arXiv:1910.00698, 2020. J. You, B. Liu, R. Ying, V. Pande, and J. Leskovec. Graph convolutional policy network for goaldirected molecular graph generation. In NeurIPS, 2018. Z. Zhou, S. Kearnes, L. Li, R.N. Zare, and P. Riley. Optimization of molecules vis deep reinforcement learning. Scientific Reports, 9:10752, 2019.
# A APPENDIX
# A.1 DEL ALGORITHM
# Algorithm 1: DEL Algorithm
Inputs: $X _ { 0 }$ , $Y _ { 0 }$ : training samples and corresponding properties; Result: population of designed molecules; learned DGM; 1 for each evolutionary generation do 2 if first generation then 3 $X = X _ { 0 }$ ; $Y = Y _ { 0 }$ ; 4 Train DGM using $\{ X , Y \}$ ; // use all training data to learn DGM 5 $X , Y = \operatorname { s u b s e t } ( X , Y , M )$ ; // a subset of $M$ examples from the original training data 6 else 7 Train DGM using $\{ X , Y \}$ ; // use population to further train DGM 8 end 9 end 10 Z = Encoder $( X )$ ; // obtain latent representations of samples in $\boldsymbol { x }$ 11 $r , \mathcal { F } =$ nondominated sort $( Y )$ ; // $\pmb { r }$ : non-domination ranks, $\mathcal { F }$ : Pareto frontiers 12 $d =$ compute crowding distance $( Y , { \mathcal { F } } )$ ; 13 $Z ^ { \prime } = \operatorname { E v { \bar { O p } } } ( Z , r , d )$ ; // evolutionary operations: selection, recombination and mutation 14 X0 = Decoder $( Z ^ { \prime } )$ ; // generate novel samples 15 $\mathbf { Y } ^ { \prime } =$ get property $( X ^ { \prime } )$ ; // obtain properties of the generated samples using a simulator, e.g. RDKit 16 $\boldsymbol { X }$ , $\mathbf { Y } =$ form new population $( { \pmb X } , { \pmb Y } , { \pmb X } ^ { \prime } , { \pmb Y } ^ { \prime } , { \pmb M } )$ ; // keep the top $M$ good samples from the combination of $\{ X , Y \}$ and $\{ X ^ { \prime } , Y ^ { \prime } \}$ 17 end 18 Return X , Y , DGM
# A.2 BUG CORRECTION
In the VAE implementation by Podda et al. (2020), the incorrect use of view function makes the forward flow of information messed up among different samples in a batch.
Listing 1: Wrong use of view function in the original VAE model in (Podda et al., 2020). , s t a t e $=$ s e l f . r n n ( p a c k e d , s t a t e ) # n u m l a y e r s b y b a t c h b y h i d d e n s i z e −> b a t c h b y h i d d e n l a y e r \* h i d d e n s i z e s t a t e $=$ s t a t e . v i e w ( b a t c h s i z e , s e l f . h i d d e n s i z e \* s e l f . h i d d e n l a y e r s ) mean $=$ s e l f . r n n 2 m e a n ( s t a t e ) # mean : b a t c h b y l a t e n t s i z e l o g v a r $=$ s e l f . r n n 2 l o g v ( s t a t e ) # l o g v : b a t c h b y l a t e n t s i z e
Listing 2: Our correction.
s t a t e $=$ s e l f . r n n ( p a c k e d , s t a t e ) # n u m l a y e r s b y b a t c h b y h i d d e n s i z e −> b a t c h b y n u m l a y e r s b y h i d d e n s i z e s t a t e $=$ s t a t e . t r a n s p o s e $^ { ( 1 , 0 ) }$ s t a t e $=$ s t a t e . f l a t t e n ( s t a r t d i m $= 1$ ) # b a t c h b y h i d d e n l a y e r \* h i d d e n s i z e mean $=$ s e l f . r n n 2 m e a n ( s t a t e ) # mean : b a t c h b y l a t e n t s i z e l o g v a r $=$ s e l f . r n n 2 l o g v ( s t a t e ) # l o g v : b a t c h b y l a t e n t s i z e
# A.3 HYPERPARAMETER SETTING FOR FRAGVAE
When not specified in the main text, the following values of hyperparameters are used in experiments.
• size of the embedding layer: 128
• mask low-frequency fragments: Yes • masking frequency: 2 • number of low frequency clusters: 5 • window for word2vec embedding: 3 • number of recurrent neurons per layer: 128 • number of recurrent layers: 2 • size of the VAE latent space: 64 • maximum length of the sampled sequence: 10 • batch size: 128 • shuffle batches: Yes • number of epochs to train: 50 • learning rate: 0.0005 • dropout for the recurrent layers: 0.3 • annealing step size for the scheduler: 4 • annealing rate for the scheduler: 0.8 • threshold to clip the gradient norm: 5 • number of layers in MLP for properties: 2 • number of hidden units in each hidden layer of MLP: 64 • weight on property regression loss $( \alpha )$ : 1 • weight on KL divergence $( \beta )$ : {0.01, 0.1, 1}
A.4 HYPERPARAMETER SETTING FOR DEL
When not specified in the main text, the following values of hyperparameters are used in experiments.
• number of evolutionary generations: 10 • popularization size: {20000 (default), 100000} • number of epochs in the initial training of DGM: 50 • annealing step size for the scheduler in initial training of DGM: 4 • annealing rate for the scheduler: 0.8 • number of epochs in a subsequent training of DGM: 30 • learning rate in the initial training of DGM: 0.0005 • annealing step size for the scheduler in initial training: 2 • probability in tournament selection: 0.95 • crossover method: {linear (default), discrete} • mutation rate: 0.01
A.5 HYPERPARAMETER SETTING FOR MOBO
When not specified in the main text, the following values of hyperparameters are used in experiments.
• number of initial data points: 1000 • number of batches: 30 • batch size: 8 • number of MC samples: 128
A.6 ADDITIONAL TABLES
Table 2: Performance of FragVAE in comparison with existing methods.
<table><tr><td>Model</td><td>Data</td><td>Validity (SMILES)</td><td>Validity (Fragments)</td><td>Novelty</td><td>Diversity</td></tr><tr><td>ChemVAE GrammarVAE SDVAE GraphVAE CGVAE</td><td>ZINC ZINC ZINC ZINC ZINC</td><td>0.170 0.310 0.435 0.140 1.000</td><td></td><td>0.980 1.000 = 1.000 1.000</td><td>0.310 0.108 1 0.316 0.998</td></tr><tr><td>NeVAE FragVAE (β=1.00)</td><td>ZINC ZINC</td><td>1.000 1.000</td><td>■ 0.922</td><td>0.999 1.000</td><td>1.000 0.961</td></tr><tr><td>FragVAE (β=0.10)</td><td>ZINC</td><td>1.000</td><td>0.953</td><td>0.999</td><td>0.985</td></tr><tr><td>FragVAE(β=0.01)</td><td>ZINC</td><td>1.000</td><td>0.655</td><td>0.997</td><td>0.809</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>FragVAE (β=1.00)</td><td>PCBA</td><td>1.000</td><td>0.443</td><td>1.000</td><td>0.925</td></tr><tr><td>FragVAE (β=0.10)</td><td>PCBA</td><td>1.000</td><td>0.481</td><td>0.983</td><td>0.886</td></tr><tr><td></td><td>PCBA</td><td>1.000</td><td>0.777</td><td>0.997</td><td></td></tr><tr><td>FragVAE (β=0.01)</td><td></td><td></td><td></td><td></td><td>0.632</td></tr></table>
Table 3: Running time of DEL and MOBO. Since both methods involve training FragVAE, the FragVAE training time was not counted in this table. Format: Hours:Minutes:Seconds. Note: when $\beta$ is annealed to 0.4 in DEL, $\alpha$ is annealed from 1 to 4. All experiments were carried out on a Dell Precision 5820 Workstation equipped with an Intel Xeon W-2255 CPU (10C), RAM of 128GB, and a Nvidia Quadro RTX 6000 (24GB) GPU.
<table><tr><td rowspan=1 colspan=1>Data</td><td rowspan=1 colspan=1>DEL Hyperparameter</td><td rowspan=1 colspan=1>DEL</td><td rowspan=1 colspan=1>MOBO</td></tr><tr><td rowspan=1 colspan=1>ZINCZINC</td><td rowspan=1 colspan=1>β=0.1→0.4β = 0.01 → 0.4</td><td rowspan=1 colspan=1>3:03:493:08:09</td><td rowspan=1 colspan=1>25:23:01141:49:37</td></tr><tr><td rowspan=1 colspan=1>PCBAPCBA</td><td rowspan=1 colspan=1>β=0.1→0.4β = 0.01 → 0.4</td><td rowspan=1 colspan=1>3:01:321:50:20</td><td rowspan=1 colspan=1>31:16:1845:31:38</td></tr></table>
Table 4: Non-dominated sorting of combination of Pareto fronts from DEL with and without property prediction (PP) component as latent space regularization.
<table><tr><td rowspan=1 colspan=2></td><td rowspan=1 colspan=2>Pareto Front Size for Comparison</td><td rowspan=1 colspan=2>InNewPareto Front</td></tr><tr><td rowspan=1 colspan=1>Data</td><td rowspan=1 colspan=1>DELParameter</td><td rowspan=1 colspan=1>With PP</td><td rowspan=1 colspan=1>Without PP</td><td rowspan=1 colspan=1>With PP</td><td rowspan=1 colspan=1>Without PP</td></tr><tr><td rowspan=1 colspan=1>ZINCPCBA</td><td rowspan=1 colspan=1>β=0.1β=0.1</td><td rowspan=1 colspan=1>235224</td><td rowspan=1 colspan=1>234108</td><td rowspan=1 colspan=1>206 (87.66%)216 (96.43%)</td><td rowspan=1 colspan=1>0(0%)0(0%)</td></tr></table>
Table 5: Non-dominated sorting of combination of Pareto fronts from DEL with and without DGM finetuning (FT) phrase.
<table><tr><td rowspan=1 colspan=2></td><td rowspan=1 colspan=2>Pareto Front Size for Comparison</td><td rowspan=1 colspan=2>In New Pareto Front</td></tr><tr><td rowspan=1 colspan=1>Data</td><td rowspan=1 colspan=1>DEL Parameter</td><td rowspan=1 colspan=1>With FT</td><td rowspan=1 colspan=1>Without FT</td><td rowspan=1 colspan=1>With FT</td><td rowspan=1 colspan=1>Without FT</td></tr><tr><td rowspan=1 colspan=1>ZINCPCBA</td><td rowspan=1 colspan=1>β=0.1β=0.1</td><td rowspan=1 colspan=1>235224</td><td rowspan=1 colspan=1>193214</td><td rowspan=1 colspan=1>235 (100%)199 (88.84%)</td><td rowspan=1 colspan=1>0 (0%)0(0%)</td></tr></table>
Table 6: Non-dominated sorting of combination of Pareto fronts from DEL with linear or discrete crossover operation. Note: when $\beta$ is annealed to 0.4, $\alpha$ is annealed from 1 to 4.
<table><tr><td rowspan=1 colspan=2></td><td rowspan=1 colspan=2>Pareto Front Size for Comparison</td><td rowspan=1 colspan=2>InNewPareto Front</td></tr><tr><td rowspan=1 colspan=1>Data</td><td rowspan=1 colspan=1>DEL Parameter</td><td rowspan=1 colspan=1>Linear</td><td rowspan=1 colspan=1>Discrete</td><td rowspan=1 colspan=1>Linear</td><td rowspan=1 colspan=1>Discrete</td></tr><tr><td rowspan=1 colspan=1>ZINCPCBA</td><td rowspan=1 colspan=1>β=0.01→0.4β = 0.01 → 0.4</td><td rowspan=1 colspan=1>200183</td><td rowspan=1 colspan=1>181195</td><td rowspan=1 colspan=1>196 (98.00%)146 (79.78%)</td><td rowspan=1 colspan=1>173 (95.58%)184 (94.36%)</td></tr></table>
A.7 ADDITIONAL FIGURES
Table 7: Non-dominated sorting of combination of Pareto fronts from DEL with population sizes of 20K and 100K. Note: when $\beta$ is annealed to 0.4, $\alpha$ is annealed from 1 to 4.
<table><tr><td rowspan=1 colspan=2></td><td rowspan=1 colspan=2>Pareto Front Size for Comparison</td><td rowspan=1 colspan=2>In New Pareto Front</td></tr><tr><td rowspan=1 colspan=1>Data</td><td rowspan=1 colspan=1>DEL Parameter</td><td rowspan=1 colspan=1>20K</td><td rowspan=1 colspan=1>100K</td><td rowspan=1 colspan=1>20K</td><td rowspan=1 colspan=1>100K</td></tr><tr><td rowspan=1 colspan=1>ZINCPCBA</td><td rowspan=1 colspan=1>β=0.1→0.4β= 0.1 → 0.4</td><td rowspan=1 colspan=1>243228</td><td rowspan=1 colspan=1>316354</td><td rowspan=1 colspan=1>78 (32.10%)88 (38.60%)</td><td rowspan=1 colspan=1>304 (96.20%)334 (94.35%)</td></tr></table>
Table 8: Non-dominated sorting of combination Pareto fronts from DEL with different values of $\beta$ Note: when $\beta$ is annealed to 0.4, $\alpha$ is annealed from 1 to 4. Population size: 20K.
<table><tr><td></td><td colspan="4">Pareto Front Size for Comparison</td><td colspan="4">In New Pareto Front</td></tr><tr><td>Data</td><td></td><td></td><td></td><td>β=0.1β=0.1→0.4β=0.01β=0.01→0.4</td><td>β=0.1</td><td>β=0.1→0.4</td><td>β=0.01</td><td>β=0.01→0.4</td></tr><tr><td>ZINC</td><td>235</td><td>243</td><td>228</td><td>200</td><td>195(82.98%)</td><td>186(76.54%)</td><td>170(74.56%)</td><td>143(71.50%)</td></tr><tr><td>PCBA</td><td>224</td><td>228</td><td>189</td><td>183</td><td>169(75.45%)</td><td>183(80.26%)</td><td>122(64.55%)</td><td>111(60.66%)</td></tr></table>
Table 9: Numbers of novel molecules that satisfy properties $\mathrm { Q E D } \geq 0 . 8 8$ , $\mathrm { S A S } \le 3$ , and $\mathrm { l o g P \le 1 }$ in the 1st, 5th and final (10th) generations of DEL. Numbers of training molecules satisfying same conditions are also given. Note: when $\beta$ is annealed to 0.4, $\alpha$ is annealed from 1 to 4.
<table><tr><td>Data</td><td>Hyperparameter</td><td>Train</td><td>DEL(1)</td><td>DEL(5)</td><td>DEL(F)</td></tr><tr><td>ZINC</td><td>β=0.1</td><td>406</td><td>226</td><td>14</td><td>40</td></tr><tr><td>ZINC ZINC</td><td>β= 0.1 → 0.4</td><td>-</td><td></td><td>22</td><td>32</td></tr><tr><td></td><td>β =0.01</td><td>-</td><td></td><td>54</td><td>115</td></tr><tr><td>ZINC</td><td>β = 0.01 →0.4</td><td>1</td><td>3</td><td>9</td><td>20</td></tr><tr><td>PCBA</td><td>β 三 :0.1</td><td>196</td><td>4</td><td>13</td><td>27</td></tr><tr><td>PCBA</td><td>β 三 0.1→ 0.4</td><td>1</td><td>10</td><td>33</td><td>52</td></tr><tr><td>PCBA</td><td>β =0.01</td><td></td><td>0</td><td>8</td><td>16</td></tr><tr><td>PCBA</td><td>β= 0.01 → 0.4</td><td>=</td><td>4</td><td>9</td><td>10</td></tr></table>
 Figure 6: Different of forms of the $\beta$ -function. The total number of epochs is $T = 1 0 0$ .
 Figure 7: Loss of FragVAE in initial training on ZINC and PCBA respectively.
 Figure 8: Loss of of FragVAE in DEL on ZINC and PCBA respectively.
 Figure 9: ZINC training molecules that satisfy properties QED≥ 0.88, $\mathrm { S A S } { \le } \ 3$ , and $\mathrm { l o g P \le 1 }$ . Note: 196 molecules satisfy these conditions, but 64 are visualized.
 Figure 10: PCBA training molecules that satisfy properties $\mathrm { Q E D } \geq 0 . 8 8$ , $\mathrm { S A S } \le 3$ , and $\mathrm { l o g P \le 1 }$ . Note: 406 molecules satisfy these conditions, but 64 are visualized.
 Figure 11: Novel molecules that satisfy properties $\mathrm { Q E D } \geq 0 . 8 8$ , $\mathrm { S A S } \le 3$ , and $\mathrm { l o g P \le 1 }$ in the final generation of DEL trained on ZINC with hyperparameter: $\beta = 0 . 1$ , $\alpha = 1$ .
 Figure 12: Novel molecules that satisfy properties QE $\mathrm { D } \geq 0 . 8 8$ , $\mathrm { S A S } \le 3$ , and $\mathrm { l o g P \le 1 }$ in the final generation of DEL trained on ZINC with hyperparameter: $\beta = 0 . 1 0 . 4$ , $\alpha = 1 4$ .
 Figure 13: Novel molecules that satisfy properties $\mathrm { Q E D } \geq 0 . 8 8$ , $\mathrm { S A S } \le 3$ , and $\mathrm { l o g P \le 1 }$ in the final generation of DEL trained on ZINC with hyperparameter: $\beta = 0 . 0 1$ , $\alpha = 1$ .
 Figure 14: Novel molecules that satisfy properties $\mathrm { Q E D } \geq 0 . 8 8 , \mathrm { S A S } \leq 3$ , and $\mathrm { l o g P \le 1 }$ in the final generation of DEL trained on ZINC with hyperparameter: $\beta = 0 . 0 1 0 . 4$ , $\alpha = 1 4$ .
 Figure 15: Novel molecules that satisfy properties $\mathrm { Q E D } \geq 0 . 8 8 , \mathrm { S A S } \leq 3$ , and $\mathrm { l o g P \le 1 }$ in the final generation of DEL trained on PCBA with hyperparameter: $\beta = 0 . 1$ , $\alpha = 1$ .
 Figure 16: Novel molecules that satisfy properties $\mathrm { Q E D } \geq 0 . 8 8$ , $\mathrm { S A S } \le 3$ , and $\mathrm { l o g P \le 1 }$ in the final generation of DEL trained on PCBA with hyperparameter: $\beta = 0 . 1 \to 0 . 4$ , $\alpha = 1 4$ .
 Figure 17: Novel molecules that satisfy properties QE $\mathrm { D \geq 0 . 8 8 }$ , $\mathrm { S A S } \le 3$ , and $\mathrm { l o g P \le 1 }$ in the final generation of DEL trained on PCBA with hyperparameter: $\beta = 0 . 0 1$ , $\alpha = 1$ .
 Figure 18: Novel molecules that satisfy properties $\mathrm { Q E D } \geq 0 . 8 8$ , $\mathrm { S A S } \le 3$ , and $\mathrm { l o g P \le 1 }$ in the final generation of DEL trained on PCBA with hyperparameter: $\beta = 0 . 0 1 0 . 4$ , $\alpha = 1 4$ .
 Figure 19: Property and structural feature distributions of population samples during DEL $\beta = 0 . 1$ ).
 Figure 20: Property and structural feature distributions of population samples during DEL $\beta =$ $0 . 1 0 . 4$ ).
 Figure 21: Property and structural feature distributions of population samples during DEL $\beta =$ 0.01).
 Figure 22: Property and structural feature distributions of randomly sampled molecules using FragVAE during DEL $\beta = 0 . 1 $ ).
 Figure 23: Property and structural feature distributions of randomly sampled molecules using FragVAE during DEL $\beta = 0 . 1 0 . 4$ ).
 Figure 24: Property and structural feature distributions of randomly sampled molecules using FragVAE during DEL ( $\beta = 0 . 0 1$ ).
 Figure 25: Property and structural feature distributions of randomly sampled molecules using FragVAE during DEL $\beta = 0 . 0 1 0 . 4$ ).
 Figure 26: Hypervolume along batches when running Sobol random search, qParEGO, and qEHVI.
 Figure 27: Pareto fronts of DEL and MOBO algorithms $\beta = 0 . 1 $ . In the legend, the last batch of qParEGO or qEHVI is written as Front 1.
 Figure 28: Validity, novelty and diversity of population samples (after evolutionary operations and before merging with previous population) in different variants of DEL.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636# CobBO: Coordinate Backoff Bayesian Optimization with Two-Stage Kernels
Anonymous Author(s) Affiliation Address email
# Abstract
1 Bayesian optimization is a popular method for optimizing expensive black-box 2 functions. Yet it oftentimes struggles in high dimensions where the computation 3 could be prohibitively expensive and a sufficient estimation of the global landscape 4 requires more observations. We introduce Coordinate backoff Bayesian optimiza 5 tion (CobBO) with two-stage kernels to alleviate this problem. In each iteration, a 6 promising subset of coordinates is selected in the first stage, as past observed points 7 in the full space are projected to the selected subspace adopting a simple kernel 8 that sacrifices the approximation accuracy for computational efficiency. Then in 9 the second stage of the same iteration a more sophisticated kernel is applied for 10 estimating the landscape in the selected low dimensional subspace where the com 11 putational cost becomes affordable. Effectively, this second stage kernel refines the 12 approximation of the global landscape estimated by the first stage kernel through 13 a sequence of observations in the local subspace. This refinement lasts until a 14 stopping rule is met determining when to back off from a certain subspace and 15 switch to another coordinate subset. This decoupling significantly reduces the com 16 putational burden in high dimensions, while the two-stage kernels of the Gaussian 17 process regressions fully leverage the observations in the whole space rather than 18 only relying on observations in each coordinate subspace. Extensive evaluations 19 show that CobBO finds solutions comparable to or better than other state-of-the-art 20 methods for dimensions ranging from tens to hundreds, while reducing the trial 21 complexity and computational costs.
# 22 1 Introduction
Bayesian optimization (BO) has emerged as an effective zero-order paradigm for optimizing expensive black-box functions. The entire sequence of iterations rely only on the function values of the already queried points without information on their derivatives. Though highly competitive in low dimensions (e.g., the dimension $D \leq 2 0$ [15]), Bayesian optimization based on Gaussian Process (GP) regression has obstacles that impede its effectiveness, especially in high dimensions.
Approximation accuracy: GP regression assumes a class of random functions in a probability space as surrogates that iteratively yield posterior distributions by conditioning on the queried points. When suggesting new query points, for complex functions with numerous local optima and saddle points due to local fluctuations, always exactly using the values on the queried points as the conditional events may mismatch the function’s local landscape by overemphasizing the approximation accuracy of the global landscape.
Curse of dimensionality: As a sample efficient method, Bayesian optimization often suffers from high dimensions. Fitting the GP model (estimating the parameters, e.g., length_scales [14]), computing the Gaussian process posterior and optimizing the acquisition function in high dimensions all
 Figure 1: Minimize the fluctuated Rastrigin function on $[ - 5 , 1 0 ] ^ { 5 0 }$ with 20 initial samples. [Left] Computation times for training the GP regression model and maximizing the acquisition function at each iteration. CobBO significantly reduces the execution time compared with a vanilla BO, e.g. $\times 1 3$ faster in this case. [Right] The average error between the GP predictions before making queries and the true function values at the queried points (solid curves, the higher the better) and the best observed function value (dashed curves, the lower the better) at iteration $t$ . CobBO captures the global landscape less accurately using the RBF kernel, and then explores selected subspaces $\Omega _ { t }$ more accurately using the Matern kernel. This eventually better exploits the promising subspaces.
39 incur large computational costs. It also results in statistical insufficiency of exploration [11, 65]. As 40 the GP regression’s error grows with dimensions [8], more samples are required to balance that in 41 high dimensions, which could cubically increase the computational costs in the worst case [45]. 42 To alleviate these issues, we design coordinate backoff Bayesian optimization (CobBO) with two 43 stage kernels, by challenging a seemingly natural intuition stating that it is always better for Bayesian 44 optimization to have a more accurate approximation of the objective function at all times. We 45 demonstrate that this is not necessarily true, by showing that smoothing out local fluctuations and 46 using the estimated function values instead of the true observations to serve as the conditional events 47 in selected subspaces can not only significantly reduce the computation time due to the curse of 48 dimensionality but also help in capturing the large-scale properties of the objective function $f ( x )$ . 49 Specifically, CobBO introduces the two-stage kernels with a stopping rule. The first stage of each 50 iteration adopts a simple kernel that sacrifices the approximation accuracy of $f ( x )$ for computational 51 efficiency. For example, by using a universal radial basis function (RBF) approximation without 52 learnable parameters [50], CobBO can eliminate the model fitting time in the full space. It captures 53 a smooth approximation ${ \hat { f } } ( x )$ of the global landscape by interpolating the values of queried points 54 projected to selected promising subspaces. These projected points serve as the conditional events 55 for GP regression. In a selected coordinate subspace, the second stage of the same iteration applies 56 a sophisticated kernel that can tolerate high computational cost in low dimensions. For example, 57 CobBO uses the Automatic Relevance Determination (ARD) Matérn 5/2 kernel [40]. It refines the 58 approximation of the local landscape by a sequence of observations determined by a stopping rule that 59 backs off from a certain subspace and switches to another coordinate subset. In addition, computing 60 the Gaussian process posterior and optimizing the acquisition function are both efficiently conducted 61 in the low dimensional subspaces, bypassing the curse of dimensionality. 62 For iteration $t$ , instead of directly computing the Gaussian process posterior distribution 63 $\left\{ \hat { f } ( x ) \middle | \mathcal { H } _ { t } = \left\{ ( x _ { i } , y _ { i } ) \right\} _ { i = 1 } ^ { t } , x \in \Omega \right\}$ by conditioning on the observations $y _ { i } = f ( x _ { i } )$ at queried 64 points $x _ { i }$ in the full space $\Omega \subset \mathbb { R } ^ { D }$ for $i = 1 , \ldots , t$ , we change the conditional events, and consider
$$\left\{ \hat { f } ( x ) \Big | R \left( P _ { \Omega _ { t } } ( x _ { 1 } , \dots , x _ { t } ) , \mathcal { H } _ { t } \right) , x \in \Omega _ { t } , \Omega _ { t } \subset \Omega \right\}$$
65 for a projection function $P _ { \Omega _ { t } } ( \cdot )$ to a random subspace $\Omega _ { t }$ and an interpolation function $R ( \cdot , \cdot )$ , e.g., 66 using a RBF approximation without learnable parameters [50] as the simple kernel for the first 67 stage. The projection $P _ { \Omega _ { t } } ( \cdot )$ maps the queried points to virtual points on a subspace $\Omega _ { t }$ of a lower 68 dimension [51]. The interpolation function $R ( \cdot , \cdot )$ estimates the objective values at the virtual points 69 using the queried points and their values as specified by $\mathcal { H } _ { t }$ . The second stage within the subspace $\Omega _ { t }$ 70 uses the more sophisticated kernel, e.g., Matérn $5 / 2$ kernel [40], which has a number of parameters 71 that otherwise would be expensive to be learned in high dimensions. 72 This method can be viewed as a variant of block coordinate ascent tailored to Bayesian optimization by 73 applying backoff stopping rules for switching coordinate blocks. While similar work exists [43, 48], 74 CobBO differs by introducing the two-stage kernels and addressing the following three issues:
1. Selecting a block of coordinates for ascending requires determining the block size as well as the coordinates therein. CobBO selects the coordinate subsets by a multiplicative weights update method [2] to the preference probability associated with each coordinate. Thus, it samples more promising subspaces with higher probabilities. 2. A coordinate subspace requires a sufficient number of query points acting as the conditional events for the GP regression. CobBO leverages all observations in the whole space by interpolating the values of queried points projected to selected promising subspaces, rather than simply starting from scratch in each subspace. 3. Querying a certain subspace, under some trial budget, comes at the expense of exploring other coordinate blocks. Yet prematurely shifting to different subspaces does not fully exploit the full potential of a given subspace. Hence determining the number of consecutive function queries within a subspace makes a trade-off between exploration and exploitation. CobBO uses a stopping rule in each subspace to switch the selected coordinates. When consecutively querying data points in the same subspace, CobBO does not need to conduct the first-stage function approximation in the full space, which is far more efficient.
90 Through comprehensive evaluations, CobBO demonstrates appealing performance for dimensions 91 ranging from tens to hundreds. It obtains comparable or better solutions with fewer queries, in 92 comparison with the state-of-the-art methods, for most of the problems tested in Section 4.2.
# 2 Related work
94 Certain assumptions are often imposed on the latent structure in high dimensions. Typical assumptions 95 include low dimensional structures and additive structures. Their advantages manifest on problems 96 with a low dimension or a low effective dimension. However, these assumptions do not necessarily 97 hold for non-separable functions with no redundant dimensions. 98 Low dimensional structure: The black-box function $f$ is assumed to have a low effective dimen 99 sion [30, 58], e.g., $f ( x ) = g ( \Phi x )$ with some function $g ( \cdot )$ and a matrix $\Phi$ of $d \times D , d < < D$ . A 100 number of different methods have been developed, including random embedding [66, 11, 63, 36, 101 44, 70, 5, 32], low-rank matrix recovery [11, 58], and learning subspaces by derivative informa 102 tion [11, 13]. In contrast to existing work on subspace selections, e.g., Hashing-enhanced Subspace 103 BO (HeSBO) [44], Mahalanobis kernel for linear embeddings [33], DROPOUT [35] and LineBO [29] 104 (which receives a special treatment in Appendix F), CobBO efficiently leverages all the observations 105 in the whole space using the two-stage kernels and the stopping rule in each subspace for consecutive 106 observations, rather than only relying on limited observations in each coordinate subspace. It exploits 107 subspace structure from a perspective of block coordinate ascent, independent of the dimensions, 108 different from some algorithms that are more suitable for low dimensions, e.g., BADS [1]. 109 Additive structure: A decomposition assumption is often made by $\begin{array} { r } { f ( x ) = \sum _ { i = 1 } ^ { k } f ^ { ( i ) } \left( x _ { i } \right) } \end{array}$ , with $x _ { i }$ 110 defined over low-dimensional components. In this case, the effective dimensionality of the model is 111 the largest dimension among all additive groups [45], which is usually small. The Gaussian process 112 is structured as an additive model [17, 28], e.g., projected-additive functions [36], ensemble Bayesian 113 optimization (EBO) [61], latent additive structural kernel learning (HDBBO) [65] and group additive 114 models [28, 36]. However, learning the unknown structure incurs a considerable computational 115 cost [44], and is not applicable for non-separable functions, for which CobBO can still be applied. 116 Trust regions and space partitions: Trust region BO has been proven effective for high-dimensional 117 problems. A typical pattern is to alternate between global and local search regions. In the local 118 trust regions, many efficient methods have been applied, e.g., local Gaussian models (TurBO [14]), 119 adaptive search on a mesh grid (BADS [1]) or quasi-Newton local optimization (BLOSSOM [41]). 120 TurBO [14] uses Thompson sampling to allocate samples across multiple regions. A related method is 121 to use space partitions, e.g., LA-MCTS[60] on a Monte Carlo tree search algorithm to learn efficient 122 partitions. CobBO differs by selecting low dimensional subspaces. It can also incorporate trust 123 regions in the first-stage global approximation, as shown in the Appendix. 125 Without loss of generality, suppose that the goal is to solve a maximization problem $\boldsymbol { x } ^ { * } =$ 126 $\mathrm { { r g m a x } } _ { x \in \Omega } f ( x )$ for a black-box function $f : \Omega \mathbb { R }$ . The domain is normalized $\Omega = [ 0 , 1 ] ^ { D }$ 127 with the coordinates indexed by $I = \{ 1 , 2 , \cdots , D \}$ . 128 For a sequence of points $\mathcal { X } _ { t } = \{ x _ { 1 } , x _ { 2 } , \cdot \cdot \cdot , x _ { t } \}$ with $t$ indexing the most recent iteration, we observe 129 $\mathcal { H } _ { t } = \{ ( x _ { i } , y _ { i } = f ( x _ { i } ) ) \} _ { i = 1 } ^ { t }$ . A random subset $C _ { t } \subseteq I$ of the coordinates is selected, forming a 130 subspace $\Omega _ { t } \subseteq \Omega$ at iteration $t$ . As a variant of coordinate ascent, the subspace $\Omega _ { t }$ contains a pivot 131 point $V _ { t }$ , which presumably is the maximum point $x _ { t } ^ { M } = \operatorname { a r g m a x } _ { x \in \mathcal { X } _ { t } } { f ( x ) }$ with $M _ { t } = f \left( { { \dot { x } } _ { t } } ^ { M } \right)$ . 132 CobBO may set $V _ { t }$ different from $x _ { t } ^ { M }$ to escape local optima. Then, BO is conducted within $\Omega _ { t }$ while 133 fixing all the other coordinates $C _ { t } ^ { c } \bar { = } I \setminus C _ { t }$ , i.e., the complement of $C _ { t }$ .
# $\overline { { \mathbf { A l g o r i t h m 1 : C o b B O ( f , \boldsymbol { \tau } , T ) } } }$
1 $\mathcal { H } _ { \tau } \gets \mathrm { s a m p l e } ~ $ $\tau$ initial points and evaluate their values 2 $V _ { \tau } , M _ { \tau } \gets$ Find the tuple with the maximal objective value in $\mathcal { H } _ { \tau }$ 3 $q _ { \tau } \gets 0$ Initialize the number of consecutive failed queries 4 $\pi _ { \tau } $ Initialize a uniform preference distribution on the coordinates 5 for $t \tau$ to $T$ do 6 if switch $\Omega _ { t - 1 }$ by the backoff stopping rule (Section 3.2) then 7 $C _ { t } \gets$ Sample a promising coordinate block according to $\pi _ { t }$ (Section 3.1) 8 $\Omega _ { t } \gets$ Take the subspace of $\Omega _ { t }$ over the coordinate block $C _ { t }$ , such that $V _ { t } \in \Omega _ { t }$ 9 else 10 $\Omega _ { t } \gets \Omega _ { t - 1 }$ 11 $\hat { \mathcal { X } } _ { t } \gets P _ { \Omega _ { t } } ( \mathcal { X } _ { t } )$ hProject $\mathcal { X } _ { t }$ onto $\Omega _ { t }$ to obtain a set of virtual points (Eq. 1)i 12 $\hat { \mathcal { H } } _ { t } \gets R \left( \hat { \mathcal { X } } _ { t } , \bar { \mathcal { H } } _ { t } \right)$ hSmooth function values on $\hat { \mathcal { X } } _ { t }$ by interpolation using $\mathcal { H } _ { t }$ i 13 $p \left[ \hat { f } _ { \Omega _ { t } } ( x ) | \hat { \mathcal { H } } _ { t } \right] \gets \mathbf { C } \mathbf { \tau }$ ompute the posterior distribution of the Gaussian process in $\Omega _ { t }$ conditional on $\hat { \mathcal { H } } _ { t }$ 14 $\begin{array} { r } { x _ { t + 1 } \gets \mathrm { a r g m a x } _ { x \in \Omega _ { t } } Q _ { \hat { f } \sim p ( \hat { f } | \hat { \mathcal { H } } _ { t } ) } ( x | \hat { \mathcal { H } } _ { t } ) \ \Big [ } \end{array}$ Suggest the next query in $\Omega _ { t }$ (Section 3)i 15 $y _ { t + 1 } \gets$ Evaluate the black-box function $y _ { t + 1 } = f ( x _ { t + 1 } )$ 16 if $y _ { t + 1 } > M _ { t }$ then 17 $| \quad V _ { t + 1 } \gets x _ { t + 1 } , M _ { t + 1 } \gets y _ { t + 1 } , q _ { t + 1 } \gets 0$ 18 else 19 $V _ { t + 1 } V _ { t }$ , $M _ { t + 1 } \gets M _ { t }$ , $q _ { t + 1 } \gets q _ { t } + 1$ 20 $\pi _ { t + 1 } $ Update $\pi _ { t }$ by a multiplicative weights update method (Eq. 2) 21 $\mathcal { H } _ { t + 1 } \bar { \mathcal { H } } _ { t } \bigcup \{ ( x _ { t + 1 } , y _ { t + 1 } ) \} , \mathcal { X } _ { t + 1 } \bar { \mathcal { X } } _ { t } \bigcup \{ x _ { t + 1 } \}$ 22 end
For BO in 134 $\Omega _ { t }$ , we use Gaussian processes as the random surrogates $\hat { f } = \hat { f } _ { \Omega _ { t } } ( x )$ to describe the 135 Bayesian statistics of $f ( x )$ for $x \in \Omega _ { t }$ . At each iteration, the next query point is generated by solving
$$\begin{array} { r } { x _ { t + 1 } = \mathrm { a r g m a x } _ { x \in \Omega _ { t } , V _ { t } \in \Omega _ { t } } Q _ { \hat { f } _ { \Omega _ { t } } ( x ) \sim p ( \hat { f } | \mathcal { H } _ { t } ) } ( x | \mathcal { H } _ { t } ) , } \end{array}$$
136 where the acquisition function $Q ( x | \mathcal { H } _ { t } )$ incorporates the posterior distribution of the Gaussian 137 processes $p ( \hat { f } | \mathcal { H } _ { t } )$ . Typical acquisition functions include the expected improvement (EI) [42, 27], 138 the upper confidence bound (UCB) [3, 54, 55], the entropy search [24, 25, 64], and the knowledge 139 gradient [16, 53, 69].
Instead of directly computing the posterior distribution 140 $p ( \hat { f } | \mathcal { H } _ { t } )$ , we replace the conditional events 141 $\mathcal { H } _ { t }$ by
$$\hat { \mathcal { H } } _ { t } : = R \left( P _ { \Omega _ { t } } \left( \mathcal { X } _ { t } \right) , \mathcal { H } _ { t } \right) = \left\{ \left( \hat { x } _ { i } , \hat { y } _ { i } \right) \right\} _ { i = 1 } ^ { t }$$
with an interpolation function 142 $R ( \cdot , \cdot )$ and a projection function $P _ { \Omega _ { t } } ( \cdot )$ ,
$$P _ { \Omega _ { t } } ( x ) ^ { ( j ) } = { \left\{ \begin{array} { l l } { x ^ { ( j ) } } & { { \mathrm { i f ~ } } j \in C _ { t } } \\ { V _ { t } ^ { ( j ) } } & { { \mathrm { i f ~ } } j \not \in C _ { t } } \end{array} \right. }$$
143 at coordinate $j$ . It simply keeps the values of $x$ whose corresponding coordinates are in $C _ { t }$ and 144 replaces the rest by the corresponding values of $V _ { t }$ , as illustrated in Fig. 2. 145 Applying $P _ { \Omega _ { t } } ( \cdot )$ on $\mathcal { X } _ { t }$ and discarding duplicates generate a new set of distinct virtual points $\hat { \mathcal { X } } _ { t } =$ 146 $\{ \hat { x } _ { 1 } , \hat { x } _ { 2 } , \hat { x } _ { 3 } , \cdot \cdot \cdot , \hat { x } _ { \hat { t } } \}$ , $\hat { x } _ { i } \in \Omega _ { t } \forall 1 \leq i \leq \hat { t } \leq t$ . The function values at $\hat { x } _ { i } \in \hat { \mathcal X } _ { t }$ are interpolated as 147 $\hat { y } _ { i } = R ( \hat { x } _ { i } , \mathcal { H } _ { t } )$ using the standard radial basis function [6, 7] and the observed points in $\mathcal { H } _ { t }$ . It not 148 only significantly reduces the GP regression time due to the efficiency of RBF [6] and the acquisition 149 function optimization in low dimensions [11], but also eventually improves the model accuracy using 150 the more sophisticated kernel applied on $\Omega _ { t }$ . 151 Note that only a fraction of the points in $\hat { \mathcal X } _ { t } \cap \mathcal X _ { t }$ 152 directly observe the exact function values. The 153 function values on the rest ones in $\hat { \mathcal { X } } _ { t } \backslash \mathcal { X } _ { t }$ are 154 estimated by interpolation, which captures the 155 landscape of $f ( x )$ by smoothing out the local 156 fluctuations. To control the trade-off between 157 the inaccurate estimations and the exact obser 158 vations in $\Omega _ { t }$ , we design a stopping rule that 159 optimizes the number of consistent queries in 160 $\Omega _ { t }$ . The more consistent queries conducted in a 161 given subspace, the more accurate observations
 Figure 2: Two-stage kernels: subspace projection and function value interpolation
62 could be obtained, albeit at the expense of a smaller remaining budget for exploring other regions.
163 The key features of CobBO are listed in Algorithm 1, with more details in the following sections. 164 Several auxiliary components are utilized and presented in Appendix C to deal with a larger variety 165 of problems and corner cases.
# 166 3.1 Block coordinate ascent and subspace selection
167 For Bayesian optimization, consider an infeasible assumption that each iteration can exactly maximize 168 the function $f ( x )$ in $\Omega _ { t }$ . This is not possible for one iteration but only if one can consistently query 169 in $\Omega _ { t }$ , since the points converge to the maximum, e.g., under the expected improvement acquisition 170 function with fixed priors [59] and the convergence rate can be characterized for smooth functions 171 in the reproducing kernel Hilbert space [8]. However, even with this infeasible assumption, it is 172 known that coordinate ascent with fixed blocks can cause stagnation at a non-critical point, e.g., for 173 non-differentiable [67] or non-convex functions [49]. This motivates us to select a subspace with a 174 variable-size coordinate block $C _ { t }$ for each query. A good coordinate block can help the iterations 175 to escape the trapped non-critical points. For example, one condition can be based on the result 176 in [21] that assumes $f ( x )$ to be differentiable and strictly quasi-convex over a collection of blocks. In 177 practice, we do not restrict ourselves to these assumptions. 178 We induce a preference distribution $\pi _ { t }$ over the coordinate set $I$ , and sample a variable-size coordinate 179 block $C _ { t }$ accordingly. This distribution is updated at iteration $t$ through a multiplicative weights 180 update method [2]. Specifically, the values of $\pi _ { t }$ at coordinates in $C _ { t }$ starts off uniform and increase 181 in face of an improvement or decrease otherwise according to different multiplicative ratios $\alpha > 1$ 182 and $\beta > 1$ , respectively,
$$w _ { t , j } = w _ { t - 1 , j } \cdot \left\{ \begin{array} { l l } { \alpha } & { \mathrm { i f ~ } j \in C _ { t } \mathrm { ~ a n d ~ } y _ { t } > M _ { t - 1 } } \\ { 1 / \beta } & { \mathrm { i f ~ } j \in C _ { t } \mathrm { ~ a n d ~ } y _ { t } \leq M _ { t - 1 } } \\ { 1 } & { \mathrm { i f ~ } j \notin C _ { t } } \end{array} \right. ; \quad w _ { 0 , j } = \frac { 1 } { D } \quad ; \quad \pi _ { t , j } = \frac { w _ { t , j } } { \sum _ { j = 1 } ^ { D } w _ { t , j } }$$
183 This update characterizes how likely a coordinate block can generate a promising search subspace. 184 The multiplicative ratio $\alpha$ is chosen to be relatively large, e.g., $\alpha = 2 . 0$ , and $\beta$ relatively small, e.g., 185 $\beta = 1 . 1$ , since the queries that improve the best observations $y _ { t } > M _ { t - 1 }$ happen more rarely than 186 the opposite $y _ { t } \le M _ { t - 1 }$ . 187 How to dynamically select the size $| C _ { t } | \cdot \cdot$ It is known that Bayesian optimization works well for low 188 dimensions [15]. Thus, we specify an upper bound for the dimension of the subspace (e.g. $| C _ { t } | \le 3 0 \}$ . 189 In principle, $| C _ { t } |$ can be any random number in a finite set of possible block sizes $\mathcal { C }$ . This is different 190 from the method that partitions the coordinates into fixed blocks and selects one according to, e.g., 191 cyclic order [68], random sampling or Gauss-Southwell [46].
# 192 3.2 Backoff stopping rule for consistent queries
Applying BO on $\Omega _ { t }$ requires a strategy to determine the number of consecutive queries for making a sufficient progress. This strategy is based on previous observations, thus forming a stopping rule. In principle, there are two different scenarios, exemplifying exploration and exploitation, respectively. Persistently querying a given subspace refrains from opportunistically exploring other coordinate combinations. Abruptly shifting to different subspaces does not fully exploit the potential of a given subspace.
CobBO designs a heuristic stopping rule in compromise. It takes the above two scenarios into joint consideration, by considering not only the number of consecutive queries that fail to improve the objective function but also other factors including the improved difference $M _ { t } - M _ { t - 1 }$ , the point distance $\vert \vert x _ { t } - x _ { t - 1 } \vert \vert$ , the query budget $T$ and the problem dimension $D$ . On the one hand, switching to another subspace $\Omega _ { t + 1 } ~ ( \neq ~ \Omega _ { t } )$ prematurely without fully exploiting $\Omega _ { t }$ incurs an additional approximation error associated with the interpolation of observations in $\Omega _ { t }$ projected to $\Omega _ { t + 1 }$ . On the other hand, it is also possible to over-exploit a subspace, spending high query budget on marginal improvements around local optima. In order to mitigate this, even when a query leads to an improvement, other factors are considered for sampling a new subspace.
# 3.3 Theoretical Analysis
209 One can view our block coordinate selection approach in section 3.1 as a combinatorial mixture of 210 experts problem [10], where each coordinate is a single expert and the forecaster aims at choosing 211 the best combination of experts in each step. Under this view, we bound the regret of our selection 212 method with respect to the policy of selecting the best (unknown) block of coordinates at each step. 213 Assume that there is a fixed optimal choice $\mathcal { T } ^ { * }$ for the block of coordinates to pick at all steps. This 214 block is characterized by improving the objective function for the largest number of times among 215 all the possible coordinate blocks when performing Bayesian optimization over the corresponding 216 subspaces. The following particular design of losses expresses this cause:
$$\ell _ { t , i } = \left\{ \begin{array} { l l } { - \log ( \tilde { \alpha } ) } & { \mathrm { i f ~ } i \in C _ { t } \mathrm { ~ a n d ~ } y _ { t } > M _ { t - 1 } } \\ { \log ( \tilde { \beta } ) } & { \mathrm { i f ~ } i \in C _ { t } \mathrm { ~ a n d ~ } y _ { t } \leq M _ { t - 1 } } \\ { 0 } & { \mathrm { i f ~ } i \not \in C _ { t } } \end{array} \right. ~ ; \quad \tilde { \alpha } , \tilde { \beta } > 1$$
217 as all the coordinates participating in the selected block incur the same loss that effectively rewards 218 these coordinates for improving the objective and penalizes these for failing to improve the objective. 219 All other coordinates that are not selected receive a zero loss and remain untouched.
Note that $\tilde { \alpha }$ and $\tilde { \beta }$ express the extent of reward and penalty, e.g. for $\tilde { \alpha } = \tilde { \beta } = e$ we have losses of $\ell _ { t , i } \in \{ - 1 , 1 , 0 \}$ . Yet, $\tilde { \alpha }$ is better chosen to be larger than $\tilde { \beta }$ , since the frequency of improving the objective is expected to be smaller.
23 The loss received by the forecaster is to reflect the same motivation. This is done by averaging 24 the losses of the individual coordinates in the selected block, so that the size of the block does not 25 matter explicitly, i.e. a bigger block should not incur more loss just due to its size but only due to its 26 performance. Such that for each coordinate block $\mathcal { T } _ { t } \subset \mathcal { T } = \{ 1 , \cdots , D \}$ selected at time step $t$ , the 27 loss incurred by the forecaster is Lt,It = 1|I | $\begin{array} { r } { L _ { t , \mathcal { T } _ { t } } = \frac { 1 } { | \mathcal { T } _ { t } | } \sum _ { i \in \mathcal { T } _ { t } } \ell _ { t , i } } \end{array}$ . This is also the common loss incurred by 28 all the coordinates participating in that block.
229 In each step we have the following multiplicative update rule of the weights associated with each coordinate (setting 230 $\alpha = \tilde { \alpha } ^ { \eta }$ and $\beta = \widetilde { \beta } ^ { \eta }$ yields the update rule in Eq. 2):
$$w _ { t , i } = w _ { t - 1 , i } \cdot e ^ { - \eta \ell _ { t , i } } = w _ { t - 1 , i } \cdot \left\{ \begin{array} { l l } { \tilde { \alpha } ^ { \eta } } & { \mathrm { i f ~ } i \in C _ { t } \mathrm { ~ a n d ~ } y _ { t } > M _ { t - 1 } } \\ { 1 / \tilde { \beta } ^ { \eta } } & { \mathrm { i f ~ } i \in C _ { t } \mathrm { ~ a n d ~ } y _ { t } \le M _ { t - 1 } } \\ { 1 } & { \mathrm { i f ~ } i \notin C _ { t } } \end{array} \right.$$
The probability $\tilde { \pi } _ { t , \mathcal { T } _ { t } }$ of selecting a certain coordinate block $\mathcal { T } _ { t }$ is induced by $\pi _ { t }$ as specified next. Thus the expected cumulative loss of the foreceaster is:
$$L _ { T } = \sum _ { t = 1 } ^ { T } \sum _ { c \in \mathcal { C } } \sum _ { \mathbb { Z } _ { t } \in \mathcal { S } _ { c } } \tilde { \pi } _ { t , \mathbb { Z } _ { t } } \cdot \frac { 1 } { | \mathbb { Z } _ { t } | } \sum _ { i \in \mathcal { T } _ { t } } \ell _ { t , i }$$
Assume the best coordinate block is $\mathcal { T } ^ { * }$ , then the corresponding cumulative loss is:
$$L _ { T } ^ { * } = \sum _ { t = 1 } ^ { T } { L _ { t , \mathbb { Z } ^ { * } } } = \sum _ { t = 1 } ^ { T } \frac { 1 } { | \mathscr { T } ^ { * } | } \sum _ { i \in \mathscr { T } ^ { * } } \ell _ { t , i }$$
We hence aim at bounding the regret 231 $R e g r e t _ { T } = L _ { T } - L _ { T } ^ { * }$ .
232 Theorem 1. Sample from the combinatorial space of all possible coordinate blocks $\textstyle { \mathcal { T } } _ { t } \in \bigcup _ { c \in { \mathcal { C } } } S _ { c }$ with probability 233 $\begin{array} { r } { \tilde { \pi } _ { t , \mathcal { T } _ { t } } ~ = ~ \prod _ { i \in \mathcal { T } _ { t } } \tilde { w } _ { t , \mathcal { T } _ { t } } \Big / \sum _ { c \in \mathcal { C } } \sum _ { \hat { \mathcal { T } } \in \mathcal { S } _ { c } } \prod _ { j \in \hat { \mathcal { T } } } \tilde { w } _ { t , \hat { \mathcal { T } } } . } \end{array}$ . Then the update rule in Eq. 2 with 234 $\alpha = \tilde { \alpha } ^ { \eta }$ , $\beta = \widetilde { \beta } ^ { \eta }$ and $\eta = \log ( \tilde { \alpha } \tilde { \beta } ) ^ { - 1 } \sqrt { T ^ { - 1 } | \mathcal { C } | D \log ( D ) }$ yields:
$$R e g r e t _ { t } \le \mathcal { O } \left( ( \log ( \tilde { \alpha } \tilde { \beta } ) \cdot \sqrt { T | \mathcal { C } | D \log ( D ) } ) \right)$$
where 235 $\begin{array} { r } { \tilde { w } _ { t , \mathcal { T } _ { t } } = \prod _ { i \in \mathcal { T } _ { t } } w _ { t , i } ^ { 1 / | \mathcal { T } _ { t } | } } \end{array}$ w1/|It|t,i is the geometric mean of weights in block It. The upper bound in Eq. 5 is tight, as the lower bound can be shown to be of 236 $\Omega ( { \sqrt { T \log ( N ) } } )$ [23] where the number of experts is 237 $\begin{array} { r } { N = \sum _ { c \in \mathcal { C } } S _ { c } \leq D ^ { | \mathcal { C } | D } } \end{array}$ in our combinatorial setup, as typically $| \mathcal { C } | \ll D$ .
238 In practice, the direct sampling policy introduced in Theorem 1 involves high computational costs due 239 to the exponential growth of combinations in $D$ . Thus CobBO suggests an alternative computationally 240 efficient sampling policy with a linear growth in $D$ .
Theorem 2. Sample a block size $c \in { \mathcal { C } }$ with probability $p _ { c }$ and c coordinates without replacement according to $\pi _ { t }$ . Assume $c \supset \{ 1 \}$ , then the update rule in Eq. 2, with $\alpha = \tilde { \alpha } ^ { \eta }$ , $\beta = { \tilde { \beta } } ^ { \eta }$ and $\begin{array} { r } { \eta = \sqrt { \frac { \log ( D ) } { T ( \log ( \tilde { \alpha } \tilde { \beta } ) ^ { 2 } - \log ( p _ { 1 } ) ) } } \geq 1 } \end{array}$ ≥ 1 yields:
$$R e g r e t _ { t } \le \mathcal { O } \left( \sqrt { ( \log ( \tilde { \alpha } \tilde { \beta } ) ^ { 2 } - \log ( p _ { 1 } ) ) } \cdot \sqrt { T \log ( D ) } ) \right)$$
where $p _ { c } > 0$ for all $c \in { \mathcal { C } }$ and $\textstyle \sum _ { c \in c } p _ { c } = 1$ , e.g., uniformly set $p _ { c } \equiv | \mathcal { C } | ^ { - 1 }$ .The proof and detailed sampling policy are in Appendix A. The regret upper bound in Eq. 6 is tight, as the lower bound for an easier setup can be shown to be of $\Omega ( { \sqrt { T \log ( D ) } } )$ [23]. The implication on $\eta$ is valid only for settings of a very high dimensionality and low query budget. In particular, CobBO is designed for this kind of problems.
Remark: Similar analysis and results follow when incorporating consistent queries from Section 3.2 and sampling a new coordinate block once every several steps. This is done by effectively performing less steps of aggregated temporal losses, as shown in Appendix A.
# 4 Numerical Experiments
This section presents detailed ablation studies of the key components presented in Section 3 and comparisons with other algorithms.
# 4.1 Empirical analysis and ablation study
Ablation studies are designed to study the contributions of the key components in Algorithm 1 by experimenting with the Rastrigin function on $[ - 5 , 1 0 ] ^ { 5 0 }$ with 20 initial points. The best performing run out of 5 experiments for each configuration is presented in Figure 3.
 Figure 3: Ablation study using Rastrigin on $[ - 5 , 1 0 ] ^ { 5 0 }$ with 20 initial random samples
259 RBF interpolation: RBF calculation is time efficient. Specifically, this is much beneficial in high 260 dimensions. Figure 1 (left) shows the computation time of plain Bayesian optimization compared to 261 CobBO’s. While the former applies GP regression using the Matérn kernel in the high dimensional 262 space directly, the later applies RBF interpolation in the high dimensional space and GP regression 263 with the Matérn kernel in the low dimensional subspace. This two-step composite kernel leads to a 264 significant speed-up. Other time efficient alternatives are, e.g., the inverse distance weighting [26] 265 and the simple approach of assigning the value of the observed nearest neighbour. Figure 3 (a) shows 266 that RBF is the most favorable.
Backoff stopping rule: CobBO applies a stopping rule to query a variable number of points in subspace $\Omega _ { t }$ (Section 3.2). To validate its effectiveness, we compare it with schemes that use a fixed budget of queries for $\Omega _ { t }$ . Figure 3 (b) shows that the stopping rule yields superior results.
70 Coordinate blocks of a varying size: CobBO selects a block of coordinates of a varying size $C _ { t }$ 71 (Section 3.1). Figure 3 (c) shows that a varying size is better than fixed.
Preference probability over coordinates: For demonstrating the effectiveness of coordinate selection (Section 3.1), we artificially let the function value only depend on the first 25 coordinates of its input and ignore the rest. It forms two separate sets of active and inactive coordinates, respectively. We expect CobBO to refrain from selecting inactive coordinates. Figure 4 shows the entropy of this preference probability $\pi _ { t }$ over coordinates and the overall probability for picking active and inactive coordinate at each iteration. We see that the entropy decreases, as the preference distribution concentrates on the significant active coordinates.

 Figure 4: The preference probability focuses on active coordinates as the entropy decreases Figure 5: Performance over low (left) medium (middle) and high (right) dimensional problems
# 286 4.2 Comparisons with other methods
The default configuration for CobBO is specified in the supplementary materials. CobBO performs on par or outperforms a collection of state-of-the-art methods across the following experiments. Most of the experiments are conducted using the same settings as in TurBO [14], where it is compared with a comprehensive list of baselines, including BFGS, BOCK [47], BOHAMIANN, CMA-ES [22], BOBYQA, EBO [61], GP-TS, HeSBO [44], Nelder-Mead and random search. To avoid repetitions, we only show TuRBO and CMA-ES that achieve the best performance among this list, and additionally compare CobBO with BADS [1], REMBO [63], Differetial Evolution (Diff-Evo) [56], Tree Parzen Estimator (TPE) [4] and Adaptive TPE (ATPE) [12].
# 4.2.1 Low dimensional tests
To evaluate CobBO on low dimensional problems, we use the lunar landing [38, 14] and robot pushing [62], by following the setup in [14]. Confidence intervals $( 9 5 \% )$ over 30 independent experiments for each problem are shown in Fig. 5.
Lunar landing (maximization): This controller learning problem (12 dimensions) is provided by the OpenAI gym [38] and evaluated in [14]. Each algorithm has 50 initial points and a budget of 1, 500 trials. TuRBO is configured with 5 trust regions and a batch size of 50 as in [14]. Fig. 5 (upper left) shows that, among the 30 independent tests, CobBO quickly exceeds 300 along some good sample paths.
Robot pushing (maximization): This control problem (14 dimensions) is introduced in [62] and extensively tested in [14]. We follow the setting in [14], where TuRBO is configured with a batch size of 50 and 15 trust regions, each of which has 30 initial points. Each experiment has a budget of 10, 000 evaluations. On average CobBO exceeds 10 within 5500 trials, as shown in Fig. 5 (lower left).
# 4.2.2 High dimensional tests
Since the duration of each experiment in this section is long, confidence intervals $( 9 5 \% )$ ) over repeated 10 independent experiments for each problem are presented.
Additive latent structure (minimization): As mentioned in Section 2, additive latent structures have been exploited in high dimensions. We construct an additive function of 56 dimensions, defined as $f _ { 5 6 } ( x ) \ = \ \mathrm { { A c k l e y } ( x _ { 1 } ) + \mathrm { { L e v y } ( x _ { 2 } ) + \mathrm { { R a s t r i g i n } ( x _ { 3 } ) + \mathrm { { H a r t m a n n } ( x _ { 4 } ) + \mathrm { { R o s e n b r o c k } ( x _ { 5 } ) + \mathrm { { A c k l e y } ( x _ { 6 } ) + \mathrm { { A c k l e y } ( x _ { 7 } ) } } } } } } } $ Schwefel $\left( \mathrm { x } _ { 6 } \right)$ , where the first three terms express the exact functions and domains described in Section 4.2.1, the Hartmann function on $[ 0 , \bar { 1 } ] ^ { 6 }$ and the Rosenbrock and Schwefel functions on $[ - 5 , 1 0 ] ^ { 1 0 }$ and $[ - 5 0 0 , 5 0 0 ] ^ { 1 0 }$ , respectively.
We compare CobBO with TPE, BADS, CMA-ES and TuRBO, each with 100 initial points. Specifically, TuRBO is configured with 15 trust regions and a batch size 100. ATPE is excluded as it takes more than 24 hours per run to finish. The results are shown in Fig. 5 (upper middle), where CobBO quickly finds the best solution among the algorithms tested.
Rover trajectory planning (maximization): This problem (60 dimensions) is introduced in [62]. The objective is to find a collision-avoiding trajectory of a sequence consisting of 30 positions in a 2-D plane. We compare CobBO with TuRBO, TPE and CMA-ES, each with a budget of 20, 000 evaluations and 200 initial points. TuRBO is configured with 15 trust regions and a batch size of 100, as in [14]. ATPE, BADS and REMBO are excluded for this problem and the following ones, as they all take more than 24 hours per run. Fig. 5 (lower middle) shows that CobBO has a good performance.
The 200-dimensional Levy and Ackley functions (minimization): We minimize the Levy and Ackley functions over $[ - 5 , \mathsf { \bar { 1 0 } } ] ^ { 2 0 0 }$ with 500 initial points. TuRBO is configured with 15 trust regions and a batch size of 100. These two problems are challenging and have no redundant dimensions. For Levy, in Fig. 5 (upper right), CobBO reaches 100.0 within 2, 000 trials, while CMA-ES and TuRBO obtain 200.0 after 8, 000 trials. TPE cannot find a comparable solution within 10, 000 trials in this case. For Ackley, in Fig. 5 (lower right), CobBO reaches the best solution among all of the algorithms tested.
Regarding running times, for Ackley, CobBO runs for 12.8 CPU hours and TuRBO-1 run for more than 80 CPU hours or $9 . 6 \ : G P U$ hours. Most other methods either cannot make any progress or find far worse solutions.
# 5 Conclusion
CobBO is a variant of coordinate ascent tailored for Bayesian optimization with a stopping rule to switch coordinate subspaces. The sampling policy of subspaces is proven to have tight regret bounds with respect to the best subspace in hindsight. Combining this projection on random subspaces with a two-stage kernels for function value interpolation and GP regression, we provide a practical Bayesian optimization method of affordable computational costs in high dimensions. Empirically, CobBO consistently finds comparable or better solutions with reduced trial complexity in comparison with the state-of-the-art methods across a variety of benchmarks.
348 [1] Luigi Acerbi and Wei Ji Ma. Practical bayesian optimization for model fitting with bayesian 349 adaptive direct search. In Proceedings of the 31st International Conference on Neural Infor 350 mation Processing Systems, NIPS’17, page 1834–1844, Red Hook, NY, USA, 2017. Curran 351 Associates Inc. 352 [2] Sanjeev Arora, Elad Hazan, and Satyen Kale. The multiplicative weights update method: a 353 meta-algorithm and applications. Theory of Computing, 8(6):121–164, 2012. 354 [3] Peter Auer. Using confidence bounds for exploitation-exploration trade-offs. J. Mach. Learn. 355 Res., 3(null):397–422, Mar. 2003. 356 [4] James S. Bergstra, Rémi Bardenet, Yoshua Bengio, and Balázs Kégl. Algorithms for hyper 357 parameter optimization. In J. Shawe-Taylor, R. S. Zemel, P. L. Bartlett, F. Pereira, and K. Q. 358 Weinberger, editors, Advances in Neural Information Processing Systems 24, pages 2546–2554. 359 Curran Associates, Inc., 2011. 360 [5] Mickaël Binois, David Ginsbourger, and Olivier Roustant. On the choice of the low-dimensional 361 domain for global optimization via random embeddings. Journal of Global Optimization, 362 76(1):69–90, January 2020. 363 [6] Martin D. Buhmann. Radial Basis Functions: Theory and Implementations. Cambridge 364 Monographs on Applied and Computational Mathematics. Cambridge University Press, 2003. 365 [7] Martin D. Buhmann and M. D. Buhmann. Radial Basis Functions. Cambridge University Press, 366 USA, 2003. 367 [8] Adam D. Bull. Convergence rates of efficient global optimization algorithms. Journal of 368 Machine Learning Research, 12(88):2879–2904, 2011. 369 [9] Roberto Calandra, André Seyfarth, Jan Peters, and Marc Peter Deisenroth. Bayesian optimiza 370 tion for learning gaits under uncertainty. Annals of Mathematics and Artificial Intelligence, 371 76(1):5–23, 2016. 372 [10] Nicolo Cesa-Bianchi and Gábor Lugosi. Prediction, learning, and games. Cambridge university 373 press, 2006. 374 [11] Josip Djolonga, Andreas Krause, and Volkan Cevher. High-dimensional gaussian process 375 bandits. In C. J. C. Burges, L. Bottou, M. Welling, Z. Ghahramani, and K. Q. Weinberger, 376 editors, Advances in Neural Information Processing Systems 26, pages 1025–1033. Curran 377 Associates, Inc., 2013. 378 [12] ElectricBrain. Blog: Learning to optimize, 2018. 379 [13] David Eriksson, Kun Dong, Eric Lee, David Bindel, and Andrew G Wilson. Scaling gaussian 380 process regression with derivatives. In S. Bengio, H. Wallach, H. Larochelle, K. Grauman, N. 381 Cesa-Bianchi, and R. Garnett, editors, Advances in Neural Information Processing Systems 31, 382 pages 6867–6877. Curran Associates, Inc., 2018. 383 [14] David Eriksson, Michael Pearce, Jacob Gardner, Ryan D Turner, and Matthias Poloczek. 384 Scalable global optimization via local bayesian optimization. In Advances in Neural Information 385 Processing Systems 32, pages 5496–5507. Curran Associates, Inc., 2019. 386 [15] Peter I. Frazier. A tutorial on bayesian optimization, 2018. 387 [16] Peter I. Frazier, Warren B. Powell, and Savas Dayanik. A knowledge-gradient policy for 388 sequential information collection. SIAM J. Control Optim., 47(5):2410–2439, Sept. 2008. 389 [17] Elad Gilboa, Yunus Saatçi, and John P. Cunningham. Scaling multidimensional Gaussian 390 processes using projected additive approximations. In Proceedings of the 30th International 391 Conference on International Conference on Machine Learning - Volume 28, ICML’13, page 392 I–454–I–461. JMLR.org, 2013. 393 [18] Daniel Golovin, Benjamin Solnik, Subhodeep Moitra, Greg Kochanski, John Karro, and D 394 Sculley. Google vizier: A service for black-box optimization. In Proceedings of the 23rd ACM 395 SIGKDD international conference on knowledge discovery and data mining, pages 1487–1495, 396 2017. 397 [19] Rafael Gómez-Bombarelli, Jennifer N Wei, David Duvenaud, José Miguel Hernández-Lobato, 398 Benjamín Sánchez-Lengeling, Dennis Sheberla, Jorge Aguilera-Iparraguirre, Timothy D Hirzel, 399 Ryan P Adams, and Alán Aspuru-Guzik. Automatic chemical design using a data-driven 400 continuous representation of molecules. ACS central science, 4(2):268–276, 2018. 401 [20] Javier Gonzalez, Zhenwen Dai, Philipp Hennig, and Neil Lawrence. Batch bayesian optimization 402 via local penalization. In Arthur Gretton and Christian C. Robert, editors, Proceedings of the 404 of Machine Learning Research, pages 648–657, Cadiz, Spain, 09–11 May 2016. PMLR. 405 [21] Luigi Grippo and Marco Sciandrone. On the convergence of the block nonlinear gauss-seidel 406 method under convex constraints. Operations Research Letters, 26(3):127–136, 2000. 407 [22] Nikolaus Hansen and Andreas Ostermeier. Completely derandomized self-adaptation in evolu 408 tion strategies. Evolutionary Computation, 9(2):159–195, June 2001. 409 [23] David Haussler, Jyrki Kivinen, and Manfred K Warmuth. Tight worst-case loss bounds for 410 predicting with expert advice. In European Conference on Computational Learning Theory, 411 pages 69–83. Springer, 1995. 412 [24] Philipp Hennig and Christian J. Schuler. Entropy search for information-efficient global 413 optimization. J. Mach. Learn. Res., 13(1):1809–1837, June 2012. 414 [25] José Miguel Henrández-Lobato, Matthew W. Hoffman, and Zoubin Ghahramani. Predictive 415 entropy search for efficient global optimization of black-box functions. In Proceedings of the 416 27th International Conference on Neural Information Processing Systems - Volume 1, NIPS’14, 417 page 918–926, Cambridge, MA, USA, 2014. MIT Press. 418 [26] IDW. https://en.wikipedia.org/wiki/Inverse_distance_weighting. 419 [27] Donald R. Jones, Matthias Schonlau, and William J. Welch. Efficient global optimization of 420 expensive black-box functions. Journal of Global optimization, 13(4):455–492, 1998. 421 [28] Kirthevasan Kandasamy, Jeff Schneider, and Barnabás Póczos. High dimensional bayesian 422 optimization and bandits via additive models. In Proceedings of the 32nd International Confer 423 ence on International Conference on Machine Learning - Volume 37, ICML’15, page 295–304. 424 JMLR.org, 2015. 425 [29] Johannes Kirschner, Mojmir Mutny, Nicole Hiller, Rasmus Ischebeck, and Andreas Krause. 426 Adaptive and safe Bayesian optimization in high dimensions via one-dimensional subspaces. In 427 Kamalika Chaudhuri and Ruslan Salakhutdinov, editors, Proceedings of the 36th International 428 Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, 429 pages 3429–3438, Long Beach, California, USA, 09–15 Jun 2019. PMLR. 430 [30] H. J. Kushner. A new method of locating the maximum point of an arbitrary multipeak curve in 431 the presence of noise. Journal of Basic Engineering, 86(1):97–106, mar 1964. 432 [31] Rémi Lam, Matthias Poloczek, Peter Frazier, and Karen E Willcox. Advances in bayesian 433 optimization with applications in aerospace engineering. In 2018 AIAA Non-Deterministic 434 Approaches Conference, page 1656, 2018. 435 [32] Ben Letham, Roberto Calandra, Akshara Rai, and Eytan Bakshy. Re-examining linear embed 436 dings for high-dimensional bayesian optimization. Advances in Neural Information Processing 437 Systems, 33, 2020. 438 [33] Ben Letham, Roberto Calandra, Akshara Rai, and Eytan Bakshy. Re-examining linear embed 439 dings for high-dimensional bayesian optimization. In H. Larochelle, M. Ranzato, R. Hadsell, 440 M. F. Balcan, and H. Lin, editors, Advances in Neural Information Processing Systems, vol 441 ume 33, pages 1546–1558. Curran Associates, Inc., 2020. 442 [34] Benjamin Letham, Brian Karrer, Guilherme Ottoni, Eytan Bakshy, et al. Constrained bayesian 443 optimization with noisy experiments. Bayesian Analysis, 14(2):495–519, 2019. 444 [35] Cheng Li, Sunil Gupta, Santu Rana, Vu Nguyen, Svetha Venkatesh, and Alistair Shilton. 445 High dimensional bayesian optimization using dropout. In Proceedings of the Twenty-Sixth 446 International Joint Conference on Artificial Intelligence, IJCAI-17, pages 2096–2102, 2017. 447 [36] Chun-Liang Li, Kirthevasan Kandasamy, Barnabas Poczos, and Jeff Schneider. High dimen 448 sional bayesian optimization via restricted projection pursuit models. In Arthur Gretton and 449 Christian C. Robert, editors, Proceedings of the 19th International Conference on Artificial 450 Intelligence and Statistics, volume 51 of Proceedings of Machine Learning Research, pages 451 884–892, Cadiz, Spain, 09–11 May 2016. PMLR. 452 [37] Daniel J Lizotte, Tao Wang, Michael H Bowling, and Dale Schuurmans. Automatic gait 453 optimization with gaussian process regression. In IJCAI, volume 7, pages 944–949, 2007. 454 [38] LunarLander v2. https://gym.openai.com/envs/LunarLander-v2/. 455 [39] Horia Mania, Aurelia Guy, and Benjamin Recht. Simple random search of static linear policies 456 is competitive for reinforcement learning. In S. Bengio, H. Wallach, H. Larochelle, K. Grauman, 457 N. Cesa-Bianchi, and R. Garnett, editors, Advances in Neural Information Processing Systems 458 31, pages 1800–1809. Curran Associates, Inc., 2018. 459 [40] Matern kernel. https://scikit-learn.org/stable/modules/generated/sklearn. 460 gaussian_process.kernels.Matern.html. 461 [41] Mark McLeod, Michael A. Osborne, and Stephen J. Roberts. Optimization, fast and slow: 462 Optimally switching between local and bayesian optimization. In ICML, 2018. 463 [42] J. Mockus. On bayesian methods for seeking the extremum. In G. I. Marchuk, editor, ˇ Optimiza 464 tion Techniques IFIP Technical Conference Novosibirsk, July 1–7, 1974, pages 400–404, Berlin, 465 Heidelberg, 1975. Springer Berlin Heidelberg. 466 [43] Riccardo Moriconi, K. S. Sesh Kumar, and Marc Peter Deisenroth. High-dimensional bayesian 467 optimization with projections using quantile gaussian processes. Optimization Letters, 14:51–64, 468 2020. 69 [44] Alexander Munteanu, Amin Nayebi, and Matthias Poloczek. A framework for Bayesian 470 optimization in embedded subspaces. In Kamalika Chaudhuri and Ruslan Salakhutdinov, 471 editors, Proceedings of the 36th International Conference on Machine Learning, volume 97 of 472 Proceedings of Machine Learning Research, pages 4752–4761, Long Beach, California, USA, 473 09–15 Jun 2019. PMLR. 74 [45] Mojmir Mutny and Andreas Krause. Efficient high dimensional bayesian optimization with 475 additivity and quadrature fourier features. In S. Bengio, H. Wallach, H. Larochelle, K. Grauman, 476 N. Cesa-Bianchi, and R. Garnett, editors, Advances in Neural Information Processing Systems 77 31, pages 9005–9016. Curran Associates, Inc., 2018. 78 [46] Julie Nutini, Mark Schmidt, Issam H. Laradji, Michael Friedlander, and Hoyt Koepke. Coordi 479 nate descent converges faster with the gauss-southwell rule than random selection. ICML’15: 480 Proceedings of the 32nd International Conference on International Conference on Machine 481 Learning, 37, July 2015. 82 [47] ChangYong Oh, Efstratios Gavves, and Max Welling. BOCK $:$ Bayesian optimization with 483 cylindrical kernels. In Jennifer Dy and Andreas Krause, editors, Proceedings of the 35th 484 International Conference on Machine Learning, volume 80 of Proceedings of Machine Learning 485 Research, pages 3868–3877, Stockholm, Sweden, 10–15 Jul 2018. PMLR. 486 [48] Rafael Oliveira, Fernando Rocha, Lionel Ott, Vitor Guizilini, Fabio Ramos, and Valdir Jr. 487 Learning to race through coordinate descent bayesian optimisation. In IEEE International 488 Conference on Robotics and Automation (ICRA), February 2018. 489 [49] M.J.D. Powell. On Search Directions for Minimization Algorithms. AERE-TP. AERE, Theoret 490 ical Physics Division, 1972. 491 [50] Radial basis function. https://docs.scipy.org/doc/scipy/reference/generated/ 492 scipy.interpolate.Rbf.html. 493 [51] Ali Rahimi and Benjamin Recht. Random features for large-scale kernel machines. In J. C. Platt, 494 D. Koller, Y. Singer, and S. T. Roweis, editors, Advances in Neural Information Processing 495 Systems 20, pages 1177–1184. Curran Associates, Inc., 2008. 96 [52] Akshara Rai, Rika Antonova, Seungmoon Song, William Martin, Hartmut Geyer, and Christo 497 pher Atkeson. Bayesian optimization using domain knowledge on the atrias biped. In 2018 498 IEEE International Conference on Robotics and Automation (ICRA), pages 1771–1778. IEEE, 499 2018. 500 [53] Warren Scott, Peter Frazier, and Warren Powell. The correlated knowledge gradient for 501 simulation optimization of continuous parameters using gaussian process regression. SIAM 502 Journal on Optimization, 21(3):996–1026, 2011. 503 [54] Niranjan Srinivas, Andreas Krause, Sham Kakade, and Matthias Seeger. Gaussian process 504 optimization in the bandit setting: No regret and experimental design. In Proceedings of the 505 27th International Conference on International Conference on Machine Learning, ICML’10, 506 page 1015–1022, Madison, WI, USA, 2010. 507 [55] N. Srinivas, A. Krause, S. M. Kakade, and M. W. Seeger. Information-theoretic regret bounds 508 for gaussian process optimization in the bandit setting. IEEE Transactions on Information 509 Theory, 58(5):3250–3265, 2012. 10 [56] Rainer Storn and Kenneth Price. Differential evolution–a simple and efficient heuristic for 511 global optimization over continuous spaces. Journal of global optimization, 11(4):341–359, 12 1997. 13 [57] Sonja Surjanovic and Derek Bingham. Optimization test problems, 2013. 14 [58] Hemant Tyagi and Volkan Cevher. Learning non-parametric basis independent models from 515 point queries via low-rank methods. Applied and Computational Harmonic Analysis, 37(3):389 516 – 412, 2014. 517 [59] Emmanuel Vazquez and Julien Bect. Convergence properties of the expected improvement 518 algorithm with fixed mean and covariance functions. Journal of Statistical Planning and 519 Inference, 140(11):3088 – 3095, 2010. 520 [60] Linnan Wang, Rodrigo Fonseca, and Yuandong Tian. Learning search space partition for 521 black-box optimization using monte carlo tree search. ArXiv, abs/2007.00708, 2020. 522 [61] Zi Wang, Clement Gehring, Pushmeet Kohli, and Stefanie Jegelka. Batched large-scale bayesian 523 optimization in high-dimensional spaces. In International Conference on Artificial Intelligence 524 and Statistics (AISTATS), 2018. 525 [62] Zi Wang, Clement Gehring, Pushmeet Kohli, and Stefanie Jegelka. Batched large-scale bayesian 526 optimization in high-dimensional spaces. In International Conference on Artificial Intelligence 527 and Statistics, pages 745–754, 2018. 528 [63] Ziyu Wang, Frank Hutter, Masrour Zoghi, David Matheson, and Nando De Freitas. Bayesian 529 optimization in a billion dimensions via random embeddings. J. Artif. Int. Res., 55(1):361–387, 530 Jan. 2016. 531 [64] Zi Wang and Stefanie Jegelka. Max-value entropy search for efficient Bayesian optimization. In 532 Doina Precup and Yee Whye Teh, editors, Proceedings of the 34th International Conference on 533 Machine Learning, volume 70 of Proceedings of Machine Learning Research, pages 3627–3635, 534 International Convention Centre, Sydney, Australia, 06–11 Aug 2017. PMLR. 535 [65] Zi Wang, Chengtao Li, Stefanie Jegelka, and Pushmeet Kohli. Batched high-dimensional 536 bayesian optimization via structural kernel learning. In Proceedings of the 34th International 537 Conference on Machine Learning - Volume 70, ICML’17, page 3656–3664. JMLR.org, 2017. 538 [66] Ziyu Wang, Masrour Zoghi, Frank Hutter, David Matheson, and Nando De Freitas. Bayesian 539 optimization in high dimensions via random embeddings. In Proceedings of the Twenty-Third 540 International Joint Conference on Artificial Intelligence, IJCAI ’13, page 1778–1784. AAAI 541 Press, 2013. 542 [67] J. Warga. Minimizing certain convex functions. Journal of the Society for Industrial and 543 Applied Mathematics, 11(3):588–593, 1963. 544 [68] Stephen J. Wright. Coordinate descent algorithms. Mathematical Programming: Series A and 545 B, June 2015. 546 [69] Jian Wu and Peter I. Frazier. The parallel knowledge gradient method for batch bayesian 547 optimization. In Proceedings of the 30th International Conference on Neural Information 548 Processing Systems, NIPS’16, page 3134–3142, Red Hook, NY, USA, 2016. Curran Associates 549 Inc. 550 [70] Miao Zhang, Huiqi Li, and Steven Su. High dimensional bayesian optimization via supervised 551 dimension reduction. In Proceedings of the Twenty-Eighth International Joint Conference on 552 Artificial Intelligence, IJCAI-19, pages 4292–4298. International Joint Conferences on Artificial 553 Intelligence Organization, 7 2019. 554 [71] Yichi Zhang, Daniel W Apley, and Wei Chen. Bayesian optimization for materials design with 555 mixed quantitative and qualitative variables. Scientific reports, 10(1):1–13, 2020.
# 556 Broader Impact
As stated in [32], Bayesian optimization is a powerful optimization technique used in a wide range of industries and applications, such as robotics [37, 9, 52], internet tech companies [18, 34], designing novel molecules for pharmaceutics [19], material design for increasing efficiency of solar cells [71], and aerospace engineering [31]. All of these settings have high-dimensional optimization problems, and advances in BO will reflect on improved capabilities on these fields as well. We have fully opensourced our code for CobBO using the MIT license to be available for researchers and practitioners in these fields, and many others. The ability to optimize a larger number of parameters than has previously been possible will bring further improvements to and further accelerate work in these areas.
# Checklist
67 The checklist follows the references. Please read the checklist guidelines carefully for information on 68 how to answer these questions. For each question, change the default [TODO] to [Yes] , [No] , or
[N/A] . You are strongly encouraged to include a justification to your answer, either by referencing 0 the appropriate section of your paper or providing a brief inline description. For example:
• Did you include the license to the code and datasets? [Yes] See Section ??. • Did you include the license to the code and datasets? [No] The code and the data are proprietary. • Did you include the license to the code and datasets? [N/A]
Please do not modify the questions and only use the provided macros for your answers. Note that the Checklist section does not count towards the page limit. In your paper, please delete this instructions block and only keep the Checklist section heading above along with the questions/answers below.
1. For all authors...
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] See Section 3. (b) Did you describe the limitations of your work? [No] (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Broader Impact. (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? [Yes] See Section 3.3. (b) Did you include complete proofs of all theoretical results? [Yes] See the Appendix 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] In the supplemental material. (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Table 2 in the appendix, which contains the default hyperparameters. (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] See Fig.5 and Fig.8-10. (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See page 9, line 324.
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? [N/A] (b) Did you mention the license of the assets? [Yes] MIT license; see the appendix. (c) Did you include any new assets either in the supplemental material or as a URL? [No] (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [Yes] See Section 4.2. (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A] It does not contain personal identifiable information or offensive content.
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]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354# ON THE WEAKNESSES OF REINFORCEMENT LEARNING FOR NEURAL MACHINE TRANSLATION
Leshem Choshen1, Lior $\mathbf { F o x } ^ { 2 }$ , Zohar Aizenbud1, Omri Abend1,3
1 School of Computer Science and Engineering, 2 The Edmond and Lily Safra Center for Brain Sciences 3 Department of Cognitive Sciences The Hebrew University of Jerusalem first.last@mail.huji.ac.il, oabend@cs.huji.ac.il
# ABSTRACT
Reinforcement learning (RL) is frequently used to increase performance in text generation tasks, including machine translation (MT), notably through the use of Minimum Risk Training (MRT) and Generative Adversarial Networks (GAN). However, little is known about what and how these methods learn in the context of MT. We prove that one of the most common RL methods for MT does not optimize the expected reward, as well as show that other methods take an infeasibly long time to converge. In fact, our results suggest that RL practices in MT are likely to improve performance only where the pre-trained parameters are already close to yielding the correct translation. Our findings further suggest that observed gains may be due to effects unrelated to the training signal, concretely, changes in the shape of the distribution curve.
# 1 INTRODUCTION
Reinforcement learning (RL) is an appealing path for advancement in Machine Translation (MT), as it allows training systems to optimize non-differentiable score functions, common in MT evaluation, as well as tackling the “exposure bias” (Ranzato et al., 2015) in standard training, namely that the model is not exposed during training to incorrectly generated tokens, and is thus unlikely to recover from generating such tokens at test time. These motivations have led to much interest in RL for text generation in general and MT in particular (see $\ S 2$ ). Various policy gradient methods have been used, notably REINFORCE (Williams, 1992) and variants thereof (e.g., Ranzato et al., 2015; Edunov et al., 2018) and Minimum Risk Training (MRT; e.g., Och, 2003; Shen et al., 2016). Another popular use of RL is for training GANs (Yang et al., 2018; Tevet et al., 2018). Nevertheless, despite increasing interest and strong results, little is known about what accounts for these performance gains, and the training dynamics involved.
We present the following contributions. First, our theoretical analysis shows that commonly used approximation methods are theoretically ill-founded, and may converge to parameter values that do not minimize the risk, nor are local minima thereof (§2.2).
Second, using both naturalistic experiments and carefully constructed simulations, we show that performance gains observed in the literature likely stem not from making target tokens the most probable, but from unrelated effects, such as increasing the peakiness of the output distribution (i.e., the probability mass of the most probable tokens). We do so by comparing a setting where the reward is informative, vs. one where it is constant. In $\ S 4$ we discuss this peakiness effect (PKE).
Third, we show that promoting the target token to be the mode is likely to take a prohibitively long time. The only case we find, where improvements are likely, is where the target token is among the first 2-3 most probable tokens according to the pretrained model. These findings suggest that REINFORCE (§5) and CMRT $( \ S 6 )$ are likely to improve over the pre-trained model only under the best possible conditions, i.e., where the pre-trained model is “nearly” correct.
We conclude by discussing other RL practices in MT which should be avoided for practical and theoretical reasons, and briefly discuss alternative RL approaches that will allow RL to tackle a larger class of errors in pre-trained models (§7).
# 2 RL IN MACHINE TRANSLATION
An MT system generates tokens $y = ( y _ { 1 } , . . . , y _ { n } )$ from a vocabulary $V$ one token at a time. The probability of generating $y _ { i }$ given preceding tokens $y _ { < i }$ is given by $P _ { \theta } ( \cdot | x , y _ { < i } )$ , where $x$ is the source sentence and $\theta$ are the model parameters. For each generated token $y _ { i }$ , we denote with $r ( y _ { i } ; y _ { < i } , x , y ^ { ( r e f ) } )$ the score, or reward, for generating $y _ { i }$ given $y _ { < i } , x$ , and the reference sentence $y ^ { ( r e f ) }$ . For brevity, we omit parameters where they are fixed within context. For simplicity, we assume $r$ does not depend on following tokens $y _ { > i }$ .
We also assume there is exactly one valid target token, as de facto, training is done against a single reference (Schulz et al., 2018). In practice, either a token-level reward is approximated using MonteCarlo methods (e.g., Yang et al., 2018), or a sentence-level (sparse) reward is given at the end of the episode (sentence). The latter is equivalent to a uniform token-level reward.
$r$ is often the negative log-likelihood, or a standard MT metric, e.g., BLEU (Papineni et al., 2002). RL’s goal is to maximize the expected episode reward (denoted with $R$ ); i.e., to find
$$\theta ^ { * } = \arg \operatorname* { m a x } _ { \theta } \ R ( \theta ) = \arg \operatorname* { m a x } _ { \theta } \ \mathbb { E } _ { y \sim P _ { \theta } } [ r ( y ) ]$$
# 2.1 REINFORCE
For a given source sentence, and past predictions $y _ { < i }$ , REINFORCE (Williams, 1992) samples $k$ tokens $k$ is a hyperparameter) $S = \bar { ( { y ^ { ( 1 ) } } , . . . , y ^ { ( k ) } ) }$ from $P _ { \theta }$ and updates $\theta$ according to this rule:
$$\Delta \theta \propto \frac { 1 } { k } \sum _ { i = 1 } ^ { k } r ( y _ { i } ) \nabla \log ( P _ { \theta } ( y _ { i } ) )$$
The right-hand side of equation 2 is an unbiased estimator of the gradient of the objective function, i.e., $\mathbb { E } \left[ \Delta \theta \right] \propto \nabla _ { \theta } R \left( \theta \right)$ . Therefore, REINFORCE is performing a form of stochastic gradient ascent on $R$ , and has similar formal guarantees. From here follows that if $R$ is constant with respect to $\theta$ , then the expected $\Delta \theta$ prescribed by REINFORCE is zero. We note that $r$ may be shifted by a constant term (called a “baseline”), without affecting the optimal value for $\theta$ .
REINFORCE is used in MT, text generation, and image-to-text tasks (Liu et al., 2016; Wu et al., 2018; Rennie et al., 2017; Shetty et al., 2017; Hendricks et al., 2016) – in isolation, or as a part of training (Ranzato et al., 2015). Lately, an especially prominent use for REINFORCE is adversarial training with discrete data, where another network predicts the reward (GAN). For some recent work on RL for NMT, see (Zhang et al., 2016; Li et al., 2017; Wu et al., 2017; Yu et al., 2017; Yang et al., 2018).
# 2.2 MINIMUM RISK TRAINING
The term Minimum Risk Training (MRT) is used ambiguously in MT to refer either to the application of REINFORCE to minimizing the risk (equivalently, to maximizing the expected reward, the negative loss), or more commonly to a somewhat different estimation method, which we term Contrastive MRT (CMRT) and turn now to analyzing. CMRT was proposed by Och (2003), adapted to NMT by Shen et al. (2016), and often used since (Ayana et al., 2016; Neubig, 2016; Shen et al., 2017; Edunov et al., 2018; Makarov & Clematide, 2018; Neubig et al., 2018).
The method works as follows: at each iteration, sample $k$ tokens $S = \{ y _ { 1 } , \dots , y _ { k } \}$ from $P _ { \theta }$ , and update $\theta$ according to the gradient of
$$\widetilde { R } ( \theta , S ) = \sum _ { i = 1 } ^ { k } Q _ { \theta , S } ( y _ { i } ) r ( y _ { i } ) = \mathbb { E } _ { y \sim Q } \left[ r ( y ) \right]$$
where
$$Q _ { \theta , S } ( y _ { i } ) = \frac { P ( y _ { i } ) ^ { \alpha } } { \sum _ { y _ { j } \in S } P ( y _ { j } ) ^ { \alpha } }$$
Commonly (but not universally), deduplication is performed, so $\widetilde { R }$ sums over a set of unique values (Sennrich et al., 2017). This changes little in our empirical results and theoretical analysis.
Despite the resemblance in definitions of $R$ (equation 1) and $\widetilde { R }$ (indeed, $\widetilde { R }$ is sometimes presented as an approximation of $R$ ), they differ in two important aspects. First, $Q$ ’s support is $S$ , so increasing
$Q ( y _ { i } )$ for some $y _ { i }$ necessarily comes at the expense of $Q ( y )$ for some $y \in S$ . In contrast, increasing $P ( y _ { i } )$ , as in REINFORCE, may come at the expense of $P ( y )$ for any $y \in V$ . Second, $\alpha$ is a smoothness parameter: the closer $\alpha$ is to 0, the closer $Q$ is to be uniform.
We show in Appendix A.1 that despite its name, CMRT does not optimize $R$ , nor does it optimize $\mathbb { E } [ { \widetilde { R } } ]$ . That is, it may well converge to values that are not local maxima of $R$ , making it theoretically ill-founded.1 However, given CMRT popularity, the strong results it yielded and the absence of theory for explaining it, we discuss it here. Given a sample $S$ , the gradient of $\widetilde { R }$ is given by
$$\nabla \widetilde { R } = \alpha \sum _ { i = 1 } ^ { k } \Big ( Q ( y _ { i } ) \cdot r ( y _ { i } ) \cdot \nabla \log P ( y _ { i } ) \Big ) - \mathbb { E } _ { Q } [ r ] \nabla \log Z ( S )$$
where $\begin{array} { r } { Z ( S ) = \sum _ { i } P ( y _ { i } ) ^ { \alpha } } \end{array}$ . See Appendix A.2.
Comparing Equations 2 and 3, the differences between REINFORCE and CMRT are reflected again. First, $\nabla \widetilde R$ has an additional term, proportional to $\nabla \log Z ( S )$ , which yields the contrastive effect. This contrast may improve the rate of convergence since it counters the decrease of probability mass for non-sampled tokens.
Second, given $S$ , the relative weighting of the gradients $\nabla \log P ( y _ { i } )$ is proportional to $r ( y _ { i } ) Q ( y _ { i } )$ , or equivalently to $r ( y _ { i } ) P ( y _ { i } ) ^ { \alpha }$ . CMRT with deduplication sums over distinct values in $S$ (equation 3), while REINFORCE sums over all values. This means that the relative weight of the unique value $y _ { i }$ is $\frac { r ( y _ { i } ) | \{ y _ { i } \in S \} | } { k }$ in REINFORCE. For $\alpha = 1$ the expected value of these relative weights is the same, and so for $\alpha < 1$ (as is commonly used), more weight is given to improbable tokens, which could also have a positive effect on the convergence rate.2 However, if $\alpha$ is too close to 0, $\nabla \widetilde R$ vanishes, as it is not affected by $\theta$ . This tradeoff explains the importance of tuning $\alpha$ reported in the literature. In $\ S 6$ we present simulations with CMRT, showing very similar trends as presented by REINFORCE.
# 3 MOTIVATING DISCUSSION
Implementing a stochastic gradient ascent, REINFORCE is guaranteed to converge to a stationary point of $R$ under broad conditions. However, not much is known about its convergence rate under the prevailing conditions in NMT.
We begin with a qualitative, motivating analysis of these questions. As work on language generation empirically showed, RNNs quickly learn to output very peaky distributions (Press et al., 2017). This tendency is advantageous for generating fluent sentences with high probability, but may also entail slower convergence rates when using RL to fine-tune the model, because RL methods used in text generation sample from the (pretrained) policy distribution, which means they mostly sample what the pretrained model deems to be likely. Since the pretrained model (or policy) is peaky, exploration of other potentially more rewarding tokens will be limited, hampering convergence.
Intuitively, REINFORCE increases the probabilities of successful (positively rewarding) observations, weighing updates by how rewarding they were. When sampling a handful of tokens in each context (source sentence $x$ and generated prefix $y _ { < i , }$ ), and where the number of epochs is not large, it is unlikely that more than a few unique tokens will be sampled from $P _ { \theta } ( \cdot | x , y _ { < i } )$ . (In practice, $k$ is typically between 1 and 20, and the number of epochs between 1 and 100.) It is thus unlikely that anything but the initially most probable candidates will be observed. Consequently, REINFORCE initially raises their probabilities, even if more rewarding tokens can be found down the list.
We thus hypothesize the peakiness of the distribution, i.e., the probability mass allocated to the most probable tokens, will increase, at least in the first phase. We call this the peakiness-effect (PKE), and show it occurs both in simulations (§4.1) and in full-scale NMT experiments (§4.2).
With more iterations, the most-rewarding tokens will be eventually sampled, and gradually gain probability mass. This discussion suggests that training will be extremely sample-inefficient. We assess the rate of convergence empirically in $\ S 5$ , finding this to be indeed the case.
 Figure 1: A histogram of the update size (x-axis) to the total predicted probability of the 10 most probable tokens (left) or the most probable token (right) in the Constant Reward setting. An update is overwhelmingly more probable to increase this probability than to decrease it.
# 4 THE PEAKINESS EFFECT
We turn to demonstrate that the initially most probable tokens will initially gain probability mass, even if they are not the most rewarding, yielding a PKE.
Caccia et al. (2018) recently observed in the context of language modeling using GANs that performance gains similar to those GAN yield can be achieved by decreasing the temperature for the prediction softmax (i.e., making it peakier). However, they proposed no causes for this effect. Our findings propose an underlying mechanism leading to this trend. We return to this point in $^ { \ S 7 }$ . Furthermore, given their findings, it is reasonable to assume that our results are relevant for RL use in other generation tasks, whose output space too is discrete, high-dimensional and concentrated.
# 4.1 CONTROLLED SIMULATIONS
We experiment with a 1-layer softmax model, that predicts a single token $i \in V$ with probability $\frac { e ^ { \theta _ { i } } } { \sum _ { j } e ^ { \theta _ { j } } }$ . $\theta = \{ \theta _ { j } \} _ { j \in V }$ are the model’s parameters. This model simulates the top of any MT decoder that ends with a softmax layer, as essentially all NMT decoders do. To make experiments realistic, we use similar parameters as those reported in the influential Transformer NMT system (Vaswani et al., 2017). Specifically, the size of $V$ (distinct BPE tokens) is 30,715, and the initial values for $\theta$ were sampled from 1,000 sets of logits taken from decoding the standard newstest2013 development set, using a pretrained Transformer model. The model was pretrained on WMT2015 training data (Bojar et al., 2015). Hyperparameters are reported in Appendix A.3. We define one of the tokens in $V$ to be the target token and denote it with $y _ { b e s t }$ . We assign deterministic token reward, this makes learning easier than when relying on approximations and our predictions optimistic. We experiment with two reward functions:
1. Simulated Reward: $r ( y ) = 2$ for $y = y _ { b e s t }$ , $r ( y ) = 1$ if $y$ is one of the 10 initially highest scoring tokens, and $r ( y ) = 0$ otherwise. This simulates a condition where the pretrained model is of decent but sub-optimal quality. $r$ here is at the scale of popular rewards used in MT, such as GAN-based rewards or BLEU (which are between 0 and 1). 2. Constant Reward: $r$ is constantly equal to 1, for all tokens. This setting is aimed to confirm that PKE is not a result of the signal carried by the reward.
Experiments with the first setting were run 100 times, each time for 50K steps, updating $\theta$ after each step. With the second setting, it is sufficient to take a single step at a time, as the expected update after each step is zero, and so any $\mathrm { P K E }$ seen in a single step is only accentuated in the next. It is, therefore, more telling to run more repetitions rather than more steps per initialization. We, therefore, sample 10,000 pretrained distributions, and perform a single REINFORCE step.
As RL training lasts about 30 epochs before stopping, samples about $1 0 0 \mathrm { K }$ tokens per epoch, and as the network already predicts $y _ { b e s t }$ in about two thirds of the contexts,3 we estimate the number of steps used in practice to be in the order of magnitude of 1M. For visual clarity, we present figures for 50K-100K steps. However, full experiments (with 1M steps) exhibit similar trends: where REINFORCE was not close to converging after 50K steps, the same was true after 1M steps.
We evaluate the peakiness of a distribution in terms of the probability of the most probable token (the mode), the total probability of the ten most probable tokens, and the entropy of the distribution (lower entropy indicates more peakiness).
 Figure 2: Token probabilities through REINFORCE training, in the controlled simulations in the Simulated Reward setting. The left/center/right figures correspond to simulations where the target token $( y _ { b e s t } )$ was initially the second/third/fourth most probable token. The green line corresponds to the target token, yellow lines to medium-reward tokens and red lines to no-reward tokens.
Results. The distributions become peakier in terms of all three measures: on average, the mode’s probability and the 10 most probable tokens increases, and the entropy decreases. Figure 1a presents the histogram of the update size, the difference in the probability of the $1 0 \mathrm { m o s t }$ probable tokens in the Constant Reward setting, after a single step. Figure 1b depicts similar statistics for the mode. The average entropy in the pretrained model is 2.9 is reduced to 2.85 after one REINFORCE step.
Simulated Reward setting shows similar trends. For example, entropy decreases from 3 to about 0.001 in 100K steps. This extreme decrease suggests it is effectively a deterministic policy. $\mathrm { P K E }$ is achieved in a few hundred steps, usually before other effects become prominent (see Figure 2), and is stronger than for Constant Reward.
# 4.2 NMT EXPERIMENTS
We turn to analyzing a real-world application of REINFORCE to NMT. Important differences between this and the previous simulations are: (1) it is rare in NMT for REINFORCE to sample from the same conditional distribution more than a handful of times, given the number of source sentences $x$ and sentence prefixes $y _ { < i }$ (contexts); and (2) in NMT $P _ { \theta } ( \cdot | x , y _ { < i } )$ shares parameters between contexts, which means that updating $P _ { \theta }$ for one context may influence $P _ { \theta }$ for another.
We follow the same pretraining as in $\ S 4 . 1$ . We then follow Yang et al. (2018) in defining the reward function based on the expected BLEU score. Expected BLEU is computed by sampling suffixes for the sentence, and averaging the BLEU score of the sampled sentences against the reference.
We use early stopping with a patience of 10 epochs, where each epoch consists of 5,000 sentences sampled from the WMT2015 (Bojar et al., 2015) German-English training data. We use $k = 1$ . We retuned the learning-rate, and positive baseline settings against the development set. Other hyper-parameters were an exact replication of the experiments reported in (Yang et al., 2018).
 Figure 3: The cumulative distribution of the probability of the most likely token in the NMT experiments. The green distribution corresponds to the pretrained model, and the blue corresponds to the reinforced model. The yaxis is the proportion of conditional probabilities with a mode of value $\leq x$ (the $\mathbf { X }$ -axis). Note that a lower cumulative percentage means a more peaked output distribution. A lower cumulative percentage means a more peaked output distribution.
Results. Results indicate an increase in the peakiness of the conditional distributions. Our results are based on a sample of 1,000 contexts from the pretrained model, and another (independent) sample from the reinforced model.
The modes of the conditional distributions tend to increase. Figure 3 presents the distribution of the modes’ probability in the reinforced conditional distributions compared with the pretrained model, showing a shift of probability mass towards higher probabilities for the mode, following RL. Another indication of the increased peakiness is the decrease in the average entropy of $P _ { \theta }$ , which was reduced from 3.45 in the pretrained model to an average of 2.82 following RL. This more modest reduction in entropy (compared to $\ S 4 . 1$ ) might also suggest that the procedure did not converge to the optimal value for $\theta$ , as then we would have expected the entropy to substantially drop if not to 0 (overfit), then to the average entropy of valid next tokens (given the source and a prefix of the sentence).
# 5 PERFORMANCE FOLLOWING REINFORCE
We now turn to assessing under what conditions it is likely that REINFORCE will lead to an improvement in the performance of an NMT system. As in the previous section, we use both controlled simulations and NMT experiments.
# 5.1 CONTROLLED SIMULATIONS
We use the same model and experimental setup described in Section 4.1, this time only exploring the Simulated Reward setting, as a Constant Reward is not expected to converge to any meaningful $\theta$ . Results are averaged over 100 conditional distributions sampled from the pretrained model.
Caution should be exercised when determining the learning rate (LR). Common LRs used in the NMT literature are of the scale of $1 0 ^ { - 4 }$ . However, in our simulations, no LR smaller than 0.1 yielded any improvement in $R$ . We thus set the LR to be 0.1. We note that in our simulations, a higher learning rate means faster convergence as our reward is noise-free: it is always highest for the best option. In practice, increasing the learning rate may deteriorate results, as it may cause the system to overfit to the sampled instances. Indeed, when increasing the learning rate in our NMT experiments (see below) by an order of magnitude, early stopping caused the RL procedure to stop without any parameter updates.
Figure 2 shows the change in $P _ { \theta }$ over the first 50K REINFORCE steps (probabilities are averaged over 100 repetitions), for a case where $y _ { b e s t }$ was initially the second, third and fourth most probable. Although these are the easiest settings, and despite the high learning rate, it fails to make $y _ { b e s t }$ the mode of the distribution within $1 0 0 \mathrm { K }$ steps, unless $y _ { b e s t }$ was initially the second most probable. In cases where $y _ { b e s t }$ is initially of a lower rank than four, it is hard to see any increase in its probability, even after 1M steps.
 Figure 4: Cumulative percentage of contexts where the pretrained model ranks $y _ { b e s t }$ in rank $_ x$ or below and where it does not rank $y _ { b e s t }$ first $( x = 0$ ). In about half the cases it is ranked fourth or below.
# 5.2 NMT EXPERIMENTS
We trained an NMT system, using the same procedure as in Section 4.2, and report BLEU scores over the news2014 test set. After training with an expected BLEU reward, we indeed see a minor improvement which is consistent between trials and pretrained models. While the pretrain BLEU score is 30.31, the reinforced one is 30.73.
Analyzing what words were influenced by the RL procedure, we begin by computing the cumulative probability of the target token $y _ { b e s t }$ to be ranked lower than a given rank according to the pretrained model. Results (Figure 4) show that in about half of the cases, $y _ { b e s t }$ is not among the top three choices of the pretrained model, and we thus expect it not to gain substantial probability following REINFORCE, according to our simulations.
We next turn to compare the ranks the reinforced model assigns to the target tokens, and their ranks according to the pretrained model. Figure 6 presents the difference in the probability that $y _ { b e s t }$ is ranked at a given rank following RL and the probability it is ranked there initially. Results indicate that indeed more target tokens are ranked first, and less second, but little consistent shift of probability mass occurs otherwise across the ten first ranks. It is possible that RL has managed to push $y _ { b e s t }$ in some cases between very low ranks $( < 1 , 0 0 0 )$ to medium-low ranks (between 10 and 1,000). However, token probabilities in these ranks are so low that it is unlikely to affect the system outputs in any way. This fits well with the results of our simulations that predicted that only the initially top-ranked tokens are likely to change.
In an attempt to explain the improved BLEU score following RL with PKE, we repeat the NMT experiment this time using a constant reward of 1. Our results present a nearly identical improvement in BLEU, achieving 30.72, and a similar pattern in the change of the target tokens’ ranks (see Appendix 8). Therefore, there is room to suspect that even in cases where RL yields an improvement in BLEU, it may partially result from reward-independent factors, such as PKE.4
 Figure 5: The probability of different tokens following CMRT, in the controlled simulations in the Simulated Reward setting. The left/right figures correspond to simulations where the target token $( y _ { b e s t } )$ was initially the second/third most probable token. The green line corresponds to the target token, yellow lines to medium-reward tokens and red lines to tokens with $r ( y ) = 0$ .
# 6 EXPERIMENTS WITH CONTRASTIVE MRT
In $\ S 2 . 2$ we showed that CMRT does not, in fact, maximize $R$ , and so does not enjoy the same theoretical guarantees as REINFORCE and similar policy gradient methods. However, being the RL procedure of choice in much recent work we repeat the simulations described in $\ S 4$ and $\ S 5$ , assessing CMRT’s performance in these conditions. We experiment with $\alpha = 0 . 0 0 5$ and $k = 2 0$ , common settings in the literature, and average over 100 trials.
Figure 5 shows how the distribution $P _ { \theta }$ changes over the course of 50K update steps to $\theta$ , where $y _ { b e s t }$ is taken to be the second and third initially most probable token (Simulated Reward setting). Results are similar in trends to those obtained with REINFORCE: MRT succeeds in pushing $y _ { b e s t }$ to be the highest ranked token if it was initially second, but struggles where it was initially ranked third or below. We only observe a small $\mathrm { P K E }$ in MRT. This is probably due to the contrastive effect, which means that tokens that were not sampled do not lose probability mass.
All graphs we present here allow sampling the same token more than once in each batch (i.e., $S$ is a sample with replacements). Simulations with deduplication show similar results.
 Figure 6: Difference between the ranks of $y _ { b e s t }$ in the reinforced and the pretrained model. Each column $_ x$ corresponds to the difference in the probability that $y _ { b e s t }$ is ranked in rank $x$ in the reinforced model, and the same probability in the pretrained model.
# 7 DISCUSSION
In this paper, we showed that the type of distributions used in NMT entail that promoting the target token to be the mode is likely to take a prohibitively long times for existing RL practices, except under the best conditions (where the pretrained model is “nearly” correct). This leads us to conclude that observed improvements from using RL for NMT are likely due either to fine-tuning the most probable tokens in the pretrained model (an effect which may be more easily achieved using reranking methods, and uses but little of the power of RL methods), or to effects unrelated to the signal carried by the reward, such as PKE. Another contribution of this paper is in showing that CMRT does not optimize the expected reward and is thus theoretically unmotivated.
A number of reasons lead us to believe that in our NMT experiments, improvements are not due to the reward function, but to artefacts such as PKE. First, reducing a constant baseline from $r$ , so as to make the expected reward zero, disallows learning. This is surprising, as REINFORCE, generally and in our simulations, converges faster where the reward is centered around zero, and so the fact that this procedure here disallows learning hints that other factors are in play. As PKE can be observed even where the reward is constant (if the expected reward is positive; see $\ S 4 . 1 \ r _ { \cdot }$ ), this suggests PKE may play a role here. Second, we observe more peakiness in the reinforced model and in such cases, we expect improvements in BLEU (Caccia et al., 2018). Third, we achieve similar results with a constant reward in our NMT experiments (§5.2). Fourth, our controlled simulations show that asymptotic convergence is not reached in any but the easiest conditions (§5.1).
Our analysis further suggests that gradient clipping, sometimes used in NMT (Zhang et al., 2016; Wieting et al., 2019), is expected to hinder convergence further. It should be avoided when using REINFORCE as it violates REINFORCE’s assumptions.
The per-token sampling as done in our experiments is more exploratory than beam search (Wu et al., 2018), reducing PKE. Furthermore, the latter does not sample from the behavior policy, but does not properly account for being off-policy in the parameter updates.
Adding the reference to the sample $S$ , which some implementations allow (Sennrich et al., 2017) may help reduce the problems of never sampling the target tokens. However, as Edunov et al. (2018) point out, this practice may lower results, as it may destabilize training by leading the model to improve over outputs it cannot generalize over, as they are very different from anything the model assigns a high probability to, at the cost of other outputs.
# 8 CONCLUSION
The standard MT scenario poses several uncommon challenges for RL. First, the action space in MT problems is a high-dimensional discrete space (generally in the size of the vocabulary of the target language or the product thereof for sentences). This contrasts with the more common scenario studied by contemporary RL methods, which focuses mostly on much smaller discrete action spaces (e.g., video games (Mnih et al., 2015; 2016)), or continuous action spaces of relatively low dimensions (e.g., simulation of robotic control tasks (Lillicrap et al., 2015)). Second, reward for MT is naturally very sparse – almost all possible sentences are “wrong” (hence, not rewarding) in a given context. Finally, it is common in MT to use RL for tuning a pretrained model. Using a pretrained model ameliorates the last problem. But then, these pretrained models are in general quite peaky, and because training is done on-policy – that is, actions are being sampled from the same model being optimized – exploration is inherently limited.
Here we argued that, taken together, these challenges result in significant weaknesses for current RL practices for NMT, that may ultimately prevent them from being truly useful. At least some of these challenges have been widely studied in the RL literature, with numerous techniques developed to address them, but were not yet adopted in NLP. We turn to discuss some of them.
Off-policy methods, in which observations are sampled from a different policy than the one being currently optimized, are prominent in RL (Watkins & Dayan, 1992; Sutton & Barto, 1998), and were also studied in the context of policy gradient methods (Degris et al., 2012; Silver et al., 2014). In principle, such methods allow learning from a more “exploratory” policy. Moreover, a key motivation for using $\alpha$ in CMRT is smoothing; off-policy sampling allows smoothing while keeping convergence guarantees.
In its basic form, exploration in REINFORCE relies on stochasticity in the action-selection (in MT, this is due to sampling). More sophisticated exploration methods have been extensively studied, for example using measures for the exploratory usefulness of states or actions (Fox et al., 2018), or relying on parameter-space noise rather than action-space noise (Plappert et al., 2017).
For MT, an additional challenge is that even effective exploration (sampling diverse sets of observations), may not be enough, since the state-action space is too large to be effectively covered, with almost all sentences being not rewarding. Recently, diversity-based and multi-goal methods for RL were proposed to tackle similar challenges (Andrychowicz et al., 2017; Ghosh et al., 2018; Eysenbach et al., 2019). We believe the adoption of such methods is a promising path forward for the application of RL in NLP.
# 9 ACKNOWLEDGMENTS
This work was supported by the Israel Science Foundation (grant no. 929/17) and by the HUJI Cyber Security Research Center in conjunction with the Israel National Cyber Bureau in the Prime Minister’s Office.
# REFERENCES
Marcin Andrychowicz, Filip Wolski, Alex Ray, Jonas Schneider, Rachel Fong, Peter Welinder, Bob McGrew, Josh Tobin, OpenAI Pieter Abbeel, and Wojciech Zaremba. Hindsight experience replay. In Advances in Neural Information Processing Systems, pp. 5048–5058, 2017.
Shiqi Shen Ayana, Zhiyuan Liu, and Maosong Sun. Neural headline generation with minimum risk training. arXiv preprint arXiv:1604.01904, 2016.
Ondrej Bojar, Rajen Chatterjee, Christian Federmann, Barry Haddow, Matthias Huck, Chris Hokamp, Philipp Koehn, Varvara Logacheva, Christof Monz, Matteo Negri, Matt Post, Carolina Scarton, Lucia Specia, and Marco Turchi. Findings of the 2015 workshop on statistical machine translation. In WMT@EMNLP, 2015.
Massimo Caccia, Lucas Caccia, William Fedus, Hugo Larochelle, Joelle Pineau, and Laurent Charlin. Language gans falling short. arXiv preprint arXiv:1811.02549, 2018. URL https: //arxiv.org/pdf/1811.02549.pdf.
Thomas Degris, Martha White, and Richard S Sutton. Off-policy actor-critic. arXiv preprint arXiv:1205.4839, 2012.
Sergey Edunov, Myle Ott, Michael Auli, David Grangier, and Marc’Aurelio Ranzato. Classical structured prediction losses for sequence to sequence learning. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), pp. 355–364. Association for Computational Linguistics, 2018. doi: 10.18653/v1/N18-1033. URL http://aclweb.org/anthology/ N18-1033.
Benjamin Eysenbach, Abhishek Gupta, Julian Ibarz, and Sergey Levine. Diversity is all you need: Learning skills without a reward function. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id $=$ SJx63jRqFm.
Lior Fox, Leshem Choshen, and Yonatan Loewenstein. Dora the explorer: Directed outreaching reinforcement action-selection. ICLR, abs/1804.04012, 2018.
Dibya Ghosh, Avi Singh, Aravind Rajeswaran, Vikash Kumar, and Sergey Levine. Divide-andconquer reinforcement learning. In International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id $=$ rJwelMbR-.
Lisa Anne Hendricks, Zeynep Akata, Marcus Rohrbach, Jeff Donahue, Bernt Schiele, and Trevor Darrell. Generating visual explanations. In ECCV, 2016.
Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. CoRR, abs/1412.6980, 2015.
Philipp Koehn, Hieu Hoang, Alexandra Birch, Chris Callison-Burch, Marcello Federico, Nicola Bertoldi, Brooke Cowan, Wade Shen, Christine Moran, Richard Zens, Chris Dyer, Ondrej Bojar, Alexandra Constantin, and Evan Herbst. Moses: Open source toolkit for statistical machine translation. In Proceedings of the 45th Annual Meeting of the Association for Computational Linguistics Companion Volume Proceedings of the Demo and Poster Sessions, pp. 177–180, 2007.
Jiwei Li, Will Monroe, Tianlin Shi, Sébastien Jean, Alan Ritter, and Dan Jurafsky. Adversarial learning for neural dialogue generation. In Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing, pp. 2157–2169, Copenhagen, Denmark, September 2017. Association for Computational Linguistics. URL https://www.aclweb.org/anthology/ D17-1230.
Timothy P Lillicrap, Jonathan J Hunt, Alexander Pritzel, Nicolas Heess, Tom Erez, Yuval Tassa, David Silver, and Daan Wierstra. Continuous control with deep reinforcement learning. arXiv preprint arXiv:1509.02971, 2015.
Siqi Liu, Zhenhai Zhu, Ning Ye, Sergio Guadarrama, and Kevin Murphy. Optimization of image description metrics using policy gradient methods. CoRR, abs/1612.00370, 2, 2016.
Peter Makarov and Simon Clematide. Neural transition-based string transduction for limitedresource setting in morphology. In COLING, 2018.
Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Andrei A Rusu, Joel Veness, Marc G Bellemare, Alex Graves, Martin Riedmiller, Andreas K Fidjeland, Georg Ostrovski, et al. Human-level control through deep reinforcement learning. Nature, 518(7540):529–533, 2015.
Volodymyr Mnih, Adria Puigdomenech Badia, Mehdi Mirza, Alex Graves, Timothy Lillicrap, Tim Harley, David Silver, and Koray Kavukcuoglu. Asynchronous methods for deep reinforcement learning. In International conference on machine learning, pp. 1928–1937, 2016.
Graham Neubig. Lexicons and minimum risk training for neural machine translation: Naist-cmu at wat2016. In WAT@COLING, 2016.
Graham Neubig, Matthias Sperber, Xinyi Wang, Matthieu Felix, Austin Matthews, Sarguna Padmanabhan, Ye Qi, Devendra Singh Sachan, Philip Arthur, Pierre Godard, John Hewitt, Rachid Riad, and Liming Wang. Xnmt: The extensible neural machine translation toolkit. In AMTA, 2018.
Franz Josef Och. Minimum error rate training in statistical machine translation. In Proceedings of the 41st Annual Meeting on Association for Computational Linguistics-Volume 1, pp. 160–167. Association for Computational Linguistics, 2003.
Kishore Papineni, Salim Roukos, Todd Ward, and Wei-Jing Zhu. Bleu: a method for automatic evaluation of machine translation. In Proceedings of the 40th annual meeting on association for computational linguistics, pp. 311–318. Association for Computational Linguistics, 2002. URL https://www.aclweb.org/anthology/P02-1040.pdf.
Matthias Plappert, Rein Houthooft, Prafulla Dhariwal, Szymon Sidor, Richard Y Chen, Xi Chen, Tamim Asfour, Pieter Abbeel, and Marcin Andrychowicz. Parameter space noise for exploration. arXiv preprint arXiv:1706.01905, 2017.
O. Press, A. Bar, B. Bogin, J. Berant, and L. Wolf. Language generation with recurrent generative adversarial networks without pre-training. In Fist Workshop on Learning to Generate Natural Language@ICML, 2017.
Marc’Aurelio Ranzato, Sumit Chopra, Michael Auli, and Wojciech Zaremba. Sequence level training with recurrent neural networks. arXiv preprint arXiv:1511.06732, 2015.
Steven J Rennie, Etienne Marcheret, Youssef Mroueh, Jerret Ross, and Vaibhava Goel. Self-critical sequence training for image captioning. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 7008–7024, 2017.
Keisuke Sakaguchi, Matt Post, and Benjamin Van Durme. Grammatical error correction with neural reinforcement learning. arXiv preprint arXiv:1707.00299, 2017.
Philip Schulz, Wilker Aziz, and Trevor Cohn. A stochastic decoder for neural machine translation. In ACL, 2018.
Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words with subword units. In Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), volume 1, pp. 1715–1725, 2016. URL http://www. aclweb.org/anthology/P16-1162.
Rico Sennrich, Orhan Firat, Kyunghyun Cho, Alexandra Birch, Barry Haddow, Julian Hitschler, Marcin Junczys-Dowmunt, Samuel Läubli, Antonio Valerio Miceli Barone, Jozef Mokry, and Maria Nadejde. Nematus: a toolkit for neural machine translation. In EACL, 2017.
Shiqi Shen, Yong Cheng, Zhongjun He, Wei He, Hua Wu, Maosong Sun, and Yang Liu. Minimum risk training for neural machine translation. In Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 1683–1692. Association for Computational Linguistics, 2016. doi: 10.18653/v1/P16-1159. URL http://aclweb. org/anthology/P16-1159.
Shiqi Shen, Yang Liu, and Maosong Sun. Optimizing non-decomposable evaluation metrics for neural machine translation. Journal of Computer Science and Technology, 32:796–804, 2017.
Rakshith Shetty, Marcus Rohrbach, Lisa Anne Hendricks, Mario Fritz, and Bernt Schiele. Speaking the same language: Matching machine to human captions by adversarial training. In 2017 IEEE International Conference on Computer Vision (ICCV), pp. 4155–4164. IEEE, 2017.
David Silver, Guy Lever, Nicolas Heess, Thomas Degris, Daan Wierstra, and Martin Riedmiller. Deterministic policy gradient algorithms. In ICML, 2014.
Richard S Sutton and Andrew G Barto. Reinforcement learning: An introduction. MIT press, 1998.
G. Tevet, G. Habib, V. Shwartz, and J. Berant. Evaluating text GANs as language models. arXiv preprint arXiv:1810.12686, 2018.
Tijmen Tieleman and Geoffrey Hinton. Lecture 6.5-rmsprop: Divide the gradient by a running average of its recent magnitude. COURSERA: Neural networks for machine learning, 4(2):26– 31, 2012.
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in Neural Information Processing Systems, pp. 5998–6008, 2017. URL https://papers.nips.cc/paper/ 7181-attention-is-all-you-need.pdf.
Christopher JCH Watkins and Peter Dayan. Q-learning. Machine learning, 8(3-4):279–292, 1992.
John Wieting, Taylor Berg-Kirkpatrick, Kevin Gimpel, and Graham Neubig. Beyond BLEU: Training neural machine translation with semantic similarity. In The 57th Annual Meeting of the Association for Computational Linguistics (ACL), Florence, Italy, July 2019. URL https: //arxiv.org/abs/1909.06694.
Ronald J Williams. Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine learning, 8(3-4):229–256, 1992.
Lijun Wu, Yingce Xia, Li Zhao, Fei Tian, Tao Qin, Jianhuang Lai, and Tie-Yan Liu. Adversarial neural machine translation. arXiv preprint arXiv:1704.06933, 2017.
Lijun Wu, Fei Tian, Tao Qin, Jianhuang Lai, and Tie-Yan Liu. A study of reinforcement learning for neural machine translation. In EMNLP, 2018.
Zhen Yang, Wei Chen, Feng Wang, and Bo Xu. Improving neural machine translation with conditional sequence generative adversarial nets. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), pp. 1346–1355. Association for Computational Linguistics, 2018. doi: 10.18653/v1/N18-1122. URL http://aclweb.org/anthology/N18-1122.
Lantao Yu, Weinan Zhang, Jun Wang, and Yong Yu. Seqgan: Sequence generative adversarial nets with policy gradient. In AAAI, pp. 2852–2858, 2017.
Jiac heng Zhang, Yanzhuo Ding, Shiqi Shen, Yong Cheng, Maosong Sun, Huanbo Luan, and Yang Liu. Thumt: An open source toolkit for neural machine translation. arXiv preprint arXiv:1706.06415, 2017.
Yizhe Zhang, Zhe Gan, and Lawrence Carin. Generating text via adversarial training. In NIPS workshop on Adversarial Training, volume 21, 2016.
# A APPENDIX
A.1 CONTRASTIVE MRT DOES NOT MAXIMIZE THE EXPECTED REWARD
We hereby detail a simple example where following the Contrastive MRT method (see $\ S 2 . 2$ ) does not converge to the parameter value that maximizes $R$ .
Let $\theta$ be a real number in $[ 0 , 0 . 5 ]$ , and let $P _ { \theta }$ be a family of distributions over three values $a , b , c$ such that:
$$P _ { \theta } ( x ) = { \left\{ \begin{array} { l l } { \theta } & { x = a } \\ { 2 \theta ^ { 2 } } & { x = b } \\ { 1 - \theta - 2 \theta ^ { 2 } } & { x = c } \end{array} \right. }$$
Let $r ( a ) = 1 , r ( b ) = 0 , r ( c ) = 0 . 5$ . The expected reward as a function of $\theta$ is:
$$R ( \theta ) = \theta + 0 . 5 ( 1 - \theta - 2 \theta ^ { 2 } )$$
$R ( \theta )$ is uniquely maximized by $\theta ^ { * } = 0 . 2 5$ .
Table 1 details the possible samples of size $k = 2$ , their probabilities, the corresponding $\widetilde { R }$ and its gradient. Standard numerical methods show that $\mathbb { E } [ \nabla \widetilde { R } ]$ over possible samples $S$ is positive for $\theta \in ( 0 , \gamma )$ and negative for $\theta \in ( \gamma , 0 . 5 ]$ , where $\gamma \approx 0 . 2 9 5$ . This means that for any initialization of $\theta \in ( 0 , 0 . 5 ]$ , Contrastive MRT will converge to $\gamma$ if the learning rate is sufficiently small. For $\theta = 0$ , $\widetilde { R } \equiv 0 . 5$ , and there will be no gradient updates, so the method will converge to $\theta = 0$ . Neither of these values maximizes $R ( \theta )$ .
We note that by using some $g \left( \theta \right)$ the $\gamma$ could be arbitrarily far from $\theta ^ { * }$ . $g$ could also map to $( - i n f , i n f )$ more often used in neural networks parameters.
We further note that resorting to maximizing $\mathbb { E } [ { \widetilde { R } } ]$ instead, does not maximize $R ( \theta )$ either. Indeed, plotting $\mathbb { E } [ { \widetilde { R } } ]$ as a function of $\theta$ for this example, yields a maximum at $\theta \approx 0 . 3 2$ .
<table><tr><td rowspan=1 colspan=1>S</td><td rowspan=1 colspan=1>P(S)</td><td rowspan=1 colspan=1>R</td><td rowspan=1 colspan=1>VR</td></tr><tr><td rowspan=1 colspan=1>{a,b}</td><td rowspan=1 colspan=1>403</td><td rowspan=1 colspan=1>11+20</td><td rowspan=1 colspan=1>-2(1+20)2</td></tr><tr><td rowspan=1 colspan=1>{a,c}</td><td rowspan=1 colspan=1>20(1-0-202)</td><td rowspan=1 colspan=1>0.5 + θ2-402</td><td rowspan=1 colspan=1>2x²+12(1-202)2</td></tr><tr><td rowspan=1 colspan=1>{b,c}</td><td rowspan=1 colspan=1>402(1-0-202)</td><td rowspan=1 colspan=1>1-0-2022-20</td><td rowspan=1 colspan=1>0²-20(1-0)2</td></tr><tr><td rowspan=1 colspan=1>a,a</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>0</td></tr><tr><td rowspan=1 colspan=1>b,b</td><td rowspan=1 colspan=1>404</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>0</td></tr><tr><td rowspan=1 colspan=1>c,c</td><td rowspan=1 colspan=1>(1-0-202)2</td><td rowspan=1 colspan=1>0.5</td><td rowspan=1 colspan=1>0</td></tr></table>
Table 1: The gradients of $\widetilde { R }$ for each possible sample $S$ . The batch size is $k = 2$ . Rows correspond to different sampled outcomes. $\nabla \widetilde R$ is the gradient of $\widetilde { R }$ given the corresponding value for $S$ .
# A.2 DERIVING THE GRADIENT OF $\widetilde { R }$
Given $S$ , recall the definition of $\widetilde { R }$ :
$$\widetilde { R } ( \theta , S ) = \sum _ { i = 1 } ^ { k } Q _ { \theta , S } ( y _ { i } ) r ( y _ { i } )$$
Taking the deriviative w.r.t. $\theta$ :
 Figure 7: The probability of different tokens following REINFORCE, in the controlled simulations in the Constant Reward setting. The left/center/right figures correspond to simulations where the target token $( y _ { b e s t } )$ was initially the second/third/fourth most probable token. The green line corresponds to the target token, yellow lines to medium-reward tokens and red lines to tokens with $\bar { \boldsymbol { r } } ( y ) = 0$ .
# A.3 NMT IMPLEMENTATION DETAILS
True casing and tokenization were used (Koehn et al., 2007), including escaping html symbols and "-" that represents a compound was changed into a separate token of $=$ . Some preprocessing used before us converted the latter to ##AT##-##AT## but standard tokenizers in use process that into 11 different tokens, which over-represents the significance of that character when BLEU is calculated. BPE (Sennrich et al., 2016) extracted 30,715 tokens. For the MT experiments we used 6 layers in the encoder and the decoder. The size of the embeddings was 512. Gradient clipping was used with size of 5 for pre-training (see Discussion on why not to use it in training). We did not use attention dropout, but 0.1 residual dropout rate was used. In pretraining and training sentences of more than 50 tokens were discarded. Pretraining and training were considered finished when BLEU did not increase in the development set for 10 consecutive evaluations, and evaluation was done every 1,000 and 5,000 for batches of size 100 and 256 for pretraining and training respectively. Learning rate used for rmsprop (Tieleman & Hinton, 2012) was 0.01 in pretraining and for adam (Kingma & Ba, 2015) with decay was 0.005 for training. 4,000 learning rate warm up steps were used. Pretraining took about 7 days with 4 GPUs, afterwards, training took roughly the same time. Monte Carlo used 20 sentence rolls per word.
# A.4 DETAILED RESULTS FOR CONSTANT REWARD SETTING
We present graphs for the constant reward setting in Figures 8 and 7. Trends are similar to the ones obtained for the Simulated Reward setting.
 Figure 8: Difference between the ranks of $y _ { b e s t }$ in the reinforced with constant reward and the pretrained model. Each column $_ x$ corresponds to the difference in the probability that $y _ { b e s t }$ is ranked in rank $x$ in the reinforced model, and the same probability in the pretrained model.md/train/1Jv6b0Zq3qi/1Jv6b0Zq3qi.mdAdded+338
md/train/2zCRcTafea/2zCRcTafea.mdAdded+267
md/train/30EvkP2aQLD/30EvkP2aQLD.mdAdded+611
md/train/3EwcMzmUbNd/3EwcMzmUbNd.mdAdded+356
md/train/5vShUEyjmm/5vShUEyjmm.mdAdded+389
md/train/7_eLEvFjCi3/7_eLEvFjCi3.mdAdded+318
md/train/8q_ca26L1fz/8q_ca26L1fz.mdAdded+346
md/train/B7v4QMR6Z9w/B7v4QMR6Z9w.mdAdded
md/train/BJInEZsTb/BJInEZsTb.mdAdded+396
md/train/BJLmN8xRW/BJLmN8xRW.mdAdded+169
md/train/BJlkgaNKvr/BJlkgaNKvr.mdAdded
md/train/BkV4VS9ll/BkV4VS9ll.mdAdded+599
md/train/BkeaEyBYDB/BkeaEyBYDB.mdAdded+234
md/train/D7bPRxNt_AP/D7bPRxNt_AP.mdAdded+292
md/train/Fo6S5-3Dx_/Fo6S5-3Dx_.mdAdded+329
md/train/GrB-y0SNkQ/GrB-y0SNkQ.mdAdded+636
md/train/H1eCw3EKvH/H1eCw3EKvH.mdAdded+354
md/train/H1gBsgBYwH/H1gBsgBYwH.mdAdded
md/train/H1xwNhCcYm/H1xwNhCcYm.mdAdded
md/train/HJ1kmv9xx/HJ1kmv9xx.mdAdded
md/train/HJxeWnCcF7/HJxeWnCcF7.mdAdded
md/train/HyGhN2A5tm/HyGhN2A5tm.mdAdded
md/train/Hyx6Bi0qYm/Hyx6Bi0qYm.mdAdded
md/train/Ig53hpHxS4/Ig53hpHxS4.mdAdded
md/train/QpU7n-6l0n/QpU7n-6l0n.mdAdded
md/train/RQfcckT1M_4/RQfcckT1M_4.mdAdded
md/train/RtNpzLdHUAW/RtNpzLdHUAW.mdAdded
md/train/S1eK3i09YQ/S1eK3i09YQ.mdAdded
md/train/S1lF8xHYwS/S1lF8xHYwS.mdAdded
md/train/SJlKrkSFPH/SJlKrkSFPH.mdAdded
md/train/SJx7Jrtgl/SJx7Jrtgl.mdAdded
md/train/SkgHtkrYPH/SkgHtkrYPH.mdAdded
md/train/SkxKPDv5xl/SkxKPDv5xl.mdAdded
md/train/Sy1f0e-R-/Sy1f0e-R-.mdAdded
md/train/UZgGf92u5N0/UZgGf92u5N0.mdAdded
md/train/VKVShLsAuZ/VKVShLsAuZ.mdAdded
md/train/VRgITLy0l2/VRgITLy0l2.mdAdded
md/train/WGWzwdjm8mS/WGWzwdjm8mS.mdAdded
md/train/XZDeL25T12l/XZDeL25T12l.mdAdded
md/train/YicbFdNTTy/YicbFdNTTy.mdAdded
md/train/dBE8OI8_ZOa/dBE8OI8_ZOa.mdAdded
md/train/m1CD7tPubNy/m1CD7tPubNy.mdAdded
md/train/r1eBeyHFDH/r1eBeyHFDH.mdAdded
md/train/r1efr3C9Ym/r1efr3C9Ym.mdAdded
md/train/rJfHoM-C-/rJfHoM-C-.mdAdded
md/train/rJiNwv9gg/rJiNwv9gg.mdAdded
md/train/rklB76EKPr/rklB76EKPr.mdAdded
md/train/rkxY-sl0W/rkxY-sl0W.mdAdded
md/train/uDeDDoFOEpj/uDeDDoFOEpj.mdAdded
md/train/zI38PZQHWKj/zI38PZQHWKj.mdAdded