diff --git a/12leadecgreconstructionviakoopmanoperators/761215aa-8bbf-45b9-a70a-e4170fc85d79_content_list.json b/12leadecgreconstructionviakoopmanoperators/761215aa-8bbf-45b9-a70a-e4170fc85d79_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..bc459b8ec2d9d8ab548e3d9b07580cefece0eced --- /dev/null +++ b/12leadecgreconstructionviakoopmanoperators/761215aa-8bbf-45b9-a70a-e4170fc85d79_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:973557ac0ad8dff1c84e930cfc12681dc205054a40e37d3164082420f733f527 +size 79001 diff --git a/12leadecgreconstructionviakoopmanoperators/761215aa-8bbf-45b9-a70a-e4170fc85d79_model.json b/12leadecgreconstructionviakoopmanoperators/761215aa-8bbf-45b9-a70a-e4170fc85d79_model.json new file mode 100644 index 0000000000000000000000000000000000000000..ed42a74b4a29686a622e8202a886f1d8ba12e460 --- /dev/null +++ b/12leadecgreconstructionviakoopmanoperators/761215aa-8bbf-45b9-a70a-e4170fc85d79_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3656f22d192b1cb5a4cd4dfdc6d70721b3c1c27fe53ef873944d924a4efbedf5 +size 94748 diff --git a/12leadecgreconstructionviakoopmanoperators/761215aa-8bbf-45b9-a70a-e4170fc85d79_origin.pdf b/12leadecgreconstructionviakoopmanoperators/761215aa-8bbf-45b9-a70a-e4170fc85d79_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..4b25a333bbd53209b6b4d40a82d3fa1fcd8c085d --- /dev/null +++ b/12leadecgreconstructionviakoopmanoperators/761215aa-8bbf-45b9-a70a-e4170fc85d79_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:38fe58a802c1ee581a80ba2020afde43173583fc90eb3b1542d8afc21d66b2af +size 1480597 diff --git a/12leadecgreconstructionviakoopmanoperators/full.md b/12leadecgreconstructionviakoopmanoperators/full.md new file mode 100644 index 0000000000000000000000000000000000000000..2c3c7dd1e0f311f1787045847383e02611840f9f --- /dev/null +++ b/12leadecgreconstructionviakoopmanoperators/full.md @@ -0,0 +1,368 @@ +# 12-lead ECG Reconstruction via Koopman Operators + +Tomer Golany $^{1}$ Daniel Freedman $^{2}$ Saar Minha $^{3}$ Kira Radinsky $^{1}$ + +# Abstract + +$32\%$ of all global deaths in the world are caused by cardiovascular diseases. Early detection, especially for patients with ischemia or cardiac arrhythmia, is crucial. To reduce the time between symptoms onset and treatment, wearable ECG sensors were developed to allow for the recording of the full 12-lead ECG signal at home. However, if even a single lead is not correctly positioned on the body that lead becomes corrupted, making automatic diagnosis on the basis of the full signal impossible. In this work, we present a methodology to reconstruct missing or noisy leads using the theory of Koopman Operators. Given a dataset consisting of full 12-lead ECGs, we learn a dynamical system describing the evolution of the 12 individual signals together in time. The Koopman theory indicates that there exists a high-dimensional embedding space in which the operator which propagates from one time instant to the next is linear. We therefore learn both the mapping to this embedding space, as well as the corresponding linear operator. Armed with this representation, we are able to impute missing leads by solving a least squares system in the embedding space, which can be achieved efficiently due to the sparse structure of the system. We perform an empirical evaluation using 12-lead ECG signals from thousands of patients, and show that we are able to reconstruct the signals in such way that enables accurate clinical diagnosis. + +# 1. Introduction + +Cardiovascular diseases are responsible for about a third of all deaths globally (Roth et al., 2018). The electrocardiogram (ECG) is a noninvasive tool for detecting diseases of the heart, and as such is one of the most common tests performed by cardiologists. The short-duration standard 12-lead ECG is the most commonly used ECG exam in medical facilities (Maron et al., 2014). In this test, ten electrodes are placed on a patient and the overall electrical potential amplitude of the heart is then measured from twelve different angles referred to as "leads", and is recorded over a period of time (10 seconds in the standard 12-lead ECG exam). This evaluation provides a full diagnosis of heart activity, including arrhythmia, acute coronary syndrome, ventricular dysfunction and cardiac chamber hypertrophy. + +However, it is still a challenge to conveniently and robustly track 12-lead ECG in people's daily lives. To reduce the time between the onset of symptoms and their treatment, wearable ECG sensors such as (Laguna et al., 1990) been developed to allow the recording of a 12-lead ECG at home. Accurate ECG monitoring from those devices is of high importance. For example, Atrial Fibrillation, the most common serious cardiac arrhythmia, affects an estimated 2.7-6.1 million people and increases a person's risk of a life-changing stroke, heart failure and death. It can occur without symptoms, thus its timely detection could help physicians and their patients get an earlier confirmed diagnosis. + +In order to properly rely on these sensors for clinical interpretation, each lead measurement must be well grounded. If even a single lead is not correctly positioned on the body that lead becomes corrupted, making diagnosis on the basis of the full 12-lead ECG signal impossible. To overcome this challenge, the problem of ECG reconstruction has gained considerable attention and several solutions based on machine learning have been proposed (Scherer et al., 1989; Nelwan, 2005; Atoui et al., 2004; Zhou et al., 2019). However, all of these methods assume a fixed set of pre-specified leads to have clean signals. This is a challenge with wearable devices where arbitrary leads can be corrupted. In this work, we introduce a framework which is able to reconstruct 12-lead ECG from any subset of available leads, without training a new model for each subset. + +ECGs using the theory of Koopman Operators (Koopman, 1931; Koopman & Neumann, 1932), a decades old theory which has recently re-emerged as a leading candidate for the systematic linear representation of nonlinear systems (Mezić & Banaszuk, 2004) (Mezić, 2005). The key aspect of Koopman theory which we leverage is its linear structure: the signal of interest can be embedded in a high-dimensional space in which the operator which propagates from one time instant to the next is linear. Learning the dynamical system is therefore equivalent to learning both the mapping to this embedding space, as well as the corresponding linear operator. Due to the linear structure, missing lead reconstruction can be posed as a least squares problem in the embedding space. Minimization leads to an explicit solution in the form of a sparse linear system, which can be solved efficiently. We emphasize again that this method of reconstruction may be applied no matter which subset of leads have been corrupted, giving it a crucial advantage over existing techniques (Zhou et al., 2019). Figure 1 presents an example of two Koopman-reconstructed leads. + +We empirically evaluate our reconstruction technique in 3 separate ways: (1) We compute the reconstruction error of our algorithm, and show that it is lower than competitor techniques. (2) We learn classifiers for common classes of abnormalities, and analyze the change in performance of these classifiers as clean signals in the test are replaced with signals in which some of the leads have been reconstructed. We show that classification accuracy remains high when using signals with reconstructed leads; and this remains the case even when a large number of leads have been corrupted. (3) We perform a small clinical experiment, in which clinicians are given examples of ECG signals with missing vs. reconstructed corrupted leads. We demonstrate that our reconstruction improves clinicians' diagnosis capabilities. + +Our contributions in this work are threefold. (1) We present a methodology to learn 12-lead ECG dynamics using Koopman operators, which are represented by deep neural nets. We learn a separable representation of the Koopman embedding functions that can be applied on each ECG lead separately. (2) We introduce a least squares system which is able to impute missing leads efficiently from any partial sub-leads ECG. We share the code for the reproducibility of our results (3) We empirically show that our method is able to reconstruct any partial-lead ECG signal to a 12-lead ECG without hurting clinical diagnosis. This is demonstrated by empirical experiments showing increased performance of both clinicians and state-of-the-art deep-learning models to identify ECG abnormalities using the reconstructed data. + +![](images/85572ace400b2b966dde2091fcb6f10874c50bf92b4c6bdfb8d71fc5140ed9a0.jpg) +Figure 1. Examples of reconstructed leads. Blue: real signal. Red: reconstructed signal by Koopman framework. + +![](images/1ba15e785a82afc2b1f149ac8cf59c2a16e44b057671109b6343e2b1b78a0f04.jpg) + +# 2. Related Work + +12-Lead ECG Reconstruction The first attempt to reconstruct 12-lead ECG from a subset of leads was introduced by (Frank, 1956). Later, classical machine learning methods were proposed using simple linear regression techniques (Scherer et al., 1989; Nelwan, 2005). An early method which used neural networks for the purposes of lead reconstruction is presented in (Atoui et al., 2004). More recent methods based on CNNs (Zhou et al., 2019) and LSTMs (Zhang & Frick, 2019) have successfully reconstructed 9-lead ECG from the 3-lead ECG. All prior works assume that specific indices of leads are recorded cleanly, and attempt to reconstruct the remaining leads. For example, it might be assumed that leads V1 and V2 are clean, and the remaining 10 leads require reconstruction. However, each 12-lead ECG recording coming from a wearable device might have a different set of leads that are cleanly recorded. Therefore, a model which expects a specific subset of leads might fail to reconstruct the full 12-lead ECG from such devices. By contrast, our framework is able to reconstruct 12-lead ECG from any subset of available leads, without training a new model for each subset. + +Learning ECG Dynamics of a Single Lead Formulating the dynamics as a system of differential equations often admits compact and efficient representations for many natural systems (Brunton et al., 2016). This holds true in the case of single-lead ECG signals, one-dimensional signals of voltage values representing the electrical activity of the heart through time. The ECG signal is a periodic signal of cardiac muscle depolarization followed by repolarization, with each period corresponding to a single heartbeat. An ECG heartbeat follows a prototypical pattern of a P wave, followed by a QRS complex, and finally a T wave. To capture this pattern, (McSharry et al., 2003) proposed a physics-based model of ECG dynamics consisting of a system of three coupled ordinary differential equations (ODE), parameterized by specific heart rate statistics, such as the frequency-domain characteristics of the heart rate variability (Malik & Camm, 1990). While this model is able to generate synthetic ECG signals with somewhat realistic PQRST morphology as well as prescribed heart rate dynamics, it has + +limited expressiveness. A more recent work (Golany et al., 2020) introduced a GAN-based setup enriched with additional knowledge from this physics-based ECG model, and showed that using the synthetically generated ECG heartbeats from the GAN significantly improved ECG heartbeat classification. Others (Golany et al., 2021) attempted to learn a new set of ODEs from data rather than relying on predefined set of ODEs to represent the dynamics of a single ECG heartbeat. This prior work that learns data-driven ECG Dynamics attempts to capture the dynamics of a single ECG heartbeat within a single lead. By contrast, we focus on the dynamics of an entire ECG signal, consisting of multiple heartbeats, with all 12 leads. The data and the corresponding modelling problem are concomitantly more complex. + +Koopman Theory The original Koopman theory was introduced nearly one hundred years ago (Koopman, 1931; Koopman & Neumann, 1932). Renewed interest in Koopman analysis has been driven by a combination of theoretical advances (Mezić & Banaszuk, 2004) (Mezić, 2005) (Budišić et al., 2012) (Mezić, 2013), improved numerical methods such as dynamic mode decomposition (Schmid, 2010) (Rowley et al., 2009), and an increasing abundance of data. Recently, (Lusch et al., 2018) utilized the power of deep learning for flexible and general representations of the Koopman framework, while enforcing a network structure that promotes parsimony and interpretability of the resulting models. Although it was applied on small scale toy problems, such as pendulum motion prediction (Erichson et al., 2019; Pan & Duraisamy, 2020), to the best of our knowledge, it was yet to be applied in a large-scale machine learning application. + +# 3. Koopman-Based ECG Reconstruction + +# 3.1. Koopman Theory of Dynamical Systems + +Throughout this paper, we will consider discrete-time dynamical systems of the form + +$$ +x _ {t + 1} = F \left(x _ {t}\right) \tag {1} +$$ + +where $x_{t} \in \mathcal{X} \equiv \mathbb{R}^{L}$ is the state of the dynamical system and $F$ represents the nonlinear transformation (the dynamics) which maps the state of the system to its future state. Note that this formulation subsumes discretizations of ordinary differential equations (ODEs). That is, suppose that the underlying continuous signal is given by $\mathbf{x}(\tau)$ for $\tau \in [0,\bar{\tau}]$ ; and the dynamics is described by the ODE $d\mathbf{x} / d\tau = f(\mathbf{x})$ . Then the signal may be discretized as $x_{t} = \mathbf{x}(t\Delta)$ for $t = 0,\dots,T$ with $\Delta = \bar{\tau} /T$ , and the dynamics approximated as $x_{t + 1} \approx x_{t} + f(x_{t})\Delta \equiv F(x_{t})$ . The approximation becomes increasingly exact as $\Delta$ gets smaller. + +(Koopman, 1931) offers a different and useful viewpoint for examining dynamical systems. In particular, rather than consider the state space $x$ , Koopman considers the space of possible measurements on $x$ . A measurement on $x$ is defined as a scalar-valued function on the state space $\mathcal{X}$ , that is + +$$ +y: \mathcal {X} \rightarrow \mathbb {R} \tag {2} +$$ + +The space of all measurements is denoted as $\mathcal{V}$ , which is an infinite-dimensional space. For a dynamical system of the form in Equation (1) given by dynamics $F$ , we define the corresponding Koopman operator which maps from measurements to measurements, $\mathcal{K}:\mathcal{V}\to \mathcal{V}$ by + +$$ +\mathcal {K} y \equiv y \circ F \tag {3} +$$ + +where $\circ$ indicates function composition. (Note that $y \circ F$ is indeed a measurement, as it maps $\mathcal{X}$ to $\mathbb{R}$ .) In this case, the dynamical system of Equation (1) can be rewritten as + +$$ +y \left(x _ {t + 1}\right) = y \left(F \left(x _ {t}\right)\right) = y \circ F \left(x _ {t}\right) +$$ + +$$ += (\mathcal {K} y) (x _ {t}) \tag {4} +$$ + +Thus, if a measurement $y$ evolves forward with the operator $\mathcal{K}$ , then it satisfies the "pullback" property given in Equation (4). However, what makes the formulation most interesting is the fact that the Koopman operator $\mathcal{K}$ is linear. This fact is easily shown: + +$$ +\begin{array}{l} \mathcal {K} \left(\alpha_ {1} y _ {1} + \alpha_ {2} y _ {2}\right) = \left(\alpha_ {1} y _ {1} + \alpha_ {2} y _ {2}\right) \circ F \\ = \alpha_ {1} y _ {1} \circ F + \alpha_ {2} y _ {2} \circ F \\ = \alpha_ {1} \mathcal {K} y _ {1} + \alpha_ {2} \mathcal {K} y _ {2} \\ \end{array} +$$ + +The linearity of the Koopman operator is crucial to the development of our method, as we shall see in Section 3.3. + +# 3.2. Learning a Koopman Representation for ECG Dynamics + +In this section, we adapt the Koopman framework to learn the dynamics of 12-lead ECG signals. We begin by describing two necessary modifications to the Koopman theory, after which we show how to learn the dynamical system. + +We begin with some notation. The number of ECG leads is denoted as $L = 12$ . The standard 12-lead electrocardiogram is a representation of the heart's electrical activity recorded from electrodes on the body surface, sampled at a fixed frequency. The $\ell^{th}$ lead sampled at time $t$ is denoted by $x_{t}^{\ell}$ ; all $L$ leads taken together at time $t$ are denoted $x_{t} = [x_{t}^{1},\ldots ,x_{t}^{L}] \in \mathbb{R}^{L}$ , taken to be a column vector. + +Finite-Dimensional Approximation The first modification we must make to the standard Koopman theory concerns dimensionality. The space $\mathcal{V}$ of measurements is infinite-dimensional and the Koopman operator $\kappa$ is likewise an infinite-dimensional operator. For computational + +purposes, we approximate the entire Koopman framework by mapping in into a finite-dimensional setting. In particular, suppose that + +$$ +\Gamma : \mathbb {R} ^ {D} \rightarrow \mathcal {Y} \tag {5} +$$ + +maps a finite-dimensional space to the space of measurements. (For concreteness, the reader may imagine mapping the coefficients of a basis expansion to the function $y$ itself, though we will not use this representation.) In this case, we will approximate the Koopman operator $\mathcal{K}$ by + +$$ +\mathcal {K} = \Gamma K \Gamma^ {- 1} \tag {6} +$$ + +where $K$ is a $D\times D$ matrix. + +In this case, we can rewrite the dynamical system in Equation (4) as + +$$ +\begin{array}{l} y \left(x _ {t + 1}\right) = \Gamma K \Gamma^ {- 1} y \left(x _ {t}\right) \\ \Rightarrow \Gamma^ {- 1} y \left(x _ {t + 1}\right) = K \Gamma^ {- 1} y \left(x _ {t}\right) \tag {7} \\ \end{array} +$$ + +Now, letting $\Phi = \Gamma^{-1}y$ so that $\Phi :\mathbb{R}^L\to \mathbb{R}^D$ , we have that + +$$ +x _ {t + 1} = \Phi^ {- 1} (K \Phi (x _ {t})) \tag {8} +$$ + +This modification is standard, and follows the practice of prior works, e.g. (Lusch et al., 2018). We refer to $\Phi$ as the Koopman embedding. + +Note that we use $K$ rather than $\kappa$ to emphasize this move to a finite-dimensional framework, but we abuse notation slightly by continuing to use the symbol $y$ to represent its finite-dimensional version, i.e. + +$$ +y = \Phi (x) \tag {9} +$$ + +In this case Equation (8) may be rewritten as + +$$ +y _ {t} = \Phi (x _ {t}) +$$ + +$$ +y _ {t + 1} = K y _ {t} \tag {10} +$$ + +$$ +x _ {t + 1} = \Phi^ {- 1} \left(y _ {t + 1}\right) +$$ + +which illustrates the fact that in the embedding space, the dynamics are linear. + +Separable Koopman Embedding We make a second modification to the standard Koopman theory, which is necessary for our reconstruction algorithm. We assume that the Koopman embedding is separable: that is, each lead has its own separate embedding. More specifically, we map the $\ell^{th}$ lead $x_{t}^{\ell}$ to its corresponding embedding $y_{t}^{\ell}$ as follows: + +$$ +y _ {t} ^ {\ell} = \phi_ {\ell} \left(x _ {t} ^ {\ell}\right) \tag {11} +$$ + +where $\phi_{\ell}:\mathbb{R}\to \mathbb{R}^{D / L}$ . The overall Koopman embedding $\Phi$ is then derived by concatenating the per-lead embeddings: + +$$ +y _ {t} = \left[ y _ {t} ^ {1}, \dots , y _ {t} ^ {L} \right] \in \mathbb {R} ^ {D} \tag {12} +$$ + +so that + +$$ +\Phi \left(x _ {t}\right) = \left[ \phi_ {1} \left(x _ {t} ^ {1}\right), \dots , \phi_ {L} \left(x _ {t} ^ {L}\right) \right] \tag {13} +$$ + +The importance of separability to the reconstruction algorithm will become clear in Section 3.3. We note that separability is not guaranteed by the Koopman theory; nevertheless, there is nothing which prevents us from imposing it as a constraint during our learning procedure. In spite of this lack of theoretical guarantees, we show empirically in Section 5 that separability does not impair the learning of an accurate dynamical system. In this context, we also note that due to the separable structure, all of the coupling between the leads is encapsulated by the matrix $K$ . + +Learning the Dynamical System Given the above Koopman framework, learning the dynamical system entails learning two things: the Koopman embedding $\Phi$ , and the Koopman operator $K$ . A variety of methods have been proposed for learning the Koopman framework based on neural networks (Wehmeyer & Noé, 2018; Mardt et al., 2018; Takeishi et al., 2017; Yeung et al., 2019). We choose to follow the technique of (Lusch et al., 2018) and outline this method briefly. + +A multilayer perceptron (MLP) specifies the Koopman embedding $\Phi$ ; in our case, we impose the separable structure on the embedding, so that the network's structure is tantamount to $L$ separate MLPs $\{\phi_{\ell}\}_{\ell=1}^{L}$ . An additional MLP is learned to represent the inverse transformation $\Phi^{-1}$ , which is again tantamount to learning $L$ separate MLPs $\{\phi_{\ell}^{-1}\}_{\ell=1}^{L}$ . The Koopman operator is simply a $D \times D$ matrix $K$ . To learn the networks $\Phi$ and $\Phi^{-1}$ and matrix $K$ , three separate losses are used: + +(1) Reconstruction: $\| x_{t} - \Phi^{-1}(\Phi (x_{t}))\|$ +(2) Linear Dynamics: $\| \Phi (x_{t + m}) - K^m\Phi (x_t)\|$ , $m\geq 1$ +(3) State Prediction: $\| x_{t + m} - \Phi^{-1}(K^m\Phi (x_t))\|$ , $m\geq 1$ . Further details, including values of $m$ to use, are described in (Lusch et al., 2018). + +We note that in practice, we have found that learning a single per-lead embedding $\phi$ which is the same for all leads is sufficient, i.e. $\phi_{\ell} = \phi$ for all $\ell$ . However, this is not necessary for the reconstruction algorithm described next, so we leave the derivation there in the general setting. + +# 3.3. Reconstruction of Missing Leads + +We now turn to our main goal: the reconstruction of corrupted 12-lead ECG signals. As we have already outlined, the corruption may be due to either missing leads or noisy values, a frequent scenario when measuring ECG from wearable sensors such as Holter monitoring (DiMarco & Philbrick, 1990) and ECG patches (Steinhubl et al., 2018). The reconstruction will rely on the Koopman-based dynamical system we have learned. + +Setup The set of missing leads is denoted $\mathcal{M} \subset \{1, \ldots, L\}$ ; our goal is therefore to reconstruct $\{x_t^\ell\}_{t=0}^T$ for each missing lead $\ell \in \mathcal{M}$ . The set of available leads is just the complement of the set of missing leads $\mathcal{A} = \{1, \ldots, L\} - \mathcal{M}$ , which has corresponding indicator vector + +$$ +a _ {\ell} = \left\{ \begin{array}{l l} 1 & \ell \in \mathcal {A} \\ 0 & \ell \notin \mathcal {A} \end{array} \right. \tag {14} +$$ + +Step 1: Mapping Available Leads to their Koopman Embeddings We begin by mapping the available leads to their corresponding Koopman embeddings. The available leads are given by $\{\bar{x}_t^\ell\}_{t=0}^T$ for each $\ell \in \mathcal{A}$ ; we therefore let + +$$ +\bar {y} _ {t} ^ {\ell} = \left\{ \begin{array}{l l} \phi_ {\ell} \left(\bar {x} _ {t} ^ {\ell}\right) & \ell \in \mathcal {A} \\ 0 & \ell \notin \mathcal {A} \end{array} \right. \tag {15} +$$ + +Missing values have been filled in with zeros for convenience, so that the overall Koopman embeddings have the correct size, i.e. $\bar{y}_t\in \mathbb{R}^D$ ; however, the missing entries can take on any values, as they will not be used. + +Step 2: Reconstructing the Missing Leads in Embedding Space Given the available leads' Koopman embeddings, we can now solve for the missing leads by leveraging the fact that the Koopman operator is linear. For convenience, we let + +$$ +A = \operatorname {d i a g} \left(a \otimes \mathbf {1} _ {D / L}\right) \tag {16} +$$ + +where $\otimes$ is the Kronecker product. In this case, we can formulate our leads reconstruction problem as one of solving the following optimization problem: + +$$ +\begin{array}{l} \min _ {y _ {0}, \dots , y _ {T}} L (y _ {0}, \dots , y _ {T}) = \\ \frac {1}{2} \sum_ {t = 0} ^ {T - 1} \| y _ {t + 1} - K y _ {t} \| ^ {2} + \frac {\lambda}{2} \sum_ {t = 0} ^ {T} \left(y _ {t} - \bar {y} _ {t}\right) ^ {T} A \left(y _ {t} - \bar {y} _ {t}\right) \tag {17} \\ \end{array} +$$ + +The first term ensures that the dynamical system holds at each time instant; crucially, due to the linearity of the Koopman formulation of the dynamics, this can be formulated nicely as a convex quadratic term. The second term is a data fidelity term for the available leads only: the matrix $A$ picks out only the available leads. $\lambda > 0$ is the weighting factor between the two terms, where a larger $\lambda$ ensures greater consistency to the given leads. In the limit as $\lambda \to \infty$ , we have a hard constraint. + +Due to the fact that $L$ is convex, we can solve for the globally optimal values of $y$ . Furthermore, $L$ is quadratic, giving us an explicit solution. Specifically, let + +$$ +C = K ^ {T} K + I + \lambda A; \tag {18} +$$ + +then the solution is given by + +$$ +\begin{array}{l} - K ^ {T} y _ {t + 1} + (C - I) y _ {t} = \lambda A \bar {y} _ {t} \quad t = 1 \\ - K ^ {T} y _ {t + 1} + C y _ {t} - K y _ {t - 1} = \lambda A \bar {y} _ {t} \quad t \in [ 2, T - 1 ] \\ \end{array} +$$ + +$$ +\left(C - K ^ {T} K\right) y _ {t} - K y _ {t - 1} = \lambda A \bar {y} _ {t} \quad t = T \tag {19} +$$ + +The above is a system of linear equations, and furthermore is quite sparse. As a result, the solution can be achieved efficiently using standard methods. In this work we leverage least squares method (Levenberg, 1944) to solve these equations. + +Step 3: Mapping the Missing Leads Back to Signal Space Finally, given the optimal values $y_{t}^{\ell}$ from the solution to Equation (19), we can map back to signal space. This is achieved by applying the inverse of the separable Koopman embedding function: + +$$ +x _ {t} ^ {\ell} = \phi_ {\ell} ^ {- 1} \left(y _ {t} ^ {\ell}\right) \quad \text {f o r} \ell \in \mathcal {M} \tag {20} +$$ + +This yields the final reconstruction of the missing ECG leads. We note in passing that it is also possible to compute a reconstruction of the ECG signals for the available leads $\ell \in \mathcal{A}$ ; if the data fidelity weight $\lambda \rightarrow \infty$ , it is straightforward to show that these will precisely replicate the data, i.e. $x_{t}^{\ell} = \bar{x}_{t}^{\ell}$ for all $t$ and $\ell \in \mathcal{A}$ . + +Comparison with Seq2Seq We draw the reader's attention to a key distinction between our method and the commonly used seq2seq-style techniques for signal reconstruction applied for ECG reconstruction (Zhou et al., 2019). The seq2seq techniques require learning a separate model from each different subset of available leads; by contrast, the methodology presented learns a single model, which can be easily applied with equal ease to any subset. More specifically, in the seq2seq setting, learning to map from lead 1 to lead 2 is different from lead 1 to lead 3, or leads 1 and 7 to the rest. In our formulation, they may all be reconstructed directly from the ECG signal's master dynamical system. + +# 4. Experimental Framework + +# 4.1. ECG Dataset + +The Georgia 12-lead ECG dataset, referred to as G12EC, was introduced in the 12-lead ECG Physionet Challenge 2020 (Alday et al., 2020) and is considered one of the largest public 12-lead ECG datasets. It represents a large population from the southeastern United States and contains 10,344 12-lead ECGs (male: 5,551, female: 4,793). Each ECG signal is 10 seconds in length with a sampling frequency of $500\mathrm{Hz}$ , yielding a total of 5,000 time samples per signal. + +Each 12-lead ECG exam is annotated with 27 diagnoses. These 27 classes represent relatively common diagnoses which are of clinical interest, with the potential to be recognizable from ECG recordings. Note that the classes are + +not mutually exclusive: each 12-lead ECG exam may hold multiple diagnoses. In our experiments we focus on the following six common types of diagnosis: AF - Atrial fibrillation; TAb - T wave abnormal; QAb - Q wave abnormal; VPB - Ventricular premature beats; LAD - Left axis deviation, and SA - Sinus arrhythmia. Our dataset is divided as follows: the train set contains 8,233 ECG signals, while the test set contains the remaining 2,059 signals. + +# 4.2. Baselines + +We compared our reconstruction model with the state-of-the-art (SOTA) model for 12-lead reconstruction. (Zhou et al., 2019) proposed a seq2seq approach using a CNN-based model for reconstruction of short 12-lead ECG segments from a 3-lead ECGs. We extend this approach and build a model for each $n$ available leads. That is, given $n$ leads the model reconstructs the 12-lead ECG. Note that the model receives any $n$ leads and reconstructs the missing $k$ leads. + +# 4.3. Experimental Setup + +We train the baselines and our model (Section 3) on the training set of G12EC. To mimic a partial 12-lead ECG reading (as often occurs in a home setting when using a wearable), we remove $k \in \{1,4,8,11\}$ random leads from each 12-lead ECG recording in the test-set. Each test instance represents a random subsample of $12 - k$ leads. For example, for $k = 4$ we might remove leads 1,2,3, and 4 from one recording, leads 4,7,9 and 11 from another. The resulting test-set contains ECG signals of shape $\mathbb{R}^{T \times n}$ , where $n = 12 - k$ is the number of leads left in each signal. On the resulting test-set we apply the baselines and solve the system of linear equations described in Section 3 to reconstruct the missing leads. + +We perform experiments showing the performance of reconstruction via two types of experiments: + +1. Reconstruction Error: Measuring the distance between the reconstructed lead and the corresponding ground truth lead (Section 5.1). + +2. Classification Accuracy: Measuring clinical diagnosis based on the reconstructed leads. + +- We perform a small clinical experiment with clinicians (Section 5.3). They received 52 12-lead ECG reading from the test (where $k$ leads are reconstructed) and are asked to make a diagnosis. This diagnosis is compared to the ground truth diagnosis. +To perform a larger experiment, we leverage the state-of-the-art machine-learning model for 12-lead ECG classification (Attia et al., 2019; Ribeiro et al., 2020) and measure its performance on reconstructed leads (Section 5.2). The model is trained on G12EC training + +set, and we report its performance over the test set, where each test set contains reconstructed leads. We compare the classifier diagnosis with the ground-truth diagnosis. We next describe the architecture of the machine-learning model (Section 4.4). + +# 4.4. Classification Network Details + +Recently (Ribeiro et al., 2020) and (Attia et al., 2019) showed superior results for classification of ECG abnormalities from 12-lead ECG signals. They trained a Residual Neural Network (He et al., 2016) based architecture. We follow this practice and use in our experiments a Residual Neural Network model. The input to the model is a 10 seconds 12-lead ECG signal sampled at $500\mathrm{Hz}$ . That is, input of shape $\mathbb{R}^{5000\times 12}$ , where the first dimension represents the temporal dimension and the second dimension represents the spatial dimension. The network consists of a convolution layer, followed by a max pooling layer, followed by six residual blocks. Each residual block consists of 3 convolution layers, and between each convolution layer, Batch-normalization and Relu activation are performed. A skip connection is applied between the input of the block to the output of the third convolution layer. The output of the last residual block is fed into a global average pooling layer, followed by a dense layer. Since multiple abnormalities may occur in the same 12-lead ECG signal (classes are not mutually exclusive), the last activation function we use is a Sigmoid function which gives a separate probability score for each predicted abnormal class. The first convolution layer has 16 filters of size $7\times 7$ . The residual blocks start with 16 filters and are increased to 32 filters in the last block. The size of the kernel in the residual blocks starts in $5\times 5$ , and decreases to $3\times 3$ . In all the residual blocks, except the first one, the first convolution layer down-samples the input temporal dimension by a stride of 2. The neural network weights were initialized as in (He et al., 2016), and the bias was initialized with zeros. The network was trained by feeding 12-lead ECG batches of size 128 from the training data. The binary cross-entropy loss was minimized using Adam Optimizer with initial learning rate 0.0001. The training ran for 100 epochs, with the final model being the one with the best accuracy on the validation set. + +# 5. Experimental Results + +# 5.1. Leads Reconstruction Performance + +We first present the results of Koopman-based ECG reconstruction. We measure the distance of the reconstructed 12-lead ECG signal $\hat{x}_t^\ell$ to the ground truth signal $x_{t}^{\ell}$ . We report our results by the Mean Absolute Deviation (MAD) error function: + +$$ +\mathrm {M A D} = \frac {1}{| \mathcal {M} | T} \sum_ {\ell \in \mathcal {M}} \sum_ {t} \left| x _ {t} ^ {\ell} - x _ {t} ^ {\ell} \right| \tag {21} +$$ + +Table 1. Evaluation of the SOTA ECG Classifier (Section 4) on reconstructed 12-lead ECG testset. Results are shown for different number of reconstructed leads both for Koopman-reconstruction and baseline-reconstruction. + +
KOOPMAN BASED RECONSTRUCTIONBASELINE (ZHOU ET AL., 2019)
RECALL (SENSITIVITY)SPECIFICITYRECALL (SENSITIVITY)SPECIFICITY
ABNORMAL CLASS12-LEAD11-LEAD8-LEAD4-LEAD12-LEAD11-LEAD8-LEAD4-LEAD11-LEAD8-LEAD4-LEAD11-LEAD8-LEAD4-LEAD
AF0.910.910.900.900.850.850.720.800.750.760.790.650.650.62
TAB0.850.850.830.810.770.770.700.700.600.610.560.600.550.52
QAB0.850.870.820.780.700.700.660.620.830.730.570.400.520.47
VPB0.770.760.790.770.560.590.580.670.890.850.810.200.300.37
SA0.660.680.680.620.560.500.550.560.500.640.460.470.570.40
LAD0.940.950.880.810.870.900.800.700.620.610.550.500.550.47
+ +where $\mathcal{M}$ is the set of missing leads. + +Table 2 shows the reconstruction results as a function of the number of missing leads. We note, that as expected as the number of missing leads in the corrupted signal increases, the reconstruction error increases for both the baseline the Koopman-based reconstruction. While our Koopman-based method is better in all cases than the baseline, it is considerably better when there are 10 missing leads, i.e. when most of the information is absent. + +
MISSED LEADSMAD KOOPMANMAD BASELINE
10.1300.134
40.1350.137
80.1380.139
100.1420.196
+ +# 5.2. ECG Classification using Reconstructed Leads + +In this section, we compare the performance of the SOTA ECG classifier when applied on 12-lead ECGs where some of the leads are reconstructed. We experiment on several number of reconstructed leads $(k)$ . + +Comparison to SOTA ECG Reconstruction Figures 2(a)-(f) show the ROC curves of each of the six classified diagnoses (Sec. 4.1). For each diagnosis we compared the results of the 12-lead ECG classifier evaluated on a different reconstructed test-set. The purple curve, the blue curve and the red curve, corresponds to a corrupted test reconstructed via our methods using Koopman operators (Sec. 3.3), with valid 11-leads, 8-leads, and 4-leads respectively. The green, pink, and brown curves in each subfigure correspond to a corrupted test reconstructed by the CNN-based methods of (Zhou et al., 2019), with a valid 11-leads, 8-leads, and 4-leads respectively. Sensitivity and Specificity metrics are also reported in Table 1. Our reconstruction method outperforms the state-of-the-art method with respect to the ROC evaluation metric for each number of corrupted leads and precision-recall points in a statistically significant manner (t-test with p-value $< 0.05$ ). We observe that for all type of diagnosis, our method is better than the CNN-based recon + +struction. This emphasizes the ability of our method to learn to reconstruct any subset of ECG leads to 12-lead ECG. + +Comparison to Complete 12-Lead ECG We notice that when comparing to the gold standard - classification using 12-Lead ECG with no missing leads - we see a very small loss in performance. This indicates that ECG classifiers can be considered for automated classification of ECGs from devices with smaller amount of leads than 12 leads, reconstructed using our method and yet reaching similar performance of full 12-lead devices. + +# 5.3. Clinician's Diagnosis Performance using Reconstructed Leads + +We perform a small clinical experiment. We choose to focus on the T wave abnormality (TAb), as abnormalities of this form are associated with several life-threatening diseases. The electrocardiographic T wave represents ventricular repolarization and are usually hard to identify without the V1 and L leads. We randomly selected 52 ECGs from the test set where $38\%$ had an abnormal T wave. We mimic a situation where the V1 and L leads are corrupted. For each example, we showed the cardiologist the 10 non-corrupted leads and asked to make a diagnosis of whether the patient exhibits TAb. We then showed the additional 2 leads (the V1 and L leads) which were reconstructed using our Koopman framework and asked the cardiologist to make the diagnosis again. Table 3 summarizes the results. Our methodology enabled the cardiologist to identify all of the patients with TAb abnormalities. Notice that without the reconstructed leads, only by observing the non-corrupted leads, the cardiologist identified only $60\%$ of the patients with TAb. We observe a loss in precision (though marginal compared to the recall improvement) and points to the fact that additional + +Table 2. Mean Absolute Deviation (MAD) error between the reconstructed ECG leads and the ground truth. In Bold are statistically significant results. Lower numbers indicate better reconstruction. + +
RecallPrecisionF1
Cardiologist using 10 leads0.60.750.67
Cardiologist using 10 leads + Koopman-reconstructed 2 leads1.00.630.77
+ +Table 3. Clinical experiment results for the TAb abnormality. Each line presents the diagnosis accuracy of the clinician. The first represents the performance results given no reconstructed leads whereas the second with reconstructed leads. + +![](images/e60bc0f1bb6471fe250690409bf4cf0f0df4baa110866ce4716c35c498278e7d.jpg) +(a) Atrial fibrillation (AF) + +![](images/74f6ec4588052484739664f4fba9824260b1c83f2bd5aeec83405a9aceb49f8d.jpg) +(b) T wave abnormal (TAb) + +![](images/b94e731f706dbabb003e096860320daacbba54286b1dd9eb34bc8aab214b3990.jpg) +(c) Q wave abnormal (QAb) + +![](images/9649bb62589fda5c7ef1a6d3e9ec2019aacde4cdd94159bea95f876d9e75e243.jpg) +(d) Left axis deviation (LAD) + +![](images/0eaedac5bd779f95f025a4d90b31327556329be6705c0b78f8590a41722a2984.jpg) +(e) Sinus arrhythmia (SA) + +![](images/0d0d9a0f52a44cd1cfa0bc9cdb1ee3799e58045a3baaa384ac18ebbf02cc8014.jpg) +(f) Ventricular premature beats (VPB) +Figure 2. ROC curves of the 6 diagnosis classes evaluated on the test-set. The orange curve at each subfigure corresponds to the results on the complete 12-lead test-set. The other curves correspond to a corrupted 12-lead test which was reconstructed either by our approach via Koopman operators (Section 3.3) or by the baseline (Zhou et al., 2019). + +training on using computer-generated ECGs is needed and should be further explored. Overall, the $F_{1}$ score with the reconstruction is considerably higher than without. + +# 6. Conclusions + +To reduce the time between cardiac symptoms onset and treatment, wearable ECG sensors were developed to allow for the recording of the full 12-lead ECG signal at home. To rely on such sensors for clinical interpretation, each lead measurement must be well grounded. However, it is enough for one lead not to be well-positioned on the body for the entire lead signal to be corrupt. This has prevented the wider usage of those sensors from home. In this work, we presented a methodology to reconstruct missing or noisy leads using the theory of Koopman Operators. To the best of our knowledge, this is one of the first applications of this theory for a large-scale machine-learning real-life application. We learn the dynamical system describing the evolution of the 12 individual signals together in time. Koopman theory + +allows us a linear structure: the signal of interest can be embedded in a high-dimensional space in which the operator which propagates from one time instant to the next is linear. Learning the dynamical system is therefore equivalent to learning both the mapping to this embedding space, as well as the corresponding linear operator and then solving a least squares system in the embedding space. An additional key benefit of this system is its ability to reconstruct any number of corrupted leads without the need to retrain a machine learning model. We empirically show that our reconstruction error is rather small and that classifiers trained on 12-leads ECGs perform well in the presence of reconstructed leads. A small-scale clinical experiment shows the value of presenting the reconstructed leads to a clinician during diagnosis. The results are staggering – the recall of a severe abnormality rises from $60\%$ to $100\%$ with a tolerable number of false positives. For future work, we plan to expand the clinical trial and to better understand how to best present the reconstructed leads to humans for better benefit of diagnosis. + +# References + +Alday, E. A. P., Gu, A., Shah, A. J., Robichaux, C., Wong, A.-K. I., Liu, C., Liu, F., Rad, A. B., Elola, A., Seyedi, S., et al. Classification of 12-lead ecg: the physionet/computing in cardiology challenge 2020. Physiological measurement, 41(12):124003, 2020. +Atoui, H., Fayn, J., and Rubel, P. A neural network approach for patient-specific 12-lead ecg synthesis in patient monitoring environments. In Computers in Cardiology, 2004, pp. 161-164. IEEE, 2004. +Attia, Z. I., Kapa, S., Lopez-Jimenez, F., McKie, P. M., Ladewig, D. J., Satam, G., Pellikka, P. A., Enriquez-Sarano, M., Noseworthy, P. A., Munger, T. M., et al. Screening for cardiac contractile dysfunction using an artificial intelligence-enabled electrocardiogram. Nature medicine, 25(1):70-74, 2019. +Brunton, S. L., Proctor, J. L., and Kutz, J. N. Discovering governing equations from data by sparse identification of nonlinear dynamical systems. Proceedings of the national academy of sciences, 113(15):3932-3937, 2016. +Budisic, M., Mohr, R., and Mezić, I. Applied koopmanism. Chaos: An Interdisciplinary Journal of Nonlinear Science, 22(4):047510, 2012. +DiMarco, J. P. and Philbrick, J. T. Use of ambulatory electrocardiographic (holter) monitoring. Annals of internal medicine, 113(1):53-68, 1990. +Erichson, N. B., Muehlebach, M., and Mahoney, M. W. Physics-informed autoencoders for lyapunov-stable fluid flow prediction. arXiv preprint arXiv:1905.10866, 2019. +Frank, E. An accurate, clinically practical system for spatial vectorcardiography. circulation, 13(5):737-749, 1956. +Golany, T., Freedman, D., and Radinsky, K. SimGANs: Simulator-based generative adversarial networks for ECG synthesis to improve deep ECG classification. In Proceedings of the International Conference on Machine Learning (ICML), 2020. +Golany, T., Freedman, D., and Radinsky, K. ECG ODEGAN: Learning ordinary differential equations of ECG dynamics via generative adversarial learning. In Proceedings of the AAAI Conference on Artificial Intelligence, 2021. +He, K., Zhang, X., Ren, S., and Sun, J. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 770-778, 2016. + +Koopman, B. and Neumann, J. v. Dynamical systems of continuous spectra. Proceedings of the National Academy of Sciences of the United States of America, 18(3):255, 1932. +Koopman, B. O. Hamiltonian systems and transformation in hilbert space. Proceedings of the national academy of sciences of the united states of America, 17(5):315, 1931. +Laguna, P., Thakor, N. V., Caminal, P., Jane, R., Yoon, H.-R., De Luna, A. B., Marti, V., and Guindo, J. New algorithm for qt interval analysis in 24-hour holter ecg: performance and applications. Medical and Biological Engineering and Computing, 28(1):67-73, 1990. +Levenberg, K. A method for the solution of certain nonlinear problems in least squares. Quarterly of applied mathematics, 2(2):164-168, 1944. +Lusch, B., Kutz, J. N., and Brunton, S. L. Deep learning for universal linear embeddings of nonlinear dynamics. Nature communications, 9(1):1-10, 2018. +Malik, M. and Camm, A. J. Heart rate variability. Clinical cardiology, 13(8):570-576, 1990. +Mardt, A., Pasquali, L., Wu, H., and Noé, F. Vampnets for deep learning of molecular kinetics. Nature communications, 9(1):1-11, 2018. +Maron, B. J., Friedman, R. A., Kligfield, P., Levine, B. D., Viskin, S., Chaitman, B. R., Okin, P. M., Saul, J. P., Salberg, L., Van Hare, G. F., et al. Assessment of the 12-lead ecg as a screening test for detection of cardiovascular disease in healthy general populations of young people (12–25 years of age) a scientific statement from the american heart association and the american college of cardiology. Circulation, 130(15):1303–1334, 2014. +McSharry, P. E., Clifford, G. D., Tarassenko, L., and Smith, L. A. A dynamical model for generating synthetic electrocardiogram signals. IEEE transactions on biomedical engineering, 50(3):289-294, 2003. +Mezić, I. Spectral properties of dynamical systems, model reduction and decompositions. Nonlinear Dynamics, 41 (1):309-325, 2005. +Mezić, I. Analysis of fluid flows via spectral properties of the koopman operator. Annual Review of Fluid Mechanics, 45:357-378, 2013. +Mezić, I. and Banaszuk, A. Comparison of systems with complex behavior. Physica D: Nonlinear Phenomena, 197(1-2):101-133, 2004. +Nelwan, S. Evaluation of 12-Lead Electrocardiogram Reconstruction Methods for Patient Monitoring. PhD thesis, Erasmus University Rotterdam, 2005. + +Pan, S. and Duraisamy, K. Physics-informed probabilistic learning of linear embeddings of nonlinear dynamics with guaranteed stability. SIAM Journal on Applied Dynamical Systems, 19(1):480-509, 2020. +Ribeiro, A. H., Ribeiro, M. H., Paixão, G. M., Oliveira, D. M., Gomes, P. R., Canazart, J. A., Ferreira, M. P., Andersson, C. R., Macfarlane, P. W., Meira Jr, W., et al. Automatic diagnosis of the 12-lead ecg using a deep neural network. Nature communications, 11(1):1-9, 2020. +Roth, G. A., Abate, D., Abate, K. H., Abay, S. M., Abbafati, C., Abbasi, N., Abbastabar, H., Abd-Allah, F., Abdela, J., Abdelalim, A., et al. Global, regional, and national age-sex-specific mortality for 282 causes of death in 195 countries and territories, 1980–2017: a systematic analysis for the global burden of disease study 2017. The Lancet, 392(10159):1736–1788, 2018. +Rowley, C. W., MEZI?, I., Bagheri, S., Schlatter, P., Henningson, D., et al. Spectral analysis of nonlinear flows. Journal of fluid mechanics, 641(1):115-127, 2009. +Scherer, J. A., Jenkins, J. M., and Nicklas, J. M. Synthesis of the 12-lead electrocardiogram from a 3-lead subset using patient-specific transformation vectors: an algorithmic approach to computerized signal synthesis. Journal of electrocardiology, 22, 1989. +Schmid, P. J. Dynamic mode decomposition of numerical and experimental data. Journal of fluid mechanics, 656: 5-28, 2010. +Steinhubl, S. R., Waalen, J., Edwards, A. M., Ariniello, L. M., Mehta, R. R., Ebner, G. S., Carter, C., Baca-Motes, K., Felicione, E., Sarich, T., et al. Effect of a home-based wearable continuous ecg monitoring patch on detection of undiagnosed atrial fibrillation: the mstops randomized clinical trial. Jama, 320(2):146-155, 2018. +Takeishi, N., Kawahara, Y., and Yairi, T. Learning koopman invariant subspaces for dynamic mode decomposition. arXiv preprint arXiv:1710.04340, 2017. +Wehmeyer, C. and Noé, F. Time-lagged autoencoders: Deep learning of slow collective variables for molecular kinetics. The Journal of chemical physics, 148(24):241703, 2018. +Yeung, E., Kundu, S., and Hodas, N. Learning deep neural network representations for koopman operators of nonlinear dynamical systems. In 2019 American Control Conference (ACC), pp. 4832-4839. IEEE, 2019. +Zhang, Q. and Frick, K. All-ecg: A least-number of leads ecg monitor for standard 12-lead ecg tracking during motion. In 2019 IEEE Healthcare Innovations and Point of Care Technologies,(HI-POCT), pp. 103-106. IEEE, 2019. + +Zhou, W., Xing, Y., Liu, N., Movahedipour, M., Zhou, X.-g., et al. A novel method based on convolutional neural networks for deriving standard 12-lead ceg from serial 3-lead ceg. Frontiers of Information Technology & Electronic Engineering, 20(3):405-413, 2019. \ No newline at end of file diff --git a/12leadecgreconstructionviakoopmanoperators/images.zip b/12leadecgreconstructionviakoopmanoperators/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..c11a1d95e41ff324a4f50de41480f98286b09abc --- /dev/null +++ b/12leadecgreconstructionviakoopmanoperators/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:28e4093b6bb6ebfcddc5504aae6b43f32bc5ced7d34fb71f5ea6bf4f5b9b57f6 +size 363903 diff --git a/12leadecgreconstructionviakoopmanoperators/layout.json b/12leadecgreconstructionviakoopmanoperators/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..8aece36719be23b31aa2b2cbbeb890fd50775bf2 --- /dev/null +++ b/12leadecgreconstructionviakoopmanoperators/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6e9f20c15e55fb07dc3c21a69fb6c1d01734eaae0bd7aad116055f8250af0d7e +size 403815 diff --git a/1bitadamcommunicationefficientlargescaletrainingwithadamsconvergencespeed/c5313d4b-2a3b-434e-8a6a-a07cba185dcd_content_list.json b/1bitadamcommunicationefficientlargescaletrainingwithadamsconvergencespeed/c5313d4b-2a3b-434e-8a6a-a07cba185dcd_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..5dd1a155aa7d27a897a3b8887f88eea0ee45943e --- /dev/null +++ b/1bitadamcommunicationefficientlargescaletrainingwithadamsconvergencespeed/c5313d4b-2a3b-434e-8a6a-a07cba185dcd_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d27fd183acdf96301958b78519331544fb0ef05cdb119cfa76d7d2d1b9a1ad4f +size 89367 diff --git a/1bitadamcommunicationefficientlargescaletrainingwithadamsconvergencespeed/c5313d4b-2a3b-434e-8a6a-a07cba185dcd_model.json b/1bitadamcommunicationefficientlargescaletrainingwithadamsconvergencespeed/c5313d4b-2a3b-434e-8a6a-a07cba185dcd_model.json new file mode 100644 index 0000000000000000000000000000000000000000..3c882e77a6acf6c17ac35ca76e69057a519c1a7a --- /dev/null +++ b/1bitadamcommunicationefficientlargescaletrainingwithadamsconvergencespeed/c5313d4b-2a3b-434e-8a6a-a07cba185dcd_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d89ce40fca562033198b89f6fa8082bc9d980ddfc35715158f1d9d551ac88ba0 +size 115151 diff --git a/1bitadamcommunicationefficientlargescaletrainingwithadamsconvergencespeed/c5313d4b-2a3b-434e-8a6a-a07cba185dcd_origin.pdf b/1bitadamcommunicationefficientlargescaletrainingwithadamsconvergencespeed/c5313d4b-2a3b-434e-8a6a-a07cba185dcd_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..caf40d91665c92b487b4e43f6edf4bf4c9d322f3 --- /dev/null +++ b/1bitadamcommunicationefficientlargescaletrainingwithadamsconvergencespeed/c5313d4b-2a3b-434e-8a6a-a07cba185dcd_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:61fb7e928793645b082058cea74d55448eb5046a90768131d8894e8de1ae2aa6 +size 3028748 diff --git a/1bitadamcommunicationefficientlargescaletrainingwithadamsconvergencespeed/full.md b/1bitadamcommunicationefficientlargescaletrainingwithadamsconvergencespeed/full.md new file mode 100644 index 0000000000000000000000000000000000000000..58cec9b88643a578e13fcad733902e41b83ae330 --- /dev/null +++ b/1bitadamcommunicationefficientlargescaletrainingwithadamsconvergencespeed/full.md @@ -0,0 +1,397 @@ +# 1-bit Adam: Communication Efficient Large-Scale Training with Adam's Convergence Speed + +Hanlin Tang $^{12}$ Shaoduo Gan $^{3}$ Ammar Ahmad Awan $^{1}$ Samyam Rajbhandari $^{1}$ Conglong Li $^{1}$ Xiangru Lian $^{2}$ Ji Liu $^{2}$ Ce Zhang $^{3}$ Yuxiong He $^{1}$ + +# Abstract + +Scalable training of large models (like BERT and GPT-3) requires careful optimization rooted in model design, architecture, and system capabilities. From a system standpoint, communication has become a major bottleneck, especially on commodity systems with standard TCP interconnects that offer limited network bandwidth. Communication compression is an important technique to reduce training time on such systems. One of the most effective methods is error-compensated compression, which offers robust convergence speed even under 1-bit compression. However, state-of-the-art error compensation techniques only work with basic optimizers like SGD and Momentum SGD, which are linearly dependent on the gradients. They do not work with non-linear gradient-based optimizers like Adam, which offer state-of-the-art convergence efficiency and accuracy for models like BERT. In this paper, we propose 1-bit Adam that reduces the communication volume by up to $5 \times$ , offers much better scalability, and provides the same convergence speed as uncompressed Adam. Our key finding is that Adam's variance (non-linear term) becomes stable during training, hence we can run Adam in the beginning (warmup phase) and use it as a precondition for Momentum SGD during the rest of the training (compression phase). Experiments on up to 256 GPUs show that 1-bit Adam enables up to $3.3 \times$ higher throughput for BERT-Large pre-training and up to $2.9 \times$ higher throughput for SQuAD fine-tuning. In addition, we provide theoretical analysis for our proposed work. + +# 1. Introduction + +Modern advancement of machine learning is heavily driven by the advancement of computational power and techniques. Nowadays, it is not unusual to train a single model using hundreds of computational devices such as GPUs. As a result, scaling up training algorithms in the distributed setting has attracted intensive interests over the years. One important direction is communication efficient distributed training, which enhances the scalability of the training system by reducing the communication cost. Example techniques include quantization (Zhang et al., 2017; Wangni et al., 2018), decentralization (Lian et al., 2017; Koloskova* et al., 2020; Li et al., 2018), and asynchronous communication (Zheng et al., 2016; Chaturapruek et al., 2015). + +One widely used strategy for alleviating the communication overhead is gradient compression. Before communication, the original gradient $\pmb{g}$ will be compressed into $\mathcal{C}_{\omega}[g]$ , where $\mathcal{C}_{\omega}[\cdot]$ is the compress operator1. As a result the communication volume could be greatly reduced. However, this gradient compression could slow down the convergence speed because important information might get lost during the compression. To recover this information lost, error-compensated compression strategy was proposed: Instead of compressing the gradient at $t$ -th iteration directly, we would first add back the compression error from the last step and then do the compression. Recent studies (Stich et al., 2018) observed that by using error-compensated compression, the asymptotic convergence speed remains unchanged for SGD even using 1-bit compression. + +On the other hand, many state-of-the-art models have to be trained using a more complicated variant, Adam (Kingma and Ba, 2014). For example, to train models such as BERT, one has to resort to the Adam optimizer, since training it with vanilla/momentum SGD has been shown to be less effective. Unfortunately, we find that error-compensated compression does not work for Adam, because Adam is non-linearly dependent on the gradient which affects the error compensation mechanism (see Section 3.2 and 4.2 for more details). + +In this paper, we first analyze the limitation of directly applying existing compression technique to Adam. One of our key findings is that Adam's variance (the non-linear term) becomes stable at early stage of training (Section 3.3). This motivates us to design a new 2-stage algorithm, 1-bit Adam, which uses Adam (warmup stage) to "pre-condition" a communication compressed momentum SGD algorithm (compression stage). We provide theoretical analysis on communication compressed momentum SGD, which is the core component of 1-bit Adam. We design a custom collective primitive using MPI to transfer the $5 \times$ communication volume reduction (achieved by our algorithm) into actual runtime speedup, which is hard to accomplish using existing DL framework libraries. Experiments with BERT-Base, BERT-Large, SQuAD 1.1 and ResNet-18 training tasks on up to 256 GPUs show that 1-bit Adam converges as fast as uncompressed Adam, and runs up to $3.3 \times$ faster than uncompressed algorithms. + +(Contributions) We make the following contributions: + +- We propose a new algorithm, 1-bit Adam, a communication efficient momentum SGD algorithm preconditioned with Adam optimizer, which to the best of our knowledge is the first work that apply a preconditioned strategy for compressed momentum SGD. We present theoretical analysis on the convergence of 1-bit Adam, and show that it admits the same asymptotic convergence rate as the uncompressed one. +- We conduct experiments on large scale ML tasks that are currently challenging for SGD to train. We show that on both BERT pre-training, SQuAD fine-tuning and ResNet-18, 1-bit Adam is able to achieve the same convergence behaviour and final accuracy as Adam, together with up to $5 \times$ less communication volume and $3.3 \times$ faster end-to-end throughput (including the full-precision warmup stage). To our best knowledge, this is the first distributed learning algorithm with communication compression that can train a model as demanding as BERT. +- We implement a custom collective communication primitive using Message Passing Interface (MPI) to provide a scalable and efficient communication system for 1-bit Adam. +- The 1-bit Adam optimizer and the communication primitive backend have been open sourced in a deep learning optimization library called DeepSpeed $^2$ . + +# 2. Related Work + +Communication-efficient distributed learning: To further reduce the communication overhead, one promising + +direction is to compress the variables that are sent between different workers (Yu et al., 2019; Ivkin et al., 2019). Previous work has applied a range of techniques such as quantization, sparsification, and sketching (Alistarh et al., 2017; Agarwal et al., 2018; Spring et al., 2019; Ye and Abbe, 2018; Shi et al., 2021). The compression is mostly assumed to be unbiased (Wangni et al., 2018; Shen et al., 2018; Zhang et al., 2017; Wen et al., 2017; Jiang and Agrawal, 2018). A general theoretical analysis of centralized compressed parallel SGD can be found in Alistarh et al. (2017). Beyond this, some biased compressing methods are also proposed and proven to be quite efficient in reducing the communication cost. One example is the 1-bit SGD (Seide et al., 2014), which compresses the entries in gradient vector into $\pm 1$ depends on its sign. The theoretical guarantee of this method is given in Bernstein et al. (2018). + +Error-compensated compression: The idea of using error compensation for compression is proposed in Seide et al. (2014), where they find that by using error compensation the training could still achieve a very good speed even using 1-bit compression. Recent study indicates that this strategy admits the same asymptotic convergence rate as the uncompressed one (Stich et al., 2018), which means that the influence of compression is trivial. More importantly, by using error compensation, it has been proved that we can use almost any compression methods (Stich et al., 2018), whereas naive compression could only converge when the compression is unbiased (the expectation of the compressed tensor is the same as the original). This method can be combined with decentralized training (Vogels et al., 2020), local SGD (Xie et al., 2020), accelerated algorithms (Gorbunov et al., 2020). Due to the promising efficiency of this method, error compensation has been applied into many related area (Zheng et al., 2019; Phuong and Phong, 2020; Yu et al., 2019; Shi et al., 2019; Ivkin et al., 2019; Sun et al., 2019; Basu et al., 2019; Vogels et al., 2019) in order to reduce the communication cost. + +Adam: Adam (Kingma and Ba, 2015) has shown promising speed for many deep learning tasks, and also admits a very good robustness to the choice of the hyper-parameters, such as learning rate. It can be viewed as an adaptive method that scales the learning rate with the magnitude of the gradients on each coordinate when running SGD. Beyond Adam, many other strategies that share the same idea of changing learning rate dynamically was studied. For example, Duchi et al. (2011) (Adagrad) and (Tieleman and Hinton, 2011) (RMSprop), use the gradient, instead of momentum, for updating the parameters; Adadelta (Zeiler, 2012) changes the variance term of Adam into a non-decreasing updating rule; Luo et al. (2019) proposed AdaBound that gives both upper bound and lower bound for the variance term. In Alacaoglu et al. (2020); Liu et al. (2020) authors + +develop a novel analysis for the convergence rate of Adam. + +# 3. Motivation and Insights + +# 3.1. Communication overhead affects the efficiency of distributed training + +To demonstrate the opportunity for communication compression, we conduct performance profiling experiments that measures the impact of communication time with respect to the total training time per step. Here we use BERT-Large pre-training task as an example (sequence length 128, detailed training parameters can be found at Section 7.1), since BERT and transformer models in general are the state-of-the-art approaches in natural language processing and many other areas. We evaluate two different kinds of clusters: the first cluster has 4 NVIDIA Tesla V100 GPUs per node, and different nodes are connected by 40 Gigabit Ethernet (effective bandwidth is 4.1 Gbps based oniperf benchmark); the second cluster has 8 V100 GPUs per node, and different nodes are connected by 100 Gigabit InfiniBand EDR (effective bandwidth is close to theoretical peak based on microbenchmark). We perform BERT-Large pre-training using the two clusters with different number of nodes and GPUs, batch sizes, and gradient accumulation steps. And we measure the average latency of forward, backward (allreduce and everything else), and step function calls. Table 1 presents the profiling results. + +Results show that allreduce communication contributes to a great portion of the training time per step, up to $94\%$ and $75\%$ for our experiments on two different kinds of internode networks. As expected, communication overhead is proportionally larger when the number of nodes is larger, when the batch size/gradient accumulation step is smaller, and when the network bandwidth is lower. These are the situations where communication compression could provide the most benefit. + +# 3.2. Basic compression affects Adam's convergence + +Given the great opportunity for communication compression, we investigate whether existing error-compensated gradient compression strategy can be applied to Adam, an important optimization algorithm for large model distributed training. We implement a basic compression strategy for Adam based on the compression-based SGD approach (Stich et al., 2018), where we perform error-compensated 1-bit compression over the gradient, and update both the momentum and variance based on the compressed gradient. We compare the BERT-Large pre-training (sequence length 128) training loss when using vanilla Adam and Adam with our basic compression strategy in Figure 1. + +Results show that basic compression based on existing work + +![](images/23cbcb4615e0154cf3d9e4e4aef455f5b976b23fca0f81b22d58538a52196984.jpg) +Figure 1. Training loss for BERT-Large pre-training using vanilla Adam and Adam with error compensated gradient compression. + +greatly affects the convergence speed for Adam. The main reason is that Adam is non-linearly dependent to the gradients (see Section 4.2 for more details). This motivates us to look for novel compression strategy that overcomes the non-linear gradient dependency challenge, and at the same time achieves the same convergence speed as Adam. + +# 3.3. Adam's variance becomes stable during training + +Unlike SGD, which directly uses the gradient $\pmb{g}$ to update the model $\pmb{x}$ , Adam uses two auxiliary variables $m$ and $v$ for the update. The mathematical updating rule of original Adam can be summarized as: + +$$ +\boldsymbol {m} _ {t + 1} = \beta_ {1} \boldsymbol {m} _ {t} + (1 - \beta_ {1}) \boldsymbol {g} _ {t} +$$ + +$$ +\boldsymbol {v} _ {t + 1} = \beta_ {2} \boldsymbol {v} _ {t} + (1 - \beta_ {2}) (\boldsymbol {g} _ {t}) ^ {2}, \tag {1} +$$ + +$$ +\boldsymbol {x} _ {t + 1} = \boldsymbol {x} _ {t} - \gamma \frac {\boldsymbol {m} _ {t + 1}}{\sqrt {\boldsymbol {v} _ {t + 1}} + \eta} +$$ + +Here $\pmb{x}_t$ is the model at $t$ -iteration, $\pmb{g}_t = \nabla F(\pmb{x}_t; \pmb{\zeta}_t)$ is the stochastic gradient, $\gamma$ is the learning rate, $\eta$ usually is a very small constant, $\beta_1$ and $\beta_2$ are decaying factor that controls the speed of forgetting history information. Notice here we disable the bias correction term in the original Adam, which is consistent with exact optimizer for training BERT (Devlin et al., 2019). + +Here we refer $\pmb{m}_t$ as the momentum term and $\pmb{v}_t$ as the variance term. Notice that when $\pmb{v}_t$ is changed into a constant $\pmb{v}$ , then Adam becomes equivalent to Momentum SGD under a coordinate-dependent learning rate $\frac{\gamma}{\sqrt{\pmb{v} + \eta}}$ . + +To investigate the non-linear gradient dependency challenge, we analyze Adam's variance during BERT-Large pre-training (seqlen 128). At each step, we fuse the variance of all parameters, and calculate the norm of the fused variance. Figure 2 presents this fused variance norm at each step. Results show that the variance norm becomes stable after around $23K$ steps. This motivates our approach 1-bit Adam to "freeze" the Adam variance after it becomes stable, and then use it as a precondition during 1-bit compression stage. + +Table 1. BERT-Large pre-training sequence 128 profiling results. + +
Cluster Network TypeNum. nodeNum. GPUBatch size per GPUBatch sizeGrad accum. stepForward (ms)Backward allreduce (ms)Backward everything else (ms)Step (ms)allreduce%
Ethernet1664164136.652205.8633.6374.9694%
Ethernet1664161024135.712275.4360.8175.5993%
Ethernet16641640964137.802259.36243.7274.9283%
Ethernet83216512137.912173.3560.7175.6393%
Ethernet41616256136.942133.2462.8276.8592%
Ethernet2816128134.951897.2161.2375.2692%
Ethernet141664135.99239.7659.9574.2158%
InfiniBand864164125.36316.1823.2558.4975%
InfiniBand864161024132.81336.4059.9957.7969%
InfiniBand8641640964131.04339.52237.9256.9144%
InfiniBand43216512133.45297.2856.8157.9867%
InfiniBand21616256132.86183.7456.4958.6055%
InfiniBand1816128132.7428.1859.7357.2916%
+ +![](images/f8556787ce485c51c6056156a4ecb00ece4252a8b03f7aabd5240cce1411839f.jpg) +Figure 2. Norm of fused variance for BERT-Large pre-training using vanilla Adam. The y-axis is in log scale. + +# 4. 1-bit Adam Algorithm + +In this section, we start with some background introduction for error compensated compression and why it is incompatible with Adam. Then we give full description of 1-bit Adam. + +Problem setting In this paper, we focus on the following optimization task and rely on the following notions and definitions: + +$$ +\min _ {\boldsymbol {x} \in \mathcal {R} ^ {d}} \quad f (\boldsymbol {x}) = \frac {1}{n} \sum_ {i = 1} ^ {n} \underbrace {\mathbb {E} _ {\zeta^ {(i)} \sim \mathcal {D} _ {i}} F (\boldsymbol {x} ; \zeta^ {(i)})} _ {:= f _ {i} (\boldsymbol {x})}, \tag {2} +$$ + +where $d$ is the dimension of the input model $\pmb{x}$ , $n$ is the number of workers included, $\mathcal{D}_i$ is the data distribution of individual data sample $\zeta^{(i)}$ on the $i$ -th worker, $F(\pmb{x};\zeta)$ is the loss function. + +Notations and definitions Throughout this paper, we use the following notations: + +- $\nabla f(\cdot)$ denotes the gradient of a function $f$ . +- $f^{*}$ denotes the optimal value of the minimization problem (2). +$f_{i}(\pmb {x}):= \mathbb{E}_{\pmb{\zeta}^{(i)}\sim \mathcal{D}_{i}}F(\pmb {x};\pmb{\zeta}^{(i)})$ + +- $\|\cdot\|$ denotes the $\ell_2$ norm for vectors and the spectral norm for matrices. +$\| X\| _A\coloneqq \operatorname {Tr}(X^\top AX).$ +- $C_{\omega}(\cdot)$ denotes the randomized compressing operator. +- $\sqrt{}$ denotes the square root of the argument. In this paper if the argument is a vector, then it returns a vector taking the element-wise square root. +- $(\pmb{x})^2$ denotes the element-wise square operation if $\pmb{x}$ is a vector. +- $\frac{a}{b}$ or $a / b$ denotes the element-wise division operation if both $a$ and $b$ are vectors and their dimension matches. + +# 4.1. Why error compensation works for SGD + +For SGD, since the update is linearly dependent to the gradient, using error compensation could potentially remove the side-effect of the history compression error. The updating rule of vanilla SGD follows + +$$ +\boldsymbol {x} _ {t + 1} = \boldsymbol {x} _ {t} - \gamma \boldsymbol {g} _ {t} = \boldsymbol {x} _ {0} - \gamma \sum_ {s = 0} ^ {t} \boldsymbol {g} _ {s}. \tag {3} +$$ + +When directly compressing the gradient without error compensation, the updating rule becomes + +$$ +\begin{array}{l} \boldsymbol {x} _ {t + 1} = \boldsymbol {x} _ {t} - \gamma C _ {\omega} [ \boldsymbol {g} _ {t} ] = \boldsymbol {x} _ {t} - \gamma (\boldsymbol {g} _ {t} - \boldsymbol {\delta} _ {t}) \\ = \boldsymbol {x} _ {0} - \gamma \sum_ {s = 0} ^ {t} \boldsymbol {g} _ {s} + \underbrace {\gamma \sum_ {s = 0} ^ {t} \boldsymbol {\delta} _ {s}} _ {\text {h i s t o r y c o m p r e s s i o n e r r o r}}. \tag {4} \\ \end{array} +$$ + +As we can see in (4), the history compression error would get accumulated and therefore slow down the convergence rate. Moreover, previous work (Alistarh et al., 2017) indicates that when using biased compression operator, the training convergence cannot be guaranteed. + +Now if we apply error compensation at each compression step, the updating rule becomes + +$$ +\begin{array}{l} \boldsymbol {x} _ {t + 1} = \boldsymbol {x} _ {t} - \gamma C _ {\omega} [ \boldsymbol {g} _ {t} + \boldsymbol {\delta} _ {t - 1} ] = \boldsymbol {x} _ {t} - \gamma (\boldsymbol {g} _ {t} - \underbrace {\boldsymbol {\delta} _ {t} + \boldsymbol {\delta} _ {t - 1}} _ {\text {e r r o r c a n c e l l a t i o n}}) \\ = \boldsymbol {x} _ {0} - \gamma \sum_ {s = 0} ^ {t} \boldsymbol {g} _ {s} + \gamma \sum_ {s = 0} ^ {t} \left(\boldsymbol {\delta} _ {s} - \boldsymbol {\delta} _ {s - 1}\right) \\ = \boldsymbol {x} _ {0} - \gamma \sum_ {s = 0} ^ {t} \boldsymbol {g} _ {s} + \gamma \delta_ {t}. \tag {5} \\ \end{array} +$$ + +This demonstrates that by using error compensation, each step's compression error would get cancelled in the next step instead of getting accumulated over steps. To make the error compensation work correctly, it is necessary that we ensure an error cancellation term $\delta_{t} + \delta_{t - 1}$ in the updating rule. Below we are going to see that this cannot be achieved for Adam. + +# 4.2. Why Adam cannot be combined with error compensation + +As we can see, Adam is non-linearly dependent to the gradient, and this non-linearity is widely believed to be essential for the superiority of Adam. Below we are going to first intuitively explain why error compensation works well for SGD, and then discuss two major reasons why this non-linearity makes Adam incompatible with error compensation. + +Difficulty for estimating the variance term $v$ . Notice that for Adam, it is necessary to communicate the gradient $g_{t}$ or momentum $m_{t}$ , and the variance term can be updated using $g_{t}$ . However, when using error-compensated gradient to update $v_{t}$ , the updating rule follows: + +non-linear error correction + +$$ +\begin{array}{l} \boldsymbol {v} _ {t + 1} = \beta_ {2} \boldsymbol {v} _ {t} + (1 - \beta_ {2}) \left(C _ {\omega} [ \boldsymbol {g} _ {t} + \boldsymbol {\delta} _ {t - 1} ]\right) ^ {2} \\ = \beta_ {2} \boldsymbol {v} _ {t} + (1 - \beta_ {2}) \left(\boldsymbol {g} _ {t} + \boldsymbol {\delta} _ {t - 1} - \boldsymbol {\delta} _ {t}\right) ^ {2} \\ = \beta_ {2} \boldsymbol {v} _ {t} + (1 - \beta_ {2}) (\boldsymbol {g} _ {t}) ^ {2} + \underbrace {\left(\boldsymbol {\delta} _ {t - 1} - \boldsymbol {\delta} _ {t}\right) ^ {2}} \\ + 2 \langle \boldsymbol {g} _ {t}, \boldsymbol {\delta} _ {t - 1} - \boldsymbol {\delta} _ {t} \rangle . \\ \end{array} +$$ + +Here the quadratic term $(\delta_{t-1} - \delta_t)^2$ cannot be cancelled by itself, therefore it will be hard to get an accurate estimation of $\pmb{v}_t$ with history error being cancelled. + +Difficulty for setting the correction factor. Another problem is that for SGD, when applying error compensation under a time varying learning rate $\gamma_{t}$ , we need to compensate the history error using + +$$ +C \left[ \pmb {g} _ {t} + \frac {\gamma_ {t}}{\gamma_ {t - 1}} \pmb {\delta} _ {t - 1} \right], +$$ + +instead of adding back $\delta_{t - 1}$ directly. In this case, if we view $\frac{\gamma}{\sqrt{\pmb{v}_t + \eta}}$ as a coordinate-dependent learning rate, which makes Adam equivalent to Momentum SGD with time-varying learning rate, we need to apply the scale factor according to + +$$ +\boldsymbol {m} _ {t + 1} = C _ {\omega} \left[ \beta_ {1} \boldsymbol {m} _ {t} + (1 - \beta_ {1}) \boldsymbol {g} _ {t} + \frac {\sqrt {\boldsymbol {v} _ {t - 1}} + \eta}{\sqrt {\boldsymbol {v} _ {t}} + \eta} \boldsymbol {\delta} _ {t - 1} \right]. +$$ + +The problem is that we cannot get the value of $v_{t}$ after the compression, which makes it impossible to set the scale factor for error compensation. + +# 4.3. 1-bit Adam + +Based on our findings (Section 3.3) that Adam's variance term becomes stable at an early stage, we propose 1-bit Adam summarized in Algorithm 1. First we use vanilla Adam for a few epochs as a warm-up. After the warm-up stage, the compression stage starts and we stop updating the variance term $v$ and use it as a fixed precondition. At the compression stage, we communicate based on the momentum applied with error-compensated 1-bit compression. The momentum are quantized into 1-bit representation (the sign of each element). Accompanying the vector, a scaling factor is computed as $\frac{\text{magnitude of compensated gradient}}{\text{magnitude of quantized gradient}}$ . This scaling factor ensures that the compressed momentum has the same magnitude as the uncompressed momentum. This 1-bit compression could reduce the $97\%$ communication cost of the original for float32 type training and $94\%$ for float16 type training. + +# 5. Theoretical Analysis + +Notice that for 1-bit Adam, we only use original Adam at warm-up, and then we essentially run error-compensated momentum SGD with coordinate-dependent learning rate $\frac{\gamma}{\sqrt{v_{T_w}}}$ . Therefore here we consider the Adam-based warm-up phase as a way to find a good precondition variance term $v_{T_w}$ to be used in the compression phase. Below we are going to introduce the convergence rate for the compression phase after warm-up. We first introduce some necessary assumptions, then we present the theoretical guarantee of the convergence rate for 1-bit Adam. + +Assumption 1. We make the following assumptions: + +1. Lipschitzian gradient: $f(\cdot)$ is assumed to be with $L$ -Lipschitzian gradients, which means + +$$ +\| \nabla f (\boldsymbol {x}) - \nabla f (\boldsymbol {y}) \| \leq L \| \boldsymbol {x} - \boldsymbol {y} \|, \quad \forall \boldsymbol {x}, \forall \boldsymbol {y}, +$$ + +2. Bounded variance: The variance of the stochastic gradient is bounded + +$$ +\mathbb {E} _ {\boldsymbol {\zeta} ^ {(i)} \sim \mathcal {D} _ {i}} \| \nabla F (\boldsymbol {x}; \boldsymbol {\zeta} ^ {(i)}) - \nabla f (\boldsymbol {x}) \| ^ {2} \leq \sigma^ {2}, \quad \forall \boldsymbol {x}, \forall i. +$$ + +![](images/30588546d8ad34e506530ea2a4138019e8a23a8ab572056b69201b3ef6a9a981.jpg) +(a) Gather step: Each worker sends its $i$ -th chunk to worker $i$ . + +![](images/0ded4028ae35734b76e1b313d7d30b5f2e3f6fa0c8dcb42990d0411a7d0856ac.jpg) +(b) Average step: Each worker averages all chunks it receives. + +![](images/2e2c80dc54464aa61ac371db3ee2aceb04d5be521eb2c48d947005f4b230888d.jpg) +(c) Scatter step: Each worker receives the $i$ -th chunk from worker $i$ . +Figure 3. Efficient system design for communication (compressed_allreduce) + +# Algorithm 1 1-bit Adam + +1: Initialize: $\pmb{x}_0$ , learning rate $\gamma$ , initial error $\delta = 0$ , $m_0 = 0$ , $\pmb{v}_0 = \mathbf{0}$ , number of total iterations $T$ , warm-up steps $T_w$ , two decaying factor $\beta_1, \beta_2$ and $\eta$ for Adam. +2: Running the original Adam for $T_{w}$ steps, then store the variance term (defined as $\mathbf{v}_t$ in (1)) $\mathbf{v}_{T_w}$ . +3: for $t = T_w, \dots, T$ do +4: (On $i$ -th node) +5: Randomly sample $\boldsymbol{\zeta}_t^{(i)}$ and compute local stochastic gradient $\pmb{g}_t^{(i)}\coloneqq \nabla F_i(\pmb{x}_t^{(i)},\pmb{\zeta}_t^{(i)})$ +6: Update the local momentum variable $\pmb{m}_{t-1}$ according to $\pmb{m}_t^{(i)} = \beta_1 \pmb{m}_{t-1} + (1 - \beta_1) \pmb{g}_t^{(i)}$ . +7: Compress $\pmb{m}_t^{(i)}$ into $\hat{\pmb{m}}_t^{(i)} = C_\omega \left[\pmb{m}_t^{(i)} + \pmb{\delta}_{t - 1}^{(i)}\right]$ , and update the compression error by $\delta_t^{(i)} = \pmb{m}_t^{(i)} + \pmb{\delta}_{t - 1}^{(i)} - \hat{\pmb{m}}_t^{(i)}$ . +8: Send the $\hat{m}_t^{(i)}$ to the server. +9: (On server) +10: Take the average over all $\hat{\pmb{m}}_t^{(i)}$ it receives and compress it into $\overline{\pmb{m}}_t = C_\omega \left[\frac{1}{n}\sum_{i=1}^n\hat{\pmb{m}}_t^{(i)} + \overline{\delta}_{t-1}\right]$ , and update the compression error accordingly by $\overline{\delta}_t = \frac{1}{n}\sum_{i=1}^n\hat{\pmb{m}}_t^{(i)} + \overline{\delta}_{t-1} - \overline{\pmb{m}}_t$ . +11: Send $\overline{m}_t$ to all the workers. +12: (On $i$ -th node) +13: Set $\pmb{m}_t = \overline{\pmb{m}}_t$ , and update local model $\pmb{x}_{t+1} = \pmb{x}_t - \gamma \pmb{m}_t / \sqrt{\pmb{v}_{Tw}}$ . +14: end for +15: Output: $x$ . + +3. Bounded magnitude of error for $\mathcal{C}_{\omega}[\cdot]$ : The magnitude of worker's local errors $\delta_t^{(i)}$ and the server's global error $\overline{\delta}_t$ , are assumed to be bounded by a constant $\epsilon$ + +$$ +\sum_ {k = 1} ^ {n} \mathbb {E} _ {\omega} \left\| \boldsymbol {\delta} _ {t} ^ {(i)} \right\| \leq \frac {\epsilon}{2}, \quad \sum_ {i = 1} ^ {n} \mathbb {E} _ {\omega} \left\| \overline {{\boldsymbol {\delta}}} _ {t} \right\| \leq \frac {\epsilon}{2}, \quad \forall t, \forall i. +$$ + +Next we present the main theorem for 1-bit Adam. + +Theorem 1. Under Assumption 1, for 1-bit Adam, we have + +the following convergence rate + +$$ +\begin{array}{l} \left(1 - \frac {\gamma L}{v _ {\operatorname* {m i n}}} - \frac {2 \gamma^ {2} L ^ {2}}{(1 - \beta) ^ {2} v _ {\operatorname* {m i n}} ^ {2}}\right) \sum_ {t = 0} ^ {T} \mathbb {E} \| \nabla f (\boldsymbol {x} _ {t}) \| _ {V} ^ {2} \\ \leq \frac {2 \mathbb {E} f (\boldsymbol {x} _ {0}) - 2 f (\boldsymbol {x} ^ {*})}{\gamma} + \frac {6 \gamma^ {2} L ^ {2} \epsilon^ {2} T}{(1 - \beta) ^ {2} v _ {\min } ^ {3}} + \\ \frac {L \gamma \sigma^ {2} T}{n v _ {\min }} + \frac {2 \gamma^ {2} L ^ {2} \sigma^ {2} T}{n (1 - \beta) ^ {2} v _ {\min } ^ {2}}, \tag {6} \\ \end{array} +$$ + +where $V = \text{diag}\left(1 / \pmb{v}_{T_w}^{(1)}, 1 / \pmb{v}_{T_w}^{(2)}, \dots, 1 / \pmb{v}_{T_w}^{(d)}\right)$ is a diagonal matrix spanned by $\pmb{v}_{T_w}$ and $v_{\min} = \min \{\pmb{v}_{T_w}^{(1)}, \pmb{v}_{T_w}^{(2)}, \dots, \pmb{v}_{T_w}^{(d)}\}$ is the minimum value in $\pmb{v}_{T_w}$ + +Given the generic result in Theorem 1, we obtain the convergence rate for 1-bit Adam with appropriately chosen learning rate $\gamma$ . + +Corollary 1. Under Assumption 1, for 1-bit Adam, choosing $\gamma = \frac{1}{4L(v_{\mathrm{min}})^{-1} + \sigma\sqrt{\frac{T}{n}} + \epsilon^{\frac{2}{3}}T^{\frac{1}{3}}(v_{\mathrm{min}})^{-1}}$ , we have the following convergence rate + +$$ +\frac {1}{T v _ {\min }} \sum_ {t = 0} ^ {T - 1} \mathbb {E} \| \nabla f (\boldsymbol {x} _ {t}) \| _ {V} ^ {2} \lesssim \frac {\sigma}{\sqrt {n T}} + \frac {\epsilon^ {\frac {2}{3}}}{T ^ {\frac {2}{3}}} + \frac {1}{T}, +$$ + +where we treat $f(\pmb{x}_1) - f^*, \beta$ and $L$ as constants. + +This result suggests that: 1-bit Adam essentially admits the same convergence rate as distributed SGD in the sense that both of them admit the asymptotical convergence rate $O(1 / \sqrt{nT})$ , which means we can still achieve linear speedup w.r.t. the number of workers $n$ . + +# 6. Efficient system design for compressed communication + +NVIDIA NCCL is an efficient and widely used communication library that has been tightly integrated in DL frameworks like PyTorch and TensorFlow. However, NCCL library cannot be used directly for performing communication based on 1-bit compression. This is because the collective communication primitives like Allreduce and Allgather are at a higher level of abstraction and can only perform data movement and/or simple operations like sum, min, max etc. + +In addition, NCCL library (before v2.7) did not expose either an Alltoall primitive or any point-to-point (send/recv) communication primitives that can be used to implement an Alltoall. Thus for 1-bit Adam, we designed a custom collective primitive using Message Passing Interface (MPI). We call it "compressed allreduce" and it has three phases as shown in Figure 3: 1) The gather step, which we have implemented using the MPI_Alltoall (personalized exchange) primitive, 2) The average step, where 1-bit Adam computes the average of compressed local momentums, and 3) The scatter step, which we implement using MPI_Allgather. We develop two versions of compressed allreduce: 1) CUDA-Aware version that exploits GPUDirect features and requires CUDA-Aware libraries like MVAPICH2-GDR and 2) Basic version that can be used with any MPI library but copies data between GPU and CPU buffers. The CUDA-Aware version works only on systems with InfiniBand whereas the basic version can run on any system with Ethernet interconnect. + +# 7. Experiments + +We evaluate 1-bit Adam and existing approaches using BERT-Base, BERT-Large, SQuAD 1.1 and ResNet training tasks on up to 256 GPUs. We show that 1-bit Adam converges as fast as uncompressed Adam, and runs up to 3.3 times faster than uncompressed algorithms under limited bandwidth. + +# 7.1. BERT pre-training and fine-tuning + +Dataset and models We evaluate the convergence and performance of 1-bit Adam and uncompressed Adam for BERT-Base ( $L = 12$ , $H = 768$ , $A = 12$ , $110M$ params) and BERT-Large ( $L = 24$ , $H = 1024$ , $A = 16$ , $340M$ params) pre-training tasks. We use the same dataset as Devlin et al. (2019), which is a concatenation of Wikipedia and BooksCorpus with $2.5B$ and $800M$ words respectively. We use the GLUE fine-tuning benchmark(Wang et al., 2018) to evaluate the convergence of the BERT models trained by Adam and 1-bit Adam. + +In addition, we also evaluate the convergence and performance of 1-bit Adam for SQuAD 1.1 fine-tuning task using a pre-trained BERT model checkpoint from HuggingFace4. + +Hardware For all experiments in this Section 7.1 we use the two clusters described in Section 3.1. We use up to 256 GPUs for pre-training tasks and up to 32 GPUs for fine-tuning tasks. + +Training parameters For BERT pre-training, the learning rate linearly increases to $4 \times 10^{-4}$ as a warmup in the + +Table 2. Number of steps for BERT pre-training tasks. + +
Seqlen 128 (warmup)Seqlen 512 (warmup)
BERT-Base Adam118K (N/A)22K (N/A)
BERT-Base 1-bit Adam118K (16K)22K (1.5K)
BERT-Large Adam152K (N/A)10K (N/A)
BERT-Large 1-bit Adam152K (23K)10K (1.5K)
+ +first $12.5K$ steps, then decays into 0.99 of the original after every 520 steps. We set the two parameters in Algorithm 1 as $\beta_{1} = 0.9$ and $\beta_{2} = 0.999$ for 1-bit Adam and Adam. For convergence test, we set total batch size as $4K$ for BERT-Base and BERT-Large. For performance test, we test different batch sizes. Table 2 summarizes the total number of steps for BERT sequence length 128 and 512 phases, together with the number of warmup steps for 1-bit Adam. We manually tuned the number of warmup steps for 1-bit Adam evaluations. On the other hand, we find that this configuration can be auto-tuned: First, the number of 1-bit Adam warmup steps should be no less than the number of learning rate warmup steps, since Adam's variance term is unstable during LR warmup. Second, we find that the ratio $\frac{\|\pmb{v}_t\|_1}{\|\pmb{v}_{t - \Delta}\|_1}$ (where $\| \cdot \| _1$ is the $l_{1}$ norm of the vector and we set $\Delta = \frac{1}{1 - \beta_2}$ ) is a good indicator of how stable the variance term is. For BERT-Large pre-training seqlen 128, when we set a threshold of $\geq 0.96$ for this ratio, the warmup will stop at step 22173, which is very close to our manually tuned $23K$ warmup steps. + +For GLUE benchmarks we use original Adam optimizer and perform single-task training on the dev set. We search over the hyperparameter space with batch sizes $\in \{8,16\}$ and learning rates $\in \{1\times 10^{-5},3\times 10^{-5},5\times 10^{-5},8\times 10^{-5}\}$ . Other settings are the same as pre-training task. + +For SQuAD fine-tuning we use the same parameters as published by HuggingFace (batch size = 24, learning rate = 3e-5, dropout=0.1, 2 epochs), except that we increase the batch size to 96 (using 32 GPUs). The first 400 steps out of total 1848 steps are used as the warmup stage for 1-bit Adam. + +Convergence results Figure 4(a) presents the samplewise convergence results. We use the BertAdam (Devlin et al., 2019) optimizer as the uncompressed baseline. For both BERT-Base and BERT-Large and for both sequence length phases, we find that 1-bit Adam provides the same convergence speed as baseline, while the communication volume is reduced into $6\%$ of the original during the compression stage. + +Table 3 presents the GLUE results using the checkpoints from our pre-training experiments. 1-bit Adam achieves similar accuracy compared to the uncompressed baseline and the numbers reported in previous work. + +For SQuAD 1.1 fine-tuning task using checkpoint from + +Table 3. GLUE development set results. BERT-Base/Large(original) results are from Devlin et al. (2019). BERT-Base/Large (uncompressed) results use the full-precision BertAdam with the same training parameters as the 1-bit Adam case. BERT-Base/Large (compressed) are the results using 1-bit Adam. The scores are the median scores over 10 runs. + +
ModelRTEMRPCCoLASST-2QNLIQQPMNLI-(m/mm)
BERT-Base (original)66.484.852.193.590.589.284.6/83.4
BERT-Base (uncompressed)68.284.856.891.890.990.983.6/83.5
BERT-Base (compressed)69.084.855.691.690.890.983.6/83.9
BERT-Large (original)70.185.460.594.992.789.386.7/85.9
BERT-Large (uncompressed)70.386.060.393.192.291.486.1/86.2
BERT-Large (compressed)70.486.162.093.891.991.585.7/85.4
+ +![](images/6c181d2ad969e4dde2a8ec987589ea1313809c8fee0a93c5b4c19e4804be18bd.jpg) +(a) Sample-wise + +![](images/4c020e7c8f231c7a8566305e5975a1e86bda81160ae81eeec568b6f87a5e275f.jpg) +(b) Time-wise +Figure 4. Sample-wise and time-wise convergence speed for BERT-Large pre-training sequence length 128 using 64 GPUs on the Ethernet cluster. 1-bit Adam and Adam also achieve the same sample-convergence speed for BERT-Base pre-training. + +HuggingFace, 1-bit Adam achieves similar F1 score (93.32) compared to the score reported by HuggingFace (93.33) using same number of samples and training parameters. + +Performance results Computed as $1 / (\text{warmup ratio} + (1 - \text{warmup ratio}) / 16)$ for FP16 training, 1-bit Adam offers up to $5\mathrm{x}$ less end-to-end communication volume for BERT-Base and BERT-Large. This leads to 3.3x higher throughput for BERT-Large sequence length 128 pre-training and up to $2.9\mathrm{x}$ higher throughput for SQuAD fine-tuning. This end-to-end throughput improvement is enabled by the 5.48x (Figure 5(a)) and 6.17x (Figure 5(c)) speedup observed during the compression stage. Figure 5(b) shows that 1-bit Adam also provides better scalability: Adam's throughput reaches peak at 32 GPUs on Ethernet, while 1-bit Adam's throughput keeps increasing until 128 GPUs. It is also worth mentioning that 1-bit Adam on Ethernet (4.1 Gbps effective bandwidth, 4 GPUs per node) is able to achieve comparable throughput as Adam on InfiniBand (near 100 Gbps effective bandwidth, 8 GPUs per node), which demonstrates 1-bit Adam's efficiency considering the hardware differences. + +In Figure 4(b) we also measured the total training time of BERT-Large pre-training seqlen 128 when using batch size $4K$ on 64 GPUs on the Ethernet cluster. It takes 174.3 hours for baseline Adam to complete the training, while 1-bit Adam only needs 51.5 hours. This $3.4\mathrm{x}$ speedup is consistent with the speedup computed based on the throughput analysis above. + +# 7.2. ResNet on CIFAR10 and ImageNet + +To further evaluate the convergence speed of 1-bit Adam and related works, we train CIFAR10 using ResNet-18(He et al., 2016). The dataset has a training set of 50000 images and a test set of 10000 images, where each image is given one of the 10 labels. We run the experiments on 8 1080Ti GPUs where each GPU is used as one worker. The batch size on each worker is 128 and the total batch size is 1024. + +We evaluate five implementations for comparison: 1) Original SGD. 2) Original Adam (Kingma and Ba, 2014). 3) 1-bit Adam where we use 13 out of 200 epochs as warmup. 4) 1-bit Adam (32-bits) where we do not compress the momentum while still freezing the variance. 5) Adam(1-bit Naive) where we compress the gradient instead of momentum, and don't freeze the variance. We set the learning rate as $1 \times 10^{-1}$ for SGD and $1 \times 10^{-4}$ for the other 4 cases. For all five cases, the learning rate is decayed into $10\%$ of the original after every 100 epochs. + +As illustrated in Figure 6, 1-bit Adam achieves similar convergence speed as Adam and 1-bit Adam (32-bits). SGD has a slightly slower convergence speed while Adam(1-bit Naive) is much worse. This and Section 3.2 demonstrate that existing compression method doesn't work for Adam. In the supplementary materials we further compare 1-bit Adam with other related works using ResNet-18. + +Moreover, to see how 1-bit Adam could speedup the training in this case, we report speedup results of training ResNet-152 on ImageNet (Russakovsky et al., 2015) using different numbers of GPUs, in Figure 7. As we can see that 1-bit Adam could potentially speedup the training especially when the bandwidth is limited. + +![](images/de34fec95e378ea0565c12df772e73cfddd0d35213ea37a317b00d50b2495ce5.jpg) +(a) Bert-Large pre-training, batch size $=$ number of GPUs $\times 16$ + +![](images/2cdb0d246db4591934ce5bb4a265686e5ce3a4181a5e590741db34eec3f256ca.jpg) +(b) Bert-Large pre-training, batch size $= 4\mathrm{K}$ + +![](images/5c7777f6c85ffa68591b4ec8ac5b5fa1e6b1fbe32ad7cae1eb89af32aa3b6d7b.jpg) +(c) SQuAD fine-tuning, batch size $=$ number of GPUs $\times 3$ + +![](images/97a3656269b8c2bd36a34ffb3e5073e4d27f596ed4a1e37685a422bab1d03093.jpg) +Figure 5. Scalability of 1-bit Adam for BERT-Large pre-training sequence length 128 and SQuAD 1.1 fine-tuning on V100 GPUs. Adam lines represent the throughput at 1-bit Adam's warmup stage (i.e., baseline Adam's throughput). 1-bit Adam lines represent the throughput at compression stage. Annotations represent the highest speedup achieved in each figure. Note that this is the speedup between warmup and compression stage. The end-to-end speedup also depends on the percentage of warmup. +(a) Training loss + +![](images/7284f6bcdba579f28d44e2130185b601b1191d154886e56e9c54409a8b6ca294.jpg) +(b) Testing accuracy +Figure 8. Comparison of Adam and 1-bit Adam (20% warmup steps) for training Deep Convolutional Generative Adversarial Networks (DCGAN). + +![](images/6d0d156d259c77b0bfcf88755ede04572fa72d44d085a7062c439dd29159d1c4.jpg) +Figure 6. Sample-wise convergence speed for ResNet-18. +Figure 7. Speedup of ResNet-152 on ImageNet. Each server has 8 V100 GPUs interconnected by NVLink, servers are connected by 10Gbits or 1Gbits TCP/IP network. + +# 7.3. Deep Convolutional Generative Adversarial Networks + +To further understand the correctness of 1-bit Adam on more tasks, we apply it to the training of Generative Adversarial Networks (GAN). We choose Deep Convolutional GAN (Radford et al., 2015) as the model, which adopts convolutional and convolutional-transpose layers for the discriminator and generator. We use CelebFaces Attributes Dataset (CelebA) (Liu et al., 2015) as the training data, which contains more than 200K celebrity images. The task is to train the discriminator and generator in an adversarial way, such that the generator can create fake but vivid face images. Figure 8 shows the training loss and generated + +![](images/7030e2599c49e07655f2179ba2037ede78be9753d97aca055dfb5477c308180f.jpg) +(a) Training loss + +![](images/c3ce6fe42b555de7fcce6a4cc458d04cb343dd934d1bde67b396d52a164bafb2.jpg) +(b) Generated ages (Adam) + +![](images/bdc2c364517cd8938184ac11ac4b50c872e8feb5b05e5e2cf01a40c0d5982623.jpg) +(c) Generated images (1-bit Adam) + +images by using original Adam optimizer and 1-bit Adam. The results show that 1-bit Adam can achieve almost the same training accuracy as the Adam optimizer. + +# 8. Conclusions + +In this paper, we propose an error-compensated Adam preconditioned momentum SGD algorithm, 1-bit Adam, which provides both communication efficiency and Adam's convergence speed. Our theoretical analysis demonstrates that 1-bit Adam admits a linear speed w.r.t the number of workers in the network, and is robust to any compression method. We validate the performance of 1-bit Adam empirically on BERT, SQuAD and ResNet training tasks on up to 256 GPUs. Results show that 1-bit Adam converges as fast as uncompressed Adam, reduces communication volume by up to $5\mathrm{x}$ , and runs up to 3.3 times faster than uncompressed algorithms. Beyond those results, it's interesting to see the performance of 1-bit Adam on wider variety of tasks, e.g., reinforcement learning, which we leave for the future work. + +# References + +N. Agarwal, A. T. Suresh, F. X. X. Yu, S. Kumar, and B. McMahan. cpSGD: Communication-efficient and differentially-private distributed SGD. In S. Bengio, H. Wallach, H. Larochelle, K. Grauman, N. Cesa-Bianchi, and R. Garnett, editors, Advances in Neural Information Processing Systems 31, pages 7564-7575. Curran Associates, Inc., 2018. +A. Alacaoglu, Y. Malitsky, P. Mertikopoulos, and V. Cevher. A new regret analysis for adam-type algorithms, 2020. +D. Alistarh, D. Grubic, J. Li, R. Tomioka, and M. Vojnovic. QSGD: Communication-Efficient SGD via gradient quantization and encoding. In I. Guyon, U. V. Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett, editors, Advances in Neural Information Processing Systems 30, pages 1709-1720. Curran Associates, Inc., 2017. +D. Basu, D. Data, C. Karakus, and S. Diggavi. Qsparse-local-sgd: Distributed sgd with quantization, sparsification and local computations. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d Alché-Buc, E. Fox, and R. Garnett, editors, Advances in Neural Information Processing Systems 32, pages 14695-14706. Curran Associates, Inc., 2019. +J. Bernstein, J. Zhao, K. Azizzadenesheli, and A. Anandkumar. signsgd with majority vote is communication efficient and byzantine fault tolerant. 10 2018. +S. Chaturapruek, J. C. Duchi, and C. Ré. Asynchronous stochastic convex optimization: the noise is in the noise and sgd don't care. In C. Cortes, N. D. Lawrence, D. D. Lee, M. Sugiyama, and R. Garnett, editors, Advances in Neural Information Processing Systems 28, pages 1531-1539. Curran Associates, Inc., 2015. +J. Devlin, M.-W. Chang, K. Lee, and K. Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In *NAACL-HLT*, 2019. +J. Duchi, E. Hazan, and Y. Singer. Adaptive subgradient methods for online learning and stochastic optimization. Journal of Machine Learning Research, 12(61):2121-2159, 2011. +E. Gorbunov, D. Kovalev, D. Makarenko, and P. Richtárik. Linearly converging error compensated sgd, 2020. +K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. In 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 770-778, 2016. + +N. Ivkin, D. Rothchild, E. Ullah, V. braverman, I. Stoica, and R. Arora. Communication-efficient distributed sgd with sketching. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d Alché-Buc, E. Fox, and R. Garnett, editors, Advances in Neural Information Processing Systems 32, pages 13144-13154. Curran Associates, Inc., 2019. +P. Jiang and G. Agrawal. A linear speedup analysis of distributed deep learning with sparse and quantized communication. In S. Bengio, H. Wallach, H. Larochelle, K. Grauman, N. Cesa-Bianchi, and R. Garnett, editors, Advances in Neural Information Processing Systems 31, pages 2530-2541. Curran Associates, Inc., 2018. +D. Kingma and J. Ba. Adam: A method for stochastic optimization. International Conference on Learning Representations, 12 2014. +D. P. Kingma and J. Ba. Adam: A method for stochastic optimization. CoRR, abs/1412.6980, 2015. +A. Koloskova*, T. Lin*, S. U. Stich, and M. Jaggi. Decentralized deep learning with arbitrary communication compression. In International Conference on Learning Representations, 2020. +Y. Li, M. Yu, S. Li, S. Avestimehr, N. S. Kim, and A. Schwing. Pipe-sgd: A decentralized pipelined sgd framework for distributed deep net training. In S. Bengio, H. Wallach, H. Larochelle, K. Grauman, N. Cesa-Bianchi, and R. Garnett, editors, Advances in Neural Information Processing Systems 31, pages 8056-8067. Curran Associates, Inc., 2018. +X. Lian, C. Zhang, H. Zhang, C.-J. Hsieh, W. Zhang, and J. Liu. Can decentralized algorithms outperform centralized algorithms? a case study for decentralized parallel stochastic gradient descent. In I. Guyon, U. V. Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett, editors, Advances in Neural Information Processing Systems 30, pages 5330-5340. Curran Associates, Inc., 2017. +R. Liu, T. Wu, and B. Mozafari. Adam with bandit sampling for deep learning, 2020. +Z. Liu, P. Luo, X. Wang, and X. Tang. Deep learning face attributes in the wild. In Proceedings of International Conference on Computer Vision (ICCV), December 2015. +L. Luo, Y. Xiong, and Y. Liu. Adaptive gradient methods with dynamic bound of learning rate. In International Conference on Learning Representations, 2019. +T. T. Phuong and L. T. Phong. Distributed sgd with flexible gradient compression. IEEE Access, 8:64707-64717, 2020. + +A. Radford, L. Metz, and S. Chintala. Unsupervised representation learning with deep convolutional generative adversarial networks. arXiv preprint arXiv:1511.06434, 2015. +O. Russakovsky, J. Deng, H. Su, J. Krause, S. Satheesh, S. Ma, Z. Huang, A. Karpathy, A. Khosla, M. Bernstein, A. C. Berg, and L. Fei-Fei. ImageNet Large Scale Visual Recognition Challenge. International Journal of Computer Vision (IJCV), 115(3):211-252, 2015. doi: 10.1007/s11263-015-0816-y. +F. Seide, H. Fu, J. Droppo, G. Li, and D. Yu. 1-bit stochastic gradient descent and application to data-parallel distributed training of speech dnns. In Interspeech 2014, September 2014. +Z. Shen, A. Mokhtari, T. Zhou, P. Zhao, and H. Qian. Towards more efficient stochastic decentralized learning: Faster convergence and sparse communication. In J. Dy and A. Krause, editors, Proceedings of the 35th International Conference on Machine Learning, volume 80 of Proceedings of Machine Learning Research, pages 4624-4633, Stockholm, Sweden, 10-15 Jul 2018. PMLR. +S. Shi, Q. Wang, K. Zhao, Z. Tang, Y. Wang, X. Huang, and X. Chu. A distributed synchronous sgd algorithm with global top-k sparsification for low bandwidth networks. In 2019 IEEE 39th International Conference on Distributed Computing Systems (ICDCS), pages 2238-2247, 2019. +S. Shi, X. Zhou, S. Song, X. Wang, Z. Zhu, X. Huang, X. Jiang, F. Zhou, Z. Guo, L. Xie, R. Lan, X. Ouyang, Y. Zhang, J. Wei, J. Gong, W. Lin, P. Gao, P. Meng, X. Xu, C. Guo, B. Yang, Z. Chen, Y. Wu, and X. Chu. Towards scalable distributed training of deep learning on public cloud clusters. In Proceedings of Machine Learning and Systems, 2021. +R. Spring, A. Kyrillidis, V. Mohan, and A. Shrivastava. Compressing gradient optimizers via Count-Sketches. Proceedings of the 36th International Conference on Machine Learning, 97:5946-5955, 2019. +S. U. Stich. Local sgd converges fast and communicates little, 2019. +S. U. Stich, J.-B. Cordonnier, and M. Jaggi. Sparsified sgd with memory. In S. Bengio, H. Wallach, H. Larochelle, K. Grauman, N. Cesa-Bianchi, and R. Garnett, editors, Advances in Neural Information Processing Systems 31, pages 4447-4458. Curran Associates, Inc., 2018. +J. Sun, T. Chen, G. Giannakis, and Z. Yang. Communication-efficient distributed learning via lazily aggregated quantized gradients. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d Alché-Buc, E. Fox, and R. Garnett, editors, + +Advances in Neural Information Processing Systems 32, pages 3370-3380. Curran Associates, Inc., 2019. +H. Tang, C. Yu, X. Lian, T. Zhang, and J. Liu. DoubleSqueeze: Parallel stochastic gradient descent with double-pass error-compensated compression. In K. Chaudhuri and R. Salakhutdinov, editors, Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pages 6155-6165, Long Beach, California, USA, 09-15 Jun 2019. PMLR. +T. Tieleman and G. Hinton. Rmsprop: Divide the gradient by a running average of its recent magnitude. COURSERA: Neural networks for machine learning, 2011. +T. Vogels, S. P. Karimireddy, and M. Jaggi. Powersgd: Practical low-rank gradient compression for distributed optimization. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d Alché-Buc, E. Fox, and R. Garnett, editors, Advances in Neural Information Processing Systems 32, pages 14259-14268. Curran Associates, Inc., 2019. +T. Vogels, S. P. Karimireddy, and M. Jaggi. Powergossip: Practical low-rank communication compression in decentralized deep learning, 2020. +A. Wang, A. Singh, J. Michael, F. Hill, O. Levy, and S. Bowman. GLUE: A multi-task benchmark and analysis platform for natural language understanding. In Proceedings of the 2018 EMNLP Workshop BlackboxNLP: Analyzing and Interpreting Neural Networks for NLP, pages 353-355, Brussels, Belgium, Nov. 2018. Association for Computational Linguistics. doi: 10.18653/v1/W18-5446. +J. Wangni, J. Wang, J. Liu, and T. Zhang. Gradient sparsification for Communication-Efficient distributed optimization. In S. Bengio, H. Wallach, H. Larochelle, K. Grauman, N. Cesa-Bianchi, and R. Garnett, editors, Advances in Neural Information Processing Systems 31, pages 1299-1309. Curran Associates, Inc., 2018. +W. Wen, C. Xu, F. Yan, C. Wu, Y. Wang, Y. Chen, and H. Li. Terngrad: Ternary gradients to reduce communication in distributed deep learning. In I. Guyon, U. V. Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett, editors, Advances in Neural Information Processing Systems 30, pages 1509-1519. Curran Associates, Inc., 2017. +C. Xie, S. Zheng, O. Koyejo, I. Gupta, M. Li, and H. Lin. Cser: Communication-efficient sgd with error reset, 2020. +M. Ye and E. Abbe. Communication-Computation efficient gradient coding. Proceedings of the 35th International Conference on Machine Learning, 80:5610-5619, 2018. + +Y. Yu, J. Wu, and L. Huang. Double quantization for communication-efficient distributed optimization. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d Alché-Buc, E. Fox, and R. Garnett, editors, Advances in Neural Information Processing Systems 32, pages 4438-4449. Curran Associates, Inc., 2019. +M. D. Zeiler. ADADELTA: an adaptive learning rate method. CoRR, abs/1212.5701, 2012. +H. Zhang, J. Li, K. Kara, D. Alistarh, J. Liu, and C. Zhang. ZipML: Training linear models with end-to-end low precision, and a little bit of deep learning. In D. Precup and Y. W. Teh, editors, Proceedings of the 34th International Conference on Machine Learning, volume 70 of Proceedings of Machine Learning Research, pages 4035-4043, International Convention Centre, Sydney, Australia, 06-11 Aug 2017. PMLR. +S. Zheng, Q. Meng, T. Wang, W. Chen, N. Yu, Z. Ma, and T. Liu. Asynchronous stochastic gradient descent with delay compensation for distributed deep learning. CoRR, abs/1609.08326, 2016. +S. Zheng, Z. Huang, and J. Kwok. Communication-efficient distributed blockwise momentum sgd with error-feedback. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d Alché-Buc, E. Fox, and R. Garnett, editors, Advances in Neural Information Processing Systems 32, pages 11450-11460. Curran Associates, Inc., 2019. \ No newline at end of file diff --git a/1bitadamcommunicationefficientlargescaletrainingwithadamsconvergencespeed/images.zip b/1bitadamcommunicationefficientlargescaletrainingwithadamsconvergencespeed/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..b672cc789e011ca744ff16cfcff1d9d132b94697 --- /dev/null +++ b/1bitadamcommunicationefficientlargescaletrainingwithadamsconvergencespeed/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fe369cdf065535a85d0dd22f870f6b1e5a37b8338de36e284ffd041d0ecb074d +size 529749 diff --git a/1bitadamcommunicationefficientlargescaletrainingwithadamsconvergencespeed/layout.json b/1bitadamcommunicationefficientlargescaletrainingwithadamsconvergencespeed/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..4f0ab6c2f4a477c22b0e353a8212b45d8f18665e --- /dev/null +++ b/1bitadamcommunicationefficientlargescaletrainingwithadamsconvergencespeed/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:875e486ae061fabb1114602608dedf4d65a1e370c07e6d7bb456b38442fc40bb +size 534761 diff --git a/abitmorebayesiandomaininvariantlearningwithuncertainty/b5f69d13-2c24-4139-8208-7cdd93ba1eaa_content_list.json b/abitmorebayesiandomaininvariantlearningwithuncertainty/b5f69d13-2c24-4139-8208-7cdd93ba1eaa_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..aa30d0fff1a4b17c868093a086668a6bad9a82aa --- /dev/null +++ b/abitmorebayesiandomaininvariantlearningwithuncertainty/b5f69d13-2c24-4139-8208-7cdd93ba1eaa_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9a02b37fbd15dd006402ff842acee34470cf53d197d827defcf973184432d28c +size 87633 diff --git a/abitmorebayesiandomaininvariantlearningwithuncertainty/b5f69d13-2c24-4139-8208-7cdd93ba1eaa_model.json b/abitmorebayesiandomaininvariantlearningwithuncertainty/b5f69d13-2c24-4139-8208-7cdd93ba1eaa_model.json new file mode 100644 index 0000000000000000000000000000000000000000..ea6db5d185e518461c9348d03c18bf7fd611dd9d --- /dev/null +++ b/abitmorebayesiandomaininvariantlearningwithuncertainty/b5f69d13-2c24-4139-8208-7cdd93ba1eaa_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:65f4405fe20dc5cab07b7b76ee16c5cfcfdff43c5a5d34efcb5c558117346522 +size 105337 diff --git a/abitmorebayesiandomaininvariantlearningwithuncertainty/b5f69d13-2c24-4139-8208-7cdd93ba1eaa_origin.pdf b/abitmorebayesiandomaininvariantlearningwithuncertainty/b5f69d13-2c24-4139-8208-7cdd93ba1eaa_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..c1014926a9fa601fbd7a5274555c247b737c5f00 --- /dev/null +++ b/abitmorebayesiandomaininvariantlearningwithuncertainty/b5f69d13-2c24-4139-8208-7cdd93ba1eaa_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:af898ef6f15610609226032645b94dee3dfdca1444c2bf0e17d2eda13e60756f +size 938932 diff --git a/abitmorebayesiandomaininvariantlearningwithuncertainty/full.md b/abitmorebayesiandomaininvariantlearningwithuncertainty/full.md new file mode 100644 index 0000000000000000000000000000000000000000..2db4d389bad5eca713515c9fcc2d3a87ca8a84c1 --- /dev/null +++ b/abitmorebayesiandomaininvariantlearningwithuncertainty/full.md @@ -0,0 +1,333 @@ +# A Bit More Bayesian: Domain-Invariant Learning with Uncertainty + +Zehao Xiao $^{1*}$ Jiayi Shen $^{1*}$ Xiantong Zhen $^{12}$ Ling Shao $^{2}$ Cees G. M. Snoek + +# Abstract + +Domain generalization is challenging due to the domain shift and the uncertainty caused by the inaccessibility of target domain data. In this paper, we address both challenges with a probabilistic framework based on variational Bayesian inference, by incorporating uncertainty into neural network weights. We couple domain invariance in a probabilistic formula with the variational Bayesian inference. This enables us to explore domain-invariant learning in a principled way. Specifically, we derive domain-invariant representations and classifiers, which are jointly established in a two-layer Bayesian neural network. We empirically demonstrate the effectiveness of our proposal on four widely used cross-domain visual recognition benchmarks. Ablation studies validate the synergistic benefits of our Bayesian treatment when jointly learning domain-invariant representations and classifiers for domain generalization. Further, our method consistently delivers state-of-the-art mean accuracy on all benchmarks. + +# 1. Introduction + +Learning to improve the generalization of deep neural networks to data out of their training distribution remains a fundamental yet challenging problem for machine learning (Wang et al., 2018; Bengio et al., 2019; Krueger et al., 2020). Domain generalization (Muandet et al., 2013) aims to train a model on several source domains and have it generalize well to unseen target domains. The main challenge stems from the large shift of distributions between the source and target domains, which is further complicated by the prediction uncertainty (Malinin & Gales, 2018) introduced by the inaccessibility to data from the target domains during training. Established approaches learn domain-invariant features by dedicated loss functions (Muandet et al., 2013; + +*Equal contribution $^{1}$ AIM Lab, University of Amsterdam, The Netherlands $^{2}$ Inception Institute of Artificial Intelligence, UAE. Correspondence to: Z. Xiao , X. Zhen , C. Snoek . + +Proceedings of the $38^{th}$ International Conference on Machine Learning, PMLR 139, 2021. Copyright 2021 by the author(s). + +Li et al., 2018a) or specific architectures (Li et al., 2017; D'Innocente & Caputo, 2018). The state-of-the-art relies on advanced deep neural network backbones, known to degenerate when the test samples are out of the training data distribution (Nguyen et al., 2015; Ilse et al., 2019), due to their poorly calibrated behavior (Guo et al., 2017; Kristiadi et al., 2020). + +Domain generalization is susceptible to uncertainty as the domain shift from the source to the target domain is unknown a priori. Hence, uncertainty should be taken into account during domain-invariant learning. As deep neural networks are commonly trained by maximum likelihood estimation, they fail to effectively capture model uncertainty. This tends to make the models overconfident in their predictions, especially on out-of-distribution data (Daxberger & Hernández-Lobato, 2019). As a possible solution, approximate Bayesian inference offers a natural framework to represent prediction uncertainty (Kristiadi et al., 2020; MacKay, 1992). It possesses better generalizability to out-of-distribution examples (Louizos & Welling, 2017) and provides an elegant formulation to transfer knowledge across different datasets (Nguyen et al., 2018). Moreover, the prediction uncertainty can be improved, even when Bayesian approximation is only applied to the last network layer (Kristiadi et al., 2020; Atanov et al., 2019). These properties make it appealing to introduce Bayesian learning into the challenging and, as of yet, unexplored scenario of domain generalization. + +In this paper, we address domain generalization under a probabilistic framework1. To better explore domain-invariant learning, we introduce weight uncertainty to the model by leveraging variational Bayesian inference. To this end, we introduce the principle of domain invariance in a probabilistic formulation and incorporate it into the variational Bayesian inference framework. This enables us to explore domain invariance in a principled way to achieve domain-invariant feature representations and classifiers jointly. To better handle the domain shifts between seen and unseen domains, we explore our method under the meta-learning framework (Du et al., 2020; Balaji et al., 2018; Li & Malik, 2017). The meta-learning setting is utilized to + +expose the model to domain shift and mimic the generalization process by randomly splitting source domains into several meta-source domains and a meta-target domain in each iteration. We evaluate our method on four widely-used benchmarks for cross-domain object classification. Our ablation studies demonstrate the benefit of domain-invariant learning in a probabilistic framework through its synergy with variational Bayesian inference, as well as the advantage of jointly learning domain-invariant feature extractors and classifiers for domain generalization. Our method achieves state-of-the-art mean accuracy on all four benchmarks. + +# 2. Methodology + +# 2.1. Preliminaries + +In domain generalization, we have $\mathcal{D} = \{D_i\}_{i=1}^{|\mathcal{D}|} = \mathcal{S} \cup \mathcal{T}$ as a set of domains, where $\mathcal{S}$ and $\mathcal{T}$ denote the source and target domains, respectively. $\mathcal{S}$ and $\mathcal{T}$ do not have any overlap besides sharing the same label space. Data from the target domains $\mathcal{T}$ is never seen during training. For each domain $D_i \in \mathcal{D}$ , we define a joint distribution $p(\mathbf{x}, \mathbf{y})$ on $\mathcal{X} \times \mathcal{Y}$ , where $\mathcal{X}$ and $\mathcal{Y}$ denote the input space and output space, respectively. We aim to learn a model $f: \mathcal{X} \rightarrow \mathcal{Y}$ in the source domains $\mathcal{S}$ that generalizes well to the target domains $\mathcal{T}$ . + +We address domain generalization in a probabilistic framework of Bayesian inference by introducing weight uncertainty into neural networks. To be specific, we adopt variational Bayesian inference to learn a neural network that is assumed to be parameterized by weights $\pmb{\theta}$ with a prior distribution $p(\pmb{\theta})$ and the posterior distribution $p(\pmb{\theta}|\mathbf{x},\mathbf{y})$ , where $(\mathbf{x},\mathbf{y})$ are samples from the source domain $\mathcal{S}$ . To learn the model, we seek for a variational distribution $q(\pmb{\theta})$ to approximate $p(\pmb{\theta}|\mathbf{x},\mathbf{y})$ by minimizing the Kullback-Leibler divergence $\mathbb{D}_{\mathrm{KL}}[q(\pmb{\theta})||p(\pmb{\theta}|\mathbf{x},\mathbf{y})]$ between them. This amounts to minimizing the following objective: + +$$ +\mathcal {L} _ {\mathrm {B a y e s}} = - \mathbb {E} _ {q (\boldsymbol {\theta})} [ \log p (\mathbf {y} | \mathbf {x}, \boldsymbol {\theta}) ] + \mathbb {D} _ {\mathrm {K L}} [ q (\boldsymbol {\theta}) | | p (\boldsymbol {\theta}) ], (1) +$$ + +which is also known as the negative value of the evidence lower bound (ELBO) (Blei et al., 2017). We learn the model on the source domain $S$ in the hope that it will generalize well to the target domain $\mathcal{T}$ . + +Kristiadi et al. (2020) show that applying Bayesian approximation to the last layer of a neural network effectively captures model uncertainty. This is also appealing when dealing with uncertainty in domain generalization since applying Monte Carlo sampling to the full Bayesian neural network can be computationally infeasible. In this paper, to obtain a model that generalizes well across domains in an efficient way, we incorporate variational Bayesian approximation into the last two network layers to jointly establish domain-invariant feature representations and classifiers. More anal + +![](images/72198e3da193d49947090d56a026cadf1041b6f0c881c9dfc5e11493f280dd1b.jpg) + +![](images/bc364b3c9aa7435367673d1195b708f61aacef0963efb294955c115f46204e46.jpg) + +![](images/f4ebeeb37849d2f72cb9f33efb5c6fce9438495eb3a6327e254e0505a08e6b96.jpg) +Figure 1. Illustrative contrast between deterministic invariance (top) and probabilistic invariance (bottom), where colors indicate domains. The deterministic invariance tends to minimize the distance between two deterministic samples $(a\rightarrow b)$ . The samples come from their respective distributions, but with limited distributional awareness. This means that the samples cannot represent the complete distributions. Thus, the deterministic invariance can lead to small distances between samples, but large gaps between distributions, as shown in figure (b). In contrast, the probabilistic invariance directly minimizes the distance between different distributions $(c\to d)$ , which yields a better domain invariance as most of the samples in the distributions are taken into account. + +![](images/68989f5fa808ab13332fd1be8a4c5f2fff0c41a1c3a9295c5f9c6189a7f80b64.jpg) + +yses are provided in the experiments and supplementary. To achieve better domain invariance, we introduce a domain-invariant principle in a probabilistic form under the Bayesian framework. We use $\phi$ and $\psi$ to denote the parameters of the feature extractor and classifier. We incorporate the domain-invariant principle into the inference of posteriors over $\psi$ and $\phi$ , which results in our two-layer Bayesian network. Next we detail the Bayesian domain-invariant learning of the network and the objective for optimization. + +# 2.2. Bayesian Domain-Invariant Learning + +Existing domain generalizations try to achieve domain invariance by minimizing the distance between intra-class samples from different domains in the hope of reducing the domain gaps (Motiian et al., 2017). However, individual samples cannot be assumed to be representative of the distributions of samples from a certain domain. Therefore, it is preferable to minimize the distributional distance of intra-class samples from different domains, which can directly narrow the domain gap. A contrastive illustration is provided in Figure 1. Motivated by this, we propose to address domain generalization under the probabilistic modeling by + +incorporating weight uncertainty into invariant learning in the variational Bayesian inference framework. + +We first introduce the definition of domain invariance in a probabilistic form, which we adopt to learn domain-invariant feature representations and classifiers in a unified way. We define a continuous domain space $\mathfrak{D}$ containing a set of domains $\{D_i\}_{i=1}^{|\mathcal{D}|}$ in $\mathcal{D}$ and a domain-transform function $g_{\zeta}(\cdot)$ with parameters $\zeta$ in the domain space. $\{D_i\}_{i=1}^{|\mathcal{D}|}$ are discrete samples in $\mathfrak{D}$ . Function $g_{\zeta}(\cdot)$ transforms samples $\mathbf{x}$ from a reference domain to a different domain $D_{\zeta}$ with respect to $\zeta$ , where $\zeta \sim q(\zeta)$ , and different samples $\zeta$ lead to different sample domains $D_{\zeta} \sim \mathfrak{D}$ . + +As a concrete example, consider the rotation domains in Rotated MNIST (Ghifary et al., 2015). $\mathfrak{D}$ is the rotation domain space, containing images rotated by continuous angles from 0 to $2\pi$ . A sample $\mathbf{x}$ from any domain in $\mathfrak{D}$ can be transferred into a different domain $D_{\zeta}$ by: + +$$ +g _ {\zeta} (\mathbf {x}) = \left[ \begin{array}{l l} \cos (\zeta) & - \sin (\zeta) \\ \sin (\zeta) & - \cos (\zeta) \end{array} \right] \left[ \begin{array}{l} x _ {1} \\ x _ {2} \end{array} \right], \tag {2} +$$ + +where $\zeta \sim \mathrm{Uniform}(0,2\pi)$ . $\zeta$ is the parameter of $g_{\zeta}(\cdot)$ and different $\zeta$ lead to different rotation angles of the original sample $\mathbf{x}$ , which form another domain $D_{\zeta}$ in $\mathfrak{D}$ . In practice, transformations between domains are more complicated and the exact forms of $g_{\zeta}(\cdot)$ and $q(\zeta)$ are not explicitly known. + +Based on the above assumptions about $\mathfrak{D}$ , $g_{\zeta}(\cdot)$ and $q(\zeta)$ , we introduce our definition of the probabilistic form of domain invariance as follows. + +Definition 2.1 (Domain Invariance) Let $\mathbf{x}_i$ be a given sample from domain $D_i$ in the domain space $\mathfrak{D}$ , and $\mathbf{x}_{\zeta} = g_{\zeta}(\mathbf{x}_i)$ be a transformation of $\mathbf{x}_i$ in another domain $D_{\zeta}$ from the same domain space, where $\zeta \sim q(\zeta)$ . $p_{\theta}(\mathbf{y}|\mathbf{x})$ denotes the output distribution of input $\mathbf{x}$ with model $\theta$ . Model $\theta$ is domain-invariant in $\mathfrak{D}$ if + +$$ +p _ {\boldsymbol {\theta}} \left(\mathbf {y} _ {i} \mid \mathbf {x} _ {i}\right) = p _ {\boldsymbol {\theta}} \left(\mathbf {y} _ {\zeta} \mid \mathbf {x} _ {\zeta}\right), \quad \forall \zeta \sim q (\zeta). \tag {3} +$$ + +Here, we use $\mathbf{y}$ to represent the output from a neural layer with input $\mathbf{x}$ , which can either be the prediction vector from the last layer or the feature vector from the last convolutional layer of a deep neural network. + +To adopt the domain-invariant principle in the variational Bayesian inference framework, we reformulate (3) to an expectation form with respect to $q_{\zeta}$ , following Nalisnick & Smyth (2018): + +$$ +p _ {\boldsymbol {\theta}} \left(\mathbf {y} _ {i} \mid \mathbf {x} _ {i}\right) = \mathbb {E} _ {q _ {\zeta}} \left[ p _ {\boldsymbol {\theta}} \left(\mathbf {y} _ {\zeta} \mid \mathbf {x} _ {\zeta}\right) \right]. \tag {4} +$$ + +According to Definition 2.1, we use the Kullback-Leibler divergence between the two terms in (4), + +$\mathbb{D}_{\mathrm{KL}}\left[p_{\boldsymbol{\theta}}(\mathbf{y}_i|\mathbf{x}_i)||\mathbb{E}_{q_\zeta}\left[p_{\boldsymbol{\theta}}(\mathbf{y}_\zeta |\mathbf{x}_\zeta)\right]\right],$ to quantify the domain invariance of the model, which will be zero when the model is domain invariant in the domain space $\mathfrak{D}$ . To further facilitate the computation, we derive the upper bound of the KL divergence: + +$$ +\begin{array}{l} \mathbb {D} _ {\mathrm {K L}} \left[ p _ {\boldsymbol {\theta}} \left(\mathbf {y} _ {i} \mid \mathbf {x} _ {i}\right) | | \mathbb {E} _ {q _ {\zeta}} \left[ p _ {\boldsymbol {\theta}} \left(\mathbf {y} _ {\zeta} \mid \mathbf {x} _ {\zeta}\right) \right] \right] \\ \leq \mathbb {E} _ {q _ {\zeta}} \left[ \mathbb {D} _ {\mathrm {K L}} \left[ p _ {\boldsymbol {\theta}} \left(\mathbf {y} _ {i} \mid \mathbf {x} _ {i}\right) \right| | p _ {\boldsymbol {\theta}} \left(\mathbf {y} _ {\zeta} \mid \mathbf {x} _ {\zeta}\right) \right], \tag {5} \\ \end{array} +$$ + +which can be approximated by Monte Carlo sampling as we usually have access to samples from different domains. The complete derivation of (5) is provided in the supplementary material. + +We now adopt the probabilistic domain invariance principle in the variational Bayesian approximation of the last two layers with parameters of $\phi$ and $\psi$ , respectively. The introduced weight uncertainty results in distributional representations $p_{\phi}(\mathbf{z}|\mathbf{x})$ and predictions $p_{\psi}(\mathbf{y}|\mathbf{z})$ , based on which we derive domain-invariant learning. + +Invariant Classifier. For the classifier with parameters $\psi$ and input features $\mathbf{z}$ , the probabilistic domain-invariant property in (5) is represented as $\mathbb{E}_{q_{\zeta}}\left[\mathbb{D}_{\mathrm{KL}}[p_{\psi}(\mathbf{y}_i|\mathbf{z}_i)||p_{\psi}(\mathbf{y}_{\zeta}|\mathbf{z}_{\zeta})]\right]$ . Under the Bayesian framework, the predictive distribution $p_{\psi}(\mathbf{y}|\mathbf{z})$ is obtained by taking the expectation over the distribution of parameter $\theta$ , i.e., $p_{\psi}(\mathbf{y}|\mathbf{z}) = \mathbb{E}_{q(\psi)}[p(\mathbf{y}|\mathbf{z},\psi)]$ . As the KL divergence is a convex function (Nalisnick & Smyth, 2018), we further extend it to the upper bound: + +$$ +\mathbb {E} _ {q _ {\zeta}} \left[ \mathbb {D} _ {\mathrm {K L}} \left[ p _ {\boldsymbol {\psi}} (\mathbf {y} _ {i} | \mathbf {z} _ {i}) | | p _ {\boldsymbol {\psi}} (\mathbf {y} _ {\zeta} | \mathbf {z} _ {\zeta}) \right] \right] +$$ + +$$ += \mathbb {E} _ {q _ {\zeta}} \left[ \mathbb {D} _ {\mathrm {K L}} \left[ \mathbb {E} _ {q (\psi)} [ p (\mathbf {y} _ {i} | \mathbf {z} _ {i}, \boldsymbol {\psi}) ] | | \mathbb {E} _ {q (\psi)} [ p (\mathbf {y} _ {\zeta} | \mathbf {z} _ {\zeta}, \boldsymbol {\psi}) ] \right] \right] +$$ + +$$ +\leq \mathbb {E} _ {q _ {\zeta}} \left[ \mathbb {E} _ {q (\boldsymbol {\psi})} \mathbb {D} _ {\mathrm {K L}} \left[ p \left(\mathbf {y} _ {i} \mid \mathbf {z} _ {i}, \boldsymbol {\psi}\right) | | p \left(\mathbf {y} _ {\zeta} \mid \mathbf {z} _ {\zeta}, \boldsymbol {\psi}\right) \right] \right], \tag {6} +$$ + +which is tractable with unbiased approximation by using Monte Carlo sampling. + +In practice, we estimate the expectation over $q(\zeta)$ in an empirical way. Specifically, in each iteration, we choose one domain from the source domains $\mathcal{S}$ as the meta-target domain $D_{t}$ and the rest are used as the meta-source domains $\{D_s\}_{s = 1}^S$ , where $S = |\mathcal{S}| - 1$ . Then we use a batch of samples $\mathbf{x}_s$ from each meta-source domain in the same category as $\mathbf{x}_t$ to approximate $\mathbf{x}_{\zeta} = g_{\zeta}(\mathbf{x}_t)$ + +Thereby, the domain-invariant classifier is established by minimizing: + +$$ +\frac {1}{S N} \sum_ {s = 1} ^ {S} \sum_ {i = 1} ^ {N} \mathbb {E} _ {q (\boldsymbol {\psi})} \left[ \mathbb {D} _ {\mathrm {K L}} \left[ p \left(\mathbf {y} _ {t} \mid \mathbf {z} _ {t}, \boldsymbol {\psi}\right) | | p \left(\mathbf {y} _ {s} ^ {i} \mid \mathbf {z} _ {s} ^ {i}, \boldsymbol {\psi}\right) \right] \right], \tag {7} +$$ + +where $\left\{\mathbf{z}_s^i\right\}_{i = 1}^N$ are representations of samples $\mathbf{x}_s$ from $D_{s}$ which are in the same category as $\mathbf{x}_t$ + +The variational Bayesian inference enables us to flexibly incorporate our domain invariant principle into different layers of the neural network. To enhance the domain invariance, we obtain domain-invariant representations by adopting the principle in the penultimate layer. + +Invariant Representations. To obtain domain-invariant representations $p(\mathbf{z}|\mathbf{x})$ with feature extractor $\phi$ , we extend the quantification of our probabilistic domain invariance in (5) to $\mathbb{E}_{q_{\zeta}}\left[\mathbb{D}_{\mathrm{KL}}[p_{\phi}(\mathbf{z}_i|\mathbf{x}_i)||p_{\phi}(\mathbf{z}_{\zeta}|\mathbf{x}_{\zeta})]\right]$ . Based on the Bayesian layer, the probabilistic distribution of features $p_{\phi}(\mathbf{z}|\mathbf{x})$ will be a factorized Gaussian distribution if the posterior of $\phi$ is as well. We illustrate this as follows. Let $\phi$ be the last Bayesian layer in the feature extractor with a factorized Gaussian posterior and $\mathbf{x}$ be the input feature of $\phi$ . The posterior of the activation $\mathbf{z}$ is also a factorized Gaussian (Kingma et al., 2015): + +$$ +\begin{array}{l} q \left(\phi_ {i, j}\right) \sim \mathcal {N} \left(\mu_ {i, j}, \sigma_ {i, j} ^ {2}\right) \quad \forall \phi_ {i, j} \in \boldsymbol {\phi} \\ \Rightarrow p \left(z _ {j} \mid \mathbf {x}, \phi\right) \sim \mathcal {N} \left(\gamma_ {j}, \delta_ {j} ^ {2}\right), \tag {8} \\ \end{array} +$$ + +$$ +\gamma_ {j} = \sum_ {i = 1} ^ {N} x _ {i} \mu_ {i, j}, \quad \text {a n d} \quad \delta_ {j} ^ {2} = \sum_ {i = 1} ^ {N} x _ {i} ^ {2} \sigma_ {i, j} ^ {2}, +$$ + +where $z_{j}$ denotes the $j$ -th element in $\mathbf{z}$ , likewise for $x_{i}$ , and $\phi_{i,j}$ denotes the element at position $(i,j)$ in $\phi$ . Thus, we assume the posterior of the last Bayesian layer in the feature extractor has a factorized Gaussian distribution. Then, it is easy to obtain the Bayesian domain invariance of the feature extractor. + +In a similar way to (7), we estimate the expectation over $q(\zeta)$ empirically. Therefore, the domain-invariant representations are established by minimizing: + +$$ +\frac {1}{S N} \sum_ {s = 1} ^ {S} \sum_ {i = 1} ^ {N} \left[ \mathbb {D} _ {\mathrm {K L}} \left[ p \left(\mathbf {z} _ {t} \mid \mathbf {x} _ {t}, \phi\right) \right| | p \left(\mathbf {z} _ {s} ^ {i} \mid \mathbf {x} _ {s} ^ {i}, \phi\right) \right], \tag {9} +$$ + +where $\{\mathbf{x}_s^i\}_{i = 1}^N$ are from $D_{s}$ , and denote the samples in the same category as $\mathbf{x}_t$ . More details and an illustration of the Bayesian domain-invariant learning are provided in the supplementary material. + +# 2.3. Objective Function + +Having the Bayesian treatment for the last two layers with respect to parameters $\phi$ and $\psi$ , the $\mathcal{L}_{\mathrm{Bayes}}$ in (1) is instantiated as the objective with respect to $\psi$ and $\phi$ as follows: + +$$ +\begin{array}{l} \mathcal {L} _ {\text {B a y e s}} = - \mathbb {E} _ {q (\psi)} \left[ \mathbb {E} _ {q (\phi)} [ \log p (\mathbf {y} | \mathbf {x}, \psi , \phi) ] \right] \tag {10} \\ + \mathbb {D} _ {\mathrm {K L}} [ q (\psi) | | p (\psi) ] + \mathbb {D} _ {\mathrm {K L}} [ q (\phi) | | p (\phi) ]. \\ \end{array} +$$ + +The detailed derivation of (10) is provided in the supplementary material. + +By integrating (7) and (9) into (10), we obtain the Bayesian domain-invariant learning objective as follows: + +$$ +\begin{array}{l} \mathcal {L} _ {\mathrm {B I L}} = \frac {1}{L} \sum_ {\ell = 1} ^ {L} \left[ \frac {1}{M} \sum_ {m} ^ {M} [ - \log p (\mathbf {y} _ {t} | \mathbf {x} _ {t}, \boldsymbol {\psi} ^ {(\ell)}, \boldsymbol {\phi} ^ {(m)}) ] \right. \\ + \frac {1}{S N} \sum_ {s = 1} ^ {S} \sum_ {i = 1} ^ {N} \left[ \lambda_ {\boldsymbol {\psi}} \mathbb {D} _ {\mathrm {K L}} \left[ p (\mathbf {y} _ {t} | \mathbf {z} _ {t}, \boldsymbol {\psi} ^ {(\ell)}) \right| \right. | p (\mathbf {y} _ {s} ^ {i} | \mathbf {z} _ {s} ^ {i}, \boldsymbol {\psi} ^ {(\ell)}) ] \\ + \lambda_ {\phi} \mathbb {D} _ {\mathrm {K L}} [ p (\mathbf {z} _ {t} | \mathbf {x} _ {t}, \phi) | | p (\mathbf {z} _ {s} ^ {i} | \mathbf {x} _ {s} ^ {i}, \phi) ] ] \\ \left. + \mathbb {D} _ {\mathrm {K L}} [ q (\psi) | | p (\psi) ] + \mathbb {D} _ {\mathrm {K L}} [ q (\phi) | | p (\phi) ] \right], \tag {11} \\ \end{array} +$$ + +where $\lambda_{\psi}$ and $\lambda_{\phi}$ are hyperparameters that control the domain-invariant terms. $\mathbf{x}_t$ and $\mathbf{z}_t$ denote the input and its feature from $D_{t}$ , and $\mathbf{x}_s^i$ and $\mathbf{z}_s^i$ are from $D_{s}$ . The posteriors are set to factorized Gaussian distributions, i.e., $q(\psi) = \mathcal{N}(\pmb{\mu}_{\psi},\pmb{\sigma}_{\psi}^{2})$ and $q(\phi) = \mathcal{N}(\pmb{\mu}_{\phi},\pmb{\sigma}_{\phi}^{2})$ . We adopt the reparameterization trick to draw Monte Carlo samples (Kingma & Welling, 2014) as $\psi^{(\ell)} = \pmb{\mu}_{\psi} + \epsilon^{(\ell)}*\pmb{\sigma}_{\psi}$ where $\epsilon^{(\ell)}\sim \mathcal{N}(0,I)$ . Likewise, we draw the Monte Carlo samples $\phi^{(m)}$ for $q(\phi)$ . + +When implementing our Bayesian invariant learning, to increase the flexibility of the prior distribution in our Bayesian layers, we place a scale mixture of two Gaussian distributions as the priors $p(\psi)$ and $p(\phi)$ (Blundell et al., 2015): + +$$ +\pi \mathcal {N} \left(0, \sigma_ {1} ^ {2}\right) + (1 - \pi) \mathcal {N} \left(0, \sigma_ {2} ^ {2}\right), \tag {12} +$$ + +where $\sigma_{1},\sigma_{2}$ are set according to (Blundell et al., 2015) and $\pi$ is chosen by cross-validation. More experiments and analyses on the hyperparameters $\lambda_{\psi},\lambda_{\phi}$ and $\pi$ are provided in the supplementary material. + +# 3. Related Work + +To address the domain shifts, domain adaptation (Saenko et al., 2010; Long et al., 2015; Wang et al., 2020) and domain generalization (Muandet et al., 2013; Li et al., 2017) are the two main settings. Domain adaptation has a key assumption that the data from the target domain is accessible during training, which is often invalid in realistic applications. By contrast, no target domain data is available during training in domain generalization, which introduces more prediction uncertainty into the problem and makes it more challenging. Our method is developed specifically for domain generalization. + +One solution for domain generalization is to generate more source domain data to increase the probability of covering the data in the target domains (Shankar et al., 2018; Volpi et al., 2018). Shankar et al. (2018) augment the data by perturbing the input images with adversarial gradients generated by an auxiliary classifier. Qiao et al. (2020) propose an even more challenging scenario of domain generaliza + +tion named single domain generalization, which only has one source domain, and introduce an adversarial domain augmentation method that creates "fictitious" yet "challenging" data. Recently, Zhou et al. (2020) employ a generator to synthesize data from pseudo-novel domains to augment the source domains, maximizing the distance between the source and pseudo-novel domains as measured by optimal transport (Peyre & Cuturi, 2019). + +Another solution for domain generalization involves learning domain-invariant features (D'Innocente & Caputo, 2018; Li et al., 2018b; 2017). Muandet et al. (2013) propose domain-invariant component analysis to learn invariant transformations by minimizing the dissimilarity across domains. Louizos et al. (2015) learn invariant representations by a variational auto-encoder (Kingma & Welling, 2014), introducing Bayesian inference into invariant feature learning. Both Dou et al. (2019) and Seo et al. (2019) achieve a similar goal by introducing two complementary losses and employing multiple normalizations. Li et al. (2019) propose an episodic training algorithm to obtain both a domain-invariant feature extractor and classifier. Zhao et al. (2020) propose entropy-regularization to learn domain-invariant features. Seo et al. (2019) and Zhou et al. (2021) design normalizations to combine different feature statistics and embed the samples into a domain-invariant feature space. + +Meta-learning has also been considered for domain generalization. Li et al. (2018a) introduce a gradient-based method, i.e., model agnostic meta-learning (Finn et al., 2017), for domain generalization. Balaji et al. (2018) meta-learn a regularization function, making their model robust to domain shifts. Du et al. (2020) propose the meta-variational information bottleneck to learn domain-invariant representations through episodic training. + +Gulrajani & Lopez-Paz (2020) find that with careful implementation, empirical risk minimization methods outperform many state-of-the-art models in domain generalization. They claim that model selection is non-trivial for domain generalization and algorithms for this task should specify their own model selection criteria, which is important for the completeness and comparability of the method. In this paper, we implement our method based on the pretrained ResNet-18, as done for our baseline and most methods we compare against in Section 4. + +Motiian et al. (2017) previously considered representation alignment across domains in the same class. They propose a classification and contrastive semantic alignment loss based on the L2 distance between deterministic features. Different from them, we exploit Bayesian neural networks to learn domain-invariant representations by minimizing the distance between probabilistic distributions. + +Bayesian neural networks have not yet been explored for + +domain generalization. Our method introduces variational Bayesian approximation to both the feature extractor and classifier of the neural network in conjunction with the newly introduced domain-invariant principle for domain generalization. The resultant Bayesian domain-invariant learning combines the representational power of deep neural networks and variational Bayesian inference. + +# 4. Experiments + +# 4.1. Datasets and Settings + +We conduct our experiments on four widely used benchmarks for domain generalization and report the mean classification accuracy on target domains. + +$\mathbf{PACS}^2$ (Li et al., 2017) consists of 9,991 images of seven classes from four domains - photo, art-painting, cartoon and sketch. We follow the "leave-one-out" protocol from (Li et al., 2017; 2018b; Carlucci et al., 2019), where the model is trained on any three of the four domains, which we call source domains, and tested on the last (target) domain. + +Office-Home3 (Venkateswara et al., 2017) also has four domains: art, clipart, product and real-world. There are about 15,500 images of 65 categories for object recognition in office and home environments. We use the same experimental protocol as for PACS. + +Rotated MNIST $^4$ and Fashion-MNIST $^5$ are introduced in (Piratla et al., 2020) for evaluating domain generalization. For fair comparison, we follow their recommended settings and randomly select a subset of 2,000 images from MNIST and 10,000 images from Fashion-MNIST, which are considered to have been rotated by $0^\circ$ . The subset of images is then rotated by $15^\circ$ through $75^\circ$ in intervals of $15^\circ$ , creating five source domains. The target domains are created by rotations of $0^\circ$ and $90^\circ$ . These datasets allow us to demonstrate the generalizability of our model by comparing its performance on in-distribution and out-of-distribution data. + +Settings. For all four benchmarks, we employ a ResNet-18 (He et al., 2016) pretrained on ImageNet (Deng et al., 2009) as the backbone. During training we use Adam optimization (Kingma & Ba, 2014) with a learning rate of 0.0001, and train for 10,000 iterations. In each iteration we choose one source domain as the meta-target domain. The batch size is 128. To fit the memory footprint, we choose a maximum number of samples per category and target domain to implement the domain-invariant learning, i.e., sixteen for + +Table 1. Ablation study on PACS. The “√” and “×” in the “Bayesian” column indicate whether the classifier $\psi$ and feature extractor $\phi$ are Bayesian layers or deterministic layers. In the “Invariant” column, they indicate whether the domain-invariant learning is introduced into the classifier and the feature extractor. Note that with “√” in the Bayesian column, the invariant column denotes Bayesian domain-invariant learning. Otherwise it denotes the deterministic one. The results show that both Bayesian and domain-invariant learning benefit domain generalization, but our Bayesian domain-invariant learning is better. We obtain the best performance with Bayesian domain-invariant learning in both the classifier and feature extractor. We also provide the visualizations of the features for each of the settings in Figure 2. + +
IDClassifier ψFeature extractor φPACS
BayesianInvariantBayesianInvariantPhotoArt-paintingCartoonSketchMean
(a)××××92.85 ±0.2175.12 ±0.4877.44 ±0.2675.72 ±0.4780.28 ±0.42
(b)×××93.89 ±0.2977.88 ±0.5378.20 ±0.3977.75 ±0.7581.93 ±0.22
(c)×××93.95 ±0.5180.03 ±0.7278.03 ±0.7777.83 ±0.5282.46 ±0.67
(d)××95.21 ±0.2681.25 ±0.7680.67 ±0.7379.31 ±0.9484.11 ±0.39
(e)×××92.81 ±0.3578.66 ±0.5677.90 ±0.4078.72 ±0.8682.02 ±0.26
(f)×××94.17 ±0.3579.75 ±0.6879.51 ±0.9878.31 ±1.1182.94 ±0.53
(g)××95.15 ±0.2680.96 ±0.6979.57 ±0.8579.15 ±0.9883.71 ±0.65
(h)××93.83 ±0.1982.13 ±0.4179.18 ±0.4879.03 ±0.7883.54 ±0.34
(i)××94.12 ±0.2280.52 ±0.6180.39 ±0.8178.53 ±0.9583.39 ±0.52
(j)95.97 ±0.2483.92 ±0.7181.61 ±0.5980.31 ±0.9185.45 ±0.24
+ +PACS, Rotated MNIST and Fashion-MNIST, and four for Office-Home. We select $\lambda_{\phi}$ and $\lambda_{\psi}$ based on validation set performance and summarize their influence in the supplementary material. The optimal values of $\lambda_{\phi}$ and $\lambda_{\psi}$ are 0.1 and 100. Parameters $\sigma_{1}$ and $\sigma_{2}$ in (12) are set to 0.1 and 1.5. The model with the highest validation set accuracy is employed for evaluation on the target domain. + +# 4.2. Results + +We first conduct an ablation study on PACS to investigate the effectiveness of our Bayesian invariant layer for domain generalization. Since the major contributions of this work are the Bayesian treatment and the probabilistic domain-invariant principle, we evaluate their effect by individually incorporating them into the classifier – the last layer – $\psi$ and the feature extractor – the penultimate layer – $\phi$ . The results are shown in Table 1, with a corresponding t-SNE visualization of the features learned by various settings in Figure 2, following Du et al. (2020). We also provide a comparison with the state-of-the-art methods on four widely used benchmarks. More results and visualizations are provided in the supplementary material. + +Benefits of Bayesian Invariant Classifier. In Table 1, rows (a) to (d) demonstrate the benefits of the Bayesian invariant classifier. Row (a) serves as our baseline model, which is a vanilla deep convolutional network without any Bayesian treatment or domain-invariant loss. The backbone is also a ResNet-18 pretrained on ImageNet. Rows (b), (c) and (d) show the performance with a Bayesian classifier, a deterministic domain-invariant classifier and our Bayesian-invariant classifier. By comparing (b) and (a), it is clear + +that the Bayesian treatment for the classifier improves the performance, especially in the "art-painting" and "sketch" domains. The deterministic invariant property, as shown in row (c), also benefits the performance. Nevertheless, our Bayesian invariant learning based on the probabilistic framework performs better. The results demonstrate that the Bayesian invariant learning enhances the robustness of Bayesian neural networks on out-of-distribution data and better leverages domain-invariance than the deterministic invariant model. + +The three subfigures in the first row of Figure 2 also demonstrate the benefits of the Bayesian invariant classifier. The Bayesian treatment enlarges the inter-class distance in all domains, as shown in Figure 2 (b). The Bayesian layer incorporates weight uncertainty into the predictions and improves their diversity, which enhances the classification performance on the source domains as well as the generalization to the target domain. The deterministic invariant classifier tends to minimize the distance between samples with the same label. However, the effect is mainly on the source domain, without obvious impact on the target domain (pink samples), as shown in Figure 2 (c). By introducing uncertainty into both the classification and domain-invariant procedure, our Bayesian domain-invariant classifier further enlarges the inter-class distance in all domains and better generalizes the domain-invariant property to the target domain (compare Figure 2 (d) to (b) and (c)). + +Benefits of Bayesian Invariant Feature Extractor. The benefit of our Bayesian domain-invariant principle for the feature extractor is demonstrated in rows (e), (f), and (g) of Table 1. Similar to the classifier, introducing Bayesian infer + +![](images/9a6725300bedc957d842dad00fb71a09b1257dbdf9883471fb65f6e114d4a52d.jpg) +Figure 2. Illustration of the benefit of Bayesian domain-invariant learning by visualization of the feature representations. Colors denote domains, where the target domain "art-painting" is in violet, and shapes indicate classes. Our Bayesian domain-invariant learning (shown in the right column), especially when employed in both the classifier and feature extractor $(\mathrm{jj})$ , achieves better results than the other cases shown in the ten subfigures, which correspond to the ten settings in Table 1 (identified by ID). + +ence into the feature extractor (comparing row (e) with row (a)) brings a good accuracy improvement. By comparing (g) to (e) and (f), we observe that our Bayesian invariant layer achieves consistently better accuracy than the deterministic invariant model and regular Bayesian layer. + +The subfigures in the second row of Figure 2 further demonstrate the effectiveness of the Bayesian domain-invariant feature extractor. Similar to the classifier, introducing the Bayesian framework into the feature extractor also enlarges the inter-class distance of all domains by introducing model uncertainty, as shown in (e). The deterministic invariant feature extractor can also minimize the intra-class distance between different domains. However, while the effect is more obvious than the deterministic domain-invariant classifier, it is still poor on the target domain (Figure 2 (f)). Compared to (e) and (f), the Bayesian invariant feature extractor in (g) tends to further maximize the inter-class distance while minimizing the intra-class distance between different domains, which obviously enlarges the inter-class distance between samples from the target domain. Since the Bayesian invariant feature extractor achieves domain invariance in a probabilistic way, more uncertainties are taken into account, enabling the model to achieve better generalization on the target domain. Note that although the Bayesian invariant classifier in (d) and feature extractor in (g) achieve + +domain-invariant learning from different directions of the feature space, they both improve the performance on the target domain and do not conflict with each other. + +Benefits of Synergistic Bayesian Invariant Learning. The last three rows of Table 1 show the performance when introducing Bayesian and invariant learning into both the classifier and feature extractor. Both the Bayesian learning (row (h)) and deterministic invariant learning (row (i)) in two layers perform better than introducing the corresponding properties into only one layer of the model (compared with (b), (c) and (e), (f)) on most domains, as well as in terms of mean performance. Overall, employing our Bayesian invariant layer in both the classifier and feature extractor achieves the best performance, as shown in row (j). + +The last row in Figure 2 further demonstrates the benefits of synergistic Bayesian invariant learning. Incorporating the Bayesian classifier and the Bayesian feature extractor further maximizes the inter-class distance of all domains, as comparing (h) to (b) and (e). Introducing deterministic invariance into both the classifier and feature extractor also improves the domain-invariant property of features and the generalization to the target domain to some extent, as shown in subfigure (i). Moreover, by utilizing both the Bayesian domain-invariant classifier and Bayesian domain-invariant feature extractor, our method combines their benefits shown + +Table 2. Performance of different priors on PACS. "Standard" denotes the standard Gaussian prior while "Mixture" denotes the scale mixture prior. + +
PriorPhotoArt-paintingCartoonSketchMean
Standard95.17 ±0.2581.95 ±0.4279.41 ±0.8277.88 ±0.5783.61 ±0.12
Mixture95.97 ±0.2483.92 ±0.7181.61 ±0.5980.31 ±0.9185.45 ±0.24
+ +Table 3. Effect of more Bayesian layers on PACS. The "Bayesian" and "Invariant" columns indicate whether the penultimate layer $\phi^{\prime}$ in the feature extractor has a Bayesian and/or domain-invariant property. More Bayesian layers benefit the performance while excessive domain-invariant learning is harmful. + +
φ'PACS
BayesianInvariantPhotoArt-paintingCartoonSketchMean
××95.97 ±0.2483.92 ±0.7181.61 ±0.5980.31 ±0.9185.45 ±0.24
×95.69 ±0.2083.28 ±0.7482.06 ±0.2581.00 ±0.5585.51 ±0.13
95.72 ±0.2982.33 ±0.4781.10 ±0.7380.67 ±1.0184.96 ±0.34
+ +Table 4. Comparison on PACS. Our method achieves the best performance on the "Cartoon" domain, is competitive on the other three domains and obtains the best overall mean accuracy. + +
PhotoArt-paintingCartoonSketchMean
Baseline92.8575.1277.4475.7280.28
Carlucci et al. (2019)96.0379.4275.2571.3580.51
Dou et al. (2019)94.9980.2977.1771.6981.04
Zhao et al. (2020)96.6580.7076.4071.7781.38
Piratla et al. (2020)94.1078.9075.8076.7081.40
Chattopadhyay et al. (2020)93.3576.9080.3875.2181.46
Li et al. (2019)93.9082.1077.0073.0081.50
Balaji et al. (2018)95.5083.7077.2070.3081.68
Zhou et al. (2020)96.2083.3078.2073.6082.83
Seo et al. (2019)95.8784.6777.6582.2385.11
Huang et al. (2020)95.9983.4380.3180.8585.15
This paper95.97 ±0.2483.92 ±0.7181.61 ±0.5980.31 ±0.9185.45 ±0.24
+ +in (d) and (g) and achieves the best performance, as shown in (j). This indicates the benefits of the synergy between Bayesian inference and probabilistic domain-invariant learning for domain generalization. + +Effect of Scale Mixture Priors. Instead of using an uninformative diagonal Gaussian prior, we adopt the scale mixture prior (Blundell et al., 2015). To show the effect of the prior, we conduct experiments with both the standard Gaussian prior and scale mixture Gaussian prior as in (12). The results are reported in Table 2. The scale mixture prior achieves better performance on all domains. We have also done an ablation on the scaling mixture prior by changing the value of $\pi$ in (12). The prior with $\pi = 0.5$ achieves the best performance on the "cartoon" domain of PACS (Figure C.2 in supplementary), and thereby we use this value in all other experiments. + +Effect of More Bayesian Layers. We also experiment with more Bayesian layers in the feature extractor, as shown in + +Table 3. The settings of the model in the first row are the same as row (j) in Table 1. When introducing another Bayesian layer $\phi'$ without domain invariance into the model, as shown in the second row, the average performance improves slightly. However, if we introduce the Bayesian domain-invariant learning into $\phi'$ (third row), the overall performance deteriorates slightly. This may due to the loss of information in the features caused by the excessive use of domain-invariant learning. In addition, due to the Bayesian inference and Monte Carlo sampling, more Bayesian layers leads to higher memory usage and more computations (more detailed discussion in supplementary material). As such, we prefer to apply the Bayesian invariant learning only in the last feature extraction layer and the classifier. + +State-of-the-Art Comparisons. We compare our method with the state-of-the-art on four datasets. For comprehensive comparison, we also include a vanilla deep convolutional ResNet-18 network as a baseline, without any Bayesian treatment, as done in row (a) of Table 1. The results for each + +Table 5. Comparison on Office-Home. Our method achieves the best performance on the "Art" and "Clipart" domains, while being competitive on the "Product" and "Real" domains. Again we report the best overall mean accuracy. + +
ArtClipartProductRealMean
Baseline54.8449.8572.4073.1462.55
Carlucci et al. (2019)53.0447.5171.4772.7961.20
Li et al. (2018b)56.5047.3072.1074.8062.68
Seo et al. (2019)59.3745.7071.8474.6862.90
Huang et al. (2020)58.4247.9071.6374.5463.12
Zhou et al. (2020)60.6050.1074.8077.0065.63
This paper61.81 ±0.3653.27 ±0.3774.27 ±0.3576.31 ±0.2466.42 ±0.18
+ +Table 6. Comparison on Rotated MNIST and Fashion-MNIST. In-distribution accuracy is evaluated on the test sets of MNIST and Fashion-MNIST with rotation angles of $15^{\circ}$ , $30^{\circ}$ , $45^{\circ}$ , $60^{\circ}$ and $75^{\circ}$ , while out-of-distribution accuracy is evaluated on test sets with angles of $0^{\circ}$ and $90^{\circ}$ . Our method achieves best performance on both the in-distribution and out-of-distribution test sets. + +
MNISTFashion-MNIST
In-distributionOut-of-distributionIn-distributionOut-of-distribution
Baseline98.493.589.676.9
Dou et al. (2019)98.293.286.972.4
Piratla et al. (2020)98.494.789.778.0
This paper99.0 ±0.0296.5 ±0.0891.5 ±0.1083.5 ±0.63
+ +dataset are reported in Tables 4, 5 and 6. + +On PACS, in Table 4, our method achieves the best mean accuracy. For each individual domain, we are competitive with the state-of-the-art and even exceed all other methods on the "cartoon" domain. On Office-Home, in Table 5, we again achieve the best mean accuracy. It is worth mentioning that on the most challenging "art" and "clipart" domains, we also deliver the highest accuracy, with a good improvement over previous methods. However, Zhou et al. (2020) and Seo et al. (2019) outperform the proposed model on some domains of PACS and Office-Home. In (Zhou et al., 2020), the source domains are augmented by a generator that synthesizes data from pseudo-novel domains, which often have similar characteristics with the source data. This pays off when the target data also has similar characteristics to the source domains, as the pseudo domains are more likely to cover the target domain, as can be seen for "product" and "real world" in Office-Home and "photo" in PACS. When the test domain is different from all of the training domains the performance suffers, e.g., "clipart" in Office-Home and "sketch" in PACS. We highlight that our method generates domain-invariant representations and classifiers, resulting in competitive results across all domains and overall. In addition, Seo et al. (2019) combine batch and instance normalization for domain generalization. This tactic is effective on PACS, but less so on Office-Home. We attribute this to the larger number of categories in Office-Home, where instance normalization is known to make features less discriminative with respect to object categories (Seo et al., 2019). In contrast, our Bayesian domain-invariant learning establishes + +domain-invariant features and predictions in a probabilistic form by introducing uncertainty into the model, resulting in good performance on both PACS and Office-Home. + +On Rotated MNIST and Fashion-MNIST, following the experimental settings in Piratla et al. (2020), we evaluate our method on the in-distribution and out-of-distribution sets. As shown in Table 6, our method achieves the best performance on both sets of the two datasets. In particular, our method improves the classification performance on the out-of-distribution sets, demonstrating its strong generalizability to unseen domains, which is also consistent with the findings in Figure 2. + +# 5. Conclusion + +In this work, we propose a variational Bayesian learning framework for domain generalization. We introduce Bayesian neural networks into the model, which are able to better represent uncertainty and enhance the generalization to out-of-distribution data. To handle the domain shift between source and target domains, we propose a domain-invariant principle under the variational inference framework, which is incorporated by establishing a domain-invariant feature extractor and classifier. Our method combines the representational power of deep neural networks and uncertainty modeling ability of Bayesian learning, demonstrating effectiveness for domain generalization. Ablation studies further validate these benefits. Our Bayesian invariant learning sets a new state-of-the-art on four domain generalization benchmarks. + +# References + +Atanov, A., Ashukha, A., Struminsky, K., Vetrov, D., and Welling, M. The deep weight prior. In International Conference on Learning Representations, 2019. +Balaji, Y., Sankaranarayanan, S., and Chellappa, R. Metareg: Towards domain generalization using meta-regularization. In Advances in Neural Information Processing Systems, pp. 998-1008, 2018. +Bengio, Y., Deleu, T., Rahaman, N., Ke, N. R., Lachapelle, S., Bilaniuk, O., Goyal, A., and Pal, C. A meta-transfer objective for learning to disentangle causal mechanisms. In International Conference on Learning Representations, 2019. +Blei, D. M., Kucukelbir, A., and McAuliffe, J. D. Variational inference: A review for statisticians. Journal of the American Statistical Association, 112(518):859-877, 2017. +Blundell, C., Cornebise, J., Kavukcuoglu, K., and Wierstra, D. Weight uncertainty in neural networks. ArXiv, abs/1505.05424, 2015. +Carlucci, F. M., D'Innocente, A., Bucci, S., Caputo, B., and Tommasi, T. Domain generalization by solving jigsaw puzzles. In IEEE Conference on Computer Vision and Pattern Recognition, pp. 2229-2238, 2019. +Chattopadhyay, P., Balaji, Y., and Hoffman, J. Learning to balance specificity and invariance for in and out of domain generalization. arXiv preprint arXiv:2008.12839, 2020. +Daxberger, E. and Hernández-Lobato, J. M. Bayesian variational autoencoders for unsupervised out-of-distribution detection. arXiv preprint arXiv:1912.05651, 2019. +Deng, J., Dong, W., Socher, R., Li, L.-J., Li, K., and Fei-Fei, L. Imagenet: A large-scale hierarchical image database. In IEEE Conference on Computer Vision and Pattern Recognition, pp. 248-255, 2009. +Dou, Q., de Castro, D. C., Kamnitsas, K., and Glocker, B. Domain generalization via model-agnostic learning of semantic features. In Advances in Neural Information Processing Systems, pp. 6450-6461, 2019. +Du, Y., Xu, J., Xiong, H., Qiu, Q., Zhen, X., Snoek, C. G. M., and Shao, L. Learning to learn with variational information bottleneck for domain generalization. In European Conference on Computer Vision, 2020. +D'Innocente, A. and Caputo, B. Domain generalization with domain-specific aggregation modules. In German Conference on Pattern Recognition, pp. 187-198. Springer, 2018. + +Finn, C., Abbeel, P., and Levine, S. Model-agnostic meta-learning for fast adaptation of deep networks. In International Conference on Machine Learning, pp. 1126-1135, 2017. +Ghifary, M., Bastiaan Kleijn, W., Zhang, M., and Balduzzi, D. Domain generalization for object recognition with multi-task autoencoders. In IEEE International Conference on Computer Vision, pp. 2551-2559, 2015. +Gulrajani, I. and Lopez-Paz, D. In search of lost domain generalization. arXiv preprint arXiv:2007.01434, 2020. +Guo, C., Pleiss, G., Sun, Y., and Weinberger, K. Q. On calibration of modern neural networks. In International Conference on Machine Learning, pp. 1321-1330, 2017. +He, K., Zhang, X., Ren, S., and Sun, J. Deep residual learning for image recognition. In IEEE Conference on Computer Vision and Pattern Recognition, pp. 770-778, 2016. +Huang, Z., Wang, H., Xing, E. P., and Huang, D. Self-challenging improves cross-domain generalization. arXiv preprint arXiv:2007.02454, 2020. +Ilse, M., Tomczak, J. M., Louizos, C., and Welling, M. Diva: Domain invariant variational autoencoders. arXiv preprint arXiv:1905.10427, 2019. +Kingma, D. P. and Ba, J. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014. +Kingma, D. P. and Welling, M. Auto-encoding variational bayes. In International Conference on Learning Representations, 2014. +Kingma, D. P., Salimans, T., and Welling, M. Variational dropout and the local reparameterization trick. In Advances in neural information processing systems, pp. 2575-2583, 2015. +Kristiadi, A., Hein, M., and Hennig, P. Being Bayesian, even just a bit, fixes overconfidence in relu networks. arXiv preprint arXiv:2002.10118, 2020. +Krueger, D., Caballero, E., Jacobsen, J.-H., Zhang, A., Binas, J., Priol, R. L., and Courville, A. Out-of-distribution generalization via risk extrapolation (rex). arXiv preprint arXiv:2003.00688, 2020. +Li, D., Yang, Y., Song, Y.-Z., and Hospedales, T. M. Deeper, broader and artier domain generalization. In IEEE International Conference on Computer Vision, pp. 5542-5550, 2017. +Li, D., Yang, Y., Song, Y.-Z., and Hospedales, T. M. Learning to generalize: Meta-learning for domain generalization. In AAAI Conference on Artificial Intelligence, 2018a. + +Li, D., Zhang, J., Yang, Y., Liu, C., Song, Y.-Z., and Hesperales, T. M. Episodic training for domain generalization. In IEEE/CVF International Conference on Computer Vision, pp. 1446-1455, 2019. +Li, H., Jialin Pan, S., Wang, S., and Kot, A. C. Domain generalization with adversarial feature learning. In IEEE Conference on Computer Vision and Pattern Recognition, pp. 5400-5409, 2018b. +Li, K. and Malik, J. Learning to optimize. In International Conference on Learning Representations, 2017. +Long, M., Cao, Y., Wang, J., and Jordan, M. Learning transferable features with deep adaptation networks. In International Conference on Machine Learning, pp. 97-105. PMLR, 2015. +Louizos, C. and Welling, M. Multiplicative normalizing flows for variational bayesian neural networks. In International Conference on Machine Learning, pp. 2218-2227, 2017. +Louizos, C., Swersky, K., Li, Y., Welling, M., and Zemel, R. The variational fair autoencoder. arXiv preprint arXiv:1511.00830, 2015. +MacKay, D. J. The evidence framework applied to classification networks. Neural computation, 4(5):720-736, 1992. +Malinin, A. and Gales, M. Predictive uncertainty estimation via prior networks. In Advances in Neural Information Processing Systems, pp. 7047-7058, 2018. +Motiian, S., Piccirilli, M., Adjeroh, D. A., and Doretto, G. Unified deep supervised domain adaptation and generalization. In IEEE International Conference on Computer Vision, pp. 5715-5725, 2017. +Muandet, K., Balduzzi, D., and Scholkopf, B. Domain generalization via invariant feature representation. In International Conference on Machine Learning, pp. 10-18, 2013. +Nalisnick, E. and Smyth, P. Learning priors for invariance. In International Conference on Artificial Intelligence and Statistics, pp. 366-375, 2018. +Nguyen, A., Yosinski, J., and Clune, J. Deep neural networks are easily fooled: High confidence predictions for unrecognizable images. In IEEE Conference on Computer Vision and Pattern Recognition, pp. 427-436, 2015. +Nguyen, C. V., Li, Y., Bui, T. D., and Turner, R. E. Variational continual learning. In International Conference on Learning Representations, 2018. + +Peyre, G. and Cuturi, M. Computational optimal transport: With applications to data science. Foundations and Trends® in Machine Learning, 11(5-6):355-607, 2019. +Piratla, V., Netrapalli, P., and Sarawagi, S. Efficient domain generalization via common-specific low-rank decomposition. arXiv preprint arXiv:2003.12815, 2020. +Qiao, F., Zhao, L., and Peng, X. Learning to learn single domain generalization. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 12556-12565, 2020. +Saenko, K., Kulis, B., Fritz, M., and Darrell, T. Adapting visual category models to new domains. In European Conference on Computer Vision, pp. 213-226, 2010. +Seo, S., Suh, Y., Kim, D., Han, J., and Han, B. Learning to optimize domain specific normalization for domain generalization. arXiv preprint arXiv:1907.04275, 2019. +Shankar, S., Piratla, V., Chakrabarti, S., Chaudhuri, S., Jyothi, P., and Sarawagi, S. Generalizing across domains via cross-gradient training. arXiv preprint arXiv:1804.10745, 2018. +Venkateswara, H., Eusebio, J., Chakraborty, S., and Panchanathan, S. Deep hashing network for unsupervised domain adaptation. In IEEE Conference on Computer Vision and Pattern Recognition, pp. 5018-5027, 2017. +Volpi, R., Namkoong, H., Sener, O., Duchi, J. C., Murino, V., and Savarese, S. Generalizing to unseen domains via adversarial data augmentation. In Advances in Neural Information Processing Systems, pp. 5334-5344, 2018. +Wang, H., He, Z., Lipton, Z. C., and Xing, E. P. Learning robust representations by projecting superficial statistics out. In International Conference on Learning Representations, 2018. +Wang, Z., Cheng, X., Sapiro, G., and Qiu, Q. A dictionary approach to domain-invariant learning in deep networks. In Advances in Neural Information Processing Systems, 2020. +Zhao, S., Gong, M., Liu, T., Fu, H., and Tao, D. Domain generalization via entropy regularization. Advances in Neural Information Processing Systems, 33, 2020. +Zhou, K., Yang, Y., Hospedales, T., and Xiang, T. Learning to generate novel domains for domain generalization. arXiv preprint arXiv:2007.03304, 2020. +Zhou, K., Yang, Y., Qiao, Y., and Xiang, T. Domain generalization with mixstyle. In International Conference on Learning Representations, 2021. \ No newline at end of file diff --git a/abitmorebayesiandomaininvariantlearningwithuncertainty/images.zip b/abitmorebayesiandomaininvariantlearningwithuncertainty/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..39fe56c0b7bbfcd4d5438e495d57aaec319882e9 --- /dev/null +++ b/abitmorebayesiandomaininvariantlearningwithuncertainty/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f7e42afb031eb5cda0a040905db0603a3585a094647a815c70236a50144f97a6 +size 544947 diff --git a/abitmorebayesiandomaininvariantlearningwithuncertainty/layout.json b/abitmorebayesiandomaininvariantlearningwithuncertainty/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..f26730d2ca9ad5416bd13ea36f7ab6c75613504d --- /dev/null +++ b/abitmorebayesiandomaininvariantlearningwithuncertainty/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cdfd23999b966fdec049560bd73d97370f9398f0975b4fe355808d725839ffa3 +size 468258 diff --git a/acollectivelearningframeworktoboostgnnexpressivenessfornodeclassification/1759542a-2ec1-468a-bc92-fb02d0d16f4a_content_list.json b/acollectivelearningframeworktoboostgnnexpressivenessfornodeclassification/1759542a-2ec1-468a-bc92-fb02d0d16f4a_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..f2d8af9ecda2dcbe71b1eb844d18d79ec5c916ea --- /dev/null +++ b/acollectivelearningframeworktoboostgnnexpressivenessfornodeclassification/1759542a-2ec1-468a-bc92-fb02d0d16f4a_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:91199d5063c880736b0dfa49428dad29410c0890cd6a8e8c8472b70765255024 +size 92800 diff --git a/acollectivelearningframeworktoboostgnnexpressivenessfornodeclassification/1759542a-2ec1-468a-bc92-fb02d0d16f4a_model.json b/acollectivelearningframeworktoboostgnnexpressivenessfornodeclassification/1759542a-2ec1-468a-bc92-fb02d0d16f4a_model.json new file mode 100644 index 0000000000000000000000000000000000000000..4bfc682604ce44d8c89776c3ff5a898a8f1bdea7 --- /dev/null +++ b/acollectivelearningframeworktoboostgnnexpressivenessfornodeclassification/1759542a-2ec1-468a-bc92-fb02d0d16f4a_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:22d7ed6f8db1e067d89b741b51464e49273d143fc94ec01345ee7c3226f86866 +size 113813 diff --git a/acollectivelearningframeworktoboostgnnexpressivenessfornodeclassification/1759542a-2ec1-468a-bc92-fb02d0d16f4a_origin.pdf b/acollectivelearningframeworktoboostgnnexpressivenessfornodeclassification/1759542a-2ec1-468a-bc92-fb02d0d16f4a_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..b64b1170e154dd28bf6d1bea637b54660bcf9dcc --- /dev/null +++ b/acollectivelearningframeworktoboostgnnexpressivenessfornodeclassification/1759542a-2ec1-468a-bc92-fb02d0d16f4a_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1d54856c5f1fc09c148d955540e9399a3d17d95e51f69a657128ea8434b66a8f +size 519120 diff --git a/acollectivelearningframeworktoboostgnnexpressivenessfornodeclassification/full.md b/acollectivelearningframeworktoboostgnnexpressivenessfornodeclassification/full.md new file mode 100644 index 0000000000000000000000000000000000000000..e76e3eb52f1190e460cb8355f308aecca64e8f61 --- /dev/null +++ b/acollectivelearningframeworktoboostgnnexpressivenessfornodeclassification/full.md @@ -0,0 +1,383 @@ +# A Collective Learning Framework to Boost GNN Expressiveness for Node Classification + +Mengyue Hang1 Jennifer Neville1 Bruno Ribero1 + +# Abstract + +Collective Inference (CI) is a procedure designed to boost weak relational classifiers, specially for node classification tasks. Graph Neural Networks (GNNs) are strong classifiers that have been used with great success. Unfortunately, most existing practical GNNs are not most-expressive (universal). Thus, it is an open question whether one can improve strong relational node classifiers, such as GNNs, with CI. In this work, we investigate this question and propose collective learning for GNNs—a general collective classification approach for node representation learning that increases their representation power. We show that previous attempts to incorporate CI into GNNs fail to boost their expressiveness because they do not adapt CI's Monte Carlo sampling to representation learning. We evaluate our proposed framework with a variety of state-of-the-art GNNs. Our experiments show a consistent, significant boost in node classification accuracy—regardless of the choice of underlying GNN—for inductive node classification in partially-labeled graphs, across five real-world network datasets. + +# 1. Introduction + +A large body of work in relational learning focuses on collective classification frameworks for strengthening poorly-expressive (i.e., local) relational node classifiers (e.g., relational logistic regression, naive Bayes, decision trees (Neville et al., 2003a)), by incorporating dependencies among node labels and propagating inferences during classification to improve performance, particularly in semi-supervised settings (Koller et al., 2007; Pfeiffer III et al., 2015; Xiang & Neville, 2008). However, a long-standing open question is when/if collective inference is needed, par + +$^{1}$ Department of Computer Science, Purdue University, West Lafayette, Indiana, USA. Correspondence to: Mengyue Hang . + +Proceedings of the $38^{th}$ International Conference on Machine Learning, PMLR 139, 2021. Copyright 2021 by the author(s). + +ticularly as more expressive relational graph models become available, e.g., Graph Neural Networks (GNNs). + +Despite the recent success of GNNs at node and graph classification tasks (Hamilton et al., 2017; Kipf & Welling, 2016; Luan et al., 2019; Xu et al., 2018), these GNNs are no more powerful than the Weisfeiler-Lehman (WL) graph isomorphism test, and thus, inherit its shortcomings. In other words, existing GNNs are not universal (most-expressive) graph representations (Chen et al., 2019; Morris et al., 2019; Murphy et al., 2019; Xu et al., 2018). This implies that these GNNs (which we refer to as WL-GNNs and also includes GCNs (Kipf & Welling, 2016)) are not expressive enough for some node classification tasks, since their representation can provably fail to distinguish non-isomorphic nodes with different labels. + +While recently there has been increasing interest in developing more expressive WL-GNNs for graph classification tasks that can differentiate non-isomorphic graphs by considering higher-order GNNs (e.g. (Maron et al., 2019a; Bouritsas et al., 2020; Vignac et al., 2020; Azizian & Lelarge, 2021; Beaini et al., 2020), these methods primarily consider graph-level representations and, even when they can be adapted for node-level classification tasks, they would be computationally expensive to apply. Is there a easy-to-implement add-on procedure to existing WL-GNNs that can boost their node classification expressiveness? + +To address this question, in this work, we theoretically and empirically investigate the potential for collective inference to improve the expressiveness of GNNs. We devise an add-on training and inference procedure, which we denote collective learning, that incorporates label dependencies among neighboring nodes via predicted label sampling—akin to how collective classification improves not-so-expressive classifiers—and show that it can improve the expressiveness of any WL-GNN. + +# Contributions: + +- We propose $CL + GNN$ , an add-on collective learning framework to GNNs that provably boosts their expressiveness for node classification tasks, beyond that of an optimal WL-GNN*. $CL + GNN$ uses self-supervised + +learning and Monte Carlo sampled embeddings to incorporate node labels during inductive learning—and it can be implemented with any component GNN. + +We provide theoretical analysis of $CL + GNN$ + +- Theorem 1 shows that collective classification is provably unnecessary for GNNs that are most-expressive. +- Since WL-GNNs are not most-expressive, Theorem 2 and Proposition 1 show that $CL + GNN$ boosts the expressiveness of optimal WL-GNN and practical WL-GNNs. +- Corollary 1 shows that previous attempts to incorporate collective inference into WL-GNNs (which in contrast to $CL + GNN$ do not Monte Carlo sample embeddings) cannot increase expressivity beyond that of an optimal WL-GNN. + +- We design and conduct extensive experiments to confirm the above theoretical claims. $CL + GNN$ achieves a consistent improvement of node classification accuracy, across a variety of state-of-the-art WL-GNNs, for tasks involving unlabeled and partially-labeled test graphs. Our ablation study demonstrates the effectiveness of our approach incorporating collective learning in GNNs via self-supervised learning with Monte Carlo sampling of embeddings. + +# 2. Problem Formulation + +We consider the problem of inductive node classification across partially-labeled graphs, which takes as input a graph $G^{(\mathrm{tr})} = (V^{(\mathrm{tr})}, E^{(\mathrm{tr})}, \mathbf{X}^{(\mathrm{tr})}, \mathbf{Y}_L^{(\mathrm{tr})})$ for training, where $V^{(\mathrm{tr})}$ is a set of $n^{(\mathrm{tr})}$ vertices, $E^{(\mathrm{tr})} \subset V^{(\mathrm{tr})} \times V^{(\mathrm{tr})}$ is a set of edges with adjacency matrix $\mathbf{A}^{(\mathrm{tr})}$ , $\mathbf{X}^{(\mathrm{tr})}$ is a $n^{(\mathrm{tr})} \times p$ matrix containing node attributes as $p$ -dimensional vectors, and $\mathbf{Y}_L^{(\mathrm{tr})}$ is a set of observed labels (with $C$ classes) of a connected set of nodes $V_L^{(\mathrm{tr})} \subset V^{(\mathrm{tr})}$ , where $V_L^{(\mathrm{tr})}$ is assumed to be a proper subset of $V^{(\mathrm{tr})}$ , noting that $V_L^{(\mathrm{tr})} \neq \emptyset$ . Let $\mathbf{Y}_U^{(\mathrm{tr})}$ be the unknown labels of nodes $V_U^{(\mathrm{tr})} = V^{(\mathrm{tr})} \setminus V_L^{(\mathrm{tr})}$ . The goal is to learn a joint model of $\mathbf{Y}_U^{(\mathrm{tr})} \sim P(\mathbf{Y}_U | G^{(\mathrm{tr})})$ and apply this same model to predict hidden labels $\mathbf{Y}_U^{(\mathrm{te})}$ in another test graph $G^{(\mathrm{te})}$ , i.e., $\hat{\mathbf{Y}}_U^{(\mathrm{te})} = \arg \max_{\mathbf{Y}_U} P(\mathbf{Y}_U | G^{(\mathrm{te})})$ . The test graph $G^{(\mathrm{te})}$ can be partially labeled or unlabeled so $V_L^{(\mathrm{te})} \supseteq \emptyset$ . + +Graph Neural Networks (GNNs), which aggregate node attribute information to produce node representations, have been successfully used for this task. At the same time, relational machine learning (RML) methods, which use collective inference to boost the performance of local node + +pressive version of a GNN-one that has the same distinguishing power as a Weisfeiler-Lehman test. Note this is not a universal graph representation. + +classifiers via (predicted) label dependencies, have also been successfully applied to this task. + +Since state-of-the-art GNNs are not most-expressive for node classification (Morris et al., 2019; Xu et al., 2018), collective classification ideas may help to improve the expressiveness of GNNs. In particular, collective inference methods often sample predicted labels (conditioned on observed labels) to improve the local representation around nodes and approximate the joint distribution $P(\mathbf{Y}_U|G^{(\mathrm{te})})$ . We also know from recent research that sampling randomized features can boost GNN expressiveness (Murphy et al., 2019). This leads to the key conjecture of this work Hypothesis 1, which we prove theoretically in Section 4 and validate empirically by extensive experimentation in Section 5. + +Hypothesis 1. Since current Graph Neural Networks (e.g. GCN, GraphSAGE, TK-GCN) cannot produce most expressive graph representations, collective learning (which takes label dependencies into account via Monte Carlo sampling) can improve the accuracy of node classification by producing a more expressive graph representation. + +Why? Because WL-GNNs can extract more information about local neighborhood dependencies via sampling (Murphy et al., 2019), and sampling predicted labels allows GNNs to pay attention to the relationship between node attributes, the graph topology, and label dependencies in local neighborhoods. With collective learning, GNNs will be able to incorporate more information into the estimated joint label distribution. Next, we describe our collective learning framework. + +# 3. Proposed Framework: Collective Learning + +In this section, we outline $CL + GNN$ . It is a general framework to incorporate any GNN, and combines self-supervised learning approach and Monte Carlo embedding sampling in an iterative process to improve inductive learning on partially labeled graphs. + +Specifically, given a partially labeled training graph $G^{(\mathrm{tr})} = (V^{(\mathrm{tr})}, E^{(\mathrm{tr})}, \mathbf{X}^{(\mathrm{tr})}, \mathbf{Y}_L^{(\mathrm{tr})})$ with adjacency matrix $\mathbf{A}^{(\mathrm{tr})}$ and a partially-labeled test graph $G^{(\mathrm{te})} = (V^{(\mathrm{te})}, E^{(\mathrm{te})}, \mathbf{X}^{(\mathrm{te})}, \mathbf{Y}_L^{(\mathrm{te})})$ with adjacency matrix $\mathbf{A}^{(\mathrm{te})}$ . The goal of inductive node classification task is to train a joint model on $G^{(\mathrm{tr})}$ to learn $P(\mathbf{Y}_U|G^{(\mathrm{tr})})$ and apply it to $G^{(\mathrm{te})}$ by replacing the input graph $G^{(\mathrm{tr})}$ with $G^{(\mathrm{te})}$ . Suppose the graphs $G^{(\mathrm{tr})}$ and $G^{(\mathrm{te})}$ , we can define $\mathbf{Y}_L^{(\mathrm{tr})}$ as a binary (0-1) matrix of dimension $|V^{(\mathrm{tr})}| \times C$ , and $\mathbf{Y}_L^{(\mathrm{te})}$ of dimension $|V^{(\mathrm{te})}| \times C$ , where the rows corresponding to the one-hot encoding of the (available) labels. + +(Background) GNN and representation learning. Given a partially labeled graphs $G^{(\mathrm{tr})}$ , WL-GNNs generate node representation by propagating feature information through- + +# At iteration t: + +![](images/07d23aa94dac8cb69664263aef8e9fbb0e9ed4578fe87c75c7533e4876c2c2e2.jpg) +Step 1: Sample a $|\mathbf{V}|$ -dim binary mask +Step 2: Obtain label prediction $\hat{Y}^{(t - 1)}$ + +![](images/2fefa7db9e0830d4e72c3edb3ba49ed69579c69b5f7c419d4f5564e4fd654305.jpg) +if $t = 1$ , go to step 4 + +Step 3: Average CLGNN representation +Figure 1: CLGNN model framework. Each iteration consists of four steps: (Step 1) Sample a random mask; (Step 2) Obtain predicted label distribution using the WL-GNN structure; (Step 3) Sample predicted labels for whatever nodes are masked, use again as input to the WL-GNN and average representations over the sampled predicted labels; (Step 4) Perform one optimization step by minimizing a negative log-likelihood upper bound. +![](images/2c370b5f2a11a538b2e1a3b233a3879ad0538c324a5cbfdf653157995a34fc26.jpg) +labels used in GNN input + +![](images/1e029d6a3961cf56f7e166172569929fbd05daadda7738fdf724ab3e84560f83.jpg) +no label (all-zero) +true label +predicted label + +out the graph. Specifically, $\forall v\in V^{(\mathrm{tr})}$ + +$$ +P \left(\mathbf {Y} _ {v} \mid \mathbf {X} ^ {\text {(t r)}}, \mathbf {Y} _ {L} ^ {\text {(t r)}}, \mathbf {A} ^ {\text {(t r)}}\right) = \sigma \left(\mathbf {W} \mathbf {Z} _ {v} + \mathbf {b}\right), \tag {1} +$$ + +where $Z_v = \mathrm{GNN}(X^{(\mathrm{tr})}, A^{(\mathrm{tr})}; \Theta)_v$ is the GNN representation of node $v$ , $\sigma(\cdot)$ is the softmax activation, and $\Theta, W$ and $b$ are model parameters, which are learned by minimizing the cross-entropy loss between true labels $Y_L^{(\mathrm{tr})}$ and the predicted labels. + +The collective learning framework. Following Hypothesis 1, we propose Collective Learning GNNs $(CL + GNN)$ , which includes label information as input to GNNs to produce a more expressive representation. The overall framework follows four steps: (Step 1) Sample a random binary mask to include true labels (if available) in the input; (Step 2) Obtain predicted label distribution using the WL-GNN structure; (Step 3) Sample predicted labels for whatever nodes are masked, combine with available true labels (if any), and use again as input to the WL-GNN; finally average representations of the WL-GNN over the sampled predicted labels; (Step 4) Perform one optimization step by minimizing a negative log-likelihood upper bound. These steps are shown in Figure 1. Collective learning for WL-GNNs then consists of iterating over Steps 1-4 for $t = 1,\dots,T$ iterations. Finally, once optimized, we perform inference via Monte Carlo estimates. + +$CL + GNN$ loss and its representation averaging. The input to GNNs is typically the full graph $G^{(\mathrm{tr})}$ . If we included the observed labels $\mathbf{Y}_L^{(\mathrm{tr})}$ directly in the input, then it would be trivial to learn a model that predicts part of the input. Instead, we either (scenario test-unlabeled) mask all label inputs if the test graph $G^{(\mathrm{te})}$ is expected to be unlabeled; or (scenario test-partial) if $G^{(\mathrm{te})}$ is expected to have partial labels, we apply a mask to the labels we wish to predict in training so they do not appear in the input $\mathbf{Y}_L^{(\mathrm{tr})}$ . + +Specifically, at the $t$ -th step of our optimization--these steps can be coarser than a gradient step -- we either (scenario test-partial) sample a mask $\pmb{M}^{(t)}\sim$ Uniform $(\mathcal{M})$ or (scenario test-unlabeled) set $\pmb{M}^{(t)} = \pmb{0}$ . For now, we assume we can sample $\hat{\mathbf{Y}}^{(t - 1)} = (\hat{\mathbf{Y}}_v^{(t - 1)})_{v\in V^{(\mathrm{tr})}}$ from an estimate of the distribution $P(\pmb{Y}_v^{\mathrm{(tr)}}|\pmb{X}^{\mathrm{(tr)}},\pmb{Y}_L^{\mathrm{(tr)}}\odot \pmb{M}^{(t)},\pmb{A}^{\mathrm{(tr)}})$ --we will come back to this assumption soon. Let $\pmb{X}_{\pmb{Y}_L^{\mathrm{(tr)}},\hat{\pmb{Y}}^{(t - 1)},\pmb{M}^{(t)}}^{\mathrm{(tr)}}$ be the matrix concatenation between $\pmb{Y}_{L}^{\mathrm{(tr)}}\odot \pmb{M}^{(t)} + \hat{\pmb{Y}}^{(t - 1)}\odot \overline{\pmb{M}}^{(t)}$ and $\pmb{X}^{\mathrm{(tr)}}$ , where again $\overline{\boldsymbol{M}} := \mathbf{1} - \boldsymbol{M}$ is the bitwise negated matrix of $\boldsymbol{M}$ . Let + +$$ +\boldsymbol {Z} _ {v} ^ {(t)} \left(\boldsymbol {M} ^ {(t)}; \Theta\right) = \mathbb {E} _ {\hat {\boldsymbol {Y}} ^ {(t - 1)}} \left[ \operatorname {G N N} \left(\boldsymbol {X} _ {\boldsymbol {Y} _ {L} ^ {(\mathrm {t r})}, \hat {\boldsymbol {Y}} ^ {(t - 1)}, \boldsymbol {M} ^ {(t)}}, \boldsymbol {A} ^ {(\mathrm {t r})}; \Theta\right) _ {v} \right], \tag {2} +$$ + +where GNN represents an arbitrary graph neural network model and $Z_v^t$ is the $CL + GNN$ 's representation obtained for node $v \in V^{(\mathrm{tr})}$ at step $t \geq 1$ . + +Our optimization is defined over the expectation of $Z_v^{(t)}(M^{(t)})$ w.r.t. to the sampled predicted labels $\hat{Y}^{(t - 1)}$ (Equation (2)) and over a loss averaged over all sampled masks (noting that the case where $M^{(t)} = 0$ is trivial): + +$$ +\begin{array}{l} \Theta_ {t}, \mathbf {W} _ {t}, \mathbf {b} _ {t} = \underset {\Theta , \mathbf {W}, \mathbf {b}} {\arg \max } \mathbb {E} _ {\boldsymbol {M} ^ {(t)}} \left[ \sum_ {v \in V _ {L} ^ {(\mathrm {t r})}} \overline {{\boldsymbol {M}}} _ {v} ^ {(t)} \right. \tag {3} \\ \left. \times \log \sigma \left(\mathbf {W} Z _ {v} ^ {(t)} \left(M ^ {(t)}; \Theta\right) + \mathbf {b}\right) _ {y _ {v} ^ {(\mathrm {t r})}} \right], \\ \end{array} +$$ + +where again, $\sigma (\cdot)$ is the softmax activation function, and $V_{L}^{(\mathrm{tr})}$ are the labeled nodes in training graph. + +Stochastic optimization of Equation (3). Equation (3) is based on a pseudolikelihood, where the joint distribution of the labels $\{\mathbf{Y}_v^{\mathrm{(tr)}}:v\in V_L^{\mathrm{(tr)}}\mathrm{s.t.}\overline{\mathcal{M}}_v^{(t)} = 1\}$ is decomposed as marginal distributions resulting in the sum over $V_{L}^{\mathrm{(tr)}}$ + +(Step 1) Sample a binary mask In (scenario test-partial), where $G^{(\mathrm{te})}$ is expected to have some observed labels, we randomly sample a binary mask $M \sim \mathrm{Uniform}(\mathcal{M})$ from a set of masks, where $M$ is a $|V^{(\mathrm{tr})}| \times C$ binary (0-1) matrix with the same $|V^{(\mathrm{tr})}|$ -dimensional vector in each column. By applying the mask on the observed labels $Y_{L}^{(\mathrm{tr})}$ , the set of true labels is effectively partitioned into two parts, where part of the true labels $Y_{L}^{(\mathrm{tr})} \odot M$ are used as input to $CL + GNN$ , and the other part $Y_{L}^{(\mathrm{tr})} \odot \overline{M}$ are used as optimization target. Here $\overline{M} := 1 - M$ is the bitwise negated matrix of $M$ . + +(Step 2) Obtaining $\hat{\mathbf{Y}}^{(t - 1)}$ . Note that in Equation (2), we first need to obtain the predicted label distribution $\hat{\mathbf{Y}}^{(t - 1)}$ with mask $M^{(t)}$ to sample labels from. At iteration $t$ , we use the learned $CL + GNN$ model parameter $\Theta_{t - 1}$ to obtain $\mathbf{Z}_v^{(t - 1)}$ according to Equation (2) and use the $CL + GNN$ model parameters $\mathbf{W}_{t - 1},\mathbf{b}_{t - 1}$ to obtain the label prediction recursively, i.e. $\forall v\in V^{\mathrm{(tr)}}$ + +$$ +\hat {\mathbf {Y}} _ {v} ^ {(t - 1)} \sim \text {C a t e g o r i c a l} (\sigma \left(\mathbf {W} _ {t - 1} \mathbf {Z} _ {v} ^ {(t - 1)} \left(M ^ {(t)}; \Theta_ {t - 1}\right) + \mathbf {b} _ {t - 1}\right)), \tag {4} +$$ + +where + +$$ +Z _ {v} ^ {(t - 1)} \left(M ^ {(t)}; \Theta_ {t - 1}\right) = \operatorname {G N N} \left(X _ {\mathbf {Y} _ {L} ^ {(\mathrm {t r})}, \mathbf {0}, M ^ {(t)}} ^ {(\mathrm {t r})}, A ^ {(\mathrm {t r})}; \Theta_ {t - 1}\right) _ {v} \tag {5} +$$ + +Note that $Z_{v}^{(t - 1)}(M^{(t)};\Theta)$ does not use any predicted labels in the GNN input, i.e. it uses the true labels for masked nodes or all-zero labels for unmasked nodes. + +In order to optimize Equation (3), we compute gradient estimates w.r.t. $\Theta$ and $\mathbf{b}$ using the following sampling procedure. + +(Step 3) We first need to compute an unbiased estimate of $\{Z_v^{(t - 1)}\}_{v\in V_L^{(\mathrm{tr})}}$ in Equation (2) using $K$ i.i.d. samples $\hat{\mathbf{Y}}^{(t - 1)}$ from the model obtained at time step $t - 1$ (as + +describe above), i.e. + +$$ +\tilde {\boldsymbol {Z}} _ {v} ^ {(t)} \left(\boldsymbol {M} ^ {(t)}; \Theta_ {t}\right) = \frac {1}{K} \sum_ {k = 1} ^ {K} \operatorname {G N N} \left(\boldsymbol {X} _ {\boldsymbol {Y} _ {L} ^ {(\mathrm {t r})}, \hat {\boldsymbol {Y}} _ {k} ^ {(t - 1)}, \boldsymbol {M} ^ {(t)}} ^ {(\mathrm {t r})}, \boldsymbol {A} ^ {(\mathrm {t r})}; \Theta_ {t}\right) _ {v}, \tag {6} +$$ + +where again $X_{\mathbf{Y}_L^{(\mathrm{tr})},\hat{\mathbf{Y}}^{(t - 1)},\mathbf{M}^{(t)}}$ is the matrix concatenation between $\pmb{X}^{\mathrm{(tr)}}$ and $\pmb {Y}_L^{\mathrm{(tr)}}\odot \pmb {M}^{(t)} + \hat{\pmb{Y}}^{(t - 1)}\odot \overline{\pmb{M}}^{(t)}$ + +Note that the time/space complexity of the $CL + GNN$ is $K$ times the time/space complexity of the corresponding GNN model as we have to compute $K$ representations for each node at each stochastic gradient step. + +(Step 4) Next, we need an unbiased estimate of the expectation over mask $M^{(t)}$ in Equation (3). In (scenario test-partial) the unbiased estimates are obtained by sampling $M^{(t)} \sim \mathrm{Uniform}(\mathcal{M})$ at each gradient step, in the (scenario test unlabeled) the value obtained is exact since $M^{(t)} = 0$ . The mask $M^{(t)}$ is used, along with the estimate $\tilde{\pmb{Z}}$ from Equation (6), to compute the loss function as in Equation (3) and perform a gradient descent step. Proposition 2 shows that the above procedure is a proper surrogate upperbound of the loss function. + +# Inference with learned model. + +Once the $CL + GNN$ parameters $\Theta_T, W_T, b_T$ are learned according to Equation (3) on the training graph $G^{(\mathrm{tr})}$ , given an any-size attributed graph $G^{(te)}$ , we sample $J$ masks $M$ of size $|V^{(\mathrm{te})}|$ , either (scenario test-partial) sampling $M \sim \mathrm{Uniform}(\mathcal{M})$ or (scenario test-unlabeled) set $M = 0$ . For each mask, we apply the same procedure as in (Step 2) and (Step 3) to obtain predicted label distribution $\hat{\mathbf{Y}}^{(\mathrm{tmp})}$ , and then sample $K$ labels $\{\hat{\mathbf{Y}}_1^{(\mathrm{tmp})}, \dots, \hat{\mathbf{Y}}_K^{(\mathrm{tmp})}\}$ from it and pass to the learned model. The node representations for $v \in V^{(\mathrm{te})}$ are obtained using $M$ and $\hat{\mathbf{Y}}_{1,\dots,K}^{(\mathrm{tmp})}$ : + +$$ +\tilde {\boldsymbol {Z}} _ {v} (M; \Theta_ {T}) = \frac {1}{K} \sum_ {k = 1} ^ {K} \operatorname {G N N} \left(\boldsymbol {X} _ {\boldsymbol {Y} _ {L} ^ {(\mathrm {t e})}, \hat {\boldsymbol {Y}} _ {k} ^ {(\mathrm {t m p})}, \boldsymbol {M}}, \boldsymbol {A} ^ {(\mathrm {t e})}; \Theta_ {T}\right) _ {v}, +$$ + +where + +$$ +(\hat {\boldsymbol {Y}} _ {k} ^ {(\mathrm {t m p})}) _ {v} \sim \operatorname {C a t e g o r i c a l} (\sigma (\mathbf {W} _ {T} \mathbf {Z} _ {v} ^ {(\mathrm {t m p})} (\boldsymbol {M}; \Theta_ {T}) + \mathbf {b} _ {T})), +$$ + +and + +$$ +Z _ {v} ^ {\left(\operatorname {t m p}\right)} (M; \Theta_ {T}) = \operatorname {G N N} \left(X _ {Y _ {L} ^ {\left(\mathrm {t e}\right)}, 0, M ^ {\left(\mathrm {t e}\right)}}, A ^ {\left(\mathrm {t e}\right)}; \Theta_ {T}\right) _ {v}. +$$ + +The final node representation is computed as the average over all sampled masks: + +$$ +\tilde {\boldsymbol {Z}} _ {v} = \frac {1}{J} \sum_ {j = 1} ^ {J} \tilde {\boldsymbol {Z}} _ {v} (M _ {j}; \Theta_ {T}), +$$ + +where $J$ and $K$ are hyperparameters, $J$ is the number of masks for our Monte Carlo average and $K$ is the number + +of Monte Carlo samples of $\hat{\mathbf{Y}}^{(\mathrm{tmp})}$ . Then the label predictions are obtained using the learned $CL + GNN$ parameters $\boldsymbol{W}_T, \boldsymbol{b}_T$ : + +$$ +\hat {\mathbf {Y}} _ {v} ^ {(\mathrm {t e})} \sim \text {C a t e g o r i c a l} \left(\sigma \left(\mathbf {W} _ {T} \tilde {\mathbf {Z}} _ {v} + \mathbf {b} _ {T}\right) _ {v}\right), \forall v \in V ^ {(\mathrm {t e})}. \tag {7} +$$ + +# 4. Collective Learning Analysis + +Is collective classification able to better represent target label distributions than node representation learning? The answer to this question is both yes (for WL-GNNs) and no (for most-expressive representations). Theorem 1 shows that a most-expressive graph representation (Murphy et al., 2019; Maron et al., 2019b; Srinivasan & Ribeiro, 2019) would not benefit from a collective learning boost. All proofs can be found in the Appendix. + +Theorem 1 (Collective classification can be unnecessary). Consider the task of predicting node labels when no labels are available in test data. Let $\Gamma^{\star}(v, G^{(te)})$ be a most-expressive representation of node $v \in V^{(te)}$ in graph $G^{(te)}$ . Then, for any collective learning procedure predicting the class label of $v \in V^{(te)}$ , there exists a classifier that takes $\Gamma^{\star}(v, G^{(te)})$ as input and predicts the label of $v$ with equal or higher accuracy. + +While Theorem 1 shows that the most-expressive graph representation does not need collective classification, WL-GNNs are not most-expressive (Morris et al., 2019; Murphy et al., 2019; Xu et al., 2018). Indeed, Theorem 2 and Proposition 1 show that $CL + GNN$ boosts the expressiveness of optimal WL-GNN and practical WL-GNNs, respectively. Then, we show that the stochastic optimization in Step 3 optimizes a loss surrogate upper bound. + +# 4.1. Expressive power of $CL + GNN$ + +Morris et al. (2019) and Xu et al. (2018) show that WL-GNNs are no more powerful in distinguishing nonisomorphic graphs and nodes as the standard Weisfeiler-Lehman graph isomorphism test (1-WL or just WL test). Two nodes are assumed isomorphic by the WL test if they have the same color assignment in the stable coloring. The node-expressivity of a parameterized graph representation $\Gamma$ (with parameter $\Gamma(\cdot; W)$ ) can then be determined by the set of graphs for which $\Gamma$ can identify non-isomorphic nodes: + +$$ +\begin{array}{l} \mathcal {G} (\Gamma) = \{G: \exists \boldsymbol {W} _ {G} ^ {\star}, \text {s . t .} \forall u, v \in V _ {G}, \Gamma (G; \boldsymbol {W} _ {G} ^ {\star}) _ {v} \\ = \Gamma (G; \boldsymbol {W} _ {G} ^ {\star}) _ {u} \text {i f f} u, v \text {a r e i s o m o r p h i c}, G \in \mathbb {G} \}, \\ \end{array} +$$ + +where $\mathbb{G}$ is the set of all any-size attributed graphs, $V_{G}$ is the set of nodes in graph $G$ . We call $\mathcal{G}(\Gamma)$ the identifiable set of graph representation $\Gamma$ . + +The most expressive graph representation $\Gamma^{\star}$ has an identifiable set of all any-size attributed graphs, i.e. $\mathcal{G}(\Gamma^{\star}) = \mathbb{G}$ . + +We refer to the WL-GNN that is equally expressive as WL test as the optimal WL-GNN (or WLGNN\*), which is at least as expressive as all other WL-GNNs. + +In this section we show that collective learning can boost the optimal WLGNN*, i.e., the identifiable set of WLGNN* is a proper subset of collective learning over WLGNN* (denoted $CL + GNN^{\star}$ ) + +$$ +\mathcal {G} \left(\mathrm {W L G N N} ^ {\star}\right) \subsetneq \mathcal {G} \left(C L + G N N ^ {\star}\right). +$$ + +Theorem 2 ( $CL + GNN^{\star}$ expressive power). Let $WLGNN^{\star}$ be an optimal WL-GNN. Then, the collective learning representation of Equation (2), using $WLGNN^{\star}$ as the GNN component, (denoted $\mathrm{CL} + \mathrm{GNN}^{\star}$ ) is strictly more expressive than this $WLGNN^{\star}$ representation model applied to the same tasks. + +Theorem 2 answers Hypothesis 1, by showing that by incorporating collective learning and sampling procedures, $CL + GNN$ can boost the expressiveness of WL-GNNs, including the optimal WLGNN\*. + +Corollary 1. Consider a graph representation learning method that, at iteration $t$ , replaces $\hat{\mathbf{Y}}^{(t - 1)}$ , in Equations (2) and (4) with a deterministic function over $Z^{(t - 1)}$ , e.g., a softmax function that outputs $(P(\hat{\mathbf{Y}}_v^{(t - 1)}|Z^{(t - 1)}))_{v\in V^{(tr)}}$ . Then, such method will be no more expressive than the optimal WLGNN* and, hence, less expressive than CL+GNN*. + +Corollary 1 proves that existing collective approaches are no different than current GNN methods (hence, no boosting). More specifically, it shows that existing graph representation methods that —on the surface— may even look like $CL + GNN$ , but do not perform the crucial step of sampling $(\hat{Y}_v^{(t - 1)})_{v\in V^{(\mathrm{tr})}}$ , unfortunately, are no more expressive than WL-GNNs. Examples of such methods include (Fan & Huang, 2019; Moore & Neville, 2017; Qu et al., 2019; Vijayan et al., 2018). + +Next, we show the practical benefits of collective learning are even greater when the WL-GNN has limited expressive power due to limited message-passing layers. + +# 4.2. How $CL + GNN$ further expands the power of few-layer WL-GNNs + +A $d$ -layer ( $d > 1$ ) WL-GNN will only aggregate neighborhood information within $d$ hops of any given node (i.e., over a $d$ -hop egonet, defined as the graph representing the connections among all nodes that are at most $d$ hops away from the center node). In practice—mostly for computational reasons—WL-GNNs have many fewer layers than the graph's diameter $D$ , i.e., $d < D$ . For instance, GCN (Kipf & Welling, 2016) and GraphSAGE (Hamilton et al., 2017) both used $d = 2$ in their experiments. Hence, they cannot differentiate two non-isomorphic nodes that are iso- + +morphic within their $d$ -hop neighborhood. We now show that $CL + GNN$ can gather $2d$ -hop neighborhood information with a $d$ -layer WL-GNN. + +Proposition 1. Let $G_v^d$ be the $d$ -hop egonet of a node $v$ in graph $G$ with diameter $D > d$ . Let $v_1$ and $v_2$ be two non-isomorphic nodes whose $d$ -hop egonets are isomorphic (i.e., $G_{v_1}^d$ is isomorphic to $G_{v_2}^d$ ) but $2d$ -hop egonets are not isomorphic. Then, a WL-GNN representation with $d$ layers will generate identical representations for $v_1$ and $v_2$ while CL+GNN is capable of giving distinct node representations. + +Proposition 1 shows that collective learning has yet another benefit: $CL + GNN$ further boosts the power of WL-GNNs with limited message-passing layers by gathering neighborhood information within a larger radius. Specifically, $CL + GNN$ built on a WL-GNN with $d$ layers can enlarge the effective neighborhood radius from $d$ to $2d$ in Equation (2), while WL-GNN would have to stack $2d$ layers to achieve the same neighborhood radius, which in practice may cause optimization challenges (i.e., $d = 2$ is a common hyperparameter value in the literature). + +# 4.3. Optimization of $CL + GNN$ + +Proposition 2. If $\forall v\in V_L^{(tr)}$ $\nabla_{\Theta}(\mathbf{W}\mathbf{Z}_v^{(t)}(\mathbf{M}^{(t)};\Theta))_{y_v^{(tr)}}$ is bounded (e.g., via gradient clipping), then the optimization in Equation (3), with the unbiased sampling of $\{\pmb {Z}_v^{(t - 1)}\}_{v\in V^{(tr)}}$ and $M^{(t)}$ described above, results in a Robbins-Monro (Robbins & Monro, 1951) stochastic optimization algorithm that optimizes a surrogate upper bound of the loss in Equation (3). + +Since the optimization objective in Equation (3) is computationally impractical, as it requires computing all possible binary masks and label predictions, Proposition 2 shows that the sampling procedures used in $CL + GNN$ that considers $K$ samples of label predictions and a random mask at each gradient step is a feasible approach of estimating an unbiased upper bound of the objective. + +# 5. Experiments + +# 5.1. Experiment Setup + +Datasets. We use datasets of Cora, Pubmed, Friendster, Facebook, and Protein. The largest dataset (Friendster (Teixeira et al., 2019)) has 43,880 nodes, which is a social network of users where the node attributes include numerical features (e.g. number of photos posted) and categorical features (e.g. gender, college, etc.) encoded as binary one-hot features. The node labels represent one of the five age groups. Please refer to Appendix E for more details. + +Train/Test split. Since most datasets used to test GNNs consist of a single graph, we apply Louvain community detection algorithm (Blondel et al., 2008) to split each single graph into three clusters for training, validation, and testing respectively, and remove the edges across clusters —shown + +Connected split +![](images/0eb6e65c0214b67bb7872e1dcddacf4578e6a24de439a2d8f0237b74d3b2db1e.jpg) +O train validation test + +![](images/e5db8cd7d683a31dffbbb482d2409792064938bd81ada34da0cf80ff68f48266.jpg) +Random split +Figure 2: Different data splits between our inductive connected split (left) and conventional GNN random split (right) + +in Figure 2 (left). This mimics the inductive within-graph scenario that often occurs in real world settings, where a connected subgraph is used to learn a model to generalize the remainder of the graph —e.g., Facebook would train a model on Iceland or New Zealand and then apply it to the rest of the world, see methodology in (Bakshy et al., 2014). + +Our train/test data split is different than previous GNN works, which have adopted random node split between train and test —shown in Figure 2 (right)—and can put test nodes close to the training nodes, making it much easier to leverage test node attributes during training. Our use of a hard split between train and test (connected split) is the reason why the model performance reported in our paper is not directly comparable with the reported results in previous GNN papers, even though we used the same implementations and hyper-parameter search procedures. In our experiments, we tested two different label rates in test graph: 0 (unlabeled) and $50\%$ (reveal $50\%$ testing labels and evaluate on the rest). We run five trials for all the experiments, and in each trial we randomly pick a connected subgraph within the training cluster and reveal their labels for training. + +As our method can be applied to any GNN models, we use four representative GNNs as examples: + +- GCN (Kipf & Welling, 2016) which includes two graph convolutional layers. Here we implemented an inductive variant of the original GCN model for our tasks. +- Supervised GraphSage (Hamilton et al., 2017) (denoted by GS) with Mean pooling aggregator. We use sample size of 5 for neighbor sampling. +- Truncated Krylov GCN (Luan et al., 2019) (denoted by TK), a recent GNN model that leverages multi-scale information in different ways and are scalable in depth. The TK has stronger expressive power and achieved state-of-the-art performance on node classification tasks. We implemented Snowball architecture which achieved comparable performance with the other truncated Krylov architecture according to the original paper. + +A Collective Learning Framework to Boost GNN Expressiveness for Node Classification + +
# train labels:CoraconnectPubmedconnectFriendsterFacebookProtein
85 (3.21%)300 (1.52%)641 (1.47%)80 (1.76%)7607 (30%)
% labels in G(te):0%50%0%50%0%50%0%50%0%50%
Random14.28 (0.00)14.28 (0.00)33.33 (0.00)33.33 (0.00)20.00 (0.00)20.00 (0.00)50.00 (0.00)50.00 (0.00)50.00 (0.00)50.00 (0.00)
GCN (Kipf & Welling, 2016)-64.74 (1.51)66.34 (1.84)54.56 (2.49)58.41 (1.27)25.97 (0.69)24.26 (0.52)50.58 (1.38)51.04 (1.20)75.86 (1.11)77.54 (1.09)
+CL+3.72 (0.40)+12.41 (1.96)+1.95 (0.69)+15.37 (2.01)+0.70 (0.14)+1.99 (0.74)+2.24 (0.81)+8.51 (1.09)+1.22 (0.51)+0.75 (0.33)
GS (Hamilton et al., 2017)-65.35 (1.19)67.71 (1.53)55.56 (2.44)59.12 (2.02)26.45 (0.62)24.75 (0.39)51.14 (1.24)52.06 (1.29)73.85 (1.12)73.01 (2.28)
+CL+2.81 (1.02)+9.94(1.04)+1.05 (0.83)+14.71 (2.89)+0.13 (0.41)+1.40 (0.62)+1.77 (0.55)+7.80 (0.84)+0.84 (0.12)+1.47 (0.63)
TK (Luan et al., 2019)-68.47 (1.31)69.50 (0.55)59.05 (2.13)60.77 (1.53)25.93 (0.91)24.42 (1.44)52.74 (1.62)53.48 (1.48)73.65 (1.69)78.94 (1.50)
+CL+1.50 (0.61)+7.92 (0.75)+0.23 (0.61)+13.62 (1.84)+1.20 (0.14)+2.34 (0.42)+3.26 (0.98)+4.60 (1.16)+1.31 (0.27)+1.36 (0.94)
GRAND (Feng et al., 2020)-71.55 (1.07)73.19 (0.41)61.82 (6.40)63.23 (7.22)28.03 (1.02)27.02 (0.84)47.10 (0.27)48.14 (0.52)75.43 (1.12)79.69 (0.29)
+CL+0.80 (0.31)+2.30 (0.56)+3.79 (1.50)+5.17 (1.44)+0.37 (0.39)+4.21 (0.72)+6.38 (2.29)+5.72 (2.34)+0.51 (0.36)+0.75 (0.20)
Best of CL72.36 (1.20)*78.31 (0.58)*65.61 (6.60)*74.39 (1.72)*28.40 (0.85)*31.23 (1.05)*56.01 (1.48)59.86 (0.83)77.08 (1.03)80.52 (0.37)
PL-EM (Pfeiffer III et al., 2015)-20.66 (0.04)54.22 (0.94)38.85 (0.03)65.65 (4.33)18.13 (0.23)22.25 (0.87)50.58 (0.03)61.17 (1.14)78.46 (1.45)77.95 (1.56)
ICA (Lu & Getoor, 2003)-62.29 (2.18)65.51 (1.30)43.93 (6.84)44.61 (6.24)26.48 (1.37)27.80 (1.56)61.56 (1.10)*62.04 (1.92)*84.88 (3.35)*84.39 (4.08)*
GMNN (Qu et al., 2019)-66.35 (3.12)72.04 (2.45)57.13 (3.01)67.94 (4.40)24.92 (1.20)26.88 (1.53)49.56 (0.88)57.09 (0.78)76.75 (0.74)75.96 (0.76)
+ +Table 1: Node classification accuracy with unlabeled and partially-labeled test data. Numbers in bold represent significant improvement in a paired t-test at the $p < 0.05$ level, and numbers with * represent the best performing method in each column. Cora $^{\text{connect}}$ and Pubmed $^{\text{connect}}$ are our processed graphs with the connected split illustrated in Figure 2 (left). + +- GRAND (Feng et al., 2020), a recent GNN model using random propagation strategy to perform graph data augmentation, in order to mitigate the issues of oversmoothing and non-robustness. GRAND achieved state-of-the-art performance on several semi-supervised node classification tasks. + +For each of the GNNs, we compare its baseline performance (on its own) to the performance achieved using collective learning in $CL + GNN$ (using that GNN). For a fair comparison, we adopt the same hyper-parameter tuning strategy for the baseline GNNs and $CL + GNN$ , e.g. hidden dimensions, learning rate, early-stopping procedures. Please refer to Appendix E for details. + +In addition, we also compare to three relational classifiers, ICA (Lu & Getoor, 2003), PL-EM (Pfeiffer III et al., 2015) and GMNN (Qu et al., 2019). The first two models apply collective learning and inference with simple local classifiers — Naive Bayes for PL-EM and Logistic regression for ICA. GMNN is the state-of-the-art collective model with GNNs, which uses two GCN models to model label dependency and node attribute dependency respectively. All the three models take true labels in their input, thus we use $\boldsymbol{Y}_L^{(\mathrm{tr})}$ for training and $\boldsymbol{Y}_L^{(\mathrm{te})}$ for testing. + +We report the average accuracy score and standard error of five trials for the baseline models, and compute the absolute improvement of accuracy of our method over the corresponding base GNN. The best performance among all $CL + GNN$ is also reported. We compute the balanced accuracy scores on Friendster dataset as the label is highly imbalanced. To evaluate the significance of $CL + GNN$ improvements, we performed a paired t-test with five trials. + +# 5.2. Results + +The node classification accuracy of all the models is shown in Table 1. Our proposed collective learning boost is denoted + +as +CL (for Collective Learning) and our model performance (absolute % of improvement over the corresponding baseline GNN) is shown in shaded area. Numbers in bold represent significant improvement over the baseline GNN based on a paired t-test $(p < 0.05)$ , and numbers with * is the best performing method in each column. + +Comparison with baseline GNN models. Table 1 shows that our method improves the corresponding non-collective GNN models for all the four model architectures (i.e. GCN, GraphSage, TK and GRAND). Although all the models have large variances over multiple trials —because different parts of the graphs are being trained in different trials—adding CL consistently improves the baseline GNN. The results from a paired t-test comparing the performance of our method and the corresponding non-collective GNN show that the improvement is almost always significant at $p = 0.05$ (marked as bold), with only five exceptions. + +Comparing the gains on different datasets in Table 1, adding CL to GNNs achieved smaller gains on Friendster especially when no test labels were available. This is because Friendster is more sparse than the other graphs (e.g. edge density of Friendster is 1.5e-4 while Cora is 1.44e-3 (Teixeira et al., 2019)), which makes it hard for any model to propagate label information and capture label dependencies. + +As expected, comparing the improvement over various GNNs with different expressive power, we observe that in general adding CL boosts the gains of simpler GNN models (i.e. GCN and GS). For example, Table 1 shows that adding CL to a GCN can boost its accuracy by $+12.41\%$ (Cora) while the boost over TK is smaller at $+7.92\%$ in the same task. This is in line with our assumption in Hypothesis 1 that collective learning can help weaker GNNs produce a more expressive representation. As GCN is less expressive than TK, there is a larger room to increase its expressiveness. + +Note that the gains in Table 1 are generally much larger when we go from $0\%$ to $50\%$ of the labels available in + +test. For example, when combining with GCN, the improvements of our method are $3.72\%$ and $2.24\%$ for unlabeled Cora and Facebook test sets, but with partially-labeled test data, the improvements are $12.41\%$ and $8.51\%$ respectively. This shows the importance of modeling label dependency especially when the some test data labels are observed. + +Comparison with other relational classifiers The two baseline non-GNN relational models —i.e. PL-EM and ICA— generally perform worse than the three GNNs, with exceptions on Protein and Facebook datasets. This could be because the two dataset has only a few node attributes (3 for Facebook and 29 for Protein), while the other graphs have hundreds or thousands of node attributes, which makes it easier for the more powerful classifier (i.e. GNNs) to overfit on Facebook and Protein. Moreover, this could also be because the two non-GNN models generally need a larger portion of labeled set to train the weak local classifier, whereas GNNs utilize a neural network architecture as "local classifier", which is better at representation learning by transforming and aggregating node attribute information. However, when the model is trained with a large training set (e.g. with $30\%$ nodes on Protein dataset), modeling the label dependency becomes crucial. At the same time, our method is still able to boost performance on the two datasets. + +For GMNN (Qu et al., 2019), a collective GNN model, it achieves better performance than its non-collective base model, i.e. GCN on most of the datasets, and we can see that adding CL to GCN achieved comparable or better performance than GMNN. However, combing CL with other more powerful GNNs can easily out-perform GMNN (e.g., on Cora and Friendster, GRAND+CL significantly outperforms GMNN). When the test labels are available, GMNN is able to out-perform several GNNs by leveraging test label information, but the best of $CL + GNN$ still out-performs GMNN consistently. + +Ablation studies, comparison to ensembles, and hyperparameter sensitivity. We conducted three ablation studies to investigate the usage of predicted labels (detailed in Appendix F), which show that (a) adding predicted labels in model input had extra value comparing to using true labels only, (b) applying the random masking procedure is crucial for the model improvements, and (c) the gain of our framework is from using samples of the predicted labels rather than random one-hot vectors. We also compared with a baseline ensemble method, which considers an ensemble of 10 GNNs with random initialization. The results (detailed in Appendix F) show that an ensemble approach is able to slightly improve the GNN performance, but the gains are much smaller than the gains observed for $CL + GNN$ . + +We also investigated the impact of training labels rates and sample size $K$ (see Appendix G), and we found that in general $CL + GNN$ framework achieves a larger improvement + +when fewer labels are available in the training graph, and that with sample size $K > 1$ there was consistent gain. + +Complexity analysis. $CL + GNN$ computes $K$ embeddings at each stochastic gradient step, therefore, per-gradient step, $CL + GNN$ is $K$ slower than its component WL-GNN. Overall, after $T$ iterations of Steps 1-3, $CL + GNN$ total runtime increases by $T \times K$ over the original runtime of its component WL-GNN. The time and space complexity of $CL + GNN$ is the same as WL-GNNs, i.e. $\mathcal{O}(m)$ where $m = |E|$ . + +Note that existing methods trying to boost the GNN expressiveness —e.g. PPGN (Maron et al., 2019a), SMP (Vignac et al., 2020))— are much more computationally expensive in time (at least $\Theta(mn)$ ) and space ( $\Theta(n^2)$ ), where $n$ and $m$ are number of nodes and edges in the graph. + +We note that we spent nearly no time engineering $CL + GNN$ for speed or for improving our results. Our interest in this paper lies entirely on the gains of a direct application of collective learning to GNNs $(CL + GNN)$ . We fully expect that further engineering advances can reduce the computational burden due to Monte Carlo sampling and increase accuracy gains. For instance, parallelism can significantly reduce the time to collect $K$ samples in $CL + GNN$ . + +# 6. Related Work + +On collective learning and neural networks. There has been work on applying deep learning to collective classification. For example, Moore & Neville (2017) proposed to use LSTM-based RNNs for classification tasks on graphs. They transform each node and its set of neighbors into an unordered sequence and use an RNN to predict the class label as the output of that sequence. Pham et al. (2017) designed a deep learning model for collective classification in multi-relational domains, which learns local and relational features simultaneously to encode multi-relations. + +The closest work to ours is Fan & Huang (2019), which proposed a recurrent collective classification (RCC) framework, a variant of ICA (Lu & Getoor, 2003) including dynamic relational features encoding label information. Unlike our framework, this method does not sample labels $\hat{Y}$ , opting for an end-to-end training procedure. Vijayan et al. (2018) opts for a similar no-sample RCC end-to-end training method as (Fan & Huang, 2019), now combining a differentiable graph kernel with an iterative stage. Graph Markov Neural Network (GMNN) (Qu et al., 2019) is another promising approach that applies statistical relational learning to GNNs. GMNNs model the joint label distribution with a conditional random field trained with the variational EM algorithm. GMNNs are trained by alternating between an E-step and an M-step, and two WL-GCNs are trained for the two steps respectively. These studies represent different ideas for bringing the power of collective + +classification to neural networks. Unfortunately, Corollary 1 shows that, without sampling $\hat{Y}$ , the above methods are still WL-GNNs, and hence, their use of collective classification fails to deliver any increase in expressiveness beyond an optimal WL-GNN (e.g., Xu et al. (2018)). In our experiments, we compared to GMNN as a representative relational GNN method, and showed that while GMNN outperformed its component GCN, the best of $CL + GNN$ still consistently out-performs GMNN. + +In parallel to our work, Jia & Benson (2020) considers regression tasks by modeling the joint GNN residual of a target set $(y - \hat{y})$ as a multivariate Gaussian, defining the loss function as the marginal likelihood only over labeled nodes $\hat{y}_L$ . In contrast, by using the more general foundation of collective classification, our framework can seamlessly model both classification and regression tasks, and include model predictions over the entire graph $\hat{\mathbf{Y}}$ as $CL + GNN$ 's input, thus affecting both the model prediction and the GNN training in inductive node classification tasks. + +Higher-order GNNs for more expressive graph representation. Recently, there has been a few works proposed to boost the representation power of WLGNN (Morris et al., 2019; Maron et al., 2019a; 2018; Vignac et al., 2020; Chen et al., 2019; Maron et al., 2019b). Most of these works consider representation for the entire graph or node sets by mimicking higher-order WL tests. However, most of them provide more theoretical implications for GNNs than practical usage due to their dependency on order- $k$ tensors $\mathbb{R}^{n^k}$ ( $n$ : number of nodes, $k > 2$ ) and inability to leverage the sparsity of the graph structures. Among them PPGN (Maron et al., 2019a) is relatively scalable with $\Theta(n^3)$ time complexity and $\Theta(n^2)$ space complexity to achieve the expressive power of the 2-WL test. A more recent method SMP (Vignac et al., 2020) proposed a powerful and more scalable message-passing framework with time complexity of $\Theta(mn)$ ( $m$ : number of edges) and space complexity of $\Theta(n^2)$ . Our work, on the other hand, focuses on node-level representations rather than (sub)graph-level representations, and our overall time/space complexity is $\Theta(m)$ . As these methods cannot be directly evaluated on node classification tasks and due to their computational inefficiency, we leave the assessment of $CL + GNN$ gains if used with these more powerful GNN variants as future work. + +On self-supervised learning and semi-supervised learning. Self-supervised learning is closely related to semi-supervised learning. In fact, self-supervised learning can be seen as a self-imposed semi-supervised learning task, where part of the input is masked (or transformed) and must be predicted back by the model (Doersch et al., 2015; Noroozi & Favaro, 2016; Lee et al., 2017; Misra et al., 2016). Recently, self-supervised learning has been broadly applied to achieve state-of-the-art accuracy in computer vision (Hénaff + +et al., 2019; Gidaris et al., 2019) and natural language processing (Devlin et al., 2018) supervised learning tasks. The use of self-supervised learning in graph representation learning is intimately related to the use of pseudolikelihood to approximate true likelihood functions. + +For further related work on collective classification, see Appendix H. + +# 7. Conclusion + +A long-standing question is when/if collective inference (CI) is needed when very expressive graph models are available (e.g., GNNs) for inductive node classification tasks. This work solves a few theoretical and empirical questions towards an answer. We show that, with the most expressive equivariant (node-embedding) GNNs, it is true that there is no need for collective learning. While the development of more expressive GNNs generally focuses on changing the architecture, in this work we ask the question of whether CI could be a practical way to boost the real-world performance of a GNN, without changing its underlying architecture. + +In this work we propose collective learning (CL), a modified CI approach for GNN-type classifiers that boosts their expressiveness, relying on both Monte Carlo sampling of node embeddings and (self-supervised) random masking in training. We show that collective learning can be combined with existing GNNs to improve their expressiveness (and we prove increased expressiveness with WL-GNNs). + +We experimentally confirm our theoretical analysis across five real-world graphs and four component GNNs, and show by extensive empirical study that $CL + GNN$ consistently, and significantly, boosts GNNs performance (up to $26\%$ ). One limitation of our proposed collective learning framework is the computational cost of using sampled embeddings during each stochastic gradient step. We leave exploration of mechanisms to reduce the additional computational burden (eg. via parallelization and/or more targeted sampling) to future work. + +# 8. Acknowledgments + +This research is supported by NSF under contract number(s) CAREER IIS-1943364, IIS-1618690, CCF-0939370 and CCF-1918483. The U.S. Government is authorized to reproduce and distribute reprints for governmental purposes notwithstanding any copyright notation hereon. The views and conclusions contained herein are those of the authors and should not be interpreted as necessarily representing the official policies or endorsements either expressed or implied, of NSF or the U.S. Government. + +# References + +Azizian, W. and Lelarge, M. Characterizing the expressive power of invariant and equivariant graph neural networks. 2021. +Bakshy, E., Eckles, D., and Bernstein, M. S. Designing and deploying online field experiments. In Proceedings of the 23rd international conference on World wide web, pp. 283-292, 2014. +Beaini, D., Passaro, S., L'etourneau, V., Hamilton, W. L., Corso, G., and Li'o, P. Directional graph networks. arXiv preprint arXiv:2010.02863, 2020. +Blondel, V. D., Guillaume, J.-L., Lambiotte, R., and Lefebvre, E. Fast unfolding of communities in large networks. Journal of statistical mechanics: theory and experiment, 2008(10):P10008, 2008. +Borgwardt, K. M., Ong, C. S., Schonauer, S., Vishwanathan, S., Smola, A. J., and Kriegel, H.-P. Protein function prediction via graph kernels. Bioinformatics, 21(suppl_1): i47-i56, 2005. +Bouritsas, G., Frasca, F., Zafeiriou, S., and Bronstein, M. M. Improving graph neural network expressivity via subgraph isomorphism counting. arXiv preprint arXiv:2006.09252, 2020. +Chen, Z., Villar, S., Chen, L., and Bruna, J. On the equivalence between graph isomorphism testing and function approximation with gnns. In Advances in Neural Information Processing Systems, pp. 15868-15876, 2019. +Devlin, J., Chang, M.-W., Lee, K., and Toutanova, K. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805, 2018. +Doersch, C., Gupta, A., and Efros, A. A. Unsupervised visual representation learning by context prediction. In Proceedings of the IEEE International Conference on Computer Vision, pp. 1422-1430, 2015. +Fan, S. and Huang, B. Recurrent collective classification. Knowledge and Information Systems, 60(2):741-755, 2019. +Feng, W., Zhang, J., Dong, Y., Han, Y., Luan, H., Xu, Q., Yang, Q., Kharlamov, E., and Tang, J. Graph random neural networks for semi-supervised learning on graphs. Advances in Neural Information Processing Systems, 33, 2020. +Gidaris, S., Bursuc, A., Komodakis, N., Pérez, P., and Cord, M. Boosting few-shot visual learning with self-supervision. In Proceedings of the IEEE International Conference on Computer Vision, pp. 8059-8068, 2019. + +Hamilton, W., Ying, Z., and Leskovec, J. Inductive representation learning on large graphs. In Advances in Neural Information Processing Systems, pp. 1024-1034, 2017. +Hénaff, O. J., Razavi, A., Doersch, C., Eslami, S., and Oord, A. v. d. Data-efficient image recognition with contrastive predictive coding. arXiv preprint arXiv:1905.09272, 2019. +Jensen, D., Neville, J., and Gallagher, B. Why collective inference improves relational classification. In Proceedings of the tenth ACM SIGKDD international conference on Knowledge discovery and data mining, pp. 593-598, 2004. +Jia, J. and Benson, A. Outcome correlation in graph neural network regression, 2020. +Kipf, T. N. and Welling, M. Semi-supervised classification with graph convolutional networks. arXiv preprint arXiv:1609.02907, 2016. +Koller, D., Friedman, N., Džeroski, S., Sutton, C., McCallum, A., Pfeffer, A., Abbeel, P., Wong, M.-F., Heckerman, D., Meek, C., et al. Introduction to statistical relational learning. MIT press, 2007. +Lee, H.-Y., Huang, J.-B., Singh, M., and Yang, M.-H. Unsupervised representation learning by sorting sequences. In Proceedings of the IEEE International Conference on Computer Vision, pp. 667-676, 2017. +Lu, Q. and Getoor, L. Link-based classification. In Proceedings of the 20th International Conference on Machine Learning (ICML-03), pp. 496-503, 2003. +Luan, S., Zhao, M., Chang, X.-W., and Precup, D. Break the ceiling: Stronger multi-scale deep graph convolutional networks. arXiv preprint arXiv:1906.02174, 2019. +Maron, H., Ben-Hamu, H., Shamir, N., and Lipman, Y. Invariant and equivariant graph networks. arXiv preprint arXiv:1812.09902, 2018. +Maron, H., Ben-Hamu, H., Serviansky, H., and Lipman, Y. Provably powerful graph networks. In Advances in neural information processing systems, pp. 2156-2167, 2019a. +Maron, H., Fetaya, E., Segol, N., and Lipman, Y. On the universality of invariant networks. In International conference on machine learning, pp. 4363-4371. PMLR, 2019b. +Misra, I., Zitnick, C. L., and Hebert, M. Shuffle and learn: unsupervised learning using temporal order verification. In European Conference on Computer Vision, pp. 527-544. Springer, 2016. + +Moore, J. and Neville, J. Deep collective inference. In Thirty-First AAAI Conference on Artificial Intelligence, 2017. +Morris, C., Ritzert, M., Fey, M., Hamilton, W. L., Lenssen, J. E., Rattan, G., and Grohe, M. 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. +Murphy, R. L., Srinivasan, B., Rao, V., and Ribeiro, B. Relational pooling for graph representations. arXiv preprint arXiv:1903.02541, 2019. +Neville, J. and Jensen, D. Iterative classification in relational data. In Proc. AAAI-2000 workshop on learning statistical models from relational data, pp. 13-20, 2000. +Neville, J., Jensen, D., Friedland, L., and Hay, M. Learning relational probability trees. In Proceedings of the ninth ACM SIGKDD international conference on Knowledge discovery and data mining, pp. 625-630, 2003a. +Neville, J., Jensen, D., and Gallagher, B. Simple estimators for relational bayesian classifiers. In Third IEEE International Conference on Data Mining, pp. 609-612. IEEE, 2003b. +Noroozi, M. and Favaro, P. Unsupervised learning of visual representations by solving jigsaw puzzles. In European Conference on Computer Vision, pp. 69-84. Springer, 2016. +Pfeiffer III, J. J., Neville, J., and Bennett, P. N. Overcoming relational learning biases to accurately predict preferences in large scale networks. In Proceedings of the 24th International Conference on World Wide Web, pp. 853-863, 2015. +Pham, T., Tran, T., Phung, D., and Venkatesh, S. Column networks for collective classification. In Thirty-First AAAI Conference on Artificial Intelligence, 2017. +Popescul, A., Ungar, L. H., Lawrence, S., and Pennock, D. M. Towards structural logistic regression: Combining relational and statistical learning. *Departmental Papers (CIS)*, pp. 134, 2002. +Qu, M., Bengio, Y., and Tang, J. Gmnn: Graph markov neural networks. arXiv preprint arXiv:1905.06214, 2019. +Robbins, H. and Monro, S. A stochastic approximation method. Ann. Math. Statist., 22(3):400-407, 09 1951. doi: 10.1214/aoms/1177729586. URL https://doi.org/10.1214/aoms/1177729586. +Sen, P., Namata, G., Bilgic, M., Getoor, L., Galligher, B., and Eliassi-Rad, T. Collective classification in network data. AI magazine, 29(3):93-93, 2008. + +Srinivasan, B. and Ribeiro, B. On the equivalence between node embeddings and structural graph representations. arXiv preprint arXiv:1910.00452, 2019. +Teixeira, L., Jalaian, B., and Ribeiro, B. Are graph neural networks miscalibrated? arXiv preprint arXiv:1905.02296, 2019. +Vignac, C., Loukas, A., and Frossard, P. Building powerful and equivariant graph neural networks with structural message-passing. arXiv e-prints, pp. arXiv-2006, 2020. +Vijayan, P., Chandak, Y., Khapra, M. M., Parthasarathy, S., and Ravindran, B. Hopf: Higher order propagation framework for deep collective classification. arXiv preprint arXiv:1805.12421, 2018. +Xiang, R. and Neville, J. Pseudolikelihood em for within-network relational learning. In 2008 Eighth IEEE International Conference on Data Mining, pp. 1103-1108. IEEE, 2008. +Xu, K., Hu, W., Leskovec, J., and Jegelka, S. How powerful are graph neural networks? arXiv preprint arXiv:1810.00826, 2018. +Yang, J., Ribeiro, B., and Neville, J. Stochastic gradient descent for relational logistic regression via partial network crawls. arXiv preprint arXiv:1707.07716, 2017. \ No newline at end of file diff --git a/acollectivelearningframeworktoboostgnnexpressivenessfornodeclassification/images.zip b/acollectivelearningframeworktoboostgnnexpressivenessfornodeclassification/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..2fa8efe991b376398f91143f19f0aa7031ec7181 --- /dev/null +++ b/acollectivelearningframeworktoboostgnnexpressivenessfornodeclassification/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cd61106fd7eb82ff80d12c44d781b000cfd69b09fea72766978250c5cae9eb49 +size 286403 diff --git a/acollectivelearningframeworktoboostgnnexpressivenessfornodeclassification/layout.json b/acollectivelearningframeworktoboostgnnexpressivenessfornodeclassification/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..d1155d9880c1b0415d9de333e83d29c9fc4601de --- /dev/null +++ b/acollectivelearningframeworktoboostgnnexpressivenessfornodeclassification/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:94e7444ccbc3d3db280131e5bea8427c4967d5a6525eea3ba8281d098480163e +size 582825 diff --git a/adeepreinforcementlearningapproachtomarginalizedimportancesamplingwiththesuccessorrepresentation/4365bc2a-f514-4154-a9bb-2a54342aa305_content_list.json b/adeepreinforcementlearningapproachtomarginalizedimportancesamplingwiththesuccessorrepresentation/4365bc2a-f514-4154-a9bb-2a54342aa305_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..49de7152da44a7749309677adbc29c31ac9678c5 --- /dev/null +++ b/adeepreinforcementlearningapproachtomarginalizedimportancesamplingwiththesuccessorrepresentation/4365bc2a-f514-4154-a9bb-2a54342aa305_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6018436b24d99cf3fdb4f080b3795708a58950cf8dbb4d4610adb77dbe43fda6 +size 92757 diff --git a/adeepreinforcementlearningapproachtomarginalizedimportancesamplingwiththesuccessorrepresentation/4365bc2a-f514-4154-a9bb-2a54342aa305_model.json b/adeepreinforcementlearningapproachtomarginalizedimportancesamplingwiththesuccessorrepresentation/4365bc2a-f514-4154-a9bb-2a54342aa305_model.json new file mode 100644 index 0000000000000000000000000000000000000000..bceb5b1885fd03f4461d430256791f5bad129a35 --- /dev/null +++ b/adeepreinforcementlearningapproachtomarginalizedimportancesamplingwiththesuccessorrepresentation/4365bc2a-f514-4154-a9bb-2a54342aa305_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0ebb9ceb5cb9cde47d167103092453612c58d4c0532464a5eee16b90c607707c +size 119790 diff --git a/adeepreinforcementlearningapproachtomarginalizedimportancesamplingwiththesuccessorrepresentation/4365bc2a-f514-4154-a9bb-2a54342aa305_origin.pdf b/adeepreinforcementlearningapproachtomarginalizedimportancesamplingwiththesuccessorrepresentation/4365bc2a-f514-4154-a9bb-2a54342aa305_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..7c3427a189d8e5bac32473bd73f9b457ef668a69 --- /dev/null +++ b/adeepreinforcementlearningapproachtomarginalizedimportancesamplingwiththesuccessorrepresentation/4365bc2a-f514-4154-a9bb-2a54342aa305_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e31996210488aa55f2e224f1d5fef57a1424489f7ea096dd44cb2ebfe1bd8af +size 5224781 diff --git a/adeepreinforcementlearningapproachtomarginalizedimportancesamplingwiththesuccessorrepresentation/full.md b/adeepreinforcementlearningapproachtomarginalizedimportancesamplingwiththesuccessorrepresentation/full.md new file mode 100644 index 0000000000000000000000000000000000000000..ed78e4c4424a463f435401a1f171a155b0585460 --- /dev/null +++ b/adeepreinforcementlearningapproachtomarginalizedimportancesamplingwiththesuccessorrepresentation/full.md @@ -0,0 +1,415 @@ +# A Deep Reinforcement Learning Approach to Marginalized Importance Sampling with the Successor Representation + +Scott Fujimoto1 David Meger1 Doina Precup1 + +# Abstract + +Marginalized importance sampling (MIS), which measures the density ratio between the state-action occupancy of a target policy and that of a sampling distribution, is a promising approach for off-policy evaluation. However, current state-of-the-art MIS methods rely on complex optimization tricks and succeed mostly on simple toy problems. We bridge the gap between MIS and deep reinforcement learning by observing that the density ratio can be computed from the successor representation of the target policy. The successor representation can be trained through deep reinforcement learning methodology and decouples the reward optimization from the dynamics of the environment, making the resulting algorithm stable and applicable to high-dimensional domains. We evaluate the empirical performance of our approach on a variety of challenging Atari and MuJoCo environments. + +# 1. Introduction + +Off-policy evaluation (OPE) is a reinforcement learning (RL) task where the aim is to measure the performance of a target policy from data collected by a separate behavior policy (Sutton & Barto, 1998). As it can often be difficult or costly to obtain new data, OPE offers an avenue for reusing previously gathered data, making OPE an important challenge for applying RL to real-world domains (Zhao et al., 2009; Mandel et al., 2014; Swaminathan et al., 2017; Gauci et al., 2018). + +Marginalized importance sampling (MIS) (Liu et al., 2018; Xie et al., 2019; Nachum et al., 2019a) is a family of OPE methods which re-weight sampled rewards by directly learning the density ratio between the state-action occupancy of the target policy and the sampling distribution. This + +. + +Proceedings of the $38^{th}$ International Conference on Machine Learning, PMLR 139, 2021. Copyright 2021 by the author(s). + +approach can have significantly lower variance than traditional importance sampling methods (Precup et al., 2001), which consider a product of ratios over trajectories, and is amenable to deterministic policies and behavior agnostic settings where the sampling distribution is unknown. However, the body of MIS work is largely theoretical, and as a result, empirical evaluations of MIS have mostly been carried out on simple low-dimensional tasks, such as mountain car (state dim. of 2) or cartpole (state dim. of 4). In comparison, deep RL algorithms have shown successful behaviors in high-dimensional domains such as Humanoid locomotion (state dim. of 376) and Atari (image-based). + +In this paper, we present a straightforward approach for MIS that can be computed from the successor representation (SR) (Dayan, 1993) of the target policy by directly optimizing the reward function. Our algorithm, the Successor Representation Distribution Correction Estimation (SR-DICE), is the first method that allows MIS to scale to high-dimensional systems, far outperforming previous approaches. In comparison to previous algorithms which rely on minimax optimization or kernel methods (Liu et al., 2018; Nachum et al., 2019a; Uehara & Jiang, 2019; Mousavi et al., 2020; Yang et al., 2020), SR-DICE requires only a simple convex loss applied to a linear function, after computing the SR. Similar to the deep RL methods which can learn in high-dimensional domains, the SR can be computed easily using behavior-agnostic temporal-difference (TD) methods. This makes our algorithm highly amenable to deep learning architectures and applicable to complex tasks. + +The SR, which measures the expected future occupancy of states for a given policy, has a clear relationship to MIS methods, which estimate the ratio between the occupancy of state-action pairs and the sampling distribution. However, this relationship is muddled in a deep RL context, where the deep SR measures the expected future sum of feature vectors. Our approach, SR-DICE, provides a straightforward and principled method for extracting density ratios from the SR without any modifications to the standard learning procedure of the SR. Access to these density ratios is valuable as they have a wide range of possible applications such as policy regularization (Nachum et al., 2019b; Touati et al., 2020), imitation learning (Kostrikov et al., 2019), off-policy + +policy gradients (Imani et al., 2018; Liu et al., 2019b; Zhang et al., 2019), non-uniform sampling procedures (Sinha et al., 2020), or for mitigating distributional shift in offline RL (Fujimoto et al., 2019; Kumar et al., 2019). + +We highlight the value of the MIS density ratios for one reason in particular—in our theoretical analysis we prove that SR-DICE and the deep SR produce exactly the same value estimate. This is surprising as SR-DICE takes a distinct approach for value estimation by re-weighting every reward in the dataset with an importance sampling ratio while the deep SR estimates the value in a similar fashion to TD learning. This theoretical result extends to the deep RL setting and is consistent in our experimental results. This result is a double-edged sword which (negatively) implies there is no discernible difference of using our MIS approach for policy evaluation, but (positively) implies the estimated density ratios are accurate enough to match the performance of TD methods. This is an important observation as our empirical results demonstrate that previous MIS methods scale very poorly in comparison to TD methods to high dimensions, which is consistent with prior results (Voloshin et al., 2019; Fu et al., 2021). Even if there is no difference for OPE, a MIS method which matches the performance of TD-based methods is desirable if we are concerned with estimating the density ratios of the target policy. + +We benchmark the performance of SR-DICE on several high-dimensional domains in MuJoCo (Todorov et al., 2012) and Atari (Bellemare et al., 2013), against several recent MIS methods (Nachum et al., 2019a; Zhang et al., 2020a). Our results demonstrate several key findings regarding high-dimensional tasks. + +Current MIS methods underperform deep RL at high-dimensional tasks. While previous results have shown that MIS methods can produce competitive results to TD methods, our empirical results show that MIS methods scale poorly to challenging tasks. In Atari we find that the baseline MIS method exhibit unstable estimates, often reaching errors with many orders of magnitude. Comparatively, the baseline deep RL methods, which rely on TD learning and have a history of achieving high performances in the control setting (Mnih et al., 2015; Schulman et al., 2017; Fujimoto et al., 2018), outperform the MIS baselines at every task and often by a wide margin. + +SR-DICE outperforms current MIS methods at policy evaluation and therefore density ratio estimation. Our empirical results confirm our theoretical analysis, which state that SR-DICE and the standard deep SR approach should produce identical value estimates (with differences due only to changes to the optimization process). While this result may initially sound discouraging, given the direct SR approach is comparable to TD learning, and TD learning significantly outperforms current MIS methods, this result + +also implies that SR-DICE is a much stronger technique for estimating density ratios than previous methods. + +Ultimately, while SR-DICE produces a similar result to existing deep RL approaches for policy evaluation, it does provide a practical, scalable, and state-of-the-art approach for estimating state-action occupancy density ratios, while highlighting connections between the SR, reward function optimization, and state-action occupancy estimation. For ease of use and reproduction, our code is open-sourced (https://github.com/sfujim/SR-DICE). + +# 2. Background + +Reinforcement Learning. RL is a framework for maximizing accumulated reward of an agent interacting with its environment (Sutton & Barto, 1998). This problem is typically framed as a Markov Decision Process (MDP) $(\mathcal{S},\mathcal{A},\mathcal{R},p,d_0,\gamma)$ , with state space $\mathcal{S}$ , action space $\mathcal{A}$ , reward function $\mathcal{R}$ , dynamics model $p$ , initial state distribution $d_0$ and discount factor $\gamma$ . An agent selects actions according to a policy $\pi : \mathcal{S} \times \mathcal{A} \to [0,1]$ . In this paper we address the problem of off-policy evaluation (OPE) problem where the aim is to measure the normalized expected per-step reward of the policy $R(\pi) = (1 - \gamma)\mathbb{E}_{\pi}[\sum_{t=0}^{\infty} \gamma^t r(s_t, a_t)]$ . An important notion in OPE is the value function $Q^{\pi}(s, a) = \mathbb{E}_{\pi}[\sum_{t=0}^{\infty} \gamma^t r(s_t, a_t)|s_0 = s, a_0 = a]$ , which measures the expected sum of discounted rewards when following $\pi$ , starting from the state-action pair $(s, a)$ . + +We define $d^{\pi}(s,a)$ as the discounted state-action occupancy, the probability of seeing $(s,a)$ under policy $\pi$ with discount $\gamma$ : $d^{\pi}(s,a) = (1 - \gamma)\sum_{t=0}^{\infty}\gamma^{t}\int_{s_{0}}d_{0}(s_{0})p_{\pi}(s_{0}\to s,t)\pi(a|s)ds_{0}$ , where $p_{\pi}(s_0\rightarrow s,t)$ is the probability of arriving at the state $s$ after $t$ time steps when starting from an initial state $s_0$ . This distribution is important as $R(\pi)$ equals the expected reward $r(s,a)$ under $d^{\pi}$ : + +$$ +R (\pi) = \mathbb {E} _ {(s, a) \sim d ^ {\pi}, r (s, a)} [ r (s, a) ]. \tag {1} +$$ + +A common approach for estimating $R(\pi)$ is through temporal-difference (TD) learning (Sutton, 1988) where an estimate of the value function $Q(s,a)$ is updated over individual transitions $(s,a,r(s,a),s^{\prime})$ by the following: + +$$ +Q (s, a) \leftarrow \alpha \left(r (s, a) + \gamma Q \left(s ^ {\prime}, a ^ {\prime}\right)\right) + (1 - \alpha) Q (s, a), \tag {2} +$$ + +where $a'$ is sampled according to the target policy $\pi$ and $\alpha$ is the learning rate. Provided an infinite set of transitions, TD learning is known to converge to the true value function in the off-policy setting (Jaakkola et al., 1994; Sutton & Barto, 1998). TD learning can also be applied to other learning problems, such as the successor representation, where the reward $r(s, a)$ in Equation (2) is replaced with the quantity of interest. + +Successor Representation. The successor representation (SR) (Dayan, 1993) of a policy is a measure of occupancy of future states. It can be viewed as a general value function that learns a vector of the expected discounted visitation for each state. The SR $\Psi^{\pi}$ of a given policy $\pi$ is defined as $\Psi^{\pi}(s'|s) = \mathbb{E}_{\pi}[\sum_{t=0}^{\infty} \gamma^{t} \mathbb{1}(s_{t} = s') | s_{0} = s]$ . Importantly, the value function can be recovered from the SR by summing over the expected reward of each state $V^{\pi}(s) = \sum_{s'} \Psi^{\pi}(s'|s) \mathbb{E}_{a' \sim \pi}[r(s', a')]$ . For infinite state and action spaces, the SR can instead be generalized to the expected occupancy over features, known as the deep SR (Kulkarni et al., 2016) or successor features (Barreto et al., 2017). For a given encoding function $\phi: S \times \mathcal{A} \rightarrow \mathbb{R}^{n}$ , the deep SR $\psi^{\pi}: S \times \mathcal{A} \rightarrow \mathbb{R}^{n}$ is defined as the expected discounted sum of features from the encoding function $\phi$ when following the policy from a given state-action pair: + +$$ +\psi^ {\pi} (s, a) = \mathbb {E} _ {\pi} \left[ \sum_ {t = 0} ^ {\infty} \gamma^ {t} \phi \left(s _ {t}, a _ {t}\right) \Bigg | s _ {0} = s, a _ {0} = a \right]. \quad (3) +$$ + +If the encoding $\phi(s, a)$ is learned such that the original reward function is a linear function of the encoding $r(s, a) = \mathbf{w}^\top \phi(s, a)$ , then similar to the original formulation of SR, the value function can be recovered from a linear function of the SR: $Q^{\pi}(s, a) = \mathbf{w}^\top \psi^{\pi}(s, a)$ . The deep SR network $\psi^{\pi}$ is trained to minimize the MSE between $\psi^{\pi}(s, a)$ and $\phi(s, a) + \gamma \psi'(s', a')$ on transitions $(s, a, s')$ sampled from the dataset. A frozen target network $\psi'$ is used to provide stability (Mnih et al., 2015; Kulkarni et al., 2016), and is updated to the current network $\psi' \gets \psi^{\pi}$ after a fixed number of time steps. The encoding function $\phi$ is typically trained by an encoder-decoder network (Kulkarni et al., 2016; Machado et al., 2017; 2018a). For OPE where the reward function is learned by minimizing $\left(\mathbf{w}^\top \phi(s, a) - r(s, a)\right)^2$ , the SR is comparable to TD learning, as they both estimate the discounted sum of future rewards and use similar updates. + +Marginalized Importance Sampling. Marginalized importance sampling (MIS) is a family of importance sampling approaches for off-policy evaluation in which the performance $R(\pi)$ is evaluated by re-weighting rewards sampled from a dataset $\mathcal{D} = \{(s, a, r, s')\} \sim p(s'|s, a)d^{\mathcal{D}}(s, a)$ , where $d^{\mathcal{D}}$ is an arbitrary distribution, typically but not necessarily, induced by some behavior policy. It follows that $R(\pi)$ can be computed with importance sampling weights on the rewards $\frac{d^{\pi}(s, a)}{d^{\mathcal{D}}(s, a)}$ : + +$$ +R (\pi) = \mathbb {E} _ {(s, a) \sim d ^ {\mathcal {D}}, r (s, a)} \left[ \frac {d ^ {\pi} (s , a)}{d ^ {\mathcal {D}} (s , a)} r (s, a) \right]. \tag {4} +$$ + +The goal of marginalized importance sampling methods is to learn the weights $w(s, a) \approx \frac{d^{\pi}(s, a)}{d^{\mathcal{D}}(s, a)}$ , using data contained in $\mathcal{D}$ . The main benefit of MIS is that unlike traditional importance methods, the ratios are applied to individual + +transitions rather than complete trajectories, which can reduce the variance of long or infinite horizon problems. In other cases, the ratios themselves can be used for a variety of applications which require estimating the occupancy of state-action pairs. + +# 3. A Reward Function Perspective on Distribution Corrections + +In this section, we present our behavior-agnostic approach to estimating MIS ratios, called the Successor Representation Distribution Correction Estimation (SR-DICE). Our main insight is that MIS can be viewed as an optimization over a learned reward function, where the loss is uniquely optimized when the virtual reward is the MIS density ratio. + +Our derived loss function is a straightforward convex loss over the learned reward and the corresponding value function of the target policy. This naturally suggests the use of the successor representation which allows us to maintain an estimate of the value estimate while directly optimizing the reward function. This disentangles the learning process, where the propagation of reward through the MDP can be learned separately from the optimization of the reward. In other words, rather than learn a reward function and value function simultaneously, we tackle each separately, changing the difficult minimax optimization of previous methods into two phases. Interestingly enough, we show that our MIS estimator produces the identical value estimate as traditional deep SR methods. This means the challenging aspect of learning has been pushed onto the computation of the SR, rather than optimizing the density ratio estimate. Fortunately, we can leverage deep RL approaches (Mnih et al., 2015; Kulkarni et al., 2016) to make learning the SR stable, giving rise to a practical MIS method for high-dimensional tasks. + +This section begins with the derivation of our core ideas, which shows MIS ratios can be learned through reward function optimization. We then highlight how the SR can be used for reward function optimization in the tabular domain. Finally, we generalize our results to the deep SR setting. + +# 3.1. Basic Derivation + +In MIS, our aim is to determine the MIS ratios $\frac{d^{\pi}(s,a)}{d^{\mathcal{D}}(s,a)}$ , using only data sampled from the dataset $\mathcal{D}$ and the target policy $\pi$ . This presents a challenge as we have direct access to neither $d^{\pi}$ nor $d^{\mathcal{D}}$ . + +As a starting point, we begin by following the derivation of DualDICE (Nachum et al., 2019a). We first consider the convex function $\frac{1}{2} mx^2 - nx$ , which is uniquely minimized by $x^* = \frac{n}{m}$ . Now by replacing $x$ with a virtual reward $\hat{r}(s, a)$ , $m$ with the density of the dataset $d^{\mathcal{D}}(s, a)$ , and + +$n$ with the density of the target policy $d^{\pi}(s,a)$ , we have reformulated the convex function as the following: + +$$ +\begin{array}{l} \min _ {\hat {r} (s, a) \forall (s, a)} J (\hat {r}) := \frac {1}{2} \mathbb {E} _ {(s, a) \sim d ^ {\mathcal {D}}} [ \hat {r} (s, a) ^ {2} ] \tag {5} \\ - \left(1 - \gamma\right) \mathbb {E} _ {(s, a) \sim d ^ {\pi}} \left[ \hat {r} (s, a) \right]. \\ \end{array} +$$ + +As Equation (5) is still the convex function with renamed variables, following Nachum et al. (2019a), we can observe the following: + +Observation 1 The objective $J(\hat{r})$ is minimized when $\hat{r}(s, a) = \frac{d^{\pi}(s, a)}{d^{\mathcal{D}}(s, a)}$ for all state-action pairs $(s, a)$ . + +Equation (5) is an optimization over two expectations over $d^{\mathcal{D}}$ and $d^{\pi}$ . While the first expectation over $d^{\mathcal{D}}$ is tractable by sampling directly from the dataset $\mathcal{D}$ , the second expectation relies on the state-action visitation of the target policy $d^{\pi}(s,a)$ which is not directly accessible without a model of the MDP. At this point, we highlight our choice of notation, $\hat{r} (s,a)$ , in Equation (5). Describing the objective in terms of a fictitious reward $\hat{r}$ will allow us to draw on familiar relationships between rewards and value functions. Consider the equivalence between the value function over initial state-action pairs $(s_0,a_0)$ and the expectation of rewards over the state-action visitation of the policy $(1 - \gamma)\mathbb{E}_{s_0,a_0\sim \pi}[Q^\pi (s_0,a_0)] = \mathbb{E}_{d^\pi}[r(s,a)]$ . It follows that the expectation over $d^{\pi}$ in Equation (5) can be replaced with a value function $\hat{Q}^{\pi}$ over $\hat{r}$ : + +$$ +\begin{array}{l} \min _ {\hat {r} (s, a) \forall (s, a)} J (\hat {r}) := \frac {1}{2} \mathbb {E} _ {(s, a) \sim d ^ {\mathcal {D}}} [ \hat {r} (s, a) ^ {2} ] \tag {6} \\ - (1 - \gamma) \mathbb {E} _ {s _ {0}, a _ {0} \sim \pi (\cdot | s _ {0})} \left[ \hat {Q} ^ {\pi} (s _ {0}, a _ {0}) \right]. \\ \end{array} +$$ + +In other words, by noting that the value function is simply the (scaled) expected reward when sampled from the state-action visitation of the target policy, we can replace the impractical expectation over $d^{\pi}$ with a tractable value function. This form of the objective, Equation (6), is convenient because we can estimate the expectation over $d^{\mathcal{D}}$ by sampling directly from the dataset and $\hat{Q}^{\pi}$ can be computed using any policy evaluation method. + +While we can estimate both terms in Equation (6) with relative ease, the optimization problem is not directly differentiable and would require re-learning the value function $\hat{Q}^{\pi}$ with every adjustment to the learned reward $\hat{r}$ . Fortunately, there exists a straightforward paradigm which enables direct reward function optimization known as successor representation (SR). + +# 3.2. Tabular SR-DICE + +We will begin by discussing how we can apply the SR to MIS in the tabular setting and then generalize our method to non-linear function approximation afterwards. Consider + +the relationship between the SR $\Psi^{\pi}$ of the target policy $\pi$ and its value function: + +$$ +\begin{array}{l} \mathbb {E} _ {s _ {0}, a _ {0} \sim \pi (\cdot | s _ {0})} [ Q ^ {\pi} (s _ {0}, a _ {0}) ] = \mathbb {E} _ {s _ {0}} [ V ^ {\pi} (s _ {0}) ] \\ = \mathbb {E} _ {s _ {0}} \left[ \sum_ {s} \Psi^ {\pi} (s | s _ {0}) \mathbb {E} _ {a \sim \pi} [ r (s, a) ] \right]. \tag {7} \\ \end{array} +$$ + +It follows that we can create an optimization problem directly over the reward function $\hat{r}$ by modifying Equation (6) to use the SR: + +$$ +\begin{array}{l} \min _ {\hat {r} (s, a) \forall (s, a)} J _ {\Psi} (\hat {r}) := \frac {1}{2} \mathbb {E} _ {(s, a) \sim d ^ {\mathcal {D}}} [ \hat {r} (s, a) ^ {2} ] (8) \\ - (1 - \gamma) \mathbb {E} _ {s _ {0}} \left[ \sum_ {s} \Psi^ {\pi} (s | s _ {0}) \mathbb {E} _ {a \sim \pi} [ \hat {r} (s, a) ] \right]. (8) \\ \end{array} +$$ + +Since this optimization problem is convex, it has a closed form solution. The unique optimizer of Equation (8) is: + +$$ +\begin{array}{l} (1 - \gamma) \frac {\left| \mathcal {D} \right|}{\sum_ {\left(s ^ {\prime} , a ^ {\prime}\right) \in \mathcal {D}} \mathbb {1} \left(s ^ {\prime} = s , a ^ {\prime} = a\right)} \tag {9} \\ \cdot \mathbb {E} _ {s _ {0}} \left[ \pi (a | s) \Psi^ {\pi} (s | s _ {0}) \right]. \\ \end{array} +$$ + +By noting the relationship between the SR and the state occupancy $d^{\pi}(s,a) = (1 - \gamma)\mathbb{E}_{s_0}\big[\Psi^{\pi}(s|s_0)\pi (s,a)\big]$ and the fact that $d^{\mathcal{D}}(s,a) = \frac{\sum_{(s',a')\in\mathcal{D}}\mathbb{1}(s' = s,a' = a)}{|\mathcal{D}|}$ we can show this solution simplifies to the MIS density ratio $\frac{d^{\pi}(s,a)}{d^{\mathcal{D}}(s,a)}$ + +Theorem 1 Equation (9) is the optimal solution to Equation (8) and is equal to $\frac{d^{\pi}(s,a)}{d^{\mathcal{P}}(s,a)}$ . + +A direct consequence of this result is that Equation (9) can be used with MIS policy evaluation to return the true value estimate $\frac{1}{|\mathcal{D}|}\sum_{(s,a)\in \mathcal{D}}\frac{d^{\pi}(s,a)}{d^{\mathcal{D}}(s,a)} r(s,a) = R(\pi)$ . + +Unfortunately, the form of Equation (9) relies on the true SR $\Psi^{\pi}$ , as well as an expectation over $s_0$ , both of which may be unobtainable in the setting where we are sampling from a finite dataset $\mathcal{D}$ . However, we can still show that with an inexact SR $\hat{\Psi}$ and sampled estimate of the expectation, using the set of start states $\mathcal{D}_0$ in the dataset, approximating the optimizer Equation (9) with + +$$ +\begin{array}{l} r ^ {*} (s, a) = (1 - \gamma) \frac {| \mathcal {D} |}{\sum_ {\left(s ^ {\prime} , a ^ {\prime}\right) \in \mathcal {D}} \mathbb {1} \left(s ^ {\prime} = s , a ^ {\prime} = a\right)} \tag {10} \\ \cdot \frac {1}{| \mathcal {D} _ {0} |} \sum_ {s _ {0} \in \mathcal {D} _ {0}} \pi (a | s) \hat {\Psi} (s | s _ {0}), \\ \end{array} +$$ + +gives an MIS estimator $\frac{1}{|\mathcal{D}|}\sum_{(s,a)\in \mathcal{D}}r^{*}(s,a)r(s,a)$ of $R(\pi)$ which is identical to the estimate of $R(\pi)$ computed directly with the SR. + +Theorem 2 Let $\bar{r}(s,a)$ be the average reward in the dataset $\mathcal{D}$ at the state-action pair $(s,a)$ . Let $\hat{\Psi}$ be any approximate SR. The direct SR estimator $(1 - \gamma)\frac{1}{|\mathcal{D}_0|}\sum_{s_0\in \mathcal{D}_0}\sum_{s\in \mathcal{S}}\hat{\Psi}(s|s_0)\sum_{a\in \mathcal{A}}\pi(a|s)\bar{r}(s,a)$ of $R(\pi)$ is identical to the MIS estimator $\frac{1}{|\mathcal{D}|}\sum_{(s,a)\in \mathcal{D}}r^*(s,a)r(s,a)$ . + +The take-away is that even when estimating the SR, the approximate density ratio defined by $r^*$ is of sufficiently high quality to match the performance of directly estimating the value with the SR. + +# 3.3. SR-DICE + +Now we will consider how this MIS estimator can be generalized to continuous states by considering the deep SR $\psi^{\pi}$ over features $\phi(s, a)$ and optimizing the weights of a linear function $\mathbf{w}$ . + +SR Refresher. We begin with a reminder of the details of the deep SR algorithm. The deep SR measures the expected sum of features $\psi^{\pi}(s,a) = \mathbb{E}_{\pi}\left[\sum_{t = 0}^{\infty}\gamma^{t}\phi (s_{t},a_{t})\right]$ . If the reward can be defined as a linear function over the features $r(s,a) = \mathbf{w}^{\top}\phi (s,a)$ then the value function can be recovered via a linear function over the deep SR $Q(s,a) = \mathbf{w}^{\top}\psi^{\pi}(s,a)$ . The typical deep SR pipeline follows three steps: + +1. Learn the encoding $\phi$ +2. Learn the deep SR $\psi^{\pi}$ over the encoding $\phi$ . +3. Learn $\mathbf{w}_{\mathrm{SR}}$ by minimizing $\left(\mathbf{w}_{\mathrm{SR}}^{\top}\phi (s,a) - r(s,a)\right)^{2}$ . + +We leave the first two stages vague as there is flexibility in how they are approached. This most commonly involves training the encoding $\phi$ via an encoder-decoder network to reconstruct transitions and training the deep SR $\psi^{\pi}$ using TD learning-style methods (Kulkarni et al., 2016; Machado et al., 2018a). While we follow this standard practice, specific details are unimportant for our analysis and we relegate implementation-level details to the appendix. + +Given the deep SR $\psi^{\pi}$ , we can use it to learn the MIS ratio. Recall our objective of reward function optimization (Equation (6)). In the deep SR paradigm, both the reward and value function are determined by linear functions with respect to a single weight vector $\mathbf{w}$ . Consequently, we can modify Equation (6) with these linear functions and then optimize the linear weights $\mathbf{w}$ directly: + +$$ +\begin{array}{l} \min _ {\mathbf {w}} J (\mathbf {w}) := \frac {1}{2} \mathbb {E} _ {d ^ {\mathcal {D}}} \left[ \left(\mathbf {w} ^ {\top} \phi (s, a)\right) ^ {2} \right] \tag {11} \\ - (1 - \gamma) \mathbb {E} _ {s _ {0}, a _ {0} \sim \pi (\cdot | s _ {0})} \left[ \mathbf {w} ^ {\top} \psi^ {\pi} (s _ {0}, a _ {0}) \right], \\ \end{array} +$$ + +where in practice we replace the expectations with samples: + +# Algorithm 1 SR-DICE + +Input: SR $\psi$ , target network $\psi'$ , encoder $\phi$ , decoder $D$ . At each time step sample mini-batch of $N$ transitions $(s, a, r, s')$ and start states $s_0$ from $\mathcal{D}$ . + +for $t = 1$ to $T_{1}$ do # Encoding $\phi$ loss + +$$ +\min _ {\phi , D} \frac {1}{2} (D (\phi (s, a)) - (s, a)) ^ {2}. +$$ + +for $t = 1$ to $T_{2}$ do # Deep SR $\psi^{\pi}$ loss + +$$ +\min _ {\psi^ {\pi}} \frac {1}{2} (\phi (s, a) + \gamma \psi^ {\prime} (s ^ {\prime}, a ^ {\prime}) - \psi^ {\pi} (s, a)) ^ {2}. +$$ + +for $t = 1$ to $T_{3}$ do # Density ratio w loss (Equation (12)) + +$$ +a _ {0} \sim \pi (\cdot | s _ {0}). +$$ + +$$ +\min _ {\mathbf {w}} \frac {1}{2} (\mathbf {w} ^ {\top} \phi (s, a)) ^ {2} - (1 - \gamma) \mathbf {w} ^ {\top} \psi^ {\pi} (s _ {0}, a _ {0}). +$$ + +Output: $|\mathcal{D}|^{-1} \sum_{(s,a,r) \in \mathcal{D}} \mathbf{w}^\top \phi(s,a)r(s,a) \approx R(\pi)$ . + +$$ +\begin{array}{l} \min _ {\mathbf {w}} J (\mathbf {w}) := \frac {1}{2 | \mathcal {D} |} \sum_ {(s, a) \in \mathcal {D}} \left[ \left(\mathbf {w} ^ {\top} \phi (s, a)\right) ^ {2} \right] \tag {12} \\ - (1 - \gamma) \frac {1}{| \mathcal {D} _ {0} |} \sum_ {s _ {0} \in \mathcal {D} _ {0}, a _ {0}} \pi (a _ {0} | s _ {0}) \mathbf {w} ^ {\top} \psi^ {\pi} (s _ {0}, a _ {0}). \\ \end{array} +$$ + +Again, since the optimization problem Equation (12) is still convex, it has a closed form solution. Let $\Phi$ be a $|\mathcal{D}| \times F$ matrix where each row is the feature vector $\phi(s, a)$ with $F$ features. Let $\Psi$ be a $|\mathcal{D}_0||\mathcal{A}| \times F$ matrix where each row is the SR weighted by its probability under the policy $\pi(a_0 | s_0) \psi^\pi(s_0, a_0)$ . Let $\mathbf{1}$ be a $|\mathcal{D}_0||\mathcal{A}|$ dimensional vector of all 1. The unique optimizer $\mathbf{w}^*$ of Equation (12) is a $F$ dimensional vector defined as follows: + +$$ +\mathbf {w} ^ {*} = (1 - \gamma) \frac {| \mathcal {D} |}{| \mathcal {D} _ {0} |} \left(\Phi^ {\top} \Phi\right) ^ {- 1} \Psi^ {\top} \mathbf {1}. \tag {13} +$$ + +In practice, a matrix-based solution is often undesirable and we may prefer iterative, gradient-based solutions for scalability. In this case, we can directly minimize Equation (12) by taking gradient steps with respect to $\mathbf{w}$ . + +We now introduce our algorithm Successor Representation stationary DDistribution Correction Estimation (SR-DICE). SR-DICE follows the same first two steps of the standard SR procedure, but replaces the third step with optimizing Equation (12). Given $\mathbf{w}$ , an estimate of $R(\pi)$ can be returned by $\frac{1}{|\mathcal{D}|} \sum_{(s,a,r(s,a)) \in \mathcal{D}} \mathbf{w}^\top \phi(s,a)r(s,a)$ , where $\mathbf{w}^\top \phi(s,a) \approx \frac{d^\pi(s,a)}{d^\mathcal{D}(s,a)}$ . We summarize SR-DICE in Algorithm 1. + +We now remark upon two important properties of SR-DICE. The first concerns the quality of the quality of the learned MIS ratio. Although it is difficult to make any guarantees on the accuracy of an approximate $\psi^{\pi}$ trained with deep RL techniques, if we assume $\psi^{\pi}$ is exact, then we can show that SR-DICE learns the least squares estimator to the desired density ratio. + +Theorem 3 If the deep SR is exact, such that $(1 - \gamma)\mathbb{E}_{s_0,a_0}[\psi^\pi (s_0,a_0)] = \mathbb{E}_{(s,a)\sim d^\pi}[\phi (s,a)]$ , and the sup- + +port of $d^{\pi}$ is contained in the dataset $\mathcal{D}$ , then the optimizer $\mathbf{w}^{*}$ of Equation (12), as defined by Equation (13), is the least squares estimator of $\sum_{(s,a)\in \mathcal{D}}\left(\mathbf{w}^{\top}\phi (s,a) - \frac{d^{\pi}(s,a)}{d^{\mathcal{D}}(s,a)}\right)^{2}$ . + +The take-away from Theorem 3 is that our optimization problem, at least in the idealized setting, produces the same density ratios as directly learning them. This also means that the main source of error in SR-DICE is in the first two phases: learning the encoding $\phi$ and the deep SR $\psi^{\pi}$ . Notably, both of these steps are independent of the main optimization problem of learning $\mathbf{w}$ , as we have shifted the challenging aspects of density ratio estimation onto learning the deep SR. This leaves deep RL to do the heavy lifting. The remaining optimization problem, Equation (11), only involves directly updating the weights of a linear function, and unlike many other MIS methods, requires no tricky minimax optimization. + +The second important property of SR-DICE is that Theorem 2 can be extended to the deep SR setting. That is, when derived from the same approximate SR, the optimal solution to both the SR-DICE estimator and the direct SR estimator produce identical estimates of $R(\pi)$ . + +Theorem 4 Given the least squares estimator $\mathbf{w}_{SR}$ of $\sum_{(s,a)\in \mathcal{D}}\left(\mathbf{w}^{\top}\phi (s,a) - r(s,a)\right)^{2}$ and the optimizer $\mathbf{w}^{*}$ of Equation (12), as defined by Equation (13), then the traditional SR estimator $\frac{1}{|\mathcal{D}_0|}\sum_{s_0\in \mathcal{D}_0}\mathbf{w}_{SR}^{\top}\psi^{\pi}(s_0,a_0)$ of $R(\pi)$ is identical to the SR-DICE estimator $\frac{1}{|\mathcal{D}|}\sum_{(s,a,r(s,a))\in \mathcal{D}}\mathbf{w}^{*\top}\phi (s,a)r(s,a)$ of $R(\pi)$ . + +This means that SR-DICE produces the same value estimate as the traditional deep SR algorithms, up to errors in the optimization process of $\mathbf{w}$ . In other words, SR-DICE does not suffer from the same instability issues that plague other MIS methods when tackling high-dimensional domains where deep RL methods excel (relative to more traditional methods). Although, we typically think of the objective of MIS methods as policy evaluation, since SR-DICE and traditional deep SR produce the same value estimate, there is not a strong argument for using SR-DICE for policy evaluation. However, this also suggests that the estimated density ratios are of reasonably high quality since SR-DICE achieves the same performance as deep RL approaches. Therefore, we can treat SR-DICE is a tractable method for accessing the state-action occupancy of the target policy. + +# 4. Related Work + +Off-Policy Evaluation. Off-policy evaluation (OPE) is a well-studied problem with several families of approaches. One family of approaches is based on importance sampling, which re-weights trajectories by the ratio of likelihoods under the target and behavior policy (Precup et al., 2001). + +Importance sampling methods are unbiased but suffer from variance which can grow exponentially with the length of trajectories (Li et al., 2015; Jiang & Li, 2016). Consequently, research has focused on variance reduction (Thomas & Brunskill, 2016; Munos et al., 2016; Farajtabar et al., 2018) or contextual bandits (Dudík et al., 2011; Wang et al., 2017). Marginalized importance sampling methods (Liu et al., 2018) aim to avoid this exponential variance by considering the ratio in stationary distributions, giving an estimator with variance which is polynomial with respect to horizon (Xie et al., 2019; Liu et al., 2019a). Follow-up work has introduced a variety of approaches and improvements, allowing them to be behavior-agnostic (Nachum et al., 2019a; Uehara & Jiang, 2019; Mousavi et al., 2020; Yang et al., 2020) and operate in the undiscounted setting (Zhang et al., 2020a,b). In a similar vein, some OPE methods rely on emphasizing, or re-weighting, updates based on their stationary distribution (Sutton et al., 2016; Mahmood et al., 2017; Hallak & Mannor, 2017; Gelada & Bellemare, 2019), or learning the stationary distribution directly (Wang et al., 2007; 2008). + +For many deep RL algorithms (Mnih et al., 2015; Lillicrap et al., 2015), off-policy evaluation is based on TD learning (Sutton, 1988) and approximate dynamic programming techniques such as Fitted Q-Iteration (Ernst et al., 2005; Riedmiller, 2005; Yang et al., 2019). While empirically successful, these approaches lose any theoretical guarantees with non-linear function approximation (Tsitsiklis & Van Roy, 1997; Chen & Jiang, 2019). Regardless, they have been shown to achieve a high performance at benchmark OPE tasks (Voloshin et al., 2019; Fu et al., 2021). + +Successor Representation. Introduced originally by Dayan (1993) as an approach for improving generalization in temporal-difference methods, successor representations (SR) were revived by recent work on deep successor RL (Kulkarni et al., 2016) and successor features (Barreto et al., 2017) which demonstrated that the SR could be generalized to a function approximation setting. The SR has found applications for task transfer (Barreto et al., 2018; Grimm et al., 2019), navigation (Zhang et al., 2017; Zhu et al., 2017), and exploration (Machado et al., 2018a; Janz et al., 2019). It has also been used in a neuroscience context to model generalization and human reinforcement learning (Gershman et al., 2012; Momennejad et al., 2017; Gershman, 2018). The SR and our work also relate to state representation learning (Lesort et al., 2018) and general value functions (Sutton & Tanner, 2005; Sutton et al., 2011). + +# 5. Experiments + +To evaluate our method, we perform several off-policy evaluation (OPE) experiments on a variety of domains. The aim is to evaluate the normalized average discounted reward $\mathbb{E}_{(s,a)\sim d^{\pi},r}[r(s,a)]$ of a target policy $\pi$ . We benchmark our + +Figure 1: Off-policy evaluation results on the continuous action MuJoCo domain using the easy experimental setting (500k time steps and $\sigma_{b} = 0.133$ ), matching the setting of previous methods (Zhang et al., 2020a). The shaded area captures one standard deviation across 10 trials. We remark that this setting can be considered easy as the behavior policy achieves a lower error, often outperforming all agents. SR-DICE significantly outperforms the other MIS methods on all environments, except for Humanoid, where GradientDICE achieves a comparable performance. +![](images/aac5726b7998e8deb1c5c717627004689a08dd90f06ca558ea9d4c2014135c59.jpg) +SR-DICE + +![](images/6952173366e886151e4c15524285d2e7d2356124987d59d936b760f6618432b3.jpg) +DualDICE + +![](images/948a65671a482b3266cf2ccb70415f5a9847192f0eba998b170a1dca239f71e6.jpg) +GradientDICE + +Ant +![](images/3fe9983672e0d0f2b3bf68aeb9016c84eb630f987b3c7955bcdb810ed972592b.jpg) +-Deep SR + +![](images/ec4cd946c4ef3885a7e70d19c378f7f0411ad059d956d5c57ed547d650c91fda.jpg) +Deep TD + +Humanoid +![](images/118594123c922fe79c27ca42f55225bf0b517aefff03cbfc6acfd6b0cd6d435c.jpg) +Behavior $R(\pi_b)$ + +Figure 2: Off-policy evaluation results on the continuous action MuJoCo domain using the hard experimental setting (50k time steps, $\sigma_{b} = 0.2$ , random actions with $p = 0.2$ ). The shaded area captures one standard deviation across 10 trials. This setting uses significantly fewer time steps than the easy setting and the behavior policy is a poor estimate of the target policy. Again, we see SR-DICE outperforms the MIS methods, demonstrating the benefits of our proposed decomposition and simpler optimization. This setting also shows the benefits of deep RL methods over MIS methods for OPE in high-dimensional domains, as deep TD performs the strongest in every environment. +![](images/e30b57c54fbce0176159035df0f4065b97c4da00065534aa5ff2510591a3b09a.jpg) +- SR-DICE + +![](images/5074b42fec8135c158d250b56e8c5f0359369d31550f3c6afc45d0cde90bfa8f.jpg) +DualDICE + +![](images/df2341f6edb13ef13334798cd6703a06a47c2d040656e28ca06a6b26e055ea53.jpg) +GradientDICE + +![](images/5f903ea2f9cbc78f0c03bad787fbb81b8a5bf21e8b3eb6a68c6c5cae17a7768c.jpg) +-Deep SR +Deep TD + +![](images/6819fee7814bc8033c62c14b02219499a880e735fffb092d5209649f2b8c5bf9.jpg) +Behavior $R(\pi_b)$ + +algorithm against two MIS methods, DualDICE (Nachum et al., 2019a) and GradientDICE (Zhang et al., 2020b), two deep RL approaches and the true return of the behavior policy. The first deep RL method is a DQN-style approach (Mnih et al., 2015) where actions are selected by $\pi$ (denoted Deep TD) and the second is the deep SR where the weight $\mathbf{w}$ is trained to minimize the MSE between $\mathbf{w}^{\top}\phi(s,a)$ and $r(s,a)$ (Kulkarni et al., 2016). Environment-specific experimental details are presented below, and complete algorithmic and hyper-parameter details are included in the appendix. + +Continuous Action Experiments. We evaluate the methods on a variety of MuJoCo environments (Brockman et al., 2016; Todorov et al., 2012). We examine two experimental settings. In both settings the target policy $\pi$ and behavior policy $\pi_{b}$ are stochastic versions of a deterministic policy $\pi_{d}$ obtained from training the TD3 algorithm (Fujimoto et al., 2018). We evaluate a target policy $\pi = \pi_{d} + \mathcal{N}(0, \sigma^{2})$ , where $\sigma = 0.1$ . + +- For the easy setting, we gather a dataset of 500k transi + +tions using a behavior policy $\pi_{b} = \pi_{d} + \mathcal{N}(0,\sigma_{b}^{2})$ , where $\sigma_{b} = 0.133$ . This setting roughly matches the experimental setting used by GradientDICE Zhang et al. (2020a). + +- For the hard setting, we gather a significantly smaller dataset of 50k transitions using a behavior policy which acts randomly with $p = 0.2$ and uses $\pi_d + \mathcal{N}(0, \sigma_b^2)$ , where $\sigma_b = 0.2$ , with $p = 0.8$ . + +Unless specified otherwise, we use a discount factor of $\gamma = 0.99$ and all hyper-parameters are kept constant across environments. All experiments are performed over 10 seeds. We display the results of the easy setting in Figure 1 and the hard setting in Figure 2. + +Atari Experiments. To demonstrate our approach can scale to even more complex domains, we perform experiments with several Atari games (Bellemare et al., 2013), which are challenging due to their high-dimensional image-based state space. Standard pre-processing steps are applied (Castro et al., 2018) and sticky actions are used (Machado et al., 2018b) to increase difficulty and remove determinism. Each method is trained on a dataset of one million time steps. The + +![](images/291f2b7b399738ceb6219ff67eb07fa7e4d39e44be61bac867dac1f75b5c724a.jpg) +Figure 3: The log MSE for off-policy evaluation in the image-based Atari domain. This high-dimensional domain tests the ability of each method to scale to more complex environments. The shaded area captures one standard deviation across 3 trials. We can see the MIS baselines diverge on this challenging environment, while the remaining methods perform similarly. Perhaps surprisingly, on most games, the naive baseline of using $R(\pi_b)$ from the behavior policy outperforms all methods by a fairly significant margin. Although the estimates from deep RL methods are stable, they are biased, resulting in a higher MSE. + +![](images/c6e5d83f265e771fca5722186e97e0ff94e9582bdebf222b0dc7e79a6ca17e30.jpg) +(a) Error Visualization +(b) Log MSE & (Percentage of rewards functions with minimum error) +Figure 4: To evaluate the quality of the MIS ratios, we evaluate each MIS ratio with 1000 randomly sampled reward functions and compare to the ground truth on-policy value estimates. (Left) Visualization of the distribution of error. Only 100 points are displayed for visual clarity. Error bars are over the standard deviation. To normalize values across rewards functions, we divide both the estimate and ground truth of $R(\pi)$ by the average reward in the dataset. (Right) Average log MSE and the standard deviation. In brackets is the percentage of reward functions where each method achieves the lowest error. We can see that SR-DICE achieves a low log MSE over a wide range of reward functions and outperforms the competing MIS methods on a high percentage of reward functions. + +target policy is the deterministic greedy policy trained by Double DQN (Van Hasselt et al., 2016). The behavior policy is the $\epsilon$ -greedy policy with $\epsilon = 0.1$ . We use a discount factor of $\gamma = 0.99$ . Experiments are performed over 3 seeds. Results are displayed in Figure 3. Additional experiments with different behavior policies can be found in the appendix. + +Evaluating the MIS ratios. To evaluate the quality of the MIS ratios themselves, we perform a randomized reward experiment. As the MIS ratio is only the value $w$ that will return the true value of $R(\pi) = \mathbb{E}_{\mathcal{D}}[w \cdot r(s, a)]$ for all possible reward functions (Uehara & Jiang, 2019), we generate a large set of rewards functions with a randomly-initialized neural network, and evaluate the estimate of $R(\pi)$ obtained from each MIS method on each reward function. The ground-truth is estimated by a set of 100 on-policy trajectories generated by $\pi$ . We generate 1000 reward functions, with scalar values in the range [0, 10] and remove any + +redundant reward functions from the set. The MIS ratios and dataset are taken from the hard setting. Experiments are performed over 5 seeds. We report the results in Figure 4. + +Discussion. Across the board we find SR-DICE significantly outperforms the MIS methods. Looking at the estimated values of $R(\pi)$ in the continuous action environments, Figure 2, we can see that SR-DICE converges rapidly and maintains a stable estimate, while the MIS methods are particularly unstable, especially in the case of DualDICE. These observations are consistent in the Atari domain (Figure 3). In accordance with our theoretical analysis, Deep SR and SR-DICE perform similarly in every task, further suggesting that the limiting factor in SR-DICE is the quality of the deep successor representation, rather than learning the density ratios. In the randomized reward experiment, we find that SR-DICE vastly outperforms the other MIS methods in average log MSE, and compares favorably against + +![](images/8f64d30840eee6963c6858b3dda59abb1f45680063455900756ea9f71a62ed06.jpg) +(a) dataset size + +![](images/2ec74e97d34201531e18d93da94a831d93f316094a2bd3cae7346f8b480f0439.jpg) +(b) Discount factor $\gamma$ + +![](images/3b5644703d00ad40be31f8e6c2c858aa72b7b2a9e26b49c68dd62f02fb9037c8.jpg) +(c) Increased noise +Figure 5: Ablation study results for the HalfCheetah task. We default to the hard setting wherever possible. Error bars and the shaded area captures one standard deviation over 10 trials. (a) We vary the size of the dataset $\mathcal{D}$ . (b) We vary the discount factor $\gamma$ . (c) We use a new behavior policy with $\mathcal{N}(0, \sigma_b^2)$ noise with $\sigma_b = 0.5$ . (d) We use the same deterministic behavior and target policy. + +![](images/ae81926e0f3e83ccce6ba240879aec0bd264388f3739368c8eb037e0cb303597.jpg) +(d) Deterministic policies + +the other MIS methods in over $80\%$ of reward functions. In the most challenging task, Humanoid, SR-DICE is the best method in over $98\%$ of reward functions. This suggests that SR-DICE provides much higher quality MIS ratio estimates than previous methods. + +Ablation. To study the robustness of SR-DICE relative to the competing methods, we perform an ablation study and investigate the effects of dataset size, discount factor, and two different behavior policies. Unless specified otherwise, we use experimental settings matching the hard setting. We report the results in Figure 5. In the dataset size experiment (a), SR-DICE performs well with as few as 5k transitions (5 trajectories). In some instances, the performance is unexpectedly improved with less data, although incrementally. For small datasets, the SR methods outperform Deep TD. One hypothesis is that the encoding acts as an auxiliary reward and helps stabilize learning in the low data regime. In (b) we report the performance over changes in discount factor. The relative ordering across methods is unchanged. In (c) we use a behavior policy of $\mathcal{N}(0,\sigma_b^2)$ , with $\sigma_{b} = 0.5$ , a much larger standard deviation than either setting for continuous control. The results are similar to the original setting, with an increased bias on the deep RL methods. In (d) we use the underlying deterministic policy as both the behavior and target policy. Even though this setup should be easier since the task is no longer off-policy, the baseline MIS methods perform surprisingly poorly, once again demonstrating their weakness on high-dimensional domains. + +# 6. Conclusion + +In this paper, we introduce a method which can perform marginalized importance sampling (MIS) using the successor representation (SR) of the target policy. This is achieved by deriving an MIS formulation that can be viewed as reward function optimization. By using the SR, we effectively + +disentangle the dynamics of the environment from learning the reward function. This allows us to (a) use well-known deep RL methods to effectively learn the SR in challenging domains (Mnih et al., 2015; Kulkarni et al., 2016) and (b) provide a straightforward loss function to learn the density ratios without any optimization tricks necessary for previous methods (Liu et al., 2018; Uehara & Jiang, 2019; Nachum et al., 2019a; Zhang et al., 2020b; Yang et al., 2020). Our resulting algorithm, SR-DICE, outperforms prior MIS methods in terms of both performance and stability and is the first MIS method which demonstrably scales to high-dimensional problems. + +# 7. Acknowledgements + +Scott Fujimoto is supported by a NSERC scholarship as well as the Borealis AI Global Fellowship Award. This research was enabled in part by support provided by Calcul Quebec and Compute Canada. We would like to thank Wesley Chung, Pierre-Luc Bacon, Edward Smith, and Wei-Di Chang for helpful discussions and feedback. + +# References + +Barreto, A., Dabney, W., Munos, R., Hunt, J. J., Schaul, T., van Hasselt, H. P., and Silver, D. Successor features for transfer in reinforcement learning. In Advances in neural information processing systems, pp. 4055-4065, 2017. +Barreto, A., Borsa, D., Quan, J., Schaul, T., Silver, D., Hessel, M., Mankowitz, D., Zidek, A., and Munos, R. Transfer in deep reinforcement learning using successor features and generalised policy improvement. In International Conference on Machine Learning, pp. 501-510, 2018. +Bellemare, M. G., Naddaf, Y., Veness, J., and Bowling, M. The arcade learning environment: An evaluation plat + +form for general agents. Journal of Artificial Intelligence Research, 47:253-279, 2013. +Brockman, G., Cheung, V., Pettersson, L., Schneider, J., Schulman, J., Tang, J., and Zaremba, W. Openai gym, 2016. +Castro, P. S., Moitra, S., Gelada, C., Kumar, S., and Bellemare, M. G. Dopamine: A research framework for deep reinforcement learning. arXiv preprint arXiv:1812.06110, 2018. +Chen, J. and Jiang, N. Information-theoretic considerations in batch reinforcement learning. arXiv preprint arXiv:1905.00360, 2019. +Dayan, P. Improving generalization for temporal difference learning: The successor representation. Neural Computation, 5(4):613-624, 1993. +Dudík, M., Langford, J., and Li, L. Doubly robust policy evaluation and learning. In Proceedings of the 28th International Conference on International Conference on Machine Learning, pp. 1097-1104, 2011. +Ernst, D., Geurts, P., and Wehenkel, L. Tree-based batch mode reinforcement learning. Journal of Machine Learning Research, 6(Apr):503-556, 2005. +Farajtabar, M., Chow, Y., and Ghavamzadeh, M. More robust doubly robust off-policy evaluation. In International Conference on Machine Learning, pp. 1447-1456, 2018. +Fu, J., Norouzi, M., Nachum, O., Tucker, G., Wang, Z., Novikov, A., Yang, M., Zhang, M. R., Chen, Y., Kumar, A., Paduraru, C., Levine, S., and Paine, T. Benchmarks for deep off-policy evaluation. In International Conference on Learning Representations, 2021. +Fujimoto, S., van Hoof, H., and Meger, D. Addressing function approximation error in actor-critic methods. In International Conference on Machine Learning, volume 80, pp. 1587-1596. PMLR, 2018. +Fujimoto, S., Meger, D., and Precup, D. Off-policy deep reinforcement learning without exploration. In International Conference on Machine Learning, pp. 2052-2062, 2019. +Gauci, J., Conti, E., Liang, Y., Virochsiri, K., He, Y., Kaden, Z., Narayanan, V., Ye, X., Chen, Z., and Fujimoto, S. Horizon: Facebook's open source applied reinforcement learning platform. arXiv preprint arXiv:1811.00260, 2018. +Gelada, C. and Bellemare, M. G. Off-policy deep reinforcement learning by bootstrapping the covariate shift. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pp. 3647-3655, 2019. + +Gershman, S. J. The successor representation: its computational logic and neural substrates. Journal of Neuroscience, 38(33):7193-7200, 2018. +Gershman, S. J., Moore, C. D., Todd, M. T., Norman, K. A., and Sederberg, P. B. The successor representation and temporal context. *Neural Computation*, 24(6):1553-1568, 2012. +Grimm, C., Higgins, I., Barreto, A., Teptyashin, D., Wulfmeier, M., Hertweck, T., Hadsell, R., and Singh, S. Disentangled cumulants help successor representations transfer to new tasks. arXiv preprint arXiv:1911.10866, 2019. +Hallak, A. and Mannor, S. Consistent on-line off-policy evaluation. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pp. 1372-1383. JMLR.org, 2017. +Imani, E., Graves, E., and White, M. An off-policy policy gradient theorem using emphatic weightings. In Advances in Neural Information Processing Systems, pp. 96-106, 2018. +Jaakkola, T., Jordan, M. I., and Singh, S. P. On the convergence of stochastic iterative dynamic programming algorithms. Neural computation, 6(6):1185-1201, 1994. +Janz, D., Hron, J., Mazur, P., Hofmann, K., Hernández-Lobato, J. M., and Tschiatschek, S. Successor uncertainties: exploration and uncertainty in temporal difference learning. In Advances in Neural Information Processing Systems, pp. 4509-4518, 2019. +Jiang, N. and Li, L. Doubly robust off-policy value evaluation for reinforcement learning. In International Conference on Machine Learning, pp. 652-661, 2016. +Kostrikov, I., Nachum, O., and Tompson, J. Imitation learning via off-policy distribution matching. arXiv preprint arXiv:1912.05032, 2019. +Kulkarni, T. D., Saeedi, A., Gautam, S., and Gershman, S. J. Deep successor reinforcement learning. arXiv preprint arXiv:1606.02396, 2016. +Kumar, A., Fu, J., Soh, M., Tucker, G., and Levine, S. Stabilizing off-policy q-learning via bootstrapping error reduction. In Advances in Neural Information Processing Systems, pp. 11784-11794, 2019. +Lesort, T., Diaz-Rodriguez, N., Goudou, J.-F., and Filliat, D. State representation learning for control: An overview. Neural Networks, 108:379-392, 2018. +Li, L., Munos, R., and Szepesvari, C. Toward minimax off-policy value estimation. In Artificial Intelligence and Statistics, pp. 608-616, 2015. + +Lillicrap, T. P., Hunt, J. J., Pritzel, A., Heess, N., Erez, T., Tassa, Y., Silver, D., and Wierstra, D. Continuous control with deep reinforcement learning. arXiv preprint arXiv:1509.02971, 2015. +Liu, Q., Li, L., Tang, Z., and Zhou, D. Breaking the curse of horizon: Infinite-horizon off-policy estimation. In Advances in Neural Information Processing Systems, pp. 5356-5366, 2018. +Liu, Y., Bacon, P.-L., and Brunskill, E. Understanding the curse of horizon in off-policy evaluation via conditional importance sampling. arXiv preprint arXiv:1910.06508, 2019a. +Liu, Y., Swaminathan, A., Agarwal, A., and Brunskill, E. Off-policy policy gradient with state distribution correction. arXiv preprint arXiv:1904.08473, 2019b. +Machado, M. C., Rosenbaum, C., Guo, X., Liu, M., Tesauro, G., and Campbell, M. Eigenoption discovery through the deep successor representation. arXiv preprint arXiv:1710.11089, 2017. +Machado, M. C., Bellemare, M. G., and Bowling, M. Count-based exploration with the successor representation. arXiv preprint arXiv:1807.11622, 2018a. +Machado, M. C., Bellemare, M. G., Talvitie, E., Veness, J., Hausknecht, M., and Bowling, M. Revisiting the arcade learning environment: Evaluation protocols and open problems for general agents. Journal of Artificial Intelligence Research, 61:523-562, 2018b. +Mahmood, A. R., Yu, H., and Sutton, R. S. Multi-step off-policy learning without importance sampling ratios. arXiv preprint arXiv:1702.03006, 2017. +Mandel, T., Liu, Y.-E., Levine, S., Brunskill, E., and Popovic, Z. Offline policy evaluation across representations with applications to educational games. In International Conference on Autonomous Agents and Multiagent Systems, 2014. +Mnih, V., Kavukcuoglu, K., Silver, D., Rusu, A. A., Veness, J., Bellemare, M. G., Graves, A., Riedmiller, M., Fidjeland, A. K., Ostrovski, G., et al. Human-level control through deep reinforcement learning. Nature, 518(7540): 529-533, 2015. +Momennejad, I., Russek, E. M., Cheong, J. H., Botvinick, M. M., Daw, N. D., and Gershman, S. J. The successor representation in human reinforcement learning. Nature Human Behaviour, 1(9):680-692, 2017. +Mousavi, A., Li, L., Liu, Q., and Zhou, D. Black-box off-policy estimation for infinite-horizon reinforcement learning. arXiv preprint arXiv:2003.11126, 2020. + +Munos, R., Stepleton, T., Harutyunyan, A., and Bellemare, M. Safe and efficient off-policy reinforcement learning. In Advances in Neural Information Processing Systems, pp. 1054-1062, 2016. +Nachum, O., Chow, Y., Dai, B., and Li, L. Dualdice: Behavior-agnostic estimation of discounted stationary distribution corrections. In Advances in Neural Information Processing Systems, pp. 2315-2325, 2019a. +Nachum, O., Dai, B., Kostrikov, I., Chow, Y., Li, L., and Schuurmans, D. Algaedice: Policy gradient from arbitrary experience. arXiv preprint arXiv:1912.02074, 2019b. +Precup, D., Sutton, R. S., and Dasgupta, S. Off-policy temporal-difference learning with function approximation. In International Conference on Machine Learning, pp. 417-424, 2001. +Riedmiller, M. Neural fitted q iteration-first experiences with a data efficient neural reinforcement learning method. In European Conference on Machine Learning, pp. 317-328. Springer, 2005. +Schulman, J., Wolski, F., Dhariwal, P., Radford, A., and Klimov, O. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017. +Sinha, S., Song, J., Garg, A., and Ermon, S. Experience replay with likelihood-free importance weights. arXiv preprint arXiv:2006.13169, 2020. +Sutton, R. S. Learning to predict by the methods of temporal differences. Machine learning, 3(1):9-44, 1988. +Sutton, R. S. and Barto, A. G. Reinforcement learning: An introduction, volume 1. MIT press Cambridge, 1998. +Sutton, R. S. and Tanner, B. Temporal-difference networks. In Advances in neural information processing systems, pp. 1377-1384, 2005. +Sutton, R. S., Modayil, J., Delp, M., Degris, T., Pilarski, P. M., White, A., and Precup, D. Horde: a scalable real-time architecture for learning knowledge from unsupervised sensorimotor interaction. In The 10th International Conference on Autonomous Agents and Multiagent Systems-Volume 2, pp. 761-768, 2011. +Sutton, R. S., Mahmood, A. R., and White, M. An emphatic approach to the problem of off-policy temporal-difference learning. The Journal of Machine Learning Research, 17 (1):2603-2631, 2016. +Swaminathan, A., Krishnamurthy, A., Agarwal, A., Dudik, M., Langford, J., Jose, D., and Zitouni, I. Off-policy evaluation for slate recommendation. In Advances in + +Neural Information Processing Systems, pp. 3632-3642, 2017. +Thomas, P. and Brunskill, E. Data-efficient off-policy policy evaluation for reinforcement learning. In International Conference on Machine Learning, pp. 2139-2148, 2016. +Todorov, E., Erez, T., and Tassa, Y. Mujoco: A physics engine for model-based control. In IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), pp. 5026-5033. IEEE, 2012. +Touati, A., Zhang, A., Pineau, J., and Vincent, P. Stable policy optimization via off-policy divergence regularization. arXiv preprint arXiv:2003.04108, 2020. +Tsitsiklis, J. N. and Van Roy, B. Analysis of temporal-difference learning with function approximation. In Advances in neural information processing systems, pp. 1075-1081, 1997. +Uehara, M. and Jiang, N. Minimax weight and q-function learning for off-policy evaluation. arXiv preprint arXiv:1910.12809, 2019. +Van Hasselt, H., Guez, A., and Silver, D. Deep reinforcement learning with double q-learning. In AAAI, pp. 2094-2100, 2016. +Voloshin, C., Le, H. M., Jiang, N., and Yue, Y. Empirical study of off-policy policy evaluation for reinforcement learning. arXiv preprint arXiv:1911.06854, 2019. +Wang, T., Bowling, M., and Schuurmans, D. Dual representations for dynamic programming and reinforcement learning. In 2007 IEEE International Symposium on Approximate Dynamic Programming and Reinforcement Learning, pp. 44-51. IEEE, 2007. +Wang, T., Bowling, M., Schuurmans, D., and Lizotte, D. J. Stable dual dynamic programming. In Advances in neural information processing systems, pp. 1569-1576, 2008. +Wang, Y.-X., Agarwal, A., and Dudík, M. Optimal and adaptive off-policy evaluation in contextual bandits. In International Conference on Machine Learning, pp. 3589-3597, 2017. +Xie, T., Ma, Y., and Wang, Y.-X. Towards optimal off-policy evaluation for reinforcement learning with marginalized importance sampling. In Advances in Neural Information Processing Systems, pp. 9665-9675, 2019. +Yang, M., Nachum, O., Dai, B., Li, L., and Schuurmans, D. Off-policy evaluation via the regularized lagrangian. Advances in Neural Information Processing Systems, 33, 2020. + +Yang, Z., Xie, Y., and Wang, Z. A theoretical analysis of deep q-learning. arXiv preprint arXiv:1901.00137, 2019. +Zhang, J., Springenberg, J. T., Boedecker, J., and Burgard, W. Deep reinforcement learning with successor features for navigation across similar environments. In 2017 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), pp. 2371-2378. IEEE, 2017. +Zhang, R., Dai, B., Li, L., and Schuurmans, D. Gendice: Generalized offline estimation of stationary values. arXiv preprint arXiv:2002.09072, 2020a. +Zhang, S., Boehmer, W., and Whiteson, S. Generalized off-policy actor-critic. In Advances in Neural Information Processing Systems, pp. 1999-2009, 2019. +Zhang, S., Liu, B., and Whiteson, S. Gradientdice: Rethinking generalized offline estimation of stationary values. arXiv preprint arXiv:2001.11113, 2020b. +Zhao, Y., Kosorok, M. R., and Zeng, D. Reinforcement learning design for cancer clinical trials. Statistics in medicine, 28(26):3294, 2009. +Zhu, Y., Gordon, D., Kolve, E., Fox, D., Fei-Fei, L., Gupta, A., Mottaghi, R., and Farhadi, A. Visual semantic planning using deep successor representations. In Proceedings of the IEEE International Conference on Computer Vision, pp. 483-492, 2017. \ No newline at end of file diff --git a/adeepreinforcementlearningapproachtomarginalizedimportancesamplingwiththesuccessorrepresentation/images.zip b/adeepreinforcementlearningapproachtomarginalizedimportancesamplingwiththesuccessorrepresentation/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..b737579914dea193310d9830bd8de7629de21eaa --- /dev/null +++ b/adeepreinforcementlearningapproachtomarginalizedimportancesamplingwiththesuccessorrepresentation/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d950103b2f3dcba38d5eb7b3b3a01f3da37fed507911452608dad602d3843dc0 +size 427422 diff --git a/adeepreinforcementlearningapproachtomarginalizedimportancesamplingwiththesuccessorrepresentation/layout.json b/adeepreinforcementlearningapproachtomarginalizedimportancesamplingwiththesuccessorrepresentation/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..24447f7eaf55b65d2152e0d0aecd64e37a8b61ee --- /dev/null +++ b/adeepreinforcementlearningapproachtomarginalizedimportancesamplingwiththesuccessorrepresentation/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:420312c04d6e6c9db13ae8dbd99502bef0f3cac442ca1f6ddf1471ad093f973c +size 584036 diff --git a/adifferentiablepointprocesswithitsapplicationtospikingneuralnetworks/eccf1f7b-3a5f-49a7-88f5-4ac04b578025_content_list.json b/adifferentiablepointprocesswithitsapplicationtospikingneuralnetworks/eccf1f7b-3a5f-49a7-88f5-4ac04b578025_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..46796a085c0178792dde6654ddd1ab0868cb1373 --- /dev/null +++ b/adifferentiablepointprocesswithitsapplicationtospikingneuralnetworks/eccf1f7b-3a5f-49a7-88f5-4ac04b578025_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c495dd694ddc7f01bd02ebab9979d3a2ae867ab5fd1d96533f6e6153ac5d9bd6 +size 94755 diff --git a/adifferentiablepointprocesswithitsapplicationtospikingneuralnetworks/eccf1f7b-3a5f-49a7-88f5-4ac04b578025_model.json b/adifferentiablepointprocesswithitsapplicationtospikingneuralnetworks/eccf1f7b-3a5f-49a7-88f5-4ac04b578025_model.json new file mode 100644 index 0000000000000000000000000000000000000000..6a67f8859621d523fc011a84217a7d56c9b62638 --- /dev/null +++ b/adifferentiablepointprocesswithitsapplicationtospikingneuralnetworks/eccf1f7b-3a5f-49a7-88f5-4ac04b578025_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cdce193b302b86980f458fc81812b8529b5656580ada0226c161fefb3ccfc1eb +size 113591 diff --git a/adifferentiablepointprocesswithitsapplicationtospikingneuralnetworks/eccf1f7b-3a5f-49a7-88f5-4ac04b578025_origin.pdf b/adifferentiablepointprocesswithitsapplicationtospikingneuralnetworks/eccf1f7b-3a5f-49a7-88f5-4ac04b578025_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..26ee7cb454e11357d4a66a29f1d0640e6c5f3539 --- /dev/null +++ b/adifferentiablepointprocesswithitsapplicationtospikingneuralnetworks/eccf1f7b-3a5f-49a7-88f5-4ac04b578025_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9ceac878121f0008190ca34dcc5ab7b1f81e70689aa5f61578ba45567cb36c71 +size 551101 diff --git a/adifferentiablepointprocesswithitsapplicationtospikingneuralnetworks/full.md b/adifferentiablepointprocesswithitsapplicationtospikingneuralnetworks/full.md new file mode 100644 index 0000000000000000000000000000000000000000..2e6a3bddd53f88622c86ea8579818b8ecc9b8f53 --- /dev/null +++ b/adifferentiablepointprocesswithitsapplicationtospikingneuralnetworks/full.md @@ -0,0 +1,419 @@ +# A Differentiable Point Process with Its Application to Spiking Neural Networks + +# Hiroshi Kajino + +# Abstract + +This paper is concerned about a learning algorithm for a probabilistic model of spiking neural networks (SNNs). Jimenez Rezende & Gerstner (2014) proposed a stochastic variational inference algorithm to train SNNs with hidden neurons. The algorithm updates the variational distribution using the score function gradient estimator, whose high variance often impedes the whole learning algorithm. This paper presents an alternative gradient estimator for SNNs based on the path-wise gradient estimator. The main technical difficulty is a lack of a general method to differentiate a realization of an arbitrary point process, which is necessary to derive the path-wise gradient estimator. We develop a differentiable point process, which is the technical highlight of this paper, and apply it to derive the path-wise gradient estimator for SNNs. We investigate the effectiveness of our gradient estimator through numerical simulation. + +# 1. Introduction + +A spiking neural network (SNN) is an artificial neural network (ANN) where neurons communicate with each other using spikes rather than real values as the conventional ANNs do. The conventional ANN is a special case of SNN where information is encoded into the firing rate of neurons (which we call the rate coding) and the rate serves as the communication currency. This specification facilitates developing learning algorithms for ANNs, leading to the recent great success of deep neural networks. On the other hand, in the community of neuroscience, experimental evidence on biological neurons indicates that the rate coding alone cannot explain the whole brain activity (Bothe, 2004) and more precise modeling of neural coding is anticipated. Since there still exist performance gaps between the rate-based ANNs and biological neural networks (i.e., brains) in terms of inference capability and energy efficiency, this + +raises the following question: how much of the current performance gaps can be attributed to this difference on neural coding? This open problem motivates us to study SNNs. + +One of the major obstacles towards answering it is a lack of practical learning algorithms for SNNs, which discourages us from empirical investigation. While there exist a number of attempts to develop learning algorithms, most of them have more or less limited applicability. We consider a practical learning algorithm should at least be (i) theoretically grounded, (ii) empirically confirmed to work well, and (iii) easy to simulate (fewer hyperparameters, less computation time, etc.)1. For example, theoretical aspects of the algorithms based on spike-timing-dependent plasticity (Chapter 19 (Gerstner et al., 2014)) are not well understood. For another example, simulating learning algorithms for continuous-time deterministic SNNs requires the step-size parameter of time-axis discretization when the dynamics of a neuron is described by differential equations (e.g., (Huh & Sejnowski, 2018)). The step-size parameter brings about the trade-off between the simulation quality and computation time, which makes the simulation more intricate. These examples illustrate that even major approaches do not satisfy all the requirements above, and therefore, there still exists much room for improvement. + +Among a number of approaches, we employ as a foundation a probabilistic formulation of SNNs (Pfister et al., 2006), which models spike trains (temporal sequence of spikes emitted from neurons) as a realization of a multivariate point process. It is easier for us to start from it than others because it already satisfies requirements (i) and (iii), which are more intrinsic properties than requirement (ii). In fact, learning algorithms are formalized by maximum likelihood estimation, and its exact simulation has no trade-off hyperparameter as will be explained in Section 2.2. Therefore, the remaining concern is its empirical performance. + +One of the state-of-the-art learning algorithms for probabilistic SNNs is the work by Jimenez Rezende & Gerstner (2014). The authors propose a stochastic variational inference algorithm for SNNs with hidden neurons. Since spike trains of hidden neurons are unobservable and it is intractable to compute the marginal likelihood, an evidence + +lowerbound (ELBO) is instead used as the objective function (Section 4.2). The key factor for optimizing ELBO is the way we estimate the gradient of ELBO. The authors employed the score function gradient estimator, also known as the REINFORCE estimator, which is widely applicable but is often reported to suffer from its high variance. + +Our main idea is to substitute a path-wise gradient estimator for the score function gradient estimator. The path-wise gradient estimator tends to have lower variance than the score function gradient estimator (Mohamed et al., 2019), but it is not widely applicable (and is not applicable to SNNs) because it requires a sample from the variational distribution to be differentiable. Our contribution is that we develop a differentiable point process (Section 3) and apply it to derive the path-wise gradient estimator for SNNs (Section 4.2.2). + +We empirically investigate the effectiveness of the proposed learning algorithm in Section 5. We will confirm that (i) the proposed gradient estimator has lower variance than the existing one and (ii) this lower variance contributes to improve the performance of the learning algorithm. By comparing the performance of the proposed and existing ones, we obtain experimental results supporting these hypotheses. Therefore, we conclude that our path-wise gradient estimator improves empirical performance of SNNs. + +One of the limitations of our learning algorithm as compared to the existing algorithm (Jimenez Rezende & Gerstner, 2014) is computation time. Since our algorithm generates more hidden spikes than the existing one does, our algorithm requires more computation time. We empirically examine the computational overhead of our algorithm against the existing one, and find that our algorithm requires 2.8 times more computation time than the existing one. + +Notation. Let $[N] = \{1,2,\dots ,N\}$ . For any vector $\mathbf{x}$ , its $d$ -th element is represented by $x_{d}$ . $\left[x_d\right]_{d\in [D]}$ denotes a $D$ -dimensional vector whose $d$ -th element is $x_{d}$ . For any vector $\mathbf{x} \in \mathbb{R}^{D}$ and scalar $c \in \mathbb{R}$ , $\left[\mathbf{x}^{\top} c\right]^{\top}$ denotes the $(D + 1)$ -dimensional vector concatenating $\mathbf{x}$ and $c$ . Let $\mathbb{R}_{\geq 0} = \{x \geq 0\}$ and $\mathbb{R}_{>0} = \{x > 0\}$ . Let $\mathbb{1}^{D} = \{\mathbf{1}_{d}\}_{d \in [D]}$ be the set of $D$ -dimensional one-hot vectors, where $\mathbf{1}_d \in \{0,1\}^D$ is the one-hot vector whose $d$ -th element is 1 and the others are 0. For any set $A$ , let $\mathrm{conv}(A)$ be its convex hull, let $\mathrm{conv}_0(A) := \mathrm{conv}(A \cup \{0\})$ . Let $\operatorname{Cat}(\mathbf{p})$ be the categorical distribution with parameter $\mathbf{p} \in \mathrm{conv}(\mathbb{1}^D)$ , whose random variable takes $\mathbf{1}_d \in \mathbb{1}^D$ with probability $p_d$ . Let $U[a,b]$ denote the uniform distribution over $[a,b]$ . For any expectation operator $\mathbb{E}_p$ , let $\hat{\mathbb{E}}_p$ be its Monte-Carlo approximation using an i.i.d. sample from $p$ . + +# 2. Preliminaries + +This section introduces temporal point processes along with their parameter estimation and sampling methods. + +# 2.1. Point Processes + +A point process (Daley & Vere-Jones, 2003) is a probabilistic model of an event collection. It is called a temporal point process when the event collection evolves in time. This paper only deals with a temporal point process, and therefore, we refer to it as a point process. We assume that point processes are simple, i.e., no events coincide. + +# 2.1.1. UNIVARIATE POINT PROCESS + +Assume we observe a sequence of $N\in \mathbb{N}$ discrete events during time interval $[0,T]$ , and let $\mathcal{T}$ denote such an observation. $\mathcal{T}$ can be represented by a series of event time stamps $\{t_n\in [0,T]\}_{n\in [N]}$ as well as the information that we observe no event during $[0,t_1)$ , $\{(t_{n},t_{n + 1})\}_{n = 1}^{N - 1}$ , and $(t_N,T]$ . Let $\mathcal{T}^{\leq t_n}$ represents a partial observation of $\mathcal{T}$ up to and including time $t_n$ . One way of modeling $\mathcal{T}$ is to specify the probability density function of the event time stamp $t_{n + 1}$ given the collection of its past events $\mathcal{T}^{\leq t_n}$ , which we describe, $f(t\mid \mathcal{T}^{\leq t_n})$ . Note that the probability density function must satisfy $f(t\mid \mathcal{T}^{\leq t_n}) = 0$ for $t\leq t_n$ and $\int_{t_n}^{\infty}f(t\mid \mathcal{T}^{\leq t_n})\mathrm{d}t = 1$ . The cumulative distribution function can be defined accordingly: $F(t\mid \mathcal{T}^{\leq t_n}) = \int_{t_n}^{t}f(s\mid \mathcal{T}^{\leq t_n})\mathrm{d}s = \operatorname*{Pr}[t_{n + 1}\in (t_n,t)\mid \mathcal{T}^{\leq t_n}]$ . + +Another way of modeling it is to specify the conditional intensity function, which is related to the distributions as, + +$$ +\lambda (t \mid \mathcal {T} ^ {\leq t _ {n}}) = \left\{ \begin{array}{l l} \frac {f (t \mid \mathcal {T} ^ {\leq t _ {n}})}{1 - F (t \mid \mathcal {T} ^ {\leq t _ {n}})} & (t > t _ {n}), \\ 0 & (t \leq t _ {n}). \end{array} \right. \tag {1} +$$ + +In the following, let $t_n$ denote an arbitrary event time stamp and we only specify the conditional intensity function for $t > t_n$ , because its value for $t \leq t_n$ is trivially 0. Observing that $\lambda(t \mid \mathcal{T}^{\leq t_n}) \mathrm{d}t = \operatorname*{Pr}[t_{n+1} \in [t, t + \mathrm{d}t] \mid t_{n+1} \notin (t_n, t), \mathcal{T}^{\leq t_n}]$ holds as $\mathrm{d}t \to +0$ (Rasmussen, 2018), the conditional intensity function represents how likely the event occurs at time $t$ given that we have observed $n$ events so far and no event has been observed during $(t_n, t)$ . + +A point process is more often specified by the conditional intensity function than the time interval distribution. Let $\mathcal{PP}(\lambda)$ be the point process with the conditional intensity function $\lambda$ . Corollary 1, which is an immediate consequence of Proposition 2, states the conditions under which the conditional intensity function uniquely specifies a point process. + +Corollary 1. A conditional intensity function $\lambda$ uniquely defines a point process if it satisfies the following conditions for any observation of discrete events $\mathcal{T}^{\leq t_n}$ and any $t > t_{n}$ : + +1. $\lambda (t\mid \mathcal{T}^{\leq t_n})$ is non-negative and integrable on any interval starting at $t_n$ +2. $\int_{t_n}^t\lambda (s\mid \mathcal{T}^{\leq t_n})\mathrm{d}s\to \infty$ as $t\to \infty$ , and + +![](images/bd7d3c72deffffa0cfa3d9d744a9a1df45b87653a0beb2bb2eb545ca2a984842.jpg) +Figure 1. Realization of a temporal point process (bottom) and its corresponding left-continuous counting process (top). + +![](images/4f237072a80e2a2d5eac0734e4cbc7693eb07a07ebacc00d86069db05b8dbc76.jpg) +Figure 2. Illustration of a multivariate point process (top) and its equivalent marked point process (bottom). + +3. $\int_{t_n}^t\lambda (s\mid \mathcal{T}^{\leq t_n})\mathrm{d}s$ is right continuous w.r.t. $t$ + +The log-likelihood of observation $\mathcal{T}$ on $\mathcal{PP}(\lambda)$ is given as, + +$$ +\log p (\mathcal {T}) = \sum_ {t \in \mathcal {T}} \log \lambda (t \mid \mathcal {T} ^ {\leq t _ {n (t)}}) - \Lambda^ {[ 0, T ]} (\mathcal {T}), \tag {2} +$$ + +where let $\Lambda^{[0,T]}(\mathcal{T}) = \int_0^T\lambda (t\mid \mathcal{T}^{\leq t_{n(t)}})\mathrm{d}t$ be the integrated conditional intensity function, also known as the compensator, which accounts for no-event periods, and let $n(t):\mathbb{R}_{\geq 0}\to \mathbb{Z}_{\geq 0}$ be the left-continuous counting process of the observation $\mathcal{T}$ , which counts the number of events up to but not including time $t$ . The latest event time stamp at time $t$ can be denoted by $t_{n(t)}\in [0,t)$ . Figure 1 illustrates a realization of a point process and its counting representation. A typical procedure of modeling $\mathcal{T}$ is to design a parametric model of the conditional intensity function that satisfies the conditions of Corollary 1 and train it by maximizing the log-likelihood function (Equation (2)). + +# 2.1.2. MULTIVARIATE POINT PROCESS + +A multivariate point process is a set of mutually dependent point processes and can be defined via a marked point process, in which each event is associated with a mark. We call a marked point process whose mark belongs to set $X$ , an $X$ -marked point process. Let $\mathcal{T}_X$ denote an observation of an $X$ -marked point process, which contains a series of event time stamps and marks, $\{(t_n, \mathbf{p}_n) \in [0, T] \times X\}_{n \in [N]}$ . As illustrated in Figure 2, a $D$ -variate point process can be + +defined by a $\mathbb{1}^D$ -marked point process, where each mark $\mathbf{p}_n$ indicates which dimension the event belongs to. For example, if $\mathbf{p}_n = \mathbf{1}_1$ , the $n$ -th event occurs at the first dimension. In Figure 2, blue-circle and red-diamond marks correspond to the first and the second dimensions respectively. + +Letting $f(t, \mathbf{p} \mid \mathcal{T}_{\mathbb{1}^D}^{< t_n})$ be the probability density function of each event $(t_{n+1}, \mathbf{p}_{n+1})$ given its past events $\mathcal{T}_{\mathbb{1}^D}^{< t_n}$ , the conditional intensity function can be defined similarly: + +$$ +\lambda \left(t, \mathbf {p} \mid \mathcal {T} _ {\mathbb {1} ^ {D}} ^ {\leq t _ {n}}\right) = \frac {f \left(t , \mathbf {p} \mid \mathcal {T} _ {\mathbb {1} ^ {D}} ^ {\leq t _ {n}}\right)}{1 - F \left(t \mid \mathcal {T} _ {\mathbb {1} ^ {D}} ^ {\leq t _ {n}}\right)}, \tag {3} +$$ + +where $F(t \mid \mathcal{T}_{\mathbb{1}^D}^{< t_n}) = \int_{t_n}^t \mathrm{d}s \sum_{\mathbf{p} \in \mathbb{1}^D} f(s, \mathbf{p} \mid \mathcal{T}_{\mathbb{1}^D}^{< t_n})$ . The conditional intensity function represents how likely event $(t, \mathbf{1}_d)$ occurs: $\lambda(t, \mathbf{1}_d \mid \mathcal{T}_{\mathbb{1}^D}^{< t_n}) \mathrm{d}t = \operatorname*{Pr}[t_{n+1} \in [t, t + \mathrm{d}t], \mathbf{p}_{n+1} = \mathbf{1}_d \mid t_{n+1} \notin (t_n, t), \mathcal{T}_{\mathbb{1}^D}^{< t_n}]$ . Proposition 2 states conditions under which the conditional intensity function uniquely specifies a marked point process. See Appendix B for its proof. Let $\mathcal{MPP}(\lambda)$ be the multivariate point process with the conditional intensity function $\lambda$ . + +Proposition 2. Let $X$ be a set. A conditional intensity function $\lambda$ uniquely defines an $X$ -marked point process if it satisfies the following conditions for any $T_X^{< t_n}$ and $t > t_n$ : + +1. $\lambda (t,\mathbf{p}\mid \mathcal{T}_X^{< t_n})\geq 0$ and integrable w.r.t. $\mathbf{p}$ and w.r.t. $t$ on any interval starting at $t_n$ +2. $\int_{t_n}^t\mathrm{d}s\int_X\mathrm{d}\mathbf{p}\lambda (s,\mathbf{p}\mid \mathcal{T}_X^{\leq t_n})\to \infty$ as $t\to \infty$ , and +3. $\int_{t_n}^t\mathrm{d}s\int_X\mathrm{d}\mathbf{p}\lambda (s,\mathbf{p}\mid \mathcal{T}_X^{\leq t_n})$ is right continuous in $t$ + +The log-likelihood of observation $\mathcal{T}_{\mathbb{L}^D}$ is written as: + +$$ +\begin{array}{l} \log p \left(\mathcal {T} _ {\mathbb {1} ^ {D}}\right) \\ = \sum_ {(t, \mathbf {p}) \in \mathcal {T} _ {\mathbb {1} D}} \log \lambda (t, \mathbf {p} \mid \mathcal {T} _ {\mathbb {1} ^ {D}} ^ {\leq t _ {n (t)}}) - \Lambda^ {[ 0, T ]} (\mathcal {T} _ {\mathbb {1} ^ {D}}), \tag {4} \\ \end{array} +$$ + +where let $\Lambda^{[0,T]}(\mathcal{T}_{\mathbb{1}^D}) = \int_0^T\sum_{\mathbf{p}\in \mathbb{1}^D}\lambda (t,\mathbf{p}\mid \mathcal{T}_{\mathbb{1}^D}^{< t_n(t)})\mathrm{d}t$ be the compensator. Since its analytical form is not available for a general conditional intensity function, we resort to Monte-Carlo approximation to estimate the compensator. In specific, we draw $M$ examples, $\{t_m\}_{m\in [M]}$ , from $U[0,T]$ and approximate it as, + +$$ +\Lambda^ {[ 0, T ]} \left(\mathcal {T} _ {\mathbb {1} ^ {D}}\right) \approx \frac {T}{M} \sum_ {m = 1} ^ {M} \sum_ {\mathbf {p} \in \mathbb {1} ^ {D}} \lambda \left(t _ {m}, \mathbf {p} \mid \mathcal {T} _ {\mathbb {1} ^ {D}} ^ {\leq t _ {n (t _ {m})}}\right). \tag {5} +$$ + +# 2.2. Sampling Algorithms + +This section introduces sampling algorithms for a point process given a conditional intensity function. A notable + +Algorithm 1 Thinning algorithm for $\mathcal{MPP}$ +Input: Conditional intensity function $\lambda$ and upperbound $\bar{\lambda}$ +Output: Realization of $\mathcal{MPP}(\lambda)$ +1: $S\gets \emptyset ,T\gets \emptyset$ +2: while true do +3: Sample $s\sim \mathcal{PP}(\bar{\lambda}\mid S)$ +4: if $s > T$ then +5: break +6: Sample $\begin{bmatrix}{\bf p}\\ {r} \end{bmatrix} \sim \mathrm{Cat}\left(\pmb {\pi}_{\bar{\lambda}}\circ \pmb {\lambda}(s\mid T)\right)\\ \textit{if} r\neq 1$ then +8: $\mathcal{T}\gets \mathcal{T}\cup \{(s,\mathbf{p})\}$ +9: $S\gets S\cup \{s\}$ +10: return $\mathcal{T}$ + +feature of the algorithms is that they can exactly simulate point processes without any approximation. This indicates that there exists no hyperparameter controlling the trade-off between computational cost and accuracy of the simulation, which greatly facilitates simulating SNNs. + +# 2.2.1. HOMOGENEOUS POISSON PROCESS + +The simplest point process is the homogeneous Poisson process whose conditional intensity function is constant; $\lambda (t\mid \mathcal{T}^{\leq t_n}) = \lambda$ for any $\mathcal{T}^{\leq t_n}$ . It is straightforward to sample from it because the interval between two successive events $\tau$ is independently and identically distributed according to the exponential distribution, $f(\tau ;\lambda) = \lambda \mathrm{e}^{-\lambda \tau}$ . + +# 2.2.2. GENERAL POINT PROCESS + +It is not straightforward to sample from a general point process when a closed-form expression of the inter-event time distribution is not available. This is true for many point processes including SNNs. Among several sampling methods, the thinning algorithm (Lewis & Shedler, 1979; Ogata, 1981) allows us to sample from such a point process without knowing the closed-form expression. For other sampling algorithms, please refer to Section 6. + +The main idea is to generate a sequence of time stamps from a homogeneous Poisson process with sufficiently high intensity (which we call the base process) and then to thin some of the events so that the sequence follows the given point process. Algorithm 1 describes it for the multivariate case, where let $\pmb{\lambda}(t|\mathcal{T}) = [\lambda(t,\mathbf{1}_d|\mathcal{T})]_{d\in [D]}$ , and let $\pi_{\bar{\lambda}}$ be an operator that receives a $D$ -dimensional vector $\pmb{\lambda}$ and returns $\frac{1}{\lambda} \begin{bmatrix} \pmb{\lambda} \\ \bar{\lambda} - \| \pmb{\lambda} \|_1 \end{bmatrix}$ . + +It first generates a new time stamp $s$ from the homogeneous Poisson process with intensity $\bar{\lambda}$ (line 3). Then it decides whether or not to accept the event, and if accepting, decides which dimension the event is assigned + +to (lines 6-8); $s$ is rejected if $r = 1$ , i.e., with probability $1 - \frac{1}{\lambda}\sum_{\mathbf{p} \in \mathbb{1}^D} \lambda(s, \mathbf{p} \mid \mathcal{T})$ , and $s$ is accepted as the event from the $d$ -th dimension ( $d \in [D]$ ) if $p_d = 1$ , i.e., with probability $\lambda(s, \mathbf{1}_d \mid \mathcal{T}) / \bar{\lambda}$ , + +Intuitively, the correctness of Algorithm 1 is understood as follows. Assuming we have sampled $\mathcal{T}_{\mathbb{1}^D}^{< t_n}$ , at any time $t > t_{n}$ , the probability that the algorithm generates the event with mark $\mathbf{1}_d$ in interval $[t,t + \mathrm{d}t]$ is, + +$$ +\begin{array}{l} \Pr \left[ t _ {n + 1} \in [ t, t + \mathrm {d} t ], \mathbf {p} _ {n + 1} = \mathbf {1} _ {d} \mid \mathcal {T} _ {\mathbb {1} ^ {D}} ^ {< t} \right] \\ = \underbrace {\bar {\lambda} \mathrm {d} t} _ {\text {P r o b . t h a t t h e b a s e p r o c e s s}} \cdot \underbrace {\lambda \left(t , \mathbf {1} _ {d} \mid \mathcal {T} _ {\mathbb {1} ^ {D}} ^ {\leq t _ {n}}\right) / \bar {\lambda}} _ {\text {P r o b . t h a t t i s}} \\ = \lambda \left(t, \mathbf {1} _ {d} \mid \mathcal {T} _ {\mathbb {1} ^ {D}} ^ {\leq t _ {n}}\right) \mathrm {d} t, \\ \end{array} +$$ + +where let $\mathcal{T}_{\mathbb{1}^D}^{< t}$ denote the event $t_{n + 1}\notin (t_n,t)$ and $\mathcal{T}_{\mathbb{1}^D}^{< t_n}$ . This shows that the output follows $\mathcal{MPP}(\lambda)$ . For its formal proof, please refer to Reference (Ogata, 1981). + +# 3. Differentiable Point Process + +We present the key building block of our method called a differentiable point process, whose realization is differentiable with respect to its parameters. Differentiability plays an essential role when designing a learning algorithm for latent variable models as will be discussed in Section 4.2. + +The key idea is that the output of Algorithm 1 becomes differentiable if we replace the categorical distribution in line 6 with a reparameterizable distribution such as the concrete distribution, also known as the Gumbel-softmax distribution (Maddison et al., 2017; Jang et al., 2017). We first review the concrete distribution (Section 3.1), and then we present the differentiable point process (Section 3.2). + +# 3.1. Concrete Distribution + +The concrete distribution has been developed as a reparameterizable substitute for the categorical distribution. The idea comes from the Gumbel-max trick, which enables us to sample from the categorical distribution. Letting $\pi \in \mathbb{R}_{\geq 0}^{D}$ be an unnormalized parameter of the categorical distribution, the Gumbel-max trick first samples $u_{d} \sim U[0,1]$ for each $d \in [D]$ , and then outputs $\mathbf{1}_{d^{\star}}$ where $d^{\star} = \arg \max_{d \in [D]} \log \pi_{d} - \log (-\log u_{d})$ . The output is known to be distributed according to $\mathrm{Cat}(\pi / \| \pi \|_1)$ . While the Gumbel-max trick successfully divides the sampling procedure into random sampling from the fixed distribution and a parameterized transformation of it, which is necessary to be differentiable, the gradient of its realization with respect to $\pi$ is non-informative, because a small variation to $\pi$ does not change the gradient. + +The concrete distribution is defined by relaxing the range of + +Algorithm 2 Thinning algorithm for $\partial \mathcal{PP}$ + +Input: Conditional intensity function $\lambda$ , its upperbound $\bar{\lambda}$ , and temperature $\tau > 0$ . + +Output: Realization of $\partial \mathcal{PP}(\lambda, \bar{\lambda}, \tau)$ + +1: $\mathcal{S}\gets \emptyset ,\mathcal{T}\gets \emptyset$ +2: while true do +3: Sample $s \sim \mathcal{PP}(\bar{\lambda} \mid S)$ +4: if $s > T$ then +5: break +6: Sample $\left[ \begin{array}{l} \mathbf{P} \\ r \end{array} \right] \sim \mathrm{Concrete}_{\tau}(\pmb{\pi}_{\overline{\lambda}} \circ \pmb{\lambda}(s \mid \mathcal{T}))$ +7: $\mathcal{T}\gets \mathcal{T}\cup \{(s,\mathbf{p})\}$ +8: $\mathcal{S}\gets \mathcal{S}\cup \{s\}$ +9: return $\mathcal{T}$ + +the random variable from $\mathbb{1}^D$ to its convex hull $\mathrm{conv}(\mathbb{1}^D)$ so that its gradient is more informative. Accordingly, the argmax operator in the Gumbel-max trick is replaced with the softmax operator with temperature $\tau > 0$ . Since softmax becomes equivalent to argmax as $\tau \to 0$ , the concrete distribution also becomes equivalent to the categorical distribution as $\tau \to 0$ . Let $g_{\tau}(\mathbf{p};\boldsymbol{\pi})$ denote the probability density function of the concrete distribution with temperature $\tau$ and unnormalized parameter $\pi \in \mathbb{R}_{>0}^{D}$ . + +# 3.2. Multivariate Differentiable Point Process + +We present a constructive definition of a differentiable point process in Definition 3. + +Definition 3. Assume the conditional intensity function $\lambda(t, \mathbf{p} \mid \mathcal{T}_{\mathbb{1}^D}^{< t_n})$ can be computed with an observation of a $\mathrm{conv}_0(\mathbb{1}^D)$ -marked point process. Let $\bar{\lambda}$ be a constant satisfying $\bar{\lambda} > \sum_{\mathbf{p} \in \mathbb{1}^D} \lambda(t, \mathbf{p} \mid \mathcal{T}_{\mathrm{conv}_0(\mathbb{1}^D)}^{< t_n})$ for any $\mathcal{T}_{\mathrm{conv}_0(\mathbb{1}^D)}^{\leq t_n}$ and $t > t_n$ , and $\tau > 0$ be temperature. The differentiable point process $\partial \mathcal{PP}(\lambda, \bar{\lambda}, \tau)$ is defined as a $\mathrm{conv}_0(\mathbb{1}^D)$ -marked point process constructed by Algorithm 2. + +Algorithms 1 and 2 are different in two ways. First, all events from the base process are accepted in Algorithm 2, while some are rejected in Algorithm 1. Second, in Algorithm 1, the mark is defined over $\mathbb{1}^D$ , while in Algorithm 2, it is defined over $\mathrm{conv}_0(\mathbb{1}^D)$ ; each mark is associated with amplitude that is continuous w.r.t. the model parameter. + +The differentiable point process as defined above can be understood as a marked point process (Proposition 4). + +Proposition 4. The differentiable point process $\partial \mathcal{PP}(\lambda, \bar{\lambda}, \tau)$ is a $\mathrm{conv}_0(\mathbb{1}^D)$ -marked point process with conditional intensity function, + +$$ +\begin{array}{l} \lambda_ {\partial} \left(t, \mathbf {p} \mid \mathcal {T} _ {\operatorname {c o n v} _ {0} \left(\mathbb {1} ^ {D}\right)} ^ {\leq t _ {n}}; \boldsymbol {\lambda}, \bar {\lambda}, \tau\right) \\ = \bar {\lambda} \cdot g _ {\tau} \left(\left[ \begin{array}{c} \mathbf {p} \\ 1 - \| \mathbf {p} \| _ {1} \end{array} \right]; \boldsymbol {\pi} _ {\bar {\lambda}} \circ \boldsymbol {\lambda} \left(t \mid \mathcal {T} _ {\operatorname {c o n v} _ {0} (\mathbb {1} ^ {D})} ^ {\leq t _ {n}}\right)\right). \\ \end{array} +$$ + +We can confirm the differentiability of a realization of $\partial \mathcal{PP}$ (Proposition 5). We can also confirm that in the limit of $\tau \to 0$ , the differentiable point process becomes equivalent to the original point process (Proposition 6). See Appendix C for their formal statements and proofs. + +As discussed by Maddison et al. (2017), the concrete distribution often suffers from underflow and we have to implement it in the logarithmic scale. Our implementation also suffers from the same issue, and we provide a numerically stable implementation idea in Appendix E. + +# 4. Learning Algorithm for SNNs + +We present a learning algorithm for spiking neural networks (SNNs) based on the differentiable point process. We first define a probabilistic model of SNNs (Section 4.1) and then will present our learning algorithm, highlighting the difference from the existing one (Section 4.2). + +# 4.1. Probabilistic Model of Spiking Neural Networks + +We employ the standard probabilistic model in the literature (Pfister et al., 2006). Let $D$ be the number of neurons, let $\mathcal{N} = \mathbb{1}^D$ be the set of neurons, each of which is indexed by a one-hot vector, and let $\mathcal{T}_{\mathcal{N}}$ be spike trains emitted from SNN during time interval $[0,T]$ . We assume that $\mathcal{T}_{\mathcal{N}}$ is a realization of an $\mathcal{N}$ -marked point process. + +We define the conditional intensity function based on a spike response model (SRM) (Gerstner et al., 2014). SRM assumes that the $d$ -th spiking neuron is driven by its internal state called a membrane potential, + +$$ +u _ {d} \left(t \mid \mathcal {T} _ {\mathcal {N}} ^ {\leq t _ {n}}\right) = \bar {u} _ {d} + \sum_ {\left(t ^ {\prime}, \mathbf {p}\right) \in \mathcal {T} _ {\mathcal {N}} ^ {\leq t _ {n}}} \mathbf {f} _ {d} \left(t - t ^ {\prime}\right) \cdot \mathbf {p}, \tag {6} +$$ + +where $\mathbf{f}_d(s) = [f_{d'}, d(s)]_{d' \in [D]}$ is a vector of filter functions from all of the neurons to the $d$ -th neuron. In specific, $f_{d',d}(s)$ describes the time course of the membrane potential of neuron $d$ in response to a spike emitted by neuron $d'$ at time $s = 0$ . We assume $f_{d,d}(s) \leq 0$ for all $d \in \mathcal{N}$ . This assumption allows us to reproduce the resetting behavior of a biological neuron; the membrane potential is reset to a lower level after the neuron fires. We also assume that $f_{d',d}(s) = 0$ for $s < 0$ . This assumption ensures that future events have no influence on past events. + +Then, the conditional intensity function is defined by, + +$$ +\lambda^ {\mathrm {S N N}} (t, \mathbf {p} \mid \mathcal {T} _ {\bar {N}} ^ {< t _ {n}}) = \mathbf {p} \cdot \sigma (\mathbf {u} (t \mid \mathcal {T} _ {\bar {N}} ^ {< t _ {n}})), \tag {7} +$$ + +where $\sigma \colon \mathbb{R}^D\to \mathbb{R}_{\geq 0}^D$ is element-wisely non-decreasing and differentiable and let $\mathbf{u}(t\mid \mathcal{T}_{\mathcal{N}}^{\leq t_n}) = [u_d(t\mid \mathcal{T}_{\mathcal{N}}^{\leq t_n})]_{d\in [D]}$ . + +As the membrane potential of one neuron increases, the neuron is more likely to fire and generate a spike. + +For numerical simulation, we assume that the filter functions are parameterized by weights $\{w_{d^{\prime},d,l}\in \mathbb{R}\}_{l = 1}^{L}$ as, + +$$ +f _ {d ^ {\prime}, d} (s) = \left\{ \begin{array}{l l} \sum_ {l = 1} ^ {L} w _ {d ^ {\prime}, d, l} \cdot \kappa (s - s _ {l}) & (s \geq 0), \\ 0 & (s < 0), \end{array} \right. \tag {8} +$$ + +where $\{s_l\in \mathbb{R}\}_{l = 1}^L$ are fixed and $\kappa (s) = \max \{\frac{3}{4} (1 - s^2),0\}$ is the Epanechnikov kernel. We chose this kernel because the bounded support of the kernel allows us to ignore events that occurred more than a certain period ago for membrane potential computation. Let $\theta = \{\bar{u}_d\in \mathbb{R}\}_{d = 1}^D\cup \{w_{d',d,l}\in \mathbb{R}\mid l\in [L]\}_{d,d' = 1}^D$ denote the set of model parameters. + +# 4.2. Learning Algorithms + +Assume some of the neurons are hidden and their spike trains are unobservable. Let $\mathcal{O} \subset \mathcal{N}$ and $\mathcal{H} = \mathcal{N} \backslash \mathcal{O}$ be the sets of observable and hidden neurons, respectively. Accordingly, the spike trains of all of the neurons are divided into observable and hidden ones: $\mathcal{T}_{\mathcal{N}} = \mathcal{T}_{\mathcal{O}} \cup \mathcal{T}_{\mathcal{H}}$ . We consider an estimation procedure for the model parameters of SNN, $\theta$ , given a set of observed spike trains $\{\mathcal{T}_{\mathcal{O},n}\}_{n=1}^{N}$ . + +Letting $p(\mathcal{T}_{\mathcal{N}}; \theta) = p(\mathcal{T}_{\mathcal{O}}, \mathcal{T}_{\mathcal{H}}; \theta)$ be the joint distribution of the observable and hidden spike trains, the parameter $\theta$ is estimated by maximum likelihood estimation: + +$$ +\underset {\theta} {\text {m a x i m i z e}} \quad \sum_ {n = 1} ^ {N} \ell (\theta ; \mathcal {T} _ {\mathcal {O}, n}) +$$ + +where $\ell (\theta ;\mathcal{T}_{\mathcal{O}}) = \log \int p(\mathcal{T}_{\mathcal{O}},\mathcal{T}_{\mathcal{H}};\theta)\mathrm{d}\mathcal{T}_{\mathcal{H}}$ is the marginalized log-likelihood function. Since it is intractable to compute it, we substitute its lower bound called an evidence lower bound (ELBO) for the marginalized log-likelihood function as the objective function: + +$$ +\begin{array}{l} \underline {{\ell}} (\theta , \phi ; \mathcal {T} _ {\mathcal {O}}) = \mathbb {E} _ {q \left(\mathcal {T} _ {\mathcal {H}}; \phi\right)} \left[ \log p \left(\mathcal {T} _ {\mathcal {O}}, \mathcal {T} _ {\mathcal {H}}; \theta\right) - \log q \left(\mathcal {T} _ {\mathcal {H}}; \phi\right) \right], \\ \equiv \mathbb {E} _ {q (\mathcal {T} _ {\mathcal {H}}; \phi)} \underline {{\ell}} (\theta , \phi ; \mathcal {T} _ {\mathcal {O}}, \mathcal {T} _ {\mathcal {H}}), \tag {9} \\ \end{array} +$$ + +where $q(\mathcal{T}_{\mathcal{H}};\phi)$ is an arbitrary distribution called a variational distribution, parameterized by $\phi$ . We specifically assume that the variational distribution is modeled by SNN driven by both observable and hidden spike trains. In the following, we omit the index of data $n$ for ease of presentation and consider ELBO using a single observation $\mathcal{T}_{\mathcal{O}}$ . + +Since there exists no closed-form solution to the maximization problem, we resort to stochastic gradient ascent methods, resulting in Algorithm 3. The basic procedure to train SNN is to choose one realization $\mathcal{T}_{\mathcal{O}}$ from the data set randomly, and update $\theta$ and $\phi$ so as to maximize Equation (9). In the following, we present both an existing approach and our novel approach to compute the gradients, $\frac{\partial\ell}{\partial\theta}$ and $\frac{\partial\ell}{\partial\phi}$ . + +# Algorithm 3 Generic learning algorithm + +Input: Observation $\mathcal{T}_{\mathcal{O}}$ , learning rate $\{\alpha_{k}\}_{k = 1}^{K}$ Output: Model parameters $\theta$ $\phi$ + +1: Initialize $\theta, \phi$ +2: for $k = 1, \dots, K$ do +3: Update $\theta \gets \theta +\alpha_{k}\frac{\partial\ell}{\partial\phi} (\theta ,\phi ;\mathcal{T}_{\mathcal{O}})$ +4: Update $\phi \gets \phi +\alpha_{k}\frac{\partial\ell}{\partial\phi} (\theta ,\phi ;\mathcal{T}_{\mathcal{O}})$ +5: return $\theta, \phi$ + +# 4.2.1. GRADIENT WITH RESPECT TO $\theta$ + +The gradient with respect to $\theta$ is straightforwardly computed by applying Monte-Carlo approximation: $\frac{\partial}{\partial\theta}\underline{\ell} (\theta ,\phi ;\mathcal{T}_{\mathcal{O}})\approx \hat{\mathbb{E}}_{q(\mathcal{T}_{\mathcal{H}};\phi)}\left[\frac{\partial}{\partial\theta}\log p(\mathcal{T}_{\mathcal{O}},\mathcal{T}_{\mathcal{H}};\theta)\right]$ . This can be numerically calculated with the help of automatic differentiation tools. + +# 4.2.2. GRADIENT WITH RESPECT TO $\phi$ + +The gradient with respect to $\phi$ is more involved. In Equation (9), the expectation operator depends on $\phi$ and we cannot exchange $\frac{\partial}{\partial\phi}$ and $\mathbb{E}_{q(\mathcal{T}_{\mathcal{H}};\phi)}$ . There are at least two approaches to computing the gradient in this situation (Mohamed et al., 2019). One approach is to rely on the score function gradient estimator, also known as the REINFORCE estimator (Williams, 1992). While it is widely applicable to a variety of models, it is often reported that the gradient estimator has high variance. Another approach is the path-wise gradient estimator, which makes use of the reparameterization trick (Kingma & Welling, 2014). While its variance is often reported to be lower than that of the score function gradient estimator (Mohamed et al., 2019), its application is limited because the probability distribution $q$ must be reparameterizable. + +In the literature of SNNs, the score function gradient estimator with respect to $\phi$ has been developed by Jimenez Rezende & Gerstner (2014). Our contribution is to develop a path-wise gradient estimator for SNNs based on a differentiable point process presented in Section 3. + +Score function gradient estimator. Jimenez Rezende & Gerstner (2014) used the score function gradient estimator for computing the gradient with respect to $\phi$ : $\frac{\partial\underline{\ell}}{\partial\phi} (\theta ,\phi ;\mathcal{T}_{\mathcal{O}})\approx \hat{\mathbb{E}}_{q(\mathcal{T}_{\mathcal{H}};\phi)}[\frac{\partial\log q(\mathcal{T}_{\mathcal{H}};\phi)}{\partial\phi} (\underline{\ell} (\theta ,\phi ;\mathcal{T}_{\mathcal{O}},\mathcal{T}_{\mathcal{H}}) - 1)]$ . While this is an unbiased estimator of the gradient, its high variance is often problematic. We employ the variational distribution with the conditional intensity function, + +$$ +\lambda_ {q} (t, \mathbf {p} \mid \mathcal {T} _ {\mathcal {N}} ^ {< t _ {n}}; \phi) = \mathbf {p} \cdot \sigma (\mathbf {u} (t \mid \mathcal {T} _ {\mathcal {N}} ^ {< t _ {n}}; \phi)), \tag {10} +$$ + +for any $\mathbf{p} \in \mathcal{H}$ . In particular, we use shared parameters for the model and the variational distribution, i.e., we set $\phi = \theta$ as we observe it improves the performance. + +Path-wise gradient estimator. We propose a path-wise gra + +dient estimator for SNNs. Our main idea is to employ the differentiable point process, $\partial \mathcal{PP}(\lambda_q(t,\mathbf{p}\mid \mathcal{T}_{\mathcal{N}};\phi);\bar{\lambda},\tau)$ as the variational distribution, where $\lambda_{q}$ is defined in Equation (10). This allows us to differentiate a Monte-Carlo approximation of ELBO (Equation (9)) using automatic differentiation tools: + +$$ +\frac {\partial \underline {{\ell}} (\theta , \phi ; \mathcal {T} _ {\mathcal {O}})}{\partial \phi} \approx \frac {\partial \hat {\mathbb {E}} _ {\partial \mathcal {P P}} \underline {{\ell}} (\theta , \phi ; \mathcal {T} _ {\mathcal {O}} , \mathcal {T} _ {\mathrm {c o n v} _ {0} (\mathcal {H})} (\phi))}{\partial \phi}. \tag {11} +$$ + +The main technical issue in applying the differentiable point process is that its realization $\mathcal{T}_{\mathrm{conv}_0(\mathcal{H})}(\phi)$ is incompatible with the SNN model defined by Equations (6) and (7). The model assumes that a mark $\mathbf{p}$ is a one-hot vector, while a mark of a differentiable point process belongs to $\mathrm{conv}_0(\mathcal{H})$ . We address this by devising a differentiable spiking neural network ( $\partial \mathrm{SNN}$ ), which can handle a mark in $\mathrm{conv}_0(\mathcal{H})$ while keeping the conditional intensity function proper. + +Let $\bar{\mathcal{N}} = \mathcal{O} \cup \operatorname{conv}_0(\mathcal{H})$ be the set of marks for $\partial \mathrm{SNN}$ . We define the membrane potential of neuron $d \in \mathcal{N}$ as, + +$$ +u _ {d} \left(t \mid \mathcal {T} _ {\bar {\mathcal {N}}} ^ {\leq t _ {n}}\right) = \bar {u} _ {d} + \sum_ {\left(t ^ {\prime}, \mathbf {p}\right) \in \mathcal {T} _ {\bar {\mathcal {N}}} ^ {\leq t _ {n}}} \mathbf {f} _ {d} \left(t - t ^ {\prime}\right) \cdot \mathbf {p}, \tag {12} +$$ + +and the conditional intensity of $\partial \mathrm{SNN}$ for $\mathbf{p} \in \bar{\mathcal{N}}$ as, + +$$ +\begin{array}{l} \lambda^ {\partial \mathrm {S N N}} \left(t, \mathbf {p} \mid \mathcal {T} _ {\bar {\mathcal {N}}} ^ {\leq t _ {n}}; \bar {\lambda}, \tau\right) \tag {13} \\ = \sum_ {\mathbf {1} _ {d} \in \mathcal {O}} \delta (\mathbf {p} - \mathbf {1} _ {d}) \lambda^ {\text {S N N}} \left(t, \mathbf {p} \mid \mathcal {T} _ {\bar {\mathcal {N}}} ^ {\leq t _ {n}}\right) \\ + \mathbb {I} [ \mathbf {p} \in \operatorname {c o n v} _ {0} (\mathcal {H}) ] \lambda_ {\partial} \left(t, \mathbf {p} _ {\mathcal {H}} \mid \mathcal {T} _ {\bar {N}} ^ {\leq t _ {n}}; \boldsymbol {\lambda} _ {\mathcal {H}}, \bar {\lambda}, \tau\right) \\ \end{array} +$$ + +where $\lambda_{\mathcal{H}}\left(t\mid \mathcal{T}_{\bar{\mathcal{N}}}^{\leq t_n}\right) = \sigma \left(\left[u_d(t\mid \mathcal{T}_{\bar{\mathcal{N}}}^{\leq t_n})\right]_{d\in \mathcal{H}}\right),\mathbb{I}[\cdot ]$ is the indicator function, and $\mathbf{p}_{\mathcal{H}} = [p_d]_{d\in \mathcal{H}}$ + +It is necessary to confirm that (i) the conditional intensity function can be calculated using past events whose marks are in $\bar{\mathcal{N}}$ and (ii) the conditional intensity function satisfies all of the conditions listed in Proposition 2 for $\mathcal{X} = \bar{\mathcal{N}}$ . The first requirement immediately follows from Equations (12) and (13). In Appendix D, we provide the formal statement and proof of the second requirement (Proposition 7). We also confirm that ELBO is differentiable (Proposition 8) and that the differentiable SNN becomes equivalent to the vanilla SNN in the limit of $\tau \to 0$ (Proposition 9). + +# 5. Empirical Studies + +Let us investigate the effectiveness of our gradient estimator through numerical simulation. Our hypothesis is that (i) the path-wise gradient estimator will have lower variance than the score function estimator and (ii) lower variance will improve the predictive performance. We design two + +Table 1. Configuration of SNN generating a synthetic data set. + +
Network sizeD=6, |O|=2, |H|=4
Activation/filter functionsa=5, L=2, s1=0, s2=10
∂PPτ=0.3, λ=20
# of samplings100 (Eq. (5)), 1 (Eq. (9))
+ +experiments (Sections 5.1 and 5.2) to verify these two hypotheses. We additionally compare computation cost of the learning algorithms using each of the gradient estimators in Section 5.3. All the experiments are conducted on IBM Cloud $^4$ , and the code is publicly available (Kajino, 2021). + +Data set. We use a synthetic data set generated by the vanilla SNN (Equation (7)). Table 1 summarizes its configuration. We set $\bar{\lambda} = a|\mathcal{H}| = 20$ , which is the tightest upperbound because we use the sigmoid activation function with amplitude $a$ . The weights are randomly sampled: biases from $U[-1,1]$ , off-diagonal kernel weights from $U[-5,5]$ , and diagonal kernel weights from $U[-5,-0.1]$ . + +Methods compared. Since our objective is to highlight the performance gap between our path-wise gradient estimator $(\partial \mathrm{SNN})$ and the score function gradient estimator (SNN), we use the same hyperparameters and initialization for both of them as much as possible. We initialize their parameters randomly using the same random seed so that both of them have random but the same initial parameters. We also set their hyperparameters as Table 1. The temperature is the only hyperparameter that impacts the performance gap. In preliminary experiments, we observe no significant impact for $\tau \in [0.1, 0.5]$ , and we only report the result at $\tau = 0.3$ . + +# 5.1. Variance of the Gradient Estimators + +First, let us study the variance of the gradient estimators. + +Protocol. We generate a single random parameter setting and use it to generate a synthetic data set consisting of 10 examples of length 50. Then, we compute the gradient estimators using the whole data set 1000 times, which yields 1000 gradient estimates for each method. Finally, we compute the standard deviations of each element of the gradients, and report the mean of the standard deviations. + +Result. The mean standard deviation of $\partial \mathrm{SNN}$ was 66.3, whereas that of SNN was $2.49 \times 10^{3}$ . This clearly demonstrates that the variance of our estimator tends to be lower than that of the existing estimator. + +# 5.2. Predictive Performance + +The second experiment studies the predictive performance of the models learned by each of the methods compared. + +![](images/637a0204cd27703842d60a15c4ba24286206be306e88aa4a6c0a6cbe34439dd9.jpg) +Figure 3. Predictive performance of SNN and $\partial$ SNN. + +![](images/32ec41771fb7d7375e0d2682d047d0571c508d4f4d9db6f8a7bd45c7cc38b23c.jpg) +Figure 4. Per-epoch computation time of SNN and $\partial$ SNN. + +Protocol. We generate 24 random parameter settings, and consistently use them in this experiment. We aim to evaluate the performance gap between SNN and $\partial$ SNN in different sizes of training sets. To this end, we execute the following, varying the size as $N_{\mathrm{train}} = 10, 20, 30, 40, 50, 75, 100, 200,$ and for each parameter setting. + +We generate training/test sets consisting of $N_{\mathrm{train}} / 100$ examples of length 50 respectively. SNN and $\partial \mathrm{SNN}$ are trained on the training set using AdaGrad (Duchi et al., 2011) with initial learning rate 0.05 for 10 epochs. We evaluate the predictive performance by computing ELBO (Equation (9)) on the test set. For fair comparison, we evaluate the performance of $\partial \mathrm{SNN}$ by transferring its parameters to the vanilla $\mathrm{SNN}^5$ . By repeating this over 24 parameter settings, we obtain 24 ELBO scores. We report their mean as the performance of each method for each $N_{\mathrm{train}}$ . + +Result. Figure 3 summarizes the experimental results. It clearly shows that $\partial$ SNN consistently outperforms SNN especially in the small-sample regime, which supports the benefit of our low-variance estimator. + +# 5.3. Computational Overhead + +The last experiment studies computation overhead of $\partial$ SNN over SNN. The computation time depends on the number of spikes, and the number of (hidden) spikes is proportional to $a$ , the amplitude of the non-linearity $\sigma$ that maps the membrane potential into the conditional intensity function. In general, $\partial$ SNN generates more hidden spikes than SNN because the thinning algorithm for the differentiable point process does not reject any of the candidate spikes. Therefore, we expect that $\partial$ SNN requires more computation time than SNN. The purpose of this experiment is to measure the computational overhead of $\partial$ SNN over SNN. + +Protocol. We generate a single parameter setting, and gen + +erate a training set of 10 examples of length 50. We then set up both SNN and $\partial$ SNN with amplitude $a = 1,2,\ldots ,20$ , resulting in 40 models to be trained. For each model, we measure the computation time of running 100 epochs, and obtain per-epoch computation time by averaging them. + +Result. Figure 4 summarizes the experimental results. As is expected, $\partial$ SNN requires 2.8 times more computation time than SNN on average. This result can be used as a reference for users to decide which gradient estimator to be employed. If a user can afford this overhead, our path-wise gradient estimator is recommended; otherwise, please consider to use the score function gradient estimator. + +Note that we can improve the computation time of our method by introducing an adaptive upperbound $\bar{\lambda}$ in Algorithm 3, if it is a tighter upperbound than the fixed upperbound. We leave this improvement as future work. + +# 6. Related Work + +The present work is related to the communities of SNNs and point processes. Let us discuss our contributions to them. + +# 6.1. Spiking Neural Networks + +The most relevant work is the stochastic variational learning algorithm for SNNs (Jimenez Rezende & Gerstner, 2014). As discussed in Section 4.2.2, the difference is the gradient estimator. The authors used the score function gradient estimator, because the path-wise gradient estimator (which became popular by VAE (Kingma & Welling, 2014)) was not popular at that time and the reparameterization trick for point processes was not trivial. Our contribution is to develop a differentiable point process that enables us to derive the path-wise gradient estimator. + +Less relevant but still worth mentioning are the line of work in learning algorithms for deterministic SNNs, where a neuron fires when the membrane potential exceeds a threshold. Although our technique cannot directly contribute to them, + +we believe it is worthwhile to compare the pros and cons of these different approaches for further development. Of a number of approaches proposed so far (Neftci et al., 2019), we introduce two inspiring studies. + +SpikeProp (Bohte et al., 2000) is one of the earliest attempts to develop a learning algorithm for deterministic SNNs. SpikeProp uses backpropagation to minimize the difference between the target firing times $\{t_n^{\star}\}_{n = 1}^{N}$ and the actual firing times $\{t_n\}_{n = 1}^N$ of the network, i.e., $\sum_{n = 1}^{N}|t_n^{\star} - t_n|^2$ . The gradient is approximated by assuming a linear relationship between the firing time and the membrane potential, which is valid only for a small learning rate. + +Huh & Sejnowski (2018) propose a differentiable alternative to the threshold-based spike generation, which facilitates gradient computation. They employ a soft-threshold mechanism, and therefore, is differentiable without approximation. Another important contribution is that their model can handle not only spike trains but also a real-valued time-series. They use a readout network that maps spike trains from/into a real-valued time-series. This end-to-end formulation is significant towards practical applications of SNNs, and probabilistic SNNs should be equipped with this feature. + +One interesting feature of probabilistic SNNs including our method is that both inference and learning algorithms can be executed naturally in an event-based manner without any discretization of time axis. This is in contrast to deterministic SNNs, where many learning algorithms require us to discretize the continuous-time dynamics for simulation. + +# 6.2. Differentiable Point Processes + +Our differentiable point process is significant in the community of point processes in that it largely expands the applicability of the reparameterization trick for point processes. Let us review the approaches to differentiable point processes, and discuss their pros and cons. + +There are mainly three approaches to sample from point processes, and each of them can be used as a basis of differentiable point processes. The first approach (Shchur et al., 2020a) is to model the inter-event time conditioned on the past history by a log-normal mixture model, instead of modeling the conditional intensity function. Since it is straightforward to develop a reparameterizable sampling algorithm for the mixture model, the resultant point process is also reparameterizable. The second one is the inverse method (Rasmussen, 2018), which utilizes the fact that the inverse of the compensator $\Lambda^{[0,t]}$ can convert a unit-rate Poisson process into the point process with the corresponding conditional intensity function. Shchur et al. (2020b) propose a reparameterization trick based on the inverse method. The third one is the thinning algorithm, as we presented. + +Of these three approaches, it is interesting to compare the + +second and the third approaches. When applying the inverse method (Shchur et al., 2020b) to computing ELBO, it is reported that the objective function contains discontinuous points, making optimization difficult. The discontinuity arises because time stamps of a realization are parameterized, and the algorithm involves a discrete decision whether a time stamp is less than $T$ or not for termination. In contrast, Our differentiable point process does not suffer from it because not time stamps but marks are parameterized. In this sense, these two approaches are complementary. + +When developing a path-wise gradient estimator for SNNs, only the third approach is feasible. The first approach is difficult to be applied because SNNs are modeled via the conditional intensity function, and the inter-event time distribution is not available in a closed form. The second approach is also difficult due to the lack of a closed-form expression of the inverse of the compensator. Our approach only assumes the existence of an upperbound of the conditional intensity function, and therefore, can be applied to SNNs. The assumption on the existence of a constant upperbound can be relaxed in the same way as Ogata's method (Ogata, 1981), which determines $\bar{\lambda}$ adaptively. + +# 7. Conclusion and Future Work + +We develop a path-wise gradient estimator for SNNs based on a differentiable point process. Given the experimental results in Section 5, we conclude that our estimator has lower variance than the existing one, which contributes to improve the learning capability. + +Throughout this paper, we only focus on the dependency of the gradient estimator on learning capability, and we have not discussed about its practical applications. In the community of SNNs, however, an increasing number of studies have started to apply SNNs to real-world tasks (Shrestha & Orchard, 2018; Wozniak et al., 2020). One of the major concerns towards applying our method to real-world tasks is a method to convert real-valued data into/from spike trains. While there are a number of information encoding methods for spike trains, it is still an open problem which encoding is preferred. One interesting direction is to empirically and theoretically investigate the performance of different encoding methods and to understand their pros and cons. + +Another limitation is the computational overhead as discussed in Section 5.3. While the probabilistic formulation can be simulated by an event-based manner, the gradient computation involves backpropagation through time (BPTT), whose complexity increases proportionally to the number of spikes. In addition to relying on the adaptive upperbound $\bar{\lambda}$ , applying online BPTT calculation and its approximation techniques (Williams & Zipser, 1989) to SNNs may be an interesting research direction. + +# References + +Bohte, S. M., Kok, J. N., and Poutré, H. L. SpikeProp: Backpropagation for Networks of Spiking Neurons. In Proceedings of the 8th European Symposium on Artificial Neural Networks (ESANN 2000), pp. 419-424, 2000. +Bothe, S. M. The evidence for neural information processing with precise spike-times: A survey. Natural Computing, 2:195-206, 2004. +Daley, D. J. and Vere-Jones, D. An Introduction to the Theory of Point Processes: Volume I: Elementary Theory and Methods. Springer-Verlag New York, 2003. +Duchi, J., Hazan, E., and Singer, Y. Adaptive subgradient methods for online learning and stochastic optimization. Journal of Machine Learning Research, 12:2121-2159, 2011. ISSN 15324435. +Gerstner, W., Kistler, W. M., Naud, R., and Paninski, L. Neuronal Dynamics. Cambridge University Press, 2014. +Huh, D. and Sejnowski, T. J. Gradient Descent for Spiking Neural Networks. In Bengio, S., Wallach, H., Larochelle, H., Grauman, K., Cesa-Bianchi, N., and Garnett, R. (eds.), Advances in Neural Information Processing Systems 31, pp. 1433-1443. Curran Associates, Inc., 2018. +Jang, E., Gu, S., and Poole, B. Categorical Reparameterization with Gumbel-Softmax. In Proceedings of the Fifth International Conference on Learning Representations, 2017. +Jimenez Rezende, D. and Gerstner, W. Stochastic variational learning in recurrent spiking networks. Frontiers in Computational Neuroscience, 8:38, 2014. ISSN 1662-5188. doi: 10.3389/fncom.2014.00038. +Kajino, H. diffsnn, 2021. URL https://github.com/ ibm-research-tokyo/diffsnn. +Kingma, D. P. and Welling, M. Auto-encoding variational Bayes. In Proceedings of the Second International Conference on Learning Representations, 2014. +Lewis, P. A. W. and Shedler, G. S. Simulation of nonhomogeneous poisson processes by thinning. *Naval Research Logistics Quarterly*, 26(3):403-413, 1979. doi: 10.1002/nav.3800260304. +Mächler, M. Accurately computing $\log (1 - \exp (-|a|))$ assessed by the Rmpfr package. Technical report, 2012. +Maddison, C. J., Mnih, A., and Teh, Y. W. The Concrete Distribution: A Continuous Relaxation of Discrete Random Variables. In Proceedings of the Fifth International Conference on Learning Representations, 2017. + +Mohamed, S., Rosca, M., Figurnov, M., and Mnih, A. Monte Carlo Gradient Estimation in Machine Learning, 2019. +Neftci, E. O., Mostafa, H., and Zenke, F. Surrogate Gradient Learning in Spiking Neural Networks: Bringing the Power of Gradient-Based Optimization to Spiking Neural Networks. IEEE Signal Processing Magazine, 36 (6):51-63, 2019. doi: 10.1109/MSP.2019.2931595. +Ogata, Y. On Lewis' simulation method for point processes. IEEE Transactions on Information Theory, 27(1):23-31, jan 1981. ISSN 1557-9654. doi: 10.1109/TIT.1981.1056305. +Pfister, J.-P., Toyoizumi, T., Barber, D., and Gerstner, W. Optimal Spike-Timing-Dependent Plasticity for Precise Action Potential Firing in Supervised Learning. Neural Computation, 18(6):1318-1348, 2006. doi: 10.1162/neco.2006.18.6.1318. +Rasmussen, J. G. Lecture notes: Temporal point processes and the conditional intensity function. arXiv preprint arXiv:1806.00221, 2018. +Shchur, O., Bilosh, M., and Gunnemann, S. Intensity-free learning of temporal point processes. In International Conference on Learning Representations, 2020a. +Shchur, O., Gao, N., Biloš, M., and Gunnemann, S. Fast and Flexible Temporal Point Processes with Triangular Maps. In Larochelle, H., Ranzato, M., Hadsell, R., Balcan, M. F., and Lin, H. (eds.), Advances in Neural Information Processing Systems, volume 33, pp. 73-84. Curran Associates, Inc., 2020b. +Shrestha, S. B. and Orchard, G. SLAYER: Spike Layer Error Reassignment in Time. In Bengio, S., Wallach, H., Larochelle, H., Grauman, K., Cesa-Bianchi, N., and Garnett, R. (eds.), Advances in Neural Information Processing Systems, volume 31. Curran Associates, Inc., 2018. +Williams, R. J. Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine Learning, 8(3):229-256, 1992. ISSN 1573-0565. doi: 10.1007/BF00992696. +Williams, R. J. and Zipser, D. A Learning Algorithm for Continually Running Fully Recurrent Neural Networks. Neural Computation, 1(2):270-280, 1989. ISSN 0899-7667. doi: 10.1162/neco.1989.1.2.270. +Wozniak, S., Pantazi, A., Bohnstingl, T., and Eleftheriou, E. Deep learning incorporating biologically inspired neural dynamics and in-memory computing. Nature Machine Intelligence, 2(6):325-336, 2020. ISSN 2522-5839. doi: 10.1038/s42256-020-0187-0. \ No newline at end of file diff --git a/adifferentiablepointprocesswithitsapplicationtospikingneuralnetworks/images.zip b/adifferentiablepointprocesswithitsapplicationtospikingneuralnetworks/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..81c0fef25052f51a768fdf08fd8b30e4f9254d48 --- /dev/null +++ b/adifferentiablepointprocesswithitsapplicationtospikingneuralnetworks/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c3a5a03f4dad44f4983c89e54c188beceb9d6f1add459639bb12280313846f16 +size 199053 diff --git a/adifferentiablepointprocesswithitsapplicationtospikingneuralnetworks/layout.json b/adifferentiablepointprocesswithitsapplicationtospikingneuralnetworks/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..af1a0e3cf2c469987c5899f4bb3c68c05a365eea --- /dev/null +++ b/adifferentiablepointprocesswithitsapplicationtospikingneuralnetworks/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6641bb37e8bce47d622c716ae0edbe0fcc20cf5d6e98efd4d799324532d57a57 +size 614988 diff --git a/adiscriminativetechniqueformultiplesourceadaptation/ef18857d-2f2d-49bf-b209-4485163d10e4_content_list.json b/adiscriminativetechniqueformultiplesourceadaptation/ef18857d-2f2d-49bf-b209-4485163d10e4_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..40ac9b006c340710be3a4974c526f3f60e5b30a7 --- /dev/null +++ b/adiscriminativetechniqueformultiplesourceadaptation/ef18857d-2f2d-49bf-b209-4485163d10e4_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9f6adcc70514a216f28a1d4086b1744422cf24aa5045a2579888298f4f5a8970 +size 99129 diff --git a/adiscriminativetechniqueformultiplesourceadaptation/ef18857d-2f2d-49bf-b209-4485163d10e4_model.json b/adiscriminativetechniqueformultiplesourceadaptation/ef18857d-2f2d-49bf-b209-4485163d10e4_model.json new file mode 100644 index 0000000000000000000000000000000000000000..5aab7d0a836101934b3a1129f1df91e31f80f981 --- /dev/null +++ b/adiscriminativetechniqueformultiplesourceadaptation/ef18857d-2f2d-49bf-b209-4485163d10e4_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e80838ee45cdb7e1ec4891979f3bf5c6389bf97fc4ed9a14fc4eacca68fa3f91 +size 120682 diff --git a/adiscriminativetechniqueformultiplesourceadaptation/ef18857d-2f2d-49bf-b209-4485163d10e4_origin.pdf b/adiscriminativetechniqueformultiplesourceadaptation/ef18857d-2f2d-49bf-b209-4485163d10e4_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..aa251ba89ec4cc12a15ca0d541512bacd0621b3e --- /dev/null +++ b/adiscriminativetechniqueformultiplesourceadaptation/ef18857d-2f2d-49bf-b209-4485163d10e4_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cfbd0d9a1a2a45b66212871231e087b473a89e6c5423cab1ed3d9b00575dbb08 +size 3104063 diff --git a/adiscriminativetechniqueformultiplesourceadaptation/full.md b/adiscriminativetechniqueformultiplesourceadaptation/full.md new file mode 100644 index 0000000000000000000000000000000000000000..4232ac0c22c08ab32d0031f53f6521740812138f --- /dev/null +++ b/adiscriminativetechniqueformultiplesourceadaptation/full.md @@ -0,0 +1,428 @@ +Corinna Cortes1 Mehryar Mohri1,2 Ananda Theertha Suresh1 Ningshan Zhang3 + +# Abstract + +We present a new discriminative technique for the multiple-source adaptation (MSA) problem. Unlike previous work, which relies on density estimation for each source domain, our solution only requires conditional probabilities that can be straightforwardly accurately estimated from unlabeled data from the source domains. We give a detailed analysis of our new technique, including general guarantees based on Rényi divergences, and learning bounds when conditional Maxent is used for estimating conditional probabilities for a point to belong to a source domain. We show that these guarantees compare favorably to those that can be derived for the generative solution, using kernel density estimation. Our experiments with real-world applications further demonstrate that our new discriminative MSA algorithm outperforms the previous generative solution as well as other domain adaptation baselines. + +# 1. Introduction + +Learning algorithms are applied to an increasingly broad array of problems. For some tasks, large amounts of labeled data are available to train very accurate predictors. But, for most new problems or domains, no such supervised information is at the learner's disposal. Furthermore, labeling data is costly since it typically requires human inspection and agreements between multiple expert labelers. Can we leverage past predictors learned for various domains and combine them to devise an accurate one for a new task? Can we provide guarantees for such combined predictors? How should we define that combined predictor? These are some of the challenges of multiple-source domain adaptation. + +The problem of domain adaptation from multiple sources admits distinct instances defined by the type of source in + +. + +Proceedings of the $38^{th}$ International Conference on Machine Learning, PMLR 139, 2021. Copyright 2021 by the author(s). + +formation available to the learner, the number of source domains, and the amount of labeled and unlabeled data available from the target domain (Mansour et al., 2008; 2009a; Hoffman et al., 2018; Pan and Yang, 2010; Muandet et al., 2013; Xu et al., 2014; Hoffman et al., 2012; Gong et al., 2013a;b; Zhang et al., 2015; Ganin et al., 2016; Tzeng et al., 2015; Motiian et al., 2017b;a; Wang et al., 2019b; Konstantinov and Lampert, 2019; Liu et al., 2015; Saito et al., 2019; Wang et al., 2019a). The specific instance we are considering is one where the learner has access to multiple source domains and where, for each domain, they only have at their disposal a predictor trained for that domain and some amount of unlabeled data. No other information about the source domains, in particular no labeled data is available. The target domain or distribution is unknown but it is assumed to be in the convex hull of the source distributions, or relatively close to that. The multiple-source adaptation (MSA) problem consists of combining relatively accurate predictors available for each source domain to derive an accurate predictor for any such new mixture target domain. This problem was first theoretically studied by Mansour et al. (2008; 2009a) and subsequently by Hoffman et al. (2018; 2021), who further provided an efficient algorithm for this problem and reported the results of a series of experiments with that algorithm and favorable comparisons with alternative solutions. + +As pointed out by these authors, this problem arises in a variety of different contexts. In speech recognition, each domain may correspond to a different group of speakers and an acoustic model learned for each domain may be available. Here, the problem consists of devising a general recognizer for a broader population, a mixture of the source domains (Liao, 2013). Similarly, in object recognition, there may be accurate models trained on different image databases and the goal is to come up with an accurate predictor for a general domain, which is likely to be close to a mixture of these sources (Torralba and Efros, 2011). A similar situation often appears in sentiment analysis and various other natural language processing problems where accurate predictors are available for some source domains such as TVs, laptops and CD players, each previously trained on labeled data, but no labeled data or predictor is at hand for the broader category of electronics, which can be viewed as a mixture of the sub-domains (Blitzer et al., 2007; Dredze et al., 2008). + +An additional motivation for this setting of multiple-source adaptation is that often the learner does not have access to labeled data from various domains for legitimate reasons such as privacy or storage limitation. This may be for example labeled data from various hospitals, each obeying strict regulations and privacy rules. But, a predictor trained on the labeled data from each hospital may be available. Similarly, a speech recognition system trained on data from some group may be available but the many hours of source labeled data used to train that model may not be accessible anymore, due to the very large amount of disk space it requires. Thus, in many cases, the learner cannot simply merge all source labeled data to learn a predictor. + +Main contributions. In Section 3, we present a new discriminative technique for the MSA problem, Previous work showed that a distribution-weighted combination of source predictors benefited from favorable theoretical guarantees (Mansour et al., 2008; 2009a; Hoffman et al., 2018; 2021). However, that generative solution requires an accurate density estimation for each source domain, which, in general, is a difficult problem. Instead, our solution only needs conditional probabilities, which is easier to accurately estimate from unlabeled data from the source domains. We also describe an efficient DC-programming optimization algorithm for determining the solution of our discriminative technique, which is somewhat similar to but distinct from that of previous work, since it requires a new DC-decomposition. + +In Section 4, we give a new and detailed theoretical analysis of our technique, starting with new general guarantees that depend on the Rényi divergences between the target distribution and mixtures of the true source distributions, instead of mixtures of estimates of those distributions (Section 3). We then present finite sample learning bounds for our new discriminative solution when conditional Maxent is used for estimating conditional probabilities. We also give a new and careful analysis of the previous generative solution, when using kernel density estimation, including the first finite sample generalization bound for that technique. We show that the theoretical guarantees for our discriminative solution compare favorably to those derived for the generative solution in several ways. While we benefit from some of the analysis in previous work (Hoffman et al., 2018; 2021), our main proofs and techniques are new and non-trivial. + +We further report the results of several experiments with our discriminative algorithm both with a synthetic dataset and several real-world applications (Section 5). Our results demonstrate that, in all tasks, our new solution outperforms the previous work's generative solution, which had been shown itself to surpass empirically the accuracy of other domain adaptation baselines (Hoffman et al., 2018). They also indicate that our discriminative technique requires fewer samples to achieve a high accuracy than the previous solu + +tion, which matches our theoretical analysis. + +Related work. There is a very broad literature dealing with single-source and multiple-source adaptation with distinct scenarios. Here, we briefly discuss the most related previous work, in addition to (Mansour et al., 2008; 2009a; Hoffman et al., 2018), and defer a more extensive discussion to Appendix A. The idea of using a domain classifier to combine domain-specific predictors has been suggested in the past. Jacobs et al. (1991) and Nowlan and Hinton (1991) considered an adaptive mixture of experts model, where there are multiple expert networks, as well as a gating network to determine which expert to use for each input. The learning method consists of jointly training the individual expert networks and the gating network. In our scenario, no labeled data is available, expert networks are pre-trained separately from the gating network, and our gating network admits a specific structure. Hoffman et al. (2012) learned a domain classifier via SVM on all source data combined, and predicted on new test points with the weighted sum of domain classifier's scores and domain-specific predictors. Such linear combinations were later shown by Hoffman et al. (2018) to perform poorly in some cases and not to benefit from strong guarantees. More recently, Xu et al. (2018) deployed multi-way adversarial training to multiple source domains to obtain a domain discriminator, and also used a weighted sum of discriminator's scores and domain-specific predictors to make predictions. Zhao et al. (2018) considered a scenario where labeled samples are available, unlike our scenario, and learned a domain classifier to approximate the discrepancy term in a MSA generalization bound, and proposed the MDAN model to minimize the bound. + +We start with a description of the learning scenario we consider and the introduction of notation and definitions relevant to our analysis (Section 2). + +# 2. Learning Scenario + +We consider the MSA problem in the general stochastic scenario studied by Hoffman et al. (2018) and adopt the same notation. + +Let $\mathcal{X}$ denote the input space, $\mathcal{Y}$ the output space. We will identify a domain with a distribution over $\mathcal{X} \times \mathcal{Y}$ . There are $p$ source domains $\mathcal{D}_1, \ldots, \mathcal{D}_p$ . As in previous work, we adopt the assumption that the domains share a common conditional probability $\mathcal{D}(\cdot | x)$ and thus $\mathcal{D}_k(x, y) = \mathcal{D}_k(x) \mathcal{D}(y|x)$ , for all $(x, y) \in \mathcal{X} \times \mathcal{Y}$ and $k \in [p]$ . This is a natural assumption in many common machine learning tasks. For example, in image classification, the label of a picture as a dog may not depend much on whether the picture is from a personal collection or a more general dataset. Nevertheless, as discussed in Hoffman et al. (2018), this condition can be relaxed and, here too, all our results can + +be similarly extended to a more general case where the conditional probabilities vary across domains. Since not all $k$ conditional probabilities are equally accurate on the single $x$ , better target accuracy can be obtained by combining the $\mathcal{D}_k(x)$ s in an $x$ -dependent way. + +For each domain $\mathcal{D}_k$ , $k \in [p]$ , the learner has access to some unlabeled data drawn i.i.d. from the marginal distribution $\mathcal{D}_k$ over $\mathcal{X}$ , as well as to a predictor $h_k$ . We consider two types of predictor functions $h_k$ , and their associated loss functions $\ell$ under the regression model $(R)$ and the probability model $(P)$ respectively: + +$$ +h _ {k} \colon \mathcal {X} \rightarrow \mathbb {R} \quad \ell \colon \mathbb {R} \times \mathcal {Y} \rightarrow \mathbb {R} _ {+} \quad (R) +$$ + +$$ +h _ {k} \colon \mathcal {X} \times \mathcal {Y} \rightarrow [ 0, 1 ] \quad \ell \colon [ 0, 1 ] \rightarrow \mathbb {R} _ {+} \tag {P} +$$ + +In the probability model, the predictors are assumed to be normalized: $\sum_{y\in \mathcal{Y}}h(x,y) = 1$ for all $x\in \mathcal{X}$ . We will denote by $\mathcal{L}(\mathcal{D},h)$ the expected loss of a predictor $h$ with respect to the distribution $\mathcal{D}$ : + +$$ +\mathcal {L} (\mathcal {D}, h) = \underset {(x, y) \sim \mathcal {D}} {\mathbb {E}} \left[ \ell (h (x), y) \right] \quad (R), +$$ + +$$ +\mathcal {L} (\mathcal {D}, h) = \underset {(x, y) \sim \mathcal {D}} {\mathbb {E}} \left[ \ell (h (x, y)) \right] \quad (P). +$$ + +Our theoretical results are general and only assume that the loss function $\ell$ is convex, continuous. But, in the regression model, we will be particularly interested in the squared loss $\ell(h(x), y) = (h(x) - y)^2$ and, in the probability model, the cross-entropy loss (or log-loss) $\ell(h(x, y)) = -\log h(x, y)$ . We will also assume that each source predictor $h_k$ is $\epsilon$ -accurate on its domain for some $\epsilon > 0$ , that is, $\forall k \in [p], \mathcal{L}(\mathcal{D}_k, h_k) \leq \epsilon$ . Our assumption that the loss of $h_k$ is bounded, implies that $\ell(h_k(x), y) \leq M$ or $\ell(h_k(x, y)) \leq M$ , for all $(x, y) \in \mathcal{X} \times \mathcal{Y}$ and $k \in [p]$ . + +Let $\Delta = \{\lambda = (\lambda_1, \dots, \lambda_p) \colon \sum_{k=1}^p \lambda_k = 1, \lambda_k \geq 0\}$ denote the simplex in $\mathbb{R}^p$ , and let $\mathcal{D} = \{\mathcal{D}_\lambda \colon \mathcal{D}_\lambda = \sum_{k=1}^p \lambda_k \mathcal{D}_k, \lambda \in \Delta\}$ be the family of all mixtures of the source domains, that is the convex hull of $\mathcal{D}_k$ s. + +Since not all $k$ source predictors are necessarily equally accurate on the single input $x$ , better target accuracy can be obtained by combining the $h_k(x)$ s dependent on $x$ . The MSA problem for the learner is exactly how to combine these source predictors $h_k$ to design a predictor $h$ with small expected loss for any unknown target domain $\mathcal{D}_T$ that is an element of $\mathcal{D}$ , or any unknown distribution $\mathcal{D}_T$ close to $\mathcal{D}$ . + +Our theoretical guarantees are presented in terms of Rényi divergences, a broad family of divergences between distributions generalizing the relative entropy. The Rényi Divergence is parameterized by $\alpha \in [0, +\infty]$ and denoted by $\mathsf{D}_{\alpha}$ . The $\alpha$ -Rényi Divergence between two distributions $\mathcal{P}$ and $\Omega$ is defined by: + +$$ +\mathsf {D} _ {\alpha} (\mathcal {P} \parallel \mathcal {Q}) = \frac {1}{\alpha - 1} \log \bigg [ \sum_ {(x, y) \in \mathcal {X} \times \mathcal {Y}} \mathcal {P} (x, y) \left[ \frac {\mathcal {P} (x , y)}{\mathcal {Q} (x , y)} \right] ^ {\alpha - 1} \bigg ], +$$ + +where, for $\alpha \in \{0,1, + \infty \}$ , the expression is defined by taking the limit (Arndt, 2004). For $\alpha = 1$ , the Rényi divergence coincides with the relative entropy. We will denote by $d_{\alpha}(\mathcal{P}\parallel \mathcal{Q})$ the exponential of $D_{\alpha}(\mathcal{P}\parallel \mathcal{Q})$ : + +$$ +\mathsf {d} _ {\alpha} (\mathcal {P} \parallel \mathcal {Q}) = \left[ \sum_ {(x, y) \in \mathcal {X} \times \mathcal {Y}} \frac {\mathcal {P} ^ {\alpha} (x , y)}{\mathcal {Q} ^ {\alpha - 1} (x , y)} \right] ^ {\frac {1}{\alpha - 1}}. +$$ + +Appendix B provides more background on the definition and the main properties of Rényi divergences. + +In the following, to alleviate the notation, we abusively denote the marginal distribution of a distribution $\mathcal{D}_k$ defined over $\mathcal{X} \times \mathcal{Y}$ in the same way and rely on the arguments for disambiguation, e.g. $\mathcal{D}_k(x)$ vs. $\mathcal{D}_k(x,y)$ . + +# 3. Discriminative MSA solution + +In this section we present our new solution for the MSA problem and give an efficient algorithm for determining its parameter. But first we describe the previous solution. + +# 3.1. Previous Generative Technique + +In previous work, it was shown that, in general, standard convex combinations of source predictors can perform poorly (Mansour et al., 2008; 2009a; Hoffman et al., 2018): in some problems, even when the source predictors have zero loss, no convex combination can achieve a loss below some constant for a uniform mixture of the source distributions. Instead, a distribution-weighted solution was proposed to the MSA problem. That solution relies on density estimates $\widehat{\mathcal{D}}_k$ for the marginal distributions $x\mapsto \mathcal{D}_k(x)$ , which are obtained via techniques such as kernel density estimation, for each source domain $k\in [p]$ independently. + +Given such estimates, the solution is defined as follows in the regression and probability models, for all $(x,y)\in \mathcal{X}\times \mathcal{Y}$ .. + +$$ +\widehat {h} _ {z} (x) = \sum_ {k = 1} ^ {p} \frac {z _ {k} \widehat {\mathcal {D}} _ {k} (x)}{\sum_ {j = 1} ^ {p} z _ {j} \widehat {\mathcal {D}} _ {j} (x)} h _ {k} (x), \tag {1} +$$ + +$$ +\widehat {h} _ {z} (x, y) = \sum_ {k = 1} ^ {p} \frac {z _ {k} \widehat {\mathcal {D}} _ {k} (x)}{\sum_ {j = 1} ^ {p} z _ {j} \widehat {\mathcal {D}} _ {j} (x)} h _ {k} (x, y), \tag {2} +$$ + +with $z \in \Delta$ is a parameter determined via an optimization problem such that $h_z$ admits the same loss for all $\mathcal{D}_k$ . We are assuming here that the estimates verify $\widehat{\mathcal{D}}_k(x) > 0$ for all $x \in \mathcal{X}$ and therefore that the denominators are positive. Otherwise, a small positive number $\eta > 0$ can be added to the denominators of the solutions, as in previous work. We are adopting this assumption only to simplify the presentation. For the probability model, the joint estimates $\widehat{\mathcal{D}}_k(x,y)$ used in (Hoffman et al., 2018) can be equivalently replaced by marginal ones $\widehat{\mathcal{D}}_k(x)$ since all domain distributions share the same conditional probabilities. + +Since this previous work relies on density estimation, we will refer to it as a generative solution to the MSA problem, in short, GMSA. The technique benefits from the following general guarantee (Hoffman et al., 2018), where we extend the Rényi divergences to divergences between a distribution $\mathcal{D}$ and a set of distributions $\mathcal{D}$ and write $\mathrm{D}_{\alpha}(\mathcal{D} \parallel \mathcal{D}) = \min_{\mathcal{D} \in \mathcal{D}} \mathrm{D}_{\alpha}(\mathcal{D} \parallel \mathcal{D})$ . + +Theorem 1. For any $\delta > 0$ , there exists a $z \in \Delta$ such that the following inequality holds for any $\alpha > 1$ and arbitrary target distribution $\mathcal{D}_T$ : + +$$ +\mathcal {L} (\mathcal {D} _ {T}, \widehat {h} _ {z}) \leq \left[ (\widehat {\epsilon} + \delta) \mathsf {d} _ {\alpha} (\mathcal {D} _ {T} \| \widehat {\mathcal {D}}) \right] ^ {\frac {\alpha - 1}{\alpha}} M ^ {\frac {1}{\alpha}}, +$$ + +where $\widehat{\epsilon} = \max_{k\in [p]}\left[\epsilon \mathsf{d}_{\alpha}(\widehat{\mathcal{D}}_k\parallel \mathcal{D}_k)\right]^{\frac{\alpha - 1}{\alpha}}M^{\frac{1}{\alpha}}$ and $\widehat{\mathcal{D}} = \left\{\sum_{k = 1}^{p}\lambda_{k}\widehat{\mathcal{D}}_{k}\colon \lambda \in \Delta \right\}$ + +The bound depends on the quality of the density estimates via the Rényi divergence between $\widehat{\mathcal{D}}_k$ and $\mathcal{D}_k$ , for each $k \in [p]$ , and the closeness of the target distribution $\mathcal{D}_T$ to the mixture family $\widehat{\mathcal{D}}$ , a bound we elaborate on further in Appendix C.1 and express in terms of the closeness of the target distribution $\mathcal{D}_T$ to the true family $\mathcal{D}$ . For $\alpha = +\infty$ , for $\mathcal{D}_T$ close to $\widehat{\mathcal{D}}$ and accurate estimates of $\mathcal{D}_k$ , $\mathrm{d}_{\alpha}(\mathcal{D}_T \parallel \widehat{\mathcal{D}})$ and $\mathrm{d}_{\alpha}(\widehat{\mathcal{D}}_k \parallel \mathcal{D}_k)$ are close to one and the upper bound is as a result close to $\epsilon$ . That is, with good density estimates, the error of $h_z$ is no worse than that of the source predictors $h_k s$ . However, obtaining good density estimators is a difficult problem and in general requires large amounts of data. In the following section, we provide a new and less data-demanding solution based on conditional probabilities. + +# 3.2. New Discriminative Technique + +Let $\mathcal{D}$ denote the distribution over $\mathcal{X}$ defined by $\mathcal{D}(x) = \frac{1}{p}\sum_{k=1}^{p}\mathcal{D}_k(x)$ . We will assume and can enforce that $\mathcal{D}$ is the distribution according to which we can expect to receive unlabeled samples from the $p$ sources to train our discriminator. We will denote by $\mathcal{Q}$ the distribution over $\mathcal{X} \times [p]$ defined by $\mathcal{Q}(x,k) = \frac{1}{p}\mathcal{D}_k(x)$ , whose $\mathcal{X}$ -marginal coincides with $\mathcal{D}$ : $\mathcal{Q}(x) = \mathcal{D}(x)$ . + +Our new solution relies on estimates $\widehat{\mathcal{Q}}(k|x)$ of the conditional probabilities $\mathcal{Q}(k|x)$ for each domain $k \in [p]$ , that is the probability that point $x$ belongs to source $k$ . Given such estimates, our new solution to the MSA problem is defined as follows in the regression and probability models, for all $(x,y) \in \mathcal{X} \times \mathcal{Y}$ : + +$$ +\widehat {g} _ {z} (x) = \sum_ {k = 1} ^ {p} \frac {z _ {k} \widehat {\mathcal {Q}} (k | x)}{\sum_ {j = 1} ^ {p} z _ {j} \widehat {\mathcal {Q}} (j | x)} h _ {k} (x), \tag {3} +$$ + +$$ +\widehat {g} _ {z} (x, y) = \sum_ {k = 1} ^ {p} \frac {z _ {k} \widehat {\mathbb {Q}} (k | x)}{\sum_ {j = 1} ^ {p} z _ {j} \widehat {\mathbb {Q}} (j | x)} h _ {k} (x, y), \tag {4} +$$ + +with $z \in \Delta$ being a parameter determined via an optimization problem. As for the GMSA solution, we are assuming here that the estimates verify $\widehat{\mathcal{Q}}(k|x) > 0$ for all $x \in \mathcal{X}$ and therefore that the denominators are positive. Otherwise, a small positive number $\eta > 0$ can be added to the denominators of the solutions, as in previous work. We are adopting this assumption only to simplify the presentation. Note that in the probability model, $\widehat{g}_z(x,y)$ is normalized since $h_k s$ are normalized: $\sum_{y \in \mathcal{Y}} g_z(x,y) = 1$ for all $x \in \mathcal{X}$ . + +Since our solution relies on estimates of conditional probabilities of domain membership, we will refer to it as a discriminative solution to the MSA problem, DMSA in short. + +Observe that, by the Bayes' formula, the conditional probability estimates $\widehat{\mathcal{Q}}(k|x)$ induce density estimates $\widehat{\mathcal{D}}_k(x)$ of the marginal distributions $x \mapsto \mathcal{D}_k(x)$ : + +$$ +\widehat {\mathcal {D}} _ {k} (x) = \frac {\widehat {\mathcal {Q}} (k | x) \mathcal {D} (x)}{\widehat {\mathcal {Q}} (k)} \tag {5} +$$ + +where $\widehat{\mathcal{Q}}(k) = \sum_{x \in \mathcal{X}} \widehat{\mathcal{Q}}(k|x)\mathcal{D}(x)$ . For an exact estimate, that is $\widehat{\mathcal{Q}}(k|x) = \mathcal{Q}(k|x)$ , the formula holds with $\widehat{\mathcal{Q}}(k) = \sum_{x \in \mathcal{X}} \mathcal{Q}(x,k) = \frac{1}{p}$ . In light of this observation, we can establish the following connection between the GMSA and DMSA solutions. + +Proposition 1. Let $\widehat{h}_z$ be the GMSA solution using the estimates $\widehat{\mathcal{D}}_k$ defined in (5). Then, for any $z\in \Delta$ , we have $\widehat{h}_z = \widehat{g}_{z'}$ with $z_k' = \frac{z_k / \widehat{\Omega}(k)}{\sum_{j = 1}^p z_j / \widehat{\Omega}(j)}$ , for all $k\in [p]$ . + +Proof. First consider the regression model. By definition of the GMSA solution, we can write: + +$$ +\begin{array}{l} \widehat {h} _ {z} (x) = \sum_ {k = 1} ^ {p} \frac {z _ {k} \frac {\widehat {\mathcal {Q}} (k | x) \mathcal {D} (x)}{\widehat {\mathcal {Q}} (k)}}{\sum_ {j = 1} ^ {p} z _ {j} \frac {\widehat {\mathcal {Q}} (j | x) \mathcal {D} (x)}{\widehat {\mathcal {Q}} (j)}} h _ {k} (x) \\ = \sum_ {k = 1} ^ {p} \frac {\frac {z _ {k}}{\widehat {\mathcal {Q}} (k)} \widehat {\mathcal {Q}} (k | x)}{\sum_ {j = 1} ^ {p} \frac {z _ {j}}{\widehat {\mathcal {Q}} (j)} \widehat {\mathcal {Q}} (j | x)} h _ {k} (x) = g _ {z ^ {\prime}} (x). \\ \end{array} +$$ + +The probability model's proof is syntactically the same. + +In view of this result, the DMSA technique benefits from a guarantee similar to GMSA (Theorem 1), where for DMSA the density estimates are based on the conditional probability estimates $\widehat{\mathcal{Q}}(k|x)$ . + +Theorem 2. For any $\delta >0$ , there exists a $z\in \Delta$ such that the following inequality holds for any $\alpha >1$ and arbitrary target distribution $\mathcal{D}_T$ : + +$$ +\mathcal {L} \left(\mathcal {D} _ {T}, \widehat {g} _ {z}\right) \leq \left[ (\widehat {\epsilon} + \delta) \mathrm {d} _ {\alpha} \left(\mathcal {D} _ {T} \| \widehat {\mathcal {D}}\right) \right] ^ {\frac {\alpha - 1}{\alpha}} M ^ {\frac {1}{\alpha}}, +$$ + +where $\widehat{\epsilon} = \max_{k\in [p]}\left[\epsilon \mathrm{d}_{\alpha}(\widehat{\mathcal{D}}_k\parallel \mathcal{D}_k)\right]^{\frac{\alpha - 1}{\alpha}}M^{\frac{1}{\alpha}}$ and $\widehat{\mathcal{D}} = \left\{\sum_{k = 1}^{p}\lambda_{k}\widehat{\mathcal{D}}_{k}\colon \lambda \in \Delta \right\}$ with $\widehat{\mathcal{D}}_k(x,y) = \frac{\widehat{\mathcal{Q}}(k|x)\mathcal{D}(x,y)}{\widehat{\mathcal{Q}}(k)}.$ + +# 3.3. Optimization Algorithm + +By Proposition 1, to determine the parameter $z'$ guaranteeing the bound of Theorem 2 for $\widehat{g}_{z'}$ , it suffices to determine the parameter $z$ that yields the guarantee of Theorem 1 for $\widehat{h}_z$ , when using the estimates $\widehat{\mathcal{D}}_k = \frac{\widehat{\mathcal{Q}}(k|x)\mathcal{D}(x)}{\widehat{\mathcal{Q}}(k)}$ . As shown by (Hoffman et al., 2018), the parameter $z$ is the one for which $\widehat{h}_z$ admits the same loss for all source domains, that is $\mathcal{L}(\widehat{\mathcal{D}}_k,\widehat{h}_z) = \mathcal{L}(\widehat{\mathcal{D}}_{k'},\widehat{h}_z)$ for all $k,k^{\prime}\in [p]$ , where $\widehat{\mathcal{D}}_k$ is the joint distribution derived from $\widehat{\mathcal{D}}_k$ : $\widehat{\mathcal{D}}_k(x,y) = \widehat{\mathcal{D}}_k(x)\mathcal{D}(y|x) = \frac{\widehat{\mathcal{Q}}(k|x)\mathcal{D}(x,y)}{\widehat{\mathcal{Q}}(k)}$ , with $\mathcal{D}(x,y) = \frac{1}{p}\sum_{k = 1}^{p}\mathcal{D}_k(x,y)$ . Note, $\widehat{\mathcal{D}}(x,y)$ is abusively denoted the same way as $\widehat{\mathcal{D}}(x)$ to avoid the introduction of additional notation, but the difference in arguments should suffice to help distinguish the two distributions. + +Thus, using $\widehat{g}_{z'} = \widehat{h}_z$ , to find $z$ , and subsequently $z'$ , it suffices to solve the following optimization problem in $z$ : + +$$ +\min _ {z \in \Delta} \max _ {k \in [ p ]} \quad \mathcal {L} \left(\widehat {\mathcal {D}} _ {k}, \widehat {g} _ {z ^ {\prime}}\right) - \mathcal {L} \left(\widehat {\mathcal {D}} _ {z}, \widehat {g} _ {z ^ {\prime}}\right), \tag {6} +$$ + +where $z_{k}^{\prime} = \frac{z_{k} / \widehat{\mathcal{Q}}(k)}{\sum_{j=1}^{p} z_{j} / \widehat{\mathcal{Q}}(j)}$ and $\widehat{\mathcal{D}}_{z} = \sum_{k=1}^{p} z_{k} \widehat{\mathcal{D}}_{k}$ . As in previous work, this problem can be cast as a DC-programming (difference-of-convex) problem and solved using the DC algorithm (Tao and An, 1997; 1998; Sriperumbudur and Lanckriet, 2012). However, we need to derive a new DC-decomposition here, both for the regression and the probability model, since the objective is distinct from that of previous work. A detailed description of that DC-decomposition and its proofs, as well as other details of the algorithm are given in Appendix D. + +# 4. Learning Guarantees + +In this section, we prove favorable learning guarantees for the predictor $\widehat{g}_z$ returned by DMSA, when using conditional maximum entropy to derive domain estimates $\mathcal{Q}(k|x)$ . We first extend Theorem 1 and present a general theoretical guarantee which holds for DMSA and GMSA (Section 4.1). Next, in Section 4.2, we give a generalization bound for conditional Maxent and use that to prove learning guarantees for DMSA. We then analyze GMSA using kernel density estimation (Section 4.3), and show that DMSA benefits from significantly more favorable learning guarantees than GMSA. + +# 4.1. General Guarantee + +Theorem 1 gives a guarantee in terms of the Rényi divergence of $\mathcal{D}_T$ and $\widehat{\mathcal{D}}$ , which depends on the empirical estimates. Instead, we derive a bound in terms of the Rényi divergence of $\mathcal{D}_T$ and $\mathcal{D}$ and, as with Theorem 1, the Rényi divergences between the distributions $\mathcal{D}_k$ and their estimates $\widehat{\mathcal{D}}_k$ . + +To do so, we use an inequality that can be viewed as a triangle inequality result for Rényi divergences (Hoffman et al., 2021). + +Proposition 2. Let $\mathbb{P},\mathbb{Q},\mathbb{R}$ be three distributions on $\mathcal{X}\times \mathcal{Y}$ . Then, for any $\gamma \in (0,1)$ and any $\alpha >\gamma$ , the following inequality holds: + +$$ +\left[ \mathsf {d} _ {\alpha} (\mathcal {P} \parallel \mathcal {Q}) \right] ^ {\alpha - 1} \leq \left[ \mathsf {d} _ {\frac {\alpha}{\gamma}} (\mathcal {P} \parallel \mathcal {R}) \right] ^ {\alpha - \gamma} \left[ \mathsf {d} _ {\frac {\alpha - \gamma}{1 - \gamma}} (\mathcal {R} \parallel \mathcal {Q}) \right] ^ {\alpha - 1}. +$$ + +The proof is given in Appendix B. This result is used in combination with Theorem 1 to establish the following. + +Theorem 3. For any $\delta >0$ , there exists $z\in \Delta$ such that the following inequality holds for any $\alpha >1$ and arbitrary target distribution $\mathcal{D}_T$ : + +$$ +\mathcal {L} (\mathcal {D} _ {T}, \widehat {g} _ {z}) \leq \left[ \left(\widehat {\epsilon} + \delta\right) \widehat {\mathsf {d}} ^ {\prime} \right] ^ {\frac {\alpha - 1}{\alpha}} \left[ \mathsf {d} _ {2 \alpha} (\mathcal {D} _ {T} \| \mathcal {D}) \right] ^ {\frac {2 \alpha - 1}{2 \alpha}} M ^ {\frac {1}{\alpha}}, +$$ + +where $\widehat{\epsilon} = (\epsilon \widehat{\mathsf{d}})^{\frac{\alpha - 1}{\alpha}}M^{\frac{1}{\alpha}}$ $\widehat{\mathsf{d}} = \max_{k\in [p]}\mathsf{d}_{\alpha}(\widehat{\mathcal{D}}_k\parallel \mathcal{D}_k)$ , and $\widehat{\mathsf{d}}^{\prime} = \max_{k\in [p]}\mathsf{d}_{2\alpha -1}(\mathcal{D}_k\parallel \widehat{\mathcal{D}}_k)$ with $\widehat{\mathcal{D}}_k = \frac{\widehat{\Omega}(k|x)\mathcal{D}(x)}{\widehat{\Omega}(k)}$ + +The proof is given in Appendix C.1. The theorem holds similarly for GMSA with $\widehat{\mathcal{D}}_k$ a direct estimate of $\mathcal{D}_k$ (Theorem 9, Appendix E.2). This provides a strong performance guarantee for GMSA or DMSA when the target distribution $\mathcal{D}_T$ is close to the family of mixtures of the source distributions $\mathcal{D}_k$ , and when $\widehat{\mathcal{D}}_k$ is a good estimate of $\mathcal{D}_k$ . + +# 4.2. Conditional Maxent + +The distribution $\mathcal{D} = \frac{1}{p}\sum_{k=1}^{p}\mathcal{D}_k$ over $\mathcal{X} \times \mathcal{Y}$ naturally induces the distribution $\Omega$ over $\mathcal{X} \times [p]$ defined for all $(x, k)$ by $\Omega(x, k) = \frac{1}{p}D_k(x)$ . Let $S = ((x_1, k_1), \ldots, (x_m, k_m))$ be a sample of $m$ labeled points drawn i.i.d. from $\Omega$ . + +Let $\Phi \colon \mathcal{X} \times [p] \to \mathbb{R}^N$ be a feature mapping with bounded norm, $\| \Phi \| \leq r$ , for some $r > 0$ . Then, the optimization problem defining the solution of conditional Maxent (or multinomial logistic regression) with the feature mapping $\Phi$ is given by + +$$ +\min _ {w \in \mathbb {R} ^ {N}} \mu \| w \| ^ {2} - \frac {1}{m} \sum_ {i = 1} ^ {m} \log \mathrm {p} _ {w} [ k _ {i} | x _ {i} ], \tag {7} +$$ + +where $\mathsf{p}_w$ is defined by $\mathsf{p}_w[k|x] = \frac{1}{Z(x)}\exp (w\cdot \Phi (x,k))$ with $Z(x) = \sum_{k\in [p]}\exp (w\cdot \Phi (x,k))$ , and where $\mu \geq 0$ is a regularization parameter. Then, conditional Maxent benefits from the following theoretical guarantee. + +Theorem 4. Let $\widehat{w}$ be the solution of problem (7) and $w^{*}$ the population solution of the conditional Maxent optimization problem: + +$$ +w ^ {*} = \operatorname * {a r g m i n} _ {w \in \mathbb {R} ^ {N}} \mu \| w \| ^ {2} - \underset {(x, k) \sim \Omega} {\mathbb {E}} \left[ \log \mathsf {p} _ {w} [ k | x ] \right]. +$$ + +Then, for any $\delta > 0$ , with probability at least $1 - \delta$ , for any $(x,k) \in \mathcal{X} \times [p]$ , the following inequality holds: + +$$ +\left| \log \mathsf {p} _ {\widehat {w}} [ k | x ] - \log \mathsf {p} _ {w ^ {*}} [ k | x ] \right| \leq \frac {2 \sqrt {2} r ^ {2}}{\mu \sqrt {m}} \left[ 1 + \sqrt {\log (1 / \delta)} \right]. +$$ + +The theorem shows that the pointwise log-loss of the conditional Maxent solution $\mathsf{p}_{\widehat{w}}$ is close to that of the best-in-class $\mathsf{p}_{w^*}$ modulo a term in $O(1 / \sqrt{m})$ that does not depend on the dimension of the feature space. The proof is given in Appendix C.2. + +# 4.3. Comparison of the Guarantees for DMSA and GMSA + +We now use Theorem 3 and the bound of Theorem 4 to give a theoretical guarantee for DMSA used with conditional Maxent. We show that it is more favorable than a guarantee for GMSA using kernel density estimation. + +Theorem 5 (DMSA). There exists $z \in \Delta$ such that for any $\delta > 0$ , with probability at least $1 - \delta$ the following inequality holds DMSA used with conditional Maxent, for an arbitrary target mixture $\mathcal{D}_T$ : + +$$ +\mathcal {L} (\mathcal {D} _ {T}, \widehat {g} _ {z}) \leq \epsilon p e ^ {\frac {6 \sqrt {2} r ^ {2}}{\mu \sqrt {m}} \left[ 1 + \sqrt {\log (1 / \delta)} \right]} \mathsf {d} ^ {*} \mathsf {d} ^ {\prime *}, +$$ + +$$ +w i t h \quad \mathrm {d} ^ {*} = \sup _ {x \in \mathcal {X}} \mathrm {d} _ {\infty} \left(\mathcal {Q} ^ {*} [ \cdot | x ] \| \mathcal {Q} (\cdot | x)\right) +$$ + +$$ +\mathsf {d} ^ {\prime *} = \sup _ {x \in \mathcal {X}} \mathsf {d} _ {\infty} ^ {2} \left(\mathcal {Q} (\cdot | x) \| \mathcal {Q} ^ {*} [ \cdot | x ]\right), +$$ + +where $\mathcal{Q}^*(\cdot | x) = \mathfrak{p}_{w^*}[\cdot | x]$ is the population solution of conditional Maxent problem (statement of Theorem 4). + +The proof is given in Appendix C.3. It is based on a new and careful analysis of the Rényi divergences, leveraging the guarantee of Theorem 4. More refined versions of these results with alternative Rényi divergence parameters and with expectations instead of suprema in the definitions of $\mathrm{d}^*$ and $\mathrm{d}'^*$ are presented in that same appendix. The theorem shows that the expected error of DMSA with conditional Maxent is close to $\epsilon$ modulo a factor that varies as $e^{1/\sqrt{m}}$ , where $m$ is the size of the total unlabeled sample received from all $p$ sources, and factors $\mathcal{Q}^*$ and $\mathcal{Q}'^*$ that measure how closely conditional Maxent can approximate the true conditional probabilities with infinite samples. + +Next, we prove learning guarantees for GMSA with densities estimated via kernel density estimation (KDE). We assume that the same i.i.d. sample $S = ((x_{1},k_{1}),\ldots ,(x_{m},k_{m}))$ as with conditional Maxent is used. Here, the points labeled with $k$ are used for estimating $\mathcal{D}_k$ via KDE. Since the sample is drawn from $\mathcal{Q}$ with $\mathcal{Q}(x,k) = \frac{1}{p}\mathcal{D}_k$ , the number of samples points $m_{k}$ labeled with $k$ is very close to $\frac{m}{p}$ . $\widehat{\mathcal{D}}_k$ is learned from $m_{k}$ samples, via KDE with a normalized kernel function $K_{\sigma}(\cdot ,\cdot)$ that satisfies $\int_{x\in \mathcal{X}}K_{\sigma}(x,x^{\prime})dx = 1$ for all $x^{\prime}\in \mathcal{X}$ . + +Theorem 6 (GMSA). There exists $z \in \Delta$ such that, for any $\delta > 0$ , with probability at least $1 - \delta$ the following inequality holds for GMSA used KDE, for an arbitrary target mixture $\mathcal{D}_T$ : + +$$ +\mathcal {L} (\mathcal {D} _ {T}, \widehat {h} _ {z}) \leq \epsilon^ {\frac {1}{4}} M ^ {\frac {3}{4}} e ^ {\frac {6 \kappa}{\sqrt {2 (m / p)}} \sqrt {\log p + \log (1 / \delta)}} \mathsf {d} ^ {*} \mathsf {d} ^ {\prime *}, +$$ + +with $\kappa = \max_{x,x^{\prime},x^{\prime \prime}\in \mathfrak{X}}\frac{K_{\sigma}(x,x^{\prime})}{K_{\sigma}(x,x^{\prime\prime})}$ , and + +$$ +\mathsf{d}^{*} = \max_{k\in [p]} \mathbb{E}_{x\sim \mathcal{D}_{k}}\left[\mathsf{d}_{+\infty}\big(K_{\sigma}(\cdot ,x)\parallel \mathcal{D}_{k}\big)\right], +$$ + +$$ +\mathsf{d}^{\prime *} = \max_{k\in [p]} \mathbb{E}_{x\sim \mathcal{D}_{k}}\left[\mathsf{d}_{+\infty}\big(\mathcal{D}_{k}\parallel K_{\sigma}(\cdot ,x)\big)\right]. +$$ + +The proof is given in Appendix E.2. More refined versions of these results with alternative Rényi divergences are presented in that same appendix. In comparison with the guarantee for DMSA, the bound for GMSA admits a worse dependency on $\epsilon$ . Furthermore, while the dependency of the learning bound of DMSA on the sample size is of the form $O(e^{1/\sqrt{m}})$ and thus decreases as a function of the full sample size $m$ , that of GMSA is of the form $O(e^{1/\sqrt{m/p}})$ and only decreases as a function of the per-domain sample size. This further reflects the benefit of our discriminative solution since the estimation of the conditional probabilities is based on conditional Maxent trained on the full sample. Finally, the bound of GMSA depends on $\kappa$ , a ratio that can be unbounded for Gaussian kernels commonly used for KDE. + +The generalization guarantees for DMSA (Theorem 7) depends on two critical terms that measure the divergence between the population solution of conditional Maxent and the true domain classifier $\mathcal{Q}(\cdot |x)$ : + +$$ +\mathsf {d} _ {+ \infty} \left(\mathcal {Q} ^ {*} (\cdot | x) \| \mathcal {Q} (\cdot | x)\right) \quad \text {a n d} \quad \mathsf {d} _ {+ \infty} \left(\mathcal {Q} (\cdot | x) \| \mathcal {Q} ^ {*} (\cdot | x)\right). +$$ + +When the feature mapping for conditional Maxent is sufficiently rich, for example when it is the reproducing kernel Hilbert space (RKHS) associated to a Gaussian kernel, one can expect the two divergences to be close to one. The generalization guarantees for GMSA (Theorem 10) also depend on two divergence terms: + +$$ +\mathsf {d} _ {+ \infty} \big (K _ {\sigma} (\cdot , x) \| \mathcal {D} _ {k} \big) \quad \text {a n d} \quad \mathsf {d} _ {+ \infty} \big (\mathcal {D} _ {k} \| K _ {\sigma} (\cdot , x) \big). +$$ + +Compared to learning a domain classifier $\widehat{\mathcal{Q}} (\cdot |x)$ , it is more difficult to choose a good density kernel $K_{\sigma}(\cdot ,\cdot)$ to ensure that the divergence between marginal distributions is small, which shows another benefit of DMSA. + +The next section further illustrates the more advantageous sample complexity of the DMSA algorithm and shows that, in addition to the theoretical advantages discussed in this section, it also benefits from more favorable empirical results. + +Table 1. MSE on the sentiment analysis dataset. Single source baselines, K, D, B, E, the uniform combination unif, GMSA, and DMSA. + +
Sentiment Analysis Test Data
KDBEKDBEDBEKBEKDBKDBKDBE
K1.42±0.102.20±0.152.35±0.161.67±0.121.81±0.072.01±0.102.07±0.081.81±0.061.76±0.061.99±0.061.91±0.05
D2.09±0.081.77±0.082.13±0.102.10±0.081.93±0.072.11±0.072.00±0.062.11±0.061.99±0.062.00±0.062.02±0.05
B2.16±0.131.98±0.101.71±0.122.21±0.072.07±0.111.96±0.071.97±0.062.03±0.062.12±0.071.95±0.082.02±0.06
E1.65±0.092.35±0.112.45±0.141.50±0.072.00±0.091.97±0.092.10±0.081.86±0.051.83±0.072.15±0.071.99±0.06
unif1.50±0.061.75±0.091.79±0.101.53±0.071.63±0.061.66±0.081.69±0.061.61±0.051.60±0.051.68±0.051.65±0.05
GMSA1.42±0.101.88±0.111.80±0.101.51±0.071.65±0.081.66±0.071.73±0.051.58±0.041.60±0.051.70±0.041.65±0.04
DMSA (ours)1.42±0.081.76±0.071.70±0.111.46±0.071.59±0.061.58±0.071.64±0.051.53±0.041.55±0.041.63±0.041.59±0.04
+ +# 5. Experiments + +We experimented with our DMSA technique on the same datasets as those used in (Hoffman et al., 2018), as well as with the UCI adult dataset, and compared its performance with several baselines, including GMSA. Since Hoffman et al. (2018) already showed that GMSA empirically outperforms alternative MSA solutions, in this section, we mainly focus on demonstrating improvements over GMSA under the same experimental setups. + +Sentiment analysis. To evaluate the DMSA solution under the regression model, we used the sentiment analysis dataset (Blitzer et al., 2007), which consists of product review text and rating labels taken from four domains: books (B),DVD (D), electronics (E), and kitchen (K), with 2,000 samples for each domain. We adopted the same training procedure and hyper-parameters as those used by Hoffman et al. (2018) to obtain base predictors: first define a vocabulary of 2,500 words that occur at least twice in each of the four domains, then use this vocabulary to define word-count feature vectors for every review text, and finally train base predictors for each domain using support vector regression. We used the same word-count features to train the domain classifier via logistic regression. We randomly split the 2,000 samples per domain into 1,600 train and 400 test samples for each domain, and learn the base predictors, domain classifier, density estimations, and parameter $z$ for both MSA solutions on all available training samples. We repeated the process 10 times, and report the mean and standard deviation of the mean squared error on various target test mixtures in Table 1. + +We compared our technique, DMSA, against each source predictor, $h_k$ , the uniform combination of the source predictors (unif), $\frac{1}{p} \sum_{k=1}^{p} h_k$ , and GMSA with kernel density estimation. Each column in Table 1 corresponds to a different target test mixture, as indicated by the column name: four single domains, and uniform mixtures of two, three, and four domains, respectively. Our distribution-weighted method DMSA outperforms all baseline predictors across almost all test domains. Observe that, even when the target is a single source domain, such as K, B, E, our method can still outperform the predictor which is trained and tested on the same domain, showing the benefits of ensembles. + +Moreover, DMSA improves upon GMSA by a wide margin on all test mixtures, which demonstrates the advantage of using a domain classifier over estimated densities in the distribution-weighted combination. + +Digit dataset. To evaluate the DMSA solution under the probability model, we considered a digit recognition task consisting of three datasets: Google Street View House Numbers (SVHN), MNIST, and USPS. For each individual domain, we trained a convolutional neural network (CNN) with the same setup as in (Hoffman et al., 2018), and used the output from the softmax score layer as our base predictors $h_k$ . Furthermore, for every input image, we extracted the last layer before softmax from each of the base networks and concatenated them to obtain the feature vector for training the domain classifier. We used the full training sets per domain to train the source model, and used 6,000 samples per domain to learn the domain classifier. Finally, for our DC-programming algorithm, we used a 1,000 image-label pairs from each domain, thus a total of 3,000 labeled pairs to learn the parameter $z$ . + +We compared our DMSA algorithm against each source predictor $(h_k)$ , the uniform combination, unif, a network jointly trained on all source data combined, joint, and GMSA with kernel density estimation. Since the training and testing datasets are fixed, we simply report the numbers from the original GMSA paper. We measured the performance of these baselines on each of the three test datasets, on combinations of two test datasets, and on all test datasets combined. The results are reported in Table 2. Once again, DMSA outperforms all baselines on all test mixtures, and when the target is a single test domain, DMSA admits a comparable performance to the predictor that is trained and tested on the same domain. And, as in the sentiment analysis experiments, DMSA outperforms GMSA by a wide margin on most of the test domains. For example, on SVHN test data, the improvement is $0.9\%$ , which is larger than $0.5\%$ , the standard deviation estimate on the test data. + +We also report empirical results for the adversarial domain adaptation method of Zhao et al. (2018) in Table 2. Let us emphasize that the learning scenario for this algorithm does not match ours: this algorithm makes use of labeled data from source domains, as well as unlabeled data from a fixed + +![](images/50164c0b8de0fbe2b57a915df8943f19745883a188ffba9851a1a1d147553fe3.jpg) +Figure 1. Left: Illustration of the true densities and kernel density estimates for GMSA for domains $\mathcal{D}_1$ and $\mathcal{D}_2$ with 1000 samples. The labeling function $f(x) = -1$ in the green regions and 1 otherwise. Right: Same estimates zoomed in at $x = 0$ . + +![](images/f944dda96fe46dd3cf22569861cf6478f31947d189d8471f124c4619549b7850.jpg) + +Table 2. Digit Dataset Accuracy. DMSA outperforms each single-source domain model, unif, joint, and most importantly GMSA, on various target mixtures. + +
Digits Test Data
svhnmnistuspsmususmsmumean
CNN-s92.366.965.666.790.485.284.278.8
CNN-m15.799.279.796.020.338.941.055.8
CNN-u16.762.396.668.122.529.432.946.9
CNN-unif75.791.392.291.476.980.080.784.0
CNN-joint90.999.196.098.691.393.293.394.6
adv-mu91.598.595.798.191.893.593.694.7
adv-su91.698.595.798.091.993.593.694.7
adv-sm91.898.395.397.892.193.693.794.7
GMSA91.498.895.698.391.793.593.694.7
DMSA (ours)92.399.296.698.892.694.294.395.4
+ +target domain. In other words, the algorithm makes use of more information than what is available in our scenario or accessible to DMSA. Nevertheless, we are including these results for reference. + +For a target domain formed by the union of two out of the three domains svhn, mnist, or usps, that is a target domain defined as sm, su, or mu, we trained adv-target-domain, where we used unlabeled data from the target domain and labeled examples from all the three source domains smu. For these experiments, we used the entire training data from source domains and the entire unlabeled training data from target domains. We used the neural architecture and the discriminator used by Zhao et al. (2018). The results show that, while the adv-target-domain algorithm (Zhao et al., 2018) is making use of more information, its performance is inferior to that of GMSA and DMSA, even for the specific target distribution it is trained for and that it has therefore extra information about. + +In Tables 5 and 6 in Appendix F, we report additional experimental results with the digits dataset for the scenario where the target domain is close to being a mixture of the source domains but where it may not necessarily be such a mixture, a scenario not covered by Hoffman et al. (2018). These experiments also demonstrate a consistently strong performance of DMSA. + +To illustrate the efficiency of DMSA we further tested DMSA + +![](images/68dcda6631d747dfba1d6c28bd0408d9ccb21b97b4f8d11353294a65f9e43a24.jpg) +Figure 2. Average test accuracy of GMSA (blue) and DMSA (orange) on the digits dataset as a function of the number of samples used in domain adaptation. + +and GMSA on the digits dataset when only a small amount of data is available for domain adaptation. We plotted the performance of both algorithms as a function of $m$ , the number of samples per domain, see Figure 2. As expected, DMSA consistently outperforms GMSA, especially in the small sample regime, thus matching our theoretical analysis that DMSA can succeed with fewer samples. + +Adult dataset. We also experimented with the UCI adult dataset (Blake, 1998), which contains 32,561 training samples with numerical and categorical features, each representing a person. The task consists of predicting if the person's income exceeds $50,000. Following (Mohri et al., 2019), we split the dataset into two domains, the doctorate Doc domain and non-doctorate NDoc domain and used categorical features for training linear classification models. We froze these models and experimented with the MSA methods GMSA and DMSA. Here, we repeatedly sampled 400 training samples from each domain for training, keeping the test set fixed. + +Table 3. Linear models for adult dataset. The experiments are averaged over 100 runs. + +
Test dataDocNDocDoc-NDoc
GMSA70.2 ± 1.276.4 ± 1.673.3 ± 0.8
DMSA70.0 ± 0.880.5 ± 0.575.3 ± 0.4
+ +The results are reported in Table 3. DMSA achieves a higher accuracy than GMSA on the NDoc domain and also in the + +![](images/fa12f2565da05ec1bde36298989f9925674284182849b8001fce18011b775574.jpg) +Figure 3. Comparison of GMSA and DMSA on the synthetic dataset. DMSA performs better than GMSA on both domains and thus on any convex combination. The experiments are averaged over 10 runs; error bars show one standard deviation. + +![](images/6dfe9fe1ae1a892aa6bc7b21736dc08b79bb685743ba29b18d37898aef90dc05.jpg) + +average of two domains. The difference in performance is not statistically significant for the Doc domain as it has very few test samples. + +Office dataset. We also carried out experiments on the visual adaptation office dataset (Saenko et al., 2010). The Office dataset is composed of 3 domains: amazon, dslr, and webcam. The amazon domain consists of 2817 images, dslr 498, and webcam 795 images. We divided the dataset into two splits following (Saenko et al., 2010). For the training data, we used 20 samples per category for amazon and 8 for both dslr and webcam. We used the rest of the samples as test data. We extracted the penultimate layer output from ResNet50 architecture (He et al., 2015) pre-trained on ImageNet and trained logistic regression models as base classifiers using this pretrained feature. The results are shown in Table 4. DMSA outperforms GMSA in all three domains and thus any convex combination. The differences for amazon and webcam is less than a standard deviation, however, we observe the advantage of DMSA over GMSA consistently. Similarly, DMSA achieves a higher accuracy than ResNet-unif, especially in the amazon domain, for which its performance matches that of a model specifically trained for that domain. + +Table 4. Office Dataset Accuracy. The experiments are averaged over 10 runs. + +
Test dataamazonwebcamdslr
ResNet-amazon82.2 ± 0.675.8 ± 1.377.6 ± 1.4
ResNet-webcam63.3 ± 1.695.7 ± 1.095.7 ± 1.3
ResNet-dslr64.6 ± 1.094.0 ± 0.795.8 ± 1.0
ResNet-unif79.3 ± 0.696.7 ± 0.797.2 ± 0.6
GMSA82.1 ± 0.496.8 ± 0.896.7 ± 0.6
DMSA82.2 ± 0.497.2 ± 0.997.4 ± 0.4
+ +Synthetic dataset. We finally conducted simulations on a small synthetic dataset to further illustrate the difference between GMSA and DMSA. We used the sklearnn toolkit for these experiments. Let $\mathcal{D}_1$ and $\mathcal{D}_2$ be Gaussian mixtures in one dimension defined as follows: $\mathcal{D}_1 = 0.9\cdot N(-20,8) + 0.1\cdot N(0,0.1)$ and $\mathcal{D}_2 = 0.75\cdot N(3,0.1) + 0.25\cdot N(5,0.1) + 0.05\cdot N(0,0.1)$ , see Figure 1. The two domains are similar + +around 0 but are disjoint otherwise. Let the labeling function $f(x) = -1$ if $x \in [-0.5, 0.5] \cup [3.5, +\infty)$ . The example is designed such that if their estimates are good, then both GMSA and DMSA would achieve close to $100\%$ accuracy. We first sampled 1000 examples and trained a linear separator $h_k$ for each domain $k$ . Compared GMSA and DMSA on this dataset. For GMSA, we trained kernel density estimators and chose the bandwidth based on a five-fold cross-validation. For DMSA, we trained a conditional Maxent threshold classifier. We first illustrate the kernel density estimate using 1000 samples in Figure 1. For $x \in [-0.5, 0.5]$ , $\mathcal{D}_1(x) > \mathcal{D}_2(x)$ , but the kernel density estimates satisfy $\widehat{\mathcal{D}}_2(x) \geq \widehat{\mathcal{D}}_1(x)$ , which shows the limitations of kernel density estimation with a single bandwidth. On the other hand, DMSA selected a threshold around 0.3 for distinguishing between $\mathcal{D}_1$ and $\mathcal{D}_2$ and achieves accuracy around $100\%$ . We varied the number of examples available for domain adaptation and compared GMSA and DMSA. For simplicity, we found the best $z$ using exhaustive search for both GMSA and DMSA. The results show that DMSA consistently outperforms GMSA on both the domains and hence on all convex combinations, see Figure 3. The results also indicate that DMSA converges faster, in accordance with our theory. + +# 6. Conclusion + +We presented a new algorithm for the important problem of multiple-source adaptation, which commonly arises in applications. Our algorithm was shown to benefit from favorable theoretical guarantees and a superior empirical performance, compared to previous work. Moreover, our algorithm is practical: it is straightforward to train a multiclass classifier in the setting we described and our DC-programming solution is very efficient. + +Providing a robust solution for the problem is particularly important for under-represented groups, whose data is not necessarily well-represented in the classifiers to be combined and trained on source data. Our solution demonstrates improved performance even in the cases where the target distribution is not included in the source distributions. We hope that continued efforts in this area will result in more equitable treatment of under-represented groups. + +# References + +C. Arndt. Information Measures: Information and its Description in Science and Engineering. Signals and Communication Technology. Springer Verlag, 2004. +S. Ben-David, J. Blitzer, K. Crammer, and F. Pereira. Analysis of representations for domain adaptation. In Proceedings of NIPS. MIT Press, 2007. +C. Blake. UCI repository of machine learning databases. https://archive.ics.uci.edu/ml/index.php, 1998. +G. Blanchard, G. Lee, and C. Scott. Generalizing from several related classification tasks to a new unlabeled sample. In NIPS, pages 2178-2186, 2011. +J. Blitzer, M. Dredze, and F. Pereira. Biographies, bollywood, boom-boxes and blenders: Domain adaptation for sentiment classification. In ACL, pages 440-447, 2007. +J. Blitzer, K. Crammer, A. Kulesza, F. Pereira, and J. Wortman. Learning bounds for domain adaptation. In Proceedings of NIPS. MIT Press, 2008. +C. Cortes and M. Mohri. Domain adaptation in regression. In Proceedings of ALT, pages 308-323, 2011. +C. Cortes and M. Mohri. Domain adaptation and sample bias correction theory and algorithm for regression. Theor. Comput. Sci., 519:103-126, 2014. +C. Cortes, M. Mohri, and A. M. Medina. Adaptation algorithm and theory based on generalized discrepancy. In Proceedings of KDD, pages 169-178, 2015. +C. Cortes, M. Mohri, and A. M. Medina. Adaptation based on generalized discrepancy. J. Mach. Learn. Res., 20: 1:1-1:30, 2019. +K. Crammer, M. J. Kearns, and J. Wortman. Learning from multiple sources. Journal of Machine Learning Research, 9(Aug):1757-1774, 2008. +M. Dredze, K. Crammer, and F. Pereira. Confidence-weighted linear classification. In ICML, volume 307, pages 264-271, 2008. +L. Duan, I. W. Tsang, D. Xu, and T. Chua. Domain adaptation from multiple sources via auxiliary classifiers. In ICML, volume 382, pages 289-296, 2009. +L. Duan, D. Xu, and I. W. Tsang. Domain adaptation from multiple sources: A domain-dependent regularization approach. IEEE Transactions on Neural Networks and Learning Systems, 23(3):504-518, 2012. +B. Fernando, A. Habrard, M. Sebban, and T. Tuytelaars. Unsupervised visual domain adaptation using subspace alignment. In Proceedings of ICCV, pages 2960-2967, 2013. + +C. Gan, T. Yang, and B. Gong. Learning attributes equals multi-source domain generalization. In Proceedings of CVPR, pages 87-97, 2016. +Y. Ganin, E. Ustinova, H. Ajakan, P. Germain, H. Larochelle, F. Laviolette, M. Marchand, and V. Lempitsky. Domain-adversarial training of neural networks. The Journal of Machine Learning Research, 17(1):2096-2030, 2016. +M. Ghifary, W. Bastiaan Kleijn, M. Zhang, and D. Balduzzi. Domain generalization for object recognition with multitask autoencoders. In Proceedings of ICCV, pages 2551-2559, 2015. +B. Gong, Y. Shi, F. Sha, and K. Grauman. Geodesic flow kernel for unsupervised domain adaptation. In CVPR, pages 2066-2073, 2012. +B. Gong, K. Grauman, and F. Sha. Connecting the dots with landmarks: Discriminatively learning domain-invariant features for unsupervised domain adaptation. In ICML, volume 28, pages 222-230, 2013a. +B. Gong, K. Grauman, and F. Sha. Reshaping visual datasets for domain adaptation. In NIPS, pages 1286-1294, 2013b. +K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition, 2015. +J. Hoffman, B. Kulis, T. Darrell, and K. Saenko. Discovering latent domains for multisource domain adaptation. In ECCV, volume 7573, pages 702-715, 2012. +J. Hoffman, M. Mohri, and N. Zhang. Algorithms and theory for multiple-source adaptation. In Proceedings of NIPS, pages 8246-8256, 2018. +J. Hoffman, M. Mohri, and N. Zhang. Multiple-source adaptation theory and algorithms. Ann. Math. Artif. Intell., 89(3-4):237-270, 2021. +R. A. Jacobs, M. I. Jordan, S. J. Nowlan, and G. E. Hinton. Adaptive mixtures of local experts. Neural computation, 3(1):79-87, 1991. +I.-H. Jhuo, D. Liu, D. Lee, and S.-F. Chang. Robust visual domain adaptation with low-rank reconstruction. In Proceedings of CVPR, pages 2168-2175. IEEE, 2012. +A. Khosla, T. Zhou, T. Malisiewicz, A. A. Efros, and A. Torralba. Undoing the damage of dataset bias. In ECCV, volume 7572, pages 158-171, 2012. +D. Kifer, S. Ben-David, and J. Gehrke. Detecting change in data streams. Proceedings of the 30th International Conference on Very Large Data Bases, 2004. + +N. Konstantinov and C. Lampert. Robust learning from untrusted sources. In Proceedings of ICML, pages 3488-3498, 2019. +H. Liao. Speaker adaptation of context dependent deep neural networks. In ICASSP, pages 7947-7951, 2013. +H. Liu, M. Shao, and Y. Fu. Structure-preserved multiresource domain adaptation. In 2016 IEEE 16th International Conference on Data Mining (ICDM), pages 1059-1064. IEEE, 2016. +J. Liu, J. Zhou, and X. Luo. Multiple source domain adaptation: A sharper bound using weighted Rademacher complexity. In Technologies and Applications of Artificial Intelligence (TAAI), 2015 Conference on, pages 546-553. IEEE, 2015. +Y. Mansour, M. Mohri, and A. Rostamizadeh. Domain adaptation with multiple sources. In NIPS, pages 1041-1048, 2008. +Y. Mansour, M. Mohri, and A. Rostamizadeh. Multiple source adaptation and the rényi divergence. In Proceedings of UAI, pages 367-374, 2009a. +Y. Mansour, M. Mohri, and A. Rostamizadeh. Domain adaptation: Learning bounds and algorithms. In Proceedings of COLT, Montreal, Canada, 2009b. Omnipress. +Y. Mansour, M. Mohri, J. Ro, A. T. Suresh, and K. Wu. A theory of multiple-source adaptation with limited target labeled data. In Proceedings of AISTATS, pages 2332-2340, 2021. +R. McDonald, M. Mohri, N. Silberman, D. Walker, and G. S. Mann. Efficient large-scale distributed training of conditional maximum entropy models. In Proceedings of NIPS, pages 1231-1239, 2009. +M. Mohri, G. Sivek, and A. T. Suresh. Agnostic federated learning. In Proceedings of ICML, pages 4615-4625. PMLR, 2019. +S. Motiian, Q. Jones, S. Iranmanesh, and G. Doretto. Few-shot adversarial domain adaptation. In Proceedings of NIPS, pages 6670-6680, 2017a. +S. Motiian, M. Piccirilli, D. A. Adjeroh, and G. Doretto. Unified deep supervised domain adaptation and generalization. In Proceedings of ICCV, pages 5715-5725, 2017b. +K. Muandet, D. Balduzzi, and B. Scholkopf. Domain generalization via invariant feature representation. In ICML, volume 28, pages 10-18, 2013. + +S. J. Nowlan and G. E. Hinton. Evaluation of adaptive mixtures of competing experts. In Proceedings of NIPS, pages 774-780, 1991. +S. J. Pan and Q. Yang. A survey on transfer learning. IEEE Trans. Knowl. Data Eng., 22(10):1345-1359, 2010. +Z. Pei, Z. Cao, M. Long, and J. Wang. Multi-adversarial domain adaptation. In AAAI, pages 3934-3941, 2018. +X. Peng, Q. Bai, X. Xia, Z. Huang, K. Saenko, and B. Wang. Moment matching for multi-source domain adaptation. In Proceedings of ICCV, pages 1406-1415, 2019. +K. Saenko, B. Kulis, M. Fritz, and T. Darrell. Adapting visual category models to new domains. In European conference on computer vision, pages 213-226. Springer, 2010. +K. Saito, D. Kim, S. Sclaroff, T. Darrell, and K. Saenko. Semi-supervised domain adaptation via minimax entropy. In Proceedings of ICCV, pages 8050-8058, 2019. +B. K. Sriperumbudur and G. R. G. Lanckriet. A proof of convergence of the concave-convex procedure using Zangwill's theory. Neural Computation, 24(6):1391-1407, 2012. +Q. Sun, R. Chattopadhyay, S. Panchanathan, and J. Ye. A two-stage weighting framework for multi-source domain adaptation. In Proceedings of NIPS, pages 505-513, 2011. +P. D. Tao and L. T. H. An. Convex analysis approach to DC programming: theory, algorithms and applications. Acta Mathematica Vietnamica, 22(1):289-355, 1997. +P. D. Tao and L. T. H. An. A DC optimization algorithm for solving the trust-region subproblem. SIAM Journal on Optimization, 8(2):476-505, 1998. +A. Torralba and A. A. Efros. Unbiased look at dataset bias. In CVPR, pages 1521-1528, 2011. +E. Tzeng, J. Hoffman, T. Darrell, and K. Saenko. Simultaneous deep transfer across domains and tasks. In Proceedings of ICCV, pages 4068-4076, 2015. +T. Van Erven and P. Harremos. Rényi divergence and Kullback-Leibler divergence. IEEE Transactions on Information Theory, 60(7):3797-3820, 2014. +B. Wang, J. Mendez, M. Cai, and E. Eaton. Transfer learning via minimizing the performance gap between domains. In Proceedings of NIPS, pages 10645-10655, 2019a. +T. Wang, X. Zhang, L. Yuan, and J. Feng. Few-shot adaptive faster r-cnn. In Proceedings of CVPR, pages 7173-7182, 2019b. + +J. Wen, R. Greiner, and D. Schuurmans. Domain aggregation networks for multi-source domain adaptation. arXiv preprint arXiv:1909.05352, 2019. +R. Xu, Z. Chen, W. Zuo, J. Yan, and L. Lin. Deep cocktail network: Multi-source unsupervised domain adaptation with category shift. In Proceedings of CVPR, pages 3964-3973, 2018. +Z. Xu, W. Li, L. Niu, and D. Xu. Exploiting low-rank structure from latent domains for domain generalization. In ECCV, volume 8691, pages 628-643, 2014. +J. Yang, R. Yan, and A. G. Hauptmann. Cross-domain video concept detection using adaptive svms. In ACM Multimedia, pages 188-197, 2007. +K. Zhang, M. Gong, and B. Schölkopf. Multi-source domain adaptation: A causal view. In AAAI, pages 3150-3157, 2015. +H. Zhao, S. Zhang, G. Wu, J. M. Moura, J. P. Costeira, and G. J. Gordon. Adversarial multiple source domain adaptation. In Proceedings of NIPS, pages 8559-8570, 2018. \ No newline at end of file diff --git a/adiscriminativetechniqueformultiplesourceadaptation/images.zip b/adiscriminativetechniqueformultiplesourceadaptation/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..2a28635b7e113a948abc314cea4243eb3a7e10df --- /dev/null +++ b/adiscriminativetechniqueformultiplesourceadaptation/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7df8a63349fc9bd41af177607b62fd653d92e550f2f274b16360717de050afc3 +size 387858 diff --git a/adiscriminativetechniqueformultiplesourceadaptation/layout.json b/adiscriminativetechniqueformultiplesourceadaptation/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..1fbd018af86e5cd7faca669c13c833c56df7caf7 --- /dev/null +++ b/adiscriminativetechniqueformultiplesourceadaptation/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5184226cf81713485ae7f15fa795c6b22c08c70f4942b1737d12e723e21c76e0 +size 610175 diff --git a/adistributiondependentanalysisofmetalearning/6db6afa5-a197-40ad-a97b-84bf3b3a92f4_content_list.json b/adistributiondependentanalysisofmetalearning/6db6afa5-a197-40ad-a97b-84bf3b3a92f4_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..2542d314cfa808b7bd243cbd73633c5349f0e777 --- /dev/null +++ b/adistributiondependentanalysisofmetalearning/6db6afa5-a197-40ad-a97b-84bf3b3a92f4_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:08d98d9156e0d5099b3679cfe166002deca157be68547c70145bf5e3103754c2 +size 88039 diff --git a/adistributiondependentanalysisofmetalearning/6db6afa5-a197-40ad-a97b-84bf3b3a92f4_model.json b/adistributiondependentanalysisofmetalearning/6db6afa5-a197-40ad-a97b-84bf3b3a92f4_model.json new file mode 100644 index 0000000000000000000000000000000000000000..be021a04f098b1970dbf2a52f6a81f560eb494f5 --- /dev/null +++ b/adistributiondependentanalysisofmetalearning/6db6afa5-a197-40ad-a97b-84bf3b3a92f4_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b9dd8b6eaeb462986364f6d05c0e1d5433bd97c683c3c28723e60117fc42db88 +size 100593 diff --git a/adistributiondependentanalysisofmetalearning/6db6afa5-a197-40ad-a97b-84bf3b3a92f4_origin.pdf b/adistributiondependentanalysisofmetalearning/6db6afa5-a197-40ad-a97b-84bf3b3a92f4_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..ad4883337985aa653475d399e12247a17307fd5d --- /dev/null +++ b/adistributiondependentanalysisofmetalearning/6db6afa5-a197-40ad-a97b-84bf3b3a92f4_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:251d5641c79a8c216f65d3eeda2534a31e5098769918589885879023e7a3b5f3 +size 684320 diff --git a/adistributiondependentanalysisofmetalearning/full.md b/adistributiondependentanalysisofmetalearning/full.md new file mode 100644 index 0000000000000000000000000000000000000000..8701e95b429b1f09b305013bb9436ede3422240a --- /dev/null +++ b/adistributiondependentanalysisofmetalearning/full.md @@ -0,0 +1,378 @@ +# A Distribution-Dependent Analysis of Meta-Learning + +Mikhail Konobeev1 Ilja Kuzborskij2 Csaba Szepesváří1,2 + +# Abstract + +A key problem in the theory of meta-learning is to understand how the task distributions influence transfer risk, the expected error of a metalearner on a new task drawn from the unknown task distribution. In this paper, focusing on fixed design linear regression with Gaussian noise and a Gaussian task (or parameter) distribution, we give distribution-dependent lower bounds on the transfer risk of any algorithm, while we also show that a novel, weighted version of the so-called biased regularized regression method is able to match these lower bounds up to a fixed constant factor. Notably, the weighting is derived from the covariance of the Gaussian task distribution. Altogether, our results provide a precise characterization of the difficulty of meta-learning in this Gaussian setting. While this problem setting may appear simple, we show that it is rich enough to unify the "parameter sharing" and "representation learning" streams of meta-learning; in particular, representation learning is obtained as the special case when the covariance matrix of the task distribution is unknown. For this case we propose to adopt the EM method, which is shown to enjoy efficient updates in our case. The paper is completed by an empirical study of EM. In particular, our experimental results show that the EM algorithm can attain the lower bound as the number of tasks grows, while the algorithm is also successful in competing with its alternatives when used in a representation learning context. + +# 1. Introduction + +In meta-learning, a learner uses data from past tasks in an attempt to speed up learning on future tasks. Whether a speedup is possible depends on whether the new task is + +"similar" to the previous ones. In the formal framework of statistical meta-learning of Baxter (2000), the learner is given a sequence of training "sets". The data in each set is independently sampled from an unknown distribution specific to the set, or task, while each such task distribution is independently sampled from an unknown meta-distribution, which we shall just call the environment. The learner's transfer risk then is its expected prediction loss on a target task freshly sampled from the environment. Can a learner achieve smaller transfer risk by using data from the possibly unrelated tasks? What are the limits of reducing transfer risk? + +As an instructive example, consider a popular approach where each of the $n$ tasks is associated with ground truth parameters $\theta_{i} \in \mathbb{R}^{d}$ , each of which is assumed to lie close to an unknown vector $\alpha$ that characterizes the environment. To estimate the unknown parameter vector of the last task, one possibility is to employ biased regularization (Yang et al., 2007; Kuzborskij & Orabona, 2013; Pentina & Lampert, 2014), that is, solve the optimization problem + +$$ +\min _ {\boldsymbol {\theta}} \left\{\hat {\mathcal {L}} _ {n} (\boldsymbol {\theta}) + \frac {\lambda}{2} \| \boldsymbol {\theta} - \hat {\boldsymbol {\alpha}} \| ^ {2} \right\} +$$ + +where $\hat{\mathcal{L}}_n(\cdot)$ is the empirical loss on the $n$ th task, $\lambda > 0$ is a regularization parameter that governs the strength of the regularization term that biases the solution towards $\hat{\alpha}$ , an estimate of $\alpha$ . Here, $\hat{\alpha}$ could be obtained, for example, by averaging parameters estimated on previous tasks (Denevi et al., 2018). This procedure implements the maxim "learn on a new task, but stay close to what is already learned", which is the basis of many successful meta-learning algorithms, including the above, and MAML (Finn et al., 2017). + +Early theoretical work in the area focused on studying the generalization gap, which is the difference between the transfer risk and its empirical counterpart. Maurer (2005) gives an upper bound on this gap for a concrete algorithm which is similar to the biased regularization approach discussed above. While these bounds are reassuring, they need further work to fully quantify the benefit of meta-learning, i.e., the gap between the risk of a standard (non-meta) learner and the transfer risk of a meta-learner. Numerous other works have shown bounds on the generalization gap when using biased regularization, in one-shot learning (Kuzborskij & Orabona, 2016), meta-learning (Pentina + +& Lampert, 2014), and sequential learning of tasks (Denevi et al., 2018; 2019; Khodak et al., 2019a;b; Finn et al., 2019). While some of these works introduced a dependence on the environment distribution, or on the "regularity" of the sequence of tasks as appropriate, they still leave open the question whether the shown dependence is best possible. + +In summary, the main weakness of the cited literature is the lack of (problem dependent) lower bounds: To be able to separate "good" meta-learning methods from "poor" ones, one needs to know the best achievable performance in a given problem setting. In learning theory, the most often used lower bounds are distribution-free or problem independent. In the context of meta learning, the distribution refers to the distribution over the tasks, or the environment. The major limitation of a distribution-free approach is that if the class of environments is sufficiently rich, all that the bound will tell us is that the best standard learner will have similar performance to that of the best meta-learner since the worst-case environment will be one where the tasks are completely unrelated. As an example, for a linear regression setting with $d$ -dimensional parameter vectors, Lucas et al. (2021) gives the worst-case lower bound $\Omega(d / ((2r)^{-d}M + m))$ for parameter identification where the error is measured in the squared Euclidean distance. Here, $M$ is the total number of data points in the identically-sized training sets, $m$ is the number of data points in the training set of the target task, and $r \geq 1$ is the radius of the ball that contains the parameter vectors. $^{1}$ It follows that as $r \to \infty$ , the lower bound reduces to that of linear regression and we see that any method that ignores the tasks is competitive with the best meta-learning method. The pioneering works of Maurer (2009); Maurer et al. (2016) avoid this pathology by introducing empirical quantities that capture task relatedness in the context of linear regression with a common low-dimensional representation. + +The bounds can be refined and the pathological limit can be avoided by restricting the set of environments. This approach is taken by Du et al. (2020) and Tripuraneni et al. (2020) who also consider linear regression where the tasks share a common low-dimensional representation. Their main results show that natural algorithms can take advantage of this extra structure. In addition, Tripuraneni et al. (2020) also shows a lower bound on the transfer risk which is matched by their method up to logarithmic factors and problem dependent "conditioning" constants. + +This result is stated in Theorem 5 in their paper and the setting is a meta linear regression. For readability, we dropped some constants, such as label noise variance and slightly generalized the cited result by introducing $r$ , which is taken to be $r = 1$ in their paper. Indeed, the analysis in the paper is not hard to modify to get the dependence shown on $r$ . + +Our contributions. In the present paper we revisit the framework underlying biased regularized regression. In particular, we propose to study the case when the unknown parameter vectors for the tasks are generated from a normal distribution with some mean and covariance matrix. First, we consider the case when the mean is unknown while the covariance matrix is known. For this case, in the context of fixed-design linear regression, we prove distribution-dependent lower and upper bounds, which essentially match each other. The lower bound is a direct lower limit on the transfer risk of any meta-learning method. The upper bound is proven for a version of a weighted biased regularized least-squares regression. Here, the parameters are biased towards the maximum likelihood estimate of the unknown common mean of the task parameter vectors, and the weighting is done with respect to the inverse covariance matrix of the distribution over the task parameter vectors. We show that the maximum likelihood estimator can be efficiently computed, which implies that the entire procedure is efficient. As opposed to the work of Tripuraneni et al. (2020), the gap between the lower and upper bounds is a universal constant, regardless of the other parameters of the meta-learning task. The matching lower and upper bounds together provide a precise and fine-grained characterization of the benefits of meta-learning. Our algorithm shows how one should combine datasets of different cardinalities and suggest specific ways of tuning biased regularized regression based on the noise characteristics of the data and the task structure. Our lower bounds are based on a rigorously proven novel observation, which may be of interest on its own. According to this observation, any predictor can be treated as a plug-in method that first estimates the unknown task distribution parameters. Hence, to prove a lower bound for the transfer risk, it suffices to do so for plug-in estimators. + +In the last part of the paper we consider the case when the covariance matrix of the task parameter vector distribution is unknown. Importantly, this case can be seen as a way of unifying the representation learning stream of meta-learning with the parameter sharing stream. In particular, if the covariance matrix is such that $d - s$ of its eigenvalues tend to zero, while the other eigenvalues $s$ are allowed to take on arbitrarily large values, the problem becomes essentially the same as the representation learning problem of Du et al. (2020); Tripuraneni et al. (2020). + +While we provide no theoretical analysis for this case, we give a detailed description of how the Expectation-Maximization (EM) algorithm can be used to tackle this problem. In particular, we show that in this special case the EM algorithm enjoys an efficient implementation: we show how to implement the iterative steps in the loop of the EM algorithm in an efficient way. The steps of this algorithm are given as closed-form expressions, which are both intuitive and straightforward to implement. We demonstrate + +![](images/c67e248f033e71c0521b4f27522b3566a671daf1618f1ef5312c88a51fce99b3.jpg) +Figure 1. Examples of predictions on the synthetic, 'Fourier' meta-learning problem. Training data is shown in bold, small dots show test data. We also show the predictions for two learners (at every input) and the target function. The column corresponds to outputs obtained training on $n \in \{10, 50, 100\}$ tasks. Our new algorithm, EM learner, performs quite well. + +![](images/2d9510195ae610a0e671e9df81f0c96307ad50c78bd0c8c58328444df6ae6c98.jpg) + +![](images/a57368df8fd6da3d7024167ad243c8e84635064c0161b266b6628d3a7f7eb094.jpg) + +the effectiveness of the resulting procedure on a number of synthetic and real benchmarks; Fig. 1 shows an example on a synthetic benchmark problem, comparing our EM algorithm with the earlier cited (unweighted) "biased regression" procedure. As can be seen from the figure, the EM based learner is significantly more effective. Further experiments suggest that the EM learner is almost as effective as the optimal biased weighted regularized regression procedure that is given the unknown parameters. We found that the EM learner is also competitive as a representation learning algorithm by comparing it to the algorithm of Tripuraneni et al. (2020) that is based on the "method-of-moments" technique. + +# 2. Setup + +In the statistical approach to meta-learning (Baxter, 1998; 2000) the learner observes a sequence of training tuples $\mathcal{D} = (D_i)_{i=1}^n$ , distributed according to a random sequence of task distributions $(P_i)_{i=1}^n$ , i.e. $D_i \sim P_i$ , and furthermore task distributions are sampled independently from each other from a fixed and unknown environment distribution $\mathcal{P}$ . The focus of this paper is linear regression with a fixed design and therefore each training tuple $D_i = ((x_{i,1}, Y_{i,1}), \ldots, (x_{i,m_i}, Y_{i,m_i}))$ consists of $m_i$ fixed training inputs from $\mathbb{R}^d$ and corresponding random, real-valued targets satisfying + +$$ +Y _ {i, j} = \boldsymbol {\theta} _ {i} ^ {\top} \boldsymbol {x} _ {i, j} + \varepsilon_ {i, j}, \tag {1} +$$ + +where $\varepsilon_{i,j}\stackrel {\mathrm{iiid}}{\sim}\mathcal{N}(0,\sigma^2),\pmb {\theta}_i\stackrel {\mathrm{iiid}}{\sim}\mathcal{N}(\pmb {\alpha},\pmb {\Sigma})$ + +while $(\varepsilon_{i,j})_{i,j}$ and $(\pmb{\theta}_i)_i$ are also independent from each other. A meta-learning environment in this setting is thus given by $\alpha$ and the noise parameters $(\sigma^2,\Sigma)$ . Initially, we will assume that $(\sigma^2,\Sigma)$ is known, while $\alpha$ (just like $(\pmb{\theta}_i)_i$ ) is unknown. The learner observes $\mathcal{D}$ and needs to produce a prediction of the value + +$$ +Y = \boldsymbol {\theta} _ {n} ^ {\top} \boldsymbol {x} + \varepsilon +$$ + +where $\varepsilon \sim \mathcal{N}(0,\sigma^2)$ and where $\pmb{x} \in \mathbb{R}^d$ is a fixed (nonrandom) point. Our theoretical results will trivially extend to the case when the learner needs to produce predictions for a sequence of input points or a fixed distribution over these, as often considered in meta-learning literature (Denevi et al., 2018; Du et al., 2020). The (random) transfer risk of the learner is defined as + +$$ +\mathcal {L} (\boldsymbol {x}) = \mathbb {E} \left[ (Y - \hat {Y}) ^ {2} \Big | \mathcal {D} \right]. +$$ + +The setting described above coincides with the standard fixed-design linear regression setup for $n = 1$ and $\Sigma \rightarrow 0$ , for which the behavior of risk is well understood. In contrast, the question that meta-learning poses is whether having $n > 1$ , one can design a predictor that achieves lower risk compared to the approach that only uses the target data. Naturally, this is of a particular interest in the small sample regime when for all tasks, $m_{i} \ll n$ , that is when facing scarcity of the training data but having many tasks. Broadly speaking, this reduces to understanding the behavior of the risk in terms of the interaction between the number of tasks $n$ , their sample sizes $(m_{1},\ldots ,m_{n})$ , and the task structure given by the noise parametrization $(\sigma^2,\Sigma)$ . + +# 3. Sufficiency of Meta-mean Prediction + +In this section we show that there is no loss of generality in considering "plug-in" predictors that predict first the unknown meta-mean $\alpha$ . We also show that biased regularized least-squares estimator belongs to this family. We start with some general remarks and notation. + +Throughout the rest of the paper, for real symmetric matrices $A$ and $B$ , we use $A \succeq B$ to indicate that the matrix $A - B$ is Positive Semi-Definite (PSD). For $\boldsymbol{x} \in \mathbb{R}^d$ and PSD matrix $A$ , we let $\| \boldsymbol{x} \|_A = \sqrt{\boldsymbol{x}^\top \boldsymbol{A}\boldsymbol{x}}$ . We use $\| \boldsymbol{x} \|$ to denote the 2-norm of $\boldsymbol{x}$ . In the following we will use matrix notation aggregating inputs, targets, and parameters over multiple tasks. In particular, let the cumulative sample size of all tasks be $M = m_{1} + \dots + m_{n}$ and introduce aggregates + +for inputs and targets as follows: + +$$ +\begin{array}{l} \boldsymbol {X} _ {i} = \underbrace {\left[ \begin{array}{c} \boldsymbol {x} _ {i , 1} ^ {\top} \\ \vdots \\ \boldsymbol {x} _ {i , m _ {i}} ^ {\top} \end{array} \right]} _ {m _ {i} \times d}, \boldsymbol {\Psi} = \underbrace {\left[ \begin{array}{c} \boldsymbol {X} _ {1} \\ \vdots \\ \boldsymbol {X} _ {n} \end{array} \right]} _ {M \times d}, \boldsymbol {Y} _ {i} = \underbrace {\left[ \begin{array}{c} Y _ {i , 1} \\ \vdots \\ Y _ {i , m _ {i}} \end{array} \right]} _ {m _ {i} \times 1}, \boldsymbol {Y} = \underbrace {\left[ \begin{array}{c} \boldsymbol {Y} _ {1} \\ \vdots \\ \boldsymbol {Y} _ {n} \end{array} \right]} _ {M \times 1} \\ \boldsymbol {X} = \underbrace {\left[ \begin{array}{l l l} \boldsymbol {X} _ {1} & \ldots & \boldsymbol {0} \\ \vdots & \ddots & \vdots \\ \boldsymbol {0} & \ldots & \boldsymbol {X} _ {n} \end{array} \right]} _ {M \times n d}, \quad \boldsymbol {\Theta} = \underbrace {\left[ \begin{array}{l} \boldsymbol {\theta} _ {1} \\ \vdots \\ \boldsymbol {\theta} _ {n} \end{array} \right]} _ {n d \times 1}. \\ \end{array} +$$ + +The matrix representation allows us to compactly state the regression model simultaneously over all tasks. In particular, for the $M$ -dimensional noise vector $\varepsilon \sim \mathcal{N}(\mathbf{0}, \sigma^2\mathbf{I})$ : + +$$ +\boldsymbol {Y} = \boldsymbol {X} \boldsymbol {\Theta} + \varepsilon \quad \Leftrightarrow \quad \boldsymbol {Y} \sim \mathcal {N} (\Psi \boldsymbol {\alpha}, \boldsymbol {K}) \tag {2} +$$ + +where $\alpha$ is a meta-mean of model (1) and $K$ is the marginal covariance matrix defined as $\pmb{K} = \pmb{X}(\pmb{I} \otimes \pmb{\Sigma})\pmb{X}^{\top} + \sigma^{2}\pmb{I}$ where $\otimes$ stands for the Kronecker product. Note that the above equivalence comes from a straightforward observation that a linear map $\mathbf{X}_i$ applied to the Gaussian r.v. $\theta_i$ is itself Gaussian with mean $\mathbb{E}[\mathbf{Y}_i] = \mathbf{X}_i\mathbb{E}[\pmb{\theta}_i] = \mathbf{X}_i\pmb{\alpha}$ and covariance $\mathbf{X}_i\pmb{\Sigma}\mathbf{X}_i^T + \sigma^2\mathbf{I}$ which follows from the property that for any random vector $\xi$ with covariance matrix $\pmb{C}$ , and matrix $\mathbf{A}$ of appropriate dimensions, covariance matrix of $\mathbf{A}\xi$ is $\mathbf{ACA}^{\top}$ , ultimately giving Eq. (2). + +# 3.1. Plug-In Predictors and their Sufficiency + +Both our lower and upper bounds will be derived from analyzing a family of "plug-in" predictors that aim to estimate $\theta_{n}$ through estimating $\alpha$ . As we shall see, weighted biased regularization is also member of this family. + +The said family is motivated by applying the well-known bias-variance decomposition to the risk of an arbitrary predictor $A: \operatorname{supp}(P_1) \times \dots \times \operatorname{supp}(P_n) \times \mathbb{R}^d \to \mathbb{R}$ . Namely, + +$$ +\begin{array}{l} \mathcal {L} (\boldsymbol {x}) = \mathbb {E} \left[ (Y - A (\mathcal {D}, \boldsymbol {x})) ^ {2} \mid \mathcal {D} \right] \\ = \mathbb {E} \left[ \left(\mathbb {E} [ Y \mid \mathcal {D} ] - A (\mathcal {D}, \boldsymbol {x})\right) ^ {2} + \mathbb {V} [ Y \mid \mathcal {D} ] \Bigg | \mathcal {D} \right] \\ \end{array} +$$ + +where we used the law of total expectation and the fact that for any r.v. $\xi$ , $\mathbb{E}[\xi^2] = \mathbb{E}[\xi]^2 + \mathbb{V}[\xi]$ . Since the variance term does not depend on $A$ , it follows that the prediction problem reduces to predicting the posterior mean $\mathbb{E}[Y|\mathcal{D}]$ , which, in our setting, can be given in closed form: + +Proposition 3.1. Let $Y = \pmb{\theta}_n^\top \pmb{x} + \varepsilon$ for $\varepsilon \sim \mathcal{N}(0, \sigma^2)$ and some $\pmb{x} \in \mathbb{R}^d$ . Then, + +$$ +\begin{array}{l} \mathbb {E} [ Y \mid \mathcal {D} ] = \boldsymbol {x} ^ {\top} \boldsymbol {\mathcal {T}} \left(\boldsymbol {\Sigma} ^ {- 1} \boldsymbol {\alpha} + \frac {1}{\sigma^ {2}} \boldsymbol {X} _ {n} ^ {\top} \boldsymbol {Y} _ {n}\right) \\ w h e r e \quad \boldsymbol {\mathcal {T}} = \left(\boldsymbol {\Sigma} ^ {- 1} + \frac {1}{\sigma^ {2}} \boldsymbol {X} _ {n} ^ {\top} \boldsymbol {X} _ {n}\right) ^ {- 1}. \\ \end{array} +$$ + +Proof. See Appendix A. + +![](images/afe574fadf6385cdf563b6c365c9f2637492e00743a623cb4fc5cda2a44cb6a1.jpg) + +Since the only unknown parameter here is the meta-mean $\alpha$ , we expect that good predictors will just estimate the meta-mean and use the above formula. That is, these predictors take the form $(\mathcal{D},\boldsymbol{x})\mapsto \boldsymbol{x}^{\top}\hat{\boldsymbol{\theta}}_n(\boldsymbol {\alpha}(\mathcal{D},\boldsymbol {x}))$ , where + +$$ +\hat {\boldsymbol {\theta}} _ {n} (\boldsymbol {a}) = \boldsymbol {\mathcal {T}} \left(\boldsymbol {\Sigma} ^ {- 1} \boldsymbol {a} + \frac {1}{\sigma^ {2}} \boldsymbol {X} _ {n} ^ {\top} \boldsymbol {Y} _ {n}\right) \quad \boldsymbol {a} \in \mathbb {R} ^ {d}, \tag {3} +$$ + +giving our family of plug-in predictors. In fact, there is no loss in generality by considering only predictors of the above form. Indeed, given some predictor $A$ and $\pmb{x} \neq \mathbf{0}$ , we can solve $A(\mathcal{D},\pmb{x}) = \pmb{x}^{\top}\hat{\pmb{\theta}}_n(\pmb{\alpha})$ for $\pmb{\alpha}$ . One solution is given by $\pmb{\alpha}(\mathcal{D},\pmb{x}) = \pmb{\Sigma}\pmb{T}^{-1}\pmb{x}c$ where $c = \frac{1}{\|\pmb{x}\|^2}\left(A(\mathcal{D},\pmb{x}) - \sigma^{-2}\pmb{x}^{\top}\pmb{T}\pmb{X}_n^{\top}\pmb{Y}_n\right)$ . Hence, to prove a lower bound for any regressor $A$ , it will be enough to prove it for algorithms that estimate $\pmb{\alpha}$ . + +One special estimator of $\alpha$ is the Maximum Likelihood Estimator (MLE) estimator, and, thanks to (2), can be obtained via $\hat{\alpha}^{\mathrm{MLE}} = \arg \max_{\boldsymbol{a}\in \mathbb{R}^d}\ln p^{\mathrm{G}}(\boldsymbol {Y};\boldsymbol {\Psi}\boldsymbol {a},\boldsymbol {K})$ , where $p^{\mathrm{G}}(\boldsymbol {x};\boldsymbol {\mu},\boldsymbol {\Sigma})\propto e^{-\frac{1}{2}\| \boldsymbol {x} - \boldsymbol {\mu}\|_{\Sigma^{-1}}^{2}}$ is a Gaussian PDF. Some standard calculations give us + +$$ +\hat {\boldsymbol {\alpha}} ^ {\mathrm {M L E}} = \left(\boldsymbol {\Psi} ^ {\top} \boldsymbol {K} ^ {- 1} \boldsymbol {\Psi}\right) ^ {- 1} \boldsymbol {\Psi} ^ {\top} \boldsymbol {K} ^ {- 1} \boldsymbol {Y}. \tag {4} +$$ + +# 3.2. Weighted Biased Regularization + +Biased regularization is a popular transfer learning technique which commonly appears in the regularized formulations of the empirical risk minimization problems, where one aims at minimizing the empirical risk (such as the mean squared error) while forcing the solution to stay close to some bias variable $\pmb{b}$ . Here we consider the Weighted Biased Regularized Least Squares (WBRLS) formulation defined w.r.t. bias $\pmb{b}$ and some PSD matrix $\Gamma$ : + +$$ +\hat {\boldsymbol {\theta}} _ {n} ^ {\mathrm {W B R L S}} = \underset {\boldsymbol {\theta} \in \mathbb {R} ^ {d}} {\arg \min } \left\{\hat {\mathcal {L}} _ {n} (\boldsymbol {\theta}) + \frac {\lambda}{2} \| \boldsymbol {\theta} - \boldsymbol {b} \| _ {\Gamma} ^ {2} \right\} +$$ + +$$ +\text {w h e r e} \quad \hat {\mathcal {L}} _ {n} (\boldsymbol {\theta}) = \sum_ {j = 1} ^ {m _ {n}} \left(Y _ {n, j} - \boldsymbol {\theta} ^ {\top} \boldsymbol {x} _ {n, j}\right) ^ {2}. +$$ + +Remarkably, an estimate $\hat{\pmb{\theta}}_n^{\mathrm{WBRLS}}$ produced by WBRLS is equivalent to estimator $\hat{\pmb{\theta}}_n(\hat{\pmb{\alpha}})$ of Eq. (3) for the choice of $\pmb {b} = \hat{\pmb{\alpha}},\pmb {\Gamma} = \pmb{\Sigma}^{-1}$ , and $\lambda = \sigma^2$ . Thus, WBRLS is a special member of the family chosen in the previous section. + +To see the equivalence, owing to the convenient least-squares formulation, we observe that + +$$ +\hat {\boldsymbol {\theta}} _ {n} ^ {\mathrm {W B R L S}} = \left(\boldsymbol {X} _ {n} ^ {\top} \boldsymbol {X} _ {n} + \lambda \boldsymbol {\Gamma}\right) ^ {- 1} \left(\boldsymbol {X} _ {n} ^ {\top} \boldsymbol {Y} _ {n} + \lambda \boldsymbol {\Gamma} \boldsymbol {b}\right) +$$ + +and from here the equivalence follows by substitution. A natural question commonly arising in such formulations is how to set the bias term $\pmb{b}$ . One choice can be $\pmb{b} = \hat{\alpha}^{\mathrm{MLE}}$ and in the following we will see that it is an optimal one. + +# 4. Problem-Dependent Bounds + +We now present our main results, which are essentially matching lower and upper bounds. The upper bounds concern the parameter estimator that uses the MLE estimate of $\alpha$ , while the lower bounds apply to any method. We also present a more precise lower bound that applies to estimators that are built on unbiased meta-mean estimators $\hat{\alpha}$ . As we shall see that plug-in predictors based on MLE will exactly match this lower bound. The general lower bounds are also quite precise: They differ from this lower bound only by a (relatively small) universal constant. We also give a high-probability variant of the same general lower bound. + +Theorem 4.1. Let $\pmb{x} \in \mathbb{R}^d$ and consider the linear regression model (1). Let $\hat{\alpha}$ be any unbiased estimator of $\alpha$ based on $\mathcal{D}$ . Then the transfer risk $\mathcal{L}(\pmb{x})$ of the predictor that predicts $\hat{Y} = \pmb{x}^\top \hat{\theta}_n(\hat{\alpha})$ satisfies + +$$ +\mathbb {E} [ \mathcal {L} (\boldsymbol {x}) ] \geq \boldsymbol {x} ^ {\top} M \boldsymbol {x} + \boldsymbol {x} ^ {\top} \boldsymbol {\mathcal {T}} \boldsymbol {x} + \sigma^ {2} \tag {5} +$$ + +where $M = \mathcal{T}\Sigma^{-1}(\Psi^{\top}K^{-1}\Psi)^{-1}\Sigma^{-1}\mathcal{T}$ + +Moreover, for all predictors we have + +$$ +\mathbb {E} [ \mathcal {L} (\boldsymbol {x}) ] \geq \frac {\boldsymbol {x} ^ {\top} M \boldsymbol {x}}{1 6 \sqrt {e}} + \boldsymbol {x} ^ {\top} \boldsymbol {\mathcal {T}} \boldsymbol {x} + \sigma^ {2}. \tag {6} +$$ + +Finally, for any $\delta \in (0,1)$ , with probability at least $1 - \delta$ for all predictors we have + +$$ +\mathcal {L} (\boldsymbol {x}) \geq \frac {1}{2} \log \left(\frac {1}{4 (1 - \delta)}\right) \boldsymbol {x} ^ {\top} M \boldsymbol {x} + \boldsymbol {x} ^ {\top} \boldsymbol {\mathcal {T}} \boldsymbol {x} + \sigma^ {2}. +$$ + +Proof. The main ideas of the proof are in Section 4.2, while the complete proof is given in Appendix B. $\square$ + +Note that the presented bounds are problem-dependent since they depend on a concrete task structure of the environment characterized by $(\Sigma, \sigma^2)$ . While the strength of the above bound is its generality, this generality makes the interpretation of the result challenging. We return to the interpretation of this result momentarily, after presenting results for the transfer risk for the plug-in method that uses the (unbiased) MLE meta-mean estimator $\hat{\alpha}^{\mathrm{MLE}}$ defined in Eq. (4). + +Theorem 4.2. For the estimator $\hat{\theta}_n(\hat{\alpha}^{\mathrm{MLE}})$ and for any $\pmb{x}\in \mathbb{R}^{d}$ we have + +$$ +\mathbb {E} [ \mathcal {L} (\boldsymbol {x}) ] = \boldsymbol {x} ^ {\top} \boldsymbol {M} \boldsymbol {x} + \boldsymbol {x} ^ {\top} \boldsymbol {\mathcal {T}} \boldsymbol {x} + \sigma^ {2}. \tag {7} +$$ + +Moreover for the same estimator, with probability at least $1 - \delta, \delta \in (0, 1)$ we have + +$$ +\mathcal {L} (\boldsymbol {x}) \leq 2 \log \left(\frac {2}{\delta}\right) \boldsymbol {x} ^ {\top} \boldsymbol {M} \boldsymbol {x} + \boldsymbol {x} ^ {\top} \boldsymbol {\mathcal {T}} \boldsymbol {x} + \sigma^ {2}. +$$ + +Proof. See Appendix C. + +![](images/2df196ea7aff158e15c871f08650da3e7980186ec32934d39b5e37f71b01511e.jpg) + +Note that Eq. (7) is an equality for the transfer risk and it matches the lower bound available for unbiased estimators. This result, together with our lower bound shows that $(i)$ the predictors based on $\hat{\alpha}^{\mathrm{MLE}}$ is optimal, with matching constant within the set of predictors that is based on unbiased estimators of $\alpha$ . It also follows that $(ii)$ apart from a constant factor of $16\sqrt{e}$ of the transfer risk, this predictor is also optimal among all predictors. + +# 4.1. Interpretation of the Results + +The following two corollaries specialize the lower bound of Theorem 4.1 in a way that will make the results more transparent. Note that while we give these simplified expressions for the lower bound (specifically, Eq. (6)), these expressions also remain essentially true for the upper bound for the MLE estimator, since these differ only in minor details. The proofs of both corollaries are given in Appendix F. + +Both specializations are concerned with the case when the inputs are isotropic, meaning that the input covariance matrix of task $i$ is $\frac{m_i}{d} I$ . + +In the first result, in addition, we assume a spherical task structure: $\pmb{\Sigma} = \tau^{2}\pmb{I}$ . Thus, the coordinates of the parameter vectors $\theta_{i}$ are uncorrelated and share the same variance $\tau^2$ . + +Corollary 4.3. Assume the same as in case of Eq. (6). In addition, let $\boldsymbol{\Sigma} = \tau^{2}\boldsymbol{I}$ , suppose that $\mathbf{X}_i^\top \mathbf{X}_i = \frac{m_i}{d}\mathbf{I}$ , and let $\| \mathbf{x}\| = 1$ . Then, + +$$ +\frac {\mathbb {E} [ \mathcal {L} (\boldsymbol {x}) ] - \sigma^ {2}}{\sigma^ {2}} \geq \frac {H _ {\tau^ {2}}}{1 6 \sqrt {e}} \cdot \frac {d ^ {2} \sigma^ {2}}{n \left(\tau^ {2} m _ {n} + d \sigma^ {2}\right) ^ {2}} + \frac {d \tau^ {2}}{\tau^ {2} m _ {n} + d \sigma^ {2}}, +$$ + +where $H_{z}$ is a harmonic mean of a sequence $(z + \frac{d\sigma^2}{m_i})_{i = 1}^n$ + +In the above bound the first term vanishes as more tasks are added ( $n$ growing). On the other hand, to decrease the second term, $m_{n}$ needs to increase. In particular, as $n \to \infty$ , we get + +$$ +\frac {\mathbb {E} [ \mathcal {L} (\boldsymbol {x}) ] - \sigma^ {2}}{\sigma^ {2}} \geq \left(\frac {m _ {n}}{d} + \frac {\sigma^ {2}}{\tau^ {2}}\right) ^ {- 1} \tag {8} +$$ + +where $\frac{m_n}{d} + \frac{\sigma^2}{\tau^2}$ can be interpreted as an effective sample size. Thus, while having infinitely many previous tasks have the potential to reduce the loss, the size of this effect is fixed and is related to the noise variance ratios. If $\tau^2 \to 0$ , having infinitely many tasks will allow perfect prediction, but for any $\tau^2 > 0$ , there is a limit on how much the data of previous tasks can help. Finally, for the case $n = 1$ and $\tau^2 = 0$ we recover the standard lower bound for linear setting $\mathbb{E}[\mathcal{L}(\pmb{x})] - \sigma^2 = \Omega (d\sigma^2 / m_1)$ . + +Our next result is concerned with "representation learning", which corresponds to the case when $\Sigma$ is a low rank PSD matrix. + +Corollary 4.4. Let the inputs be isotropic as before and $\| \pmb{x}\| = 1$ . Moreover, let $\pmb{\Sigma}$ be a PSD matrix of rank $s \leq d$ with eigenvalues $\lambda_1 \geq \ldots \geq \lambda_s > 0$ , and suppose that $\| \pmb{x}\|_{P_s^\top P_s}^2 = s / d$ where $\pmb{P}_s = [\pmb{u}_1, \dots, \pmb{u}_s]^\top$ and $(\pmb{u}_j)_{j=1}^s$ are unit length eigenvectors of $\pmb{\Sigma}$ . Then, + +$$ +\frac {\mathbb {E} [ \mathcal {L} (\pmb {x}) ] - \sigma^ {2}}{\sigma^ {2}} \geq \frac {H _ {\lambda_ {s}}}{1 6 \sqrt {e}} \cdot \frac {s d \sigma^ {2}}{n (\lambda_ {1} m _ {n} + d \sigma^ {2}) ^ {2}} + \frac {s \lambda_ {s}}{\lambda_ {s} m _ {n} + d \sigma^ {2}}. +$$ + +Note that the first term on the right-hand side of the last display scales with $sd / n$ , where $sd$ is the number of parameter in a matrix that would give the low-dimensional representation and the second term scales with $s / m_{n}$ for $m_{n} \gg d\sigma^{2} / \lambda_{s}$ . Somewhat surprisingly (given that here $\Sigma$ is known), these essentially match the upper bounds due to Du et al. (2020); Tripuraneni et al. (2020), implying that their results are unimprovable. + +# 4.2. Proof Sketches + +Our lower and upper bounds on the risk are based on an identity that holds for the transfer risk of plug-in methods. The identity is essentially a bias-variance decomposition. + +Lemma 4.5. For $\hat{\theta}_n(\hat{\alpha})$ defined in Eq. (3), any task mean estimator $\hat{\alpha}$ , and any $\pmb{x} \in \mathbb{R}^d$ we have $\mathbb{E}[\mathcal{L}(\pmb{x})] = \mathbb{E}\left[(\pmb{x}^\top \pmb{T}\pmb{\Sigma}^{-1}(\pmb{\alpha} - \hat{\alpha}))^2\right] + \pmb{x}^\top \pmb{T}\pmb{x} + \sigma^2$ . + +For the proof of this lemma we need the following proposition whose proof is given in Appendix A: + +Proposition 4.6. Let $Y = \theta_{n}^{\top}\pmb{x} + \varepsilon$ for $\varepsilon \sim \mathcal{N}(0,\sigma^{2})$ and some $\pmb{x} \in \mathbb{R}^{d}$ . Then, $\mathbb{E}[Y|\mathcal{D}] = \pmb{x}^{\top}\pmb{\mathcal{T}}\left(\pmb{\Sigma}^{-1}\pmb{\alpha} + \frac{1}{\sigma^{2}}\pmb{X}_{n}^{\top}\pmb{Y}_{n}\right)$ and $\mathbb{V}[Y|\mathcal{D}] = \pmb{x}^{\top}\pmb{\mathcal{T}}\pmb{x} + \sigma^{2}$ . + +Proof of Lemma 4.5. Using the law of total expectation and that for a r.v. $\xi$ we have $\mathbb{E}[\xi^2] = \mathbb{E}[\xi]^2 + \mathbb{V}[\xi]$ , + +$$ +\begin{array}{l} \mathcal {L} (\boldsymbol {x}) = \mathbb {E} \left[ (Y - \hat {\boldsymbol {\theta}} _ {n} (\hat {\boldsymbol {\alpha}}) ^ {\top} \boldsymbol {x}) ^ {2} \mid \mathcal {D} \right] \\ = \mathbb {E} \left[ \left(\mathbb {E} [ Y \mid \mathcal {D} ] - \hat {\boldsymbol {\theta}} _ {n} (\hat {\boldsymbol {\alpha}}) ^ {\top} \boldsymbol {x}\right) ^ {2} + \mathbb {V} [ Y \mid \mathcal {D} ] \mid \mathcal {D} \right] \\ = \mathbb {E} \left[ \left(\boldsymbol {x} ^ {\top} \boldsymbol {\mathcal {T}} \boldsymbol {\Sigma} ^ {- 1} (\boldsymbol {\alpha} - \hat {\boldsymbol {\alpha}})\right) ^ {2} \mid \mathcal {D} \right] + \boldsymbol {x} ^ {\top} \boldsymbol {\mathcal {T}} \boldsymbol {x} + \sigma^ {2}, \\ \end{array} +$$ + +where identities for $\mathbb{E}[Y\mid \mathcal{D}]$ and $\mathbb{V}[Y\mid \mathcal{D}]$ come from Proposition 4.6 and identity for $\hat{\pmb{\theta}}_n(\hat{\pmb{\alpha}})$ is due to (3). + +Thus, to establish universal lower bounds we need to lower bound $\mathbb{E}\left[\left(\boldsymbol{x}^{\top}\boldsymbol{\mathcal{T}}\boldsymbol{\Sigma}^{-1}(\boldsymbol{\alpha}-\hat{\boldsymbol{\alpha}})\right)^{2}\right]$ for any choice of estimator $\hat{\alpha}$ , which in combination with Lemma 4.5 will prove Theorem 4.1. Here, relying on the Cramér-Rao inequality (Theorem B.1), we only prove a lower bound for unbiased estimators, while the general case, whose proof uses Le Cam's method, is left to Appendix B.2. + +Lemma 4.7. For any unbiased estimator $\hat{\alpha}$ of $\alpha$ in Eq. (2) we have $\mathbb{E}\left[\left(\boldsymbol{x}^{\top}\boldsymbol{T}\boldsymbol{\Sigma}^{-1}(\boldsymbol{\alpha} - \hat{\boldsymbol{\alpha}})^{2}\right)\right] \geq \boldsymbol{x}^{\top}\boldsymbol{M}\boldsymbol{x}$ . + +Proof. Recall that according to the equivalence (2), $\mathbf{Y} \sim \mathcal{N}(\Psi \alpha, \mathbf{K})$ and the unknown parameter is $\alpha$ . To compute the Fisher information matrix we first observe that $\nabla_{\alpha} \ln p^{\mathrm{G}}(\mathbf{Y}; \Psi \alpha, \mathbf{K}) = \Psi^{\top} \mathbf{K}^{-1} (\mathbf{Y} - \Psi \alpha)$ and + +$$ +\begin{array}{l} \boldsymbol {F} = \mathbb {E} \left[ \nabla_ {\boldsymbol {\alpha}} \ln p ^ {\mathrm {G}} (\boldsymbol {Y}; \boldsymbol {\Psi} \boldsymbol {\alpha}, \boldsymbol {K}) \nabla_ {\boldsymbol {\alpha}} \ln p ^ {\mathrm {G}} (\boldsymbol {Y}; \boldsymbol {\Psi} \boldsymbol {\alpha}, \boldsymbol {K}) ^ {\top} \right] \\ = \Psi^ {\top} K ^ {- 1} \mathbb {E} \left[ (Y - \Psi \alpha) (Y - \Psi \alpha) ^ {\top} \right] K ^ {- 1} \Psi \\ = \boldsymbol {\Psi} ^ {\top} \boldsymbol {K} ^ {- 1} \boldsymbol {\Psi}. \\ \end{array} +$$ + +Thus, by the Cramér-Rao inequality we have $\mathbb{E}\left[(\pmb {\alpha} - \hat{\pmb{\alpha}})(\pmb {\alpha} - \hat{\pmb{\alpha}})^{\top}\right]\succeq (\Psi^{\top}\pmb{K}^{-1}\Psi)^{-1}$ . Finally, left-multiplying by $x^{\top}\pmb {\mathcal{T}}\pmb{\Sigma}^{-1}$ and right-multiplying the above by $\pmb{\Sigma}^{-1}\pmb {\mathcal{T}}\pmb{x}$ gives us the statement. + +# 5. Learning with Unknown Task Structure + +So far we have assumed that parameters $(\sigma^2, \Sigma)$ characterizing the structure of environment are known, which limits the applicability of the predictor (though does not limit the lower bound). Staying within our framework, a natural idea is to estimate all the environment parameters $\mathcal{E} = (\alpha, \sigma^2, \Sigma)$ by maximizing the data marginal log-likelihood + +$$ +J (\mathcal {D}, \mathcal {E} ^ {\prime}) = \ln \int_ {\mathbb {R} ^ {n d}} p (\mathcal {D} \mid \boldsymbol {\vartheta}) \mathrm {d} p (\boldsymbol {\vartheta} \mid \mathcal {E} ^ {\prime}) +$$ + +over $\mathcal{E}'$ , where $p(\mathcal{D}, \Theta, \mathcal{E})$ stands for the joint distribution in the model (1). The above problem is non-convex. As such, we propose to use EM procedure (Dempster et al., 1977), which is known to be a reasonable algorithm for similar settings.4 EM can be derived as a procedure that maximizes a lower bound on $J(\mathcal{D}, \mathcal{E}')$ : Jensen's inequality gives us that for any probability measure $q$ on $\mathbb{R}^{nd}$ , $J(\mathcal{D}, \mathcal{E}') \geq \int \ln \left(\frac{p(\vartheta, \mathcal{D}|\mathcal{E}')}{q(\vartheta)}\right) \mathrm{d}q(\vartheta)$ . This is then maximized in $\mathcal{E}'$ and $q$ in an alternating fashion: Letting $\hat{\mathcal{E}}_t$ to be a parameter estimate at step $t$ , we maximize the lower bound in $q$ for a fixed $\mathcal{E}' = \hat{\mathcal{E}}_t$ , and then obtain $\hat{\mathcal{E}}_{t+1}$ by maximizing the lower bound in $\mathcal{E}'$ for a fixed previously obtained solution in $q$ . Maximization in $q$ gives us $q(\vartheta) = p(\vartheta|\mathcal{D}, \hat{\mathcal{E}}_t)$ , while maximization in $\mathcal{E}'$ yields + +$$ +\hat {\mathcal {E}} _ {t + 1} \in \underset {\mathcal {E} ^ {\prime}} {\arg \max } \int \ln (p (\boldsymbol {\vartheta}, \mathcal {D} \mid \mathcal {E} ^ {\prime})) \mathrm {d} p (\boldsymbol {\vartheta} \mid \mathcal {D}, \hat {\mathcal {E}} _ {t}). \tag {9} +$$ + +After some calculations (cf. Appendix D), this gives Algorithm 1. During the E-step (lines 4-5), the algorithm computes the parameters of the posterior distribution $\mathcal{N}(\pmb{\theta}_i|\hat{\pmb{\mu}}_{t,i},\hat{\pmb{T}}_{t,i})$ relying on $\hat{\varepsilon}_t$ , and during the M-step + +lines 7-9) it estimates $\hat{\mathcal{E}}_{t + 1}$ based on $(\hat{\mu}_{t,i},\hat{\mathcal{T}}_{t,i})$ .We propose to detect convergence (not shown) by checking the relative difference between successive parameter values. + +Algorithm 1 EM procedure to estimate $(\alpha, \sigma^2, \Sigma)$ +Input: Initial parameter estimates $\hat{\mathcal{E}}_1 = (\hat{\alpha}_1,\hat{\sigma}_1^2,\hat{\Sigma}_1)$ +Output: Final parameter estimates $\hat{\mathcal{E}}_t = (\hat{\alpha}_t,\hat{\sigma}_t^2,\hat{\Sigma}_t)$ +1: $\hat{\pmb{T}}_{1,i}\gets \mathbf{0},\hat{\pmb{\mu}}_{1,i}\gets \mathbf{0}\quad i\in [n]$ +2: repeat +3: for $i = 1,\dots ,n$ do E-step +4: $\hat{\pmb{T}}_{t,i}\gets \left(\hat{\pmb{\Sigma}}_t^{-1} + \hat{\sigma}_t^{-2}\pmb {X}_i^\top \pmb {X}_i\right)^{-1}$ +5: $\hat{\pmb{\mu}}_{t,i}\gets \hat{\pmb{T}}_{t,i}\left(\hat{\pmb{\Sigma}}_t^{-1}\hat{\pmb{\alpha}}_t + \hat{\sigma}_t^{-2}\pmb {X}_i^\top \pmb {Y}_i\right)$ +6: end for +7: $\hat{\alpha}_{t}\gets \frac{1}{n}\sum_{i = 1}^{n}\hat{\mu}_{t,i}$ M-step +8: $\hat{\pmb{\Sigma}}_t\gets \frac{1}{n}\sum_{i = 1}^{n}\Bigl (\hat{\pmb{T}}_{t,i} + (\hat{\pmb{\mu}}_{t,i} - \hat{\pmb{\alpha}}_t)(\hat{\pmb{\mu}}_{t,i} - \hat{\pmb{\alpha}}_t)^\top \Bigr)$ +9: $\hat{\sigma}_t^2\gets \frac{1}{n}\sum_{i = 1}^{n}\frac{1}{m_i}\left(\hat{\mathcal{L}}_i(\hat{\pmb{\mu}}_{t,i}) + \mathrm{tr}\left(\pmb {X}_i\hat{\pmb{T}}_{t,i}\pmb {X}_i^\top\right)\right)$ +10: $t\gets t + 1$ +11: until Convergence (see discussion) + +# 6. Experiments + +In this section we present experiments $^5$ designed to verify three hypotheses: (i) Under ideal circumstances, the predictor $\pmb{x}^{\top}\hat{\pmb{\theta}}_n(\hat{\pmb{\alpha}}^{\mathrm{MLE}})$ is superior to its alternatives, including biased, but unweighted regression; (ii) The EM-algorithm reliably recovers unknown parameters of the environment and is also suitable for representation learning; (iii) our distribution-dependent lower bound Eq. (5) is numerically sharp. In addition, we briefly report on experiments with a real-world dataset. + +Baselines. We consider two non-meta-learning baselines, that is Linear Regression (All) — Ordinary Least Squares (OLS) fitted on $\mathcal{D}^{\backslash n} = (D_i)_{i=1}^{n-1}$ , which excludes the newly observed task, and Linear Regression (Task) — OLS fitted on a newly encountered task $D_n$ . Next, we consider meta-learning algorithms. We report performance of the unweighted Biased Regression procedure with bias set to the least squares solution $(\sum_{i \neq n} X_i^\top X_i)^{-1} \sum_{i \neq n} X_i^\top Y_i$ and $\lambda$ found by cross-validation (cf. Appendix E). Note that the bias and the regularization coefficient are found on $\mathcal{D}^{\backslash n}$ , while $D_n$ is used for the final fitting. EM Learner is estimator (3) with all environment parameters found by Algorithm 1 on $\mathcal{D}^{\backslash n}$ . The convergence threshold was set to $10^{-6}$ while the maximum number of iterations was set to $10^3$ . Finally, we report numerical values of Eq. (5) as Known Covariance Lower Bound. For all of the experiments we show aver + +ages and standard deviations of the mean test errors computed over 30 independent runs of that experiment. + +Synthetic Experiments. We conduct synthetic experiments on datasets with Fourier generated features and features sampled from a $d$ -dimensional unit sphere. In all of the synthetic experiments we have $\alpha = 0, \sigma^2 = 1$ and $\Sigma$ generated by computing $\boldsymbol{\Sigma} = \mathbf{L}\mathbf{L}^{\top} + \eta \mathbf{I}$ where $L_{ij} = \mathbb{I}\left\{i \geq j\right\} Z_{ij}$ with $Z_{ij}$ and $\eta$ sampled from the standard normal distribution. Test error is computed on 100 test tasks using 10 examples for training and 100 examples for testing. + +For the Fourier-features, we sample a value $u \sim \mathcal{U}(-5, 5)$ and compute features by evaluating $d = 11$ Fourier basis functions at $u$ : $x_{j} = \mathbb{I}\{1 \leq j \leq 5\} \sin \left(\frac{j}{5} \pi u\right) + \mathbb{I}\{6 \leq j \leq 10\} \cos \left(\frac{j - 5}{5} \pi u\right) + \mathbb{I}\{j = 11\}$ , where $\mathbb{I}\{E\} = 1$ if $E$ is true and $\mathbb{I}\{E\} = 0$ otherwise. Examples of these tasks and results of meta-learning on some of these were shown in Fig. 1. In Fig. 2 we show the test errors for various meta-learners while varying the number of tasks $n$ and task sizes $m$ . For the 'spherical' data, the same is shown in Fig. 3. Here, we generate $\pmb{x}$ from a $d = 42$ dimensional unit sphere. In both experiments for sufficiently large number of training tasks the EM-based learner approaches the optimal estimator even when the number of examples per task is less than the dimensionality of that task. + +In the context of the 'Fourier' dataset, we also experimented with generating low-rank $\Sigma$ , corresponding to the challenge of learning a low-dimensional representation, shared across the tasks. We found that the EM-based meta learner stays competitive in this setting. To save space, the results are presented in Appendix G. + +Real Dataset Experiment. We also conducted experiments on a real world dataset containing information about students in 139 schools in years 1985-1987 (Dua & Graff, 2017, School Dataset). We adapt the dataset to a meta-learning problem with the goal to predict the exam score of students based on the student-specific and school-specific features. After one-hot encoding of the categorical values there are $d = 27$ features for each student. We randomly split schools into two subsets: The first, consisting of 100 schools, forms $\mathcal{D}^{\backslash n}$ (used for training the bias, $\lambda$ selection, and EM). The second subset consists of 39 schools, where each school is further split into $80\% / 20\%$ for the final training and testing of the meta-learners. Results are given in Fig. 4. We can see that while both Biased Regression and EM Learner outperform regression, their performance is very similar. This could be attributed to the fact that the features mostly contain weakly relevant information, which is confirmed by inspecting the coefficient vector. + +Representation learning experiments I. Our next figure (Fig. 5) shows the outcomes of experiments for the Fourier task but when $\Sigma$ is low-rank. As can be seen, the EM based + +![](images/80f041d44bab67ded8171e41791572b886fcfa0bd8fc8973e422767dc3876db1.jpg) +Figure 2. Test errors on Fourier synthetic experiment with changing number of tasks $n$ and number of samples per task $m$ . When one of the parameters changes, the other one is set to 10. + +![](images/a111ca33da580a8b0b2dcadbb22a298cea167311dfbf3897f17a70ed8a220c68.jpg) + +![](images/457d37ef03d4d46659a5d960a9091e6cc553f0d9e565efa0aaa667bbcf23f306.jpg) +Figure 3. Test error on spherical synthetic experiment with changing number of tasks $n$ and number of samples per task $m$ . When one of the parameters changes, the other one is set to 40. + +![](images/21ab0a9b158ed6435c8c572099925ce4121d307cbbbf1ee3178763d1ac0d79e9.jpg) + +![](images/d6a1b493196522ca8bfced89baeee36e5299cc5c36609442206c7a80fec66a41.jpg) +Figure 4. Test error on the School Dataset. Up to 100 schools are used for fitting environment-related parameters (see text for details) and the remaining 39 are used as the target task. + +learner excels in exploiting the low-rank structure. For this experiment we have the same setup as for the Fourier experiment, but the covariance matrix $\pmb{\Sigma}$ is generated by computing $\pmb{\Sigma} = \mathbf{L}\mathbf{L}^{\top}$ where $\mathbf{L}$ is a $d\times r$ matrix with $r = \lfloor d / 2\rfloor = 5$ and elements $L_{i,j}\sim \mathcal{N}(0,1)$ . Note that in this case we can write $\theta_{i} = \mathbf{B}\boldsymbol{w}_{i}$ for some matrix $\mathbf{B}$ of size $d\times r$ and vector $\mathbf{w}_i$ of size $r$ sampled from multivariate normal + +distribution. Thus, if the matrix $\mathbf{B}$ is known or estimated during training, one can project the features $\boldsymbol{x}_{i,j}$ onto a lower-dimensional space by computing $\mathbf{B}^{\top}\boldsymbol{x}_{i,j}$ to speed up the adaptation to new tasks by running least-squares regression to estimate $\boldsymbol{w}_i$ instead of $\boldsymbol{\theta}_i$ . + +In addition to the baselines described in the main text, we compared EM Learner with two additional baselines: one is based on the Method of Moments (MoM) estimator from Tripuraneni et al. (2020) (not shown on the figure), and another which we refer to as Oracle Representation. We omit displaying the error of the method of moments estimator since for the features generated as in this experiment it is not able to perform estimation of the subspace and leads to test errors with values around 60. At the same time, as shown on Fig. 5 (left) we observe that EM Learner can outperform Oracle Representation which assumes the knowledge of the covariance matrix $\Sigma$ from which it computes the subspace matrix $\mathbf{B}$ and uses it to obtain lower-dimensional representation of the features when adapting to a new task via least-squares, as described above. This is possible because the coefficients estimated by EM are biased toward $\alpha$ which does not happen with least squares regression in the lower + +![](images/4688c535beac546466efc20d282030765b4b9d4976e715979b18b8558586dadc.jpg) +Figure 5. Test error when the task covariance matrix is low-rank. As usual, on the left the number of tasks is changed, on the right, the number of training datapoints (per task). When one parameter is varied, the other is set to the value of 10. + +![](images/54688b75384ea0e58b95c0bc3ea83bbb608858283da0044d114871cb895dbf4b.jpg) + +![](images/96d114b8c1bb87e82344892ea6fc374953953a33ee9dfd0fe615c7d85438e9a8.jpg) +Figure 6. Max-correlation $d_{\mathrm{max}}(\hat{B}, B)$ between the estimated matrix $\hat{B}$ (by the respective algorithm) and the ground truth matrix $B$ while increasing number of tasks $n$ . + +dimensional subspace and this is beneficial, especially when the number of test-task training examples is small. + +Representation learning experiments II. To validate our implementation of the MoM estimator of Tripuraneni et al. (2020) and to investigate more whether EM is preferable to the MoM estimator beyond the setting that is ideal for the EM method we considered the experimental setup of Tripuraneni et al. (2020). + +To explain the setup, we recall that the MoM estimator computes an estimate $\hat{B}$ of the ground truth matrix $B$ . Tripuraneni et al. (2020) proves results for the max-correlation between $\hat{B}$ and $B$ , and also reports experimentally measured max-correlation values between the ground truth and the MoM computed matrix. The max-correlation between matrices $A$ and $A'$ is based on the definition of principal angles and is equal to $d_{\max}(A, A') = \sqrt{1 - \cos^2(A, A')}$ where $\cos(A, A') = \max_{u \in \operatorname{span}(A): \|u\| = 1} \max_{v \in \operatorname{span}(A'): \|v\| = 1} u^\top v$ . Intuitively, max-correlation captures how well the subspaces spanned by matrices $A$ and $A'$ are aligned. + +To compare our EM estimator to MoM we run the EM estimator as described in Algorithm 1, and once the final estimate $\hat{\Sigma}$ is obtained, we reduce its rank by clipping eigenvalues $\lambda_{s+1} \geq \ldots \geq \lambda_d$ to 0. + +We follow the experimental setup of Tripuraneni et al. (2020), that is, inputs are generated as $\boldsymbol{x}_i \sim \mathcal{N}(0, \boldsymbol{I}_d)$ , while the regression model is given by Eq. (1) with $(\sigma^2, \Sigma) = (1, \frac{1}{s} BB^\top)$ . Here, columns of $B \in \mathbb{R}^{d \times s}$ are sampled from a uniform distribution on a unit $d$ -sphere. Finally, the number of examples per previously observed task is set as $m_1 = \ldots = m_{n-1} = 5$ , the representation rank is $s = 5$ , the input dimension is $d = 100$ , and the experiment is repeated 30 times. Since we only estimate the subspace matrix we do not use the data from the test task $(X_n, y_n)$ . + +We report our results in Fig. 6, plotting the max-correlation between $\hat{B}$ found by the respective algorithm and $B$ , while increasing the number of tasks. We see that EM learner considerably outperforms MoM Representation in terms of the subspace estimation to the degree captured by max-correlation. While we suspect that the improvement is due to the joint optimization over the covariance of environment and the mean of the environment (the bias in biased regularization), the detailed understanding of this effect is left for the future work. + +# 7. Conclusions + +While ours is the first work to derive matching, distribution-dependent lower and upper bounds, much works remains to be done: our approach to derive meta-learning algorithms based on a probabilistic model should be applicable more broadly and could lead to further interesting developments in meta-learning. The most interesting narrower question is to theoretically analyze the EM algorithm. Doing this in the low-rank setting looks particularly interesting. We hope that our paper will inspire other researchers to do further work in this area. + +# References + +Baxter, J. Theoretical models of learning to learn. In S. Thrun, L. P. (ed.), Learning to learn, pp. 71-94. Springer, 1998. +Baxter, J. A model of inductive bias learning. Journal of Artificial Intelligence Research, 12:149-198, 2000. +Bretagnolle, J. and Huber, C. Estimation des densités: risque minimax. Zeitschrift für Wahrscheinlichkeitstheorie und verwandte Gebiete, 47(2):119-137, 1979. +Dempster, A. P., Laird, N. M., and Rubin, D. B. Maximum likelihood from incomplete data via the em algorithm. Journal of the Royal Statistical Society: Series B (Methodological), 39(1):1-22, 1977. +Denevi, G., Ciliberto, C., Stamos, D., and Pontil, M. Learning to learn around a common mean. In Conference on Neural Information Processing Systems (NeurIPS), pp. 10169-10179, 2018. +Denevi, G., Ciliberto, C., Grazzi, R., and Pontil, M. Learning-to-learn stochastic gradient descent with biased regularization. In International Conference on Machine Learning (ICML), 2019. +Du, S. S., Hu, W., Kakade, S. M., Lee, J. D., and Lei, Q. Few-shot learning via learning the representation, provably. arXiv:2002.09434, 2020. +Dua, D. and Graff, C. UCI machine learning repository, 2017. URL http://archive.ics.uci.edu/ml. +Finn, C., Abbeel, P., and Levine, S. Model-agnostic meta-learning for fast adaptation of deep networks. In International Conference on Machine Learning (ICML), 2017. +Finn, C., Rajeswaran, A., Kakade, S., and Levine, S. Online meta-learning. International Conference on Machine Learning (ICML), 2019. +Khodak, M., Balcan, M.-F., and Talwalkar, A. Provable guarantees for gradient-based meta-learning. In International Conference on Machine Learning (ICML), pp. 424-433, 2019a. +Khodak, M., Balcan, M.-F. F., and Talwalkar, A. S. Adaptive gradient-based meta-learning methods. Advances in Neural Information Processing Systems, 32:5917-5928, 2019b. +Kuzborskij, I. and Orabona, F. Stability and Hypothesis Transfer Learning. In International Conference on Machine Learning (ICML), pp. 942-950, 2013. +Kuzborskij, I. and Orabona, F. Fast Rates by Transferring from Auxiliary Hypotheses. Machine Learning, pp. 1-25, 2016. ISSN 1573-0565. doi: 10.1007/s10994-016-5594-4. + +Lattimore, T. and Szepesvári, C. Bandit algorithms. Cambridge University Press, 2018. +Lucas, J., Ren, M., Kameni, I., Pitassi, T., and Zemel, R. Theoretical bounds on estimation error for meta-learning. In International Conference on Learning Representations, 2021. +Maurer, A. Algorithmic stability and meta-learning. Journal of Machine Learning Research, 6(Jun):967-994, 2005. +Maurer, A. Transfer bounds for linear feature learning. Machine Learning, 75(3):327-350, 2009. +Maurer, A., Pontil, M., and Romera-Paredes, B. The benefit of multitask representation learning. Journal of Machine Learning Research, 2016. +Pentina, A. and Lampert, C. A pac-bayesian bound for lifelong learning. In International Conference on Machine Learning (ICML), pp. 991-999, 2014. +Tripuraneni, N., Jin, C., and Jordan, M. I. Provable meta-learning of linear representations. arXiv:2002.11684, 2020. +Yang, J., Yan, R., and Hauptmann, A. G. Cross-domain video concept detection using adaptive svms. In Proceedings of the 15th ACM international conference on Multimedia, pp. 188-197, 2007. \ No newline at end of file diff --git a/adistributiondependentanalysisofmetalearning/images.zip b/adistributiondependentanalysisofmetalearning/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..db3acef709b73216e8076b8f62742216f61ef1e0 --- /dev/null +++ b/adistributiondependentanalysisofmetalearning/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:261b5e5ff19a4e4f57dbf169c1f756c6f33206a3f2e54eec443f7b64a713a499 +size 371786 diff --git a/adistributiondependentanalysisofmetalearning/layout.json b/adistributiondependentanalysisofmetalearning/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..029505d5ff076d103672cb790548fbef9babf834 --- /dev/null +++ b/adistributiondependentanalysisofmetalearning/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d13ff0e4c5a8b5ca4f1cfa6f3aac03ee151ecc45abcb91377cdb9f6a64b898ca +size 562420 diff --git a/aframeworkforprivatematrixanalysisinslidingwindowmodel/549f9551-ce0a-437b-a081-f1b54147a939_content_list.json b/aframeworkforprivatematrixanalysisinslidingwindowmodel/549f9551-ce0a-437b-a081-f1b54147a939_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..8e84932bcef8965a393da732a53284860928ff40 --- /dev/null +++ b/aframeworkforprivatematrixanalysisinslidingwindowmodel/549f9551-ce0a-437b-a081-f1b54147a939_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:06bcc7e08f21f67da4855729fe6ca981b54d8cf1345474ad6796353cac3047fd +size 86736 diff --git a/aframeworkforprivatematrixanalysisinslidingwindowmodel/549f9551-ce0a-437b-a081-f1b54147a939_model.json b/aframeworkforprivatematrixanalysisinslidingwindowmodel/549f9551-ce0a-437b-a081-f1b54147a939_model.json new file mode 100644 index 0000000000000000000000000000000000000000..441c582a2a1b18a972737973524b9fc258e8de81 --- /dev/null +++ b/aframeworkforprivatematrixanalysisinslidingwindowmodel/549f9551-ce0a-437b-a081-f1b54147a939_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5308bd2dbecb9ab68058b6cb7c5b046a7d1accf48177ea21b78db17792719018 +size 105934 diff --git a/aframeworkforprivatematrixanalysisinslidingwindowmodel/549f9551-ce0a-437b-a081-f1b54147a939_origin.pdf b/aframeworkforprivatematrixanalysisinslidingwindowmodel/549f9551-ce0a-437b-a081-f1b54147a939_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..b5d4b2b27d87cf90f069e78fdbd37abd95619b4d --- /dev/null +++ b/aframeworkforprivatematrixanalysisinslidingwindowmodel/549f9551-ce0a-437b-a081-f1b54147a939_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:093364b5f5214acd98885660a153214f906ba6145feb44d561b1430d363e67f9 +size 766930 diff --git a/aframeworkforprivatematrixanalysisinslidingwindowmodel/full.md b/aframeworkforprivatematrixanalysisinslidingwindowmodel/full.md new file mode 100644 index 0000000000000000000000000000000000000000..31b3d514503f33e05c524520986c30296cc11152 --- /dev/null +++ b/aframeworkforprivatematrixanalysisinslidingwindowmodel/full.md @@ -0,0 +1,356 @@ +# A Framework for Private Matrix Analysis in Sliding Window Model + +Jalaj Upadhyay $^{*1}$ Sarvagya Upadhyay $^{*2}$ + +# Abstract + +We perform a rigorous study of private matrix analysis when only the last $W$ updates to matrices are considered useful for analysis. We show the existing framework in the non-private setting is not robust to noise required for privacy. We then propose a framework robust to noise and use it to give first efficient $o(W)$ space differentially private algorithms for spectral approximation, principal component analysis (PCA), multi-response linear regression, sparse PCA, and non-negative PCA. Prior to our work, no such result was known for sparse and non-negative differentially private PCA even in the static data setting. We also give a lower bound to demonstrate the cost of privacy. + +# 1. Introduction + +Matrix analysis manifests itself in many walks of life such as financial transactions, recommendation system, social networks, machine learning, and learning kernels. In the recent past, there has been a paradigm shift in matrix analysis in the era of big data. Two aspects that have become increasingly important are (i) protecting sensitive information and (ii) the increasing frequency with which data is being continuously updated. An example that illustrates the importance of these two aspects arises in several investment strategies in a financial firm. The strategies rely on matrix analysis (such as principal component analysis) of financial data that get continuously updated. Most of these strategies make use of "recent data" as opposed to the entire history. This heuristic is rooted in the empirical observation that recent data are better predictors of the future behavior of assets than older data (Moore et al., 2013; Tsay, 2005), a theme also found in many other applications of matrix analysis (Campos et al., 2014; Quadrana et al., 2018). + +Moreover, the strategies are sensitive and have to be kept private. It is well documented that performing statistical + +*Equal contribution 1Apple, USA (work done when the author was between jobs). 2Fujitsu Research of America, USA. Correspondence to: Jalaj Upadhyay . + +Proceedings of the $38^{th}$ International Conference on Machine Learning, PMLR 139, 2021. Copyright 2021 by the author(s). + +analysis, including matrix analysis, accurately can leak private information (Narayanan & Shmatikov, 2006). As a result, privacy preserving algorithms for matrix analysis with robust privacy guarantees such as differential privacy are known (Amin et al., 2019; Blum et al., 2005; Dwork et al., 2014; Kapralov & Talwar, 2013; McSherry & Mironov, 2009; Hardt & Price, 2014; Hardt & Roth, 2012; Upadhyay, 2018)). However, these algorithms are not amenable to the scenario where a collection of the most recent updates on data is pertinent for analysis. In contrast, the current practical deployment of private algorithms (Erlingsson et al., 2014; Thakurta et al., 2017) favors using only recent data for a variety of reasons. + +In view of this, we focus on a rigorous and comprehensive study of privacy-preserving matrix analysis in the sliding window model of privacy (Bolot et al., 2013; Chan et al., 2012; Upadhyay, 2019). The model is parameterized by the window size $W$ , and assumes that the data arrive in the form of (possibly infinite) stream over time. An analyst is required to perform the analysis only on the $W$ most recent streams of data (usually referred to as a sliding window) using $o(W)$ space. On the other hand, privacy is guaranteed for the entire historical data, i.e., even if the data is not in the current window, its privacy should not be compromised. + +We give $o(W)$ space differentially private algorithms for several matrix analysis problems in the sliding window model (see, Table 1). Here and henceforth, $o(W)$ will ignore other factors such as matrix dimensions and privacy parameters. + +A brief overview of our main contributions are as follows (and annotate each of the points below with the corresponding appendix in the supplementary material). + +1. (Limitations of known framework and algorithm). We show that existing framework of spectral histogram used in the non-private setting (Braverman et al., 2020) is too stringent for privacy and algorithms in that framework are not robust to perturbation required for privacy. We show rigorously that the strict constraint imposed by spectral histogram only permits sub-optimal accurate private algorithms (Appendix B). That is, adding appropriately scaled noise to the algorithm of (Braverman et al., 2020) does not suffice. This warrants a robust framework for private matrix analysis. + +
PrivacyAdditive errorSpace requiredReference
η-spectral approximation(ε,δ)-DPO(r2log2(1/δ)/ε2) 1dO(r2d/η log W)Theorem 13
Principal component analysis (PCA)(ε,δ)-DPO(√kd log(1/δ)/ε)O(dk2/η3 log W)Theorem 16
Sparse and Non-negative PCA(ε,δ)-DPO(√kd log(1/δ)/ε)O(dk2/η3 log W)Theorem 17
Multiple linear regression(ε,δ)-DPO(d(d+log(1/δ)/ε))O(d3/η log W)Theorem 18
Directional variance query(ε,δ)-DPO(d(d+log(1/δ)/ε))O(d3/η log W)Theorem 11
+ +Table 1. Results presented in this paper (W: window size, $k$ : target rank, $d$ : dimension of streamed row, privacy parameters $\left( {\epsilon ,\delta }\right) ,{\mathbb{1}}_{d}$ is a $d \times d$ identity matrix, $r$ : rank of streamed matrix). + +2. (New framework and data structure). We introduce a relaxation of spectral histogram property on a set of positive semidefinite (PSD) matrices that is more robust to noise and call it approximate spectral histogram property. We also design an update time efficient data structure that maintains the approximate spectral histogram property on a set of PSD matrices while preserving differential privacy (Appendix C). +3. (Optimal algorithms for matrix analysis). We use approximate spectral histogram property to efficiently compute private spectral approximation. Using this, we solve several matrix analysis problems in the sliding window model while preserving privacy and optimal accuracy in Appendix D: (i) principal component analysis (PCA); (ii) directional variance queries; and (iii) multi-response linear regression. We also give algorithm for private constrained PCA (Cohen et al., 2015). This generalizes many variants of PCA studied in statistical machine learning such as sparse PCA and non-negative PCA. +4. (Limitation of private sliding window algorithms). Finally, to complete the picture, we exhibit limitations of private matrix analysis by giving a lower bound on differentially private algorithm for low-rank approximation in the sliding window model (Appendix E). + +There is a known separation between what is achievable with privacy and without privacy for real-valued functions in the sliding window model (Upadhyay, 2019). Our work can be seen as extending this study to matrix-valued functions in a unified manner. Conceptually, approximate spectral histogram property can be viewed as a generalization of subspace embedding property (Sarlós, 2006). This allows us to use approximate spectral histogram property in the sliding window model in the same way as subspace embedding is employed in the streaming model of privacy (Upadhyay, 2018). Given the wide application of subspace embedding in streaming algorithms, we believe that the notion of approximate spectral histogram will have further applications in the sliding window model of privacy. + +A natural question one may ask is why we need to introduce approximate spectral histogram property in the sliding window model of privacy. We end this section with a discussion on this (more details in Section 2). Let us consider the spectral approximation of matrices. There is one private algorithm (Blocki et al., 2012) which relies on subspace embedding. They explicitly compute the singular value decomposition of the matrix making it suitable only for static data matrix. Furthermore, we cannot just take off-the-shelf algorithm and add noise matrix to preserve privacy as well as guarantee non-trivial utility and efficiency. To begin with, standard noise mechanisms would result in a matrix that is not positive semidefinite. This is, for example, the mechanism in Dwork et al. (2014). If we instead use the projection trick of Arora & Upadhyay (2019) on top of Dwork et al. (2014), it would incur noise that scales with the dimension and have an inefficient update time. Moreover, the existing randomized space-efficient algorithm of Braverman et al. (2020) performs sampling proportional to its leverage score. As a result, the effect of a single row in the matrix formed by this sampling procedure can be arbitrarily large, and consequently, the sensitivity is high1. + +Notations. For a natural number $n$ , the notation $[n]$ denotes the set $\{1, \ldots, n\}$ . The Euclidean norm of a vector $v \in \mathbb{R}^d$ is denoted by $||v||_2$ . For a rank- $r$ matrix $A \in \mathbb{R}^{n \times d}$ , we let the tuple $(s_1(A), s_2(A), \ldots, s_r(A))$ denote the non-zero singular values of $A$ arranged in decreasing order, $A^\top$ to denote transpose of $A$ , and $\|A\|_F$ to denote its Frobenius norm. The $i$ -th row vector and the $j$ -th column vector of a matrix $A$ are denoted by $A[i:]$ and $A[:j]$ , respectively. We use $\|A[:j]\|_2$ and $\|A[i:]\|_2$ to denote their Euclidean norms. We use $\mathbb{1}_d$ to denote identity matrix of dimension $d$ . If all the eigenvalues of a symmetrix matrix $S \in \mathbb{R}^{d \times d}$ are nonnegative, then the matrix is known as positive semidefinite (PSD for short) and is denoted by $S \succeq 0$ . For symmetric + +![](images/77407cbf8edb4d3661676a877bd7480c18e2c977aadf5c519714c94de3f3e6a7.jpg) +Figure 1. Dependency graph of various results (bold lines shows optimal results and dashed lines shows suboptimal results, orange boxes are datastructure). For example, a datastructure satisfying $\eta$ -approximate spectral histogram implies an algorithm for spectral approximation, and so on. All our algorithms extend to the streaming model as well by setting $W = T$ . + +matrices $A, B \in \mathbb{R}^{d \times d}$ , the notations $A \preceq B$ implies that $B - A$ is PSD and $A \not\preceq B$ implies that $B - A$ is not a PSD. For any $T, d > 0$ , we use $\mathsf{N}_{T,d}$ to denote the following set of $T \times d$ matrices: + +$$ +\begin{array}{c} \mathsf {N} _ {T, d} := \big \{B \in \mathbb {R} ^ {T \times d}: \exists i \in [ T ] \text {s u c h t h a t} \| B [ i: ] \| _ {2} \leq 1 \\ \text {a n d} \| B [ j: ] \| _ {2} = 0 \text {f o r a l l} j \neq i \big \}. \end{array} +$$ + +A comprehensive overview of preliminaries and notations is presented in Appendix A. + +# 1.1. Sliding window, privacy, and matrix analysis + +We start by defining some additional notations pertinent to studying matrix analysis in the sliding window model. The matrix formed by $d$ -dimensional row vectors streamed between time stamps $t_1$ and $t_2$ is denoted $A_{[t_1,t_2]}$ . We define $A_W(T) \coloneqq A_{[T - W + 1,t]}$ for any current timestamp $T$ where $W$ is used to denote the window size and $A_T \coloneqq A_{[0,T]}$ . The matrix $A_T$ can be obtained by setting $W = T$ and gives us the insertion only streaming model (Muthukrishnan, 2005). The matrix $A_W(T) \in \mathbb{R}^{W \times d}$ is formed incrementally through a stream of $d$ -dimensional row vectors $\{a_i : T - W + 1 \leq i \leq T\}$ as follows: + +$$ +A _ {W} (T) := \left( \begin{array}{c} a _ {T - W + 1} \\ \vdots \\ a _ {T - 1} \\ a _ {T} \end{array} \right) \in \mathbb {R} ^ {W \times d}. \tag {1} +$$ + +At start, the matrix $A_W(0)$ is an all zero matrix (with $a_i = 0^d$ if $i \leq 0$ ). At any time $T$ , we are interested in performing various analysis on the matrix $A_W(T)$ . Our results are independent of the current time stamp $T$ , and we will slightly abuse the notation by letting $A_W = A_W(T)$ as the matrix formed by rows streamed in the last $W$ updates. + +We now formalize the privacy model. We adhere to the neighboring relation employed in existing literature study + +ing matrix analysis in static setting (Blocki et al., 2012; Hardt & Roth, 2012; Dwork et al., 2014; Sheffet, 2019) and streaming setting (Upadhyay, 2018). + +In privacy literature, there are two well-studied levels of granularity when the data arrives in an online manner (Bolot et al., 2013; Chan et al., 2011; 2012; Dwork et al., 2010; Dwork & Roth, 2014; Upadhyay, 2018; 2019): (i) user-level privacy, where two streams are neighboring if they differ in a single user's data; and (ii) event-level privacy, where two streams are neighboring if they differ in one-time epoch. We follow previous works on private analysis in the sliding window model (Bolot et al., 2013; Chan et al., 2012; Huang et al., 2021) and consider event-level privacy. We say that two streams are neighboring if, at any time $T > 0$ , they form matrices $A_{T}$ and $A_{T}^{\prime}$ such that $A_{T} - A_{T}^{\prime} \in \mathsf{N}_{T,d}$ . We now define the privacy notion that extends the privacy notion of Bolot et al. (2013); Chan et al. (2012); Huang et al. (2021); Upadhyay et al. (2021) and Upadhyay (2019) to general matrices. + +Definition 1 (Differential privacy under sliding window model). For $\epsilon \geq 0, \delta \in [0,1]$ , we say a randomized algorithm $\mathcal{M}$ with range $\Upsilon$ is $(\epsilon, \delta)$ -differentially private in the sliding window model if for all $T > 0$ , for every two matrices $A_T$ and $A_T'$ formed by neighboring streams, and for all $\mathsf{S} \subseteq \Upsilon$ , $\operatorname*{Pr}[\mathcal{M}(A_T) \in \mathsf{S}] \leq \exp(\epsilon) \operatorname*{Pr}[\mathcal{M}(A_T') \in \mathsf{S}] + \delta$ , where the probability is over the private coin tosses of $M$ . + +Note that the privacy guarantee is for the entire stream, i.e., even if the data has expired, its privacy is not lost. However, accuracy is required only for the last $W$ updates. This is in accordance with previous problem formulation (Bolot et al., 2013; Chan et al., 2012; Upadhyay, 2019). + +The central algebraic concept underlying all analysis of interest in this paper is the spectrum of a matrix (see Figure 1). Therefore, we focus on privately computing $(\eta, \zeta)$ -spectral approximation, i.e., given parameters $\eta, \zeta \geq 0$ and a matrix + +$A_W \in \mathbb{R}^{W \times d}$ , find a matrix $C \in \mathbb{R}^{d \times d}$ , such that + +$$ +(1 - \eta) A _ {W} ^ {\top} A _ {W} - \nu \mathbb {1} _ {d} \preceq C \preceq (1 + \eta) A _ {W} ^ {\top} A _ {W} + \nu \mathbb {1} _ {d}. +$$ + +Here the parameter $\nu \geq 0$ is the cost of privacy in the terms of distortion in the spectrum. Our goal is to keep $\eta$ as small as possible so that they are useful in subsequent tasks, like PCA, multiple regression, etc. We show the following: + +Theorem 1 (Informal version of Theorem 14). Let $A_W \in \mathbb{R}^{W \times d}$ be a rank- $r$ matrix formed by the current window. Then for $\nu = \xi \log \xi$ where $\xi = O\left(\frac{r \log^2(W / \delta)}{\epsilon^2 \eta}\right)$ , there is an efficient $(\epsilon, \delta)$ -differentially private algorithm under sliding window model that uses $O\left(\frac{dr^2}{\eta^2} \log W\right)$ space and outputs a matrix $C$ at the end of the stream such that + +$$ +(1 - \eta) A _ {W} ^ {\top} A _ {W} - \nu \mathbb {1} _ {d} \preceq C \preceq (1 + \eta) A _ {W} ^ {\top} A _ {W} + \nu \mathbb {1} _ {d}. +$$ + +A special case when the matrix is the edge-adjacency matrices was considered by Upadhyay et al. (2021). In the static setting, using the result of Sarlós (2006) and Blocki et al. (2012), we get an $O(d^{2})$ space private algorithm which guarantees $(\eta, \nu, \nu)$ -spectral approximation for $\nu = O\left(\frac{d\log(1 / \delta)}{\epsilon^2\eta}\right)$ . Non-privately, there is an algorithm in the sliding window model that uses $O\left(\frac{rd}{\eta}\log W\right)$ space if the matrix has a bounded condition number (Braverman et al., 2020). In many practical scenarios, the rank is constant. In this scenario, the privacy overhead is only a constant factor. Our algorithm is also flexible in the sense that we can also guarantee that the output is a PSD matrix. + +Before giving a technical overview of our private algorithm, we begin by arguing why the existing private algorithms in the static setting fail in the sliding window model. Blocki et al. (2012) gave the first privacy preserving approximation of matrices. Their approach is to first compute the singular value decomposition of the given matrix $A = USV^{\top}$ , and then output $C_{\mathsf{BBDS}} = \widehat{A}^{\top}\Phi^{\top}\Phi \widehat{A}$ , where $\widehat{A} := U\sqrt{S^2 + \sigma^2\mathbb{1}_d} V^{\top}$ for a perturbation parameter $\sigma$ chosen appropriately, and $\Phi$ is a random Gaussian matrix. Since, the algorithm requires computing the SVD, one cannot extend this approach in the sliding window model. Another approach, due to Dwork et al. (2014), computes $C_{\mathsf{DTTZ}} = A^{\top}A + N$ , where $N$ is a symmetric Gaussian matrix with appropriate variance. In this case, we cannot revert the effect of the rows outside of the window. + +Private principal component analysis has been extensively studied (Amin et al., 2019; Blum et al., 2005; Dwork et al., 2014; Hardt & Roth, 2012; Upadhyay, 2018; Dwork et al., 2014; Hardt & Price, 2014; Kapralov & Talwar, 2013; Singhal & Steinke, 2021), and matching lower and upper bounds are known on achievable accuracy in the static setting. With the exception of Arora et al. (2018); Upadhyay (2018), + +these algorithms perform at least two passes over the matrix. Dwork et al. (2014) gave an online algorithm for PCA using regularized follow-the-leader framework; however, online model is very different from the sliding window model2. Finally, the algorithm of Arora et al. (2018) and Upadhyay (2018) does not extend to the sliding window model because we cannot revert the effect of the rows that are outside of the current window. + +# 2. Main lemma and overview of techniques + +One-shot vs Continual release. In this section, we focus only on the case when the output is produced just once at the end of the stream for the ease of presentation. Such algorithms are known as one-shot algorithm in the literature of differential privacy and used as a building block for algorithms that continually release statistics. We cover the case of continual release (Dwork et al., 2010) in Appendix F, where we propose two data structures that allow continual release depending on whether space is more important or accuracy. The first approach uses the binary tree method introduced by Bentley & Saxe (1980) and used in Dwork et al. (2010) and Chan et al. (2011). However, unlike them, we build the binary tree only over the current window. This uses space linear in $W$ but incur error that only grows polylogarithmically. In the second approach, we reduce the space requirement to be sublinear in $W$ at the cost of increasing the error. We subdivide each window in to $\sqrt{W}$ sub-windows, each of size $\sqrt{W}$ . We then run an instance of our algorithm for each of these sub-windows. + +We now focus our attention to design a one-shot algorithm. Algorithmically, our approach is closest to Smith et al. (2020). They present a one-shot space-optimal algorithm for distinct element count in a data-stream by showing that the celebrated Flajolet-Martin sketch initiated with some random "phantom" elements (guaranteed to be not in the data set) is differentially private. Similar approaches has been used for computing low-rank approximation of a matrix formed in a streaming manner (Upadhyay, 2018). + +One-shot algorithm. Our one-shot algorithms (on which the continual release algorithms is based) can be seen as a generalization of the technique of Smith et al. (2020) from real-valued functions to matrix-valued functions. We inject an appropriate random matrix to the data stream. However, this would only allows us to perform the analysis on the entire data stream and not just on the current window. That is, we need to resolve the following two related questions: + +1. (Question 1). How to account only for only the relevant part of the streamed data, i.e., one in the window? +2. (Question 2). What distribution of random matrices is to be used to inject phantom random matrices? + +One naive candidate algorithm, $\mathsf{A}_{\mathrm{priv}}$ , for private spectral approximation is as follows: store a set of $w = \min \{W,T\}$ positive semidefinite matrices at any time $T$ , where the $i$ -th matrix in this set is a sanitized version of the matrix formed by the last $i$ updates. In this case, question 1 is answered by just removing any matrix that is out of the window, and question 2 is answered by using Wishart matrix of appropriate scale. However, $\mathsf{A}_{\mathrm{priv}}$ requires prohibitively large $O(Wd^{2})$ space. + +To answer question 1, while using significantly less space (as in Smith et al. (2020)) requires a conceptual contribution. To this end, we introduce $\eta$ -approximate spectral histogram property for a set of PSD matrices and timestamps. We will occasionally refer to such a set as a data structure. + +$\eta$ -approximate spectral histogram property. For a matrix $S\succeq 0$ , denote by $\widetilde{S}$ a matrix such that + +$$ +\left(1 - \frac {\eta}{4}\right) \widetilde {S} \preceq S \preceq \left(1 + \frac {\eta}{4}\right) \widetilde {S}. +$$ + +Let the current window of our matrix analysis be from timestamp $T - W + 1$ to $T$ and $S(i)$ be the covariance matrix of the matrix formed by rows streamed between timestamps $t_i$ and $T$ . In other words, + +$$ +S (i) = A _ {[ t _ {i}, T ]} ^ {\top} A _ {[ t _ {i}, T ]}. +$$ + +Let $\mathfrak{D}$ be a data structure comprised of a collection of $\ell$ timestamps and PSD matrices $\{(t_1, \widetilde{S}(1)), \ldots, (t_\ell, \widetilde{S}(\ell))\}$ for some $\ell \in \mathbb{N}$ . For all $i \in [\ell]$ , $\widetilde{S}_i$ is an $(\eta/4, 0)$ -spectral approximation of the matrix $S_i$ . Roughly speaking, such a data structure $\mathfrak{D}$ satisfies $\eta$ -approximate spectral histogram property if following two listed properties are satisfied.. + +1. The timestamps satisfy the following two requirements: + +$$ +t _ {1} < \dots < t _ {\ell} = T \quad \text {a n d} \quad t _ {1} \leq T - W + 1 \leq t _ {2}. +$$ + +2. These two sets of matrices $\{S(i)\}_{i\in [\ell ]}$ and $\{\widetilde{S} (i)\}_{i\in [\ell ]}$ satisfy the following three conditions: + +$$ +\forall i \in [ \ell - 1 ], S (i + 1) \preceq S (i); +$$ + +$$ +\forall i \in [ \ell - 1 ], (1 - \eta) S (i) \preceq S (i + 1); \text {a n d} \tag {2} +$$ + +$$ +\forall i \in [ \ell - 2 ], \left(1 - \frac {\eta}{2}\right) \widetilde {S} (i) \not \leq \widetilde {S} (i + 2). +$$ + +When it is clear from context, we call a set of matrices $\left\{\widetilde{S}_1,\dots ,\widetilde{S}_\ell \right\}$ as the one satisfying the $\eta$ -approximate spectral histogram property. In contrast, spectral histogram + +Algorithm 1 PHASE 2 $(\mathfrak{M}_{T + 1}^{\prime} = \{\bar{A} (1),\dots ,\bar{A} (\ell +1)\})$ + +$$ +\begin{array}{l} \begin{array}{l} 1: \text {I f} t _ {2} < T - W + 1, \text {s e t} \bar {A} (i) = \bar {A} (i + 1), t _ {i} = t _ {i + 1} \\ \text {f o r a l l} i \in [ \ell - 1 ]. \text {S e t} \ell = \ell - 1 \end{array} \\ 2: \quad \text {D e f i n e} \bar {S} (i) = \bar {A} (i) ^ {\top} \bar {A} (i) \text {f o r a l l} 1 \leq i \leq \ell + 1. \\ 3: \quad \text {F o r} i = 1, \dots \ell - 2 \\ 4: \quad \text {F i n d} j = \max \left\{u > i: (1 - \frac {\eta}{2}) \bar {S} (i) \preceq \bar {S} (u) \right\}. \\ 5: \quad \operatorname {S e t} \mathfrak {M} _ {T + 1} ^ {\prime} \leftarrow \mathfrak {M} _ {T + 1} ^ {\prime} \backslash \{A (i + 1), \dots , A (j - 1) \}. \\ 6: \quad \text {R e o r d e r} \\ 7: \quad \text {U p d a t e} \ell := \ell + i - j + 1. \\ 8: \mathbf {O u t p u t} \mathfrak {M} _ {T + 1} := \mathfrak {M} _ {T + 1} ^ {\prime}. \\ \end{array} +$$ + +in Braverman et al. (2020) requires $\widetilde{S}(i) = S(i)$ and uses the condition $(1 - \eta)S(i) \nleq S(i + 2)$ instead of $(1 - \frac{\eta}{2})\widetilde{S}(i) \nleq \widetilde{S}(i + 2)$ . + +The properties in Equation 2 are required to get the desirable space bound. Likewise, the second condition in Equation 2 and the restriction $t_1 \leq T - W + 1 \leq t_2$ are required to demonstrate the accuracy guarantee (see proof sketch of Theorem 1). Before proving the accuracy guarantee, we answer how to maintain such a set of matrices. For brevity, we introduce the following notation for matrices in the rest of this section: for any time $T$ , we write $A(i)$ to denote the $i$ -th matrix stored in the current data-structure. + +Lemma 1. Let $\mathfrak{M}_T\coloneqq \{A(1),\ldots ,A(\ell)\}$ be the set of matrices such that $\{A(1)^{\top}A(1),\dots,A(\ell)^{\top}A(\ell)\}$ satisfies $\eta$ -approximate spectral histogram property at time $T$ . Then there is an efficient algorithm, UPDATE, that takes $\mathfrak{M}_T$ and a row $a_{T + 1}\in \mathbb{R}^d$ as input and outputs a set of matrices $\mathfrak{M}_{T + 1} = \{B(1),\dots,B(m)\}$ such that $\{B(1)^{\top}B(1),\dots,B(m)^{\top}B(m)\}$ satisfy the $\eta$ -approximate spectral histogram property for some $m\leq$ $\ell +1$ + +When a new row $a_{T + 1} \in \mathbb{R}^d$ is streamed, an algorithm is invoked that updates the data structure. It works in two phases: privatization and maintenance. Privatization is accomplished by (i) adding a linear sketch of $a_{T + 1}$ to all $\ell$ matrices in $\mathfrak{M}_T$ to obtain a new set $\mathfrak{M}_T'$ , (ii) privatizing $a_{T + 1}$ to get a matrix $A(\ell + 1)$ , and (iii) defining $\mathfrak{M}_{T + 1}' := \mathfrak{M}_T' \cup A(\ell + 1)$ . For privacy (or answering Question 2), adding a noise matrix that is a PSD matrix would incur additive error linear in dimension. Moreover, it will not maintain structural properties of matrices such as low-rank, which are one of the reasons why matrix analysis have such a wide array of applications. Therefore, just adding appropriately scaled noise is not an option (see Appendix B for details). As it turns out, a variant of Johnson-Lindenstrauss mechanism (Blocki et al., 2012) used in Upadhyay (2018) suffices for our purpose. + +Now the set $\{\bar{A}^\top \bar{A} : \bar{A} \in \mathfrak{M}_{T+1}'\}$ may not satisfy $\eta$ -approximate spectral histogram property. The maintenance + +phase (high-level description of this phase is provided in Algorithm 1) ensures that the final set of matrices satisfies $\eta$ -approximate spectral histogram property. In this phase, we greedily remove matrices if they do not satisfy any of the desired properties of $\eta$ -approximate spectral histogram property (Algorithm 7 in supplementary material). The computationally expensive part in Algorithm 1 is Step 3. For this step, we can use known PSD testing algorithms (Bakshi et al., 2020). + +Our greedy approach is reminiscent of the potential barrier method to compute spectral sparsification of a $W \times d$ matrix (Batson et al., 2012). In the potential barrier method, we remove a large subset of rank-one matrices and show that only storing $\Theta(d\eta^{-2})$ rank-one matrices suffices for $(\eta, 0)$ -spectral sparsification. This approach does not extend over to streaming matrices. In fact, two key technical features distinguish our method from theirs. In their setting, all PSD matrices are rank-one matrices corresponding to a row of the matrix; whereas we have $W$ positive semidefinite matrices that may have different ranks (not necessarily rank-one). The second crucial point is that we aim to significantly reduce the number of matrices stored for our application. This makes maintaining our data structure much more complicated than the potential barrier method. + +The proof of Lemma 1 is subtle. While it is tempting to use the analysis of the deterministic algorithm by Braverman et al. (2020) in our setting, their analysis is highly susceptible to noise. Their proof relies heavily on the fact that for all $i \in [\ell]$ , $\widetilde{S}(i) = S(i)$ , i.e., matrices are exact covariance matrices corresponding to the streamed rows. In contrast, our analysis deals with the spectral approximation of the streamed matrix along with the perturbation required to preserve privacy. That is, each of the matrices $\widetilde{S}(1), \dots, \widetilde{S}(\ell)$ is an approximation of the input matrix and has both multiplicative approximation as well as additive term. We give an arguably simpler analysis than Braverman et al. (2020) and crucially use the slack of $\left(1 - \frac{\eta}{2}\right)$ factor in the third condition of approximation spectral histogram property (Equation 2). A detail proof of Lemma 1 is presented in Appendix C. + +Spectral approximation. Now that we have an algorithm to maintain $\eta$ -approximate spectral histogram property, we show how to use it to compute an $(\eta, \nu)$ -spectral approximation of $A_W$ . Let $\widetilde{S}(1), \ldots, \widetilde{S}(\ell)$ be the set of matrices satisfying $\eta$ -approximate spectral histogram property. The algorithm outputs $S = \widetilde{S}(1) - \sigma^2 \mathbb{1}_d$ , where $\sigma^2$ is the perturbation posit in the mechanism of Upadhyay (2018). Using the first condition of Equation 2 and that $t_1 < T - W + 1 < t_2$ , $S(2) \preceq A_W^\top A_W \preceq S(1)$ . The second condition of Equation 2 implies that $(1 - \eta)S(1) \preceq S(2)$ . Since $\widetilde{S}(1)$ and $\widetilde{S}(2)$ are a $(\eta/4, 0)$ -spectral approximation of $S(1)$ and $S(2)$ , respectively, this allows us to prove that $\widetilde{S}(1)$ is a + +spectral approximation of $A_W$ . + +Proof sketch of Theorem 1. For space bound, properties in equation (2) imply that there is at least one singular value that decreases by a factor of $(1 - \frac{\eta}{2})$ in every successive timestamp. We will see later that our privacy mechanism ensures that the spectrum of any matrix $\widetilde{S}_i$ is lower bounded by a constant. Since updates have bounded entries, there can be at most $\ell := O\left(r\log_{1 - \frac{\eta}{2}}(W)\right) = O\left(\frac{r}{\eta}\log (W)\right)$ matrices satisfying $\eta$ -approximate spectral histogram. For privacy, we use the Johnson-Lindenstrauss mechanism (Blocki et al., 2012). In this mechanism, we first perturb the matrix to raise its singular value and then multiply it with a random Gaussian matrix. The choice of perturbation used here is the one described in Upadhyay (2018) because it can account for the streamed data. + +Now we give a proof sketch of the accuracy guarantee. At any time $T$ , let $A(i)$ be the matrix formed between the time interval $[t_i, T]$ . Let $\{\widetilde{A}(1), \dots, \widetilde{A}(\ell)\}$ be the set of matrices obtained by applying Johnson-Lindenstrauss mechanism on the streamed matrices $\{A(1), \dots, A(\ell)\}$ and $\{\widehat{A}(1), \dots, \widehat{A}(\ell)\}$ be the set of perturbed matrices before applying the Johnson-Lindenstrauss transform. Fix the following notations for covariance matrices: + +$$ +C (j) := A (j) ^ {\top} A (j), \quad \widetilde {S} (j) := \widetilde {A} (j) ^ {\top} \widetilde {A} (j) +$$ + +$$ +S (j) := \widehat {A} (j) ^ {\top} \widehat {A} (j) = C (j) + \sigma^ {2} \mathbb {1} _ {d}. +$$ + +The perturbation parameter $\sigma$ is as chosen in Sheffet (2019). Since $t_1 \leq T - W + 1 \leq t_2$ , we have $C(2) \preceq A_W^\top A_W \preceq C(1)$ . By design of our algorithm and the second property of $\eta$ -approximate spectral histogram property, we have $(1 - \eta)S(1) \preceq S(2)$ . We pick the dimension of the Johnson-Lindenstrauss transform so that $\widetilde{S}(j)$ is an $(\eta/4,0)$ -spectral approximation of $S(j)$ for all $j \in [\ell]$ using Sarlós (2006)'s result. Therefore, for $i \in \{1,2\}$ , + +$$ +\left(1 - \frac {\eta}{4}\right) S (i) \preceq \widetilde {S} (i) \preceq \left(1 + \frac {\eta}{4}\right) S (i). +$$ + +This implies that $\left(1 - \frac{\eta}{4}\right)\left(C(1) + \sigma^2\mathbb{1}_d\right) \preceq \widetilde{S}(1)$ . Since adding positive semidefinite matrices preserves the Loewner ordering and $A_W^\top A_W \preceq C(1)$ , we get the following: + +$$ +\begin{array}{l} \left(1 - \frac {\eta}{4}\right) \left(A _ {W} ^ {\top} A _ {W} + \sigma^ {2} \mathbb {1} _ {d}\right) \preceq \left(1 - \frac {\eta}{4}\right) (C (1) + \sigma^ {2} \mathbb {1} _ {d}) \\ \succneqq \widetilde {S} (1). \\ \end{array} +$$ + +Similarly, for the upper bound, we have from the definition, + +$$ +\begin{array}{l} \widetilde {S} (1) \preceq \left(1 + \frac {\eta}{4}\right) S (1) \preceq \frac {\left(1 + \frac {\eta}{4}\right)}{(1 - \eta)} S (2) \\ = \frac {\left(1 + \frac {\eta}{4}\right)}{\left(1 - \eta\right)} (C (2) + \sigma^ {2} \mathbb {1} _ {d}). \\ \end{array} +$$ + +Using the fact that $C(2) \preceq A_W^\top A_W$ , scaling $\eta$ and setting the value of $\sigma$ completes the proof. + +# 3. Applications + +We present three main applications of $\eta$ -approximate spectral histogram property for matrix analysis. + +Applications I: Principal component analysis. Principal component analysis is an extensively used subroutine in many applications like clustering (Cohen et al., 2015), recommendation systems (Drineas et al., 2002), and learning distributions (Achlioptas & McSherry, 2005). In these applications, given a matrix $A \in \mathbb{R}^{n \times d}$ and a target rank $k$ , the goal is to output a rank- $k$ orthonormal projection matrix $P \in \mathbb{R}^{d \times d}$ such that + +$$ +\| A - A P \| _ {F} \leq (1 + \eta) \min _ {\operatorname {r a n k} (X) \leq k} \| A - X \| _ {F} + \zeta . +$$ + +The goal here is to minimize $\zeta$ for a given $k, d$ , and privacy parameters $\epsilon$ and $\delta$ . In many applications, instead of optimizing over all rank- $k$ projection matrices, we are required to optimize over a smaller set of projection matrices, such as one with only non-negative entries. In particular, let $\Pi$ be any set of rank- $k$ projection matrices (not necessarily set of all rank- $k$ projection matrices). Then the constrained principal component analysis is to find $P^{*} = \operatorname{argmin}_{P \in \Pi} \|A - AP\|_{F}^{2}$ . + +A naive application of approximate spectral histogram property to solve PCA leads to an additive error that depends linearly on the rank of the streamed matrix. To solve these problems with optimal accuracy, we introduce an intermediate problem that we call private projection preserving summary (Definition 8). This problem can be seen as a private analogue of PCP sketches (Cohen et al., 2015). Solving this problem ensures that the additive error scales with the parameter $k$ and not with the rank of the matrix. + +To remove the dependency on the rank of the streamed matrix, we consider the first $k / \eta$ spectrum of the streamed matrix and show that it suffices for our purpose. That is, let $\widetilde{A}_1,\dots ,\widetilde{A}_{\ell}$ be matrices such that their covariance matrices $\widetilde{S}_1,\dots ,\widetilde{S}_{\ell}$ satisfy $\eta$ -approximate spectral histogram property. We show that random projections of $\widetilde{A}_1,\dots ,\widetilde{A}_{\ell}$ to a $k / \eta$ dimensional linear subspace suffice. Let $\pi_{k / \eta}(\widetilde{A}_1),\dots ,\pi_{k / \eta}(\widetilde{A}_{\ell})$ be the projected matrices. We show that the set of covariance matrices corresponding to $\pi_{k / \eta}(\widetilde{A}_1),\dots ,\pi_{k / \eta}(\widetilde{A}_{\ell})$ satisfy the approximate spectral histogram property. Using this, we show that the first matrix in this set, $\widetilde{A} := \pi_{k / \eta}(\widetilde{A}_1)$ , is a private projection preserving summary for $A_W$ with a small additive error. For this, we make use of the private version of one of the characterizations of projection preserving summary due to (Cohen et al., 2015). This characterization is crucial as it defines + +the multiplicative approximation as well as additive error. + +Lemma 2 (Informal version of Lemma 11). Let $k$ be the desired rank, $\eta$ be the approximation parameter, and $(\epsilon, \delta)$ be the privacy parameter. Let $\Pi$ be the set of all rank- $k$ projection matrices. Then there is an efficient $(\epsilon, \delta)$ -differentially private algorithm under sliding window model that for a given matrix $A_W$ formed by the current window, outputs a matrix $\tilde{A}$ such that for any $P \in \Pi$ , + +$$ +\begin{array}{l} \left\| \widetilde {A} (\mathbb {1} _ {d} - P) \right\| _ {F} \leq (1 + \eta) \| A _ {W} (\mathbb {1} _ {d} - P) \| _ {F} \\ + O \left(\frac {1}{\alpha \epsilon} \sqrt {k d \log (d) \log^ {2} \left(\frac {W}{\delta}\right)}\right). \\ \end{array} +$$ + +This lemma allows us to show the first result to solve constrained PCA. + +Theorem 2 (Informal version of Theorem 17). Let $A_W$ be the matrix formed by last $W$ updates and $\Pi$ be a given set of rank- $k$ projection matrices. Then there is an $(\epsilon, \delta)$ -differentially private algorithm that outputs a matrix $\widetilde{A}$ at the end of the stream, such that if $\| \widetilde{A}(\mathbb{1}_d - P) \|_F \leq \gamma \cdot \min_{X \in \Pi} \| \widetilde{A}(\mathbb{1}_d - X) \|_F$ for some $\gamma > 0$ and $P \in \Pi$ , then + +$$ +\begin{array}{l} \left\| A _ {W} \left(\mathbb {1} _ {d} - P\right) \right\| _ {F} \leq (1 + \eta) \gamma \cdot \min _ {X \in \Pi} \left\| A _ {W} \left(\mathbb {1} _ {d} - X\right) \right\| _ {F} \\ + O \left(\frac {1}{\alpha \epsilon} \sqrt {k d \log (d) \log^ {2} \left(\frac {W}{\delta}\right)}\right). \\ \end{array} +$$ + +The matrix $P$ in the above result can be computed by running any known non-private algorithm on $A$ . There are existing results for structured projection matrices, such as Asteris et al. (2014); Yuan & Zhang (2013). In particular, if $\Pi$ is a set of sparse or non-negative projection matrices, then Theorem 17 gives a way to solve these problems privately. Moreover, Theorem 17 also implies a private algorithm for PCA by using any algorithm for PCA that achieves $\gamma = 1$ (Eckart & Young, 1936). + +For traditional PCA, Corollary 4.5 in Hardt & Roth (2012) gives a rank- $p$ projection matrix for $p > 2k$ with a large constant multiplicative approximation and $O\left(\frac{k\sqrt{d}}{\epsilon^2}\right)$ additive error. The underlying reason for this large constant factor is because they use Markov inequality after using the expectation bound of Halko et al. (2011). We avoid this by appealing to the results that use the concentration property of random Gaussian matrices (Kane & Nelson, 2014). + +We finally remark that we do not violate the lower bound of Dwork et al. (2014). Their lower bound holds when there is no multiplicative approximation. They show similar upper bound as Theorem 17 when matrices has a singular value gap of $\Omega (\sqrt{d})$ . In contrast to their $O(d^{2})$ space algorithm, we make use of $O\left(\frac{dk^2}{\eta^3}\log W\right)$ space in the + +
Additive ErrorMultiplicativeSpace RequiredComments
Hardt & Roth (2012)O(k√d/ε2)O(1)O(d2)rank-2k, static data
Dwork et al. (2014)O(ε-1k√d)-O(d2)Static data
Upadhyay (2018)O(ε-1√kd)(1+η)O(η-1dk)Streaming data
Lower BoundΩ(√kd)(1+η)Ω(η-1dk log W)Sliding window
This PaperO(ε-1√kd)(1+η)O(η-3dk2 log W)Sliding window
+ +Table 2. Comparison of $\left( {\epsilon ,\Theta \left( {{d}^{-\log d}}\right) }\right)$ -Differentially private PCA results (our results are in red). + +sliding window setting, which is an improvement whenever $k \log(W) = o(\eta^3 d)$ . We also note that Dwork et al. (2014) studied PCA in the online learning model (Hazan, 2019), which is incomparable to the sliding window model. + +Application II: Multi-response linear regression. Another application of Theorem 1 is solving multi-response linear regression (also known as generalized linear regression) in the sliding window model. It is a widely studied generalization of the standard $\ell_2$ -regression (Woodruff, 2014). Formally, given two matrices $A \in \mathbb{R}^{n \times d}$ and $B \in \mathbb{R}^{n \times p}$ as input, the multi-response linear regression is defined as the minimization problem, $\min_{X \in \mathbb{R}^{d \times p}} \|AX - B\|_F^2$ . + +Theorem 3 (Informal version of Theorem 18). Let $A_W \in \mathbb{R}^{W \times d}$ and $B \in \mathbb{R}^{W \times p}$ be the matrix streamed during the window of size $W$ formed as defined in equation (1), $\epsilon, \delta, \eta$ be as before. Then there exists an $\tau = \left(d + \frac{14}{\epsilon^2} \log \left( \frac{4}{\delta} \right)\right) \log^2(W)$ and $(\epsilon, \delta)$ -differentially private algorithm in the sliding window model that output a matrix $\widetilde{X} \in \mathbb{R}^{d \times p}$ such that + +$$ +\begin{array}{l} \left\| A _ {W} \widetilde {X} - B _ {W} \right\| _ {F} ^ {2} \leq (1 + \eta) \min _ {X \in \mathbb {R} ^ {d _ {\times p}}} \| A _ {W} X - B \| _ {F} ^ {2} \\ + O \left(\frac {(\tau + p) ^ {2} \log (\tau + p)}{\epsilon}\right). \\ \end{array} +$$ + +This is the first result for multiple-response regression and matches the bound achieved in Sheffet (2019) when $p = 1$ even though we are in a more restrictive setting. + +Application III: Directional variance queries. The directional variance queries has the following form: the analyst gives a unit-length vector $x \in \mathbb{R}^d$ and wish to know the variance of $A_W$ along $x$ . Theorem 1 gives an algorithm to answer directional covariance queries (and cut queries when the matrix is the edge-adjacency matrix of a graph). + +Theorem 4 (Informal version of Theorem 15). Let $A_W$ be the matrix formed by last $W$ updates as defined in equation (1) and $\epsilon, \delta, \eta$ be as before. Given a bound $q$ on the number of queries that can be made, there is an efficient $(\epsilon, \delta)$ -differentially private algorithm that outputs a matrix $C$ such that for any set of $q$ unit vector queries $x_1, \dots, x_q \in \mathbb{R}^d$ , + +we have for all $i \in [q]$ + +$$ +\begin{array}{l} x _ {i} ^ {\top} A _ {W} ^ {\top} A _ {W} x _ {i} - \frac {c \log q \log d}{\epsilon} \leq x _ {i} ^ {\top} C x _ {i} \\ \leq (1 + \eta) x _ {i} ^ {\top} A _ {W} ^ {\top} A _ {W} x _ {i} + \frac {c \log q \log d}{\epsilon}. \\ \end{array} +$$ + +Even though we are in a more restrictive setting of sliding window, this matches the bound achieved in Blocki et al. (2012) after we apply the improvement in Sheffet (2019). + +# 4. Concluding remarks + +We believe that our approach will find applications beyond what is covered in this paper and will pave way for further research in the intersection of differential privacy and sliding window model. We focus on the model where every data in the current window is considered equally useful to explain the heuristics used in recent deployments. However, one can consider other variants of the sliding window model as far as privacy is concerned. As an example, one can consider a model where the privacy of a data decays as a monotonic function of time lapse. More so, there are more concrete questions to be asked and answered even in the model studied in this paper. + +As we mentioned earlier, one can see $\eta$ -approximate spectral histogram property as a generalization of subspace embedding property. We believe that any improvement in designing a more efficient data structure for maintaining a set of matrices satisfying $\eta$ -approximate spectral histogram property will have a profound impact on large-scale deployment of privacy-preserving algorithms in the sliding window model. For example, we believe that space requirements can be reduced using randomization. This randomization can be either oblivious or may depend on the current set of positive semidefinite matrices. Since our set of positive semidefinite matrices are generated using a privacy mechanism, any such sampling can be viewed as post-processing and hence privacy preserving. Hence, our main conjectures are concerning the space required by any privacy-preserving algorithm. We elaborate them next. + +The lower bound of $\Omega\left(d^{2}\right)$ space for spectral approximation is required even in the static setting. We conjecture that + +there should be $\frac{1}{\eta}\log W$ factor due to the sliding window requirement. This is because, if the spectrum of a matrix is polynomially bounded, then one can construct a sequence of updates that requires at least $\frac{1}{\eta}\log W$ matrices such that successive matrices are $(1 - \eta)$ apart in terms of their spectrum. For an upper bound, we believe randomization can help reduce a factor of $d$ . This is achieved in the non-private setting using online row sampling. It was shown by Upadhyay (2018) that one can design private algorithms with space-bound comparable to a non-private algorithm in the streaming model of computation. The situation in the sliding window model is more complicated, but we believe it is possible to achieve a matching upper bound. In view of this, we conjecture the following. + +Conjecture 1. The space required for differentially private spectral approximation is $\Theta\left(\frac{d^2}{\eta}\log W\right)$ . + +We believe that the bound on the additive error is optimal. A positive resolution to this conjecture would imply that the price of privacy is only in terms of the additive error. + +Our second conjecture is for principal component analysis. We believe that our space-bound for principal component analysis is tight up to a factor of $\frac{k}{\eta}$ . A lower bound of $\Omega(dk)$ is trivial as one requires $O(dk)$ space just to store the orthonormal matrix corresponding to the rank- $k$ projection matrix. As before, a factor of $\frac{1}{\eta} \log W$ would be incurred due to the sliding window model. The factor of $\frac{1}{\eta}$ comes from the fact that to extract the top- $k$ subspace, we need $\frac{k}{\eta}$ dimensional subspace. + +Conjecture 2. The space required for differentially private $PCA$ is $\Omega \left( \frac{dk}{\eta^2} \log W \right)$ . + +We believe that proving such a lower bound would require new techniques. This is because, in PCA, we only have access to an orthonormal projection matrix, while in the case of low-rank approximation, we have far more information to solve the underlying communication complexity problem. + +Our work identifies another application of the Johnson-Lindenstrauss and Wishart mechanisms. Before our results, it was not even clear whether the JL mechanism can be used to compute PCA (see Section V in Blocki et al. (2012))? They consider their output matrix $\widetilde{C}$ as a "test" matrix to test if the input matrix has high directional variance along some direction $x\in \mathbb{R}^d$ . However, they do not give any guarantee as to how the spectrum of $C$ relates to that of the input covariance matrix. + +# 5. Acknowledgement + +JU's research was supported, in part, by NSF BIGDATA awards IIS-1838139 and IIS 1546482. JU would like to acknowledge Petros Drineas for useful discussion on the + +technique of Batson et al. (2012). + +# References + +Achlioptas, D. and McSherry, F. On spectral learning of mixtures of distributions. In Proceedings of the 18th Annual Conference on Learning Theory, pp. 458-469. Springer, 2005. +Amin, K., Dick, T., Kulesza, A., Munoz, A., and Vassilvitskii, S. Differentially private covariance estimation. In Proceedings of the 32nd Advances in Neural Information Processing Systems, pp. 14190-14199, 2019. +Arora, R. and Upadhyay, J. On differentially private graph sparsification and applications. In Proceedings of the 32nd Advances in Neural Information Processing Systems, pp. 13378-13389, 2019. +Arora, R., Braverman, V., and Upadhyay, J. Differentially private robust low-rank approximation. In Advances in Neural Information Processing Systems, pp. 4137-4145, 2018. +Asteris, M., Papailiopoulos, D., and Dimakis, A. Nonnegative sparse PCA with provable guarantees. In Proceedings of the 31st International Conference on Machine Learning, pp. 1728-1736, 2014. +Bakshi, A., Chepurko, N., and Jayaram, R. Testing positive semi-definiteness via random submatrices. In Proceedings of the 61st Annual Symposium on Foundations of Computer Science, pp. 1191-1202, 2020. +Bar-Yossef, Z. The complexity of massive data set computations. PhD thesis, University of California, Berkeley, 2002. +Batson, J., Spielman, D. A., and Srivastava, N. Twice-ramanujan sparsifiers. SIAM Journal on Computing, 41 (6):1704-1721, 2012. +Bentley, J. L. and Saxe, J. B. Decomposable searching problems i. static-to-dynamic transformation. Journal of Algorithms, 1(4):301-358, 1980. +Blocki, J., Blum, A., Datta, A., and Sheffet, O. The Johnson-Lindenstrauss transform itself preserves differential privacy. In Proceeding of the 53rd Annual IEEE Symposium on Foundations of Computer Science, pp. 410-419, 2012. +Blum, A., Dwork, C., McSherry, F., and Nissim, K. Practical privacy: the SuLQ framework. In Proceedings of the 24th ACM SIGMOD-SIGACT-SIGART Symposium on Principles of Database Systems, pp. 128-138, 2005. +Bolot, J., Fawaz, N., Muthukrishnan, S., Nikolov, A., and Taft, N. Private decayed predicate sums on streams. + +In Proceedings of the 16th International Conference on Database Theory, pp. 284-295, 2013. +Braverman, V., Drineas, P., Musco, C., Musco, C., Upadhyay, J., Woodruff, D. P., and Zhou, S. Near optimal linear algebra in the online and sliding window models. In Proceeding of the 61st Annual Symposium on Foundations of Computer Science, pp. 517-528, 2020. +Campos, P. G., Díez, F., and Cantador, I. Time-aware recommender systems: a comprehensive survey and analysis of existing evaluation protocols. User Modeling and User-Adapted Interaction, 24(1-2):67-119, 2014. +Chan, T. H., Shi, E., and Song, D. Private and continual release of statistics. ACM Transactions on Information and System Security, 14(3):26:1-26:24, 2011. +Chan, T.-H. H., Li, M., Shi, E., and Xu, W. Differentially private continual monitoring of heavy hitters from distributed streams. In Proceedings of the 12th International Privacy Enhancing Technologies Symposium, pp. 140-159, 2012. +Clarkson, K. L. and Woodruff, D. P. Low-rank approximation and regression in input sparsity time. Journal of the ACM, 63(6):54, 2017. +Cohen, M. B., Elder, S., Musco, C., Musco, C., and Persu, M. Dimensionality reduction for k-means clustering and low rank approximation. In Proceedings of the 47th Annual ACM symposium on Theory of computing, pp. 163-172, 2015. +Drineas, P., Kerenidis, I., and Raghavan, P. Competitive recommendation systems. In Proceedings of the 34th ACM Symposium on Theory of Computing, pp. 82-90, 2002. +Dwork, C. and Roth, A. The algorithmic foundations of differential privacy. Foundations and Trends® in Theoretical Computer Science, 9(3-4):211-407, 2014. +Dwork, C., Naor, M., Pitassi, T., and Rothblum, G. N. Differential privacy under continual observation. In Proceedings of the 42nd ACM Symposium on Theory of Computing, pp. 715-724, 2010. +Dwork, C., Talwar, K., Thakurta, A., and Zhang, L. Analyze gauss: optimal bounds for privacy-preserving principal component analysis. In Proceedings of the 46th Annual ACM Symposium on Theory of Computing, pp. 11-20, 2014. +Eckart, C. and Young, G. The approximation of one matrix by another of lower rank. Psychometrika, 1(3):211-218, 1936. + +Erlingsson, U., Pihur, V., and Korolova, A. Rappor: Randomized aggregatable privacy-preserving ordinal response. In Proceedings of the 2014 ACM SIGSAC Conference on Computer and Communications Security, pp. 1054-1067, 2014. +Friedland, S. and Torokhti, A. Generalized rank-constrained matrix approximations. SIAM Journal on Matrix Analysis and Applications, 29(2):656-659, 2007. +Halko, N., Martinsson, P.-G., and Tropp, J. A. Finding structure with randomness: Probabilistic algorithms for constructing approximate matrix decompositions. SIAM Review, 53(2):217-288, 2011. +Hardt, M. and Price, E. The noisy power method: A meta algorithm with applications. In Proceedings of the 27th Advances in Neural Information Processing Systems, pp. 2861-2869, 2014. +Hardt, M. and Roth, A. Beating randomized response on incoherent matrices. In Proceedings of the 44th Annual ACM Symposium on Theory of Computing, pp. 1255-1268, 2012. +Hazan, E. Introduction to online convex optimization. arXiv preprint arXiv:1909.05207, 2019. +Huang, Z., Qiu, Y., Yi, K., and Cormode, G. Frequency estimation under multiparty differential privacy: One-shot and streaming. arXiv preprint arXiv:2104.01808, 2021. +Kane, D. M. and Nelson, J. Sparser Johnson-Lindenstrauss transforms. Journal of the ACM, 61(1):4, 2014. +Kapralov, M. and Talwar, K. On differentially private low rank approximation. In Proceedings of the 44th Annual ACM-SIAM Symposium on Discrete algorithms, pp. 1395-1414, 2013. +McSherry, F. and Mironov, I. Differentially private recommender systems: Building privacy into the netflix prize contenders. In Proceedings of the 15th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pp. 627-636, 2009. +Miltersen, P. B., Nisan, N., Safra, S., and Wigderson, A. On data structures and asymmetric communication complexity. In STOC, pp. 103-111. ACM, 1995. +Moore, J. L., Chen, S., Turnbull, D., and Joachims, T. Taste over time: The temporal dynamics of user preferences. In Proceedings of the 14th International Society for Music Information Retrieval Conference, pp. 401-406, 2013. +Muthukrishnan, S. Data streams: Algorithms and applications. Foundations and Trends® in Theoretical Computer Science, 1(2), 2005. + +Narayanan, A. and Shmatikov, V. How to break anonymity of the netflix prize dataset. arXiv preprint cs/0610105, 2006. +Quadrana, M., Cremonesi, P., and Jannach, D. Sequence-aware recommender systems. ACM Computing Surveys, 51(4):66, 2018. +Sarlós, T. Improved approximation algorithms for large matrices via random projections. In Proceedings of the 47th Annual IEEE Symposium on Foundations of Computer Science, pp. 143-152, 2006. +Sheffet, O. Old techniques in differentially private linear regression. In Proceedings of the 30th International Conference on Algorithmic Learning Theory, pp. 789-827, 2019. +Singhal, V. and Steinke, T. Privately learning subspaces. arXiv preprint arXiv:2106.00001, 2021. +Smith, A., Song, S., and Thakurta, A. The Flajolet-Martin sketch itself preserves differential privacy: Private counting with minimal space. In Proceedings of the 33rd Advances in Neural Information Processing Systems, 2020. +Thakurta, A. G., Vyrros, A. H., Vaishampayan, U. S., Kapoor, G., Freudiger, J., Sridhar, V. R., and Davidson, D. Learning new words, March 14 2017. US Patent 9,594,741. +Tsay, R. Analysis of Financial Time Series. Wiley Series in Probability and Statistics. Wiley-Interscience, 2005. +Upadhyay, J. The price of privacy for low-rank factorization. In Proceedings of the 31st Advances in Neural Information Processing Systems, pp. 4180-4191, 2018. +Upadhyay, J. Sublinear space private algorithms under the sliding window model. In Proceedings of the 36th International Conference of Machine Learning, pp. 6363-6372, 2019. +Upadhyay, J., Upadhyay, S., and Arora, R. Differentially private analysis on graph streams. In Proceedings of the 24th International Conference on Artificial Intelligence and Statistics, pp. 1171-1179, 2021. +Woodruff, D. P. Sketching as a tool for numerical linear algebra. Foundations and Trends® in Theoretical Computer Science, 10(1-2):1-157, 2014. +Yuan, X.-T. and Zhang, T. Truncated power method for sparse eigenvalue problems. Journal of Machine Learning Research, 14:899-925, 2013. +Zass, R. and Shashua, A. Nonnegative sparse PCA. In Proceedings of the 19th Advances in Neural Information Processing Systems, pp. 1561-1568, 2006. \ No newline at end of file diff --git a/aframeworkforprivatematrixanalysisinslidingwindowmodel/images.zip b/aframeworkforprivatematrixanalysisinslidingwindowmodel/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..a8fe8ad8e5a3018d5c0adcba206c95f83323d0ca --- /dev/null +++ b/aframeworkforprivatematrixanalysisinslidingwindowmodel/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f84917ef62a8968b8b169ed1abd566c3822581322b9220bb33bfcc50cd0dc484 +size 329469 diff --git a/aframeworkforprivatematrixanalysisinslidingwindowmodel/layout.json b/aframeworkforprivatematrixanalysisinslidingwindowmodel/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..919575204ac61f5cc10910efd04ec31b26aa0955 --- /dev/null +++ b/aframeworkforprivatematrixanalysisinslidingwindowmodel/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:96b84f35b34322d3bf6aa5e38ec514256e6ada8a0d9e00083c4e7270e705a545 +size 584085 diff --git a/afreelunchfromanntowardsefficientaccuratespikingneuralnetworkscalibration/ac217128-1727-4e22-8766-19783810df28_content_list.json b/afreelunchfromanntowardsefficientaccuratespikingneuralnetworkscalibration/ac217128-1727-4e22-8766-19783810df28_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..98c8a46eb08bddd9cff42cc746c5444288c043db --- /dev/null +++ b/afreelunchfromanntowardsefficientaccuratespikingneuralnetworkscalibration/ac217128-1727-4e22-8766-19783810df28_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:66a5159aab6ff6977ab57a49d1cdf7aa70246c4bbc85cca2103c2a325467e93a +size 80217 diff --git a/afreelunchfromanntowardsefficientaccuratespikingneuralnetworkscalibration/ac217128-1727-4e22-8766-19783810df28_model.json b/afreelunchfromanntowardsefficientaccuratespikingneuralnetworkscalibration/ac217128-1727-4e22-8766-19783810df28_model.json new file mode 100644 index 0000000000000000000000000000000000000000..18bb529e5397aa1766f4922754ea40ccab6b7a15 --- /dev/null +++ b/afreelunchfromanntowardsefficientaccuratespikingneuralnetworkscalibration/ac217128-1727-4e22-8766-19783810df28_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a2dc6a7673c7d42835f7cf2c33525a0836384edf87d07309eac56520144e04d8 +size 95826 diff --git a/afreelunchfromanntowardsefficientaccuratespikingneuralnetworkscalibration/ac217128-1727-4e22-8766-19783810df28_origin.pdf b/afreelunchfromanntowardsefficientaccuratespikingneuralnetworkscalibration/ac217128-1727-4e22-8766-19783810df28_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..f9213914c67bd9ca8f0cd628b11751004563e449 --- /dev/null +++ b/afreelunchfromanntowardsefficientaccuratespikingneuralnetworkscalibration/ac217128-1727-4e22-8766-19783810df28_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5e7c96de8a1412047a028d46e59eacc9ad42f0d8e2f09df5845005b249728c82 +size 3146698 diff --git a/afreelunchfromanntowardsefficientaccuratespikingneuralnetworkscalibration/full.md b/afreelunchfromanntowardsefficientaccuratespikingneuralnetworkscalibration/full.md new file mode 100644 index 0000000000000000000000000000000000000000..d814d38995f83b7a6617ec92d1bf3a28a401ded8 --- /dev/null +++ b/afreelunchfromanntowardsefficientaccuratespikingneuralnetworkscalibration/full.md @@ -0,0 +1,348 @@ +# A Free Lunch From ANN: Towards Efficient, Accurate Spiking Neural Networks Calibration + +Yuhang Li $^{*12}$ Shikuang Deng $^{*1}$ Xin Dong $^{3}$ Ruihao Gong $^{4}$ Shi Gu $^{1}$ + +# Abstract + +Spiking Neural Network (SNN) has been recognized as one of the next generation of neural networks. Conventionally, SNN can be converted from a pre-trained ANN by only replacing the ReLU activation to spike activation while keeping the parameters intact. Perhaps surprisingly, in this work we show that a proper way to calibrate the parameters during the conversion of ANN to SNN can bring significant improvements. We introduce SNN Calibration, a cheap but extraordinarily effective method by leveraging the knowledge within a pre-trained Artificial Neural Network (ANN). Starting by analyzing the conversion error and its propagation through layers theoretically, we propose the calibration algorithm that can correct the error layer-by-layer. The calibration only takes a handful number of training data and several minutes to finish. Moreover, our calibration algorithm can produce SNN with state-of-the-art architecture on the large-scale ImageNet dataset, including MobileNet and RegNet. Extensive experiments demonstrate the effectiveness and efficiency of our algorithm. For example, our advanced pipeline can increase up to $69\%$ top-1 accuracy when converting MobileNet on ImageNet compared to baselines. Codes are released at a GitHub repo. + +# 1. Introduction + +Spiking neural networks (SNNs) are based on the spiking neural behavior in biological neurons (Hodgkin & Huxley, 1952; Izhikevich, 2003). Each neuron in SNNs elicits a spike when its accumulated membrane potential exceeds a threshold, otherwise, it would stay inactive in the current + +*Equal contribution $^{1}$ University of Electronic Science and Technology of China $^{2}$ Yale University $^{3}$ Harvard University $^{4}$ SenseTime Research. Correspondence to: Yuhang Li , Shi Gu . + +Proceedings of the $38^{th}$ International Conference on Machine Learning, PMLR 139, 2021. Copyright 2021 by the author(s). + +
FeaturesTrainingConversionCalibration
Accuracy(T ≤ 100)HighLowHigh
ScalabilityTinyLargeLarge
Training SpeedSlowFastFast
# Required DataFull-set10001000
Inference SpeedFastSlowFast
+ +Table 1. Features comparison between SNN direct training, ANN-SNN conversion and our SNN calibration. + +time step. Compared with ANNs, the activation values in SNNs are binarized (i.e., neuromorphic computing (Roy et al., 2019b)), thus resulting in an advantage of energy efficiency for SNNs. Existing works reveal that on specialized hardware, SNNs can save energy by orders of magnitude compared with ANNs (Roy et al., 2019a; Deng et al., 2020). Another vital attribute of SNN is its ability to make inferences in a spatial-temporal paradigm. Specifically, the forwarding pass in SNN is repeated for $T$ steps to get the final result, where the final result is the expectation of the ultimate layer's output across $T$ steps. This allows the flexibility of adjusting $T$ to balance between the latency and accuracy of SNNs for different application scenarios. + +Conventionally, there are two distinct routes to obtain a functional SNN: (1) training SNN from scratch (Shrestha & Orchard, 2018; Kheradpisheh et al., 2018), and (2) converting a pretrained ANN to SNN (Cao et al., 2015; Diehl et al., 2015). For training from scratch, it is hard to adopt gradient-based optimization methods because of the nondifferentiability of the binary activation function in SNNs (Neftci et al., 2019). Although several approaches like surrogate gradients (Wu et al., 2018; Shrestha & Orchard, 2018) and synaptic plasticity (Kheradpisheh et al., 2018) are proposed to mitigate this problem, training SNN from scratch still lacks the scalability to obtain an effective SNN on the ImageNet dataset. Another notable problem is the tremendous resources required to complete the training process. The binary acceleration cannot be employed in GPU training since no CUDA instructions support this kind of computation. As a result, training an SNN may require $T \times$ more time than ANN training. + +Besides directly training SNNs from scratch, another family + +of approaches is converting a pretrained ANN into SNN (Diehl et al., 2016; Rueckauer et al., 2017; Sengupta et al., 2018). The conversion process demands less computation and memory than training from scratch. Although some progress in SNN conversion is made, such as threshold balancing (Diehl et al., 2015; Sengupta et al., 2018), weight normalization (Rueckauer et al., 2017), and soft-reset mechanism (Rueckauer et al., 2017; Han et al., 2020), all of them fail to convert ANN with BN layers in low latency time steps ( $\leq$ 256), which may significantly increase the latency especially for resource-limited devices. We think the simple copy-paste of parameters without any dedicated calibration on SNN will inevitably result in activation mismatch. + +In this work, we aim to obtain an SNN in extremely low latency (less than 256 time steps) and in extremely low cost. We choose to utilize a pre-trained ANN and convert it to SNN. Unlike previous conversion work which simply transplants the weights parameters to the SNN, in this work we show that the activation translating is much more important. In order to accomplish this, we propose SNN calibration, a new technology family by calibrating the parameters in SNN to match the activation after conversion, and thus significantly narrow the gap in activation distribution between the source ANN and calibrated SNN. We summarize the comparison between our calibration method and the existing conversion & training methods in Table 1. The novel contributions of the paper are threefold: + +- We formulate the conversion equation and divide the conventional conversion error into flooring error and clipping error. And then we analyze the error propagation through layers. +- We propose layer-wise calibration algorithm to adjust the network parameters including weights, bias, and initial potential to diminish the conversion error. To accommodate different user requirements, we provide Light Pipeline and Advanced Pipeline to balance accuracy and practical utility. +- We verify our algorithms on large-scale datasets like ImageNet (Deng et al., 2009). In addition to ResNets and VGG networks in previous work, we test a lightweight model MobileNet (Howard et al., 2017) and a large model RegNetX-4GF (Radosavovic et al., 2020) (79.4% top-1 accuracy) for the first time in ANN-to-SNN conversion. Our method can increase up to 69% accuracy in Spiking MobileNet conversion with 256 time steps. + +# 2. Related Work + +For training-based SNN, there are several supervised learning algorithms divided into (1) synaptic plasticity and (2) surrogate gradient. Synaptic plasticity methods are based + +on time-sensitivity and update the connection weight via the two neurons' firing time interval (Kheradpisheh et al., 2018; Iyer & Chua, 2020; LI & LI, 2019). They are more suitable for the neuromorphic image (Amir et al., 2017) or rate coding from static images. On the other hand, surrogate gradient (spiking-based backpropagation) methods use a soft relaxed function to replace the hard step function and train SNN like RNN (Wu et al., 2018; Shrestha & Orchard, 2018). They suffer from the computationally expensive and slow during the training process on complex network architecture (Rathi et al., 2019). + +Unlike training from scratch, ANN-to-SNN conversion methods, such as data-based normalization (Diehl et al., 2015; Rueckauer et al., 2016) or threshold balancing (Diehl et al., 2015; 2016), adapt to more complex situations (Tavanaei et al., 2019). The major bottleneck of these methods is how to balance accuracy and inference latency as they require more than $2\mathrm{k}$ time steps to get accurate results. Recently, many methods have been proposed to reduce the conversion loss and simulation length. The soft-reset also called the reset-by-subtraction mechanism, is the most common technique to address the potential reset's information loss (Rueckauer et al., 2016; Han & Roy, 2020). Our IF neuron model also adopts this strategy. Rueckauer et al. (2017) suggest using percentile threshold, which avoids picking the outlier in the activation distribution. Spike-Norm (Sengupta et al., 2018) tests architectures like VGG-16 and ResNet20. In this work, we further extend the source architecture to MobileNet and RegNet. RMP (Han et al., 2020) and TSC (Han & Roy, 2020) achieves near-to-origin accuracy by adjusting the threshold according to the input and output spike frequency. Deng & Gu (2021) decompose the conversion loss into each layer and reduce it via shifting bias. Low latency converted SNN is an on-going research challenge since it still requires a considerable amount of simulation length. At the same time, most SNN conversion work does not address the BN layers in low latency settings. + +# 3. Preliminaries + +Neuron Model for ANN. Considering the $\ell$ -th fully-connected layer or convolutional layer in the ANNs, its forwarding process can be formulated as, + +$$ +\mathbf {x} ^ {(\ell + 1)} = h \left(\mathbf {z} ^ {(\ell)}\right) = h \left(\mathbf {W} ^ {(\ell)} \mathbf {x} ^ {(\ell)}\right), 1 \leq \ell \leq n, \tag {1} +$$ + +where $\mathbf{x}^{(\ell)}$ , $\mathbf{W}^{(\ell)}$ denote the input activation and weight parameters in that layer respectively, and $h(\cdot)$ is the ReLU activation function. One can optionally train a bias parameter $\mathbf{b}^{(\ell)}$ and add it to pre-activation. + +Neuron Model for SNN. Here we use the Integrate-andFire (IF) neuron model (Liu & Wang, 2001; Barbi et al., 2003). In specific, suppose at time step $t$ the spiking neurons in layer $\ell$ receive its binary input $\mathbf{s}^{(\ell)}(t) \in \{0, V_{th}^{(\ell - 1)}\}$ , the + +neuron will update its temporary membrane potential by, + +$$ +\mathbf {v} _ {\text {t e m p}} ^ {(\ell)} (t + 1) = \mathbf {v} ^ {(\ell)} (t) + \mathbf {W} ^ {(\ell)} \mathbf {s} ^ {(\ell)} (t), \tag {2} +$$ + +where $\mathbf{v}^{(\ell)}(t)$ denotes the membrane potential at time step $t$ , and $\mathbf{v}_{temp}^{(\ell)}(t + 1)$ denotes the intermediate variable that would be used to determine the update from $\mathbf{v}^{(\ell)}(t)$ to $\mathbf{v}^{(\ell)}(t + 1)$ . If this temporary potential exceeds a pre-defined threshold $V_{th}^{(\ell)}$ , it would produce a spike output $\mathbf{s}^{(\ell + 1)}(t)$ with the value of $V_{th}^{(\ell)}$ . Otherwise, it would release no spikes, i.e. $\mathbf{s}^{(\ell + 1)}(t) = 0$ . The membrane potential at the next time step $t + 1$ would then be updated by soft-reset mechanism, also known as reset-by-subtraction. Mathematically, we describe the updating rule as + +$$ +\mathbf {v} ^ {(\ell)} (t + 1) = \mathbf {v} _ {t e m p} ^ {(\ell)} (t + 1) - \mathbf {s} ^ {(\ell + 1)} (t), \qquad (3) +$$ + +$$ +\mathbf {s} ^ {(\ell + 1)} (t) = \left\{ \begin{array}{l l} V _ {t h} ^ {(\ell)} & \text {i f} \mathbf {v} _ {\text {t e m p}} ^ {(\ell)} (t + 1) \geq V _ {t h} ^ {(\ell)} \\ 0 & \text {o t h e r w i s e} \end{array} . \right. \tag {4} +$$ + +Note that $V_{th}^{\ell}$ can be distinct in each layer. Thus, we cannot represent the spike in the whole network with binary signals. This problem can be avoided by utilizing a weight normalization technique to convert the $\{0, V_{th}^{(\ell - 1)}\}$ spike to $\{0, 1\}$ spike in every layers, given by: + +$$ +\mathbf {W} ^ {(\ell)} \leftarrow \frac {V _ {t h} ^ {(\ell - 1)}}{V _ {t h} ^ {(\ell)}}, \quad V _ {t h} ^ {(\ell)} \leftarrow 1. \tag {5} +$$ + +Recursively applying the above euqalization, we can use 0,1 spike to represent the intermediate activation for each layer. For the rest of the paper, we shall continue using the notation of $\{0,V_{th}^{(\ell -1)}\}$ spike for simplicity. + +As for the input to the first layer and the output of the last layer, we do not employ any spiking mechanism. We use the first layer to direct encode the static image to temporal dynamic spikes, this can prevent the undesired information loss of the Poisson encoding. For the last layer output, we only integrate the pre-synaptic input and does not firing any spikes. This is because the output can be either positive or negative, yet Eq. (4) can only convert the ReLU activation. + +Converting ANN to SNN Compared with ANN, SNN employs binary activation (i.e. spikes) at each layer. To compensate the loss in representation capacity, researchers introduce the time dimension to SNN by repeating the forwarding pass $T$ times to get final results. Ideally, the converted SNN is expected to have approximately the same input-output function mapping as the original ANN, i.e., + +$$ +\mathbf {x} ^ {(\ell)} \approx \bar {\mathbf {s}} ^ {(\ell)} = \frac {1}{T} \sum_ {t = 0} ^ {T} \mathbf {s} ^ {(\ell)} (t). \tag {6} +$$ + +In practice, the above approximation only holds when $T$ grows to 1k or even higher. However, high $T$ would lead to large inference latency thus damage SNN's practical utility. + +![](images/9a5af064b0c2e99c801cc51c96649558aef6c24cc13174e9b27c417030118e01.jpg) +Figure 1. The conversion error between the ReLU activation used in ANN and the output spike in SNN $(V_{th} = 10, T = 5)$ contains flooring error and clipping error. + +# 4. Methodology + +# 4.1. Dividing the Conversion Loss + +We first use the derivation in Deng & Gu (2021) to deduce the relationship between $\bar{\mathbf{s}}^{(\ell)}$ and $\bar{\mathbf{s}}^{(\ell + 1)}$ . Suppose the initial membrane potential $\mathbf{v}^{(\ell)}(0) = \mathbf{0}$ . Substitute Eq. (2) into Eq. (3) and sum over $T$ , then we get + +$$ +\mathbf {v} ^ {(\ell)} (T) = \mathbf {W} ^ {(\ell)} \left(\sum_ {t = 0} ^ {T} \mathbf {s} ^ {(\ell)} (t)\right) - \sum_ {t = 0} ^ {T} \mathbf {s} ^ {(\ell + 1)} (t). \tag {7} +$$ + +Since at each time step, the output can be either 0 or $V_{th}^{(\ell)}$ , the accumulated output $\sum_{t=0}^{T} \mathbf{s}^{(\ell+1)}(t)$ can be written to $mV_{th}^{(\ell)}$ where $m \in \{0,1,\dots,T\}$ denotes the total number of spikes. Note that we assume the terminal membrane potential $\mathbf{v}^{(\ell)}(T)$ lies within the range $[0,V_{th}^{(\ell)})$ . Therefore, according to Eq. (7), we have + +$$ +T \mathbf {W} ^ {(\ell)} \bar {\mathbf {s}} ^ {(\ell)} - V _ {t h} ^ {(\ell)} < m V _ {t h} ^ {(\ell)} \leq T \mathbf {W} ^ {(\ell)} \bar {\mathbf {s}} ^ {(\ell)}. \tag {8} +$$ + +where $\bar{\mathbf{s}}^{(\ell)}$ is defined in Eq. (6). Then, we can use floor operation and clip operation to determine the $m$ : + +$$ +m = \operatorname {c l i p} \left(\left\lfloor \frac {T}{V _ {t h} ^ {(\ell)}} \mathbf {W} ^ {(\ell)} \bar {\mathbf {s}} ^ {(\ell)} \right\rfloor , 0, T\right). \tag {9} +$$ + +Here the clip function sets the upper bound $T$ and lower bound 0. Floor function $\lfloor x \rfloor$ returns the greatest integer that less than or equal to $x$ . Given this formula, we can calculate the expected output spike: + +$$ +\begin{array}{l} \bar {\mathbf {s}} ^ {(\ell + 1)} = \operatorname {c l i p f l o o r} \left(\mathbf {W} ^ {(\ell)} \bar {\mathbf {s}} ^ {(\ell)}, T, V _ {t h} ^ {(\ell)}\right) \\ = \frac {V _ {t h} ^ {(\ell)}}{T} \operatorname {c l i p} \left(\left\lfloor \frac {T}{V _ {t h} ^ {(\ell)}} \mathbf {W} ^ {(\ell)} \bar {\mathbf {s}} ^ {(\ell)} \right\rfloor , 0, T\right) \tag {10} \\ \end{array} +$$ + +![](images/f594986f0035915fe56d52a59c2a90b927ba1a6fd19369fbe7d105c206db91f9.jpg) +Figure 2. Comparison of the threshold determined by three different approaches. Our MMSE threshold will vary with time steps. + +According to Eq. (10), the conversion loss (difference between $\mathbf{x}^{(\ell + 1)}$ and $\bar{\mathbf{s}}^{(\ell + 1)}$ ) comes from two aspects, namely the flooring error and the clipping error. + +In Fig. 1, we further indicate that $V_{th}^{(\ell)}$ is crucial for conversion loss because it affects both the flooring and the clipping errors. Increasing $V_{th}^{(\ell)}$ leads to lower clipping error but higher flooring error. Previous work (Diehl et al., 2015; 2016) sets $V_{th}^{(\ell)}$ to the maximum pre-activations across samples in ANN to eliminate the clipping error. However, the maximum pre-activations are usually outliers. Given this insight, the outliers may tremendously increase the flooring error. As a result, they have to use a very large $T$ (for example, 2000) to decrease the flooring error. + +# 4.2. Adaptive Threshold by MMSE + +In an effort to better balance flooring error and the clipping error, we use Minimization of Mean Squared Error (MMSE) to obtain the threshold $V_{th}^{(\ell)}$ under different simulation length $T$ . Here we adopt the similar layer-wise optimization problem in (Deng & Gu, 2021), which is formulated by + +$$ +\min _ {V _ {t h}} \left(\operatorname {c l i p f l o o r} \left(\mathbf {x} ^ {(\ell + 1)}, T, V _ {t h} ^ {(\ell)}\right) - \operatorname {R e L U} \left(\mathbf {x} ^ {(\ell + 1)}\right)\right) ^ {2} \tag {11} +$$ + +Note that the above problem is not guaranteed to be convex, and there is no closed-form solution to this minimization. We hereby sample several batches of training images and use grid search to determine the final result of $V_{th}^{(\ell)}$ . Specifically, we linearly sample $N$ grids between $[0, \max(\mathbf{x}^{(\ell + 1)})]$ , and find the grid that has lowest MSE. We set $N = 100$ and find this option is precise enough to obtain a good solution. Fig. 2 shows the dynamics of our proposed method. + +It is worthwhile to note that $V_{th}^{(\ell)}$ does not monotonically increase along with $T$ , because the flooring error may be decreased by slightly increment the threshold. We can further apply MMSE threshold channel-wisely to further decrease the MSE error, as did in (Kim et al., 2019). + +# 4.3. Layer-wise Calibration + +Besides adaptive threshold, we further reduce the conversion error by calibrating the parameters of SNN. We first analyze how conversion errors accumulate through layers, and then present a set of layer-wise algorithms to calibrate different types of SNN parameters, including bias, weights and initial membrane potential. + +As aforementioned, the output layer of our SNN only accumulates the pre-synaptic inputs through time, that is to say, the final output of SNN is arithmetic sum of output from each time step $\sum_{t=1}^{T} \mathbf{W}^{(n)} \mathbf{s}^{(n)}(t)$ . Note that this modification doesn't introduce additional overhead because network output won't participate in further operation. With this modified last layer, our object becomes to minimize the difference between the input to the last layer, i.e., $\bar{\mathbf{s}}^{(n)}$ and $\mathbf{x}^{(n)}$ . + +Lemma 4.1. Denote the Frobenius norm as $||\cdot ||$ , the conversion error in the last layer in given by + +$$ +\left| \left| \mathbf {e} ^ {(n)} \right| \right| = \left| \left| \mathbf {x} ^ {(n)} - \bar {\mathbf {s}} ^ {(n)} \right| \right| \leq \left| \left| \sum_ {\ell = 1} ^ {n} E r r ^ {(\ell)} \prod_ {k = \ell} ^ {n} \mathbf {W} ^ {(k)} \right| \right|, \tag {12} +$$ + +where $Err^{(\ell)} = \mathrm{clipfloor}(\bar{\mathbf{s}}^{(\ell)}) - \mathrm{ReLU}(\bar{\mathbf{s}}^{(\ell)})$ . + +We provide the detailed derivation of above lemma in Appendix A. The above lemma indicates that the conversion errors in former layers have a cumulative effect on the subsequent layers. In addition, the conversion error in the ultimate layer is upper bounded by weighted linear combination of layer-wise error. Based on this observation, we develop a set of greedy layer-wise calibration algorithm to correct the conversion error in each layer progressively. + +We introduce Light Pipeline and Advanced Pipeline, which can be chose by users according to their memory and computation budgets for layer-wise calibration in practice. The light pipeline achieves fast calibration with less memory and computation consumption by only adjusting bias in SNNs. With a little effort, the light pipeline can outperform state-of-the-art methods by a large margin. We also propose an Advanced Pipeline that achieves best results by calibrating the weights as well as the initial membrane potential in a fine-grained way. + +Light Pipeline Light Pipeline only contains Bias Calibration (BC). In order to calibrate the bias parameters, we first + +define a reduced mean function: + +$$ +\mu_ {c} (\mathbf {x}) = \frac {1}{w h} \sum_ {i = 1} ^ {w} \sum_ {j = 1} ^ {h} \mathbf {x} _ {c, i, j} \tag {13} +$$ + +where $w, h$ are the width and height of the feature-map, and $\mu_c(\mathbf{x})$ computes the spatial mean of the feature-map in each channel $c$ . We notice that the spatial mean of conversion error $\mathbf{e}^{(\ell)} = \mathbf{x}^{(\ell)} - \bar{\mathbf{s}}^{(\ell)}$ can be written by + +$$ +\mu_ {c} (\mathbf {x} ^ {(\ell)}) = \mu_ {c} (\bar {\mathbf {s}} ^ {(\ell)}) + \mu_ {c} (\mathbf {e} ^ {(\ell)}). \tag {14} +$$ + +To ensure the mean output of SNN is equal to the mean output of ANN, we can add the expected conversion error into the bias term as $\mathbf{b}_c^{(\ell)}\gets \mathbf{b}_c^{(\ell)} + \mu_c(\mathbf{e}^{(\ell +1)})$ . In practice, we only sample one batch training images and compute the reduced mean to calibrate the bias. + +Advanced Pipeline Calibrating the bias only corrects partial error. We need a more fine-grained calibration method. To this end, we propose advanced pipeline which consists of Potential Calibration (PC) and Weights Calibration (WC). + +Now consider a non-zero initial membrane potential $\mathbf{v}^{(\ell)}(0)$ we can rewrite Eq. (10) to + +$$ +\tilde {\bar {\mathbf {s}}} ^ {(\ell + 1)} = \frac {V _ {t h} ^ {(\ell)}}{T} \operatorname {c l i p} \left(\left\lfloor \frac {T}{V _ {t h} ^ {(\ell)}} \mathbf {W} ^ {(\ell)} \bar {\mathbf {s}} ^ {(\ell)} + \frac {\mathbf {v} ^ {(\ell)} (0)}{V _ {t h} ^ {(\ell)}} \right\rfloor , 0, T\right), \tag {15} +$$ + +where $\tilde{\mathbf{s}}^{(\ell +1)}$ is the calibrated expected output with nonzero initialization of membrane potential. To obtain a fast calibration for the initial membrane potential, here we make an approximation that: + +$$ +\begin{array}{l} \tilde {\bar {\mathbf {s}}} ^ {(\ell + 1)} \approx \frac {V _ {t h} ^ {(\ell)}}{T} \operatorname {c l i p} \left(\left\lfloor \frac {T}{V _ {t h} ^ {(\ell)}} \mathbf {W} ^ {(\ell)} \bar {\mathbf {s}} ^ {(\ell)} \right\rfloor , 0, T\right) + \frac {\mathbf {v} ^ {(\ell)} (0)}{T} \\ = \bar {\mathbf {s}} ^ {(\ell + 1)} + \mathbf {v} ^ {(\ell)} (0) / T \tag {16} \\ \end{array} +$$ + +Similar to BC, $\mathbf{v}^{(\ell)}(0) / T$ can correct the output distribution of SNN. We can directly set $\mathbf{v}^{(\ell)}(0)$ to $T\times \mathbf{e}^{(\ell +1)}$ to calibrate the initial potential. Note that Potential Calibration does not need to compute spatial mean. + +In advanced pipeline, we also introduce Weights Calibration to correct the conversion error in each layer. In WC, the formulation is given by: + +$$ +\min _ {\mathbf {W} ^ {(\ell)}} \left\| \mathbf {e} ^ {(\ell + 1)} \right\| ^ {2}. \tag {17} +$$ + +Here we optimize the whole weights tensor in SNN layer-by-layer and can reduce the conversion error even further. For practical implementation, we will first store input samples in ANN $\mathbf{x}^{(\ell)}$ and input spikes samples in SNN of each time step $\mathbf{s}^{(\ell)}(t)$ and then compute the expected spike input by $\bar{\mathbf{s}}^{(\ell)} = \sum_{t=1}^{T} \mathbf{s}^{(\ell)}(t)$ . To further compute the gradient of clipfloor + +# Algorithm 1 Overall Algorithms + +input Pretrained ANN; simulation length $T$ Fold BN Layers into Conv Layers (cf. Eq. (19)) Replace AvgPooling Layers to depthwise Conv Layers for all $i = 1,2,\dots ,N$ -th layers in the ANN do Collect input data $\mathbf{x}^{(i)}$ output data $\mathbf{x}^{(i + 1)}$ in one batch Get MMSE threshold $V_{th}^{(i)}$ using grid search Get SNN output $\bar{\mathbf{s}}^{(i + 1)}$ Compute Error term $\mathbf{e}^{(i + 1)} = \mathbf{x}^{(i + 1)} - \bar{\mathbf{s}}^{(i + 1)}$ if Light Pipeline then Calibrate bias term $\mathbf{b}^{(i)}\gets \mathbf{b}^{(i)} + \mu (\mathbf{e}^{(i + 1)})$ else Calibrate Potential $\mathbf{v}^{(i)}(0)\leftarrow T\times \mathbf{e}^{(i + 1)}$ Optimize weights to minimize $\| \mathbf{e}^{(\ell +1)}\| ^2$ via stochastic gradient descent end if end for output Converted SNN model + +function, we apply the StraightThrough Estimator (Bengio et al., 2013) of the floor operation, i.e. + +$$ +\frac {\partial \lfloor x \rfloor}{\partial x} = 1. \tag {18} +$$ + +To this end, we can use regular training methods like stochastic gradient descent for calibrating the weights. When conducting calibration for weights, the optimization process is very efficient compared to other direct training methods. This is because we first store the expected input from previous layers, and we do not have to perform $T$ times convolution like direct training methods. The major bottleneck of WC is storing the input of SNN. For example, if we set $T = 1024$ , then we will do 1024 times forwarding pass for one batch and accumulate them to get the final expected results. + +# 4.4. Average Pooling Layers + +Most SNN works do not include the Max Pooling layers since finding the maximum activation neuron ahead of time is impractical, i.e. we cannot determine the maximum neuron $\overline{s}$ when we only observe $s(1)$ . Therefore, they use Average Pooling Layers to downsample the feature-maps and do not convert them in SNN. However, we argue that Average Pooling Layers will produce non-binary information. For example, a $2 \times 2$ kernel AvgPool layer can output 4 possible values [0, 0.25, 0.5, 1] with spike inputs. To make SNN run on corresponding hardware, we convert the AvgPool layer by treating the AvgPool layer as a convolutional layer with specific values. So we can convert the AvgPool layer just like other convolutional layers. More details are included in Appendix. + +# 4.5. Converting BN layers + +There is no corresponding module in SNN for Batch Normalization (BN) layers. Rueckauer et al. (2017) propose to absorb the BN parameters to the weight and bias, which can be represented by: + +$$ +\mathbf {W} \leftarrow \mathbf {W} \frac {\gamma}{\sigma}, \quad \mathbf {b} \leftarrow \beta + (\mathbf {b} - \mu) \frac {\gamma}{\sigma}, \tag {19} +$$ + +where $\mu, \sigma$ are the running mean and standard deviation, and $\gamma, \beta$ are the transformation parameters in the BN layer. + +# 5. Experiments + +To demonstrate the effectiveness and the efficiency of the proposed algorithm, we conduct experiments on CIFAR (Krizhevsky et al.) and ImageNet (Deng et al., 2009) datasets with extremely low simulation length (say $T \leq 256$ ). In Sec. 5.2, we study the impact of the approximations and design choices made in Sec. 4. In Sec. 5.3, we compare our methods to other methods. + +# 5.1. Implementation Details + +For all ANN with BN layers, we fold the BN layer before conversion. We do not convert input images to binary spikes because generating binary spikes requires time and degrades the accuracy. We also do not convert network output to spikes as explained in Sec. 4.3. To correct the bias and membrane potential, we sample one batch of unlabeled data (128 training images). To estimate the MMSE threshold and calibrate weights, we use 1024 training images. In our experiments, we apply the bias shift as described in Deng & Gu (2021). We use Stochastic Gradient Descent with 0.9 momentum to optimize weights in WC, followed by a cosine learning rate decay (Loshchilov & Hutter, 2016). The learning rate for WC is set to $10^{-5}$ , and no L2 regularization is imposed. We optimize the weights in each layer with 5000 iterations. We will analyze the time and space complexity of our algorithm in the next section. Note that the training details of ANN are included in the Appendix. + +# 5.2. Ablation Study + +In this section, we verify the design choices of our proposed adaptive threshold and layer-wise calibration. In all ablation experiments, we test VGG-16 and ResNet-20 (Sengupta et al., 2018; Han et al., 2020) on CIFAR100. We also conduct variance studies by running 5 times with different random seeds and report the mean and standard deviation of the (top1) accuracy on the validation set. + +Effect of MMSE Threshold in Conversion We study the effect of choosing different threshold $V_{th}$ . In Table 2, we show that maximum activation has the lowest effect because of the under-fire problem in the initial stage. Our + +
MethodVGG-16 (77.89)ResNet-20 (77.16)
T=16T=32T=16T=32
Maximum Act2.38±0.175.01±1.2325.67±4.6751.27±3.82
Percentile 99.9%3.73±0.3842.11±0.3755.00±0.4771.94±0.19
MMSE (Ours)19.42±0.8143.53±0.7258.38±0.6272.13±0.18
MMSE* (Ours)17.50±2.4647.40±2.7163.55±0.6073.57±0.06
+ +Table 2. (Top-1) Accuracy comparison on different threshold determination methods for ANN with BN layers. * denotes channel-wise threshold. + +
MethodVGG-16 (77.89)ResNet-20 (77.16)
T=16T=32T=16T=32
MaxAct + BC24.61±2.1932.60±2.6155.17±5.0668.78±2.48
Percentile + BC40.56±1.2966.87±0.7869.60±0.1475.26±0.20
MMSE + BC44.95±0.5267.61±0.7270.78±0.1575.53±0.15
MMSE* + BC52.96±1.9169.19±0.7572.33±0.1375.94±0.23
+ +Table 3. Light pipeline combines BC with different thresholds for ANN with BN layers and consistently improves accuracy. * denotes channel-wise threshold. + +MMSE threshold achieves better results than maximum activation (Diehl et al., 2015) and percentile (Rueckauer et al., 2017) threshold when $T = 16$ . As an example, our method is $15.7\%$ higher in accuracy than percentile when converting VGG-16. In ResNet-20, better threshold can significantly improve the accuracy of conversion. Finally, we apply the channel-wise MMSE threshold and further boost the accuracy from $43.5\%$ to $47.4\%$ in VGG-16 and from $72.1\%$ to $73.5\%$ in ResNet-20. + +Light Pipeline: Combining Bias Calibration Next, we verify the effect of the proposed Bias Calibration by applying it to different threshold methods. Results are summarized in Table 3, where we can find BC can consistently improve the accuracy of converted SNN by simply tuning the bias parameters. For example, BC can boost $22\%$ accuracy in VGG-16 using percentile threshold when $T = 16$ . On our MMSE threshold, the Bias Calibration can increase up to $35\%$ accuracy. We should emphasize that BC is cheap and only requires tiny memory space to store the bias term for different $T$ . Therefore our light pipeline is flexible to make trade-off between accuracy and latency. + +Advanced Pipeline: Potential and Weights Calibration Our advanced pipeline contains Potential and Weights Calibration that will alter the ANN's parameters to adapt better in spiking configuration. We validate the effect of them on our MMSE threshold mode in Table 5. We can find that Potential Calibration can substantially improve the accuracy of SNN. As an example, the MMSE + BC on VGG-16 only has $44.95\%$ accuracy. However, with PC, we can uplift the accuracy to $59.52\%$ . We also find WC is slightly more stable since the variance of the results is lower. + +Spiking Neural Networks Calibration + +
MethodUse BNConvert APANN Acc.T=32T=64T=128T=256T≥2048
ResNet-34 (He et al., 2016) ImageNet
Spike-Norm (Sengupta et al., 2018)XX70.69----65.47
Hybrid Train (Rathi et al., 2019)XX70.20---61.4865.10
RMP (Han et al., 2020)XX70.64---55.6569.89
TSC (Han & Roy, 2020)XX70.64---55.6569.93
Opt. (Deng & Gu, 2021)*X70.9533.0159.5267.5470.0670.98
Ours (Light Pipeline)X70.9562.3468.3870.1570.7570.97
Opt. (Deng & Gu, 2021)*75.660.090.123.1947.1175.08
Ours (Light Pipeline)75.6650.2163.6668.8972.1275.44
Ours (Advanced Pipeline)75.6664.5471.1273.4574.6175.45
VGG-16 (Simonyan & Zisserman, 2014) ImageNet
Spike-Norm (Sengupta et al., 2018)XX70.52----69.96
Hybrid Train (Rathi et al., 2019)XX69.35---62.7365.19
RMP (Han et al., 2020)XX73.49---48.3273.09
TSC (Han & Roy, 2020)XX73.49---69.7173.46
Opt. (Deng & Gu, 2021)*X72.4054.9266.5169.9471.3572.09
Ours (Light Pipeline)X72.4069.3071.1271.8572.2072.29
Opt. (Deng & Gu, 2021)*75.360.1140.1180.1221.8173.88
Ours (Light Pipeline)75.3624.8856.7770.4973.6675.15
Ours (Advanced Pipeline)75.3663.6470.6973.3274.2375.32
MobileNet (Howard et al., 2017) ImageNet
Opt. (Deng & Gu, 2021)*73.400.1100.1040.1000.96468.21
Ours (Light Pipeline)73.400.25412.6253.9165.8672.19
Ours (Advanced Pipeline)73.4037.4356.2665.4069.0272.38
RegNetX-4GF (Radosavovic et al., 2020) ImageNet
Opt. (Deng & Gu, 2021)*80.020.2183.54248.6071.2278.33
Ours (Light Pipeline)80.0235.6365.2874.3777.3379.15
Ours (Advanced Pipeline)80.0255.7070.9675.7877.5079.21
+ +Table 4. Comparison of our algorithm with other existing SNN conversion works. Use BN means use BN layers to optimize ANN, Convert AP means use depthwise convolutional layers to replace Average Pooling layers. * denotes self-implementation results. + +
MethodVGG-16 (77.89)ResNet-20 (77.16)
T=16T=32T=16T=32
MMSE + PC59.52±1.0670.62±0.4773.37±0.2876.21±0.06
MMSE* + PC65.29±0.8673.53±0.2774.22±0.2576.68±0.12
MMSE + PC + WC65.02±0.3373.51±0.2373.36±0.2876.32 ±0.13
MMSE* + PC + WC67.14±0.8874.52±0.3674.02±0.2076.52±0.16
+ +Table 5. Advanced pipeline use Potential and Weights Calibration to optimize SNN. * denotes channel-wise threshold. + +# 5.3. Comparison to Previous Work + +In this section, we compare our proposed algorithm with other existing work. We first test ImageNet models1. Here we choose the widely adopted ResNet-34 (He et al., 2016) and VGG-16 (Simonyan & Zisserman, 2014) in the existing literature. Note that we test ANNs both with and without BN layers. We additionally verify our algorithm on MobileNet (Howard et al., 2017). To our best knowledge, this is the first work that studies Spiking MobileNet conversion. + +Results can be found in Table 9. For both ResNet-34 and + +VGG-16 without BN, our light pipeline is within $1\%$ accuracy loss when $T = 128$ . On models with BN layers, our method can substantially improve the conversion loss. In particular, the light pipeline can improve $50.1\%$ , and the advanced pipeline can improve $64.4\%$ accuracy in ResNet-34 with BN Conversion when $T = 32$ . Baseline methods still produce a large accuracy gap even on VGG-16 without BN layers and AvgPool Conversion. While our light pipeline reaches 73.66 (less than $2\%$ accuracy drop) when $T = 256$ . The superiority of our algorithm is also reflected in Spiking MobileNet conversion, where the baseline method (Deng & Gu, 2021) crashed when $T \leq 256$ . To reach acceptable accuracy of Spiking MobileNet, the baseline method has to increase $T$ to 2048. However, our advanced pipeline can achieve higher accuracy while reducing $8\times$ simulation length (69.02 when $T = 256$ ). Finally, we test our algorithm on a large ANN, RegNetX-4GF (Radosavovic et al., 2020) which achieves $79.4\%$ top-1 accuracy. Our light pipeline reaches $73\%$ accuracy when $T = 128$ and our advanced pipeline reaches $75.8\%$ accuracy when $T = 128$ . + +
ModelBCPCWC
VGG-160.098±0.0030.106±0.0174.70±0.037
MobileNet2.29±0.0052.19±0.0127.6±1.62
+ +Table 6. Conversion time (minutes) for different calibration algorithm. We set $T = 64$ and test VGG-16 on CIFAR100 and MobileNet on ImageNet. + +
#Samples3264128256
VGG-1664.50±1.1965.12±1.0266.04±0.7266.20±0.58
ResNet-2075.35±0.1675.41±0.1875.43±0.0975.41±0.08
+ +Table 7. Comparison of the accuracy using different number of data samples for bias correction. + +# 5.4. Complexity Study + +Time Complexity During run-time, our converted SNN will not produce additional inference time. However, converting SNN using light or advanced pipeline may require time and computing resources. The time needed for each calibration is described in the table below. All experiments were tested on a single NVIDIA GTX 1080TI with 5 runs. In Table 6, we can see that the Bias Calibration and Potential Calibration only takes limited time on CIFAR100 and ImageNet. Using Weights Calibration is much expensive than the other two methods. For example, calibrate a MobileNet on ImageNet may take 30 minutes using the advanced pipeline. We should emphasize that our advanced pipeline is still much cheaper than Hybrid Train (Rathi et al., 2019), which requires 20 epochs of end-to-end training (hundreds of GPU hours). + +Space Complexity In this section, we report the memory requirements for each calibration algorithm. Since our method will calibrate a new set of parameters for different $T$ , therefore it is necessary to study the model size if we want to deploy SNNs under different $T$ . Specifically, calibrating the bias of ResNet-34 on ImageNet only requires 0.3653MB memory. However, calibrating the weights and potential requires 83.25MB and 18.76MB, respectively. Thus, our proposed light pipeline is both computational and memory cheap and is optimal for flexible SNN conversion. In contrast, the advanced pipeline (PC and WC) requires much more memory space. One may optionally only apply PC to lower down the memory footprint of ResNet-34. Interestingly, some tiny structures like MobileNet share less weights memory (12.21MB) but higher activation memory (19.81MB). + +Data Sample Complexity We study the robustness of the our algorithm by increasing the size of calibration dataset. Here we test Bias Calibration in Table 7 on ResNet-20 and VGG-16 ( $T = 32$ ). By increasing the number of samples for calibration, the accuracy will also increase. However, + +![](images/11e8a556a8c057125b7d9e542f4baf528e17236cf796c81cb6d5044652db473a.jpg) +Figure 3. Firing rate visualization of VGG-16. + +we can see that in ResNet-20 the effect of samples is trivial. While in VGG-16, increasing the number of samples from 32 to 256 can increase $1.7\%$ mean accuracy. We also find that more samples lead to a stable calibration result. Therefore, we recommend using at least 128 images for calibration. In our experiments, the same trend is also observed in other calibration algorithms. + +# 5.5. Efficiency and Sparsity + +In this section we visualize the sparsity of our calibrated SNN. We choose the spike VGG-16 on the ImageNet dataset, with $T = 64$ . We only leverage light pipeline (bias calibration) and record the mean firing ratio across the whole validation dataset, which also corresponds to sparsity of the activation. The firing ratio is demonstrated in Fig. 3, where we can find the maximum firing ratio is under 0.08, and the minimum firing ratio can be 0.025. To quantitatively compute the energy saving, we use the energy-estimation equation in Rathi & Roy (2020). For addition, we measure it by $0.9J$ per operation; for multiplication, we measure it by $4.6J$ per operation. On the event-driven neuromorphic hardware, a non-firing neuron will not cost any energy. Based on this rule, our calibrated spiking VGG-16 only costs $69.36\%$ energy of ANN's consumption. + +# Conclusion + +In this work, we analyze the composition of conversion error and its cumulative effect. To reduce the gap between ANN activation and SNN activation, we propose adaptive threshold to determine the threshold in different time steps. We also introduce the layer-wise calibration, which significantly improves the performance of SNN compared with other simple-copy methods. Layer-wise calibration is easy to use and only requires a few training images. Our method estab + +lishes new state-of-the-art performance for SNN conversion. It can successfully convert challenging architectures like MobileNet and RegNetX-4GF with a low latency (less than 256 time steps) for the first time. Even when converting the ANN with Batch Normalization layers, our method can preserve high classification accuracy. + +# Acknowledgement + +This work is supported by NSFC 61876032. We greatly thank anonymous reviewers for their kind suggestions to this work. + +# References + +Amir, A., Taba, B., Berg, D., Melano, T., McKinstry, J., Di Nolfo, C., Nayak, T., Andreopoulos, A., Garreau, G., Mendoza, M., et al. A low power, fully event-based gesture recognition system. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 7243-7252, 2017. +Barbi, M., Chillemi, S., Di Garbo, A., and Reale, L. Stochastic resonance in a sinusoidally forced lif model with noisy threshold. *Biosystems*, 71(1-2):23-28, 2003. +Bengio, Y., Léonard, N., and Courville, A. Estimating or propagating gradients through stochastic neurons for conditional computation. arXiv preprint arXiv:1308.3432, 2013. +Cao, Y., Chen, Y., and Khosla, D. Spiking deep convolutional neural networks for energy-efficient object recognition. International Journal of Computer Vision, 113(1): 54-66, 2015. +Cubuk, E. D., Zoph, B., Mane, D., Vasudevan, V., and Le, Q. V. Autoaugment: Learning augmentation strategies from data. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 113-123, 2019. +Deng, J., Dong, W., Socher, R., Li, L.-J., Li, K., and Fei-Fei, L. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pp. 248-255. IEEE, 2009. +Deng, L., Wu, Y., Hu, X., Liang, L., Ding, Y., Li, G., Zhao, G., Li, P., and Xie, Y. Rethinking the performance comparison between snns and anns. *Neural Networks*, 121: 294 - 307, 2020. +Deng, S. and Gu, S. Optimal conversion of conventional artificial neural networks to spiking neural networks. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id=FZ1oTwcXchK. + +DeVries, T. and Taylor, G. W. Improved regularization of convolutional neural networks with cutout. arXiv preprint arXiv:1708.04552, 2017. +Diehl, P. U., Neil, D., Binas, J., Cook, M., and Liu, S. C. Fast-classifying, high-accuracy spiking deep networks through weight and threshold balancing. In Neural Networks (IJCNN), 2015 International Joint Conference on, 2015. +Diehl, P. U., Zarrella, G., Cassidy, A., Pedroni, B. U., and Neftci, E. Conversion of artificial recurrent neural networks to spiking neural networks for low-power neuromorphic hardware. In 2016 IEEE International Conference on Rebooting Computing (ICRC), pp. 1-8. IEEE, 2016. +Han, B. and Roy, K. Deep spiking neural network: Energy efficiency through time based coding. In European Conference on Computer Vision, 2020. +Han, B., Srinivasan, G., and Roy, K. Rmp-snn: Residual membrane potential neuron for enabling deeper high-accuracy and low-latency spiking neural network. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 13558-13567, 2020. +He, K., Zhang, X., Ren, S., and Jian, S. Deep residual learning for image recognition. In 2016 IEEE Conference on Computer Vision and Pattern Recognition, 2016. +He, T., Zhang, Z., Zhang, H., Zhang, Z., Xie, J., and Li, M. Bag of tricks for image classification with convolutional neural networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 558-567, 2019. +Hodgkin, A. L. and Huxley, A. F. A quantitative description of membrane current and its application to conduction and excitation in nerve. The Journal of physiology, 117 (4):500-544, 1952. +Howard, A. G., Zhu, M., Chen, B., Kalenichenko, D., Wang, W., Weyand, T., Andreetto, M., and Adam, H. Mobilenets: Efficient convolutional neural networks for mobile vision applications. arXiv preprint arXiv:1704.04861, 2017. +Iyer, L. R. and Chua, Y. Classifying neuromorphic datasets with tempotron and spike timing dependent plasticity. In 2020 International Joint Conference on Neural Networks (IJCNN), pp. 1-8. IEEE, 2020. +Izhikevich, E. M. Simple model of spiking neurons. IEEE Transactions on neural networks, 14(6):1569-1572, 2003. +Kheradpisheh, S. R., Ganjtabesh, M., Thorpe, S. J., and Masquelier, T. Stdp-based spiking deep convolutional + +neural networks for object recognition. Neural Networks, 99:56-67, 2018. +Kim, S., Park, S., Na, B., and Yoon, S. Spiking-yolo: Spiking neural network for energy-efficient object detection. arXiv preprint arXiv:1903.06530, 2019. +Krizhevsky, A., Nair, V., and Hinton, G. Cifar-10 (canadian institute for advanced research). URL http://www.cs.toronto.edu/~kriz/cifar.html. +LI, S.-L. and LI, J.-P. Research on learning algorithm of spiking neural network. In 2019 16th International Computer Conference on Wavelet Active Media Technology and Information Processing, pp. 45-48. IEEE, 2019. +Liu, Y.-H. and Wang, X.-J. Spike-frequency adaptation of a generalized leaky integrate-and-fire model neuron. Journal of computational neuroscience, 10(1):25-45, 2001. +Loshchilov, I. and Hutter, F. Sgdr: Stochastic gradient descent with warm restarts. arXiv preprint arXiv:1608.03983, 2016. +Neftci, E. O., Mostafa, H., and Zenke, F. Surrogate gradient learning in spiking neural networks: Bringing the power of gradient-based optimization to spiking neural networks. IEEE Signal Processing Magazine, 36(6):51-63, 2019. +Radosavovic, I., Kosaraju, R. P., Girshick, R., He, K., and Dollar, P. Designing network design spaces. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 10428-10436, 2020. +Rathi, N. and Roy, K. Diet-snn: Direct input encoding with leakage and threshold optimization in deep spiking neural networks. arXiv preprint arXiv:2008.03658, 2020. +Rathi, N., Srinivasan, G., Panda, P., and Roy, K. Enabling deep spiking neural networks with hybrid conversion and spike timing dependent backpropagation. In International Conference on Learning Representations, 2019. +Roy, D., Chakraborty, I., and Roy, K. Scaling deep spiking neural networks with binary stochastic activations. In 2019 IEEE International Conference on Cognitive Computing (ICCC), pp. 50-58. IEEE, 2019a. +Roy, K., Jaiswal, A., and Panda, P. Towards spike-based machine intelligence with neuromorphic computing. Nature, 575(7784):607-617, 2019b. +Rueckauer, B., Lungu, I.-A., Hu, Y., and Pfeiffer, M. Theory and tools for the conversion of analog to spiking convolutional neural networks. arXiv: Statistics/Machine Learning, (1612.04052):0-0, 2016. + +Rueckauer, B., Lungu, I.-A., Hu, Y., Pfeiffer, M., and Liu, S.-C. Conversion of continuous-valued deep networks to efficient event-driven networks for image classification. Frontiers in neuroscience, 11:682, 2017. +Sengupta, A., Ye, Y., Wang, R., Liu, C., and Roy, K. Going deeper in spiking neural networks: Vgg and residual architectures. Frontiers in Neuroence, 13, 2018. +Shrestha, S. B. and Orchard, G. Slayer: Spike layer error reassignment in time. In Advances in Neural Information Processing Systems, pp. 1412-1421, 2018. +Simonyan, K. and Zisserman, A. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014. +Szegedy, C., Vanhoucke, V., Ioffe, S., Shlens, J., and Wojna, Z. Rethinking the inception architecture for computer vision. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2818-2826, 2016. +Tavanaei, A., Ghodrati, M., Kheradpisheh, S. R., Masquelier, T., and Maida, A. Deep learning in spiking neural networks. Neural Networks, 111:47-63, 2019. +Wu, Y., Deng, L., Li, G., Zhu, J., and Shi, L. Spatiotemporal backpropagation for training high-performance spiking neural networks. Frontiers in neuroscience, 12: 331, 2018. \ No newline at end of file diff --git a/afreelunchfromanntowardsefficientaccuratespikingneuralnetworkscalibration/images.zip b/afreelunchfromanntowardsefficientaccuratespikingneuralnetworkscalibration/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..4f04e2ae7313df32a553ef3a202dad0e003be4fc --- /dev/null +++ b/afreelunchfromanntowardsefficientaccuratespikingneuralnetworkscalibration/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c0f8775da5f3919cf56c529934a592e219cf3d014065c77229ebbe5faf535c1f +size 481116 diff --git a/afreelunchfromanntowardsefficientaccuratespikingneuralnetworkscalibration/layout.json b/afreelunchfromanntowardsefficientaccuratespikingneuralnetworkscalibration/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..e2a77c8560419ed014f4516ea3eaabdea7b673ba --- /dev/null +++ b/afreelunchfromanntowardsefficientaccuratespikingneuralnetworkscalibration/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c0446d1509670cc931aa7b95ece1193cdc133d82e082cfddeeda1ce439fcfd43 +size 418742 diff --git a/afunctionalperspectiveonlearningsymmetricfunctionswithneuralnetworks/e293ee91-2326-4d01-89cf-ffaa0a8c5cb1_content_list.json b/afunctionalperspectiveonlearningsymmetricfunctionswithneuralnetworks/e293ee91-2326-4d01-89cf-ffaa0a8c5cb1_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..fd9ba3ccf9850244bf9c5162253d17d650b7919f --- /dev/null +++ b/afunctionalperspectiveonlearningsymmetricfunctionswithneuralnetworks/e293ee91-2326-4d01-89cf-ffaa0a8c5cb1_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3da3eac29981b16adfc0cba89eb2f36bd8a7f01494eeca5c2313502100a9515d +size 82554 diff --git a/afunctionalperspectiveonlearningsymmetricfunctionswithneuralnetworks/e293ee91-2326-4d01-89cf-ffaa0a8c5cb1_model.json b/afunctionalperspectiveonlearningsymmetricfunctionswithneuralnetworks/e293ee91-2326-4d01-89cf-ffaa0a8c5cb1_model.json new file mode 100644 index 0000000000000000000000000000000000000000..88dba8f55a9a3edae321ef15af7851214fc24d53 --- /dev/null +++ b/afunctionalperspectiveonlearningsymmetricfunctionswithneuralnetworks/e293ee91-2326-4d01-89cf-ffaa0a8c5cb1_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7a1117c43791fb4f1a5b3623b42e203390a99550be9780580aaa76011b95a645 +size 98185 diff --git a/afunctionalperspectiveonlearningsymmetricfunctionswithneuralnetworks/e293ee91-2326-4d01-89cf-ffaa0a8c5cb1_origin.pdf b/afunctionalperspectiveonlearningsymmetricfunctionswithneuralnetworks/e293ee91-2326-4d01-89cf-ffaa0a8c5cb1_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..172876c1f7a058b9976e25322a1a6c3f9254a29b --- /dev/null +++ b/afunctionalperspectiveonlearningsymmetricfunctionswithneuralnetworks/e293ee91-2326-4d01-89cf-ffaa0a8c5cb1_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:96be9420ec23f6257917824bf31553304c9fcd0e6a06ea8e603c160bb3fdb280 +size 599255 diff --git a/afunctionalperspectiveonlearningsymmetricfunctionswithneuralnetworks/full.md b/afunctionalperspectiveonlearningsymmetricfunctionswithneuralnetworks/full.md new file mode 100644 index 0000000000000000000000000000000000000000..ad27f01c1fc924897d00fdc2d21490f9a32804b8 --- /dev/null +++ b/afunctionalperspectiveonlearningsymmetricfunctionswithneuralnetworks/full.md @@ -0,0 +1,352 @@ +# A Functional Perspective on Learning Symmetric Functions with Neural Networks + +Aaron Zweig1 Joan Bruna1,2 + +# Abstract + +Symmetric functions, which take as input an unordered, fixed-size set, are known to be universally representable by neural networks that enforce permutation invariance. These architectures only give guarantees for fixed input sizes, yet in many practical applications, including point clouds and particle physics, a relevant notion of generalization should include varying the input size. In this work we treat symmetric functions (of any size) as functions over probability measures, and study the learning and representation of neural networks defined on measures. By focusing on shallow architectures, we establish approximation and generalization bounds under different choices of regularization (such as RKHS and variation norms), that capture a hierarchy of functional spaces with increasing degree of non-linear learning. The resulting models can be learned efficiently and enjoy generalization guarantees that extend across input sizes, as we verify empirically. + +# 1. Introduction + +Deep learning becomes far more efficient with prior knowledge of function invariants. This knowledge underlies architectural choices that enforce the invariance or equivariance in the network, including Convolutional Neural Networks (LeCun et al., 1998) which encode translation symmetries, and Graph Neural Networks (Scarselli et al., 2008) which encode conjugate permutation symmetries. For functions with invariance to permutation of the input elements, several universal architectures encode this invariance by treating the input as a set (Zaheer et al., 2017; Qi et al., 2017). However, these formulations assume a constant input size, which precludes learning an entire family of symmetric functions. + +Such symmetric functions appear naturally across several domains, including particle physics, computer graphics, population statistics and cosmology. Yet, in most of these applications, the input size corresponds to a sampling parameter that is independent of the underlying symmetric function of interest. As a motivating example, consider the function family induced by the max function, where for varying $N$ , $f_{N}(\{x_{1}\ldots x_{N}\}) = \max_{i\leq N}x_{i}$ . It is natural to ask if a network can simultaneously learn all these functions. + +In this work, we interpret input sets as an empirical measure defined over the base space $\mathbb{I}$ , and develop families of neural networks defined over the space of probability measures probability measures of $\mathbb{I}$ , as initially suggested in (Pevny & Kovarik, 2019; De Bie et al., 2019). We identify functional spaces characterized by neural architectures and provide generalization bounds that showcase a natural hierarchy among spaces of symmetric functions. In particular, our framework allows us to understand the question of generalizing across input sizes as a corollary. Our constructions rely on the theory of infinitely wide neural networks (Bengio et al., 2006; Rosset et al., 2007; Bach, 2017a), and provide a novel instance of depth separation leveraging the symmetric structure of the input. + +Summary of Contributions: We consider the infinite-width limit of neural networks taking as domain the space of probability measures in order to formalize learning of symmetric function families. We prove a necessary and sufficient condition for which symmetric functions can be learned. By controlling the amount of non-linear learning, we partition the space of networks on measures into several function classes, proving a separation result among the classes as well as proving a generalization result and empirically studying the performance of these classes to learn symmetric functions on synthetic and real-world data. + +Related Work Several works consider representing symmetric functions of fixed input size with invariant neural networks, and in particular there are two main universal architectures, DeepSets (Zaheer et al., 2017) and PointNet (Qi et al., 2017). An alternative generalization of DeepSets is given in (Maron et al., 2019), which proves the universality of tensor networks invariant to any subgroup of the + +symmetric group. Regarding variable input size, the work from (Wagstaff et al., 2019) proves lower bounds on representation of the max function in the DeepSets architecture with a dependency on input size. + +Separately, there is a wide literature considering neural networks that act on elements on functional data. These results mainly consider universal approximation (Sandberg & Xu, 1996; Stinchcombe, 1999; Rossi & Conan-Guez, 2005). The work (Mhaskar & Hahm, 1997) bears some similarity to the present work, as they prove a quantitative separation between the class of neural networks and the class of functionals with bounded norm, while our main result shows separations among several neural network classes. + +The work most similar to ours are (Pevny & Kovarik, 2019; De Bie et al., 2019), which also normalize the DeepSets architecture to define a function on measures. However, they only prove the universality of this model, while we justify the model by classifying symmetric families that are representable and recovering generalization results. We also build on the framework given by (Bach, 2017a), which introduces function classes to characterize neural networks in the wide limit, and proves statistical generalization bounds to demonstrate the advantage of non-linear learning. Although we motivate our work from symmetric functions on finite sets, there are applications in multi-label learning (Frogner et al., 2015) and evolving population dynamics (Hashimoto et al., 2016) that require functions of measures. + +Roadmap: We introduce notation and summarize the infinite-dimensional convex network theory theory (Bach, 2017a) in Section 2. In Section 3 we introduce measure networks and characterize their relationship to symmetric functions. Section 4 gives our main result, separating several classes of measure networks according to the degree of non-linear learning, and Section 5 introduces generalization results. Finally, we detail several experiments with the finite instantiation of measure networks in Section 6. + +# 2. Preliminaries + +# 2.1. Problem Setup + +Let $\mathbb{I} \subseteq \mathbb{R}^d$ be a convex domain, and $N \in \mathbb{N}$ . A symmetric function $f: \mathbb{I}^N \to \mathbb{R}$ is such that $f(x_1, \ldots, x_N) = f(x_{\pi(1)}, \ldots, x_{\pi(N)})$ for any $x \in \mathbb{I}^N$ and any permutation $\pi \in S_N$ . In this work, we are interested in learning symmetric functions defined independently of $N$ . Let $\overline{\mathbb{I}} = \bigcup_{N=1}^{\infty} \mathbb{I}^N$ , then $f: \overline{\mathbb{I}} \to \mathbb{R}$ is symmetric if $f$ restricted to $\mathbb{I}^N$ is symmetric for each $N \in \mathbb{N}$ . Let $\mathcal{F}_{\mathrm{sym}}$ denote the space of symmetric functions defined on $\overline{\mathbb{I}}$ . This setting is motivated by applications in statistical mechanics and particle physics, where $N$ is a sampling parameter. + +We focus on the realizable regression setting, where we + +observe a dataset $\{(x_i, f^*(x_i)) \in \overline{\mathbb{I}} \times \mathbb{R}\}_{i=1,\ldots,n}$ of $n$ samples from an unknown symmetric function $f^*$ , and $\pmb{x}_i$ are drawn iid from a distribution $\mathcal{D}$ on $\overline{\mathbb{I}}$ . The goal is to find a proper estimator $\hat{f} \in \mathcal{F}_{\mathrm{sym}}$ such that the population error $\mathbb{E}_{\pmb{x} \sim \mathcal{D}} \ell(f^*(\pmb{x}), \hat{f}(\pmb{x}))$ is low, where $\ell$ is a convex loss. + +Following a standard Empirical Risk Minimisation setup (Shalev-Shwartz & Ben-David, 2014; Bach, 2017a), we will construct hypothesis classes $\mathcal{F} \subset \mathcal{F}_{\mathrm{sym}}$ endowed with a metric $\|f\|_{\mathcal{F}}$ , and consider + +$$ +\hat {f} \in \underset {f \in \mathcal {F}; \| f \| _ {\mathcal {F}} \leq \delta} {\arg \min } \frac {1}{n} \sum_ {i = 1} ^ {n} \ell \left(f ^ {*} \left(\boldsymbol {x} _ {i}\right), f \left(\boldsymbol {x} _ {i}\right)\right), \tag {1} +$$ + +where $\delta$ is a regularization parameter that is optimised using e.g. cross-validation. We focus on the approximation and statistical aspects of this estimator for different choices of $\mathcal{F}$ ; solving the optimization problem (1) is not the focus of the present work and will be briefly discussed in Section 7. + +# 2.2. Symmetric Polynomials + +A simplest way to approximate symmetric functions is with symmetric polynomials. Combining Weierstrass approximation theory with a symmetrization argument, it can be seen that assuming $d = 1$ , any symmetric continuous function $f: \mathbb{I}^N \to \mathbb{R}$ can be uniformly approximated by symmetric polynomials (see (Yarotsky, 2018) for a proof). There are several canonical bases over the ring of symmetric polynomials, but we will consider the one given by the power sum polynomials, given by $p_k(x) = \sum_{i=1}^{N} x_i^k$ , with $x \in \mathbb{I}^N$ . + +Theorem 2.1 ((2.12) in (Macdonald, 1998)) For any symmetric polynomial $f$ on $N$ inputs, there exists a polynomial $q$ such that $f(x) = q(p_1(x), \ldots, p_N(x))$ . + +If $q$ is linear, this theorem suggests a simple predictor for symmetric functions across varying $N$ . If $x \in \mathbb{I}^M$ , we can consider $x \mapsto \sum_{i=1}^{N} c_i \left(\frac{1}{M} p_i(x)\right) = \sum_{i=1}^{N} c_i \mathbb{E}_{y \sim \mu}(y^i)$ where $\mu = \frac{1}{M} \sum_{j=1}^{M} \delta_{x_j}$ . The truncated moments of the empirical distribution given by $x$ act as linear features, which yield an estimator over any input size $M$ . We will consider a generalization of this decomposition, by moving beyond the polynomial kernel to a general RKHS (see Section 3.1). + +# 2.3. Convex Shallow Neural Networks + +By considering the limit of infinitely many neurons (Bengio et al., 2006; Rosset et al., 2007), (Bach, 2017a) introduces two norms on shallow neural representation of functions $\phi$ defined over $\mathbb{R}^d$ . For a constant $R \in \mathbb{R}$ , a fixed probability measure $\kappa \in \mathcal{P}(\mathbb{S}^d)$ with full support, a signed Radon measure $\nu \in \mathcal{M}(\mathbb{S}^d)$ , a density $p \in L_2(d\kappa)$ , and the notation that $\tilde{x} = [x,R]^T$ , define: + +$$ +\begin{array}{l} \gamma_ {1} (\phi) = \inf \left\{\| \nu \| _ {\mathrm {T V}}; \phi (x) = \int_ {\mathbb {S} ^ {d}} \sigma_ {\alpha} (\langle w, \tilde {x} \rangle) \nu (d w) \right\} \text {a n d} \\ \gamma_ {2} (\phi) = \inf \left\{\| p \| _ {L _ {2}}; \phi (x) = \int_ {\mathbb {S} ^ {d}} \sigma_ {\alpha} (\langle w, \tilde {x} \rangle) p (w) \kappa (d w) \right\} \\ \end{array} +$$ + +where $\| \nu \|_{\mathrm{TV}} \coloneqq \sup_{|g| \leq 1} \int g d\nu$ is the Total Variation of $\nu$ and $\sigma_{\alpha}(t) = \max (0, t)^{\alpha}$ is the ReLU activation raised to the positive integer power $\alpha$ . These norms measure the minimal representation of $\phi$ , using either a Radon measure $\nu$ over neuron weights, or a density $p$ over the fixed probability measure $\kappa$ . The norms induce function classes: + +$$ +\mathcal {F} _ {1} = \{\phi \in C _ {0} (\mathbb {I}): \gamma_ {1} (\phi) < \infty \}, +$$ + +$$ +\mathcal {F} _ {2} = \left\{\phi \in C _ {0} (\mathbb {I}): \gamma_ {2} (\phi) < \infty \right\}. +$$ + +We also assume that the input domain $\mathbb{I}$ is bounded with $\sup_{x\in \mathbb{I}}\| x\| _2\leq R$ + +These two functional spaces are fundamental for the theoretical study of shallow neural networks and capture two distinct regimes of overparametrisation: whereas the so-called lazy or kernel regime corresponds to learning in the space $\mathcal{F}_2$ (Chizat & Bach, 2018; Jacot et al., 2018), which is in fact an RKHS with kernel given by $k(x,y) = \mathbb{E}_{w\sim \kappa}[\sigma_{\alpha}(\langle w,\tilde{x}\rangle)\sigma_{\alpha}(\langle w,\tilde{y}\rangle)]$ (Bach, 2017a)1, the meanfield regime captures learning in $\mathcal{F}_1$ , which satisfies $\mathcal{F}_2\subset \mathcal{F}_1$ from Jensen's inequality, and can efficiently approximate functions with hidden low-dimensional structure, as opposed to $\mathcal{F}_2$ (Bach, 2017a). + +Finally, one can leverage the fact that the kernel above is an expectation over features to define a finite-dimensional random feature kernel $k_{m}(x,y) = \frac{1}{m}\sum_{j = 1}^{m}\sigma_{\alpha}(\langle w_{j},\tilde{x}\rangle)\sigma_{\alpha}(\langle w_{j},\tilde{y}\rangle)$ with $w_{j} \stackrel{i.i.d.}{\sim} \kappa$ , which defines a (random) RKHS $\mathcal{F}_{2,m}$ converging to $\mathcal{F}_2$ as $m$ increases (Bach, 2017b; Rahimi & Recht, 2008). The empirical norm $\gamma_{2,m}$ can be defined similarly to $\gamma_{2}$ , where the density $p$ is replaced by coefficients over the sampled basis functions $\sigma_{\alpha}(\langle w_j,\cdot \rangle)$ . + +# 2.4. Symmetric Neural Networks + +A universal approximator for symmetric functions was proposed by (Zaheer et al., 2017), which proved that for any fixed $N$ and $f_{N}\in \mathcal{F}_{\mathrm{sym}}^{N}$ there must exist $\Phi :\mathbb{I}\to \mathbb{R}^L$ and $\rho :\mathbb{R}^L\to \mathbb{R}$ such that + +$$ +f _ {N} (x) = \rho \left(\frac {1}{N} \sum_ {n = 1} ^ {N} \Phi \left(x _ {n}\right)\right). \tag {2} +$$ + +However, universality is only proven for fixed $N$ . Given a symmetric function $f \in \mathcal{F}_{\mathrm{sym}}$ we might hope to learn $\rho$ + +and $\Phi$ such that this equation holds for all $N$ . Note that the fraction $\frac{1}{N}$ is not present in their formulation, but is necessary for generalization across $N$ to be feasible (as otherwise the effective domain of $\rho$ could grow arbitrarily large as $N \to \infty$ ). + +Treating the input to $\rho$ as an average motivates moving from sets to measures as inputs, as proposed in (Pevny & Kovarik, 2019; De Bie et al., 2019). Given $x\in \mathbb{I}^N$ , let $\mu^{(N)} = \frac{1}{N}\sum_{i = 1}^{N}\delta_{x_i}$ denote the empirical measure in the space $\mathcal{P}(\mathbb{I})$ of probability measures over $\mathbb{I}$ . Then (2) can be written as $f_{N}(x) = \rho \left(\int_{\mathbb{I}}\Phi (u)\mu^{(N)}(du)\right)$ . + +# 3. From Set to Measure Functions + +# 3.1. Neural Functional Spaces for Learning over Measures + +Equipped with the perspective of (2) acting on an empirical measure, we consider shallow neural networks that take probability measures as inputs, with test functions as weights. We discuss in Section 3.2 which functions defined over sets admit an extension to functions over measures. + +Let $\mathcal{A}$ be a subset of $C_0(\mathbb{I})$ , equipped with its Borel sigma algebra. For $\mu \in \mathcal{P}(\mathbb{I})$ , and a signed Radon measure $\chi \in \mathcal{M}(\mathcal{A})$ , define $f:\mathcal{P}(\mathbb{I})\to \mathbb{R}$ as + +$$ +f (\mu ; \chi) = \int_ {\mathcal {A}} \widetilde {\sigma} (\langle \phi , \mu \rangle) \chi (d \phi). \tag {3} +$$ + +where $\widetilde{\sigma}$ is again a scalar activation function, such as the ReLU, and $\langle \phi ,\mu \rangle \coloneqq \int_{\mathbb{I}}\phi (x)\mu (dx)$ . Crucially, the space of functions given by $f(\cdot ;\chi)$ were proven to be dense in the space of real-valued continuous (in the weak topology) functions on $\mathcal{P}(\mathbb{I})$ in (Pevny & Kovarik, 2019; De Bie et al., 2019), and so this network exhibits universality. + +Keeping in mind the functional norms defined on test functions in Section 2.3, we can introduce analogous norms for neural networks on measures. For a fixed probability measure $\tau \in \mathcal{P}(\mathcal{A})$ , define + +$$ +\| f \| _ {1, \mathcal {A}} = \inf \left\{\| \chi \| _ {\mathrm {T V}}; f (\mu) = \int_ {\mathcal {A}} \widetilde {\sigma} (\langle \phi , \mu \rangle) \chi (d \phi) \right\}, \tag {4} +$$ + +$$ +\| f \| _ {2, \mathcal {A}} = \inf \left\{\| q \| _ {L _ {2}}; f (\mu) = \int_ {\mathcal {A}} \widetilde {\sigma} (\langle \phi , \mu \rangle) q (\phi) \tau (d \phi) \right\}, \tag {5} +$$ + +where we take the infima over Radon measures $\chi \in \mathcal{M}(\mathcal{A})$ and densities $q\in L_2(d\tau)$ . Analogously these norms also induce the respective function classes $\mathcal{G}_1(\mathcal{A}) = \{f:\| f\|_{1,\mathcal{A}} < \infty \}$ , $\mathcal{G}_2(\mathcal{A}) = \{f:\| f\|_{2,\mathcal{A}} < \infty \}$ . The argument in Appendix A of (Bach, 2017a) implies $\mathcal{G}_2(\mathcal{A})$ is an RKHS, with associated kernel $k_{\mathcal{G}}(\mu ,\mu^{\prime}) = \int_{\mathcal{A}}\widetilde{\sigma} (\langle \phi ,\mu \rangle)\widetilde{\sigma} (\langle \phi ,\mu^{\prime}\rangle)\tau (d\phi)$ . + +Moving from vector-valued weights to function-valued weights presents an immediate issue. The space $C_0(\mathbb{I})$ is infinite-dimensional, and it is not obvious how to learn a measure $\chi$ over this entire space. Moreover, our ultimate goal is to understand finite-width symmetric networks, so we would prefer the function-valued weights be efficiently calculable rather than pathological. To that end, we choose the set of test functions $\mathcal{A}$ to be representable as regular neural networks. + +
Explicitly, using the function norms of Section 2.3, define A1,m = {φ; φ(x) = ∑j=1m βjσα(⟨wj, x⟩, ||wj||2 ≤ 1, ||β||1 ≤ 1} and A2,m = {φ ∈ F2,m: γ2,m(φ) ≤ 1}.
+ +$\mathcal{A}_{1,m}$ thus contains functions in the unit ball of $\mathcal{F}_1$ that can be expressed with $m$ neurons, and $\mathcal{A}_{2,m}$ contains functions in the (random) RKHS $\mathcal{F}_{2,m}$ obtained by sampling $m$ neurons from $\kappa$ . By definition $\mathcal{A}_{2,m} \subset \mathcal{A}_{1,m}$ for all $m$ . Representational power grows with $m$ , and observe that the approximation rate in the unit ball of $\mathcal{F}_1$ or $\mathcal{F}_2$ is in $m^{-1/2}$ , obtained for instance with Monte-Carlo estimators (Bach, 2017a; Ma et al., 2019). Hence we can also consider the setting where $m = \infty$ , with the notation $\mathcal{A}_{\{i,\infty\}} = \{\phi \in \mathcal{F}_i : \gamma_i(\phi) \leq 1\}$ . Note also that there is no loss of generality in choosing the radius to be 1, as by homogeneity of $\sigma$ any $\phi$ with $\gamma_i(\phi) < \infty$ can be scaled into its respective norm ball. + +We now examine the combinations of $\mathcal{G}_i$ with $\mathcal{A}_i$ : + +- $\mathcal{S}_{1,m} \coloneqq \mathcal{G}_1(\mathcal{A}_{1,m})$ ; the measure $\chi$ is supported on test functions in $\mathcal{A}_{1,m}$ . +- $\mathcal{S}_{2,m} := \mathcal{G}_1(\mathcal{A}_{2,m})$ ; $\chi$ is supported on test functions in $\mathcal{A}_{2,m}$ . +- $S_{3,m} \coloneqq \mathcal{G}_2(\mathcal{A}_{2,m})$ ; $\chi$ has a density with regards to $\tau$ , which is supported on $\mathcal{A}_{2,m}$ . +- The remaining class $\mathcal{G}_2(\mathcal{A}_{1,m})$ requires defining a probability measure $\tau$ over $\mathcal{A}_{1,m}$ that sufficiently spreads mass outside of any RKHS ball. Due to the difficulty in defining this measure in finite setting, we omit this class. + +Note that from Jensen's inequality and the inclusion $\mathcal{A}_{2,m} \subset \mathcal{A}_{1,m}$ for all $m$ , we have the inclusions $S_{3,m} \subset S_{2,m} \subset S_{1,m}$ . And $S_{3,m}$ is clearly an RKHS, since it is a particular instantiation of $\mathcal{G}_2(\mathcal{A})$ . In the sequel we will drop the subscript $m$ and simply write $\mathcal{A}_i$ and $S_i$ . + +These functional spaces provide an increasing level of adaptivity: while $S_{2}$ is able to adapt by selecting 'useful' test functions $\phi$ , it is limited to smooth test functions that lie on the RKHS, whereas $S_{1}$ is able to also adapt to more irregular + +
First LayerSecond LayerThird Layer
S1TrainedTrainedTrained
S2FrozenTrainedTrained
S3FrozenFrozenTrained
+ +Table 1: Training for finite function approximation + +test functions that themselves depend on low-dimensional structures from the input domain. We let $\| f\|_{S_i}$ denote the associated norm, i.e. $\| f\|_{S_1} \coloneqq \| f\|_{1,A_1}$ . + +Finite-Width Implementation: For any $m$ , these classes admit a particularly simple interpretation when implemented in practice. On the one hand, the spaces of test functions are implemented as a single hidden-layer neural network of width $m$ . On the other hand, the integral representations in (4) and (5) are instantiated by a finite-sum using $m'$ neurons, leading to the finite analogues of our function classes given in Table 1. Specifically, + +$$ +f (\mu) = \frac {1}{m ^ {\prime}} \sum_ {j ^ {\prime} = 1} ^ {m ^ {\prime}} b _ {j ^ {\prime}} \widetilde {\sigma} \left(\frac {1}{m} \sum_ {j = 1} ^ {m} c _ {j ^ {\prime}, j} \int \sigma_ {\alpha} (\langle w _ {j ^ {\prime}, j}, \tilde {x} \rangle) \mu (d x)\right) +$$ + +One can verify (Neyshabur et al., 2015) that the finite-width proxy for the variation norm is given by + +$$ +\| f \| _ {1} = \frac {1}{m ^ {\prime}} \sum_ {j ^ {\prime}} | b _ {j ^ {\prime}} | \| \phi_ {j ^ {\prime}} \| _ {1} \leq \frac {1}{m m ^ {\prime}} \sum_ {j ^ {\prime}, j} | b _ {j ^ {\prime}} | | c _ {j ^ {\prime}, j} | \| w _ {j ^ {\prime}, j} \|, +$$ + +which in our case corresponds to the so-called path norm (Neyshabur et al., 2014). In particular, under the practical assumption that the test functions $\phi_{j'}$ are parameterized by two-layer networks with shared first layer, the weight vectors $w_{j',j}$ only depend on $j$ and this norm may be easily calculated as a matrix product of the network weights. We can control this term by constraining the weights of the first two layers to obey our theoretical assumptions (of bounded weights and test functions in respective RKHS balls), and regularize the final network weights. See Section 6 and the Appendix for practical relaxations of the constraints. + +# 3.2. Continuous Extension + +In general, the functions we want to represent don't take in measures $\mu \in \mathcal{P}(\mathbb{I})$ as inputs. In this section, we want to understand when a function $f$ defined on the power set $f:\bar{\mathbb{I}}\to \mathbb{R}$ can be extended to a continuous map $\bar{f}:\mathcal{P}(\mathbb{I})\to \mathbb{R}$ in the weak topology, in the sense that for all $N\in \mathbb{N}$ and all $(x_{1},\ldots x_{N})\in \mathbb{I}^{N},\bar{f}\left(\frac{1}{N}\sum_{i = 1}^{N}\delta_{x_{i}}\right) = f(x_{1},\ldots ,x_{N}).$ + +Observe that by construction $\bar{f}$ captures the permutation symmetry of the original $f$ . Define the mapping $D:\overline{\mathbb{I}}\to \mathcal{P}(\mathbb{I})$ by $D(x_{1},\ldots ,x_{N}) = \frac{1}{N}\sum_{i = 1}^{N}\delta_{x_{i}}$ . Let $\hat{\mathcal{P}}_N(\mathbb{I})\coloneqq D(\mathbb{I}^N)$ and $\hat{\mathcal{P}} (\mathbb{I}) = \bigcup_{N = 1}^{\infty}\hat{\mathcal{P}}_N(\mathbb{I})$ , so that $\hat{\mathcal{P}} (\mathbb{I})$ is the set + +of all finite discrete measures. For $\mu \in \hat{\mathcal{P}} (\mathbb{I})$ , let $N(\mu)$ be the smallest dimension of a point in $D^{-1}(\mu)$ , and let $x$ be this point (which is unique up to permutation). Then define $\hat{f}:\hat{\mathcal{P}} (\mathbb{I})\to \mathbb{R}$ such that $\hat{f} (\mu) = f_N(x)$ . + +We also write $W_{1}(\mu, \mu')$ as the Wasserstein 1-metric under the $\| \cdot \|_2$ norm (Villani, 2008). The following proposition establishes a necessary and sufficient condition for continuous extension of $f$ : + +Proposition 3.1 There exists a continuous extension $\bar{f}$ iff $\hat{f}$ is uniformly continuous with regard to the $W_{1}$ metric on its domain. + +This result formalises the intuition that extending a symmetric function from sets to measures requires a minimal amount of regularity across sizes. We next show examples of symmetric families that can be extended to $\mathcal{P}(\mathbb{I})$ . + +# 3.3. Examples of Eligible Symmetric Families + +Moment-based Functions: Functions based on finite-range interactions across input elements admit continuous extensions. For example, a function of singleton and pairwise interactions $f(x) = \rho \left( \frac{1}{N} \sum_{i=1}^{N} \phi_1(x_i), \frac{1}{N^2} \sum_{i_1, i_2=1}^{N} \phi_2(x_{i_1}, x_{i_2}) \right)$ is a special case of the continuous measure extension $\bar{f}(\mu) = \rho(\langle \phi_1, \mu \rangle, \langle \phi_2, \mu \otimes \mu \rangle)$ when $\mu = D(x)$ . + +Ranking: Suppose that $\mathbb{I} \subseteq \mathbb{R}$ . The max function $f_{N}(x) = \max_{i \leq N} x_{i}$ cannot be lifted to a function on measures due to discontinuity in the weak topology. Specifically, consider $\mu = \delta_{0}$ and $\nu_{N} = \frac{N - 1}{N} \delta_{0} + \frac{1}{N} \delta_{1}$ . Then $\nu_{N} \rightharpoonup \mu$ , but for $\hat{f}$ as in Proposition 3.1, $\hat{f}(\nu_{N}) = 1 \neq 0 = \hat{f}(\mu)$ . + +Nevertheless, we can define an extension on a smooth approximation via the softmax, namely $g_N^\lambda (x) = \frac{1}{\lambda}\log \frac{1}{N}\sum_{i = 1}^N\exp (\lambda x_i)$ . This formulation, which is the softmax up to an additive term, can clearly be lifted to a function on measures, with the bound $\| g_N^\lambda -f_N\|_\infty \leq \frac{\log N}{\lambda}$ . Although we cannot learn the max family across all $N$ , we can approximate arbitrarily well for bounded $N$ . + +Counterexamples: Define the map $\Delta_k : \mathbb{R}^N \to \mathbb{R}^{kN}$ such that $\Delta_k(x)$ is a vector of $k$ copies of $x$ . Then a necessary condition for the function $\hat{f}$ introduced in Proposition 3.1 to be uniformly continuous is that $f_N(x) = f_{kN}(\Delta_k(x))$ for any $k$ . Intuitively, if $f_N$ can distinguish the input set beyond the amount of mass on each point, it cannot be lifted to measures. This fact implies any continuous approximation to the family $f_N(x) = x_{[2]}$ , the second largest value of $x$ will incur constant error. + +# 4. Approximation and Function Class Separation + +# 4.1. Approximation of single 'neurons' + +In the same spirit as the "separations" between $\mathcal{F}_1$ and $\mathcal{F}_2$ , we characterise prototypical functions that belong to $S_{i}$ but have poor approximation rates in $S_{i+1}$ for $i = \{1,2\}$ in terms of the relevant parameters of the problem, the input dimensionality $d$ and the bandwidth parameter $m$ . Such functions are given by single neurons in a spherical input regime (details for this setting are given in the Appendix). + +For the remainder of this work, we consider $\widetilde{\sigma} = \sigma$ as the ReLU activation, and choose $\alpha = 2$ such that $\sigma_{2}(t) = \sigma (t)^{2}$ is the squared ReLU. + +Theorem 4.1 (informal) Assume $m = \infty$ . For appropriate choices of the kernel base measures $\kappa$ and $\tau$ , there exist $f_{1}$ with $\| f_1\|_{S_1} \leq 1$ and $f_{2}$ with $\| f_2\|_{S_2} \leq 1$ such that: + +$$ +\begin{array}{l} \inf _ {\| f \| _ {S _ {3}} \leq \delta} \| f - f _ {2} \| _ {\infty} \gtrsim d ^ {- 2} \delta^ {- 5 / d}, \\ \inf _ {\| f \| _ {\mathcal {S} _ {2}} \leq \delta} \| f - f _ {1} \| _ {\infty} \gtrsim | d ^ {- 1 1} - d ^ {- d / 3} \delta |. \\ \end{array} +$$ + +The choice of the squared ReLU activation in the parameterization of the test functions is required in the proof separating $S_{1}$ and $S_{2}$ . This follows from some properties of spherical harmonic parity and the decomposition of signed measures into probability measures. + +These separations use the infinity norm rather than an appropriate $L_{2}$ norm, and therefore hold in a weaker norm than separation between $\mathcal{F}_1$ and $\mathcal{F}_2$ . Nevertheless, these separations confirm that symmetric network expressiveness is graded by the degree of non-linear learning. + +Both results hold in the domain $m = \infty$ , so from the concentration of the empirical kernel $k_{m} \to k$ , with high probability these approximation lower bounds will still hold for sufficiently large $m$ . In finite-width implementations, however, $m$ may be sufficiently small that the random kernel more explicitly determines the expressiveness of $\mathcal{S}_{i,m}$ . We experimentally test the presence of these depth separations with finite $m$ in Section 6. + +# 4.2. Approximation of variational symmetric function via Laplace method + +Consider any symmetric family $f_{N}(x) = \arg \min_{t\in T}\langle \hat{\mu}_{x},\phi_{t}\rangle$ where $\hat{\mu}_x$ is the empirical measure of $x$ , ie, $\hat{\mu}_x = \frac{1}{N}\sum_i\delta_{x_i}$ , $T$ is a Euclidean subset, and $t\mapsto \phi_t$ is measurable. For example $T = \mathbb{R}$ and $\phi_t(x) = |t - x|$ yields $f_{N}$ as the median. + +Although this function family isn't necessarily uniformly continuous in the weak topology, we highlight the option + +of a Laplace approximation. Define $E_{\mu}(t) \coloneqq \langle \mu, \phi_t \rangle$ and introduce the density $p_{\beta}(t) = \frac{1}{Z} e^{-\beta E_{\mu}(t)}$ where $Z = \int_{T} e^{-\beta E_{\mu}(t)} dt$ is the partition function. Then consider the Gibbs approximation $g_{\beta}(\mu) \coloneqq \mathbb{E}_{p_{\beta}}[t] = \frac{1}{Z} \int_{T} te^{-\beta E_{\mu}(t)} dt$ . + +One can verify (e.g. (Raginsky et al., 2017)) that $g_{\beta} \to g$ pointwise at a rate $\sim \frac{d\log(\beta + 1)}{\beta}$ . As $g_{\beta}$ is continuous, by universality it can be represented in $S_{i}$ for all $i = \{1,2,3\}$ . An approximation of $g_{\beta}$ is given as a ratio of two shallow networks $g_{\beta}(\mu) = \frac{\int_{T}t\sigma_{1}(\langle\mu,\phi_{t}\rangle)dt}{\int_{T}\sigma_{1}(\langle\mu,\phi_{t}\rangle)dt}$ , with $\sigma_{1}(u) = e^{-\beta u}$ . However, the approximation rates blow-up as $\beta \to \infty$ with an exponential dependency on the dimension of $T$ . + +# 5. Generalization and Concentration + +# 5.1. Generalization Bounds + +Despite being a larger function class than $\mathcal{F}_2$ , the class $\mathcal{F}_1$ enjoys a nice generalization bound (Bach, 2017a). Crucially, this property is inherited when we lift to functions on measures, controlling the generalization of functions in $S_1$ : + +Proposition 5.1 Assume for given $\delta$ , for all $y$ the loss function $\ell(y, \cdot)$ is $G$ -Lipschitz on $B_0(2R^2\delta)$ , and $l(y, 0) \leq RG\delta$ . Then with probability at least $1 - t$ , + +$$ +\begin{array}{l} \sup _ {\| f \| _ {s _ {1}} \leq \delta} \left| \mathbb {E} _ {\mu \sim \mathcal {D}} \ell (f ^ {*} (\mu), f (\mu)) - \frac {1}{n} \sum_ {i = 1} ^ {n} \ell (f ^ {*} (\mu_ {i}), f (\mu_ {i})) \right| \\ \leq \frac {2 R G \delta + 1 6 R ^ {4} G \delta}{\sqrt {n}} + (4 R ^ {2} G \delta + 2 R G \delta) \sqrt {\frac {\log 1 / t}{2 n}}. \\ \end{array} +$$ + +This proposition demonstrates that learning in $S_{1}$ is not cursed by the dimension of the underlying input space $\mathbb{I}$ . In other words, the main price for learning in $S_{1}$ is not in generalization, despite the size of this class relative to $S_{2}$ and $S_{3}$ . In the absence of a lower bound on generalization error for the RKHS function classes, our experiments investigate the generalization of these models in practice. + +Although $d$ and $N$ do not appear in this bound, these parameters nevertheless impact the generalization of our function classes $\mathcal{S}_i$ . The input dimension controls the separation of the classes according to Theorem 4.1, and therefore larger $d$ weakens the generalization of $\mathcal{S}_2$ and $\mathcal{S}_3$ ; compare Figure 1 and Figure 4 (in the Appendix) for how RKHS methods suffer in higher dimensions. Whereas large $N$ and a natural choice of $\mathcal{D}$ make generalization for $\mathcal{S}_1$ , and hence all three classes, nearly trivial, as discussed in section 5.2. + +# 5.2. Concentration across Input Size + +Consider the data distribution from which we sample, namely a measure from $\mathcal{P}(\bar{\mathbb{I}})$ to sample finite sets. A natural way to draw data is to consider the following sampling + +procedure: given $\xi \in \mathcal{P}(\mathcal{P}(\mathbb{I}))$ and $\Omega \in \mathcal{P}(\mathbb{N})$ , draw $\mu \sim \xi$ and $N \sim \Omega$ , sample $N$ independent points $x_{i} \sim \mu$ , and return $\{x_{1}, \ldots, x_{N}\}$ . If $\xi$ is too peaked, this sampling process will concentrate very rapidly: + +Proposition 5.2 For $\xi = \delta_{\mu^{*}}$ , the Rademacher complexity $\mathbb{E}\sup_{\| f\|_{S_1}\leq \delta}\left|\frac{1}{n}\sum_{i = 1}^{n}\epsilon_if(\mu_i)\right|\lesssim \delta R(n^{-1 / 2} +$ $R\mathbb{E}_{N\sim \Omega}[N^{-1 / d}])$ + +Hence, the question of generalization across differently sized sets becomes trivial if $N$ is large and $d$ is small. In our experiments, $N \approx d$ , so we will nevertheless choose $\xi = \delta_{\mu}$ for some $\mu \in \mathcal{P}(\mathbb{I})$ . We consider more exotic data distributions over measures in the experiments on robust mean estimation in Section 6.2. + +# 6. Experiments + +# 6.1. Symmetric Function Approximation + +We consider the task of learning several common symmetric functions (see Figure 1). Our aim is to practically understand the approximation bounds of Theorem 4.1, as well as the generalization result of Proposition 5.1. Furthermore, by training and testing on sets of different sizes, we may consider how the models perform on out-of-distribution generalization across input size. + +Experimental Setup: We instantiate our three function classes in the finite network setting, as outlined in Table 1. We use input dimension $d = 10$ . For the finite realization of $S_{1}$ , we use first hidden layer size $m = 100$ and second hidden layer size $h = 100$ . Crucially, after fixing the finite architecture representing $S_{1}$ , we scale up the width by 10 for the models with frozen weights. That is, the first hidden layer in $S_{2}$ , and both hidden layers in $S_{3}$ , have width equal to 1000. Increasing the width makes the $S_{2}$ and $S_{3}$ models strictly more powerful, and this setup allows us to inspect whether a larger number of random kernel features can compensate for a smaller, trained weight in approximation. For each model, we use its associated functional norm for regularization. + +Each network is trained on a batch of 100 input sets. For our data distribution we consider the base domain $\mathbb{I} = [-3,3]^d$ , and the distribution over input measures $\xi$ places all its mass on the uniform measure $U([-3,3]^d)$ . We choose to train with $N = 4$ , i.e. all networks train on input sets of size 4, and test on sets of varying size. From the results we can measure out-of-distribution generalization of finite sets. + +The one-dimensional symmetric functions are defined on sets of vectors by first applying inverse norms, i.e. $f_{N}(x) = \max_{1\leq i\leq N}\| x_{i}\|_{2}^{-1}$ . The potential function calculates the normalized gravitational potential among equal masses, i.e. $f_{N}(x) = \frac{2}{N(N - 1)}\sum_{i < j}\frac{1}{\|x_{i} - x_{j}\|_{2}}$ . The planted neuron and + +![](images/565528d025a02fbf5cd55304dccfea635a0bb8af5d6e7a35fc996569fa8c6a3a.jpg) + +![](images/56df28bbd44df5db23959061b7423790b2082d68a0bdd53846f6ebc44840625f.jpg) + +![](images/c6fa4a0aa66b98acaa98946804561a100ef15255cc5ec6644964891c6651efb3.jpg) + +![](images/50300546998e9c774155f60f7ffdf9a2f1d2a1198ded30ebe96c7210541cc9f0.jpg) +Figure 1: Test Error for $d = 10$ on the neural architectures of Section 3.1 + +![](images/28398cd0b539fbe5bd027fc2d8d6839c155e03057e9082fbe370f47baf467acc.jpg) + +![](images/0efe0a579524d956d00f516d6cfb2127e804963c8a5f690c571ab3024fedb5f9.jpg) + +smooth neuron are given as single-neuron networks, where following from the proof of Theorem 4.1, the planted neuron weight initialization is distinct from the model weight initialization. Further details are given in the Appendix. + +We additionally consider an applied experiment on a variant of MNIST to observe how the finite-width implementations perform on real-world data, by first mapping images to point clouds. Due to space limitations, details and results are given in the Appendix. + +Discussion: We observe in Figure 1 that $S_{3}$ performs substantially worse in several cases, consistent with this function class being the smallest of those considered. The classes $S_{2}$ and $S_{1}$ are competitive for some functions, although we observe a trend where $S_{1}$ still has better generalization performance. Therefore, the larger number of random kernel features doesn't compensate for training a smaller weight matrix in $S_{1}$ , empirically confirming Theorem 4.1. + +The test error on sets of larger size than the training data corroborates the conclusion of Proposition 3.1. The second-largest-element function generalizes extremely poorly, consistent with the observation in Section 3.3 that this function family cannot be approximated without constant error. In particular, all function classes more effectively generalize across different $N$ on the softmax than the max, seeing as the latter lacks uniform continuity in measure space. + +The other essential takeaway is the performance of the three models on the planted neurons in Figure 2. By using a distinct weight initialization for the neuron, its first layer will have very little mass under $\kappa$ , and its first two layers will have little mass under $\tau$ , and therefore random features will not suffice to approximate this neuron. This is true + +even with the scaling of $S_{2}$ and $S_{3}$ to enable more random kernel features, reiterating that these single neuron functions realize a meaningful separation between the classes. We observe a more similar performance of $S_{1}$ and $S_{2}$ on the smooth_neuron, as this function is chosen to be exactly representable with the random kernel features sampled by $S_{2}$ . According to the function class inclusion it is still representable by $S_{1}$ , but from Theorem 4.1 not efficiently representable by $S_{3}$ , which is consistent with the results. + +On increasing $m$ , the standard deviations of $S_{2}$ and $S_{3}$ shrink with more random kernel features, but $S_{1}$ still achieves the best approximation on the neuron. For the smooth neuron, $S_{1}$ and $S_{2}$ perform comparably, but $S_{3}$ performs worse even for larger $m$ . In Figure 3 we confirm the need for taking averages rather than sums in the DeepSets architecture, as the unnormalized model cannot generalize outside of the value of $N = 4$ where it was trained. + +# 6.2. Robust Mean Estimation + +Symmetric functions naturally arise in the context of empirical estimators. We consider specifically the task of robust mean estimation (Diakonikolas et al., 2017), where one seeks to estimate $\mathbb{E}_{X\sim P}[X]$ given samples drawn from the mixture distribution $(1 - \epsilon)P + \epsilon Q$ . For simplicity, we consider an oblivious contamination model where the true distribution $P$ and the noise distribution $Q$ have similar mean vectors. Explicitly, each input set is derived as follows: we sample $m\sim \mathcal{N}(0,\sigma_m^2 I)$ , $m'\sim \mathcal{N}(m,\sigma_{m'}^2 I)$ , and define $P = \mathcal{N}(m,\sigma_P^2 I)$ and $Q = \mathcal{N}(m',\sigma_Q^2 I)$ . Then each input sets consist of $N$ samples $(X_1,\ldots ,X_N)$ where $X_{i}\stackrel {iid}{\sim} (1 - \epsilon)P + \epsilon Q$ . Note that each input set is a corrupted sample with a different true mean vector $m$ . + +![](images/dd56179a2f70abad076a94912b2fba73e1ac489154f12e28b7ce9d1a17a21feb.jpg) + +![](images/eb827e9e7a241a792e3aa1c26fe69604893ee6fbb5cbad7023de5762e1ad2b30.jpg) + +![](images/204f096fad1889dfc454995f5055d1eca3e51b8bd17ff30f79216fbb8c12f8fd.jpg) +Figure 2: Planted neurons for $m = 100$ (left two) and $m = 200$ (right two). The smooth neuron has weights sampled consistently with $\mathcal{F}_2$ while the regular neuron has weights sampled distinctly from the network initialization. + +![](images/74356ed2f3512f7b6aa184450d9c6e2c13a0dad7f5615d8614e8ed0b87b413e5.jpg) + +
N=10N=20N=30N=40
S10.335 ± 0.1530.131 ± 0.0180.091 ± 0.0110.076 ± 0.011
S20.342 ± 0.1530.137 ± 0.0190.098 ± 0.0120.082 ± 0.011
S30.361 ± 0.1620.144 ± 0.0200.103 ± 0.0130.087 ± 0.013
Sample Mean0.385 ± 0.1720.153 ± 0.0680.093 ± 0.0420.096 ± 0.043
Geometric Median0.321 ± 0.1440.138 ± 0.0620.087 ± 0.0390.077 ± 0.034
Adversarial Estimator0.612 ± 0.4950.469 ± 0.5500.417 ± 0.5490.420 ± 0.564
+ +Table 2: Mean squared test error for robust mean estimation among the finite model instantiations and baselines. + +![](images/af533ffbdb056c69c8b9cd46ddc0daf8cf04cd4096f92f1ec986f7f6d589f9f2.jpg) +Figure 3: Test error for $S_{1}$ versus unnormalized DeepSets architecture. + +Experimental Setup: The network architecture is the same as above, with $d = 10$ . We use $\sigma_{m} = 1$ , $\sigma_{m'} = 2$ , $\sigma_{P} = \sigma_{Q} = 1.5$ , and $\epsilon = 0.2$ . All networks train on sets of size $N = 20$ , and test on sets of varying size, with mean squared error as the objective. As baselines we consider the naive sample mean, the geometric median, and the adversarially robust mean estimator proposed in (Diakonikolas et al., 2017). The results are given in Table 2. + +Discussion: Although the variance is quite high due to the sampling procedure, performance in this setting confirms + +that robust mean estimation also realizes the class separation, and that for this simple corruption model learning is competitive and in some cases superior to fixed estimators. In particular, the advantage of $S_{1}$ over the baselines is most clear for $N = 20$ , the setting where it was trained. Although the dependence of the fixed estimators on $\sigma_{P}$ and $\sigma_{Q}$ vanishes as $N \to \infty$ , the dependence on these parameters is non-negligible in the regime where $N$ is small, and therefore the robust mean may not generalize in the sense of Proposition 3.1. We explore training on different $N$ sizes further in the Appendix. The poor performance of the adversarial estimator can mainly be attributed to the fact that the number of samples is considerably smaller than the setting studied in (Diakonikolas et al., 2017), weakening the concentration of the empirical covariance matrix on which this estimator relies. + +# 7. Conclusion + +In this work, we have analyzed learning and generalization of symmetric functions through the lens of neural networks defined over probability measures, which formalizes the + +learning of symmetric function families across varying input size. Our experimental data confirms the theoretical insights distinguishing tiers of non-linear learning, and suggests that symmetries in the input might be a natural device to study the functional spaces defined by deeper neural networks. Specifically, and by focusing on shallow architectures, our analysis extends the fundamental separation between adaptive and non-adaptive neural networks from (Bach, 2017a) to symmetric functions, leading to a hierarchy of functional spaces $S_3 \subset S_2 \subset S_1$ , in which nonlinear learning is added into the parametrization of the network weights $(S_2)$ , and into the parametrization of test functions $(S_1)$ respectively. + +A crucial aspect we have not addressed, though, is the computational cost of learning in $S_{1}$ through gradient-based algorithms. An important direction of future work is to build on recent advances in mean-field theory for learning shallow neural networks (Chizat & Bach, 2020; Ma et al., 2019; 2020; de Dios & Bruna, 2020). + +Acknowledgements: We thank Raghav Singhal for helpful discussions regarding the proof of Theorem 4.1. This work has been partially supported by the Alfred P. Sloan Foundation, NSF RI-1816753, NSF CAREER CIF-1845360, and NSF CCF-1814524. + +# References + +Bach, F. Breaking the curse of dimensionality with convex neural networks. The Journal of Machine Learning Research, 18(1):629-681, 2017a. +Bach, F. On the equivalence between kernel quadrature rules and random feature expansions. The Journal of Machine Learning Research, 18(1):714-751, 2017b. +Bengio, Y., Roux, N. L., Vincent, P., Delalleau, O., and Marcotte, P. Convex neural networks. In Advances in neural information processing systems, pp. 123-130, 2006. +Chizat, L. and Bach, F. A note on lazy training in supervised differentiable programming. arXiv preprint arXiv:1812.07956, 2018. +Chizat, L. and Bach, F. Implicit bias of gradient descent for wide two-layer neural networks trained with the logistic loss. arXiv preprint arXiv:2002.04486, 2020. +De Bie, G., Peyre, G., and Cuturi, M. Stochastic deep networks. In International Conference on Machine Learning, pp. 1556-1565, 2019. +de Dios, J. and Bruna, J. On sparsity in overparametrised shallow relu networks. arXiv preprint arXiv:2006.10225, 2020. + +Diakonikolas, I., Kamath, G., Kane, D. M., Li, J., Moitra, A., and Stewart, A. Being robust (in high dimensions) can be practical. In International Conference on Machine Learning, pp. 999-1008. PMLR, 2017. +Efhimiou, C. and Frye, C. Spherical harmonics in $p$ dimensions. World Scientific, 2014. +Fournier, N. and Guillin, A. On the rate of convergence in Wasserstein distance of the empirical measure. Probability Theory and Related Fields, 162(3-4):707-738, 2015. +Frogner, C., Zhang, C., Mobahi, H., Araya, M., and Poggio, T. A. Learning with a wasserstein loss. In Advances in neural information processing systems, pp. 2053-2061, 2015. +Hashimoto, T., Gifford, D., and Jaakkola, T. Learning population-level diffusions with generative rnns. In International Conference on Machine Learning, pp. 2417-2426, 2016. +He, K., Zhang, X., Ren, S., and Sun, J. Delving deep into rectifiers: Surpassing human-level performance on imagenet classification. In Proceedings of the IEEE international conference on computer vision, pp. 1026-1034, 2015. +Jacot, A., Gabriel, F., and Hongler, C. Neural tangent kernel: Convergence and generalization in neural networks. In Advances in neural information processing systems, pp. 8571-8580, 2018. +Kingma, D. P. and Ba, J. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014. +LeCun, Y., Bottou, L., Bengio, Y., and Haffner, P. Gradient-based learning applied to document recognition. Proceedings of the IEEE, 86(11):2278-2324, 1998. +Ma, C., Wu, L., and E, W. Barron spaces and the compositional function spaces for neural network models. arXiv preprint arXiv:1906.08039, 2019. +Ma, C., Wu, L., et al. The quenching-activation behavior of the gradient descent dynamics for two-layer neural network models. arXiv preprint arXiv:2006.14450, 2020. +Macdonald, I. G. Symmetric functions and Hall polynomials. Oxford university press, 1998. +Maron, H., Fetaya, E., Segol, N., and Lipman, Y. On the universality of invariant networks. In International Conference on Machine Learning, pp. 4363-4371, 2019. +Mhaskar, H. N. and Hahm, N. Neural networks for functional approximation and system identification. Neural Computation, 9(1):143-159, 1997. + +Neyshabur, B., Tomioka, R., and Srebro, N. In search of the real inductive bias: On the role of implicit regularization in deep learning. arXiv preprint arXiv:1412.6614, 2014. +Neyshabur, B., Tomioka, R., and Srebro, N. Norm-Based Capacity Control in Neural Networks. arXiv:1503.00036 [cs, stat], April 2015. URL http://arxiv.org/abs/1503.00036.arXiv:1503.00036. +Pevny, T. and Kovarik, V. Approximation capability of neural networks on spaces of probability measures and tree-structured domains. arXiv preprint arXiv:1906.00764, 2019. +Qi, C. R., Su, H., Mo, K., and Guibas, L. J. Pointnet: Deep learning on point sets for 3d classification and segmentation. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 652-660, 2017. +Raginsky, M., Rakhlin, A., and Telgarsky, M. Nonconvex learning via stochastic gradient Langevin dynamics: a nonasymptotic analysis. arXiv preprint arXiv:1702.03849, 2017. +Rahimi, A. and Recht, B. Random features for large-scale kernel machines. In Advances in neural information processing systems, pp. 1177-1184, 2008. +Rosset, S., Swirszcz, G., Srebro, N., and Zhu, J. $\ell_{1}$ regularization in infinite dimensional feature spaces. In International Conference on Computational Learning Theory, pp. 544-558. Springer, 2007. +Rossi, F. and Conan-Guez, B. Functional multi-layer perceptron: a non-linear tool for functional data analysis. Neural networks, 18(1):45-60, 2005. +Sandberg, I. W. and Xu, L. Network approximation of input-output maps and functionals. Circuits, Systems and Signal Processing, 15(6):711-725, 1996. +Scarselli, F., Gori, M., Tsoi, A. C., Hagenbuchner, M., and Monfardini, G. The graph neural network model. IEEE Transactions on Neural Networks, 20(1):61-80, 2008. +Shalev-Shwartz, S. and Ben-David, S. Understanding machine learning: From theory to algorithms. Cambridge university press, 2014. +Stinchcombe, M. B. Neural network approximation of continuous functionals and continuous functions on compactifications. Neural Networks, 12(3):467-477, 1999. +Villani, C. Optimal transport: old and new, volume 338. Springer Science & Business Media, 2008. +Wagstaff, E., Fuchs, F., Engelcke, M., Posner, I., and Osborne, M. A. On the limitations of representing functions on sets. In International Conference on Machine Learning, pp. 6487-6494, 2019. + +Yarotsky, D. Universal approximations of invariant maps by neural networks. arXiv preprint arXiv:1804.10306, 2018. +Zaheer, M., Kottur, S., Ravanbakhsh, S., Poczos, B., Salakhutdinov, R. R., and Smola, A. J. Deep sets. In Advances in neural information processing systems, pp. 3391-3401, 2017. \ No newline at end of file diff --git a/afunctionalperspectiveonlearningsymmetricfunctionswithneuralnetworks/images.zip b/afunctionalperspectiveonlearningsymmetricfunctionswithneuralnetworks/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..34a7867bea8d48da80c9967663914ca29d5214ca --- /dev/null +++ b/afunctionalperspectiveonlearningsymmetricfunctionswithneuralnetworks/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7cf01b9e8afbe9b8cfd36afa739c63ae3a19174bcd738b958d89a564eb2b552a +size 306193 diff --git a/afunctionalperspectiveonlearningsymmetricfunctionswithneuralnetworks/layout.json b/afunctionalperspectiveonlearningsymmetricfunctionswithneuralnetworks/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..122f1e0e69e9a89419d1ee95f1b5f798ed6d1a88 --- /dev/null +++ b/afunctionalperspectiveonlearningsymmetricfunctionswithneuralnetworks/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:03daf3a7e51a358bb9e4fa14acb15cd68c3cd1d8289578a6661be7e5c739d52a +size 639433 diff --git a/ageneralframeworkfordetectinganomalousinputstodnnclassifiers/2b4f093a-cd14-4f37-8134-79e37a72aba8_content_list.json b/ageneralframeworkfordetectinganomalousinputstodnnclassifiers/2b4f093a-cd14-4f37-8134-79e37a72aba8_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..6bf7222035cf441c4e337381621462373e3d7e99 --- /dev/null +++ b/ageneralframeworkfordetectinganomalousinputstodnnclassifiers/2b4f093a-cd14-4f37-8134-79e37a72aba8_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1d7df9874e67d6608dea41775906b25031c99f3ba7fe64cb507316a131c4d58d +size 102122 diff --git a/ageneralframeworkfordetectinganomalousinputstodnnclassifiers/2b4f093a-cd14-4f37-8134-79e37a72aba8_model.json b/ageneralframeworkfordetectinganomalousinputstodnnclassifiers/2b4f093a-cd14-4f37-8134-79e37a72aba8_model.json new file mode 100644 index 0000000000000000000000000000000000000000..a908ae6e742c085eff45693e918b0ce4b6623c4e --- /dev/null +++ b/ageneralframeworkfordetectinganomalousinputstodnnclassifiers/2b4f093a-cd14-4f37-8134-79e37a72aba8_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cd467c273927a29519c44a74b69dda3fb7ac9abd0a2d9a273ec04b99eb7c5e33 +size 132240 diff --git a/ageneralframeworkfordetectinganomalousinputstodnnclassifiers/2b4f093a-cd14-4f37-8134-79e37a72aba8_origin.pdf b/ageneralframeworkfordetectinganomalousinputstodnnclassifiers/2b4f093a-cd14-4f37-8134-79e37a72aba8_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..aef86873dda46bcb576b17d954e005dc00814e9e --- /dev/null +++ b/ageneralframeworkfordetectinganomalousinputstodnnclassifiers/2b4f093a-cd14-4f37-8134-79e37a72aba8_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8f9ff82d2487778d2d6e44c8d20b27f308f8faa7102d83d494676d6effe97d86 +size 1521517 diff --git a/ageneralframeworkfordetectinganomalousinputstodnnclassifiers/full.md b/ageneralframeworkfordetectinganomalousinputstodnnclassifiers/full.md new file mode 100644 index 0000000000000000000000000000000000000000..bfb2d5b83c46776046767de097426b7835bd823c --- /dev/null +++ b/ageneralframeworkfordetectinganomalousinputstodnnclassifiers/full.md @@ -0,0 +1,439 @@ +# A General Framework For Detecting Anomalous Inputs to DNN Classifiers + +Jayaram Raghuram $^{*1}$ Varun Chandrasekaran $^{*1}$ Somesh Jha $^{12}$ Suman Banerjee $^{1}$ + +# Abstract + +Detecting anomalous inputs, such as adversarial and out-of-distribution (OOD) inputs, is critical for classifiers (including deep neural networks or DNNs) deployed in real-world applications. While prior works have proposed various methods to detect such anomalous samples using information from the internal layer representations of a DNN, there is a lack of consensus on a principled approach for the different components of such a detection method. As a result, often heuristic and one-off methods are applied for different aspects of this problem. We propose an unsupervised anomaly detection framework based on the internal DNN layer representations in the form of a meta-algorithm with configurable components. We proceed to propose specific instantiations for each component of the meta-algorithm based on ideas grounded in statistical testing and anomaly detection. We evaluate the proposed methods on well-known image classification datasets with strong adversarial attacks and OOD inputs, including an adaptive attack that uses the internal layer representations of the DNN (often not considered in prior work). Comparisons with five recently-proposed competing detection methods demonstrate the effectiveness of our method in detecting adversarial and OOD inputs. + +# 1. Introduction + +Deep neural networks (DNNs) have achieved impressive performance on a variety of challenging machine learning (ML) problems such as image classification, object detection, speech recognition, and natural language processing (He et al., 2015; Krizhevsky et al., 2017). However, it is well-known that DNN classifiers can be highly inaccurate (sometimes with high confidence) on test inputs from out- + +side the training distribution (Nguyen et al., 2015; Szegedy et al., 2014; Hendrycks & Gimpel, 2017; Hein et al., 2019). Such anomalous inputs can arise in real-world settings either unintentionally due to external factors, or due to malicious adversaries that intend to cause prediction errors in the DNN and disrupt the system (Barreno et al., 2006; Biggio & Roli, 2018). Therefore, it is critical to have a defense mechanism that can detect such anomalous inputs, and take suitable corrective action (e.g., abstain from predicting (Tax & Duin, 2008) or provide a more reliable class prediction). + +In this work, we propose JTLA (Joint statistical Testing across DNN Layers for Anomalies), a general unsupervised framework for detecting anomalous inputs (including adversarial and OOD) to a DNN classifier using its layer representations. JTLA utilizes the rich information at the intermediate layer representations of a DNN to obtain a better understanding of the patterns produced by anomalous inputs for detection. Our method is unsupervised, i.e., it does not utilize any specific class(es) of known anomalous samples for learning or tuning its parameters. While a number of prior works have addressed the problem of adversarial and OOD detection (Feinman et al., 2017; Xu et al., 2018; Li & Li, 2017; Lee et al., 2018; Ma et al., 2018; Roth et al., 2019), including ones that utilize intermediate layer representations of a DNN (Li & Li, 2017; Meng & Chen, 2017; Xu et al., 2018; Lee et al., 2018; Zheng & Hong, 2018; Ma et al., 2018; Papernot & McDaniel, 2018; Miller et al., 2019; Yang et al., 2020; Sastry & Oore, 2020), some key limitations persist, that we propose to address in this work. + +Limitations of prior work. First, a number of existing detection methods (Feinman et al., 2017; Lee et al., 2018; Ma et al., 2018; Yang et al., 2020) being supervised, have to be presented with a broad sampling of known anomalous samples for training (e.g., different adversarial attacks of varying strength). Such methods typically also need to configure hyper-parameters based on the known anomalous samples from the training set (e.g., using cross-validation). As a result, they often do not generalize well to unknown anomalies (e.g., novel or adaptive attacks). It has been shown that a majority of the current detection methods fail to handle unseen and adaptive adversaries that are aware of the defense mechanism (Carlini & Wagner, 2017a; Tramér et al., 2020). Second, detection methods that use only the input, output (pre-softmax), or a specific DNN layer (Roth et al., + +2019; Hendrycks & Gimpel, 2017; Feinman et al., 2017) do not jointly exploit the properties exhibited by anomalous inputs across the layers. Third, although methods that utilize information from multiple layers (listed earlier) propose specific test statistics or features calculated from the layer representations (e.g., local intrinsic dimensionality (Ma et al., 2018)), there is a lack of a general anomaly detection framework where one can plug-in test statistics, aggregation, and scoring methods suitable for the detection task. Fourth, existing unsupervised detection methods that are based on density (generative) modeling of the DNN layer representations (Zheng & Hong, 2018; Miller et al., 2019; Feinman et al., 2017) are not well-suited to handle the (often very) high dimensional layer representations. Finally, we observe that existing detection methods often do not utilize the predicted class of the DNN to focus on class-conditional properties of the layer representations (Ma et al., 2018; Li & Li, 2017; Xu et al., 2018; Yang et al., 2020), which can lead to improved detection performance. While prior works such as (Roth et al., 2019; Miller et al., 2019; Zheng & Hong, 2018; Sastry & Oore, 2020) are exceptions to this, there is still need for a unified approach in this regard. + +Our contributions can be summarized as follows: + +- We propose a general unsupervised framework JTLA for detecting anomalous inputs to a DNN using its layer representations. We first present a meta-algorithm and describe its components in general terms (§ 3). We then propose specific methods for realizing the components in a principled way (§ 4). The proposed framework is modular, and a number of prior works for anomaly detection based on the layer representations can be cast into this meta-algorithm. +- The importance of designing an adaptive, defense-aware adversary has been underscored in the literature (Carlini & Wagner, 2017a; Tramér et al., 2020). We propose and evaluate against an adversarial attack that focuses on defenses (such as ours) that use the $k$ -nearest neighbors of the layer representations of the DNN ( $\S 5$ ). +- We report extensive experimental evaluations comparing JTLA with five baseline methods on three image classification datasets trained with suitably-complex DNN architectures. For adversarial detection, we evaluate on three well-known whitebox attacks and our proposed defense-aware attack (§ 6 and Appendix E) ${}^{1}$ . + +# 2. Related Works + +We provide a brief review of related works on adversarial and OOD detection, focusing on methods that use the internal layer representations of a DNN. A detailed discuss + +sion of closely-related prior works, and how they fit into the proposed anomaly detection framework is provided in Appendix A.4. Recent surveys on adversarial learning and anomaly detection for DNNs can be found in (Biggio & Roli, 2018; Miller et al., 2020; Bulusu et al., 2020). + +Prior works on adversarial and OOD detection can be broadly categorized into unsupervised and supervised methods. Supervised methods such as (Lee et al., 2018), (Ma et al., 2018), and (Yang et al., 2020) use a training set of adversarial or OOD samples (i.e., known anomalies) to train a binary classifier that discriminates natural inputs from anomalies. They extract specific informative test statistics from the layer representations as features for the classifier. On the other hand, unsupervised methods such as (Roth et al., 2019; Zheng & Hong, 2018; Miller et al., 2019; Sastry & Oore, 2020; Li & Li, 2017; Xu et al., 2018), rely on interesting statistical properties and generative modeling of natural inputs at specific (e.g., logit) or multiple layer representations of the DNN for detection. Works such as the trust score (Jiang et al., 2018), deep kNN (Papernot & McDaniel, 2018), and by Jha et al. (2019) have explored the problem of developing a confidence metric that can independently validate the predictions of a classifier. Inputs with low confidence scores are likely to be misclassified and hence are detected as anomalies. + +# 3. Anomaly Detection Meta-algorithm + +We first introduce the notation and problem setup, followed by a description of the proposed meta-algorithm. + +# 3.1. Notations and Setup + +Consider the conventional classification problem where the goal is to accurately classify an input $\mathbf{x} \in \mathcal{X}$ into one of $m$ classes $[m] := \{1, \dots, m\}$ . We focus on DNN classifiers that learn a function of the form $\mathbf{F}(\mathbf{x}) = [F_1(\mathbf{x}), \dots, F_m(\mathbf{x})]$ , $\mathbf{F}: \mathcal{X} \mapsto \Delta_m$ , where $\mathcal{X}$ is the space of inputs to the DNN and $\Delta_m = \{(p_1, \dots, p_m) \in [0, 1]^m : \sum_i p_i = 1\}$ is the space of output class probabilities. The class prediction of the DNN based on its output class probabilities is defined as $\widehat{C}(\mathbf{x}) = \arg \max_{c \in [m]} F_c(\mathbf{x})$ . The multi-layer architecture of a DNN allows the input-output mapping to be expressed as a composition of multiple functions, i.e., $\mathbf{F}(\mathbf{x}) = (\mathbf{g}_L \circ \mathbf{g}_{L-1} \dots \circ \mathbf{g}_1)(\mathbf{x})$ , where $L$ is the number of layers. The output from an intermediate layer $\ell \in \{1, \dots, L\}$ of the DNN, $\mathbf{f}_{\ell}(\mathbf{x}) = (\mathbf{g}_{\ell} \circ \dots \circ \mathbf{g}_1)(\mathbf{x}) \in \mathbb{R}^{d_\ell}$ , is referred to as its layer representation. We also use the shorthand notation $\mathbf{x}^{(\ell)} = \mathbf{f}_{\ell}(\mathbf{x})$ , with $\mathbf{x}^{(0)} = \mathbf{f}_0(\mathbf{x})$ denoting the vectorized input. The set of layers and distinct layer pairs are denoted by $\mathcal{L} = \{0, \dots, L\}$ and $\mathcal{L}^2 = \{(\ell_1, \ell_2) \in \mathcal{L} \times \mathcal{L} : \ell_2 > \ell_1\}$ . Table 1 in the + +Appendix provides a quick reference for the notations. + +We assume access to the trained DNN classifier to defend, and a labeled data set $\mathcal{D} = \{(\mathbf{x}_n,c_n), n = 1,\dots ,N\}$ that is different from the one used to train the DNN and does not contain any anomalous samples. We define an augmented data set $\mathcal{D}_a = \{(\mathbf{x}_n^{(0)},\dots ,\mathbf{x}_n^{(L)},c_n,\hat{c}_n), n = 1,\dots ,N\}$ that is obtained by passing samples from $\mathcal{D}$ through the DNN and extracting their layer representations $\mathbf{x}_n^{(\ell)} = \mathbf{f}_{\ell}(\mathbf{x}_n)$ , $\ell \in \mathcal{L}$ and the class prediction $\hat{c}_n = \widehat{C} (\mathbf{x}_n)$ . We also define subsets of $\mathcal{D}_a$ corresponding to each layer $\ell \in \mathcal{L}$ , and each predicted class $\hat{c}\in [m]$ or true class $c\in [m]$ respectively as: + +$$ +\widehat {\mathcal {D}} _ {a} (\ell , \hat {c}) = \left\{\left(\mathbf {x} _ {n} ^ {(\ell)}, c _ {n}, \hat {c} _ {n}\right), n = 1, \dots , N: \hat {c} _ {n} = \hat {c} \right\}, +$$ + +$$ +\mathcal {D} _ {a} (\ell , c) = \left\{\left(\mathbf {x} _ {n} ^ {(\ell)}, c _ {n}, \hat {c} _ {n}\right), n = 1, \dots , N: c _ {n} = c \right\}. +$$ + +# 3.2. Components of the Meta-algorithm + +Algorithm 1 Meta-algorithm for Anomaly Detection + +1: Inputs: Trained DNN $\mathbf{F}(\cdot)$ , Dataset $\mathcal{D}$ , Test input $\mathbf{x}$ , FPR $\alpha$ or detection threshold $\tau$ . +2: Output: Detector decision – normal 0 or anomaly 1. + +3: Preprocessing: +4: Calculate the detection threshold $\tau$ (if not specified). +5: Calculate the class prediction and layer representations of $\mathbf{x}$ . +6: Create the data subsets corresponding to each layer, predicted class, and $m$ true classes. + +7: I. Test statistics (TS): +8: for each layer $\ell$ : +9: Calculate the TS at layer $\ell$ conditioned on the predicted class and the $m$ candidate true classes. + +10: Compile the $m + 1$ TS vectors from the layers. + +11: II. Normalizing transformations: +12: if multivariate normalization: +13: Normalize each of the $m + 1$ TS vectors. +14: else +15: for each layer $\ell$ : +16: Normalize the $m + 1$ TS from layer $\ell$ . +17: for each distinct layer pair $(\ell_1,\ell_2)$ : [optional] +18:Normalize the $m + 1$ TS pairs from layers $\ell_1,\ell_2$ +19: III. Layerwise aggregation and scoring: +20: if multivariate normalization: +21: No need to aggregate the normalized TS. +22: else +23: Aggregate the normalized TS from the layers and layer pairs for the predicted class and each candidate true class. +24: Calculate the final score from the $m + 1$ aggregated normalized TS. +25: IV. Detection decision: +26: Return anomaly (1) if the final score exceeds threshold; Else return normal (0). + +The proposed meta-algorithm for detecting anomalous inputs to a DNN classifier based on its layer representations is given in Algorithm 1. A more formal version of the same can be found in Algorithm 2 in the Appendix. Details of the + +individual components of the meta-algorithm are discussed next. For this discussion, consider a test sample $\mathbf{x}$ whose true class is unknown, predicted class is $\hat{C}(\mathbf{x}) = \hat{c}$ , and layer representations are $\mathbf{x}^{(\ell)}$ , $\ell \in \mathcal{L}$ . + +![](images/05d54d066c35e7b32072162dcb0262ccc8229fdaf53fcdfd81f5820ccfda8d13.jpg) +Figure 1: Distribution of test statistics corresponding to normal and adversarial samples (PGD, $\ell_{\infty}$ attack) from the layers of a DNN trained on the SVHN dataset. The top and bottom figures show the multinomial test statistic (§ 4.1) conditioned on the predicted and true class respectively. BC is the Bhattacharya coefficient, which is a measure of distribution overlap. + +I. Test Statistics: In line with prior works that use the layer representations of a DNN for detection, we define test statistics at each layer that capture a statistical property of the layer representation useful for detection (e.g., Mahalanobis distances (Lee et al., 2018)). The test statistics are defined to be conditioned on the predicted class and on each candidate true class (since the true class is unknown). The latter is particularly useful for adversarial samples, since they are known to have originated from one of the $m$ classes. For a test input $\mathbf{x}$ predicted as class $\hat{c}$ , the test statistic at any layer $\ell$ conditioned on the predicted class is defined as $T(\mathbf{x}^{(\ell)}, \hat{c}, \widehat{\mathcal{D}}_a(\ell, \hat{c}))$ . It captures how anomalous the layer representation $\mathbf{x}^{(\ell)}$ is with respect to the distribution of natural inputs predicted into class $\hat{c}$ by the DNN. Similarly, a set of $m$ test statistics at layer $\ell$ , conditioned on each candidate true class $c$ , are defined as $T(\mathbf{x}^{(\ell)}, c, \mathcal{D}_a(\ell, c))$ , $c \in [m]$ . They capture how anomalous $\mathbf{x}^{(\ell)}$ is with respect to the distribution of natural inputs from a true class $c$ . A mild requirement on the definition of the test statistic function is that larger values of $T(\cdot)$ correspond to larger deviations of the layer representation from the class-conditional distribution of natural inputs. When the input is clear from the context, we denote the test statistic random variables by $T_{p|\hat{c}}^{(\ell)} := T(\mathbf{x}^{(\ell)}, \hat{c}, \widehat{\mathcal{D}}_a(\ell, \hat{c}))$ and $T_{s|c}^{(\ell)} := T(\mathbf{x}^{(\ell)}, c, \mathcal{D}_a(\ell, c))$ . Specific values of the test statistic are denoted by $t_{p|\hat{c}}^{(\ell)}$ and $t_{s|c}^{(\ell)}$ . The vector of test statistics across the layers is defined as $\mathbf{t}_{p|\hat{c}} := [t_{p|\hat{c}}^{(0)}, \dots, t_{p|\hat{c}}^{(L)}]$ given the predicted class $\hat{c}$ , and as $\mathbf{t}_{s|c} := [t_{s|c}^{(0)}, \dots, t_{s|c}^{(L)}]$ , $\forall c \in [m]$ given each candidate true class. In § 4.1, we propose a test statistic based on the multinomial likelihood ratio test (LRT) applied to + +class counts from the $k$ -nearest neighbors (kNN) of a layer representation. However, the above definitions are general and apply to test statistics proposed in prior works such as Gram matrix-based deviations (Sastry & Oore, 2020). + +II. Distribution-Independent Normalization: In the absence of any prior assumptions, the class-conditional and marginal distributions of the test statistics are unknown and expected to change across the DNN layers (e.g., see Fig. 1). Therefore, in order to effectively combine the test statistics from the layers for anomaly scoring, it is important to apply a normalizing transformation that (ideally) makes the transformed test statistics distribution independent. Some prior works partially address this using heuristic approaches such as z-score normalization (Roth et al., 2019) and scaling by the expected value (Sastry & Oore, 2020) in order to account for the distribution and range differences of the test statistics across the layers. We propose two approaches for applying normalizing transformations – the first one focuses on test statistics from the individual layers and layer pairs, and the second one focuses on the vector of test statistic across the layers. Considering test statistic pairs and the vector of test statistics allows our method to capture the joint effect of anomalous inputs on the layer representations. + +Consider the first approach. In the meta-algorithm, such normalizing transformations are defined as $q(t_{p|\hat{c}}^{(\ell)})$ for the test statistic at layer $\ell$ conditioned on the predicted class $\hat{c}$ , and $q(t_{s|c}^{(\ell)})$ , $\forall c \in [m]$ for the test statistic at layer $\ell$ conditioned on each candidate true class. For each pair of layers $(\ell_1, \ell_2) \in \mathcal{L}^2$ , $q(t_{p|\hat{c}}^{(\ell_1)}, t_{p|\hat{c}}^{(\ell_2)})$ and $q(t_{s|c}^{(\ell_1)}, t_{s|c}^{(\ell_2)})$ , $\forall c \in [m]$ define the normalizing transformations for the corresponding test statistic pair conditioned on the predicted class $\hat{c}$ and on each candidate true class respectively. Since it is not efficient to include all the layer pairs beyond few tens of layers, this is specified as optional in Algorithm 1. + +In the second approach, $q(\mathbf{t}_{p|c})$ and $q(\mathbf{t}_{s|c}), \forall c \in [m]$ define the normalizing transformations for a vector of test statistics from the layers conditioned on the predicted class $\hat{c}$ and on each candidate true class respectively. In § 4.2, we propose specific realizations for each case of the above normalizing transformations based on class-conditional $p$ -values. They have the advantage of being nonparametric, and transform the test statistics into probabilities that, for natural inputs, will be approximately uniform on [0, 1]. + +III. Layerwise Aggregation and Scoring: The normalized test statistics can be interpreted as anomaly scores that are each based on information from one or more layer representations and a specific (predicted or true) class. The goal of a scoring function is to aggregate the multiple anomaly + +scores in a principled way such that the combined score is low for inputs following the same distribution as normal inputs to the DNN, and high for anomalies. Prior works have taken approaches such as average or maximum of the normalized test statistics (Miller et al., 2019; Sastry & Oore, 2020), or a weighted sum of unnormalized test statistics, with the weights trained using a binary logistic classifier (Lee et al., 2018; Ma et al., 2018; Yang et al., 2020). In our meta-algorithm, we define an aggregation function $r(\cdot)$ that combines the set of all normalized test statistics from the individual layers and (optionally) layer pairs as follows: $q_{\mathrm{agg}}(\mathbf{t}_{p|c}) = r(Q_{p|c})$ and $q_{\mathrm{agg}}(\mathbf{t}_{s|c}) = r(Q_{s|c}), \forall c \in [m]$ , where + +$$ +\begin{array}{l} Q _ {p \mid \hat {c}} = \left\{q \left(t _ {p \mid \hat {c}} ^ {(\ell)}\right), \forall \ell \in \mathcal {L} \right\} \\ \cup \left\{q \left(t _ {p \mid \hat {c}} ^ {\left(\ell_ {1}\right)}, t _ {p \mid \hat {c}} ^ {\left(\ell_ {2}\right)}\right), \forall \left(\ell_ {1}, \ell_ {2}\right) \in \mathcal {L} ^ {2} \right\} \quad \text {a n d} \tag {1} \\ \end{array} +$$ + +$$ +\begin{array}{l} Q _ {s \mid c} = \left\{q \left(t _ {s \mid c} ^ {(\ell)}\right), \forall \ell \in \mathcal {L} \right\} \\ \cup \left\{q \left(t _ {p \mid c} ^ {\left(\ell_ {1}\right)}, t _ {p \mid c} ^ {\left(\ell_ {2}\right)}\right), \forall \left(\ell_ {1}, \ell_ {2}\right) \in \mathcal {L} ^ {2} \right\}, \forall c \in [ m ] \\ \end{array} +$$ + +define the sets of normalized test statistics. + +Motivated by ideas from multiple testing, we propose specific aggregation functions $r(\cdot)$ in § 4.3 for combining multiple p-values from the layers and layer pairs. For the normalization approach that directly transforms the test statistic vector from the layers, there is no need for an aggregation function; we simply set $q_{\mathrm{agg}}(\mathbf{t}_{p|\hat{c}}) = q(\mathbf{t}_{p|\hat{c}})$ and $q_{\mathrm{agg}}(\mathbf{t}_{s|c}) = q(\mathbf{t}_{s|c}), \forall c \in [m]$ . The final anomaly score in the meta-algorithm is defined to be a simple function of the aggregate, normalized test statistics, i.e., $S(q_{\mathrm{agg}}(\mathbf{t}_{p|\hat{c}}), q_{\mathrm{agg}}(\mathbf{t}_{s|1}), \dots, q_{\mathrm{agg}}(\mathbf{t}_{s|m}), \hat{c})$ . We propose specific realizations of the score functions for adversarial and OOD detection in § 4.4. + +IV. Detection Decision: The detection decision for a test input $\mathbf{x}$ predicted into class $\hat{c}$ is obtained by thresholding the final anomaly score as follows: + +$$ +\begin{array}{l} \psi_ {\tau} (\mathbf {x} ^ {(0)}, \dots , \mathbf {x} ^ {(L)}, \hat {c}) = \\ \mathbb {1} \left[ S \left(q _ {\text {a g g}} \left(\mathbf {t} _ {p \mid \hat {c}}\right), q _ {\text {a g g}} \left(\mathbf {t} _ {s \mid 1}\right), \dots , q _ {\text {a g g}} \left(\mathbf {t} _ {s \mid m}\right), \hat {c}\right) \geq \tau \right] \tag {2} \\ \end{array} +$$ + +where decisions 0 and 1 correspond to natural and anomalous inputs respectively, and $\mathbb{1}[\cdot ]$ is the indicator function. The threshold $\tau$ is usually set based on a false positive rate (FPR) that is suitable for the target application. In order to operate the detector at an FPR $\alpha \in (0,1)$ (usually a small value e.g., 0.01), the threshold can be set by estimating the FPR $\widehat{P}_{\mathrm{F}}(\tau)$ from the set of natural inputs $\mathcal{D}_a$ as follows: + +$$ +\tau_ {\alpha} = \sup \{\tau \in \mathbb {R}: \widehat {P} _ {\mathrm {F}} (\tau) \leq \alpha \}, \text {w h e r e} +$$ + +$$ +\widehat {P} _ {\mathrm {F}} (\tau) = \frac {1}{N} \sum_ {n = 1} ^ {N} \psi_ {\tau} \left(\mathbf {x} _ {n} ^ {(0)}, \dots , \mathbf {x} _ {n} ^ {(L)}, \hat {c} _ {n}\right). \tag {3} +$$ + +This threshold choice ensures that natural inputs are accepted by the detector with a probability close to $1 - \alpha$ . + +# 4. A Realization of the Meta-algorithm + +In this section, we propose concrete methods for realizing the components of the anomaly detection meta-algorithm. + +# 4.1. Test Statistic Based on kNN Class Counts + +Consider a set of natural inputs to the DNN that are predicted into a class $\hat{c} \in [m]$ . The class counts from the kNN of its representations from a layer $\ell \in \mathcal{L}$ are expected to follow a certain distribution, wherein class $\hat{c}$ has a higher probability than the other classes. A similar observation can be made for natural inputs from a candidate true class $c \in [m]$ . Let $(k_1^{(\ell)},\dots ,k_m^{(\ell)})$ denote the tuple of class counts from the kNN $N_{k}^{(\ell)}(\mathbf{x}^{(\ell)})$ of a layer representation $\mathbf{x}^{(\ell)}$ , such that $k_{i}^{(\ell)} \in \{0,1,\dots ,k\}$ and $\sum_{i = 1}^{m}k_{i}^{(\ell)} = k$ . The null (natural) distribution of the kNN class counts at a layer $\ell$ conditioned on the predicted class $\hat{c}$ can be modeled using the following multinomial distribution + +$$ +p (k _ {1} ^ {(\ell)}, \dots , k _ {m} ^ {(\ell)} \mid \widehat {C} = \widehat {c}) = k! \prod_ {i = 1} ^ {m} \frac {\left[ \pi_ {i \mid \widehat {c}} ^ {(\ell)} \right] ^ {k _ {i} ^ {(\ell)}}}{k _ {i} ^ {(\ell)} !}, \quad (4) +$$ + +where $(\pi_{1| \hat{c}}^{(\ell)}, \dots, \pi_{m| \hat{c}}^{(\ell)})$ are the multinomial probability parameters specific to class $\hat{c}$ and layer $\ell$ (they are nonnegative and sum to 1). We estimate these parameters from the labeled subset $\widehat{\mathcal{D}}_a(\ell, \hat{c})$ using maximum-a-posteriori (MAP) estimation with the Dirichlet conjugate prior distribution (Barber, 2012) $^4$ . For a test input $\mathbf{x}$ sampled from the natural data distribution that is predicted into class $\hat{c}$ by the DNN, we expect the multinomial distribution (4) to be a good fit for the class counts observed from its kNN at layer $\ell$ . In order to test whether the observed class counts $(k_1^{(\ell)}, \dots, k_m^{(\ell)})$ from layer $\ell$ given predicted class $\hat{c}$ are consistent with distribution (4), we apply the well-known multinomial LRT (Read & Cressie, 2012), whose log-likelihood ratio statistic is given by + +$$ +T (\mathbf {x} ^ {(\ell)}, \hat {c}, \widehat {\mathcal {D}} _ {a} (\ell , \hat {c})) = \sum_ {i = 1} ^ {m} k _ {i} ^ {(\ell)} \log \frac {k _ {i} ^ {(\ell)}}{k \pi_ {i | \hat {c}} ^ {(\ell)}}. (5) +$$ + +This test statistic is a class count deviation measure which is always non-negative, with larger values corresponding to a larger deviation from the null distribution (4). In a similar way, the test statistics conditioned on each candidate true class are defined as + +$$ +T \left(\mathbf {x} ^ {(\ell)}, c, \mathcal {D} _ {a} (\ell , c)\right) = \sum_ {i = 1} ^ {m} k _ {i} ^ {(\ell)} \log \frac {k _ {i} ^ {(\ell)}}{k \tilde {\pi} _ {i | c} ^ {(\ell)}}, \forall c \in [ m ]. \tag {6} +$$ + +Here, $(\widetilde{\pi}_{1|c}^{(\ell)},\dots ,\widetilde{\pi}_{m|c}^{(\ell)})$ are the multinomial parameters specific to class $c$ and layer $\ell$ , which are estimated from the corresponding data subset $\mathcal{D}_a(\ell ,c)$ . + +# 4.2. Normalizing Transformations Based on p-values + +Recall that we are interested in designing a normalizing transformation that, for natural inputs, makes the transformed test statistics across the layers and classes follow the same distribution. One such approach is to use the p-value, that calculates the probability of a test statistic taking values (as or) more extreme than the observed value. More generally, a p-value is defined as any transformation of the test statistic (possibly a vector), following the null hypothesis distribution, into a uniformly distributed probability (Root et al., 2016). This provides a simple approach for normalizing the class-conditional test statistics in both the univariate and multivariate cases, as discussed next. + +# A. p-values at Individual Layers and Layer Pairs + +For an input predicted into class $\hat{c}$ with class-conditional test statistics at a layer $\ell$ given by $t_{p|\hat{c}}^{(\ell)}, t_{s|1}^{(\ell)}, \dots, t_{s|m}^{(\ell)}$ , the normalizing p-value transformations are defined as: + +$$ +q (t _ {p | \hat {c}} ^ {(\ell)}) = \mathbb {P} (T _ {p | \hat {c}} ^ {(\ell)} \geq t _ {p | \hat {c}} ^ {(\ell)} | \widehat {C} = \hat {c}) +$$ + +$$ +q \left(t _ {s \mid c} ^ {(\ell)}\right) = \mathbb {P} \left(T _ {s \mid c} ^ {(\ell)} \geq t _ {s \mid c} ^ {(\ell)} \mid C = c\right), \forall c \in [ m ]. \tag {7} +$$ + +Similarly the normalizing p-value transformations for test statistic pairs from layers $(\ell_1,\ell_2)$ are defined as: + +$$ +q \left(t _ {p \mid \hat {c}} ^ {\left(\ell_ {1}\right)}, t _ {p \mid \hat {c}} ^ {\left(\ell_ {2}\right)}\right) = \mathbb {P} \left(T _ {p \mid \hat {c}} ^ {\left(\ell_ {1}\right)} \geq t _ {p \mid \hat {c}} ^ {\left(\ell_ {1}\right)}, T _ {p \mid \hat {c}} ^ {\left(\ell_ {2}\right)} \geq t _ {p \mid \hat {c}} ^ {\left(\ell_ {2}\right)} \mid \widehat {C} = \hat {c}\right) +$$ + +$$ +q (t _ {s \mid c} ^ {(\ell_ {1})}, t _ {s \mid c} ^ {(\ell_ {2})}) = +$$ + +$$ +\mathbb {P} \left(T _ {s \mid c} ^ {(\ell_ {1})} \geq t _ {s \mid c} ^ {(\ell_ {1})}, T _ {s \mid c} ^ {(\ell_ {2})} \geq t _ {s \mid c} ^ {(\ell_ {2})} \mid C = c\right), \forall c \in [ m ]. \tag {8} +$$ + +Since the class-conditional distributions of the test statistics are unknown, we estimate the p-values using the empirical cumulative distribution function of the test statistics calculated from the corresponding data subsets of $\mathcal{D}_a$ . + +# B. Multivariate p-value Based Normalization + +In this approach, we consider the class-conditional joint density of a test statistic vector from the layers, and propose a normalizing transformation $q: \mathbb{R}^{L + 1} \mapsto [0,1]$ based on the idea of multivariate p-values. Consider an input predicted into a class $\hat{c}$ , that has a vector of test statistics $\mathbf{t}_{p|\hat{c}} = \mathbf{t}$ from the layers. Suppose $f_0(\mathbf{t}_{p|\hat{c}}|\hat{c})$ denotes the true null-hypothesis density of $\mathbf{t}_{p|\hat{c}}$ conditioned on the predicted class $\hat{c}$ , then the region outside the level set of constant density equal to $f_0(\mathbf{t}|\hat{c})$ is given by $\{\mathbf{t}_{p|\hat{c}} \in \mathbb{R}^{L + 1}: f_0(\mathbf{t}_{p|\hat{c}}|\hat{c}) < f_0(\mathbf{t}|\hat{c})\}$ . The multivariate p-value for $\mathbf{t}$ is the probability of this region under the null hypothesis probability measure (Root et al., 2016). + +We use the averaged localized p-value estimation method using kNN graphs (aK-LPE) proposed by (Qian & Saligram, + +2012). The main idea is to define a score function based on nearest neighbor graphs $G(\mathbf{t})$ that captures the local relative density around $\mathbf{t}$ . They show that a score function defined as the average distance from $\mathbf{t}$ to its $\frac{k}{2}$ -th through $\frac{3k}{2}$ -th nearest neighbors provides the following asymptotically-consistent p-value estimate: + +$$ +q _ {\mathrm {l p e}} (\mathbf {t}) = \frac {1}{| \mathcal {D} _ {t} |} \sum_ {\mathbf {t} _ {n} \in \mathcal {D} _ {t}} \mathbb {1} [ G (\mathbf {t}) \leq G (\mathbf {t} _ {n}) ], \tag {9} +$$ + +where $\mathcal{D}_t$ is a large sample of test statistic vectors corresponding to natural inputs. In our problem, we apply the above p-value transformation (using the appropriate data subsets) to normalize the $m + 1$ test statistic vectors giving: $q_{\mathrm{lpe}}(\mathbf{t}_{p|\hat{c}}), q_{\mathrm{lpe}}(\mathbf{t}_{s|1}), \dots, q_{\mathrm{lpe}}(\mathbf{t}_{s|m})$ . + +# 4.3. Aggregation of p-values + +The p-value based normalized test statistics capture the extent of deviation of the test statistics of an input relative to their distribution on natural inputs; smaller p-values correspond to a larger deviation. For approach A in § 4.2, we can consider each p-value to correspond to a hypothesis test involving a particular layer or layer pair. We are interested in combining the evidence from these multiple tests (Dudoit & Van Der Laan, 2007) into a single p-value for the overall problem of testing for natural versus anomalous inputs. We investigate two methods for combining p-values from multiple tests and define the corresponding aggregation functions. Note that there is no need to aggregate p-values for approach B in § 4.2, and we simply set $q_{\mathrm{agg}}(\mathbf{t}_{p| \hat{c}}) = q_{\mathrm{lpe}}(\mathbf{t}_{p| \hat{c}})$ and $q_{\mathrm{agg}}(\mathbf{t}_{s|c}) = q_{\mathrm{lpe}}(\mathbf{t}_{s|c}), \forall c \in [m]$ . + +Fisher's method (Fisher, 1992) provides a principled way of combining p-values from multiple independent tests based on the idea that, under the null hypothesis, the sum of the log of multiple p-values follows a $\chi^2$ -distribution. The aggregate p-value function based on this method is given by + +$$ +\log q _ {\mathrm {f i s}} (\mathbf {t}) = \log r (Q) = \sum_ {q \in Q} \log q, \tag {10} +$$ + +where $Q$ is one of the sets $Q_{p|c}$ or $Q_{s|c}$ defined in Eq. (1), and $\mathbf{t}$ is the corresponding test statistic vector7. An apparent weakness of Fisher's method is its assumption of independent p-values. We briefly provide the aggregate p-value function for an alternate harmonic mean p-value (HMP) method for combining p-values from multiple dependent tests (Wilson, 2019), and discuss its details in Appendix B. + +$$ +q _ {\operatorname {h m p}} (\mathbf {t}) ^ {- 1} = r (Q) ^ {- 1} = \sum_ {q \in Q} q ^ {- 1}. \tag {11} +$$ + +# 4.4. Scoring for Adversarial and OOD Detection + +We propose different score functions for detecting adversarial and general OOD inputs. An adversarial input predicted + +into class $\hat{c}$ by the DNN is expected to be anomalous at one or more of its layer representations relative to the distribution of natural inputs predicted into the same class. This implies that its aggregate p-value conditioned on the predicted class, $q_{\mathrm{agg}}(\mathbf{t}_{p|\hat{c}})$ , should have a small value. Moreover, since the adversarial input was created from a source class different from $\hat{c}$ , it is expected to be a typical sample relative to the distribution of natural inputs from the unknown source class $c \neq \hat{c}$ . This implies that its aggregate p-value conditioned on a candidate true class (different from $\hat{c}$ ) should have a relatively large value. Combining these ideas, we define the score function for adversarial inputs as + +$$ +\begin{array}{l} S (q _ {\mathrm {a g g}} (\mathbf {t} _ {p \mid \hat {c}}), q _ {\mathrm {a g g}} (\mathbf {t} _ {s \mid 1}), \dots , q _ {\mathrm {a g g}} (\mathbf {t} _ {s \mid m}), \hat {c}) \\ = \log \left(\frac {\operatorname* {m a x} _ {c \in [ m ] \backslash \{\hat {c} \}} q _ {\mathrm {a g g}} \left(\mathbf {t} _ {s \mid c}\right)}{q _ {\mathrm {a g g}} \left(\mathbf {t} _ {p \mid \hat {c}}\right)}\right). \tag {12} \\ \end{array} +$$ + +The table below provides additional insight on this score function by considering the numerator and denominator terms (inside the log) for different categories of input. + +
Input type & predictionNumeratorDenominatorScore
x natural, \(\widehat{C}(\mathbf{x}) = c\)LowHighLow
x natural, \(\widehat{C}(\mathbf{x}) \neq c\)HighHighMedium
x adversarial, \(\widehat{C}(\mathbf{x}) \neq c\)HighLowHigh
+ +Similar to adversarial inputs, OOD inputs are also expected to exhibit anomalous patterns at the layers of the DNN relative to the distribution of natural inputs predicted into the same class. Since OOD inputs are not created by intentionally perturbing natural inputs from a true class different from the predicted class, we simplify score function (12) for OOD detection as follows + +$$ +\mathbf {S} (\mathbf {q} _ {\mathrm {a g g}} (\mathbf {t} _ {p \mid \hat {c}}), q _ {\mathrm {a g g}} (\mathbf {t} _ {s \mid 1}), \dots , q _ {\mathrm {a g g}} (\mathbf {t} _ {s \mid m}), \hat {c}) = - \log q _ {\mathrm {a g g}} (\mathbf {t} _ {p \mid \hat {c}}). +$$ + +OOD inputs are expected to have a low aggregate p-value $q_{\mathrm{agg}}(\mathbf{t}_{p|\hat{c}})$ , and hence a high value for the above score. + +# 4.5. Implementation and Computational Complexity + +We briefly discuss some practical aspects of implementing JTLA efficiently. We apply the neighborhood preserving projection method (He et al., 2005) to perform dimensionality reduction on the DNN layer representations since they can be very high dimensional (details in Appendix D.3). In order to efficiently construct and query from kNN graphs at the layer representations, we use the fast approximate nearest neighbors method NNDescent (Dong et al., 2011)8. Together, these two techniques significantly reduce the memory utilization and running time of JTLA. + +The computational complexity of the proposed instantiation of JTLA at prediction (test) time can be expressed as + +$\mathrm{O}\left(L\left(d_{\max}N^{\rho} + m^{2} + BN\right)\right)$ when layer pairs are not used, and $\mathrm{O}\left(L^{2}\left(d_{\max}N^{\rho} + m^{2} + BN\right)\right)$ when layer pairs are used. Here $d_{\max}$ is the maximum dimension of the projected layer representations, $m$ is the number of classes, $N$ is the number of samples, $B$ is the number of bootstrap replications used for estimating p-values, and $\rho \in (0,1)$ is an unknown factor associated with the approximate nearest neighbor queries (that are sub-linear in $N$ ). The p-value calculation can be made faster and independent of $N$ by pre-computing the empirical class-conditional CDFs. A comparison of the running time of JTLA with other detection methods can be found in Appendix E.6. + +# 5. Defense-Aware Adaptive Attack + +The importance of evaluating adversarial detection methods against an adaptive, defense-aware adversary has been highlighted in prior works (Carlini & Wagner, 2017a; Athalye et al., 2018; Tramér et al., 2020). We consider a gray-box adversary that is assumed to have full knowledge of the DNN architecture and parameters, and partial knowledge of the detection method9. + +Consider a clean input sample $\mathbf{x}$ from class $c$ that is correctly classified by the DNN. Let $\eta_{\ell}$ denote the distance between $\mathbf{x}^{(\ell)} = \mathbf{f}_{\ell}(\mathbf{x})$ and its $k$ -th nearest neighbor from layer $\ell$ . The number of samples from any class $i$ among the kNNs of $\mathbf{x}^{(\ell)}$ , relative to the dataset $\mathcal{D}_a$ , can be expressed as + +$$ +k _ {i} ^ {(\ell)} = \sum_ {n = 1: c _ {n} = i} ^ {N} u (\eta_ {\ell} - d (\mathbf {f} _ {\ell} (\mathbf {x}), \mathbf {f} _ {\ell} (\mathbf {x} _ {n}))), i = 1, \dots , m, +$$ + +where $u(\cdot)$ is the unit step function. Consider the following probability mass function over the class labels: $p_i = k_i / \sum_{j=1}^{m} k_j$ , $i \in [m]$ , where $k_i = \sum_{\ell=0}^{L} k_i^{(\ell)}$ is the cumulative kNN count from class $i$ across the layers. In order to fool a defense method relying on the kNN class counts from the layer representations, our attack finds an adversarial input $\mathbf{x}' = \mathbf{x} + \boldsymbol{\delta}$ with target class $c' \neq c$ that minimizes the following log-ratio of probabilities: + +$$ +\log \frac {p _ {c}}{p _ {c ^ {\prime}}} = \log k _ {c} - \log k _ {c ^ {\prime}} = \log \sum_ {\ell = 0} ^ {L} k _ {c} ^ {(\ell)} - \log \sum_ {\ell = 0} ^ {L} k _ {c ^ {\prime}} ^ {(\ell)}, \tag {13} +$$ + +subject to a penalty on the norm of the perturbation $\delta^{10}$ . To address the non-smoothness arising from the step function in the class counts, we use the Gaussian (RBF) kernel $h_{\sigma}(\mathbf{x},\mathbf{y}) = e^{-\frac{1}{\sigma^2} d(\mathbf{x},\mathbf{y})^2}$ to obtain a smooth approximation of the class counts $k_{i}^{(\ell)}$ . The attack objective function to minimize is a weighted sum of the $\ell_2$ -perturbation norm and the kernel-smoothed log-ratio of probabilities, given by + +$$ +\begin{array}{l} J(\boldsymbol {\delta}) = \| \boldsymbol {\delta}\|_{2}^{2} + \lambda \log \sum_{\ell = 0}^{L}\sum_{\substack{n = 1:\\ c_{n} = c}}^{N}h_{\sigma_{\ell}}(\mathbf{f}_{\ell}(\mathbf{x} + \boldsymbol {\delta}),\mathbf{f}_{\ell}(\mathbf{x}_{n})) \\ - \lambda \log \sum_ {\ell = 0} ^ {L} \sum_ {\substack {n = 1; \\ c _ {n} = c ^ {\prime}}} ^ {N} h _ {\sigma_ {\ell}} \left(\mathbf {f} _ {\ell} (\mathbf {x} + \boldsymbol {\delta}), \mathbf {f} _ {\ell} \left(\mathbf {x} _ {n}\right)\right). \tag{14} \\ \end{array} +$$ + +Here $\sigma_{\ell} > 0$ is the kernel scale for layer $\ell$ and $\lambda > 0$ is a constant that sets the relative importance of the terms in the objective function. The method used for setting the kernel scale per layer and minor extensions of the proposed attack are described in Appendix C. Details of the optimization method and the choice of $\lambda$ are given in Appendix D.4. In our experiments, we chose the class with the second highest probability predicted by the DNN as the target attack class. + +# 6. Experimental Results + +We evaluated JTLA on the following well-known image classification datasets: CIFAR-10 (Krizhevsky et al., 2009), SVHN (Netzer et al., 2011), and MNIST (LeCun et al., 1998). We used the training partition provided by the datasets for training standard CNN architectures, including a Resnet for CIFAR-10. We performed class-stratified 5-folds cross-validation on the test partition provided by the datasets; the training folds are used for estimating the detector parameters, and the test folds are used solely for calculating performance metrics (which are then averaged across the test folds). We used the Foolbox library (Rauber et al., 2017) for generating adversarial samples from the following attack methods: (i) Projected Gradient Descent (PGD) with $\ell_{\infty}$ norm (Madry et al., 2018), (ii) Carlini-Wagner (CW) attack with $\ell_{2}$ norm (Carlini & Wagner, 2017b), and (iii) Fast gradient sign method (FGSM) with $\ell_{\infty}$ norm (Goodfellow et al., 2015). We also implement and generate adversarial samples from the adaptive attack proposed in § 5. More details on the datasets, DNN architectures, and the attack parameters used are provided in Appendix D. + +Methods Compared. We evaluated the following two variants of JTLA using the multinomial test statistic: 1) p-value normalization at the layers and layer pairs using Fisher's method for aggregation, 2) multivariate p-value normalization based on the aK-LPE method. The score functions from § 4.4 for adversarial and OOD detection are used for the respective tasks. The number of nearest neighbors is the only hyperparameter of the proposed instantiation of JTLA. This is set to be a function of the number of in-distribution training samples $n$ using the heuristic $k = \lceil n^{0.4} \rceil$ . + +We compared against the following recently-proposed methods: (i) Deep Mahalanobis detector (Mahalanobis) (Lee et al., 2018), (ii) Local Intrinsic Dimensionality detector (LID) (Ma et al., 2018), (iii) The odds are odd detector (Odds) (Roth et al., 2019), (iv) Deep kNN (DKNN) (Paper + +![](images/40647af462b61fd23c0d3402fb98407fa96854e206b0f63a71327832486c021c.jpg) +Deep KNN + +![](images/b61e4b77408687a265582733a0a59a063302b6433646bee15e66b98bd67c8927.jpg) +Odds are odd + +![](images/87009075d32782a81830150e6df23507712309fd9f37f2ba7feda110246ea4e3.jpg) +JTLA, Fisher, multi + +![](images/b1171820fbcc213d15a1305a74b22498180d2563b1679c16b62c097afcf4b44d.jpg) +Trust Score + +![](images/ee150c86e6c6cbcd99e81874140c06d6fb9df0531b40217713513990b28f0b6f.jpg) +(a) CW, confidence $= 0$ + +![](images/52373f5c3fa3755ca40998609a505b1e60a150664f4e77be2af08e39772be756.jpg) +(b) Adaptive attack + +![](images/b823cce82d2831c63629f28a616305c0dbef800c816fe3f12747d1bce7e50561.jpg) +(c) PGD, $\epsilon = 1 / 255$ + +![](images/04862044d897808b7d80b3f798b3343c5bc442a36207a37d9fd4b8bcb0b7807d.jpg) +Figure 2: Adversarial detection performance on CIFAR-10 under different attacks. +(a) CW, confidence $= 0$ +Figure 3: Adversarial detection performance on SVHN under different attacks. + +![](images/87a1fdc0441f78174e2c49bbb612c5e42dd0feed279d545c62ec66d4427092a6.jpg) +(b) Adaptive attack + +![](images/31f994b460181c0d651434ec5655cab41676b624e715f60efa543b28d4db9c98.jpg) +(c) PGD, $\epsilon = 1 / 255$ + +not & McDaniel, 2018), and (v) Trust Score (Trust) (Jiang et al., 2018). Mahalanobis and LID are supervised (they utilize adversarial or outlier data from the training folds), while the remaining methods are unsupervised. LID and Odds are excluded from the OOD detection experiment because they specifically address adversarial samples. Details on the implementation, hyperparameters, and layer representations used by the methods can be found in Appendix D.3. + +Performance metrics. We evaluate detection performance using the precision-recall (PR) curve (Davis & Goadrich, 2006; Flach & Kull, 2015) and the receiver operating characteristic (ROC) curve (Fawcett, 2006). We use average precision as a threshold-independent metric to summarize the PR curve, and partial area under the ROC curve below FPR $\alpha$ ( $pAUC-\alpha$ ) as the metric to summarize low-FPR region of the ROC curve. Note that both the metrics do not require the selection of a threshold. We do not report the area under the entire ROC curve because it is skew-insensitive and tends to have optimistic values when the fraction of anomalies is very small (Ahmed & Courville, 2020). + +# 6.1. Detecting Adversarial Samples + +Figures 2 and 3 show the average precision of the detection methods as a function of the perturbation $\ell_2$ norm of the adversarial samples generated by the CW (confidence $= 0$ ) and + +adaptive attack methods. For the PGD attack $(\epsilon = 1 / 255)$ , the proportion of adversarial samples is shown on the $x$ -axis instead of the perturbation norm because most of the samples from this attack have the same norm value. We observe that in almost all cases, JTLA outperforms the other baselines. Methods such as Mahalanobis, Odds, and DKNN perform well in some cases but fail on others, while LID performs poorly in nearly all scenarios. We observe an outlying trend in Figure 3b, where Odds outperforms JTLA on the adaptive attack applied to SVHN. However, a comparison of the pAUC-0.2 metric for this scenario (Figure 10 in Appendix E.4) reveals that JTLA has higher pAUC-0.2 for low perturbation norm (where adversarial samples are likely to be more realistic and harder to detect). We provide additional results in Appendix E that include: (i) attack transfer and attacks of varying strength, (ii) evaluation of the pAUC-0.2 metric, (iii) results on the MNIST dataset, and (iv) results on the FGSM attack. + +# 6.2. Detecting Out-Of-Distribution Samples + +We evaluated OOD detection using the following image dataset pairs, with the first dataset used as in-distribution (inliers) and the second dataset used as out-distribution (outliers): 1) MNIST vs. Not-MNIST (Bulatov, 2011), 2) CIFAR-10 vs. SVHN. While a majority of papers on OOD + +![](images/30277049ff03053e9e05a22cd802d16ec128878fd1620054342ba4b948cb12bf.jpg) + +![](images/a8135198a7bd1fc0628b547938d47c11a8c15a95acba7bc546d9b43d94024729.jpg) +(a) CIFAR-10 vs. SVHN + +![](images/6eedcb25e1cf77c6d4bb4ba647d73afa6995e081b843e2e8740ce48831457ce4.jpg) +(b) MNIST vs. not-MNIST + +![](images/cde2be2775d07af9c9489d58f403c5f81e90ce1c260eea1eab9c1ecf0d86f23b.jpg) +(c) CIFAR-10 vs. CIFAR-100 +Figure 4: Comparison of OOD detection performance. + +detection evaluate using such dataset pairs, the importance of evaluating against outliers that are semantically meaningful has been emphasized by Ahmed & Courville (2020). Therefore, we performed an experiment where object classes from the CIFAR-100 dataset (not in CIFAR-10) are treated as outliers relative to CIFAR-10. This is a more realistic and challenging task since novel object categories can be considered semantically-meaningful anomalies. Using the same 5-fold cross-validation setup, we compared the performance of JTLA with Mahalanobis, DKNN, and Trust (Odds and LID are excluded because they focus on adversarial examples). Since Mahalanobis is a supervised method, it uses both inlier and outlier data from the training folds, while the remaining methods (all unsupervised) use only the inlier data from the training folds. To promote fairness in the comparison, we excluded outlier data corresponding to one half of the classes from the training folds, and included outlier data from only the excluded classes in the test folds. Additionally, in the test folds we included image samples with random pixel values uniformly selected from the same range as valid images. The number of random samples is set equal to the average number of test-fold samples from a single class. Figure 4 shows the average precision and pAUC-0.05 as a function of the proportion of OOD samples on the OOD detection tasks [1]. We observe that JTLA outperforms the unsupervised methods DKNN and Trust in all cases, but does not achieve the very good performance of Mahalanobis. This should be considered in light of the fact that Mahalanobis uses outlier samples from the training folds to train a classifier and tune a noise parameter (Lee et al., 2018). However, in real-world settings, one is unlikely to have the prior knowledge and sufficient number (and variety) of outlier samples for training. + +11We report pAUC below 5% FPR because the methods achieve high detection rates at very low FPR. + +# 6.3. Ablation Studies + +We performed ablation studies to gain a better understanding of the different components of the proposed method. Specifically, we evaluated 1) the relative performance of the proposed p-value based normalization and aggregation methods, 2) the performance improvement from testing at layer pairs in addition to the individual layers, 3) the relative performance of using only the last few layers compared to using all the layer representations, and 4) the relative performance of the two scoring methods in § 4.4. These results are discussed in Appendix E.2. + +# 7. Conclusions + +We presented JTLA, a general framework for detecting anomalous inputs to a DNN classifier based on joint statistical testing of its layer representations. We presented a general meta-algorithm for this problem, and proposed specific methods for realizing the components of this algorithm in a principled way. The construction of JTLA is modular, allowing it to be used with a variety of test statistics proposed in prior works. Extensive experiments with strong adversarial attacks (including an adaptive defense-aware attack we proposed) and anomalous inputs to DNN image classifiers demonstrate the effectiveness of our method. + +# Acknowledgements + +We thank the anonymous reviewers for their useful feedback that helped improve the paper. VC, JR, and SB were supported in part through the following US NSF grants: CNS-1838733, CNS-1719336, CNS-1647152, CNS-1629833, CNS-1942014, CNS-2003129, and an award from the US Department of Commerce with award number 70NANB21H043. SJ was partially supported by Air Force Grant FA9550-18-1-0166, the NSF Grants CCF-FMitF-1836978, SaTC-Frontiers-1804648 and CCF-1652140, and ARO grant number W911NF-17-1-0405. + +# References + +Ahmed, F. and Courville, A. C. Detecting semantic anomalies. In The Thirty-Fourth AAAI Conference on Artificial Intelligence, New York, NY, USA, February 7-12, 2020, pp. 3154-3162. AAAI Press, 2020. +Akhtar, N. and Mian, A. S. Threat of adversarial attacks on deep learning in computer vision: A survey. IEEE Access, 6:14410-14430, 2018. +Amsaleg, L., Chelly, O., Furon, T., Girard, S., Houle, M. E., Kawarabayashi, K.-i., and Nett, M. Estimating local intrinsic dimensionality. In Proceedings of the 21th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pp. 29-38. ACM, 2015. +Athalye, A., Carlini, N., and Wagner, D. A. Obfuscated gradients give a false sense of security: Circumventing defenses to adversarial examples. In Proceedings of the 35th International Conference on Machine Learning, ICML, volume 80 of Proceedings of Machine Learning Research, pp. 274-283. PMLR, 2018. +Barber, D. Bayesian reasoning and machine learning. Cambridge University Press, 2012. ISBN 0521518148. +Barreno, M., Nelson, B., Sears, R., Joseph, A. D., and Tygar, J. D. Can machine learning be secure? In Proceedings of the 2006 ACM Symposium on Information, Computer and Communications Security (ASIACCS), pp. 16-25. ACM, 2006. doi: 10.1145/1128817.1128824. +Biggio, B. and Roli, F. Wild patterns: Ten years after the rise of adversarial machine learning. Pattern Recognition, 84:317-331, 2018. doi: 10.1016/j.patcog.2018.07.023. +Biggio, B., Nelson, B., and Laskov, P. Poisoning attacks against support vector machines. In Proceedings of the 29th International Conference on Machine Learning, ICML. icml.cc / Omnipress, 2012. +Bulatov, Y. NotMNIST dataset. http://yaroslavvb.com/upload/notMNIST/, 2011. +Bulusu, S., Kailkhura, B., Li, B., Varshney, P. K., and Song, D. Anomalous instance detection in deep learning: A survey. CoRR, abs/2003.06979, 2020. URL https://arxiv.org/abs/2003.06979. +Carlini, N. and Wagner, D. A. Adversarial examples are not easily detected: Bypassing ten detection methods. In Proceedings of the 10th ACM Workshop on Artificial Intelligence and Security, AISec@CCS, pp. 3-14. ACM, 2017a. doi: 10.1145/3128572.3140444. +Carlini, N. and Wagner, D. A. Towards evaluating the robustness of neural networks. In IEEE Symposium on Security and Privacy (S&P), pp. 39-57. IEEE Computer Society, 2017b. doi: 10.1109/SP.2017.49. + +Chandola, V., Banerjee, A., and Kumar, V. Anomaly detection: A survey. ACM computing surveys (CSUR), 41(3): 1-58, 2009. +Davis, J. and Goadrich, M. The relationship between Precision-Recall and ROC curves. In Proceedings of the 23rd international conference on Machine learning, pp. 233-240, 2006. +Dong, W., Moses, C., and Li, K. Efficient k-nearest neighbor graph construction for generic similarity measures. In Proceedings of the 20th international conference on World wide web, pp. 577-586, 2011. +Dudoit, S. and Van Der Laan, M. J. Multiple testing procedures with applications to genomics. Springer Science & Business Media, 2007. +Fawcett, T. An introduction to ROC analysis. Pattern recognition letters, 27(8):861-874, 2006. +Fawzi, A., Moosavi-Dezfooli, S., and Frossard, P. Robustness of classifiers: from adversarial to random noise. In Advances in Neural Information Processing Systems 29: Annual Conference on Neural Information Processing Systems, pp. 1624-1632, 2016. +Fawzi, A., Fawzi, O., and Frossard, P. Analysis of classifiers' robustness to adversarial perturbations. Machine Learning, 107(3):481-508, 2018. +Feinman, R., Curtin, R. R., Shintre, S., and Gardner, A. B. Detecting adversarial samples from artifacts. CoRR, abs/1703.00410, 2017. URL http://arxiv.org/abs/1703.00410. +Fisher, R. A. Statistical methods for research workers. In Breakthroughs in statistics, pp. 66-70. Springer, 1992. +Flach, P. and Kull, M. Precision-recall-gain curves: PR analysis done right. In Advances in neural information processing systems, pp. 838-846, 2015. +Goodfellow, I. J., Shlens, J., and Szegedy, C. Explaining and harnessing adversarial examples. In 3rd International Conference on Learning Representations, Conference Track Proceedings, 2015. +He, K., Zhang, X., Ren, S., and Sun, J. Delving deep into rectifiers: Surpassing human-level performance on imagelet classification. In IEEE International Conference on Computer Vision (ICCV), pp. 1026-1034. IEEE Computer Society, 2015. doi: 10.1109/ICCV.2015.123. +He, K., Zhang, X., Ren, S., and Sun, J. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 770-778, 2016. + +He, X., Cai, D., Yan, S., and Zhang, H.-J. Neighborhood preserving embedding. In Tenth IEEE International Conference on Computer Vision (ICCV'05) Volume 1, volume 2, pp. 1208-1213. IEEE, 2005. +Hein, M., Andriushchenko, M., and Bitterwolf, J. Why relu networks yield high-confidence predictions far away from the training data and how to mitigate the problem. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 41-50. Computer Vision Foundation / IEEE, 2019. doi: 10.1109/CVPR.2019.00013. +Hendrycks, D. and Gimpel, K. A baseline for detecting misclassified and out-of-distribution examples in neural networks. In 5th International Conference on Learning Representations, Conference Track Proceedings. Open-Review.net, 2017. +Jha, S., Raj, S., Fernandes, S. L., Jha, S. K., Jha, S., Jalaian, B., Verma, G., and Swami, A. Attribution-based confidence metric for deep neural networks. In Advances in Neural Information Processing Systems 32: Annual Conference on Neural Information Processing Systems, pp. 11826-11837, 2019. +Jiang, H., Kim, B., Guan, M. Y., and Gupta, M. R. To trust or not to trust a classifier. In Advances in Neural Information Processing Systems 31: Annual Conference on Neural Information Processing Systems, pp. 5546-5557, 2018. +Krizhevsky, A., Hinton, G., et al. Learning multiple layers of features from tiny images. 2009. +Krizhevsky, A., Sutskever, I., and Hinton, G. E. ImageNet classification with deep convolutional neural networks. Communications of the ACM, 60(6):84-90, 2017. +Kurakin, A., Goodfellow, I. J., and Bengio, S. Adversarial machine learning at scale. In 5th International Conference on Learning Representations, Conference Track Proceedings. OpenReview.net, 2017. +LeCun, Y., Bottou, L., Bengio, Y., and Haffner, P. Gradient-based learning applied to document recognition. Proceedings of the IEEE, 86(11):2278-2324, 1998. +Lee, K., Lee, K., Lee, H., and Shin, J. A simple unified framework for detecting out-of-distribution samples and adversarial attacks. In Advances in Neural Information Processing Systems 31: Annual Conference on Neural Information Processing Systems, pp. 7167-7177, 2018. +Li, X. and Li, F. Adversarial examples detection in deep networks with convolutional filter statistics. In IEEE International Conference on Computer Vision (ICCV), pp. 5775-5783. IEEE Computer Society, 2017. + +Ma, X., Li, B., Wang, Y., Erfani, S. M., Wijewickrema, S. N. R., Schoenebeck, G., Song, D., Houle, M. E., and Bailey, J. Characterizing adversarial subspaces using local intrinsic dimensionality. In 6th International Conference on Learning Representations, Conference Track Proceedings. OpenReview.net, 2018. +Madry, A., Makelov, A., Schmidt, L., Tsipras, D., and Vladu, A. Towards deep learning models resistant to adversarial attacks. In 6th International Conference on Learning Representations, Conference Track Proceedings. OpenReview.net, 2018. +Meng, D. and Chen, H. MagNet: A two-pronged defense against adversarial examples. In Proceedings of the 2017 ACM SIGSAC Conference on Computer and Communications Security (CCS), pp. 135-147. ACM, 2017. +Miller, D. J., Wang, Y., and Kesidis, G. When not to classify: Anomaly detection of attacks (ADA) on DNN classifiers at test time. *Neural Computation*, 31(8):1624–1670, 2019. +Miller, D. J., Xiang, Z., and Kesidis, G. Adversarial learning targeting deep neural network classification: A comprehensive review of defenses against attacks. Proceedings of the IEEE, 108(3):402-433, 2020. +Moosavi-Dezfooli, S., Fawzi, A., and Frossard, P. Deepfool: A simple and accurate method to fool deep neural networks. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 2574-2582. IEEE Computer Society, 2016. doi: 10.1109/CVPR.2016.282. +Moosavi-Dezfooli, S., Fawzi, A., Fawzi, O., and Frossard, P. Universal adversarial perturbations. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 86-94. IEEE Computer Society, 2017. +Muñoz-González, L., Biggio, B., Demontis, A., Paudice, A., Wongrassamee, V., Lupu, E. C., and Roli, F. Towards poisoning of deep learning algorithms with back-gradient optimization. In Proceedings of the 10th ACM Workshop on Artificial Intelligence and Security, AISec@CCS, pp. 27-38. ACM, 2017. doi: 10.1145/3128572.3140451. +Netzer, Y., Wang, T., Coates, A., Bissacco, A., Wu, B., and Ng, A. Y. Reading digits in natural images with unsupervised feature learning. 2011. +Nguyen, A. M., Yosinski, J., and Clune, J. Deep neural networks are easily fooled: High confidence predictions for unrecognizable images. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 427-436. IEEE Computer Society, 2015. + +Papernot, N. and McDaniel, P. D. Deep k-nearest neighbors: Towards confident, interpretable and robust deep learning. CoRR, abs/1803.04765, 2018. URL http://arxiv.org/abs/1803.04765. +Papernot, N., McDaniel, P. D., Jha, S., Fredrikson, M., Celik, Z. B., and Swami, A. The limitations of deep learning in adversarial settings. In IEEE European Symposium on Security and Privacy, EuroS&P, pp. 372-387. IEEE, 2016. doi: 10.1109/EuroSP.2016.36. +Paszke, A., Gross, S., Chintala, S., Chanan, G., Yang, E., DeVito, Z., Lin, Z., Desmaison, A., Antiga, L., and Lerer, A. Automatic differentiation in PyTorch. 2017. +Pedregosa, F., Varoquaux, G., Gramfort, A., Michel, V., Thirion, B., Grisel, O., Blondel, M., Prettenhofer, P., Weiss, R., Dubourg, V., et al. Scikit-learn: Machine learning in Python. Journal of machine learning research, 12(Oct):2825-2830, 2011. +Qian, J. and Saligram, V. New statistic in p-value estimation for anomaly detection. In IEEE Statistical Signal Processing Workshop (SSP), pp. 393-396. IEEE, 2012. doi: 10.1109/SSP.2012.6319713. +Rauber, J., Brendel, W., and Bethge, M. Foolbox: A python toolbox to benchmark the robustness of machine learning models. In *Reliable Machine Learning in the Wild Workshop*, 34th International Conference on Machine Learning, 2017. +Read, T. R. and Cressie, N. A. Goodness-of-fit statistics for discrete multivariate data. Springer Science & Business Media, 2012. +Root, J., Saligram, V., and Qian, J. Learning minimum volume sets and anomaly detectors from KNN graphs. CoRR, abs/1601.06105, 2016. URL http://arxiv.org/abs/1601.06105. +Roth, K., Kilcher, Y., and Hofmann, T. The odds are odd: A statistical test for detecting adversarial examples. In Proceedings of the 36th International Conference on Machine Learning, ICML, volume 97 of Proceedings of Machine Learning Research, pp. 5498-5507. PMLR, 2019. +Ruder, S. An overview of gradient descent optimization algorithms. CoRR, abs/1609.04747, 2016. URL http://arxiv.org/abs/1609.04747. +Sastry, C. S. and Oore, S. Detecting out-of-distribution examples with gram matrices. In Proceedings of the 37th International Conference on Machine Learning (ICML), volume 119 of Proceedings of Machine Learning Research, pp. 8491-8501. PMLR, 2020. + +Sitawarin, C. and Wagner, D. A. Minimum-norm adversarial examples on KNN and KNN-based models. In IEEE Security and Privacy Workshops, SP Workshops, pp. 34-40. IEEE, 2020. doi: 10.1109/SPW50608.2020.00023. +Steinhardt, J., Koh, P. W., and Liang, P. Certified defenses for data poisoning attacks. In Advances in Neural Information Processing Systems 30: Annual Conference on Neural Information Processing Systems, pp. 3517-3529, 2017. +Szegedy, C., Zaremba, W., Sutskever, I., Bruna, J., Erhan, D., Goodfellow, I. J., and Fergus, R. Intriguing properties of neural networks. In 2nd International Conference on Learning Representations, Conference Track Proceedings, 2014. +Tax, D. M. J. and Duin, R. P. W. Growing a multi-class classifier with a reject option. Pattern Recognition Letters, 29(10):1565-1570, 2008. +Tramér, F., Carlini, N., Brendel, W., and Madry, A. On adaptive attacks to adversarial example defenses. In Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems, 2020. +Wilson, D. J. The harmonic mean p-value for combining dependent tests. Proceedings of the National Academy of Sciences, 116(4):1195-1200, 2019. +Xu, W., Evans, D., and Qi, Y. Feature squeezing: Detecting adversarial examples in deep neural networks. In 25th Annual Network and Distributed System Security Symposium (NDSS). The Internet Society, 2018. +Yang, P., Chen, J., Hsieh, C., Wang, J., and Jordan, M. I. ML-LOO: Detecting adversarial examples with feature attribution. In The Thirty-Fourth AAAI Conference on Artificial Intelligence, pp. 6639-6647. AAAI Press, 2020. +Yuan, X., He, P., Zhu, Q., and Li, X. Adversarial examples: Attacks and defenses for deep learning. IEEE Transactions on Neural Networks and Learning Systems, 30(9): 2805-2824, 2019. doi: 10.1109/TNNLS.2018.2886017. +Zhao, M. and Saligrama, V. Anomaly detection with score functions based on nearest neighbor graphs. In Advances in Neural Information Processing Systems 22: 23rd Annual Conference on Neural Information Processing Systems, pp. 2250-2258, 2009. +Zheng, Z. and Hong, P. Robust detection of adversarial attacks by modeling the intrinsic properties of deep neural networks. In Advances in Neural Information Processing Systems 31: Annual Conference on Neural Information Processing Systems, pp. 7924-7933, 2018. \ No newline at end of file diff --git a/ageneralframeworkfordetectinganomalousinputstodnnclassifiers/images.zip b/ageneralframeworkfordetectinganomalousinputstodnnclassifiers/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..6a1f825a45452a6cb40ccd9ed3724283263d4bc7 --- /dev/null +++ b/ageneralframeworkfordetectinganomalousinputstodnnclassifiers/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:be5f09771dd92dfdf638c4798fa3499d351c4a5000a801180c19c7e8046b57a7 +size 398853 diff --git a/ageneralframeworkfordetectinganomalousinputstodnnclassifiers/layout.json b/ageneralframeworkfordetectinganomalousinputstodnnclassifiers/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..57db41a0b8414593501370b596a16f7280d4c401 --- /dev/null +++ b/ageneralframeworkfordetectinganomalousinputstodnnclassifiers/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d08dece395966973cacfec599e4e868608034ce6fd2769084fcabc40bde1a5c4 +size 620809 diff --git a/agradientbasedstrategyforhamiltonianmontecarlohyperparameteroptimization/4edda155-0c7e-4941-941f-aac42dfe320e_content_list.json b/agradientbasedstrategyforhamiltonianmontecarlohyperparameteroptimization/4edda155-0c7e-4941-941f-aac42dfe320e_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..94d135399b406c350b805e3a34cf4e084fbc33c1 --- /dev/null +++ b/agradientbasedstrategyforhamiltonianmontecarlohyperparameteroptimization/4edda155-0c7e-4941-941f-aac42dfe320e_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6d410d94d15e8b7b30de4256217eccea0e0254f503f240dd14a0006e6e6f0e73 +size 85039 diff --git a/agradientbasedstrategyforhamiltonianmontecarlohyperparameteroptimization/4edda155-0c7e-4941-941f-aac42dfe320e_model.json b/agradientbasedstrategyforhamiltonianmontecarlohyperparameteroptimization/4edda155-0c7e-4941-941f-aac42dfe320e_model.json new file mode 100644 index 0000000000000000000000000000000000000000..1c595dd3664f68f59a1a654d160bed48ba281455 --- /dev/null +++ b/agradientbasedstrategyforhamiltonianmontecarlohyperparameteroptimization/4edda155-0c7e-4941-941f-aac42dfe320e_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1bef74ed686ecec7ee8905fec59ce6915e4ee5184831eb31c96ff102295992f8 +size 101734 diff --git a/agradientbasedstrategyforhamiltonianmontecarlohyperparameteroptimization/4edda155-0c7e-4941-941f-aac42dfe320e_origin.pdf b/agradientbasedstrategyforhamiltonianmontecarlohyperparameteroptimization/4edda155-0c7e-4941-941f-aac42dfe320e_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..918bdb9f4be2a8d721b721323616c43428bfb214 --- /dev/null +++ b/agradientbasedstrategyforhamiltonianmontecarlohyperparameteroptimization/4edda155-0c7e-4941-941f-aac42dfe320e_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ddb55a8e0d68dec36b1f5635fceed4792d594d742c99f1f64b714c1542e76353 +size 2845242 diff --git a/agradientbasedstrategyforhamiltonianmontecarlohyperparameteroptimization/full.md b/agradientbasedstrategyforhamiltonianmontecarlohyperparameteroptimization/full.md new file mode 100644 index 0000000000000000000000000000000000000000..8113bcc6d70207cb35524f807b770ff1b66b6105 --- /dev/null +++ b/agradientbasedstrategyforhamiltonianmontecarlohyperparameteroptimization/full.md @@ -0,0 +1,346 @@ +# A Gradient Based Strategy for Hamiltonian Monte Carlo Hyperparameter Optimization + +Andrew Campbell *1 Wenlong Chen *2 Vincent Stimper *34 José Miguel Hernández-Lobato 3 Yichuan Zhang 5 + +# Abstract + +Hamiltonian Monte Carlo (HMC) is one of the most successful sampling methods in machine learning. However, its performance is significantly affected by the choice of hyperparameter values. Existing approaches for optimizing the HMC hyperparameters either optimize a proxy for mixing speed or consider the HMC chain as an implicit variational distribution and optimize a tractable lower bound that can be very loose in practice. Instead, we propose to optimize an objective that quantifies directly the speed of convergence to the target distribution. Our objective can be easily optimized using stochastic gradient descent. We evaluate our proposed method and compare to baselines on a variety of problems including sampling from synthetic 2D distributions, reconstructing sparse signals, learning deep latent variable models and sampling molecular configurations from the Boltzmann distribution of a 22 atom molecule. We find that our method is competitive with or improves upon alternative baselines in all these experiments. + +# 1. Introduction + +Hamiltonian Monte Carlo (HMC) is a very popular Markov Chain Monte Carlo (MCMC) method for generating approximate samples from complex probability distributions. It finds wide use in machine learning (Neal, 2011) and across the broader statistical community (Carpenter et al., 2017). Unfortunately, HMC's performance depends heavily on the choice of hyperparameters such as the proposal step size. A step size that is too large can lead to unstable dynamics, while a step size that is too small may result in random walk + +*Equal contribution $^{1}$ Department of Statistics, University of Oxford $^{2}$ Baidu, Inc. $^{3}$ Department of Engineering, University of Cambridge $^{4}$ Max Planck Institute for Intelligent Systems $^{5}$ Boltzbit Ltd. Correspondence to: Andrew Campbell . + +Proceedings of the $38^{th}$ International Conference on Machine Learning, PMLR 139, 2021. Copyright 2021 by the author(s). + +behaviour and highly correlated samples. Furthermore, the step sizes may need to be tuned on a dimension by dimension basis depending on the scale and shape of the target distribution (Neal, 2011). + +Traditionally, samples are produced by running a single HMC chain for a long time compensating for imperfect hyperparameter choices through ergodicity. However, it is becomingly increasingly attractive to run many short MCMC chains in parallel to make better use of parallel compute hardware (Hoffman & Ma, 2020). In this case, it is even more important to choose good hyperparameters that encourage fast mixing. This approach also offers the novel opportunity to choose different hyperparameter values for each step in the chain, providing more tuning flexibility. + +Fully exploiting this opportunity in practice is a challenge. MCMC hyperparameters are commonly tuned according to the average acceptance probability but it is unclear how this can scale up to tuning every hyperparameter individually. Looking to backpropagation's success in training neural networks, a gradient based method would seem most appropriate. Unfortunately, there is no universal tractable metric to quantify the performance of HMC that we can optimize for. We must therefore make a choice about which approximate metric is best suited for this application. + +One approach is to use a proxy for the mixing speed of the chain. Levy et al. (2018) make use of a variation of the expected squared jumped distance (Pasarica & Gelman, 2010) to encourage proposals to make large moves in space. Alternatively, one can draw upon ideas from Variational Inference (VI) (Jordan et al., 1999), which matches an approximate distribution $q$ to the target distribution $p$ by maximizing the Evidence Lower Bound or ELBO. This is equivalent to minimizing the KL-divergence between $q$ and $p$ . + +Salimans et al. (2015); Wolf et al. (2016) use VI to obtain a training objective in which $q$ is the joint distribution of all HMC samples along the chain. For tractability, they introduce an auxiliary inference distribution approximating the reverse dynamics of the chain. The looseness of their ELBO then depends on the KL-divergence between the auxiliary inference distribution and the true reverse dynamics. As the chain length increases so does the dimensionality of + +these distributions, resulting in a looser and looser bound. This is problematic as, for longer chains, the optimized hyperparameters are encouraged to fit the imperfect auxiliary distribution as opposed to the target. In practice, Salimans et al. avoid this problem by only considering very short HMC chains, which limits the flexibility of their method. + +We overcome these issues by considering the marginal distribution of the final state in the chain as our variational $q$ . In this case, the ELBO can be broken down into the sum of the tractable expectation with respect to $q$ of the log target density (up to a normalization constant) and the intractable entropy of $q$ . During optimization, the entropy term prevents a fully flexible $q$ from collapsing to a point mass maximizing the log target density. However, a HMC chain, by construction, cannot collapse to such a point mass. We argue that optimization can still be successful whilst ignoring the entropy term, provided the initial distribution of the chain is broad enough. In practice, we achieve this by inflating the initial proposal distribution by a scaling that is independently tuned by minimizing a discrepancy measure between $p$ and $q$ (Gong et al., 2021). + +We empirically compare our method with alternative baselines on a wide range of tasks. We first consider sampling from a collection of 2D toy distributions. We then focus on more challenging approximate inference problems: reconstructing sparse signals, training deep latent variable models on MNIST and FashionMNIST and finally, sampling molecular configurations from the Boltzmann distribution of the 22 atom molecule Alanine Dipeptide. Our results show that our method is competitive with or can improve upon alternative tuning methods for HMC on all these problems. + +# 2. Background + +# 2.1. Hamiltonian Monte Carlo + +HMC (Neal, 1993) aims to draw samples from an $n$ -dimensional target distribution $p(x) = \frac{1}{\mathcal{Z}} p^{*}(x)$ where $\mathcal{Z}$ is the (usually unknown) normalization constant. It introduces an auxiliary variable $\nu \in \mathbb{R}^n$ , referred to as the momentum, which is distributed according to $\mathcal{N}(\nu;0,\mathrm{diag}(\boldsymbol{m}))$ , with the resulting method sampling on the extended space $(x,\nu)$ . HMC progresses by first sampling an initial state from some initial distribution and then iteratively proposing new states and accepting/rejecting them according to an acceptance probability. To propose a new state, first, a new value for the momentum is drawn from $\mathcal{N}(\nu;0,\mathrm{diag}(\boldsymbol{m}))$ , then, we simulate Hamiltonian Dynamics with Hamiltonian, $H(x,\nu) = -\log p^{*}(x) + \frac{1}{2}\nu^{T}\mathrm{diag}(\boldsymbol{m})^{-1}\nu$ arriving at new state $(x',\nu')$ . This new state is accepted with probability $\min\left[1,\exp(-H(x',\nu') + H(x,\nu))\right]$ . Otherwise we reject the proposed state and remain at the starting state. The Hamiltonian Dynamics are simulated using a numerical in + +tegrator, with leapfrog (Hairer et al., 2003) being a popular choice. $L$ leapfrog updates are taken to propose a new state, with the update equations at step $k$ being + +$$ +\nu_ {k + \frac {1}{2}} = \nu_ {k} + \frac {1}{2} \boldsymbol {\epsilon} \circ \nabla_ {x _ {k}} \log p ^ {*} (x _ {k}), +$$ + +$$ +x _ {k + 1} = x _ {k} + \nu_ {k + \frac {1}{2}} \circ \epsilon \circ \frac {1}{\boldsymbol {m}}, +$$ + +$$ +\nu_ {k + 1} = \nu_ {k + \frac {1}{2}} + \frac {1}{2} \boldsymbol {\epsilon} \circ \nabla_ {x _ {k + 1}} \log p ^ {*} (x _ {k + 1}), +$$ + +where $\frac{1}{m} = \left(\frac{1}{m_1},\dots ,\frac{1}{m_n}\right)$ and $\circ$ denotes element wise multiplication. The step size, $\epsilon$ , and the mass, $m$ , are hyperparameters that need to be tuned for each problem the method is applied to. We note that in the usual definition of HMC, a single scalar valued $\epsilon$ is used. Our use of a vector $\epsilon$ implies a different step size in each dimension which, with proper tuning, can improve performance by accounting for different scales across dimensions. The use of $\epsilon$ does mean the procedure can no longer be interpreted as simulating Hamiltonian Dynamics, however, it can still be used as a valid HMC proposal (Neal, 2011). Further, $\epsilon$ and $m$ both correspond to an element-wise rescaling of $x$ and so tuning both does not increase the expressivity of the method. However, we found empirically this overparameterization aided optimization. We do not consider the problem of choosing $L$ in this work. + +# 2.2. Variational Inference + +VI approximates the target $p(x)$ with a tractable distribution $q_{\phi}(x)$ parameterized by $\phi$ . The value of $\phi$ is chosen as to minimise the Kullback-Leibler divergence with the target, $D_{\mathrm{KL}}(q_{\phi}(x)||p(x))$ . As, typically, we know $p(x)$ only up to a normalization constant, we can equivalently choose $\phi$ by maximising the tractable ELBO: + +$$ +\log \mathcal {Z} - D _ {\mathrm {K L}} \big (q _ {\phi} (x) | | p (x) \big) = \mathbb {E} _ {q _ {\phi} (x)} \left[ \log p ^ {*} (x) - \log q _ {\phi} (x) \right]. +$$ + +# 3. Expected Log-Target Maximization + +VI tunes the parameters of an approximate distribution to make it closer to the target. We build on this to obtain a tractable objective for HMC hyperparameter optimization. In the parallel HMC setting, we run multiple parallel HMC chains and take the final sample in each chain. Viewing this from the VI perspective, these final samples would be independent samples from an implicit variational distribution. If each chain starts at a sample from an initial distribution $q^{(0)}(x)$ and then runs $T$ accept/reject cycles, we can denote the resulting implicit distribution as $q_{\phi}^{(T)}(x)$ , where $\phi$ now represents the step-by-step hyperparameters $\phi = \{\pmb{\epsilon}^{(1:T)}, \pmb{m}^{(1:T)}\}$ . Ideally, $\phi$ would be chosen as to + +![](images/1bbeadd4c4be79395ac1c8ba3c916066b4b728179373f92f8442bc39ef1dd76a.jpg) + +![](images/d9ab21f4077fcd7023d90f50eb7aa7c2d6564f4bfbb41bbd977d8920acefff42.jpg) +Figure 1. (Upper) Expected log target as a function of step $t$ in the HMC chain for initial distribution 1, $\mathcal{N}(0,0.25)$ , and initial distribution 2, $\mathcal{N}(0,4)$ , before and after training. The 'true' value, $\mathbb{E}_p[\log p(x)]$ is also plotted. (Lower) The target pdf along with the two initial distributions. + +maximise the ELBO: + +$$ +\begin{array}{l} \phi^ {*} = \underset {\phi} {\operatorname {a r g m a x}} \mathbb {E} _ {q _ {\phi} ^ {(T)} (x)} \left[ \log p ^ {*} (x) - \log q _ {\phi} ^ {(T)} (x) \right] \\ = \underset {\phi} {\operatorname {a r g m a x}} \mathbb {E} _ {q _ {\phi} ^ {(T)} (x)} \left[ \log p ^ {*} (x) \right] + H \left[ q _ {\phi} ^ {(T)} (x) \right]. \\ \end{array} +$$ + +Whilst the first term in this expression can be estimated directly via Monte Carlo, the entropy term, $H[q_{\phi}^{(T)}(x)]$ , is intractable. To get around this, we should consider the purpose of the two terms during optimization. Maximizing the first term encourages $q_{\phi}^{(T)}(x)$ to produce samples that are in the high probability regions of the target, i.e., ensuring that $q_{\phi}^{(T)}(x)$ is high where $\log p^*(x)$ is high. The entropy term acts as a regularizer preventing $q_{\phi}^{(T)}(x)$ from simply collapsing to a point mass at the mode of $p(x)$ . The key observation of our method is that HMC already fulfills this regularization role because the implicit distribution it defines is not fully flexible. If $q_{\phi}^{(T)}(x)$ were to collapse to a point mass, this would require the hyperparameters to be such that the HMC scheme always guides the chain state to the same point in space, irrespective of what initial position is sampled from $q^{(0)}(x)$ . This is unreasonable for practical problems. Therefore, we propose optimizing $\phi$ simply by + +maximizing the expected log target density under the final state of the chain: + +$$ +\phi^ {*} = \underset {\phi} {\operatorname {a r g m a x}} \mathbb {E} _ {q _ {\phi} ^ {(T)} (x)} \left[ \log p ^ {*} (x) \right]. \tag {1} +$$ + +Although HMC does have a regularization effect, removing the entropy term does have some implications that we must consider. Namely, if the initial distribution, $q^{(0)}(x)$ , is concentrated in a very high probability region of the target, $p(x)$ , then optimizing the objective in (1) will not encourage HMC to explore the full target. Conversely, it would encourage the chains to remain in this region of high probability, close to their initial sampling point, which is undesirable behaviour. The key to avoiding this problem is to choose an initial distribution that has a sufficiently wide coverage of the target. We discuss methods for doing this in Section 3.3. + +# 3.1. Demonstration on a Toy Problem + +We now demonstrate the ideas of the previous section on a very simple toy problem. Here the target is a 1-dimensional normal distribution $\mathcal{N}(0,1)$ which we attempt to sample from using a 10 step HMC chain with each step consisting of 5 leapfrog updates. We initialize the chain either with a narrow initial distribution $\mathcal{N}(0,0.25)$ or a wide initial distribution $\mathcal{N}(0,4)$ , as shown in the bottom plot in Figure 1. We keep $m$ constant for all steps but train one step size $\epsilon_t$ for each HMC step. The top of Figure 1 plots the progression of $\mathbb{E}_{q_{\phi}^{(t)}}[\log p(x)]$ during sampling for these two cases, before and after hyperparameter training. Before training, when using the narrow initial distribution, $\mathbb{E}_{q_{\phi}^{(t)}}[\log p(x)]$ initially starts above the true value but converges from above as the marginal HMC distribution, $q_{\phi}^{(t)}$ , spreads to cover the target. However, after training according to (1), all the step sizes have become very small causing the HMC chains to remain at their initial sampled positions which is obviously detrimental for convergence. To avoid this, we can use a wide initial distribution. The top plot in Figure 1 shows that, in this case, tuning hyperparameters according to (1) greatly speeds up convergence. + +# 3.2. Estimating the Gradients + +We solve (1) using stochastic gradient descent (SGD), with gradients computed using a Monte Carlo approximation and the reparameterization trick (Rezende et al., 2014; Kingma & Welling, 2014). Here, we are forced to make another approximation since the discontinuous accept/reject step introduces a non-differentiability in the Monte Carlo estimate of the objective. We can either ignore this and use biased gradients or remove the accept/reject step altogether as other works have suggested (Salimans et al., 2015; Caterini et al., 2018). We opt for the former since we wish to work with HMC in its original form with the accept/reject step. + +Our empirical results confirm that we are able to successfully optimize the hyperparameters whilst using biased gradients. The intuition behind this is that the bias originates from the effect of the hyperparameters on the acceptance probability through the leapfrog discretization error. In practice, this discretization error and its gradient with respect to the hyperparameters is small due to the leapfrog integrator having second order accuracy (Leimkuhler & Reich, 2004). This results in a small overall bias. More concrete arguments justifying this can be found in the supplement. Finally, to improve computational efficiency, we avoid the calculation of second-order gradients by stopping backpropagation of the gradient through $x_{k}$ in $\nabla_{x_k}\log p^* (x_k)$ during the leapfrog updates. We find this has little impact on convergence and can lead to $5\times$ speedups in execution time. + +# 3.3. Tuning the Initial Distribution + +For our method to be useful, the initial distribution $q^{(0)}(x)$ must provide a sufficient coverage of $p(x)$ . However, a $q^{(0)}(x)$ that is overly spread out is undesirable because the burn-in time is then unnecessarily long. We describe below a method for choosing $q^{(0)}(x)$ that aims to achieve an optimal trade-off between these two requirements. + +The main idea is to use a variational approximation to the target as the initial distribution, as done by Hoffman (2017). This should be a distribution that can be easily sampled from and easily tuned to fit the target, e.g. a Gaussian or a normalizing flow (Tabak & Vanden-Eijnden, 2010; Rezende & Mohamed, 2015). Rather than use the standard ELBO for tuning $q^{(0)}(x)$ , we use $\alpha$ -divergence minimization (Hernández-Lobato et al., 2016). The $\alpha$ value dictates the mass covering behaviour of the resulting approximation, with $\alpha = 0$ corresponding to the standard mode seeking $D_{\mathrm{KL}}\big(q^{(0)}(x)||p(x)\big)$ minimization and $\alpha = 1$ corresponding to the mass covering $D_{\mathrm{KL}}\big(p(x)||q^{(0)}(x)\big)$ minimization. We compare both $\alpha$ values in our experiments. The $\alpha$ -divergence is very useful in this context as it can provide a mass covering approximation without the use of samples from the target. However, if samples from $p(x)$ are available, then $q^{(0)}(x)$ can alternatively be tuned on those samples via maximum likelihood (ML), which is also mass-covering. + +The previous approaches will produce a $q^{(0)}(x)$ that fits the target, but do not guarantee that it will be broad enough. To address this, we allow our method to automatically adjust the width of the initial distribution as necessary to keep $q_{\phi}^{(T)}(x)$ as closely matched to $p(x)$ as possible. This is achieved by applying a scalar scale factor $s$ centered around the mean $\mu$ of $q^{(0)}(x)$ to each sample $x_{i}$ from this distribution, i.e. $\hat{x}_i = s(x_i - \mu) + \mu$ . We tune $s$ by minimizing the Sliced Kernelized Stein Discrepancy (Gong et al., 2021) or + +$\mathrm{SKSD}^1$ between the final state distribution $q_{\phi}^{(T)}(x)$ and $p(x)$ The SKSD requires only samples from $q_{\phi}^{(T)}$ and gradients of the target, $\nabla_x\log p^* (x)$ . This objective encourages suitable values of $s$ because if $s$ is too small then the tuning of $\phi$ by solving (1) (which occurs jointly with the tuning of $s$ ) will result in a degenerate $q_{\phi}^{(T)}(x)$ far from the target. The SKSD measures this discrepancy and provides a learning signal for increasing $s$ . Conversely, if $s$ is too large then $q_{\phi}^{(T)}(x)$ will also be far from the target since the HMC chain will not be able to compensate for the poor initialization. The SKSD will then favor to decrease $s$ . Finally, as in the leapfrog updates, we stop the gradient computations through $x$ in $\nabla_x\log p^* (x)$ when evaluating SKSD to avoid the calculation of second-order gradients. + +Given that the SKSD is a tractable objective that measures the discrepancy between $q_{\phi}^{(T)}(x)$ and $p(x)$ , it is theoretically feasible to use the SKSD to optimize $\phi$ too. However, we found that the SKSD does not scale well when optimizing many parameters, which is why (1) is used instead. Note, however, that the SKSD works very well in practice when we only tune the single scalar parameter $s$ . + +We have empirically evaluated the method described in this section on a variety of applications and have found that it gives consistently good results. + +# 3.4. Final optimization procedure + +Algorithm 1 summarizes our optimization strategy, where Adam_update $(\eta ,\nabla_{\eta}\mathcal{L},i)$ returns the new value for $\eta$ given by the $i$ -th iteration of the Adam optimizer using gradient $\nabla_{\eta}\mathcal{L}$ , $D_{\alpha}(q_{\psi_{i - 1}}^{(0)}(x)\mid p(x))$ is an estimate of the $\alpha$ -divergence whose gradient is computed using doubly reparameterized gradient estimators (Tucker et al., 2019), $\mathrm{SKSD}(x_{1:N}^{(T)},\mathrm{score}(x))$ estimates the sliced kernelized Stein discrepancy and $\mathrm{HMC}_{\phi_{i - 1}}(x_n^{(0)'}$ , score $(x))$ runs an HMC chain with initial state $x_{n}^{(0)'}$ , target score function score $(x)$ and hyperparameters $\phi_{i - 1}$ . Details on the computation of $D_{\alpha}(q_{\psi_{i - 1}}^{(0)}(x)\mid p(x)),i)$ and $\mathrm{SKSD}(x_{1:N}^{(T)},\mathrm{score}(x))$ are given in the Supplementary Material. + +# 4. Experiments + +Different experiments are performed to confirm that we can discover good hyperparameter settings by using the previously described method. We provide code for reproducing all our experiments on github2. + +![](images/95bd78ac085d19a5a320438b0ac2808bffe0b22d25c431c0ace29e10bc29f475.jpg) +Gaussian + +![](images/e231a63ff52005fccb6e9d24b366e66e0e3debe1fc39357286199b966c06dabc.jpg) +Laplace + +![](images/2c23e663740276ac3d4835da1a140118a55e2a763236b1d350abba71bdc0d0a7.jpg) +Dual Moon + +![](images/571d2909f117fb3b9a38d52e4a0683c4e6d4b96439adf53b71c6a20011370475.jpg) +Mixture + +![](images/1181af2f0c6651ac190e69c1772daa683492b95531f4341a1b3f33badcf2ea51.jpg) +Wave 1 + +![](images/a37b8810a4bc91a116413d2368d9ed30e7b54f906fce8d1187e0d51ba80cca2d.jpg) +Wave 2 +Figure 2. Histograms of 2D targets generated by rejection sampling. + +
GaussianLaplaceDual MoonMixtureWave 1Wave 2
maxELT α = 00.06770.00050.23700.00040.05250.0462
maxELT α = 10.00090.00040.86370.00100.01580.0801
maxELT α = 0 SKSD0.00080.00160.16840.00040.00200.0217
maxELT α = 1 SKSD0.00090.00140.25280.00040.00190.0317
Hoffman (2017)0.03640.00051.15530.08460.94470.0465
Ruiz & Titsias (2019)0.00030.00031.62900.00030.00240.2375
NUTS0.00440.00160.23260.00230.02600.0965
+ +Table 1. KSD between the HMC samples and the target distribution for the baselines and the 4 variations of our method on each of the synthetic target distributions (equations are given in the Supplementary Material). + +# Algorithm 1 Optimization Procedure + +Input: Initial $\psi_0$ , $\phi_0$ and $s_0$ , number of iterations $I_{1}$ and $I_{2}$ and number of samples $N$ + +Define score(x) = stop-gradient(∇x log p*(x)) + +Train initial distribution + +for $i = 1$ to $I_{1}$ do + +$$ +\psi_ {i} \leftarrow \operatorname {A d a m \_ u p d a t e} \left(\psi_ {i - 1}, \nabla_ {\psi_ {i - 1}} D _ {\alpha} \left(q _ {\psi_ {i - 1}} ^ {(0)} (x) \mid | p (x), i\right) \right. +$$ + +end for + +$$ +\mu \leftarrow \text {m e a n} q _ {\psi_ {i - 1}} ^ {(0)} (x) +$$ + +Train HMC hyperparameters + +for $i = 1$ ,to $I_{2}$ do + +for $n = 1$ , to $N$ do # This loop is vectorized in practice + +$$ +\text {D r a w} x _ {n} ^ {(0)} \sim q _ {\psi} ^ {(0)} (x) +$$ + +$$ +x _ {n} ^ {(0) ^ {\prime}} \leftarrow s _ {i - 1} \left(x _ {n} ^ {(0)} - \mu\right) + \mu \# \text {R e s c a l e} +$$ + +$$ +x _ {n} ^ {(T)} \leftarrow \operatorname {H M C} _ {\phi_ {i - 1}} \left(x _ {n} ^ {(0) ^ {\prime}}, \text {s c o r e} (x)\right) +$$ + +end for + +$$ +\phi_ {i} \leftarrow \operatorname {A d a m \_ u p d a t e} \left(\phi_ {i - 1}, \nabla_ {\phi_ {i - 1}} \frac {1}{N} \sum_ {n = 1} ^ {N} \log p ^ {*} \left(x _ {n} ^ {(T)}\right), i\right) +$$ + +$$ +s _ {i} \leftarrow \operatorname {A d a m \_ u p d a t e} \left(s _ {i - 1}, \nabla_ {s _ {i - 1}} \operatorname {S K S D} \left(x _ {1: N} ^ {(T)}, \operatorname {s c o r e} (x)\right), i\right) +$$ + +end for + +$$ +\text {R e t u r n} \psi_ {I _ {1}}, \phi_ {I _ {2}}, s _ {I _ {2}} +$$ + +# 4.1. 2D distributions + +We first focus on drawing approximate samples from a range of synthetic 2D target densities (Figure 2). We use 30-step HMC chains and a factorized Gaussian $q^{(0)}(x)$ that is trained by minimizing the $\alpha$ -divergence. We optimize step sizes and masses using (1), a procedure we refer to as 'maxELT' for maximizing the expected log target. Additionally, as an ablation study, we consider different initial distribution training strategies: $\alpha = 0$ or 1 and whether or not to tune the scaling $s$ by minimizing the SKSD ( $s = 1$ when not tuned). To quantify convergence to the target, we used the Kernelized Stein Discrepancy (KSD) (Liu et al., 2016; Chwialkowski et al., 2016) between the generated samples and the targets. + +We include three baselines for reference. The first one is taken from Hoffman (2017) and initializes the HMC chains with an $\alpha = 0$ trained Gaussian distribution and tunes step sizes according to a minimum acceptance probability heuris + +![](images/0974500b1ddef07972b2b52a55fd390ad4d200897a40eed1673083f07ec3ca58.jpg) +Figure 3. KSD versus step size used as initialization point for optimization. Wave 1 is the target distribution. + +tic. The second baseline is the method from Ruiz & Titsias (2019) which initializes chains with a variational distribution, trained using a novel divergence metric. The HMC parameters are not tuned however. The final baseline is the popular No-U-Turn Sampler (Hoffman & Gelman, 2014). Full details regarding the baselines are given in the Supplementary Material. + +Results are shown in Table 1. Our method with automatic $s$ scaling using the SKSD performs consistently well across distributions. For some simple targets, e.g. Gaussian and Laplace, it performs slightly worse than Ruiz & Titsias (2019), however, this method breaks down on the more complex targets, Dual Moon and Wave 2 whereas ours remains consistent. Furthermore, we fit the targets better when we tune $s$ by minimizing the SKSD than when we do not. For some distributions, tuning $s$ effectively helps prevent mode seeking behaviour. We confirm this quantitatively in the Supplementary Material by comparing expected log target values. We find that narrow initial distributions $(\alpha = 0)$ often lead to excessively high log target values, but the tuning of $s$ can prevent this pathology. + +We also investigate the method's robustness to the initialization point. Figure 3 plots the KSD between the HMC samples and the target distribution (Wave 1) before and after training the hyperparameters for a large range of initialization step sizes. We find our method is largely invariant to + +the initialization point provided it is not excessively large, in which case every step in the chain is rejected and there is no gradient signal for learning. However, we do no worse than the initial distribution as each sample remains at its initial sampling point. + +# 4.2. Sparse Signal Recovery + +We now consider higher dimensional target distributions. Specifically, posterior distributions in Bayesian compressed sensing (Donoho, 2006; Ji et al., 2008). The aim is to recover the sparse signal $w \in \mathbb{R}^d$ from measurements $y \in \mathbb{R}^n$ where $n < d$ . The observation model is $y = Xw + e$ where $e \in \mathbb{R}^n$ , $e \sim \mathcal{N}(0, \sigma_0^2 I)$ , is additive Gaussian noise and $X \in \mathbb{R}^{n \times d}$ is a measurement matrix obtained by sampling its entries from a standard Gaussian distribution and then normalizing the rows to have unit Euclidean norm. We place a sparsity enforcing horseshoe prior on $w$ and consider the posterior for $w$ given $y$ , $X$ and $\sigma_0^2$ . When $n << d$ this posterior is multi-modal representing multiple potential explanations for the available observations. In these experiments we fix $n = 6$ and $d = 64$ . + +We draw posterior samples using a 20 step HMC chain with 5 leapfrog iterations per step, initialized with a factorized Gaussian distribution that is trained with $\alpha = 1$ . We do not use $\alpha = 0$ here since this method performs significantly worse in this problem due to its mode seeking tendency (Hernández-Lobato et al., 2015). We evaluate the quality of our samples by calculating their log marginal likelihood on test data generated using the same sparse signal as in the training set. The highest test log marginal likelihood is obtained when the generated samples come from the true posterior distribution. + +![](images/fc25525c4ff98174ae3a64b3952a12a7e7d7a18851fca746fa968f48799ded5a.jpg) +Figure 4. Violin-Box plot of test log marginal likelihoods on the sparse signal recovery problems. We draw 10,000 posterior samples to estimate the log marginal likelihood of 1000 test observations and repeat 20 times to obtain confidence bands. + +We compare our method with three baselines that use the + +same initial distribution. The first two are parallel samplers where for each sample we first sample the initial distribution and then run 20 HMC accept/reject steps. The step sizes and masses are tuned either by a grid search to maximize the log marginal likelihood on a validation set or the step sizes are tuned such that the average acceptance probability is 0.65. The final baseline is sequential—the No-U-Turn sampler. To generate samples, we first sample the initial distribution once then run 15000 accept/reject steps, discarding the first 5000 samples. The hyperparameters are tuned using dual averaging during the burn-in period. Full experimental details are in the Supplementary Material. + +The results are shown in Figure 4 and we see that our method generally outperforms the baselines. It is also noticeable that the sequential sampler (NUTS) has a very high variance between repeats. This is because it is very sensitive to the initialization point. NUTS performs well in the very few cases where the initialization is close to a posterior mode with good properties. However, if it is initialized close to a sub-optimal mode, it will likely stay there for the whole run and find hyperparameters only suited to this local region giving a very poor log likelihood. The parallel samplers do not have this issue as they have a new initialization point for each sample. We also note that, in this case, using SKSD to tune $s$ results in a slight degradation in performance. On this problem, $\alpha = 1$ is already well suited to find a good initial distribution and, indeed, the value for $s$ tuned by SKSD was very close to 1. + +# 4.3. Deep Latent Gaussian Models + +We now focus on training Variational Autoencoders (VAEs) (Kingma & Welling, 2014; Rezende et al., 2014). These are generative models of the form $p(x,z) = p_{\theta}(x|z)\mathcal{N}(z;0,I)$ , explaining observed data $x$ with a latent variable $z$ and a likelihood $p_{\theta}(x|z)$ parameterized by a neural network $\mathrm{NN}_{\theta}(z)$ with parameters $\theta$ and input $z$ . The standard training in VAEs is to use a factorized Gaussian distribution $q_{\psi}(z|x)$ parameterized by $\mathrm{NN}_{\psi}(x)$ to approximate $p_{\theta}(z|x)$ and train $(\theta ,\psi)$ jointly by maximizing the ELBO. + +Our approximation to $p_{\theta}(z|x)$ is the HMC chain output distribution $q_{\phi}^{(T)}(z|x)$ . The initial state of the HMC chain is sampled from $q_{\psi}^{(0)}(z|x)$ , which is given by a factorized Gaussian distribution parameterized by $\mathrm{NN}_{\psi}(x)$ and appropriately scaled by $s$ as before. The parameters $\psi$ are trained by minimizing the $\alpha$ -divergence and $s$ is trained using the SKSD. We train $\phi$ and $\theta$ by jointly maximizing the objective in (1) with respect to these two parameters. We consider HMC chains of length 30 with 5 leapfrog iterations per step and tune a different step size parameter per dimension and per step in the HMC chain while the mass parameters are all kept constant and equal to 1 all throughout the HMC chain. + +Note that we use only one set of HMC hyperparameters for + +Table 2. Average test marginal log-likelihood and its standard error (SE) estimated using HAIS for different methods for MNIST and Fashion MNIST. For methods with a scale factor $s$ , we report the final scale after training. We also report the best log-likelihood values from previous works. + +
ModelMNISTFashion MNIST
ScaleMeanSEScaleMeanSE
VAE--85.080.22--108.540.60
DReG-IWAE--83.730.21--104.480.58
maxELT α = 01.0-83.480.211.0-104.080.58
maxELT α = 11.0-82.460.211.0-103.570.58
maxELT α = 0 SKSD6.79-81.910.205.58-103.180.58
maxELT α = 1 SKSD3.90-81.940.203.59-102.290.57
Hoffman--81.740.20--103.040.58
Ruiz & Titsias--82.450.21--105.130.59
Salimans et al.--81.94---104.440.59
Caterini et al.--82.62---104.260.58
+ +all $p_{\theta}(z|x)$ targets, independently of $x$ . One could make the hyperparameters depend on $x$ through an amortization network, but we found that this did not improve performance. We consider two benchmark datasets: MNIST and Fashion MNIST. As is common, we use binarized images and a Bernoulli likelihood $p_{\theta}(x|z)$ parameterized with the same convolutional architecture as Salimans et al. (2015). Full experimental details are in the Supplementary Material. + +We evaluate the quality of our trained models using the marginal log-likelihood $\log p_{\theta}(x)$ on the test set estimated using Hamiltonian Annealed Importance Sampling or HAIS (Sohl-Dickstein & Culpepper, 2012). Results are shown in Table 2. We also report log-likelihood values for multiple baselines. Using the same neural architecture, we implemented the standard VAE and IWAE3 models. We also implemented another method for tuning $\phi$ (Hoffman, 2017) where the step sizes are adjusted to make the minimum average acceptance probability in each minibatch equal to 0.25. Furthermore, we implemented the method for tuning $\psi$ from Ruiz & Titsias (2019) while the HMC step sizes were tuned to ensure the mean average acceptance probability in each minibatch is equal to 0.65. We update $\theta$ as in our method and use the same number of leapfrog steps for a fair comparison. Finally, we report results for MNIST from Salimans et al. (2015) and Caterini et al. (2018) which include HMC hyperparameter tuning during training and use the same network architecture as us. These authors only evaluated on MNIST, so we reimplemented their methods for Fashion MNIST4. We confirm significant differences between the models using paired t-tests. Full results are in + +the Supplementary Material. + +On both datasets, the HMC based methods achieve better performance than VAE or IWAE, showing that reducing the approximation bias of the variational distribution with HMC greatly helps. Furthermore, we see that adding the scale factor to our method significantly improves performance as this avoids degenerate behaviour when training the HMC hyperparameters. We note that, without any scaling $s$ , $\alpha = 1$ outperforms $\alpha = 0$ due to $\alpha = 0$ resulting in a too narrow initial distribution. With scaling, the SKSD automatically widens the initial distribution making the performance of both methods similar. Finally, we observe that HMC based methods top out at similar log-likelihood values (within around one standard error). We believe this is due to the methods reaching the limits of the chosen neural network architecture on these datasets, with no more gains to be made from more accurate posterior approximations. + +# 4.4. Molecular Configurations + +Finally, we evaluate our method on the complex real-world problem of sampling equilibrium molecular configurations from the Boltzmann distribution of the molecule Alanine Dipeptide. The unnormalized target distribution for the atom coordinates $x$ is $\mathrm{e}^{-u(x)}$ , where $u$ denotes the potential energy of the system, which can be obtained using the laws of physics. This problem is usually tackled via Molecular Dynamics (MD) simulations. Here, we aim to produce independent samples from $\mathrm{e}^{-u(x)}$ using our trained short HMC chains. We do not operate directly on the Cartesian coordinates but apply the coordinate transform presented by Noé et al. (2019), to map some of the Cartesian coordinates to bond lengths, bond angles, and dihedral angles. The final dimensionality for $x$ is 60. For more details, we refer to the Supplementary Material. + +For the initial distribution, we use a normalizing flow based on real-valued non-volume preserving (RNVP) transformations (Dinh et al., 2017), followed by 50 HMC steps with 10 leapfrog iterations per step. We used different methods to train the flow and the HMC hyperparameters. The flow was trained with $\alpha = \{0,1\}$ -divergence and by ML. The latter was done using $10^{5}$ training data samples obtained via a MD simulation5. As in the case with 2D densities and with sparse signals but unlike in the VAE case, we first trained the flows and then kept them fixed when tuning the HMC hyperparameters and the scale factor. + +For each initial distribution type, the HMC hyperparameters were tuned according to maxELT alone or by maxELT with SKSD scale training. As a baseline, we optimized the HMC parameters via grid search, keeping step sizes and masses + +![](images/b3471d5287af2aaccc2c80992242b040cb0f309b5021a1894321642722078a0d.jpg) +(a) Ground truth (MD) + +![](images/3de4344be7dd68198290c6a1bc6d0726f98c5a27ca694278c9d11b4a4838e9d2.jpg) +(b) maxELT & SKSD + +constant across dimensions and HMC step, varying these two parameters in a grid and picking the combination that gave the lowest median marginal KL-divergence to the MD training data. We also considered another baseline by adjusting the step size value such that the average acceptance probability was 0.65 (referred to as $\overline{p}_{\mathrm{a}} = 0.65$ ). Further implementation details are given in the Supplementary Material. + +A new MD simulation was run to obtain $10^{6}$ ground truth samples for evaluating the performance of the different methods. For tractability, this is done by comparing the marginal distributions of the generated and ground truth samples. First, we use Ramachandran plots (Ramachandran et al., 1963), which are 2D histograms for the two dihedral angles in the bonds connecting an amino acid to the protein backbone. These plots are frequently used to analyse how proteins fold locally. In the Alanine Dipeptide case we can obtain a Ramachandran plot for the bond connecting the two amino acids forming this molecule. Two sample plots are shown in Figure 5. We compute KL divergences between the 2D histograms (Ramachandran plots) for the ground truth samples and for the samples generated by the different methods. The results are given in Figure 6. All the corresponding Ramachandran plots are shown in the Supplementary Material. Our method outperforms the baselines for all proposals except for the one trained with the $\alpha = 0$ -divergence, where it improves upon grid search but performs worse than the $\overline{p}_{\mathrm{a}} = 0.65$ baseline. + +Finally, for each dimension of $x$ and using kernel density estimation, we compute the KL-divergences between the 1D densities produced by the ground truth samples and by the samples generated by the different methods. We perform a Wilcoxon test to check whether the resulting 60 divergence values (one per dimension) are consistently lower for one method or another. Table 3 shows $p$ -values for the case in which maxELT & SKSD is being tested for having lower KL-divergences than the baselines. In all but + +![](images/af2311804fcbd562b4bbcde14a004fea28919f270e4633c8bafa3d3104da6607.jpg) +Figure 5. Ramachandran plot of (a) the ground truth determined via a MD simulation and (b) samples from the model with the proposal trained with ML and HMC hyperparameters being tuned by maxELT & SKSD. +Figure 6. Visualization of the KL-divergences of the proposal and the models where different HMC hyperparameter tuning schemes were used. + +Table 3. P-values of the Wilcoxon test with the alternative hypothesis that the model with HMC parameters tuned by maxELT & SKSD leads to lower KL-divergences of the marginals with respect to the ground truth than the respective baseline. + +
Grid searchpa=0.65
α=00.00300.39
α=10.00300.0040
ML0.0105.1e-5
+ +one case maxELT & SKSD leads a significant improvement over the baselines and in the remaining case the two methods are on par with each other. All the other remaining $p$ -values can be found in the Supplementary Material. + +# 5. Discussion and Related Work + +Our experiments show a general trend that, when we solely optimize the objective in (1), the value of $\alpha$ used significantly affects performance. However, when applying the SKSD scaling, this difference becomes smaller, showing that this technique is useful for automatically finding a suitable initial distribution. + +A limitation of the method is that the hyperparameter optimization procedure must be run before samples can be produced. Therefore, our method is most applicable in cases where the optimization time is outweighed by the time savings gained through better hyperparameter choices and a faster mixing speed. This is the case for difficult problems where choosing reasonable hyperparameters is highly non-trivial and also for problems where a large number of samples need to be produced for a downstream task. + +Previous works have also used VI to obtain an objective for the gradient based tuning of HMC hyperparameters. As discussed previously, Salimans et al. (2015); Wolf et al. (2016) + +consider the entire joint distribution of the HMC chain as the variational distribution. The higher dimensionality increases the looseness of the variational bound, making the method highly sensitive to the length of the chain and the accuracy of a reverse dynamics approximation. Our experiments in section 4.3 show we can consider much longer chains and perform just as well without needing a reverse approximation. Caterini et al. (2018) also construct an alternative ELBO for HMC. However, they only sample the auxiliary momentum variables once at the start of the chain which reduces the empirical performance of HMC. + +In contrast to these methods, some gradient based tuning techniques do not use ideas from VI but instead optimize a proxy for mixing speed. Levy et al. (2018) generalize the standard leapfrog integrator used in HMC with multi-layer perceptrons which are then trained by maximizing a modified version of the expected squared jumped distance. We improve upon this objective by directly optimizing convergence speed by using gradient information from the target distribution itself. It would be an interesting direction to use our objective to train this generalised leapfrog operator. Finally, Titsias & Dellaportas (2019) consider the gradient based tuning of the Markov transition operator, $p_{\phi}(x_t|x_{t-1})$ , in the case of a single long MCMC chain. They optimize with respect to the expected acceptance probability for the next step in the chain, regularized with the entropy of $p_{\phi}(x_t|x_{t-1})$ . Unfortunately, as this entropy is intractable when using the leapfrog algorithm as the transition operator, it cannot be applied to HMC in its current form. + +There are also many non-gradient based heuristics for tuning HMC hyperparameters. The popular No-U-Turn Sampler (Hoffman & Gelman, 2014) can adaptively set the number of leapfrog steps $L$ to avoid U-turns and find a global constant for the step sizes by adjusting the average acceptance rate. In section 4.1, we found we can outperform NUTS even though we do not adaptively set L. With our objective, we can tune individual step sizes (and masses) for each dimension and step in the chain, allowing for a much higher degree of granular control over the algorithm. Furthermore, we do not need to rely on 'rules of thumb' such as standard acceptance rate targets used in many algorithms (Hoffman & Gelman, 2014; Hoffman, 2017) but we can automatically tune all continuous hyperparameters using information from the target distribution directly. + +Other works use MCMC as part of a hybrid inference scheme. Ruiz & Titsias (2019) propose a novel objective to improve the training of the initial distribution using MCMC samples. However, their objective cannot be used for tuning MCMC as it encourages final samples to be close to the initial distribution. Hoffman et al. (2019) use normalizing flows to warp the target distribution such that it is close to an isotropic Gaussian and thus easy to sample from using + +HMC. Though, they must still use gradient-free optimization on a heuristic to tune the HMC parameters, one could investigate performance if hyperparameters were instead tuned using our differentiable objective. + +Our work also builds upon methods from statistical mechanics. The Boltzmann Generator (Noé et al., 2019) opened up this line of research by using a normalizing flow to sample molecular configurations. We found we can improve upon this by using the flow as the initial distribution for HMC, fine tuning the flow samples with our short chains. Our Alanine Dipeptide experiment comes from the recent work of Wu et al. (2020) on stochastic normalizing flows, which consist of stochastic steps interspersed between deterministic steps in a normalizing flow. It is possible to combine such models with our approach, using our objective to tune hyperparameters within the stochastic layers. We leave this extension to future work. + +# 6. Conclusion + +In this work, we presented a new objective motivated by VI that can be easily used for the gradient-based optimization of HMC hyperparameters. We provided a fully automatic method for choosing an initial distribution for the HMC chain that reduces burn-in time and aids optimization. Evaluating on multiple real-world problems, we found our method is competitive with or improves upon existing methods for tuning hyperparameters. We hope this encourages further work applying this idea to other methods that use HMC and that would benefit from increased convergence speed. + +# Acknowledgements + +Andrew Campbell acknowledges support from the EPSRC CDT in Modern Statistics and Statistical Machine Learning (EP/S023151/1). José Miguel Hernández Lobato acknowledges support from a Turing AI Fellowship under grant EP/V023756/1. Yichuan Zhang acknowledges support from Samsung Research, Samsung Electronics Co., Seoul, Republic of Korea and from Boltzbit Ltd. + +# References + +Carpenter, B., Gelman, A., Hoffman, M. D., Lee, D., Goodrich, B., Betancourt, M., Brubaker, M., Guo, J., Li, P., and Riddell, A. Stan: A probabilistic programming language. Journal of statistical software, 76(1), 2017. +Caterini, A. L., Doucet, A., and Sejdinovic, D. Hamiltonian variational auto-encoder. Advances in Neural Information Processing Systems (NeurIPS), 2018. +Chwialkowski, K., Strathmann, H., and Gretton, A. A kernel + +test of goodness of fit. Proceedings of the International Conference on Machine Learning (ICML), 2016. +Dinh, L., Sohl-Dickstein, J., and Bengio, S. Density estimation using Real NVP. International Conference on Learning Representations (ICLR), 2017. +Donoho, D. L. Compressed sensing. IEEE Transactions on Information Theory, 52(4):1289-1306, 2006. doi: 10.1109/TIT.2006.871582. +Gong, W., Li, Y., and Hernández-Lobato, J. M. Sliced kernelized stein discrepancy. International Conference on Learning Representations (ICLR), 2021. +Hairer, E., Lubich, C., and Wanner, G. Geometric numerical integration illustrated by the Störmer-Verlet method. Acta Numerica, 12:399-450, 2003. +Hernández-Lobato, J., Hernández-Lobato, D., and Suárez, A. Expectation propagation in linear regression models with spike-and-slab priors. Machine Learning, 99:437-487, 2015. +Hernández-Lobato, J. M., Li, Y., Rowland, M., Bui, T., Hernandez-Lobato, D., and Turner, R. Black-box alpha divergence minimization. Proceedings of the International Conference on Machine Learning (ICML), 2016. +Hoffman, M. and Gelman, A. The no-u-turn sampler: Adaptively setting path lengths in Hamiltonian Monte Carlo. Journal of Machine Learning Research (JMLR), 2014. +Hoffman, M. and Ma, Y. Black-box variational inference as a parametric approximation to Langevin dynamics. Proceedings of the International Conference on Machine Learning (ICML), 2020. +Hoffman, M., Sountsov, P., Dillon, J. V., Langmore, I., Tran, D., and Vasudevan, S. Neutra-lizing bad geometry in hamiltonian monte carlo using neural transport. arXiv preprint arXiv:1903.03704, 2019. +Hoffman, M. D. Learning deep latent Gaussian models with Markov Chain Monte Carlo. Proceedings of the International Conference on Machine Learning (ICML), 2017. +Ji, S., Xue, Y., and Carin, L. Bayesian compressive sensing. IEEE Transactions on signal processing, 56(6):2346-2356, 2008. +Jordan, M. I., Ghahramani, Z., Jaakkola, T. S., and Saul, L. K. An introduction to variational methods for graphical models. Machine learning, 37(2):183-233, 1999. +Kingma, D. P. and Welling, M. Auto-encoding Variational Bayes. In International Conference on Learning Representations (ICLR), 2014. + +Leimkuhler, B. and Reich, S. Simulating Hamiltonian dynamics. Number 14. Cambridge university press, 2004. +Levy, D., Hoffman, M. D., and Sohl-Dickstein, J. Generalizing Hamiltonian Monte Carlo with neural networks. In International Conference on Learning Representations (ICLR), 2018. +Liu, Q., Lee, J., and Jordan, M. A kernelized stein discrepancy for goodness-of-fit tests. Proceedings of the International Conference on Machine Learning (ICML), 2016. +Neal, R. M. Probabilistic Inference using Markov Chain Monte Carlo Methods. Technical report, University of Toronto, Department of Computer Science, 1993. +Neal, R. M. MCMC using Hamiltonian dynamics. Handbook of markov chain monte carlo, 2(11):2, 2011. +Noé, F., Olsson, S., Kohler, J., and Wu, H. Boltzmann generators: Sampling equilibrium states of many-body systems with deep learning. Science, 365(6457), September 2019. ISSN 0036-8075, 1095-9203. doi: 10.1126/science.aaw1147. +Pasarica, C. and Gelman, A. Adaptively scaling the Metropolis algorithm using expected squared jumped distance. Statistica Sinica, 20(1):343-364, 2010. +Ramachandran, G. N., Ramakrishnan, C., and Sasisekharan, V. Stereochemistry of polypeptide chain configurations. Journal of Molecular Biology, 7(1):95-99, July 1963. ISSN 0022-2836. doi: 10.1016/S0022-2836(63)80023-6. +Rezende, D. and Mohamed, S. Variational Inference with Normalizing Flows. Proceedings of the International Conference on Machine Learning (ICML), 2015. +Rezende, D. J., Mohamed, S., and Wierstra, D. Stochastic Backpropagation and Approximate Inference in Deep Generative Models. Proceedings of the International Conference on Machine Learning (ICML), 2014. +Ruiz, F. and Titsias, M. A contrastive divergence for combining variational inference and MCMC. Proceedings of the International Conference on Machine Learning (ICML), 2019. +Salimans, T., Kingma, D., and Welling, M. Markov Chain Monte Carlo and variational inference: Bridging the gap. Proceedings of the International Conference on Machine Learning (ICML), 2015. +Sohl-Dickstein, J. and Culpepper, B. J. Hamiltonian annealed importance sampling for partition function estimation. Technical report, Redwood Center for Theoretical Neuroscience University of California, Berkeley, 2012. + +Tabak, E. G. and Vanden-Eijnden, E. Density estimation by dual ascent of the log-likelihood. Communications in Mathematical Sciences, 8(1):217-233, 2010. ISSN 15396746, 19450796. doi: 10.4310/CMS.2010.v8.n1.a11. +Titsias, M. and Dellaportas, P. Gradient-based adaptive Markov Chain Monte Carlo. Advances in Neural Information Processing Systems (NeurIPS), 2019. +Tucker, G., Lawson, D., Gu, S., and Maddison, C. Doubly reparameterized gradient estimators for Monte Carlo objectives. International Conference on Learning Representations (ICLR), 2019. +Wolf, C., Karl, M., and van der Smagt, P. Variational inference with Hamiltonian Monte Carlo. arXiv preprint arXiv:1609.08203, 2016. +Wu, H., Kohler, J., and Noel, F. Stochastic Normalizing Flows. Advances in Neural Information Processing Systems (NeurIPS), 2020. \ No newline at end of file diff --git a/agradientbasedstrategyforhamiltonianmontecarlohyperparameteroptimization/images.zip b/agradientbasedstrategyforhamiltonianmontecarlohyperparameteroptimization/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..a58623e348bbbdbe51ffb8e870ebbd115f732c57 --- /dev/null +++ b/agradientbasedstrategyforhamiltonianmontecarlohyperparameteroptimization/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c6aa19a8e93bee0a54d709deb33d732f7852554637fd01be6efc01a3ec6183aa +size 347917 diff --git a/agradientbasedstrategyforhamiltonianmontecarlohyperparameteroptimization/layout.json b/agradientbasedstrategyforhamiltonianmontecarlohyperparameteroptimization/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..bc1c4fe066dc7310b6700d0c4ccf420ad8ec9835 --- /dev/null +++ b/agradientbasedstrategyforhamiltonianmontecarlohyperparameteroptimization/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1a61b68f1f03982e2efabf9af67133bb3415c20f725f8c6adbd4a2ece3b33fd6 +size 511680 diff --git a/ahybridvariancereducedmethodfordecentralizedstochasticnonconvexoptimization/18834a88-35e9-42cd-adec-5f86bbede495_content_list.json b/ahybridvariancereducedmethodfordecentralizedstochasticnonconvexoptimization/18834a88-35e9-42cd-adec-5f86bbede495_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..e471ffd939d037cde06ba4a5490869176f707281 --- /dev/null +++ b/ahybridvariancereducedmethodfordecentralizedstochasticnonconvexoptimization/18834a88-35e9-42cd-adec-5f86bbede495_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:55c1b9c9ddfe524ae9dbc2d2e24155adfa0011cf983bc158824ca484ae0906f3 +size 100149 diff --git a/ahybridvariancereducedmethodfordecentralizedstochasticnonconvexoptimization/18834a88-35e9-42cd-adec-5f86bbede495_model.json b/ahybridvariancereducedmethodfordecentralizedstochasticnonconvexoptimization/18834a88-35e9-42cd-adec-5f86bbede495_model.json new file mode 100644 index 0000000000000000000000000000000000000000..96efcad6134d663ce9fbd3450ce29060dde2f97e --- /dev/null +++ b/ahybridvariancereducedmethodfordecentralizedstochasticnonconvexoptimization/18834a88-35e9-42cd-adec-5f86bbede495_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9b90e8c722e6e8939c4f9a1558783683c18d063a6315e8a438f0b7b8d11aca93 +size 123196 diff --git a/ahybridvariancereducedmethodfordecentralizedstochasticnonconvexoptimization/18834a88-35e9-42cd-adec-5f86bbede495_origin.pdf b/ahybridvariancereducedmethodfordecentralizedstochasticnonconvexoptimization/18834a88-35e9-42cd-adec-5f86bbede495_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..cdc6eb5f76699e741591b8771b8f5d4d48e3dd85 --- /dev/null +++ b/ahybridvariancereducedmethodfordecentralizedstochasticnonconvexoptimization/18834a88-35e9-42cd-adec-5f86bbede495_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:79b1ade00e645b6770cbbb9e1ca2c5b9e9b63520e164672d25d570b7459e3e8c +size 4703834 diff --git a/ahybridvariancereducedmethodfordecentralizedstochasticnonconvexoptimization/full.md b/ahybridvariancereducedmethodfordecentralizedstochasticnonconvexoptimization/full.md new file mode 100644 index 0000000000000000000000000000000000000000..440a13ca25348ba6342e0225587123a3d35eecbc --- /dev/null +++ b/ahybridvariancereducedmethodfordecentralizedstochasticnonconvexoptimization/full.md @@ -0,0 +1,461 @@ +# A Hybrid Variance-Reduced Method for Decentralized Stochastic Non-Convex Optimization + +Ran Xin1 Usman A. Khan2 Soummya Kar1 + +# Abstract + +This paper considers decentralized stochastic optimization over a network of $n$ nodes, where each node possesses a smooth non-convex local cost function and the goal of the networked nodes is to find an $\epsilon$ -accurate first-order stationary point of the sum of the local costs. We focus on an online setting, where each node accesses its local cost only by means of a stochastic first-order oracle that returns a noisy version of the exact gradient. In this context, we propose a novel single-loop decentralized hybrid variance-reduced stochastic gradient method, called GT-HSGD, that outperforms the existing approaches in terms of both the oracle complexity and practical implementation. The GT-HSGD algorithm implements specialized local hybrid stochastic gradient estimators that are fused over the network to track the global gradient. Remarkably, GT-HSGD achieves a network topology-independent oracle complexity of $O(n^{-1}\epsilon^{-3})$ when the required error tolerance $\epsilon$ is small enough, leading to a linear speedup with respect to the centralized optimal online variance-reduced approaches that operate on a single node. Numerical experiments are provided to illustrate our main technical results. + +# 1. Introduction + +We consider $n$ nodes, such as machines or edge devices, communicating over a decentralized network described by a directed graph $\mathcal{G} = (\mathcal{V},\mathcal{E})$ , where $\mathcal{V} = \{1,\dots ,n\}$ is the set of node indices and $\mathcal{E}\subseteq \mathcal{V}\times \mathcal{V}$ is the collection of ordered pairs $(i,j)$ , $i,j\in \mathcal{V}$ , such that node $j$ sends information to node $i$ . Each node $i$ possesses a private local cost function $f_{i}:\mathbb{R}^{p}\to \mathbb{R}$ and the goal of the networked nodes + +$^{1}$ Department of Electrical and Computer Engineering, Carnegie Mellon University, Pittsburgh, PA, USA $^{2}$ Department of Electrical and Computer Engineering, Tufts University, Medford, MA, USA. Correspondence to: Ran Xin . + +Proceedings of the $38^{th}$ International Conference on Machine Learning, PMLR 139, 2021. Copyright 2021 by the author(s). + +is to solve, via local computation and communication, the following optimization problem: + +$$ +\min _ {\mathbf {x} \in \mathbb {R} ^ {p}} F (\mathbf {x}) = \frac {1}{n} \sum_ {i = 1} ^ {n} f _ {i} (\mathbf {x}). +$$ + +This canonical formulation is known as decentralized optimization (Tsitsiklis et al., 1986; Nedic & Ozdaglar, 2009; Kar et al., 2012; Chen & Sayed, 2015) that has emerged as a promising framework for large-scale data science and machine learning problems (Lian et al., 2017; Assran et al., 2019). Decentralized optimization is essential in scenarios where data is geographically distributed and/or centralized data processing is infeasible due to communication and computation overhead or data privacy concerns. In this paper, we focus on an online and non-convex setting. In particular, we assume that each local cost $f_{i}$ is non-convex and each node $i$ only accesses $f_{i}$ by querying a local stochastic first-order oracle (SFO) (Nemirovski et al., 2009) that returns a stochastic gradient, i.e., a noisy version of the exact gradient, at the queried point. As a concrete example of practical interest, the SFO mechanism applies to many online learning and expected risk minimization problems where the noise in SFO lies in the uncertainty of sampling from the underlying streaming data received at each node (Kar et al., 2012; Chen & Sayed, 2015). We are interested in the oracle complexity, i.e., the total number of queries to SFO required at each node, to find an $\epsilon$ -accurate first-order stationary point $\mathbf{x}^*$ of the global cost $F$ such that $\mathbb{E}[\| \nabla F(\mathbf{x}^*)\| ]\leq \epsilon$ . + +# 1.1. Related Work + +We now briefly review the literature of decentralized nonconvex optimization with SFO, which has been widely studied recently. Perhaps the most well-known approach is the decentralized stochastic gradient descent (DSGD) and its variants (Chen & Sayed, 2015; Kar et al., 2012; Vlaski & Sayed, 2019; Lian et al., 2017; Taheri et al., 2020), which combine average consensus and a local stochastic gradient step. Although being simple and effective, DSGD is known to have difficulties in handling heterogeneous data (Xin et al., 2020a). Recent works (Tang et al., 2018; Lu et al., 2019; Xin et al., 2020e; Yi et al., 2020) achieve robustness to heterogeneous environments by leveraging certain + +decentralized bias-correction techniques such as EXTRA (type) (Shi et al., 2015; Yuan et al., 2020; Li & Lin, 2020), gradient tracking (Di Lorenzo & Scutari, 2016; Xu et al., 2015; Pu & Nedich, 2020; Xin et al., 2020f; Nedich et al., 2017; Qu & Li, 2017; Xi et al., 2017), and primal-dual principles (Jakovetic, 2018; Li et al., 2019; Alghunaim et al., 2020; Xu et al., 2020). Built on top of these bias-correction techniques, very recent works (Sun et al., 2020) and (Pan et al., 2020) propose D-GET and D-SPIDER-SFO respectively that further incorporate online SARAH/SPIDER-type variance reduction schemes (Fang et al., 2018; Wang et al., 2019; Pham et al., 2020) to achieve lower oracle complexities, when the SFO satisfies a mean-squared smoothness property. Finally, we note that the family of decentralized variance reduced methods has been significantly enriched recently, see, for instance, (Mokhtari & Ribeiro, 2016; Yuan et al., 2018; Xin et al., 2020a; Li et al., 2020b;a; Rajawat & Kumar, 2020; Xin et al., 2020b;c; Liu et al., 2020); however, these approaches are explicitly designed for empirical minimization where each local cost $f_{i}$ is decomposed as a finite-sum of component functions, i.e., $f_{i} = \frac{1}{m}\sum_{r=1}^{m}f_{i,r}$ ; it is therefore unclear whether these algorithms can be adapted to the online SFO setting, which is the focus of this paper. + +# 1.2. Our Contributions + +In this paper, we propose GT-HSGD, a novel online variance reduced method for decentralized non-convex optimization with stochastic first-order oracles (SFO). To achieve fast and robust performance, the GT-HSGD algorithm is built upon global gradient tracking (Di Lorenzo & Scutari, 2016; Xu et al., 2015) and a local hybrid stochastic gradient estimator (Liu et al., 2020; Tran-Dinh et al., 2020; Cutkosky & Orabona, 2019) that can be considered as a convex combination of the vanilla stochastic gradient returned by the SFO and a SARAH-type variance-reduced stochastic gradient (Nguyen et al., 2017). In the following, we emphasize the key advantages of GT-HSGD compared with the existing decentralized online (variance-reduced) approaches, from both theoretical and practical aspects. + +Improved oracle complexity. A comparison of the oracle complexity of GT-HSGD with related algorithms is provided in Table 1, from which we have the following important observations. First of all, the oracle complexity of GT-HSGD is lower than that of DSGD, D2, GT-DSGD and D-PD-SGD, which are decentralized online algorithms without variance reduction; however, GT-HSGD imposes on the SFO an additional mean-squared smoothness (MSS) assumption that is required by all online variance-reduced techniques in the literature (Arjevani et al., 2019; Fang et al., 2018; Wang et al., 2019; Pham et al., 2020; Liu et al., 2020; Tran-Dinh et al., 2020; Cutkosky & Orabona, 2019; Sun et al., 2020; Pan et al., 2020; Zhou et al., 2020). Secondly, GT-HSGD further achieves a lower oracle complexity than + +the existing decentralized online variance-reduced methods D-GET (Sun et al., 2020) and D-SPIDER-SFO (Pan et al., 2020), especially in a regime where the required error tolerance $\epsilon$ and the network spectral gap $(1 - \lambda)$ are relatively small. Moreover, when $\epsilon$ is small enough such that $\epsilon \lesssim \min \left\{\lambda^{-4}(1 - \lambda)^{3}n^{-1},\lambda^{-1}(1 - \lambda)^{1.5}n^{-1}\right\}$ , it can be verified that the oracle complexity of GT-HSGD reduces to $O(n^{-1}\epsilon^{-3})$ , independent of the network topology, and GT-HSGD achieves a linear speedup, in terms of the scaling with the network size $n$ , compared with the centralized optimal online variance-reduced approaches that operate on a single node (Fang et al., 2018; Wang et al., 2019; Pham et al., 2020; Liu et al., 2020; Tran-Dinh et al., 2020; Zhou et al., 2020); see Section 3 for a detailed discussion. In sharp contrast, the speedup of D-GET (Sun et al., 2020) and D-SPIDER-SFO (Pan et al., 2020) is not clear compared with the aforementioned centralized optimal methods even if the network is fully connected, i.e., $\lambda = 0$ . + +More practical implementation. Both D-GET (Sun et al., 2020) and D-SPIDER-SFO (Pan et al., 2020) are double-loop algorithms that require very large minibatch sizes. In particular, during each inner loop they execute a fixed number of minibatch stochastic gradient type iterations with $O(\epsilon^{-1})$ oracle queries per update per node, while at every outer loop they obtain a stochastic gradient with mega minibatch size by $O(\epsilon^{-2})$ oracle queries at each node. Clearly, querying the oracles exceedingly, i.e., obtaining a large amount of samples, at each node and every iteration in online steaming data scenarios substantially jeopardizes the actual wall-clock time. This is because the next iteration cannot be performed until all nodes complete the sampling process. Moreover, the double-loop implementation may incur periodic network synchronizations. These issues are especially significant when the working environments of the nodes are heterogeneous. Conversely, the proposed GT-HSGD is a single-loop algorithm with $O(1)$ oracle queries per update and only requires a large minibatch size with $O(\epsilon^{-1})$ oracle queries once in the initialization phase, i.e., before the update recursion is executed; see Algorithm 1 and Corollary 1 for details. + +# 1.3. Roadmap and Notations + +The rest of the paper is organized as follows. In Section 2, we state the problem formulation and develop the proposed GT-HSGD algorithm. Section 3 presents the main convergence results of GT-HSGD and their implications. Section 4 outlines the convergence analysis of GT-HSGD, while the detailed proofs are provided in the Appendix. Section 5 provides numerical experiments to illustrate our theoretical claims. Section 6 concludes the paper. + +Table 1. A comparison of the oracle complexity of decentralized online stochastic gradient methods. The oracle complexity is in terms of the total number of queries to SFO required at each node to obtain an $\epsilon$ -accurate stationary point $\mathbf{x}^*$ of the global cost $F$ such that $\mathbb{E}[\|\nabla F(\mathbf{x}^*)\|] \leq \epsilon$ . In the table, $n$ is the number of the nodes and $(1 - \lambda) \in (0,1]$ is the spectral gap of the weight matrix associated with the network. We note that the complexity of D2 and D-SPIDER-SFO also depends on the smallest eigenvalue $\lambda_n$ of the weight matrix; however, since $\lambda_n$ is less sensitive to the network topology, we omit the dependence of $\lambda_n$ in the table for conciseness. The MSS column indicates whether the algorithm in question requires the mean-squared smoothness assumption on the SFO. Finally, we emphasize that DSGD requires bounded heterogeneity such that $\sup_{\mathbf{x}} \frac{1}{n} \sum_{i=1}^{n} \| \nabla f_i(\mathbf{x}) - \nabla F(\mathbf{x}) \|^2 \leq \zeta^2$ , for some $\zeta \in \mathbb{R}^+$ , while other algorithms in the table do not need this assumption. + +
AlgorithmOracle ComplexityMSSRemarks
DSGD (Lian et al., 2017)O\left(\max\left\{\frac{1}{n\epsilon^4}, \frac{\lambda^2n}{(1-\lambda)^2\epsilon^2}\right\}\right)Xbounded heterogeneity
D2 (Tang et al., 2018)O\left(\max\left\{\frac{1}{n\epsilon^4}, \frac{n}{(1-\lambda)^b\epsilon^2}\right\}\right)Xb∈R+ is not explicitly shown in (Tang et al., 2018)
GT-DSGD (Xin et al., 2020e)O\left(\max\left\{\frac{1}{n\epsilon^4}, \frac{\lambda^2n}{(1-\lambda)^3\epsilon^2}\right\}\right)X
D-PD-SGD (Yi et al., 2020)O\left(\max\left\{\frac{1}{n\epsilon^4}, \frac{n}{(1-\lambda)^c\epsilon^2}\right\}\right)Xc∈R+ is not explicitly shown in (Yi et al., 2020)
D-GET (Sun et al., 2020)O\left(\frac{1}{(1-\lambda)^d\epsilon^3}\right)d∈R+ is not explicitly shown in (Sun et al., 2020)
D-SPIDER-SFO (Pan et al., 2020)O\left(\frac{1}{(1-\lambda)^h\epsilon^3}\right)h∈R+ is not explicitly shown in (Pan et al., 2020)
GT-HSGD (this work)O\left(\max\left\{\frac{1}{n\epsilon^3}, \frac{\lambda^4}{(1-\lambda)^3\epsilon^2}, \frac{\lambda^{1.5}n^{0.5}}{(1-\lambda)^{2.25}\epsilon^{1.5}}\right\}\right)
+ +We adopt the following notations throughout the paper. We use lowercase bold letters to denote vectors and uppercase bold letters to denote matrices. The ceiling function is denoted as $\lceil \cdot \rceil$ . The matrix $\mathbf{I}_d$ represents the $d\times d$ identity; $\mathbf{1}_d$ and $\mathbf{0}_d$ are the $d$ -dimensional column vectors of all ones and zeros, respectively. We denote $[\mathbf{x}]_i$ as the $i$ -th entry of a vector $\mathbf{x}$ . The Kronecker product of two matrices $\mathbf{A}$ and $\mathbf{B}$ is denoted by $\mathbf{A}\otimes \mathbf{B}$ . We use $\| \cdot \|$ to denote the Euclidean norm of a vector or the spectral norm of a matrix. We use $\sigma (\cdot)$ to denote the $\sigma$ -algebra generated by the sets and/or random vectors in its argument. + +# 2. Problem Setup and GT-HSGD + +In this section, we introduce the mathematical model of the stochastic first-order oracle (SFO) at each node and the communication network. Based on these formulations, we develop the proposed GT-HSGD algorithm. + +# 2.1. Optimization and Network Model + +We work with a rich enough probability space $\{\Omega, \mathbb{P}, \mathcal{F}\}$ . We consider decentralized recursive algorithms of interest that generate a sequence of estimates $\{\mathbf{x}_t^i\}_{t \geq 0}$ of the first-order stationary points of $F$ at each node $i$ , where $\mathbf{x}_0^i$ is assumed constant. At each iteration $t$ , each node $i$ observes a random vector $\pmb{\xi}_t^i$ in $\mathbb{R}^q$ , which, for instance, may be considered as noise or as an online data sample. We then introduce the natural filtration (an increasing family of sub + +$\sigma$ -algebras of $\mathcal{F}$ ) induced by these random vectors observed sequentially by the networked nodes: + +$$ +\mathcal {F} _ {0} := \{\Omega , \phi \}, +$$ + +$$ +\mathcal {F} _ {t} := \sigma \left(\left\{\boldsymbol {\xi} _ {0} ^ {i}, \boldsymbol {\xi} _ {1} ^ {i}, \dots , \boldsymbol {\xi} _ {t - 1} ^ {i}: i \in \mathcal {V} \right\}\right), \quad \forall t \geq 1, \tag {1} +$$ + +where $\phi$ is the empty set. We are now ready to define the SFO mechanism in the following. At each iteration $t$ , each node $i$ , given an input random vector $\mathbf{x} \in \mathbb{R}^p$ that is $\mathcal{F}_t$ -measurable, is able to query the local SFO to obtain a stochastic gradient of the form $\mathbf{g}_i(\mathbf{x}, \boldsymbol{\xi}_t^i)$ , where $\mathbf{g}_i: \mathbb{R}^p \times \mathbb{R}^q \to \mathbb{R}^p$ is a Borel measurable function. We assume that the SFO satisfies the following four properties. + +Assumption 1 (Oracle). For any $\mathcal{F}_t$ -measurable random vectors $\mathbf{x}, \mathbf{y} \in \mathbb{R}^p$ , we have the following: $\forall i \in \mathcal{V}, \forall t \geq 0$ + +$\mathbb{E}\left[\mathbf{g}_i(\mathbf{x},\pmb {\xi}_t^i)|\mathcal{F}_t\right] = \nabla f_i(\mathbf{x});$ +$\mathbb{E}\left[\| \mathbf{g}_i(\mathbf{x},\pmb {\xi}_t^i) - \nabla f_i(\mathbf{x})\| ^2\right]\leq \nu_i^2,\overline{\nu}^2 := \frac{1}{n}\sum_{i = 1}^{n}\nu_i^2;$ +- the family $\{\pmb{\xi}_t^i : \forall t \geq 0, i \in \mathcal{V}\}$ of random vectors is independent; +$\mathbb{E}\left[\| \mathbf{g}_i(\mathbf{x},\pmb {\xi}_t^i) - \mathbf{g}_i(\mathbf{y},\pmb {\xi}_t^i)\| ^2\right]\leq L^2\mathbb{E}\left[\| \mathbf{x} - \mathbf{y}\| ^2\right].$ + +The first three properties above are standard and commonly used to establish the convergence of decentralized stochastic gradient methods. They however do not explicitly impose any structures on the stochastic gradient mapping $\mathbf{g}_i$ other + +than the measurability. On the other hand, the last property, the mean-squared smoothness, roughly speaking, requires that $\mathbf{g}_i$ is $L$ -smooth on average with respect to the input arguments $\mathbf{x}$ and $\mathbf{y}$ . As a simple example, Assumption 1 holds if $f_i(\mathbf{x}) = \frac{1}{2}\mathbf{x}^\top \mathbf{Q}_i\mathbf{x}$ and $\mathbf{g}_i(\mathbf{x},\boldsymbol {\xi}_i) = \mathbf{Q}_i\mathbf{x} + \boldsymbol {\xi}_i$ , where $\mathbf{Q}_i$ is a constant matrix and $\boldsymbol{\xi}_i$ has zero mean and finite second moment. We further note that the mean-squared smoothness of each $\mathbf{g}_i$ implies, by Jensen's inequality, that each $f_i$ is $L$ -smooth, i.e., $\| \nabla f_i(\mathbf{x}) - \nabla f_i(\mathbf{y})\| \leq L\| \mathbf{x} - \mathbf{y}\|$ , and consequently the global function $F$ is also $L$ -smooth. + +In addition, we make the following assumptions on $F$ and the communication network $\mathcal{G}$ . + +Assumption 2 (Global Function). $F$ is bounded below, i.e., $F^{*} \coloneqq \inf_{\mathbf{x} \in \mathbb{R}^{p}} F(\mathbf{x}) > -\infty$ . + +Assumption 3 (Communication Network). The directed network $\mathcal{G}$ admits a primitive and doubly-stochastic weight matrix $\underline{\mathbf{W}} = \{\underline{w}_{ij}\} \in \mathbb{R}^{n\times n}$ . Hence, $\underline{\mathbf{W}}\mathbf{1}_n = \underline{\mathbf{W}}^\top \mathbf{1}_n = \mathbf{1}_n$ and $\lambda := \|\underline{\mathbf{W}} - \frac{1}{n}\mathbf{1}_n\mathbf{1}_n^\top\| \in [0,1)$ . + +The weight matrix $\underline{\mathbf{W}}$ that satisfies Assumption 3 may be designed for strongly-connected weight-balanced directed graphs (and thus for arbitrary connected undirected graphs). For example, the family of directed exponential graphs is weight-balanced and plays a key role in decentralized training (Assran et al., 2019). We note that $\lambda$ is known as the second largest singular value of $\underline{\mathbf{W}}$ and measures the algebraic connectivity of the graph, i.e., a smaller value of $\lambda$ roughly means a better connectivity. We note that several existing approaches require strictly stronger assumptions on $\underline{\mathbf{W}}$ . For instance, D2 (Tang et al., 2018) and D-PD-SGD (Yi et al., 2020) require $\underline{\mathbf{W}}$ to be symmetric and hence are restricted to undirected networks. + +# 2.2. Algorithm Development and Description + +We now describe the proposed GT-HSGD algorithm and provide an intuitive construction. Recall that $\mathbf{x}_t^i$ is the estimate of an stationary point of the global cost $F$ at node $i$ and iteration $t$ . Let $\mathbf{g}_i(\mathbf{x}_t^i,\pmb {\xi}_t^i)$ and $\mathbf{g}_i(\mathbf{x}_{t - 1}^i,\pmb {\xi}_t^i)$ be the corresponding stochastic gradients returned by the local SFO queried at $\mathbf{x}_t^i$ and $\mathbf{x}_{t - 1}^i$ respectively. Motivated by the strong performance of recently introduced decentralized methods that combine gradient tracking and various variance reduction schemes for finite-sum problems (Xin et al., 2020b;c; Li et al., 2020a; Sun et al., 2020), we seek similar variance reduction for decentralized online problems with SFO. In particular, we focus on the following local hybrid variance reduced stochastic gradient estimator $\mathbf{v}_t^i$ introduced in (Liu et al., 2020; Tran-Dinh et al., 2020; Cutkosky & Orabona, 2019) for centralized online problems: $\forall t\geq 1$ + +$$ +\mathbf {v} _ {t} ^ {i} = \mathbf {g} _ {i} (\mathbf {x} _ {t} ^ {i}, \pmb {\xi} _ {t} ^ {i}) + (1 - \beta) \big (\mathbf {v} _ {t - 1} ^ {i} - \mathbf {g} _ {i} (\mathbf {x} _ {t - 1} ^ {i}, \pmb {\xi} _ {t} ^ {i}) \big), \quad (2) +$$ + +for some applicable weight parameter $\beta \in [0,1]$ . This local gradient estimator $\mathbf{v}_t^i$ is fused, via a gradient tracking + +mechanism (Di Lorenzo & Scutari, 2016; Xu et al., 2015), over the network to update the global gradient tracker $\mathbf{y}_t^i$ , which is subsequently used as the descent direction in the $\mathbf{x}_t^i$ -update. The complete description of GT-HSGD is provided in Algorithm 1. We note that the update (2) of $\mathbf{v}_t^i$ may be equivalently written as + +$$ +\begin{array}{l} \mathbf {v} _ {t} ^ {i} = \boldsymbol {\beta} \cdot \underbrace {\mathbf {g} _ {i} \left(\mathbf {x} _ {t} ^ {i} , \boldsymbol {\xi} _ {t} ^ {i}\right)} \\ \text {S t o c h a s t i c g r a d i e n t} \\ + (1 - \beta) \cdot \underbrace {\left(\mathbf {g} _ {i} \left(\mathbf {x} _ {t} ^ {i} , \boldsymbol {\xi} _ {t} ^ {i}\right) - \mathbf {g} _ {i} \left(\mathbf {x} _ {t - 1} ^ {i} , \boldsymbol {\xi} _ {t} ^ {i}\right) + \mathbf {v} _ {t - 1} ^ {i}\right)} _ {\text {S A R A H}}, \\ \end{array} +$$ + +which is a convex combination of the local vanilla stochastic gradient returned by the SFO and a SARAH-type (Nguyen et al., 2017; Fang et al., 2018; Wang et al., 2019) gradient estimator. This discussion leads to the fact that GT-HSGD reduces to GT-DSGD (Pu & Nedich, 2020; Xin et al., 2020e; Lu et al., 2019) when $\beta = 1$ , and becomes the inner loop of GT-SARAH (Xin et al., 2020b) when $\beta = 0$ . However, our convergence analysis shows that GT-HSGD achieves its best oracle complexity and outperforms the existing decentralized online variance-reduced approaches (Sun et al., 2020; Pan et al., 2020) with a weight parameter $\beta \in (0,1)$ . It is then clear that neither GT-DSGD nor the inner loop of GT-SARAH, on their own, are able to outperform the proposed approach, making GT-HSGD a non-trivial algorithmic design for this problem class. + +Algorithm 1 GT-HSGD at each node $i$ + +Require: $\mathbf{x}_0^i = \overline{\mathbf{x}}_0$ ; $\alpha$ ; $\beta$ ; $b_0$ ; $\mathbf{y}_0^i = \mathbf{0}_p$ ; $\mathbf{v}_{-1}^i = \mathbf{0}_p$ ; $T$ . + +1: Sample $\{\pmb{\xi}_{0,r}^{i}\}_{r = 1}^{b_{0}}$ and $\mathbf{v}_0^i = \frac{1}{b_0}\sum_{r = 1}^{b_0}\mathbf{g}_i(\mathbf{x}_0^i,\pmb{\xi}_{0,r}^i)$ +2: $\mathbf{y}_1^i = \sum_{j=1}^{n} \underline{w}_{ij} \left( \mathbf{y}_0^j + \mathbf{v}_0^j - \mathbf{v}_{-1}^j \right)$ ; +3: $\mathbf{x}_1^i = \sum_{j=1}^{n} \underline{w}_{ij} \left( \mathbf{x}_0^j - \alpha \mathbf{y}_1^j \right)$ ; +4: for $t = 1,2,\dots ,T - 1$ do +5: Sample $\pmb{\xi}_t^i$ ; +6: $\mathbf{v}_t^i = \mathbf{g}_i(\mathbf{x}_t^i,\pmb {\xi}_t^i) + (1 - \beta)\bigl (\mathbf{v}_{t - 1}^i -\mathbf{g}_i(\mathbf{x}_{t - 1}^i,\pmb {\xi}_t^i)\bigr).$ +7: $\mathbf{y}_{t + 1}^{i} = \sum_{j = 1}^{n}\underline{w}_{ij}\bigl (\mathbf{y}_{t}^{j} + \mathbf{v}_{t}^{j} - \mathbf{v}_{t - 1}^{j}\bigr);$ +8: $\mathbf{x}_{t + 1}^{i} = \sum_{j = 1}^{n}\underline{w}_{ij}\bigl (\mathbf{x}_{t}^{j} - \alpha \mathbf{y}_{t + 1}^{j}\bigr);$ +9: end for + +output $\widetilde{\mathbf{x}}_T$ selected uniformly at random from $\{\mathbf{x}_t^i\}_{0\leq t\leq T}^{i\in \mathcal{V}}$ + +Remark 1. Clearly, each $\mathbf{v}_t^i$ is a conditionally biased estimator of $\nabla f_i(\mathbf{x}_t^i)$ , i.e., $\mathbb{E}[\mathbf{v}_t^i|\mathcal{F}_t]\neq \nabla f_i(\mathbf{x}_t^i)$ in general. However, it can be shown that $\mathbb{E}[\mathbf{v}_t^i] = \mathbb{E}[\nabla f_i(\mathbf{x}_t^i)]$ , meaning that $\mathbf{v}_t^i$ serves as a surrogate for the underlying exact gradient in the sense of total expectation. + +# 3. Main Results + +In this section, we present the main convergence results of GT-HSGD in this paper and discuss their salient features. + +The formal convergence analysis is deferred to Section 4. + +Theorem 1. If the weight parameter $\beta = \frac{48L^2\alpha^2}{n}$ and the step-size $\alpha$ is chosen as + +$$ +0 < \alpha < \min \left\{\frac {(1 - \lambda^ {2}) ^ {2}}{9 0 \lambda^ {2}}, \frac {\sqrt {n (1 - \lambda)}}{2 6 \lambda}, \frac {1}{4 \sqrt {3}} \right\} \frac {1}{L}, +$$ + +then the output $\widetilde{\mathbf{x}}_T$ of $GT$ -HSGD satisfies: $\forall T \geq 2$ , + +$$ +\begin{array}{l} \mathbb {E} \big [ \| \nabla F (\widetilde {\mathbf {x}} _ {T}) \| ^ {2} \big ] \leq \frac {4 (F (\overline {{\mathbf {x}}} _ {0}) - F ^ {*})}{\alpha T} + \frac {8 \beta \overline {{\nu}} ^ {2}}{n} + \frac {4 \overline {{\nu}} ^ {2}}{\beta b _ {0} n T} \\ + \frac {6 4 \lambda^ {4} \| \nabla \mathbf {f} (\mathbf {x} _ {0}) \| ^ {2}}{(1 - \lambda^ {2}) ^ {3} n T} + \frac {9 6 \lambda^ {2} \overline {{\nu}} ^ {2}}{(1 - \lambda^ {2}) ^ {3} b _ {0} T} + \frac {2 5 6 \lambda^ {2} \beta^ {2} \overline {{\nu}} ^ {2}}{(1 - \lambda^ {2}) ^ {3}}, \\ \end{array} +$$ + +where $\| \nabla \mathbf{f}(\mathbf{x}_0)\|^2 = \sum_{i=1}^n \| \nabla f_i(\overline{\mathbf{x}}_0)\|^2$ + +Remark 2. Theorem 1 holds for $GT-HSGD$ with arbitrary initial minibatch size $b_0 \geq 1$ . + +Theorem 1 establishes a non-asymptotic bound, with no hidden constants, on the mean-squared stationary gap of GT-HSGD over any finite time horizon $T$ . + +Transient and steady-state performance over infinite time horizon. If $\alpha$ and $\beta$ are chosen according to Theorem 1, the mean-squared stationary gap $\mathbb{E}\left[||\nabla F(\widetilde{\mathbf{x}}_T)||^2\right]$ of GT-HSGD decays sublinearly at a rate of $O(1 / T)$ up to a steady-state error (SSE) such that + +$$ +\operatorname * {l i m s u p} _ {T \rightarrow \infty} \mathbb {E} \left[ \| \nabla F (\widetilde {\mathbf {x}} _ {T}) \| ^ {2} \right] \leq \frac {8 \beta \bar {\nu} ^ {2}}{n} + \frac {2 5 6 \lambda^ {2} \beta^ {2} \bar {\nu} ^ {2}}{\left(1 - \lambda^ {2}\right) ^ {3}}. \tag {3} +$$ + +In view of (3), the SSE of GT-HSGD is bounded by the sum of two terms: (i) the first term is in the order of $O(\beta)$ and the division by $n$ demonstrates the benefit of increasing the network size $^2$ ; (ii) the second term is in the order of $O(\beta^2)$ and reveals the impact of the spectral gap $(1 - \lambda)$ of the network topology. Clearly, the SSE can be made arbitrarily small by choosing small enough $\beta$ and $\alpha$ . Moreover, since the spectral gap $(1 - \lambda)$ only appears in a higher order term of $\beta$ in (3), its impact reduces as $\beta$ becomes smaller, i.e., as we require a smaller SSE. + +The following corollary is concerned with the finite-time convergence rate of GT-HSGD with specific choices of the algorithmic parameters $\alpha, \beta$ , and $b_0$ . + +Corollary 1. Setting $\alpha = \frac{n^{2/3}}{8LT^{1/3}}$ , $\beta = \frac{3n^{1/3}}{4T^{2/3}}$ , and $b_0 = \left\lceil \frac{T^{1/3}}{n^{2/3}} \right\rceil$ in Theorem 1, we have: + +$$ +\begin{array}{l} \mathbb {E} \left[ \| \nabla F (\widetilde {\mathbf {x}} _ {T}) \| ^ {2} \right] \leq \frac {3 2 L (F (\overline {{\mathbf {x}}} _ {0}) - F ^ {*}) + 1 2 \overline {{\nu}} ^ {2}}{(n T) ^ {2 / 3}} \\ + \frac {6 4 \lambda^ {4} \| \nabla \mathbf {f} (\mathbf {x} _ {0}) \| ^ {2}}{(1 - \lambda^ {2}) ^ {3} n T} + \frac {2 4 0 \lambda^ {2} n ^ {2 / 3} \overline {{\nu}} ^ {2}}{(1 - \lambda^ {2}) ^ {3} T ^ {4 / 3}}, \\ \end{array} +$$ + +for all $T > \max \left\{\frac{1424\lambda^6n^2}{(1 - \lambda^2)^6},\frac{35\lambda^3n^{0.5}}{(1 - \lambda)^{1.5}}\right\}$ . As a consequence, $GT-HSGD$ achieves an $\epsilon$ -accurate stationary point $\mathbf{x}^*$ of the global cost $F$ such that $\mathbb{E}[\|\nabla F(\mathbf{x}^*)\|] \leq \epsilon$ with + +$$ +\mathcal {H} = O \left(\max \left\{\mathcal {H} _ {\text {o p t}}, \mathcal {H} _ {\text {n e t}} \right\}\right) +$$ + +iterations $^3$ , where $\mathcal{H}_{opt}$ and $\mathcal{H}_{net}$ are given respectively by + +$$ +\begin{array}{l} \mathcal {H} _ {o p t} = \frac {(L (F (\overline {{\mathbf {x}}} _ {0}) - F ^ {*}) + \overline {{\nu}} ^ {2}) ^ {1 . 5}}{n \epsilon^ {3}}, \\ \mathcal {H} _ {n e t} = \max \left\{\frac {\lambda^ {4} \| \nabla \mathbf {f} (\mathbf {x} _ {0}) \| ^ {2}}{(1 - \lambda^ {2}) ^ {3} n \epsilon^ {2}}, \frac {\lambda^ {1 . 5} n ^ {0 . 5} \overline {{\nu}} ^ {1 . 5}}{(1 - \lambda^ {2}) ^ {2 . 2 5} \epsilon^ {1 . 5}} \right\}. \\ \end{array} +$$ + +The resulting total number of oracle queries at each node is thus $\lceil \mathcal{H} + \mathcal{H}^{1 / 3}n^{-2 / 3}\rceil$ + +Remark 3. Since $\mathcal{H}^{1/3}n^{-2/3}$ is much smaller than $\mathcal{H}$ , we treat the oracle complexity of $GT-HSGD$ as $\mathcal{H}$ for the ease of exposition in Table 1 and the following discussion. + +An important implication of Corollary 1 is given in the following. + +A regime for network topology-independent oracle complexity and linear speedup. According to Corollary 1, the oracle complexity of GT-HSGD at each node is bounded by the maximum of two terms: (i) the first term $\mathcal{H}_{opt}$ is independent of the network topology and, more importantly, is $n$ times smaller than the oracle complexity of the optimal centralized online variance-reduced methods that execute on a single node for this problem class (Fang et al., 2018; Wang et al., 2019; Pham et al., 2020; Tran-Dinh et al., 2020; Liu et al., 2020); (ii) the second term $\mathcal{H}_{net}$ depends on the network spectral gap $1 - \lambda$ and is in the lower order of $1 / \epsilon$ . These two observations lead to the interesting fact that the oracle complexity of GT-HSGD becomes independent of the network topology, i.e., $\mathcal{H}_{opt}$ dominates $\mathcal{H}_{net}$ , if the required error tolerance $\epsilon$ is small enough such that $4\epsilon \lesssim \min \left\{\lambda^{-4}(1 - \lambda)^3 n^{-1}, \lambda^{-1}(1 - \lambda)^{1.5} n^{-1}\right\}$ . In this regime, GT-HSGD thus achieves a network topology-independent oracle complexity $\mathcal{H}_{opt} = O(n^{-1}\epsilon^{-3})$ , exhibiting a linear speed up compared with the aforementioned centralized optimal algorithms (Fang et al., 2018; Wang et al., 2019; Pham et al., 2020; Tran-Dinh et al., 2020; Liu et al., 2020; Zhou et al., 2020), in the sense that the total number of oracle queries required to achieve an $\epsilon$ -accurate stationary point at each node is reduced by a factor of $1 / n$ . + +Remark 4. The small error tolerance regime in the above discussion corresponds to a large number of oracle queries, which translates to the scenario where the required total number of iterations $T$ is large. Note that a large $T$ further implies that the step-size $\alpha$ and the weight parameter $\beta$ are small; see the expression of $\alpha$ and $\beta$ in Corollary 1. + +# 4. Outline of the Convergence Analysis + +In this section, we outlines the proof of Theorem 1, while the detailed proofs are provided in the Appendix. We let Assumptions 1-3 hold throughout the rest of the paper without explicitly stating them. For the ease of exposition, we write the $\mathbf{x}_{t^{-}}$ and $\mathbf{y}_t$ -update of GT-HSGD in the following equivalent matrix form: $\forall t\geq 0$ + +$$ +\mathbf {y} _ {t + 1} = \mathbf {W} \left(\mathbf {y} _ {t} + \mathbf {v} _ {t} - \mathbf {v} _ {t - 1}\right), \tag {4a} +$$ + +$$ +\mathbf {x} _ {t + 1} = \mathbf {W} \left(\mathbf {x} _ {t} - \alpha \mathbf {y} _ {t + 1}\right), \tag {4b} +$$ + +where $\mathbf{W} := \underline{\mathbf{W}} \otimes \mathbf{I}_p$ and $\mathbf{x}_t, \mathbf{y}_t, \mathbf{v}_t$ are square-integrable random vectors in $\mathbb{R}^{np}$ that respectively concatenate the local estimates $\{\mathbf{x}_t^i\}_{i=1}^n$ of a stationary point of $F$ , gradient trackers $\{\mathbf{y}_t^i\}_{i=1}^n$ , stochastic gradient estimators $\{\mathbf{v}_t^i\}_{i=1}^n$ . It is straightforward to verify that $\mathbf{x}_t$ and $\mathbf{y}_t$ are $\mathcal{F}_t$ -measurable while $\mathbf{v}_t$ is $\mathcal{F}_{t+1}$ -measurable for all $t \geq 0$ . For convenience, we also denote + +$$ +\nabla \mathbf {f} (\mathbf {x} _ {t}) := \left[ \nabla f _ {1} \left(\mathbf {x} _ {t} ^ {1}\right) ^ {\top}, \dots , \nabla f _ {n} \left(\mathbf {x} _ {t} ^ {n}\right) ^ {\top} \right] ^ {\top} +$$ + +and introduce the following quantities: + +$$ +\mathbf {J} := \left(\frac {1}{n} \mathbf {1} _ {n} \mathbf {1} _ {n} ^ {\top}\right) \otimes \mathbf {I} _ {p} +$$ + +$$ +\overline {{\mathbf {x}}} _ {t} := \frac {1}{n} (\mathbf {1} _ {n} ^ {\top} \otimes \mathbf {I} _ {p}) \mathbf {x} _ {t}, \quad \overline {{\mathbf {y}}} _ {t} := \frac {1}{n} (\mathbf {1} _ {n} ^ {\top} \otimes \mathbf {I} _ {p}) \mathbf {y} _ {t}, +$$ + +$$ +\overline {{\mathbf {v}}} _ {t} := \frac {1}{n} (\mathbf {1} _ {n} ^ {\top} \otimes \mathbf {I} _ {p}) \mathbf {v} _ {t}, \quad \overline {{\nabla \mathbf {f}}} (\mathbf {x} _ {t}) := \frac {1}{n} (\mathbf {1} _ {n} ^ {\top} \otimes \mathbf {I} _ {p}) \nabla \mathbf {f} (\mathbf {x} _ {t}). +$$ + +In the following lemma, we enlist several well-known results in the context of gradient tracking-based algorithms for decentralized stochastic optimization, whose proofs may be found in (Di Lorenzo & Scutari, 2016; Qu & Li, 2017; Xin et al., 2020d; Pu & Nedich, 2020). + +Lemma 1. The following relationships hold. + +(a) $\| \mathbf{W}\mathbf{x} - \mathbf{J}\mathbf{x}\| \leq \lambda \| \mathbf{x} - \mathbf{J}\mathbf{x}\|$ ,VxE np. +(b) $\overline{\mathbf{y}}_{t + 1} = \overline{\mathbf{v}}_t,\forall t\geq 0.$ +(c) $\left\| \overline{\nabla}\mathbf{f}(\mathbf{x}_t) - \nabla F(\overline{\mathbf{x}}_t)\right\|^2 \leq \frac{L^2}{n}\left\| \mathbf{x}_t - \mathbf{J}\mathbf{x}_t\right\|^2, \forall t \geq 0.$ + +We note that Lemma 1(a) holds since $\underline{\mathbf{W}}$ is primitive and doubly-stochastic, Lemma 1(b) is a direct consequence of the gradient tracking update (4a) and Lemma 1(c) is due to the $L$ -smoothness of each $f_{i}$ . By the estimate update of GT-HSGD described in (4b) and Lemma 1(b), it is straightforward to obtain: + +$$ +\overline {{\mathbf {x}}} _ {t + 1} = \overline {{\mathbf {x}}} _ {t} - \alpha \overline {{\mathbf {y}}} _ {t + 1} = \overline {{\mathbf {x}}} _ {t} - \alpha \overline {{\mathbf {v}}} _ {t}, \quad \forall t \geq 0. \tag {5} +$$ + +Hence, the mean state $\overline{\mathbf{x}}_t$ proceeds in the direction of the average of local stochastic gradient estimators $\overline{\mathbf{v}}_t$ . With the help of (5) and the $L$ -smoothness of $F$ and each $f_i$ , we establish the following descent inequality which sheds light on the overall convergence analysis. + +Lemma 2. If $0 < \alpha \leq \frac{1}{2L}$ , then we have: $\forall T \geq 0$ , + +$$ +\begin{array}{l} \sum_ {t = 0} ^ {T} \left\| \nabla F (\overline {{\mathbf {x}}} _ {t}) \right\| ^ {2} \leq \frac {2 (F (\overline {{\mathbf {x}}} _ {0}) - F ^ {*})}{\alpha} - \frac {1}{2} \sum_ {t = 0} ^ {T} \| \overline {{\mathbf {v}}} _ {t} \| ^ {2} \\ + 2 \sum_ {t = 0} ^ {T} \left| \left| \overline {{\mathbf {v}}} _ {t} - \overline {{\nabla \mathbf {f}}} (\mathbf {x} _ {t}) \right| \right| ^ {2} + \frac {2 L ^ {2}}{n} \sum_ {t = 0} ^ {T} \left\| \mathbf {x} _ {t} - \mathbf {J} \mathbf {x} _ {t} \right\| ^ {2}. \\ \end{array} +$$ + +In light of Lemma 2, our approach to establishing the convergence of GT-HSGD is to seek the conditions on the algorithmic parameters of GT-HSGD, i.e., the step-size $\alpha$ and the weight parameter $\beta$ , such that + +$$ +\begin{array}{l} - \frac {1}{2 T} \sum_ {t = 0} ^ {T} \mathbb {E} \left[ \| \overline {{\mathbf {v}}} _ {t} \| ^ {2} \right] + \frac {2}{T} \sum_ {t = 0} ^ {T} \mathbb {E} \left[ \| \overline {{\mathbf {v}}} _ {t} - \overline {{\nabla \mathbf {f}}} (\mathbf {x} _ {t}) \| ^ {2} \right] \\ + \frac {2 L ^ {2}}{n T} \sum_ {t = 0} ^ {T} \mathbb {E} \left[ \| \mathbf {x} _ {t} - \mathbf {J} \mathbf {x} _ {t} \| ^ {2} \right] = O \left(\alpha , \beta , \frac {1}{b _ {0}}, \frac {1}{T}\right), \tag {6} \\ \end{array} +$$ + +where $O(\alpha, \beta, 1/b_0, 1/T)$ represents a nonnegative quantity which may be made arbitrarily small by choosing small enough $\alpha$ and $\beta$ along with large enough $T$ and $b_0$ . If (6) holds, then Lemma 2 reduces to + +$$ +\begin{array}{l} \frac {1}{T + 1} \sum_ {t = 0} ^ {T} \mathbb {E} \left[ \| \nabla F (\overline {{\mathbf {x}}} _ {t}) \| ^ {2} \right] \\ \leq \frac {2 (F (\overline {{\mathbf {x}}} _ {0}) - F ^ {*})}{\alpha T} + O \left(\alpha , \beta , \frac {1}{b _ {0}}, \frac {1}{T}\right), \\ \end{array} +$$ + +which leads to the convergence arguments of GT-HSGD. For these purposes, we quantify $\sum_{t=0}^{T} \mathbb{E}\left[\|\overline{\mathbf{v}}_t - \overline{\nabla\mathbf{f}}(\mathbf{x}_t)\|^2\right]$ and $\sum_{t=0}^{T} \mathbb{E}\left[\|\mathbf{x}_t - \mathbf{J}\mathbf{x}_t\|^2\right]$ next. + +# 4.1. Contraction Relationships + +First of all, we establish upper bounds on the gradient variances $\mathbb{E}\left[\|\overline{\mathbf{v}}_t - \overline{\nabla\mathbf{f}}(\mathbf{x}_t)\|^2\right]$ and $\mathbb{E}\left[\|\mathbf{v}_t - \nabla \mathbf{f}(\mathbf{x}_t)\|^2\right]$ by exploiting the hybrid and recursive update of $\mathbf{v}_t$ . + +Lemma 3. The following inequalities hold: $\forall t\geq 1$ + +$$ +\begin{array}{l} \mathbb {E} \left[ \left\| \overline {{\mathbf {v}}} _ {t} - \overline {{\nabla \mathbf {f}}} (\mathbf {x} _ {t}) \right\| ^ {2} \right] \\ \leq (1 - \beta) ^ {2} \mathbb {E} \left[ \| \overline {{\mathbf {v}}} _ {t - 1} - \overline {{\nabla \mathbf {f}}} (\mathbf {x} _ {t - 1}) \| ^ {2} \right] \\ + \frac {6 L ^ {2} \alpha^ {2}}{n} (1 - \beta) ^ {2} \mathbb {E} \left[ \| \overline {{\mathbf {v}}} _ {t - 1} \| ^ {2} \right] + \frac {2 \beta^ {2} \overline {{\nu}} ^ {2}}{n} \\ + \frac {6 L ^ {2}}{n ^ {2}} (1 - \beta) ^ {2} \mathbb {E} \left[ \| \mathbf {x} _ {t} - \mathbf {J} \mathbf {x} _ {t} \| ^ {2} + \| \mathbf {x} _ {t - 1} - \mathbf {J} \mathbf {x} _ {t - 1} \| ^ {2} \right], \tag {7} \\ \end{array} +$$ + +and, $\forall t\geq 1$ + +$$ +\begin{array}{l} \mathbb {E} \left[ \left\| \mathbf {v} _ {t} - \nabla \mathbf {f} (\mathbf {x} _ {t}) \right\| ^ {2} \right] \\ \leq (1 - \beta) ^ {2} \mathbb {E} \left[ \| \mathbf {v} _ {t - 1} - \nabla \mathbf {f} (\mathbf {x} _ {t - 1}) \| ^ {2} \right] \\ + 6 n L ^ {2} \alpha^ {2} (1 - \beta) ^ {2} \mathbb {E} \left[ \| \overline {{\mathbf {v}}} _ {t - 1} \| ^ {2} \right] + 2 n \beta^ {2} \overline {{\nu}} ^ {2} \\ + 6 L ^ {2} (1 - \beta) ^ {2} \mathbb {E} \left[ \| \mathbf {x} _ {t} - \mathbf {J} \mathbf {x} _ {t} \| ^ {2} + \| \mathbf {x} _ {t - 1} - \mathbf {J} \mathbf {x} _ {t - 1} \| ^ {2} \right]. \tag {8} \\ \end{array} +$$ + +Remark 5. Since $\mathbf{v}_t$ is a conditionally biased estimator of $\nabla \mathbf{f}(\mathbf{x}_t)$ , (7) and (8) do not directly imply each other and need to be established separately. + +We emphasize that the contraction structure of the gradient variances shown in Lemma 3 plays a crucial role in the convergence analysis. The following contraction bounds on the consensus errors $\mathbb{E}\left[\| \mathbf{x}_t - \mathbf{J}\mathbf{x}_t\|^2\right]$ are standard in decentralized algorithms based on gradient tracking, e.g., (Pu & Nedich, 2020; Xin et al., 2020b); in particular, it follows directly from the $\mathbf{x}_t$ -update (4b) and Young's inequality. + +Lemma 4. The following inequalities hold: $\forall t\geq 0$ + +$$ +\begin{array}{l} \left\| \mathbf {x} _ {t + 1} - \mathbf {J} \mathbf {x} _ {t + 1} \right\| ^ {2} \leq \frac {1 + \lambda^ {2}}{2} \left\| \mathbf {x} _ {t} - \mathbf {J} \mathbf {x} _ {t} \right\| ^ {2} \\ + \frac {2 \alpha^ {2} \lambda^ {2}}{1 - \lambda^ {2}} \left\| \mathbf {y} _ {t + 1} - \mathbf {J} \mathbf {y} _ {t + 1} \right\| ^ {2}. \tag {9} \\ \end{array} +$$ + +$$ +\begin{array}{l} \left\| \mathbf {x} _ {t + 1} - \mathbf {J} \mathbf {x} _ {t + 1} \right\| ^ {2} \leq 2 \lambda^ {2} \left\| \mathbf {x} _ {t} - \mathbf {J} \mathbf {x} _ {t} \right\| ^ {2} \\ + 2 \alpha^ {2} \lambda^ {2} \left\| \mathbf {y} _ {t + 1} - \mathbf {J} \mathbf {y} _ {t + 1} \right\| ^ {2}. \tag {10} \\ \end{array} +$$ + +It is then clear from Lemma 4 that we need to further quantify the gradient tracking errors $\mathbb{E}\left[\| \mathbf{y}_t - \mathbf{J}\mathbf{y}_t\|^2\right]$ in order to bound the consensus errors. These error bounds are shown in the following lemma. + +Lemma 5. We have the following. + +(a) $\mathbb{E}\left[\| \mathbf{y}_1 - \mathbf{J}\mathbf{y}_1\|^2\right] \leq \lambda^2\left\|\nabla \mathbf{f}(\mathbf{x}_0)\right\|^2 + \lambda^2 n\nu^2 / b_0.$ +(b) If $0 < \alpha \leq \frac{1 - \lambda^2}{2\sqrt{42}\lambda^2L}$ , then $\forall t \geq 1$ , + +$$ +\begin{array}{l} \mathbb {E} \left[ \left\| \mathbf {y} _ {t + 1} - \mathbf {J} \mathbf {y} _ {t + 1} \right\| ^ {2} \right] \\ \leq \frac {3 + \lambda^ {2}}{4} \mathbb {E} \left[ \| \mathbf {y} _ {t} - \mathbf {J} \mathbf {y} _ {t} \| ^ {2} \right] + \frac {2 1 \lambda^ {2} n L ^ {2} \alpha^ {2}}{1 - \lambda^ {2}} \mathbb {E} [ \| \overline {{\mathbf {v}}} _ {t - 1} \| ^ {2} ] \\ + \frac {6 3 \lambda^ {2} L ^ {2}}{1 - \lambda^ {2}} \mathbb {E} \left[ \| \mathbf {x} _ {t - 1} - \mathbf {J} \mathbf {x} _ {t - 1} \| ^ {2} \right] \\ + \frac {7 \lambda^ {2} \beta^ {2}}{1 - \lambda^ {2}} \mathbb {E} \left[ \| \mathbf {v} _ {t - 1} - \nabla \mathbf {f} (\mathbf {x} _ {t - 1}) \| ^ {2} \right] + 3 \lambda^ {2} n \beta^ {2} \bar {\nu} ^ {2}. \\ \end{array} +$$ + +We note that establishing the contraction argument of gradient tracking errors in Lemma 5 requires a careful examination of the structure of the $\mathbf{v}_t$ -update. + +# 4.2. Error Accumulations + +To proceed, we observe, from Lemma 3, 4, and 5, that the recursions of the gradient variances, consensus, and gradient tracking errors admit similar forms. Therefore, we abstract out formulas for the accumulation of the error recursions of this type in the following lemma. + +Lemma 6. Let $\{V_t\}_{t \geq 0}$ , $\{R_t\}_{t \geq 0}$ and $\{Q_t\}_{t \geq 0}$ be nonnegative sequences and $C \geq 0$ be some constant such + +that $V_{t} \leq qV_{t - 1} + qR_{t - 1} + Q_{t} + C, \forall t \geq 1$ , where $q \in (0,1)$ . Then the following inequality holds: $\forall T \geq 1$ + +$$ +\sum_ {t = 0} ^ {T} V _ {t} \leq \frac {V _ {0}}{1 - q} + \frac {1}{1 - q} \sum_ {t = 0} ^ {T - 1} R _ {t} + \frac {1}{1 - q} \sum_ {t = 1} ^ {T} Q _ {t} + \frac {C T}{1 - q}. \tag {11} +$$ + +Similarly, if $V_{t + 1} \leq qV_t + R_{t - 1} + C, \forall t \geq 1$ , then we have: $\forall T \geq 2$ + +$$ +\sum_ {t = 1} ^ {T} V _ {t} \leq \frac {V _ {1}}{1 - q} + \frac {1}{1 - q} \sum_ {t = 0} ^ {T - 2} R _ {t} + \frac {C T}{1 - q}. \tag {12} +$$ + +Applying Lemma 6 to Lemma 3 leads to the following upper bounds on the accumulated variances. + +Lemma 7. For any $\beta \in (0,1)$ , the following inequalities hold: $\forall T\geq 1$ + +$$ +\begin{array}{l} \sum_ {t = 0} ^ {T} \mathbb {E} \left[ \| \overline {{\mathbf {v}}} _ {t} - \overline {{\nabla \mathbf {f}}} (\mathbf {x} _ {t}) \| ^ {2} \right] \\ \leq \frac {\overline {{\nu}} ^ {2}}{\beta b _ {0} n} + \frac {6 L ^ {2} \alpha^ {2}}{n \beta} \sum_ {t = 0} ^ {T - 1} \mathbb {E} \left[ \| \overline {{\mathbf {v}}} _ {t} \| ^ {2} \right] \\ + \frac {1 2 L ^ {2}}{n ^ {2} \beta} \sum_ {t = 0} ^ {T} \mathbb {E} \left[ \left\| \mathbf {x} _ {t} - \mathbf {J} \mathbf {x} _ {t} \right\| ^ {2} \right] + \frac {2 \beta \bar {\nu} ^ {2} T}{n}, \tag {13} \\ \end{array} +$$ + +and, $\forall T\geq 1$ + +$$ +\begin{array}{l} \sum_ {t = 0} ^ {T} \mathbb {E} \left[ \| \mathbf {v} _ {t} - \nabla \mathbf {f} (\mathbf {x} _ {t}) \| ^ {2} \right] \\ \leq \frac {n \bar {\nu} ^ {2}}{\beta b _ {0}} + \frac {6 n L ^ {2} \alpha^ {2}}{\beta} \sum_ {t = 0} ^ {T - 1} \mathbb {E} \left[ \| \overline {{\mathbf {v}}} _ {t} \| ^ {2} \right] \\ + \frac {1 2 L ^ {2}}{\beta} \sum_ {t = 0} ^ {T} \mathbb {E} \left[ \left\| \mathbf {x} _ {t} - \mathbf {J} \mathbf {x} _ {t} \right\| ^ {2} \right] + 2 n \beta \bar {\nu} ^ {2} T. \tag {14} \\ \end{array} +$$ + +It can be observed that (13) in Lemma 7 may be used to refine the left hand side of (6). The remaining step, naturally, is to bound $\sum_{t}\mathbb{E}\left[\| \mathbf{x}_t - \mathbf{J}\mathbf{x}_t\| ^2\right]$ in terms of $\sum_{t}\mathbb{E}\left[\| \overline{\mathbf{v}}_t\| ^2\right]$ . This result is provided in the following lemma that is obtained with the help of Lemma 4, 5, 6, and 7. + +Lemma 8. If $0 < \alpha \leq \frac{(1 - \lambda^2)^2}{70\lambda^2L}$ and $\beta \in (0,1)$ , then the following inequality holds: $\forall T \geq 2$ , + +$$ +\begin{array}{l} \sum_ {t = 0} ^ {T} \frac {\mathbb {E} \left[ \| \mathbf {x} _ {t} - \mathbf {J} \mathbf {x} _ {t} \| ^ {2} \right]}{n} \leq \frac {2 0 1 6 \lambda^ {4} L ^ {2} \alpha^ {4}}{(1 - \lambda^ {2}) ^ {4}} \sum_ {t = 0} ^ {T - 2} \mathbb {E} \left[ \| \overline {{\mathbf {v}}} _ {t} \| ^ {2} \right] \\ + \frac {3 2 \lambda^ {4} \alpha^ {2}}{(1 - \lambda^ {2}) ^ {3}} \frac {\| \nabla \mathbf {f} (\mathbf {x} _ {0}) \| ^ {2}}{n} + \left(\frac {7 \beta}{1 - \lambda^ {2}} + 1\right) \frac {3 2 \lambda^ {4} \overline {{\nu}} ^ {2} \alpha^ {2}}{(1 - \lambda^ {2}) ^ {3} b _ {0}} \\ + \left(\frac {1 4 \beta}{1 - \lambda^ {2}} + 3\right) \frac {3 2 \lambda^ {4} \beta^ {2} \bar {\nu} ^ {2} \alpha^ {2} T}{(1 - \lambda^ {2}) ^ {3}}. \\ \end{array} +$$ + +Finally, we note that Lemma 7 and 8 suffice to establish (6) and hence lead to Theorem 1; see the Appendix for details. + +![](images/c0f7438a2fd917c4cb8b631204d4afb5e0320a5bd41ee13ba14a8e3952a2aa17.jpg) + +![](images/e6439ecf122ae7766cf3af58a3b1811d1f1a46ac993c800afa8a80b16e97cc5b.jpg) + +![](images/77cdf9264af9e36cb1aebd60dd7bcba8251f52e244a3c056f4c226fc7864ea03.jpg) +Figure 1. A comparison of GT-HSGD with other decentralized online stochastic gradient algorithms over the undirected exponential graph of 20 nodes on the a9a, covertype, KDD98, and MiniBooNE datasets. + +![](images/33b8892611c8f7330696a5f551a8294a9b8052005c6ab94794a16caf0ba10aa5.jpg) + +# 5. Numerical Experiments + +In this section, we illustrate our theoretical results on the convergence of the proposed GT-HSGD algorithm with the help of numerical experiments. + +Model. We consider a non-convex logistic regression model (Antoniadis et al., 2011) for decentralized binary classification. In particular, the decentralized non-convex optimization problem of interest takes the form $\min_{\mathbf{x} \in \mathbb{R}^p} F(\mathbf{x}) \coloneqq \frac{1}{n} \sum_{i=1}^{n} f_i(\mathbf{x}) + r(\mathbf{x})$ , such that + +$$ +f _ {i} (\mathbf {x}) = \frac {1}{m} \sum_ {j = 1} ^ {m} \log \left[ 1 + e ^ {- \langle \mathbf {x}, \pmb {\theta} _ {i j} \rangle l _ {i j}} \right] +$$ + +and + +$$ +r (\mathbf {x}) = R \sum_ {k = 1} ^ {p} \frac {[ \mathbf {x} ] _ {k} ^ {2}}{1 + [ \mathbf {x} ] _ {k} ^ {2}}, +$$ + +where $\theta_{i,j}$ is the feature vector, $l_{i,j} \in \{-1, +1\}$ is the corresponding binary label, and $r(\mathbf{x})$ is a non-convex regularizer. To simulate the online SFO setting described in Section 2, each node $i$ is only able to sample with replacement from its local data $\{\theta_{i,j}, l_{i,j}\}_{j=1}^{m}$ and compute the corresponding (minibatch) stochastic gradient. Throughout all experiments, we set the number of the nodes to $n = 20$ and the regularization parameter to $R = 10^{-4}$ . + +Data. To test the performance of the applicable decentralized algorithms, we distribute the a9a, covertype, KDD98, MiniBooNE datasets uniformly over the nodes and normalize the feature vectors such that $\| \pmb{\theta}_{i,j}\| = 1,\forall i,j$ . The statistics of these datasets are provided in Table 2. + +Table 2. Datasets used in numerical experiments, all available at https://www.openml.org/. + +
Datasettrain (nm)dimension (p)
a9a48,840123
covertype100,00054
KDD9875,000477
MiniBooNE100,00011
+ +Network topology. We consider the following network topologies: the undirected ring graph, the undirected and directed exponential graphs, and the complete graph; see (Nedic et al., 2018; Xin et al., 2020f; Assran et al., 2019; Lian et al., 2017) for detailed configurations of these graphs. For all graphs, the associated doubly stochastic weights are set to be equal. The resulting second largest singular value $\lambda$ of the weight matrices are 0.98, 0.75, 0.67, 0, respectively, demonstrating a significant difference in the algebraic connectivity of these graphs. + +Performance measure. We measure the performance of the decentralized algorithms in question by the decrease of the global cost function value $F(\overline{\mathbf{x}})$ , to which we refer as loss, versus epochs, where $\overline{\mathbf{x}} = \frac{1}{n}\sum_{i=1}^{n}\mathbf{x}_i$ with $\mathbf{x}_i$ being the model at node $i$ and each epoch contains $m$ stochastic gradient computations at each node. + +# 5.1. Comparison with the Existing Decentralized Stochastic Gradient Methods. + +We conduct a performance comparison of GT-HSGD with GT-DSGD (Pu & Nedich, 2020; Lu et al., 2019; Xin et al., 2020e), D-GET (Sun et al., 2020), and D-SPIDER-SFO (Pan et al., 2020) over the undirected exponential graph of 20 nodes. Note that we use GT-DSGD to represent methods that do not incorporate online variance reduction techniques, since it in general matches or outperforms DSGD (Lian et al., 2017) and has a similar performance with D2 (Tang et al., 2018) and D-PD-SGD (Yi et al., 2020). + +Parameter tuning. We set the parameters of GT-HSGD, GT-DSGD, D-GET, and D-SPIDER-SFO according to the following procedures. First, we find a very large step-size candidate set for each algorithm in comparison. Second, we choose the minibatch size candidate set for all algorithms as $\mathcal{B} \coloneqq \{1, 4, 8, 16, 32, 64, 128, 256, 512, 1024\}$ : the minibatch size of GT-DSGD, the minibatch size of GT-HSGD at $t = 0$ , the minibatch size of D-GET and D-SPIDER-SFO at inner- and outer-loop are all chosen from $\mathcal{B}$ . Third, for D-GET and D-SPIDER-SFO, we choose the inner-loop length candidate set as $\{\frac{m}{20b}, \frac{m}{19b}, \dots, \frac{m}{b}, \frac{2m}{b}, \dots, \frac{20m}{b}\}$ , where $m$ is the local data size and $b$ is the minibatch size at the inner-loop. Fourth, we iterate over all combinations of parameters for each algorithm to find its best performance. In particular, we find that the best performance of GT-HSGD is attained with a small $\beta$ and a relatively large $\alpha$ as Corollary 1 suggests. + +The experimental results are provided in Fig. 1, where we observe that GT-HSGD achieves faster convergence than the other algorithms in comparison on those four datasets. This observation is coherent with our main convergence results that GT-HSGD achieves a lower oracle complexity than the existing approaches; see Table 1. + +# 5.2. Topology-Independent Rate of GT-HSGD + +We test the performance of GT-HSGD over different network topologies. In particular, we follow the procedures described in Section 5.1 to find the best set of parameters for GT-HSGD over the complete graph and then use this parameter set for other graphs. The corresponding experimental results are presented in Fig. 2. Clearly, it can be observed that when the number of iterations is large enough, that is to say, the required error tolerance is small enough, the convergence rate of GT-HSGD is not affected by the + +![](images/1ae663df418b3d19a18df0a7b87aa11b3cafe6f7bc52ed52f49b58028696ecac.jpg) + +![](images/467b9ef4e15906b63f590e698ae21b92204de1f253ddb13a077be98578ba0b06.jpg) +Figure 2. Convergence behaviors of GT-HSGD over different network topologies on the a9a and covertype datasets. + +underlying network topology. This interesting phenomenon is consistent with our convergence theory; see Corollary 1 and the related discussion in Section 3. + +# 6. Conclusion + +In this paper, we investigate decentralized stochastic optimization to minimize a sum of smooth non-convex cost functions over a network of nodes. Assuming that each node has access to a stochastic first-order oracle, we propose GT-HSGD, a novel single-loop decentralized algorithm that leverages local hybrid variance reduction and gradient tracking to achieve provably fast convergence and robust performance. Compared with the existing online variance-reduced methods, GT-HSGD achieves a lower oracle complexity with a more practical implementation. We further show that GT-HSGD achieves a network topology-independent oracle complexity, when the required error tolerance is small enough, leading to a linear speedup with respect to the centralized optimal methods that execute on a single node. + +# Acknowledgments + +The work of Ran Xin and Soummya Kar was supported in part by NSF under Award #1513936. The work of Usman A. Khan was supported in part by NSF under Awards #1903972 and #1935555. + +# References + +Alghunaim, S. A., Ryu, E., Yuan, K., and Sayed, A. H. Decentralized proximal gradient algorithms with linear convergence rates. IEEE Trans. Autom. Control, 2020. +Antoniadis, A., Gijbels, I., and Nikolova, M. Penalized likelihood regression for generalized linear models with non-quadratic penalties. Annals of the Institute of Statistical Mathematics, 63(3):585-615, 2011. +Arjevani, Y., Carmon, Y., Duchi, J. C., Foster, D. J., Srebro, N., and Woodworth, B. Lower bounds for non-convex stochastic optimization. arXiv preprint arXiv:1912.02365, 2019. +Assran, M., Loizou, N., Ballas, N., and Rabbat, M. Stochastic gradient push for distributed deep learning. In Proceedings of the 36th International Conference on Machine Learning, pp. 97: 344-353, 2019. +Chen, J. and Sayed, A. H. On the learning behavior of adaptive networks—part i: Transient analysis. IEEE Transactions on Information Theory, 61(6):3487-3517, 2015. +Cutkosky, A. and Orabona, F. Momentum-based variance reduction in non-convex sgd. In Adv. Neural Inf. Process. Syst., pp. 15236-15245, 2019. +Di Lorenzo, P. and Scutari, G. NEXT: In-network nonconvex optimization. IEEE Trans. Signal Inf. Process. Netw. Process., 2(2):120-136, 2016. +Fang, C., Li, C. J., Lin, Z., and Zhang, T. SPIDER: near-optimal non-convex optimization via stochastic path-integrated differential estimator. In Proc. Adv. Neural Inf. Process. Syst., pp. 689-699, 2018. +Jakovetic, D. A unification and generalization of exact distributed first-order methods. IEEE Trans. Signal Inf. Process. Netw. Process., 5(1):31-46, 2018. +Kar, S., Moura, J. M. F., and Ramanan, K. Distributed parameter estimation in sensor networks: Nonlinear observation models and imperfect communication. IEEE Trans. Inf. Theory, 58(6):3575-3605, 2012. +Li, B., Cen, S., Chen, Y., and Chi, Y. Communication-efficient distributed optimization in networks with gradient tracking and variance reduction. J. Mach. Learn. Res., 21(180):1-51, 2020a. +Li, H. and Lin, Z. Revisiting extra for smooth distributed optimization. SIAM J. Optim., 30(3):1795-1821, 2020. +Li, H., Lin, Z., and Fang, Y. Optimal accelerated variance reduced EXTRA and DIGing for strongly convex and smooth decentralized optimization. arXiv preprint arXiv:2009.04373, 2020b. + +Li, Z., Shi, W., and Yan, M. A decentralized proximal-gradient method with network independent step-sizes and separated convergence rates. IEEE Trans. Signal Process., 67(17):4494-4506, 2019. +Lian, X., Zhang, C., Zhang, H., Hsieh, C.-J., Zhang, W., and Liu, J. Can decentralized algorithms outperform centralized algorithms? A case study for decentralized parallel stochastic gradient descent. In Adv. Neural Inf. Process. Syst., pp. 5330-5340, 2017. +Liu, D., Nguyen, L. M., and Tran-Dinh, Q. An optimal hybrid variance-reduced algorithm for stochastic composite nonconvex optimization. arXiv preprint arXiv:2008.09055, 2020. +Liu, Q., Liao, X., Li, H., and Huang, T. A computation-efficient decentralized algorithm for composite constrained optimization. IEEE Trans. Signal Inf. Process. Netw., 6:774-789, 2020. +Lu, S., Zhang, X., Sun, H., and Hong, M. GNSD: A gradient-tracking based nonconvex stochastic algorithm for decentralized optimization. In 2019 IEEE Data Science Workshop, pp. 315-321, 2019. +Mokhtari, A. and Ribeiro, A. DSA: Decentralized double stochastic averaging gradient algorithm. J. Mach. Learn. Res., 17(1):2165-2199, 2016. +Nedic, A. and Ozdaglar, A. Distributed subgradient methods for multi-agent optimization. IEEE Trans. Autom. Control, 54(1):48, 2009. +Nedic, A., Olshevsky, A., and Rabbat, M. G. Network topology and communication-computation tradeoffs in decentralized optimization. P. IEEE, 106(5):953-976, 2018. +Nedich, A., Olshovsky, A., and Shi, W. Achieving geometric convergence for distributed optimization over time-varying graphs. SIAM J. Optim., 27(4):2597-2633, 2017. +Nemirovski, A., Juditsky, A., Lan, G., and Shapiro, A. Robust stochastic approximation approach to stochastic programming. SIAM J. Optim., 19(4):1574-1609, 2009. +Nesterov, Y. Lectures on convex optimization, volume 137. Springer, 2018. +Nguyen, L. M., Liu, J., Scheinberg, K., and Takac, M. SARAH: A novel method for machine learning problems using stochastic recursive gradient. In Proc. 34th Int. Conf. Mach. Learn., pp. 2613-2621, 2017. +Pan, T., Liu, J., and Wang, J. D-SPIDER-SFO: A decentralized optimization algorithm with faster convergence rate + +for nonconvex problems. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pp. 1619-1626, 2020. +Pham, N. H., Nguyen, L. M., Phan, D. T., and Tran-Dinh, Q. ProxSARAH: an efficient algorithmic framework for stochastic composite nonconvex optimization. J. Mach. Learn. Res., 21(110):1-48, 2020. +Pu, S. and Nedich, A. Distributed stochastic gradient tracking methods. Math. Program., pp. 1-49, 2020. +Qu, G. and Li, N. Harnessing smoothness to accelerate distributed optimization. IEEE Trans. Control. Netw. Syst., 5(3):1245-1260, 2017. +Rajawat, K. and Kumar, C. A primal-dual framework for decentralized stochastic optimization. arXiv preprint arXiv:2012.04402, 2020. +Shi, W., Ling, Q., Wu, G., and Yin, W. EXTRA: An exact first-order algorithm for decentralized consensus optimization. SIAM J. Optim., 25(2):944-966, 2015. +Sun, H., Lu, S., and Hong, M. Improving the sample and communication complexity for decentralized non-convex optimization: Joint gradient estimation and tracking. In Proceedings of the 37th International Conference on Machine Learning, volume 119, pp. 9217-9228, 13-18 Jul 2020. +Taheri, H., Mokhtari, A., Hassani, H., and Pedarsani, R. Quantized decentralized stochastic learning over directed graphs. In International Conference on Machine Learning, pp. 9324-9333, 2020. +Tang, H., Lian, X., Yan, M., Zhang, C., and Liu, J. $D^2$ : Decentralized training over decentralized data. In International Conference on Machine Learning, pp. 4848-4856, 2018. +Tran-Dinh, Q., Pham, N. H., Phan, D. T., and Nguyen, L. M. A hybrid stochastic optimization framework for stochastic composite nonconvex optimization. Math. Program., 2020. +Tsitsiklis, J., Bertsekas, D., and Athans, M. Distributed asynchronous deterministic and stochastic gradient optimization algorithms. IEEE Trans. Autom. Control, 31(9): 803-812, 1986. +Vlaski, S. and Sayed, A. H. Distributed learning in nonconvex environments–Part II: Polynomial escape from saddle-points. arXiv:1907.01849, 2019. +Wang, Z., Ji, K., Zhou, Y., Liang, Y., and Tarokh, V. Spiderboost and momentum: Faster variance reduction algorithms. In Proc. Adv. Neural Inf. Process. Syst., pp. 2403-2413, 2019. + +Xi, C., Xin, R., and Khan, U. A. ADD-OPT: Accelerated distributed directed optimization. IEEE Trans. Autom. Control, 63(5):1329-1339, 2017. +Xin, R., Kar, S., and Khan, U. A. Decentralized stochastic optimization and machine learning: A unified variance-reduction framework for robust performance and fast convergence. IEEE Signal Process. Mag., 37(3):102-113, 2020a. +Xin, R., Khan, U. A., and Kar, S. A near-optimal stochastic gradient method for decentralized non-convex finite-sum optimization. arXiv preprint arXiv:2008.07428, 2020b. +Xin, R., Khan, U. A., and Kar, S. A fast randomized incremental gradient method for decentralized non-convex optimization. arXiv preprint arXiv:2011.03853, 2020c. +Xin, R., Khan, U. A., and Kar, S. Variance-reduced decentralized stochastic optimization with accelerated convergence. IEEE Trans. Signal Process., 68:6255-6271, 2020d. +Xin, R., Khan, U. A., and Kar, S. An improved convergence analysis for decentralized online stochastic non-convex optimization. arXiv preprint arXiv:2008.04195, 2020e. +Xin, R., Pu, S., Nedic, A., and Khan, U. A. A general framework for decentralized optimization with first-order methods. Proceedings of the IEEE, 108(11):1869-1889, 2020f. +Xu, J., Zhu, S., Soh, Y. C., and Xie, L. Augmented distributed gradient methods for multi-agent optimization under uncoordinated constant step sizes. In Proc. IEEE Conf. Decis. Control, pp. 2055-2060, 2015. +Xu, J., Tian, Y., Sun, Y., and Scutari, G. Distributed algorithms for composite optimization: Unified and tight convergence analysis. arXiv:2002.11534, 2020. +Yi, X., Zhang, S., Yang, T., Chai, T., and Johansson, K. H. A primal-dual SGD algorithm for distributed nonconvex optimization. arXiv preprint arXiv:2006.03474, 2020. +Yuan, K., Ying, B., Liu, J., and Sayed, A. H. Variance-reduced stochastic learning by networked agents under random reshuffling. IEEE Trans. Signal Process., 67(2): 351-366, 2018. +Yuan, K., Alghunaim, S. A., Ying, B., and Sayed, A. H. On the influence of bias-correction on distributed stochastic optimization. IEEE Trans. Signal Process., 2020. +Zhou, D., Xu, P., and Gu, Q. Stochastic nested variance reduction for nonconvex optimization. J. Mach. Learn. Res., 2020. \ No newline at end of file diff --git a/ahybridvariancereducedmethodfordecentralizedstochasticnonconvexoptimization/images.zip b/ahybridvariancereducedmethodfordecentralizedstochasticnonconvexoptimization/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..053a5a03ab981a9e074ec5c5f01f1023205aee21 --- /dev/null +++ b/ahybridvariancereducedmethodfordecentralizedstochasticnonconvexoptimization/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:775d434b426b0eecd0e396a381cf2d85f5db539ad725dbba694e51f9ca5f39fa +size 597159 diff --git a/ahybridvariancereducedmethodfordecentralizedstochasticnonconvexoptimization/layout.json b/ahybridvariancereducedmethodfordecentralizedstochasticnonconvexoptimization/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..967307eebc3545e1bd5a29e68aa3dec1aa031715 --- /dev/null +++ b/ahybridvariancereducedmethodfordecentralizedstochasticnonconvexoptimization/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:739ba94d14f4c6756d5c57a2d1ccfc567b5584c111ab10845a77abc46f6b608b +size 642007 diff --git a/alanguageforcounterfactualgenerativemodels/b0a48e9c-0122-476c-8124-a02bfcfddd7b_content_list.json b/alanguageforcounterfactualgenerativemodels/b0a48e9c-0122-476c-8124-a02bfcfddd7b_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..059ecf1c32e933049c0226799ee705c3c711ff7d --- /dev/null +++ b/alanguageforcounterfactualgenerativemodels/b0a48e9c-0122-476c-8124-a02bfcfddd7b_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:68bfdcaec5febd7775f8f90f345915ce2a62f3a0d1e5265bd01ccd4d5dc90265 +size 86301 diff --git a/alanguageforcounterfactualgenerativemodels/b0a48e9c-0122-476c-8124-a02bfcfddd7b_model.json b/alanguageforcounterfactualgenerativemodels/b0a48e9c-0122-476c-8124-a02bfcfddd7b_model.json new file mode 100644 index 0000000000000000000000000000000000000000..4359e6d89ec0ed17b7c9a2cd9723ff1ff4e99825 --- /dev/null +++ b/alanguageforcounterfactualgenerativemodels/b0a48e9c-0122-476c-8124-a02bfcfddd7b_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:efe74b566b631e9013b536e133ea80f469c1836468e6bd2dfe780c5ffb6f9434 +size 102607 diff --git a/alanguageforcounterfactualgenerativemodels/b0a48e9c-0122-476c-8124-a02bfcfddd7b_origin.pdf b/alanguageforcounterfactualgenerativemodels/b0a48e9c-0122-476c-8124-a02bfcfddd7b_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..e2e5caf0c12bd3af91bdb7c9f03e1e8f45eca198 --- /dev/null +++ b/alanguageforcounterfactualgenerativemodels/b0a48e9c-0122-476c-8124-a02bfcfddd7b_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4b4c4341410bfd106a2383cc3a4361e1597b4e77b9eeaf89d43bc309ffe9cf5f +size 2585394 diff --git a/alanguageforcounterfactualgenerativemodels/full.md b/alanguageforcounterfactualgenerativemodels/full.md new file mode 100644 index 0000000000000000000000000000000000000000..1200844b05ee340241caa2096e156943cf6f05b0 --- /dev/null +++ b/alanguageforcounterfactualgenerativemodels/full.md @@ -0,0 +1,429 @@ +Zenna Tavares1 James Koppel1 Xin Zhang2 Ria Das1 Armando Solar-Lezama1 + +# Abstract + +We present OMEGAC, a probabilistic programming language with support for counterfactual inference. Counterfactual inference means to observe some fact in the present, and infer what would have happened had some past intervention been taken, e.g. "given that medication was not effective at dose $x$ , what is the probability that it would have been effective at dose $2x$ ?" We accomplish this by introducing a new operator to probabilistic programming akin to Pearl's do, define its formal semantics, provide an implementation, and demonstrate its utility through examples in a variety of simulation models. + +# 1. Introduction + +In this paper we introduce $\mathrm{OMEGAC}$ : a Turing-universal programming language for causal reasoning. $\mathrm{OMEGAC}$ allows users to automatically derive causal inferences about phenomena modelled through simulation. This contribution focuses on using $\mathrm{OMEGAC}$ to compute counterfactuals - what-if causal inferences about the way the world could have been, had things been different. + +$\mathrm{OMEGAC}$ programs are simulation models augmented with probability distributions to represent uncertainty. In a similar vein to other probabilistic languages, $\mathrm{OMEGAC}$ provides primitive operators for conditioning, which revises the model to be consistent with observed evidence. Counterfactuals, however, cannot be expressed through probabilistic conditioning alone. They have the form: "Given that some evidence $E$ is true, what would $Y$ have been had $X$ been different?" For example, given that a drug treatment was not effective on a patient, would it have been effective at a stronger dosage? Although one can condition on $E$ being true, attempting to condition on $X$ being different to the + +![](images/490665c8f2e54f76d588b204c4ac88b9a0058c8596c5798852fb876a784a0df9.jpg) +Figure 1: A speeding driver (Left: driver's view) crashes into a pedestrian (yellow) emerging from behind an obstruction (blue). Given a single frame of camera footage (Right), $\mathrm{OMEGAC}$ infers whether driving below the speed limit would have prevented the crash. + +![](images/984857229424b26cc02d8126b533665fd5661e23ea6e781408c620e84f37ac83.jpg) + +value it actually took is contradictory. + +In order to express these hypothetical scenarios, OMEGAC introduces a do operator, which constructs interventions: + +$$ +Y \mid \mathbf {d o} (X \rightarrow x) \tag {1} +$$ + +This evaluates to what $Y$ would have been had $X$ been bound to $x$ when $Y$ was defined. Here, $X$ and $Y$ are program variables, typically bound to random variables. + +A counterfactual in $\mathrm{OMEGAC}$ is then simply an expression of the form $Y_{x} \mid E$ where $Y_{x} = Y \mid \mathbf{d}\mathbf{o}(X \to x)$ , i.e., one that contains both a condition and an intervention, in a particular pattern. The salient feature of this counterfactual pattern is that conditioning on $E$ revises the distribution over $Y$ (because $E$ is defined in terms of $Y$ , not $Y_{X}$ ), and it is to this revised distribution that a causal intervention is performed. The relative nesting of the condition and intervention reflects the fact that we want to intervene $Y$ but not on the evidence $E$ . + +To illustrate the potential of counterfactual reasoning within a universal programming language, consider the scenario of an expert witness called to determine, from only a frame of recorded video (Fig. 1), whether a driver was to blame for them crashing into a pedestrian. Using OMEGAC, the expert could first construct a probabilistic model that includes the car dynamics, the driver and pedestrian's behaviour, and a rendering function that produces two dimensional images + +from the three dimensional scene. She could then condition the model on the captured images to infer the conditional distribution over the driver's velocity, determining the probability that the driver had been speeding. Next, she could then pose a counterfactual in $\mathrm{OMEGA_C}$ , querying whether the crash would have still occurred even if the driver had obeyed the speed limit. If she later wanted to investigate the culpability of another candidate cause, such as the presence of an obstacle occluding the driver's view, she could do so by adding a single-line, and without modifying her underlying models at all. + +Causal reasoning is currently done predominantly using causal graphical models (21): graphs whose vertices are variables, and whose directed edges represent causal dependencies. Despite widespread use, causal graphs cannot easily express many real-world phenomena. One reason for this is that causal graphs are equivalent to straight-line programs: programs without conditional branching or loops – just finite sequences of primitive operations. Straight-line languages are not Turing-complete; they cannot express unbounded models with an unknown number of variables. In practice, they lack many of the features (composite functions, data types, polymorphism, etc.) necessary to express the kinds of simulation models we would like to perform causal inference in. + +$\mathrm{OMEGA_C}$ , in contrast, can express complex simulation models, but the design of a generic do operator presents several challenges. In particular, to construct $Y_{X}$ , we must be able to copy $Y$ in such a way that the code that defines it is retroactively modified. This goes beyond the capabilities of existing programming languages, probabilistic or otherwise, and hence $\mathrm{OMEGA_C}$ requires a non-standard semantics and implementation. + +In summary, we (i) present the syntax and semantics of a universal probabilistic language for counterfactual generative models (Section 3); (ii) provide a complete implementation of $\mathrm{OMEGAC}$ , and (iii) demonstrate counterfactual generative modelling through a number of examples (Section 5). Regarding scope, causal inference includes problems of both (i) inferring a causal model from data, and (ii) given a causal model, predicting the result of interventions and counterfactuals on that model. We focus here on the latter. + +# 2. Overview of Counterfactuals + +Counterfactual claims assume some structure is invariant between the original factual world and intervened hypothetical world. For instance, the counterfactual "If I had trained more, I would have won the match" is predicated on the invariance of the opponent's skill, the existence of the game, laws of physics, etc. Any system for counterfactual reasoning must provide mechanisms to construct hypothetical + +worlds that maintain invariances (and hence share information) with the factual world, so that for instance the fact that I actually lost the match helps predict whether I would have won the match had I trained harder. + +These requirements have been resolved in the context of causal graphical models. Causal interventions are "surgical procedures" which modify single nodes but leave functional dependencies intact. Pearl's twin-network construction (21) of counterfactuals duplicates the model into one twice the size. One half is the original model. The other half is a duplicate, modified to express the counterfactual interventions. These halves are joined via a shared dependence on the background facts. Hence, conditioning a variable in the factual world influences the counterfactual world. + +To generalize the twin-network construction to arbitrary programs, $\mathrm{OMEGA_C}$ runs two copies of a program, one factual execution, and one counterfactual execution which shares some variables, but where others have been given alternate definitions. It is folklore that programs doing this can be built by hand, but, as in the twin-network construction, each intervention requires writing a separate model, and each counterfactual included doubles the size of the program. The solution in $\mathrm{OMEGA_C}$ is to provide a new $\mathbf{do}$ operator which removes the need to modify an existing program to add a counterfactual execution. Instead, $t_1\mid \mathbf{do}(x\to t_2)$ is defined to be the value that a term $t_1$ would take if $x$ had been set to $t_2$ . This works even if any dependencies of $t_1$ on $x$ are indirect. For instance, if $y = 2x$ , then $y^2\mid \mathbf{do}(x\rightarrow f)$ is equivalent to $(2f)^2$ . And note that the variable $x$ can be any variable, even one that is bound to a function, meaning users can compactly define interventions which are substantial modifications. Finally, combining the operator with conditioning automatically gives counterfactual inference. + +Our examples show that $\mathrm{OMEGAC}$ enables compact definition of many counterfactual inference problems. Indeed, we prove that the do operator is not expressible as syntactic sugar (as defined by programming language theory). + +# 3. A Calculus for Counterfactuals + +Our language $\mathrm{OMEGA}_{\mathrm{C}}$ is a simple functional probabilistic language augmented to support counterfactuals. To achieve this: (1) the syntax includes a do operator, and (2) the language evaluation is lazy rather than eager, which is key to handling interventions. In this section, we introduce $\lambda_{C}$ , a core calculus of $\mathrm{OMEGA}_{\mathrm{C}}$ . After some preliminaries, we show the deterministic semantics of the language, followed by its probabilistic features. Together, intervention and conditioning give the language the ability to do counterfactual inference. Appendix A gives a more formal definition of the entire $\lambda_{C}$ language. A Julia implementation of $\mathrm{OMEGA}_{\mathrm{C}}$ can be found at https://github.com/zenna/0mega.jl, and + +a Haskell implementation of $\lambda_C$ can be found at https: //github.com/jkoppel/omega-calculus. + +Variables $x,y,z\in \mathrm{Var}$ + +$$ +\begin{array}{l} \text {T y p e} \tau := \operatorname {I n t} | \operatorname {B o o l} | \operatorname {R e a l} | \tau_ {1} \rightarrow \tau_ {2} \\ \text {T e r m} t := n \mid b \mid r \mid t _ {1} \oplus t _ {2} \mid x \mid \operatorname {l e t} x = t _ {1} \operatorname {i n} t _ {2} \\ \lambda x: \tau . t | t _ {1} (t _ {2}) | \text {i f} t _ {1} \text {t h e n} t _ {2} \text {e l s e} t _ {3} \\ \end{array} +$$ + +Figure 2: Abstract Syntax for $\lambda_C$ , deterministic fragment + +Preliminaries Here, we introduce the notation to describe the semantics of a simple deterministic programming language; Fig. 2 gives the syntax. We use the formalism of operational semantics (24) to describe how one expression reduces to another. Appendix A provides an operational semantics for $\mathrm{OMEGAC}$ . Here, we describe these reductions through examples. The execution of an expression is defined both in terms of the expression as well as the current program state. In $\lambda_{C}$ , this program state is an environment $\Gamma$ : a mapping from variables to values. + +$\lambda_C$ has integer numbers (denoted $n$ ), Booleans $\{\text{True, False}\}$ (denoted $b$ ), and real numbers $(r)$ . $\oplus$ represents a mathematical binary operator such as $+$ , *, etc. let $x = t_1$ in $t_2$ binds variable $x$ to expression $t_1$ when evaluating $t_2$ . Lambda expressions create functions: $\lambda x.2 * x$ defines a mapping $x \mapsto 2x$ . + +Next, we show the semantics of operators and let. The notation $\left\{ \begin{array}{l}\Gamma \\ e \end{array} \right\}$ denotes a pair of an environment $\Gamma$ and an expression $e$ , and $\left\{ \begin{array}{l}\Gamma_1\\ e_1 \end{array} \right\} \to \left\{ \begin{array}{l}\Gamma_2\\ e_2 \end{array} \right\}$ denotes that $e_1$ with environment $\Gamma_{1}$ steps to $e_2$ with environment $\Gamma_{2}$ . For example, in the expression let $x = 3$ in $x$ , $x$ is first bound to 3, creating a new environment. Finally, $x$ is evaluated by looking up its value in the environment. + +$$ +\left\{ \begin{array}{c} \Gamma : \emptyset \\ \mathbf {l e t} x = 3 \mathbf {i n} x \end{array} \right\} \to \left\{ \begin{array}{c} \Gamma : x \mapsto 3 \\ x \end{array} \right\} \to \left\{ \begin{array}{c} \Gamma : x \mapsto 3 \\ 3 \end{array} \right\} +$$ + +Function applications are done by substitution, as in other variants of the lambda calculus: + +$$ +\left\{ \begin{array}{c} \Gamma : \emptyset \\ (\lambda x. (x + x) (2) \end{array} \right\} \to \left\{ \begin{array}{c} \Gamma : \emptyset \\ 2 + 2 \end{array} \right\} \to \left\{ \begin{array}{c} \Gamma : \emptyset \\ 4 \end{array} \right\} +$$ + +The above semantics is eager: let $x = t_1$ in $t_2$ first evaluates $t_1$ and then binds the result to $x$ , creating a new environment in which to then evaluate $t_2$ . We next show how this is problematic for counterfactuals. and how we address it using lazy semantics. + +Deterministic OMEGAc OMEGAc adds a new term: the do expression (Fig. 3). $t_1 \mid \mathbf{d}\mathbf{o}(x \rightarrow t_2)$ evaluates $t_1$ to the + +value that it would have evaluated to, had $x$ been defined as $t_2$ at its point of definition. Here, $x$ can be any variable that is in scope, bound locally or globally, and $t$ can be any term denoting a value. One idea is to define $\mathbf{d}\mathbf{o}$ similarly to let: $t_1 \mid \mathbf{d}\mathbf{o}(x \to t_2)$ would rebind $x$ to $t_2$ when evaluating $t_1$ . However, this does account for transitive dependencies. For example, let $x = 0$ in let $y = x$ in $(y \mid \mathbf{d}\mathbf{o}(x \to 1))$ should evaluate to 1, but by the time we evaluate the $\mathbf{d}\mathbf{o}$ , $y$ has already been bound to 0 so that rebinding $x$ does nothing. To overcome this, we redefine let to use lazy evaluation. + +In lazy evaluation, instead of storing the value of a variable in the environment, the execution stores its defining expression as well as the environment when the variable is defined. So, while environments for eager evaluation store mappings $x \mapsto v$ from variable $x$ to value $v$ , in lazy evaluation, the environments store mappings $x \mapsto (\Gamma, e)$ , which map each variable $x$ to a closure containing both its defining expression $e$ and the environment $\Gamma$ in which it was defined. A variable, such as $x$ , is evaluated by evaluating its definition under the environment where it is defined. + +We can now define $\mathbf{do} \colon y \mid \mathbf{do}(x \to -1)$ evaluates $y$ under a new environment which is created by recursively mapping all bindings for $x$ in the current environment to $-1$ . This includes both the binding of $x$ at the top level and the bindings in an environment that is used in any closure. The following example demonstrates this process: + +$$ +\begin{array}{l} \left\{\begin{array}{c}\Gamma : \emptyset\\\text {l e t} x = 0 \text {i n} \text {l e t} y = x + 1 \text {i n} y + (y \mid \mathbf {d o} (x \rightarrow - 1))\end{array}\right\} \\ \xrightarrow {1} \left\{ \begin{array}{c} \Gamma : x \mapsto (\emptyset , 0) \\ \mathbf {l e t} y = x + 1 \mathbf {i n} y + (y | \mathbf {d o} (x \to - 1)) \end{array} \right\} \\ \stackrel {2} {\rightarrow} \left\{\begin{array}{c}\Gamma : x \mapsto (\emptyset , 0), y \mapsto (x \mapsto (\emptyset , 0), x + 1)\\y + (y | \mathbf {d o} (x \to - 1))\end{array}\right\} \\ \stackrel {3} {\rightarrow} \left\{\begin{array}{c}\Gamma : x \mapsto (\emptyset , 0), y \mapsto (x \mapsto (\emptyset , 0), x + 1)\\\left\{\begin{array}{c}\Gamma : x \mapsto (\emptyset , 0)\\x + 1\end{array}\right\} + (y \mid \mathbf {d o} (x \to - 1))\end{array}\right\} \\ \stackrel {{4}} {{\rightarrow}} \left\{\begin{array}{c}\Gamma : x \mapsto (\emptyset , 0), y \mapsto (x \mapsto (\emptyset , 0), x + 1)\\1 + (y | \mathbf {d o} (x \to - 1))\end{array}\right\} \\ \xrightarrow {5} \left\{ \begin{array}{c} \Gamma : x \mapsto (\emptyset , 0), y \mapsto (x \mapsto (\emptyset , 0), x + 1) \\ 1 + \left\{ \begin{array}{c} \Gamma : x \mapsto (\emptyset , 0), y \mapsto (x \mapsto (\emptyset , 0), x + 1) \\ (y | \mathbf {d o} (x \to - 1)) \end{array} \right\} \end{array} \right\} \\ \xrightarrow {6} \left\{ \begin{array}{c} \Gamma : x \mapsto (\emptyset , 0), y \mapsto (x \mapsto (\emptyset , 0), x + 1) \\ 1 + \left\{\stackrel {\Gamma : x \mapsto (\emptyset , - 1), y \mapsto (x \mapsto (\emptyset , - 1), x + 1)} {y} \right\} \end{array} \right\} \\ \stackrel {7} {\rightarrow} \left\{\begin{array}{c}\Gamma : x \mapsto (\emptyset , 0), y \mapsto (x \mapsto (\emptyset , 0), x + 1)\\1 + \left\{\frac {\Gamma : x \mapsto (\emptyset , - 1)}{x + 1} \right\}\end{array}\right\} \\ \stackrel {{8}} {{\rightarrow}} \left\{\begin{array}{c}\Gamma : x \mapsto (\emptyset , 0), y \mapsto (x \mapsto (\emptyset , 0), x + 1)\\1 + 0\end{array}\right\} \\ \stackrel {{9}} {{\to}} \left\{ \begin{array}{c} \Gamma : x \mapsto (\emptyset , 0), y \mapsto (x \mapsto (\emptyset , 0), x + 1) \\ 1 \end{array} \right\} \\ \end{array} +$$ + +$$ +\text {T e r m} t := \dots \mid t _ {1} \mid \mathbf {d o} (x \rightarrow t _ {2}) +$$ + +Figure 3: Abstract Syntax for $\lambda_{C}$ , causal fragment + +The program is evaluated under an empty environment. (1) Evaluating the outermost let binds $x$ to a closure $(\emptyset, 0)$ (consisting of the initial environment and $x$ 's definition). (2) $y$ is bound to a closure, containing the environment from step (1) and $y$ 's definition. The left operand of the addition is then evaluated, by first (3) looking up its closure in the environment, and then (4) evaluating its definition under the corresponding environment in the closure. To evaluate the do in the right operand, (5) the current environment is copied, and then (6) modified to rebind all definitions of $x$ to $-1$ . The right operand of the addition is a do expression of $y$ , which the execution tries to evaluate under the current environment, by (7) looking up the closure of $y$ in this "intervened" environment, and then (8) evaluating it. (9) The final result of the program is then 1. + +To implement do we introduce a procedure which we call retroactive-updating. Informally, this creates a new environment that rebinds all occurrences of the intervened variable within a closure to its intervened value. This is formally specified with respect to the operational semantics in the supplementary material. + +$$ +\text {T y p e} \tau : := \dots | \Omega \quad \text {T e r m} t: := \dots | \perp | t _ {1} | t _ {2} | \mathbf {r a n d} (t) +$$ + +Figure 4: Abstract Syntax for $\lambda_C$ , probabilistic fragment + +Probabilistic OMEGAC In probability theory, a random variable is a function from a sample space $\Omega$ to some domain $\tau$ . $\lambda_{C}$ defines random variables similarly: as functions of type $\Omega \to \tau$ . This separates the source of randomness of a program from its main body, which allows for a clean definition of counterfactuals. + +Fig. 4 shows the abstract syntax of the probabilistic fragment. It introduces a new type $\Omega$ , representing the sample space. $\Omega$ is left unspecified, save that it may be sampled from uniformly. In most applications, $\Omega$ will be a hypercube, with one dimension for each independent sample. To access the values of each dimension of this hypercube, one of the $\oplus$ operators must be the indexing operator [], so that $\omega[i]$ evaluates to the $i$ th component of $\omega$ . + +Random variables are normal functions. If $\Omega = [0,1]$ , and $a < b$ are integer constants, then $R = \lambda \omega : \Omega \cdot \omega * (b - a) + a$ is a random variable uniformly distributed in $[a,b]$ . The rand operator then samples from a random variable: rand $R$ returns a random value drawn uniformly from $[a,b]$ . Note that unlike in other probabilistic languages, we sepa + +rate the construction of random variables from their sampling. Consequently, rand does not occur in the definition of a random variable itself. + +To support conditioning, we use $\bot$ to denote the undefined value. Any expression (excluding rand) that depends on a $\bot$ value will result in another $\bot$ value. A program execution is invalid if it evaluates to $\bot$ . + +Conditioning can now be defined as syntactic sugar: $t \mid E$ is defined as $\lambda \omega$ . If $E(\omega)$ then $t(\omega)$ else $\bot$ . In words: if the evidence $E$ is false in scenario $\omega$ , then $t \mid E$ is undefined in that scenario. + +One can imagine the execution of a $\lambda_C$ program as a rejection sampling process: we ignore all samples from rand that would make the program evaluate to $\perp$ . In the implementation, we use a much more efficient inference algorithm (31). + +For example, let $\Omega = \{1,2,\dots ,10\}$ , and consider the program rand $\lambda \omega .\omega *2\mid \lambda \omega .\omega < 4$ . If $\omega \geq 4$ , then evaluating the random variable results in $\perp$ . The rand operator hence runs the variable with $\omega$ drawn uniformly from $\{1,2,3\}$ , resulting in 2, 4, or 6, each with $\frac{1}{3}$ probability. + +Counterfactuals A counterfactual is a random variable of the form $(t_1 \mid \mathbf{do}(x \rightarrow t_2)) \mid E$ . Consider the following program depicting a game where a player chooses a number $c$ , and then a number $\omega$ is drawn randomly from a sample space $\Omega = \{0, 1, \ldots, 6\}$ . He wins iff $c$ is within 1 of $\omega$ . The query asks: given that the player chose 1 and did not win, what would have happened, had the player chosen 4? + +$$ +l e t c = 1 i n +$$ + +$$ +\text {l e t} x = \lambda \omega . \text {i f} (\omega - c) * (\omega - c) < = 1 +$$ + +$$ +t h e n 1 e l s e - 1 i n +$$ + +$$ +\text {l e t} \operatorname {c f x} = (x | \operatorname {d o} (c \rightarrow 4)) | \lambda \omega . x (\omega) = = - 1) +$$ + +$$ +i n \quad r a n d (c f x) +$$ + +As before, the rand expression is evaluated in the context $\Gamma_1 = \{c \mapsto (\emptyset, 1), x \mapsto (c \mapsto \dots, \lambda \omega .\mathbf{if} \dots)\}$ . Its argument, a conditioning term, desugars to $\lambda \omega'$ . If $x(\omega') == -1$ then $(x \mid \mathbf{do}(c \rightarrow 4))(\omega')$ else $\perp$ . This random variable evaluates to $\perp$ for $\omega' \in \{0, 1, 2\}$ , so the program is evaluated with $\omega'$ drawn uniformly from $\{3, 4, 5, 6\}$ . The do expression $x \mid \mathbf{do}(c \rightarrow 4)$ is reduced to evaluating $x$ in the context $\Gamma_2 = \{c = \dots, x = (c \mapsto (\emptyset, 4), \lambda \omega .\mathbf{if} \dots)\}$ . This is then applied to $\omega'$ , and the overall computation hence evaluates to 1 with probability $\frac{3}{4}$ and $-1$ with probability $\frac{1}{4}$ . + +Syntactic Sugar $\mathrm{OMEG}_{\mathrm{C}}$ introduces some syntactic conveniences on top of $\lambda_{C}$ . Random variables are functions but it is convenient to treat them as if they were the values in their domains. To support this, $\mathrm{OMEG}_{\mathrm{C}}$ interprets the application of a function to one or more random variables pointwise – if both $X$ and $Y$ are random variables, then $X + Y$ is also a random variable defined as $\lambda \omega .X(\omega) + Y(\omega)$ . + +Similarly, if $x$ is a constant, then $X = x$ is $\lambda \omega .X(\omega) = x$ . In addition, $\mathrm{OMEG}_{\mathrm{C}}$ represents distribution families as functions from parameters to random variables. For instance, $\mathbf{bern} = \lambda p.\lambda \omega .\omega [1] < p$ represents the Bernoulli family by mapping a parameter $p \in [0,1]$ to a random variable that is true with probability $p$ . Finally, since $\lambda_{C}$ is purely functional, if $X = \mathbf{bern}(0.5)$ and $Y = \mathbf{bern}(0.5)$ , then $X$ and $Y$ are not only i.i.d. but the very same random variable, which is not often what we want. $\mathrm{OMEG}_{\mathrm{C}}$ defines the syntax $\sim X$ , so that in let $X \sim \mathbf{bern}(0.5), Y \sim \mathbf{bern}(0.5), X$ and $Y$ are independent. + +# 3.1. Other Composite Queries + +Conditioning and intervening can be composed arbitrarily. This allows us to express a variety of causal queries. + +To demonstrate, we adapt an example from (21), whereby (i) with probability $p$ , a court orders rifleman $A$ and $B$ to shoot a prisoner, (ii) $A$ 's calmness $C$ ranges uniformly from 1 (cool) to 0 (nervous), (iii) if $C$ falls below a threshold $q$ (and hence with probability $q$ ) $A$ nervously fires regardless of the order, and (iv) the prisoner dies $(D = 1)$ if either shoots. In OMEGA: + +$$ +\begin{array}{l} l e t p = 0. 7, q = 0. 3, \\ E = \sim \text {b e r n} (p), \quad \text {-- E x e c u t i o n o r d e r} \\ C = \sim \text {u n i f} (0, 1), \quad - - \text {C a l m n e s s} \\ N = C < q, \quad - - N e r v e s \\ A = E \text {o r} N, \quad - A \text {s h o o t s} \\ B = E, \quad \text {--} B \text {s h o o t s o n o r d e r} \\ D = A \text {o r} B \text {i n} \quad - - \text {P r i s o n e r D i e s} \\ \end{array} +$$ + +As we have seen, counterfactuals condition the real world and consider the implications in a hypothetical world, e.g.: + +-- Given $D$ , would $D$ be true had A not fired? + +$$ +\left(D \mid \mathbf {d o} (A \rightarrow \theta)\right) \mid D +$$ + +Non-atomic Interventions Atomic interventions, which replace a random variable with a constant, often do not reflect the kinds of interventions that have, or even could have, taken place in the real-world. Various non-atomic interventions are easily expressed in $\mathrm{OMEGA_C}$ : + +Conditional interventions (8) replace a variable with a deterministic function of other observable variables: + +-- if A's nerves had spread to B, would D occur? + +$$ +D \mid d o (B \rightarrow C < q) +$$ + +A mechanism change (32) alters the functional dependencies between variables. + +-- Would D occur if it took both shots to kill him? + +$$ +\left(D \mid \mathbf {d o} (D \rightarrow A a n d B)\right) \mid D +$$ + +Parametric interventions (9) alter, but do not break, causal dependencies. They are expressible by intervening a variable to be a function of its non-intervened self. + +-- If A were more calm, would D have occurred? + +$$ +D \mid d o (C \rightarrow C * 1. 2) +$$ + +Partial compliance (20) is where an intervention fails to have any effect with some probability: + +-- Would D have occurred had we attempted (and failed + +-- with probability s) to prevent A shooting? + +D | do(A $\rightarrow$ if \~ bern(s) then 0 else A) + +"Fat-hand" interventions (9) inadvertently (and probabilistically) affect some variables other than the intended ones: + +-- Would D be dead if we stopped A from firing and + +-- (with probability $r$ ) also prevented $B$ , too? + +D | do(A → Θ, B → if ~ bern(r) + +then 0 else B) + +# 4. Why do is not Syntactic Sugar + +In his influential thesis work, Felleisen (10) addressed the question of when a language construct is mere "syntactic sugar," vs. when it increases a language's power. In this, he provided the notions of expressibility and macro-expressibility. A language construct $F$ is expressible in terms of the rest of the language if the minimal subprograms containing $F$ can be rewritten to not use $F$ while preserving program semantics. Macro-expressibility further stipulates that these rewrites must be local. + +With these, he also provided an ingeniously simple proof technique: a construct is not macro-expressible if there are two expressions which are indistinguishable without the language construct (i.e.: they run the same when embedded into any larger program), but distinguishable with it. + +In the following theorem, we prove that we cannot implement the do operator as a syntactic sugar (i.e., macro) in the original OMEGA language. + +From our literature search, this is also the first time any variant of dynamic scope has been proven not macro-expressible in a language without dynamic scope. + +Theorem 1. The do operator is not macro-expressible in $\lambda_C$ without do. + +Proof. According to the proof technique of Felleisen (10), to show $\mathbf{d}\mathbf{o}$ is not macro-expressible in $\lambda_C$ without $\mathbf{d}\mathbf{o}$ , it suffices to find two expressions $P$ and $P'$ such that, for any evaluation context $C$ in $\lambda_C$ without $\mathbf{d}\mathbf{o}$ , $C[P] = C[P']$ , but such that there is an evaluation context $C$ in $\lambda_C$ with $\mathbf{d}\mathbf{o}$ such that $C[P] \neq C[P']$ . + +![](images/e97ce2f5af3aa3b447e3bd2555078bde75c860f94f273a00e9f01aaabb549fe7.jpg) +Figure 5: Traces of counterfactual scenarios through time. Each figure is a single sample from (Left) the posterior – the car crashes into the pedestrian, (Middle) the counterfactual on intervening the obstacle position, and (Right) intervening the driver speed. Each image shows the driver and car at (in decreasing transparency) at times 1, 9, and 19. +Figure 6: Histograms of causal effect of interventions. How close would the car have come to the pedestrian had (Left) the velocity been reduced to the speed limit $(\mathrm{CarV} \to 14)$ , or (Right) the obstacle been moved. Even at the speed limit, the driver still would have crashed with high probability. + +Let $P = \lambda f.\lambda x.(f0)$ , and $P^{\prime} = \lambda f.(\lambda a.\lambda x.a)(f0)$ . + +Note that all constructs of $\lambda_C$ except do and rand are macro-expressible in terms of the pure lambda calculus. After fixing a random seed, rand is also deterministic. Hence, with a fixed seed, $\lambda_C$ without do respects beta equivalence. Hence, since $P \equiv_{\beta} P'$ , for any context $C$ which does not contain do, $C[P] = C[P']$ . + +Now pick: + +$$ +C [ e ] = ((\lambda g. g 0 | \mathbf {d o} (p \rightarrow 1)) (e (\lambda x. p))) | \mathbf {d o} (p \rightarrow 0) +$$ + +Then $C[P] \Downarrow 1$ , but $C[P'] \Downarrow 0$ , where $\Downarrow$ is the reduction relation between terms. + +![](images/d50b4c1aeebd435328c7b1cf981b9c6c9b8c5d84c1a64deeb492b3d719981519.jpg) + +# 5. Experiments + +Here we demonstrate counterfactual reasoning in $\mathrm{OMEGA_C}$ through three case studies. All experiments were performed using predicate exchange (31). + +Car-Crash Model Continuing from the introduction, this example asks whether a crash would have occurred had a car driven more slowly, given observed camera footage. Let $S$ be the space of scenes, where each scene $s \in S$ consists of the position, velocity, and acceleration of the car, pedestrian and an obstacle. A ray-marching based (1) rendering function $r: S \to I$ maps a scene to an image. The driver acts according to a driver model - a function mapping $s \in S$ to a target acceleration: + +![](images/58a3028be0627b29d616504fc9e7263285cb85c1be2129d768856483c94ea514.jpg) +$\mathrm{d}(\mathrm{ped},\mathrm{car})$ + +![](images/b24a29a1eb807cd12a11ad76eb92e723b626aaa2efc4f3ccf5351936e54ddc66.jpg) +$\mathrm{d}(\mathrm{ped},\mathrm{car})$ + +# let + +```txt +drivermodel $=$ $\lambda$ car,ped,obs. if cansee(car,ped,obs)--if ped is visible then-9 --decelerate else0, --elsemaintain +``` + +The expert witness maintains random variables over the car's acceleration, velocity, and position at $t = 0$ . The function simulate returns state space trajectories of the form $(s_t, s_{t+1}, \ldots, s_n)$ . Since the initial scene is a random variable, Traj is a random variable over trajectories. Applying render to each scene in Traj yields a random variable over image trajectories. + +```latex +$\mathrm{CarV} = \sim$ normal(12, 4), + $\mathrm{CarP} = \sim$ normal(30, 5), + $\mathrm{PedV} = \sim$ normal(3, 1), + $\mathrm{PedP} = \sim$ normal(1, 2), + $\mathrm{InitScene} = (\mathrm{CarV}, \mathrm{CarP}, \mathrm{PedV}, \mathrm{PedP}, \mathrm{obs})$ , + $\mathrm{Traj} = \mathrm{simulate}(\mathrm{InitScene}, \mathrm{drivermodel})$ , + $\mathrm{Images} = \mathrm{map}(\mathrm{render}, \mathrm{Traj})$ , +``` + +We then ask the counterfactual, conditioning the $t_{obs}$ th image on observed data (Figure 1 right) and intervening $\mathrm{CarV} \rightarrow 14$ . + +```txt +$\mathsf{E} =$ (Images[t] == data) and crashed(Traj) +in (Traj | do(CarV $\rightarrow$ 14)) | E +``` + +We can also ask: would the crash have occurred had the obstacle been displaced? + +```txt +in (Traj | do(obs → obs - 3)) | E +``` + +Figures 5 and 6 visualize the posterior distributions over $d(\text{pred, car})$ , the (smallest) distance between the car and the pedestrian. + +Glucose Modelling This example queries whether a hypoglycemic episode could have been avoided in a diabetic patient. We first construct an ODE over variables captured + +in the Ohio Glucose dataset (17): (1) CGM: continuously monitored glucose measurements, (2) Steps: steps walked by patient, (3) Bolus: insulin injection events, and (4) Meals: calorie intake. The recursive function euler implements Euler's method to solve the ODE, taking as input an initial state $\mathbf{u}$ and derivative function $f'$ , and producing a time-series $(u_{t}, u_{t + \Delta t}, u_{t + 2\Delta t}, \ldots, u_{tmax})$ . + +```txt +let $t\theta = \theta$ , $\Delta t = 0.1$ ,tmax=1, $\tau = \lambda u$ ,t.u, --tointerveneu euler $=$ λf',u,t. let $u = \tau (u,t)$ ,tnext $= t + \Delta t$ in if $t < t_{max}$ then let unext $= u + f^{\prime}(tnext,u)*\Delta t$ in cons(u,euler(f',unext,tnext)) else u, +``` + +We pre-trained a neural network for the derivative function, and added normally distributed noise to the weights to introduce uncertainty, yielding $F'$ , a random variable over functions. Given $F'$ as input, euler produces a random variable over time-series. + +```javascript +Series $=$ euler(F', u, t0), +``` + +Now we can ask, had we eaten (increased food) at $t = 0.2$ , would the hypoglycemic event have occurred? We use the function $\tau$ to intervene. It maps $u$ at every time $t$ to a new value, since $u$ is internal to $euler$ . + +```txt +$\tau \mathrm{int} = \lambda \mathrm{u},\mathrm{t}.$ if $t = = 0.5$ then [u[1], u[2], inc(u[3])] else u, Series $=$ Series | do( $\tau \rightarrow \tau \mathrm{int}$ 1 +``` + +As a more exotic example, suppose we are told that someone has intervened, and hypoglycemia was avoided, but we do not know when the intervention occurred. We construct a distribution over the intervention time, then condition the intervened world to find the posterior over times. + +```haskell +CGM = first(Series), +-- Hypoglycemia occurs if $x$ is low at any time +Hypo = any(map(λ x . x < thresh, CGM)) +-- Prior over time of intervention +T = ~ unif(0, 1) +-- intervention increases food at time T +tau2 = λ ω . λ u, t. if t == T(ω) +then [u[1], u[2], inc(u[3])] else u +-- Condition on hypoglycemia not occurring +-- in intervened world +Hypoint = λ ω . +(Hypo | do(τ → tint2(ω)))(ω) +in CGM | ¬ Hypoint +``` + +As shown in Figure 7(c), it is more plausible that the intervention occurred early in the day. + +Counterfactual Planning Consider a dispute between three hypothetical islands (Figure 10): $S$ (South), $E$ (East) and $N$ (North). The people of $S$ consider a barrier between $S$ and $N$ , asking the counterfactual: given observed migration patterns, how would they differ had a border existed. + +We model this as a population of agents each acting according in accordance to a Markov Decision Process (25) (MDP) model. Each grid cell is a state in a state space $S = \{(i,j) \mid i = 1 \dots 7, j = 1 \dots 6\}$ . The action space moves an agent a single cell: $\mathcal{A} = \{\text{up, down, left, right}\}$ . Each agent acts according to a reward function that is a function of the state they are in only $R: S \to \mathbb{R}$ . This reward function is normally distributed, conditional on the country the agent originates from. For $t = 100$ timesteps we simulate the migration behavior of each individual using value iteration and count the amount of time spent in each country over the time period. Figure 8 shows population counts according to these dynamics. Figure 9 shows migration in the prior, after conditioning on an observed migration pattern (constructed artificially), and the counterfactual cases (adding the border). + +But-for Causality in Occlusion In this experiment, we implement "but-for" causation (13) to determine (i) whether a projectile's launch-angle is the cause of it hitting a ball, and (ii) occlusion, i.e. whether one object is the cause of an inability to see another. An event $C$ is the but-for cause of an event $E$ if had $C$ not occurred, neither would have $E$ (12). But-for judgements cannot be resolved by conditioning on the negation of $C$ , since this fails to differentiate cause from effect. Instead, the modeler must find an alternative world where $C$ does not hold. In $\mathrm{OMEGA}_{\mathrm{C}}$ , a value $\omega \in \Omega$ encompasses all the uncertainty, and hence we define but-for causality relative to a concrete value $\omega$ . + +Definition 1. Let $C_1, \ldots, C_n$ be a set of random variables and $c_1, \ldots, c_n$ a set of values. With respect to a world $\omega$ , the conjunction $C_1 = c_1 \wedge \dots \wedge C_n = c_n$ is the but-for cause of a predicate $E: \Omega \to \mathsf{Bool}$ if (i) it is true wrt $\omega$ and (ii) there exist $\hat{c}_1, \ldots, \hat{c}_n$ such that: + +$$ +(E \mid \mathbf {d o} (C _ {1} \rightarrow \hat {c} _ {1}, \dots , C _ {n} \rightarrow \hat {c} _ {n})) (\omega) = \text {F a l s e} \tag {2} +$$ + +$E(\omega) =$ True is a precondition, the effect must actually have occurred for but-for to be defined. + +But-for is defined existentially. To solve it, $\mathrm{OMEGAC}$ relies on predicate relaxation (31), which underlies inference in $\mathrm{OMEGAC}$ . That is, $E$ is a predicate that in (i) is true iff the projectile hits the ball, and in (ii) is true iff the yellow object is occluded in the scene, computed by tracing rays from the viewpoint and checking for intersections. Predicate relaxation transforms $E$ into soft predicate $\tilde{E}$ which returns a value in [0, 1] denoting how + +![](images/cb91fe5112f4e753616439cd8fa0a5a41ea97be6b778013e73848172b54fc8ba.jpg) +Figure 7: Glucose time series model. Dots are datapoints, trajectories sampled from prior. (Left) Prior samples, (Middle) Samples from interventional distributions under Meal $\rightarrow 5$ at $t = 0.20$ , (Right) Posterior over time $T$ of intervention given hypoglycemia did not occur after intervention. + +![](images/d15491962482f8536bdcd52ff954638d6eed88a334c66a937a7ffe94b9e5306d.jpg) + +![](images/dee0b5264eee4ec5cd3a15aa1c7dafe78c9dd72141b57c4f879ec7be7f772f6f.jpg) + +![](images/52e1a350013f9705332a998de005af8d59cdeae695c7ab61c954e53cbcbbffb3.jpg) +Figure 8: Map (i) without / (ii) with boundary. Sample from population counts after $n$ timesteps of MDP based migration. (iii) unconditional sample, (iv) conditional sample (v) counterfactual sample. + +![](images/9de15d7ca9cef045d5c5248ef3f054854259591cd917a18a6d36cfdd7d25a2f0.jpg) +Figure 9: Three samples of migration under three conditions. Each figure shows the migration from islanders born in $S$ , $N$ , or $E$ (y-axis) to $S$ , $N$ , $E$ , $W$ (water) or $B$ (barrier) on the x-axis. We accumulate all states visited in each persons' trajectory. (Plots 1 to 3 from left) Prior samples, (4 to 6) Conditioned on observations, (7 to 9) counterfactual: conditioned and with intervention (border). + +![](images/75e95a190279f157b897b357f5168b9df3fbaf4a82ae092d86f903f6047a5777.jpg) +Figure 10: But-for causality. Left to Right: stages of optimization to infer that grey-sphere is cause of inability to see yellow sphere, and launch-angle is cause of projectile colliding with ball. + +close $E$ is to being satisfied. Using this, our implementation uses gradient descent over $\hat{c}_1,\dots ,\hat{c}_n$ to minimize $(\tilde{E}\mid \mathbf{d o}(C_1\to \hat{c}_1,\ldots ,C_n\to \hat{c}_n))(\omega)$ . In (i) $\hat{c}_i$ is the launch-angle and in (ii) $\hat{c}_{x,y,z}$ is the position of the occluder. Finding $\hat{c}_i$ such that soft $E(\hat{c}_i) = 0$ confirms a but-for cause. In Figure 10 we present a visualization of the optimization, which ultimately infers that the angle is the cause of collision and the grey-sphere is the cause of the viewer's inability to see the yellow sphere. + +# 6. Related Work and Discussion + +Related work. Operators resembling do appear in existing PPLs. Venture (16) has a force expression [FORCE ] which modifies the current trace object (a mapping from random primitives to values) so that the simulation of takes on the value . It is intended as a tool for initialization and debugging. Pyro (5) and Anglican (34) have similar mechanisms. This can and has (18; 23) been used to compute counterfactuals by (i) approximating the posterior with samples, (ii) revising the model with an intervention, and then (ii) simulating the intervened model using the posterior samples instead of priors. + +The fundamental distinction is that in $\mathrm{OMEGAC}$ , the operators to condition and intervene both produce new random variables, which can then be further conditioned or intervened to produce counterfactual variables, which in turn can be either sampled from or reused in some other process. The Pyro approach, in contrast, computes counterfactual queries by performing inference first and then changing the model second. This has several practical consequences. Counterfactual queries in $\mathrm{OMEGAC}$ tend to be significantly more concise, and require none of the manualacks. More fundamentally, $\mathrm{OMEGAC}$ does not embed an inference procedure into the counterfactual model itself, which muddles the distinction between modelling and inference. In this vein, Pyro is similar to Metaverse (23), a recent Python based system, which mirrors Pearl's three steps of abduction, action and prediction, using importance sampling for inference. A downside of this approach is that it is difficult to create the kinds of composite queries we have demonstrated. We explore this in more detail in the Appendix. + +RankPL (27) uses ranking functions in place of numerical probability. It advertises support for causal inference, as a user can manually modify a program to change a variable definition. Baral et al. (4) described a recipe to encode counterfactuals in P-log, a probabilistic logic programming language. However, no language construct is provided to + +automate this process, which they call "intervention". There has also been work in adding causal operators to knowledge-based programming (11), answer-set programming (7), and logic programming (22). There are several libraries for causal inference on causal graphs (6; 28; 33; 3; 2). Whittimore (6) is an embedded Clojure DSL implementing the do-calculus (21). It can estimate the results of interventions, but not counterfactuals, from a dataset. + +Ibeling and Icard (14) introduce computable structural equation models (SEMs) to support infinite variable spaces, and prove that an axiomatization of counterfactuals is sound and complete. $\mathrm{OMEGA}_{\mathrm{C}}$ similarly supports open-world models, but our approach is constructive rather than axiomatic - we provide primitives to construct and compute counterfactuals. Ness et al. (19) relates SEMs to Markov process models, which are naturally expressible in $\mathrm{OMEGA}_{\mathrm{C}}$ . They introduce a novel kind of intervention that finds a change to induce a target post-equilibrium value. A version of this is expressible within $\mathrm{OMEGA}_{\mathrm{C}}-$ first construct a distribution over interventions, then condition that distribution on the target post-equilibrium value occurring. + +Alternative approaches. Some languages have inbuilt mechanisms for reflection – the ability to introspect and dynamically execute code, Python for instance includes getsource(foo) which returns the source code of a function foo. By extracting the source code of a model, transforming it, and reexecuting the result with eval, a system of interventions could be formulated. This could be a useful way to bring counterfactuals to existing languages such as Python which cannot support lazy evaluation. + +While we have presented a minimal language here, $\mathrm{OMEGAC}$ is also implemented in Julia. Since Julia is not lazy, it is less flexible than $\mathrm{OMEGAC}$ , suffering some of the limitations of Pyro. We detail this in the Appendix. + +Invariants in counterfactuals. An important property of counterfactual inference is that observations in the factual world carry over to the counterfactual world. This property is easy to satisfy in conventional causal graphs as all exogenous and endogenous variables are created and accessed statically. However, this is not true in $\mathrm{OMEGA}_{\mathrm{C}}$ as variable creation and access can be dynamic. Concretely, interventions can change the control-flow of a program, which in turn can cause mismatches between variable accesses in the factual world and ones in the counterfactual world. To address this issue, we tie variable identities to program structures. Appendix B discusses this in detail. + +Limitations. Procedures such as the PC algorithm (30) handle situations where a causal relationship exists, but nothing is known about the relationship other than that it is an arbitrary function. Like other probabilistic programming languages, $\mathrm{OMEGA_C}$ cannot reason about such models. + +In some cases the variable we want to intervene is internal to some function and not in scope at the point where we want to construct an intervention. In other cases, the value we want to intervene (e.g. $(\mathbf{x} + 2)$ in $2*(\mathbf{x} + 2)$ is not bound to a variable at all. While it is always possible to manually modify the program to expose these inaccessible values, future work is to increase the expressiveness of $\mathrm{OMEGA_C}$ to be able to automatically intervene in such cases. Since our formalism relies on variable binding, this would require an entirely different mechanism to what we have presented. + +# References + +[1] Differentiable Path Tracing on the TPU. https://blog.evjang.com/2019/11/jaxpt.html. Accessed: 2021-01-01. +[2] ggdag. https://ggdag.malco.io/. Accessed: 2019-03-08. +[3] pgmpy. http://pgmpy.org/. Accessed: 2019-03-08. +[4] Chitta Baral and Matt Hunsaker. Using the Probabilistic Logic Programming Language P-log for Causal and Counterfactual Reasoning and Non-Naive conditioning. In *IJCAI* 2007, Proceedings of the 20th International Joint Conference on Artificial Intelligence, Hyderabad, India, January 6-12, 2007, pages 243-249, 2007. +[5] Eli Bingham, Jonathan P. Chen, Martin Jankowiak, Fritz Obermeyer, Neeraj Pradhan, Theofanis Karalettos, Rohit Singh, Paul Szerlip, Paul Horsfall, and Noah D. Goodman. Pyro: Deep Universal Probabilistic Programming. Journal of Machine Learning Research, 2018. +[6] Joshua Brule. Whittemore: An Embedded Domain Specific Language for Causal Programming. arXiv preprint arXiv:1812.11918, 2018. +[7] Pedro Cabalar. Causal Logic Programming. In Correct Reasoning, pages 102-116. Springer, 2012. +[8] Juan Correa and Elias Bareinboim. A Calculus for Stochastic Interventions: Causal Effect Identification and Surrogate experiments. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pages 10093-10100, 2020. +[9] Frederick Eberhardt and Richard Scheines. Interventions and Causal Inference. Philosophy of Science, 74(5):981-995, 2007. +[10] Matthias Felleisen. On the Expressive Power of Programming Languages. In *ESOP'90, 3rd European Symposium on Programming*, Copenhagen, Denmark, May 15-18, 1990, Proceedings, pages 134-151, 1990. + +[11] Joseph Halpern and Yoram Moses. Using Counterfactuals in Knowledge-Based Programming. volume 17, pages 97-110, 07 1998. +[12] Joseph Y Halpern and Christopher Hitchcock. Actual Causation and the Art of Modeling. arXiv preprint arXiv:1106.2652, 2011. +[13] Daniel M Hausman, Herbert a Simon, et al. Causal Asymmetries. Cambridge University Press, 1998. +[14] Duligur Ibeling and Thomas Icard. On Open-Universal Causal Reasoning. In Uncertainty in Artificial Intelligence, pages 1233–1243. PMLR, 2020. +[15] Oleg Kiselyov, Chung-chieh Shan, and Amr Sabry. Delimited Dynamic Binding. In Proceedings of the 11th ACM SIGPLAN International Conference on Functional Programming, ICFP 2006, Portland, Oregon, USA, September 16-21, 2006, pages 26-37, 2006. +[16] Vikash Mansinghka, Daniel Selsam, and Yura Perov. Venture: A Higher-Order Probabilistic Programming Platform with Programmable Inference. arXiv preprint arXiv:1404.0099, 2014. +[17] Cindy Marling and Razvan C Bunescu. The OhioT1DM Dataset for Blood Glucose Level Prediction. In KHD@IJCAI, 2018. +[18] Robert Ness. Lecture Notes for Causality in Machine Learning, Section 9.6: "Bayesian counterfactual algorithm with SMCs in Pyro", 2019. +[19] Robert Osazuwa Ness, Kaushal Paneri, and Olga Vitek. Integrating Markov processes with Structural causal Modeling Enables Counterfactual Inference in Complex Systems. arXiv preprint arXiv:1911.02175, 2019. +[20] Judea Pearl. From Bayesian networks to Causal Networks. In Mathematical models for handling partial knowledge in artificial intelligence, pages 157-182. Springer, 1995. +[21] Judea Pearl. Causality. Cambridge University Press, 2009. +[22] Luís Moniz Pereira and Ari Saptawijaya. Agent Morality via Counterfactuals in Logic Programming. In Proceedings of the Workshop on Bridging the Gap between Human and Automated Reasoning - Is Logic and Automated Reasoning a Foundation for Human Reasoning? co-located with 39th Annual Meeting of the Cognitive Science Society (CogSci 2017), London, UK, July 26, 2017., pages 39-53, 2017. +[23] Yura Perov, Logan Graham, Kostis Gourgoulias, Jonathan Richens, Ciaran Lee, Adam Baker, and + +Saurabh Johri. Multiverse: Causal Reasoning Using Importance Sampling in Probabilistic Programming. In Symposium on advances in approximate bayesian inference, pages 1-36. PMLR, 2020. +[24] Gordon D Plotkin. A Structural Approach to Operational Semantics. 1981. +[25] Martin L Puterman. Markov Decision Processes: Discrete Stochastic Dynamic Programming. John Wiley & Sons, 2014. +[26] Jarrett Revels, Valentin Churavy, Tim Besard, Lyndon White, Twan Koolen, Mike J Innes, Nathan Daly, Rogerluo, Robin Deits, Morten Piibeleht, Moritz Schauer, Kristoffer Carlsson, Keno Fischer, and Chris de Graaf. jreveils/cassette.jl: v0.3.3, April 2020. +[27] Tjitze Rienstra. RankPL: A Qualitative Probabilistic Programming Language. In European Conference on Symbolic and Quantitative Approaches to Reasoning and Uncertainty, pages 470-479. Springer, 2017. +[28] Amit Sharma and Emre Kiciman. DoWhy: Making Causal Inference Easy. https://github.com/Microsoft/dowhy, 2018. +[29] Yehonathan Sharvit. Lazy Sequences are not Compatible with Dynamic Scope. https://blog.klipse.tech/clojure/2018/12/25/dynamic-scope-clojure.html, 2018. +[30] Peter Spirtes, Clark N Glymour, Richard Scheines, David Heckerman, Christopher Meek, Gregory Cooper, and Thomas Richardson. Causation, Prediction, and Search. MIT press, 2000. +[31] Zenna Tavares, Javier Burroni, Edgar Minaysan, Armando Solar Lezama, and Rajesh Ranganath. Predicate Exchange: Inference with Declarative Knowledge. In International Conference on Machine Learning, 2019. +[32] Jin Tian and Judea Pearl. Causal Discovery from Changes. arXiv preprint arXiv:1301.2312, 2013. +[33] Santtu Tikka and Juha Karvanen. Identifying Causal Effects with the R Package causaleffect. Journal of Statistical Software, 76(1):1-30, 2017. +[34] David Tolpin, Jan-Willem van de Meent, and Frank Wood. Probabilistic Programming in Anglican. In Joint European Conference on Machine Learning and Knowledge Discovery in Databases, pages 308-311. Springer, 2015. \ No newline at end of file diff --git a/alanguageforcounterfactualgenerativemodels/images.zip b/alanguageforcounterfactualgenerativemodels/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..bd11f8943247e81927fb51a865d0a841b56989c7 --- /dev/null +++ b/alanguageforcounterfactualgenerativemodels/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3aef3665525980da735a15766a26734fa27e92ba084480958463dc2ea3b2fd2e +size 272251 diff --git a/alanguageforcounterfactualgenerativemodels/layout.json b/alanguageforcounterfactualgenerativemodels/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..e9c23ecbe786d991a7f52eb545c05134c35bc80e --- /dev/null +++ b/alanguageforcounterfactualgenerativemodels/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:07863333481cbced1bb2aaa764e50555b65d3dcba854c4e8bfe6324fa260188f +size 647803